Skip to content

Instantly share code, notes, and snippets.

@rainly
rainly / gist:553f3c73141ee07179cc93f2342866f0
Created January 16, 2017 13:16 — forked from zhuowater/gist:1046096
python BP ANN 神经网络
#!/usr/bin/env python
# -*- coding: utf-8 -*-
import math,random
import numpy as np
def rand(a, b):
return (b-a)*random.random() + a
def dtanh(y):
return 1.0-y*y
def mat(x):
@rainly
rainly / linux-http-tcp.md
Created October 21, 2016 08:10 — forked from v5tech/linux-http-tcp.md
linux下查看http 并发和 tcp连接数

linux查看httpd进程数

ps -ef | grep httpd | wc -l

查看Apache的并发请求数及其TCP连接状态

netstat -n | awk '/^tcp/ {++S[$NF]} END {for(a in S) print a, S[a]}'
@rainly
rainly / latency.markdown
Created October 14, 2016 07:30 — forked from hellerbarde/latency.markdown
Latency numbers every programmer should know

Latency numbers every programmer should know

L1 cache reference ......................... 0.5 ns
Branch mispredict ............................ 5 ns
L2 cache reference ........................... 7 ns
Mutex lock/unlock ........................... 25 ns
Main memory reference ...................... 100 ns             
Compress 1K bytes with Zippy ............. 3,000 ns  =   3 µs
Send 2K bytes over 1 Gbps network ....... 20,000 ns  =  20 µs
SSD random read ........................ 150,000 ns  = 150 µs

Read 1 MB sequentially from memory ..... 250,000 ns = 250 µs

@rainly
rainly / dns2https.php
Created October 8, 2016 13:21 — forked from diyism/dns2https.php
dns2https.php
<?php
/*
tcp dns client for google dns over https (https://dns.google.com)
ubuntu上使用:
在/etc/rc.local里加/usr/bin/php /home/<your_name>/dns2https.php
执行:
sysv-rc-conf unbound off
sysv-rc-conf dnscrypt-proxy off
@rainly
rainly / git_action_set_tutor.md
Created May 8, 2016 07:39 — forked from pastleo/git_action_set_tutor.md
My Git Action Sets & Tutorials

My Git Action Sets & Tutorial

Init the git repo

  • git clone <url> [path]
  • git init

Trouble-Free Actions

@rainly
rainly / sysctl.conf
Created April 17, 2016 16:31 — forked from kgriffs/sysctl.conf
Linux Web Server Kernel Tuning
# Configuration file for runtime kernel parameters.
# See sysctl.conf(5) for more information.
# See also http://www.nateware.com/linux-network-tuning-for-2013.html for
# an explanation about some of these parameters, and instructions for
# a few other tweaks outside this file.
# Protection from SYN flood attack.
net.ipv4.tcp_syncookies = 1
@rainly
rainly / test long-poll server
Created April 15, 2016 07:43 — forked from diyism/test long-poll server
test long-poll server, test hight concurrency
===========================================httperf===========================
apache bench常碰到"apr_poll: The timeout specified has expired (70007) ",
测试行业里常用httperf+autobench(有bench2graph生成性能图表):
(共10000连接,每秒10000个连接,每连接1个请求(就没必要分bursts来发了,即connection-oriented或request-oriented workload下--burst-length是在connection之内pipeline)):
httperf --hog --num-conns 10000 --rate 10000 --num-calls=1 --timeout 20 --server 127.0.0.1 --port 8888 --uri /
等同(共1次会话,每秒1次会话,每次会话10000请求,分若干bursts,每bursts含10000个请求,每bursts间隔1秒,每连接最多1请求,最大连接数10000,
max-connections大于4需要修改httperf/src/gen/session.c为#define MAX_CONN 65536,即session-oriented workload下--burst-length肯能是一个connection内pipeline也可能跨connection):
httperf --hog --wsess=1,10000,1 --rate 1 --burst-length=10000 --max-piped-calls 1 --max-connections=10000 --timeout 20 --server 127.0.0.1 --port 8888 --uri /
#发出超过3000个并行连接PC还是会报"*** buffer overflow detected ***: httperf terminated",不知怎么解决
#"--hog" means to use all available ports to create connection
# xcode-build-bump.sh
# @desc Auto-increment the build number every time the project is run.
# @usage
# 1. Select: your Target in Xcode
# 2. Select: Build Phases Tab
# 3. Select: Add Build Phase -> Add Run Script
# 4. Paste code below in to new "Run Script" section
# 5. Drag the "Run Script" below "Link Binaries With Libraries"
# 6. Insure that your starting build number is set to a whole integer and not a float (e.g. 1, not 1.0)
一.积累大量TIME_WAIT连接无法接受新请求:
比较安全的设置是/etc/sysctl.conf:
net.ipv4.tcp_timestamps=1
net.ipv4.tcp_tw_recycle=0
net.ipv4.tcp_tw_reuse=1
sysctl net.ipv4.tcp_max_tw_buckets=10000
参考: http://nick.txtcc.com/index.php/linux/1162
二.启动iptables一两个小时后出现大量丢包:
/var/log/messages出现大量nf_conntrack: table full, dropping packet.
  1. DOS usb boot -> peppermint live iso usb boot
  2. diskgenius for dos -> fdisk, gnome-disks
  3. norton ghost for dos -> "fsarchiver savefs" "fsarchiver restfs", remastersys
  4. windows xp -> peppermint 4, lubuntu 13.04
  5. ntldr boot.ini -> grub menu.lst, boot-repair
  6. RemapKey/KeyTweak -> xmodmap -pke > ~/.Xmodmap then modify it, it will be loaded automatically
  7. myboard.exe -> myboard.py + modified xorg-server + modified libgtk2.0-0 + fcitx-googlepinyin
  8. MagicMover(D:\Program Files) -> remastersys restored sda1 + UnionFS-FUSE(pivot_root) sda2
  9. WinHex -> wxHexEditor
  10. emEditor(PHP/C braces outline, csv editor) -> sublime(ctrl+r to list functions, AlignTab package, SublimeCodeIntel package)