Skip to content

Instantly share code, notes, and snippets.

View ninehills's full-sized avatar

Tao Yang ninehills

View GitHub Profile
@maliubiao
maliubiao / tcpinfo.py
Last active August 29, 2015 14:05
功能: 1, 获取系统当前所有的tcp链接信息, 2: 找到绑定某个端口的进程tcpinfo.port_to_pid(port)
import os
import struct
import socket
state_table = (
"EMPTY SLOT",
"ESTABLISHED",
"SENT",
"RECV",
"WAIT1",
@leemars
leemars / sync.sh
Created July 5, 2012 02:50
Git -> SVN sync script
#!/bin/bash
if [[ $# != 1 && $# != 2 ]]
then
echo "$0 <path to git repository> [tree-ish]"
exit 1
fi
msg() {
echo -e -n "\e[32;1m==>\e[0m "
@ninehills
ninehills / backgroudmix.py
Last active December 10, 2015 17:08 — forked from methane/gist:2185380
tornado add block task to ThreadPool
from time import sleep
import tornado
from multiprocessing.pool import ThreadPool
_workers = ThreadPool(10)
class BackgroundMix(tornado.web.RequestHandler):
"""将block任务放入线程池中执行
EXAMPLE:
# blocking task like querying to MySQL
@ninehills
ninehills / mactype_win8.md
Last active June 19, 2016 02:26
win8使用MacType
@dongweiming
dongweiming / benchmarks.ipynb
Created March 16, 2015 02:27
benchmarks.ipynb
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@ninehills
ninehills / sshgfw
Created July 30, 2010 05:03 — forked from fuckgfw/sshgfw
linux下ssh翻墙断线重连
#!/usr/bin/expect
set timeout 60
spawn /usr/bin/ssh -D 7070 -g username@yourserver.com
#这里的 username 为你自己的用户名,yourserver.com 为你自己的服务器域名或ip
expect {
"password:" {
send "password\r"
#将第二个 password 改为你自己的密码
}
@ninehills
ninehills / delay
Created March 9, 2011 10:32
Linux下用来延时执行命令的小脚本
#!/bin/bash
# 参数1:延迟的时间,单位s
# 参数2:需要执行的命令
# example:
# delay 10 "conky -d"
sleep $1
exec $2
@huacnlee
huacnlee / nginx.conf
Created September 14, 2011 13:50
Nginx http proxy cache to mirror of Rubygems.org
# 在本地服务器建立 rubygems.org 的镜像缓存,以提高 gem 的安装速度
# 此配置设置缓存过期为1天,也就是说,新上的 gem 无法马上安装
# 做这个起什么作用?
# rubygems 的很多资源文件是存放到 Amazon S3 上面的,由于 GFW 对某些 S3 服务器又连接重置或丢包,导致 gem 安装异常缓慢或有时候根本无法连接安装。
# 而通过这种跳板的方式可以很好的解决这个问题,当然前提是 Nginx反向代理 服务器需要在国外
proxy_cache_path /var/cache/rubygems levels=1:2 keys_zone=RUBYGEMS:10m
inactive=24h max_size=1g;
server {
listen 80;
@drsnyder
drsnyder / urandom-reads.py
Last active August 11, 2021 10:44
Demonstrate the contention on /dev/urandom with N threads.
# Create a user land file for testing.
# dd if=/dev/urandom of=/tmp/urandom bs=1M count=10
#
# urandom-reads.py infile threads
# Examples:
# time python2.6 urandom-reads.py /tmp/urandom
# time python2.6 urandom-reads.py /dev/urandom
#
# R to generate a plot of the read time distribution at each level of concurrency
# rdt = read.csv("output.csv", header=F)
@troelskn
troelskn / app.rb
Last active August 12, 2021 17:25 — forked from dstrelau/app.rb
Gollum protected by HTTP Basic
require 'gollum/frontend/app'
require 'digest/sha1'
class App < Precious::App
User = Struct.new(:name, :email, :password_hash, :can_write)
before { authenticate! }
before /^\/(edit|create|delete|livepreview|revert)/ do authorize_write! ; end
helpers do