我正在尝试使用jcrop保存裁剪的图像,基于x,y,w,h.我发送到我的PHP文件,轴x,y和宽度/高度,但裁剪区域是错误的.
这是我的php功能
$axis_x = $_POST["x"];
$axis_y = $_POST["y"];
$width = $_POST["w"];
$height = $_POST["h"];
$path_foto = "imgs/3.jpg";
$targ_w = $width;
$targ_h = $height;
$jpeg_quality = 90;
$src = $path_foto;
$img_r = imagecreatefromjpeg($src);
$dst_r = ImageCreateTrueColor($targ_w, $targ_h);
imagecopyresampled($dst_r, $img_r, 0, 0, $axis_x, $axis_y, $width, $targ_w, $targ_h, $height);
imagejpeg($dst_r, $path_foto, $jpeg_quality);
Run Code Online (Sandbox Code Playgroud)
每当图像被重新显示时,此坐标由jcrop在每次隐藏的输入中设置.问题始终是错误的区域.
我做错了什么?
我正在编写一些客户端/服务器风格的程序.现在我正在开发服务器端,我打开一个套接字.
但是,我需要知道谁在我的插座中连接.什么IP连接.因为我需要输入在服务器上连接的日志.
所以,我的问题是如何在C中执行此操作?使用Linux.
我尝试使用getsockopt()但不起作用.我是网络编程的新手.
有人知道我该怎么办?
这是我的socket的代码:
int init_socket() {
/** Declara um socket */
Socket sock;
/** Inicia o socket */
sock.socket = socket(AF_INET, SOCK_STREAM, 0);
/** Seta zeros no sockaddr */
memset(&sock.server, 0, sizeof (sock.server));
/** E tambem no buffer */
memset(sock.buff, 0, sizeof (sock.buff));
/** Seta os valores do sockaddr */
sock.server.sin_family = AF_INET;
sock.server.sin_addr.s_addr = htonl(INADDR_ANY);
//sock.server.sin_port = htons(get_config_int(&conf, "monitor_port"));
sock.server.sin_port = htons(2200);
/** Chama o bind */
bind(sock.socket, (struct sockaddr*) &sock.server, sizeof (sock.server));
/* …Run Code Online (Sandbox Code Playgroud) 我遇到了在 Nginx 上运行 SSE 的问题。我有一个正在使用 Flask 的 Web 应用程序,并且我正在使用一个名为flask-sse将事件发送到 JS 端的模块。
我用来gunicorn处理请求,我将其作为 Nginx 配置:
upstream backend {
server 127.0.0.1:5000;
keepalive 100;
}
server {
listen 80;
access_log /var/log/nginx/client-access.log;
error_log /var/log/nginx/client-error.log;
location / {
include proxy_params;
proxy_pass http://backend;
proxy_buffering off;
proxy_cache off;
proxy_set_header Host $host;
proxy_set_header Upgrade $http_upgrade;
proxy_set_header Connection "upgrade";
proxy_http_version 1.1;
chunked_transfer_encoding off;
proxy_request_buffering off;
}
}
Run Code Online (Sandbox Code Playgroud)
接收事件的端点已打开/stream。通过查看 Nginx 日志,我发现到此端点的第一次连接始终是 504 错误,如下所示:
10.2.2.254 - - [09/Apr/2018:09:06:14 +0000] "GET /stream HTTP/1.1" 504 585 "http://address/results" …
我在C中构建一个程序,它是一个控制台,我使用libreadline来帮助我构建这个控制台.一切正常,但当我收到一个ctrl-d,我得到一个分段错误.
我可以弄清楚如何处理这个,我曾尝试使用signal.h来做到这一点,但不起作用.
下面是我的一段代码.
int init_console(char * ip, int port) {
/** Variaveis que serão utilizadas */
char * str_command;
char * filename = malloc(100);
Client * cli = malloc(sizeof (Client));
/** Monta o filename do arquivo de histórico */
strcpy(filename, getenv("HOME"));
strcat(filename, HISTORY_FILE);
/** Inicializa o histórico de comandos */
using_history();
/** Inicializa o readline */
rl_initialize();
/** Seta o número de comandos a serem guardados */
stifle_history(10);
/** Habilita o auto completation */
rl_inhibit_completion = true;
/** …Run Code Online (Sandbox Code Playgroud) 我正在使用CKEditor为我所在的某些文本区域创建一个所见即所得。
关键是,在站点的注释部分中,我将加载CKEditor的表单的DOM移动到<div>我站点中的另一个DOM,以在下面显示将由用户编辑的注释。
因此,当CKEditor出现在另一个div中时,没有任何作用。我无法编辑内容,按钮也不起作用。
对于上下文,我这样做:
<div class='ckeditor-hidden'>
<form action="/" class="form-edit-content">
<textarea id="someid"></textarea>
</form>
</div>
<div class="div-where-ckeditor-will-be-placed">
</div>
Run Code Online (Sandbox Code Playgroud)
在jQuery中,我这样做:
$(".form-edit-content").appendTo(".div-where-ckeditor-will-be-placed");
Run Code Online (Sandbox Code Playgroud)
现在,为什么我要这样做?因为我在网站的不同位置使用相同的表单,所以这就是我移动它们的原因。
因此,当我移动时,CKEditor现在可以工作了。
要知道,我在我的网站上使用Drupal 7,并且安装了适用于Drupal的Module CKEditor(https://www.drupal.org/project/ckeditor)。
有人知道为什么会这样吗?
我正在尝试这个简单的例子来使用 Kivy 播放视频:
from kivy.app import App
from kivy.uix.videoplayer import VideoPlayer
class TestApp(App):
vid = None
def replay(self, instance, value):
if value != "play":
# self.vid.play = True
self.vid.state = "play"
def build(self):
self.vid = VideoPlayer(source="./S02E02.mp4", state="play")
# self.vid.bind(state=self.replay) # When state changes, if not playing, play it
return self.vid
TestApp().run()
Run Code Online (Sandbox Code Playgroud)
但视频未加载和播放。我有这个作为输出:
[INFO ] [Logger ] Record log in /home/villar/.kivy/logs/kivy_18-08-16_13.txt
[INFO ] [Kivy ] v1.10.1
[INFO ] [Python ] v3.6.5 (default, Apr 1 2018, 05:46:30)
[GCC 7.3.0]
[INFO ] [Factory …Run Code Online (Sandbox Code Playgroud) 我正在使用valgrind在我的系统上找到内存泄漏,我收到了这个输出
==9697== Memcheck, a memory error detector
==9697== Copyright (C) 2002-2011, and GNU GPL'd, by Julian Seward et al.
==9697== Using Valgrind-3.7.0 and LibVEX; rerun with -h for copyright info
==9697== Command: bin/vfirewall-monitor
==9697==
==9697==
==9697== HEAP SUMMARY:
==9697== in use at exit: 0 bytes in 0 blocks
==9697== total heap usage: 1 allocs, 1 frees, 37 bytes allocated
==9697==
==9697== All heap blocks were freed -- no leaks are possible
==9697==
==9697== For counts of detected and suppressed errors, …Run Code Online (Sandbox Code Playgroud) 我正在使用 Spring Boot 开始使用 Apache Kafka。我想实现以下事实:同一服务的两个实例以循环方式消耗同一主题的消息。
因此,实例 1 接收主题的第一条消息,实例 2 接收第二条消息,实例 1 接收第三条消息,依此类推。
这是我当前的配置:
spring:
kafka:
consumer:
bootstrap-servers: rommel.local:9092
group-id: core
auto-offset-reset: earliest
key-deserializer: org.apache.kafka.common.serialization.StringDeserializer
value-deserializer: org.apache.kafka.common.serialization.StringDeserializer
enable-auto-commit: false
producer:
bootstrap-servers: rommel.local:9092
key-serializer: org.apache.kafka.common.serialization.StringSerializer
value-serializer: org.apache.kafka.common.serialization.StringSerializer
listener:
missing-topics-fatal: false
ack-mode: record
Run Code Online (Sandbox Code Playgroud)
这是我的听众:
@KafkaListener(topics = "new-topic", groupId = "core")
public void consume(String payload) {
System.out.println("Data received: " + payload);
}
Run Code Online (Sandbox Code Playgroud)
问题是,当我运行应用程序的两个实例时,只有一个实例收到该主题的消息。
我在日志中意识到了这一点:
Instance 1:
core: partitions assigned: [new-topic-0]
Run Code Online (Sandbox Code Playgroud)
Instance 2:
core: partitions assigned: []
Run Code Online (Sandbox Code Playgroud)
那么当我杀死实例1时。被new-topic-0分配给实例 2。
那么如何实现两个实例循环获取同一主题消息的场景呢?
谢谢!!
我在我的C程序中收到一个奇怪的SIGABRT,这是我出现问题的函数:
int get_interface_mac_addr(Interface* iface) {
char arquivo[10];
sprintf(arquivo, "/sys/class/net/%s/address", iface->interface_name);
int fd;
fd = open(arquivo, O_RDONLY, 0);
char buf[100];
read(fd, buf, sizeof (buf));
buf[strlen(buf) - 1] = '\0';
strcpy(iface->interface_mac_addr, buf);
close(fd);
return GET_MAC_ADDR_SUCCESS;
}
Run Code Online (Sandbox Code Playgroud)
错误发生在最后一行代码"}".
我尝试使用GDB进行调试,但我是新手,所以我不理解GDB告诉我的很多事情.以下是GDB的输出:
Core was generated by `./vfirewall-monitor'.
Program terminated with signal 6, Aborted.
#0 0x00007f36c043b425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
64 ../nptl/sysdeps/unix/sysv/linux/raise.c: No such file or directory.
(gdb) bt
#0 0x00007f36c043b425 in __GI_raise (sig=<optimized out>) at ../nptl/sysdeps/unix/sysv/linux/raise.c:64
#1 0x00007f36c043eb8b in __GI_abort () at abort.c:91
#2 …Run Code Online (Sandbox Code Playgroud)