V2EX = way to explore
V2EX 是一个关于分享和探索的地方
现在注册
已注册用户请  登录
V2EX  ›  XiaoxiaoPu  ›  全部回复第 30 页 / 共 39 页
回复总数  776
1 ... 22  23  24  25  26  27  28  29  30  31 ... 39  
2016-04-21 00:07:19 +08:00
回复了 brando 创建的主题 NGINX Nginx 反向代理问题之二
@brando 我在反代 Transmission 的 Web 界面时这么写是可以用的。会不会是你的应用跳转的?比如 302 ,前端 js 跳转,你可以执行 curl -vv http://abc.hello.com/ 看一下。
2016-04-20 23:43:24 +08:00
回复了 brando 创建的主题 NGINX Nginx 反向代理问题之二
试试下面的

server
{
listen 80;
server_name abc.hello.com;

location / {
rewrite ^/(.*)$ /abc/$1 break;
proxy_set_header Host $host;
proxy_set_header X-Real-IP $remote_addr;
proxy_set_header X-Forwarded-For $proxy_add_x_forwarded_for;
proxy_pass http://192.168.1.12:8080/;
}
access_log /var/log/nginx/abc_access.log;
error_log /var/log/nginx/abc_error.log;
}
2016-04-20 22:37:13 +08:00
回复了 xiaoz 创建的主题 硬件 占美 mini 主机到啦,开箱体验
问下楼主,这个机器的固件是 BIOS 还是 UEFI ?你说安装过程有点小曲折,能否详细说下呢?多谢。
2016-04-13 10:55:26 +08:00
回复了 webdev 创建的主题 问与答 中国的所有 ip 地址范围
2016-04-03 20:57:58 +08:00
回复了 abelyao 创建的主题 SSL 请教一下 Let's Encrypt 的 DNS 方式验证的流程(或原理)?
2016-03-06 17:01:29 +08:00
回复了 tangyang 创建的主题 问与答 哪个压缩软件可以设置压缩效率
楼主的目的是这个帖子吧 https://www.v2ex.com/t/261451#reply4 ,可以考虑只用 tar 打包,但是不压缩,如果一定要压缩,可以在低峰期批量压缩,或者把未压缩的文件传输到一台专门的机器上再压缩
2016-02-25 00:41:39 +08:00
回复了 SlipStupig 创建的主题 Python 编码挑战:求一千万自然数中质数和
啊哦,上面发的错了,这个才对

#include <stdio.h>
#include <string.h>
#include <stdlib.h>


static inline int getbit(int *bits, int i)
{
return (bits[i>>5] >> (i & 31)) & 1;
}

static inline void setbit(int *bits, int i)
{
bits[i>>5] |= (1 << (i & 31));
}

static inline void clrbit(int *bits, int i)
{
bits[i>>5] &= ~(1 << (i & 31));
}

int isqrt(int num)
{
register int x1 = num, x2;

do
{
x2 = x1;
x1 = (x1 + num / x1) / 2;
} while (x1 < x2);
return x2;
}


int main()
{
int n = 10000000;
int *bits;

bits = (int *)malloc(((n>>5)+1) * sizeof(int));
if (bits == NULL)
{
fprintf(stderr, "Out of memory.\n");
return 1;
}

for (int i = 0; i < ((n>>5)+1); i++)
{
bits[i] = ~0;
}

clrbit(bits, 0);
clrbit(bits, 1);
clrbit(bits, 4);

int end = isqrt(n);
for (int i = 2; i <= end; i++)
{
if (getbit(bits, i))
{
int j0 = n / i;
for (int j = 2; j <= j0; j++)
{
clrbit(bits, i * j);
}
}
}

long sum = 0;
for (int i = 2; i <= n; i++)
{
if (getbit(bits, i))
{
sum += i;
}
}
printf("%ld\n", sum);

return 0;
}


➜ ~ gcc -o prime -std=gnu99 -O3 prime.c
➜ ~ ./prime
3203324994356
➜ ~
2016-02-25 00:39:34 +08:00
回复了 SlipStupig 创建的主题 Python 编码挑战:求一千万自然数中质数和
#include <stdio.h>
#include <string.h>
#include <stdlib.h>


static inline int getbit(int *bits, int i)
{
return (bits[i>>5] >> (i & 31)) & 1;
}

static inline void setbit(int *bits, int i)
{
bits[i>>5] |= (1 << (i & 31));
}

static inline void clrbit(int *bits, int i)
{
bits[i>>5] &= ~(1 << (i & 31));
}

int isqrt(int num)
{
register int x1 = num, x2;

do
{
x2 = x1;
x1 = (x1 + num / x1) / 2;
} while (x1 < x2);
return x2;
}


int main()
{
int n = 10000000;
int *bits;

bits = (int *)malloc(((n>>5)+1) * sizeof(int));
if (bits == NULL)
{
fprintf(stderr, "Out of memory.\n");
return 1;
}

for (int i = 0; i < ((n>>5)+1); i++)
{
bits[i] = ~0;
}

clrbit(bits, 0);
clrbit(bits, 1);
clrbit(bits, 4);

int end = isqrt(n);
long sum = 0;
for (int i = 2; i <= end; i++)
{
if (getbit(bits, i))
{
sum += i;
int j0 = n / i;
for (int j = 2; j <= j0; j++)
{
clrbit(bits, i * j);
}
}
}

printf("%ld\n", sum);

return 0;
}



发个 C 写的
➜ ~ gcc -o prime -std=gnu99 -O3 prime.c
➜ ~ time ./prime
642869
./prime 0.04s user 0.00s system 94% cpu 0.046 total
➜ ~
2016-02-23 23:02:01 +08:00
回复了 quietin 创建的主题 Python socket 的客户端发送空字符与主动关闭是否有区别
@quietin 以用 read 函数读取 socket 为例:对于 socket 连接的*阻塞*读请求, 1: 如果对端没有写数据,那么会一直阻塞直到后面两种情况发生, 2: 如果接收到对端写的数据,那么会返回这次请求接收的数据的字节数, 3: 如果对端关闭连接\结束写操作(即发送 FIN),那么会返回 0 。你说的客户端发送空字符的情况,说法是不准确的, socket 上发送或接受的都是字节流,要么有数据,要么没数据,无所谓数据的内容,只看数据的字节数。
2016-02-20 16:39:57 +08:00
回复了 holinhot 创建的主题 问与答 为什么国内的 dns 都不让编辑 ns 记录和 soa 记录
@holinhot 域名只要能解析,肯定知道用的是哪个 NS ,藏不了的。另外要投诉的话,直接找域名的注册商不是更直接?
2016-02-02 01:17:19 +08:00
回复了 sneezry 创建的主题 分享发现 80、443 端口无法使用时使用 Let’s Encrypt 签发证书
写了个 Python3 脚本自动调用 DnsPod API
https://gist.github.com/XiaoxiaoPu/d69f99fcebe49f3af843
保存为 dnspod.py ,修改 111, 112 行的登录邮箱、密码、域名,在 hook.sh 的 deploy_challenge 函数中写上

./dnspod.py "${DOMAIN}" "${TOKEN_VALUE}"
sleep 3

欢迎使用&建议
@abutter lzo 是线程安全的,问题已解决,与 lzo 无关。
@zhczhy
1. http://www.oberhumer.com/opensource/lzo/
2. 很多变量紧接着就被赋值了,感觉没必要声明时就初始化。除此之外还有哪里规范性太差呢?
3. 只在本文件用到的函数为什么不写成 static ,万一跟其他文件的符号重名了怎么办?
4. DUP_LEN 是要作为数组长度的,改成 const 的话 gcc 会编译不通过
@kezhuw 非常感谢,我试试。我理解的,重入时如果只修改局部变量,那么不会有问题,这样可能问题在于 minilzo 在压缩时访问全局变量了,我在看下。再次感谢!
找到没有 coredump 的原因了,要生成 suid 程序的 coredump ,需要执行 sudo sysctl fs.suid_dumpable=1 才行
@mzer0 “弄了一堆什么用都没有的文件”,那你说说看,哪个文件是多余的没有用的?你说的都是莫名其妙的点,这我肯定无法接受。
1 ... 22  23  24  25  26  27  28  29  30  31 ... 39  
关于   ·   帮助文档   ·   博客   ·   API   ·   FAQ   ·   实用小工具   ·   2509 人在线   最高记录 6679   ·     Select Language
创意工作者们的社区
World is powered by solitude
VERSION: 3.9.8.5 · 32ms · UTC 12:20 · PVG 20:20 · LAX 05:20 · JFK 08:20
Developed with CodeLauncher
♥ Do have faith in what you're doing.