Skip to content

Instantly share code, notes, and snippets.

View wenjianhn's full-sized avatar
🐢

Jian Wen wenjianhn

🐢
  • Xiaomi
  • Beijing, China
  • 06:32 (UTC +08:00)
View GitHub Profile
@rohityadavcloud
rohityadavcloud / updateddns
Created January 9, 2016 12:05
CloudFlare DDNS
[email protected]
cfkey=cf-key-here
zoneid=some-zoneid
dnsrec=dns-record-id
domain=somedomain.com
curl -X PUT "https://api.cloudflare.com/client/v4/zones/$zoneid/dns_records/$dnsrec" \
-H "X-Auth-Email: $cfuser" \
-H "X-Auth-Key: $cfkey" \
-H "Content-Type: application/json" \
@GABeech
GABeech / haproxy.cfg
Created August 21, 2014 18:35
Stack Exchange HAProxy
# This is an example of the Stack Exchange Tier 1 HAProxy config
# The only things that have been changed from what we are running are:
# 1. User names have been removed
# 2. All Passwords have been remove
# 3. IPs have been changed to use the example/documentation ranges
# 4. Rate limit numbers have been changed to randome numbers, don't read into them
userlist stats-auth
group admin users $admin_user
user $admin_user insecure-password $some_password
@cryptix
cryptix / client.go
Created June 22, 2014 11:09
multipart upload with io.Pipe
package main
import (
"io"
"log"
"mime/multipart"
"net/http"
"os"
"path/filepath"
"runtime"
@leverich
leverich / track.stp
Created April 9, 2014 17:07
Systemtap script to trace latency of concurrent memcached requests as they percolate through the Linux kernel.
# Systemtap script to trace latency of concurrent memcached requests
# as they percolate through the Linux kernel.
# - Jacob Leverich <[email protected]> 2013
#
# Note: You MUST call this script with "-x <TID>" where TID is the
# *task id* of a memcached worker thread. This is usually PID+1 of
# memcached. So do something like:
#
# % memcached -t 1 -d
# % pgrep memcached
@vishvananda
vishvananda / tunnel.sh
Created October 22, 2013 03:16
Script to set up an ipsec tunnel between two machines For Example: ./tunnel.sh 10.10.10.1 10.10.10.2 192.168.0.1 192.168.0.2 would set up an ipsec tunnel over 10.10.10.1 address using 192.168.0.1 as a virtual address passwordless sudo required for user on remote machine
#!/bin/bash
if [ "$4" == "" ]; then
echo "usage: $0 <local_ip> <remote_ip> <new_local_ip> <new_remote_ip>"
echo "creates an ipsec tunnel between two machines"
exit 1
fi
SRC="$1"; shift
DST="$1"; shift
@audreyt
audreyt / posa.mkdn
Last active November 28, 2022 21:24
EtherCalc.tw

從 SocialCalc 到 EtherCalc

先前在《開源應用程式架構》 一書中,我介紹了 SocialCalc 這個在瀏覽器中運行的試算表編輯器,以取代伺服器為中心的 WikiCalc 架構。SocialCalc 在瀏覽器中執行所有的運算,只有在載入和儲存試算表時才會使用伺服器。

追求效能是 Socialtext 團隊在 2006 年時設計 SocialCalc 的主要目的。重點在於:在 JavaScript 環境下執行客戶端運算,儘管在當年的速度僅有伺服器端 Perl 運算的十分之一,但仍然勝過 AJAX 來回傳輸資料造成的網路延遲:


WikiCalc 與 SocialCalc 架構比較

******
@giannitedesco
giannitedesco / tbf.py
Created October 1, 2012 10:02
python: Token bucket filter with burst and sleep
#!/usr/bin/python
class TokenBucket:
from time import sleep, time
def __init__(self, rate, burst = None):
'Rate in tokens per second, burst in number of tokens'
self.rate = float(rate)
if burst is None:
@tumf
tumf / gist:1354282
Created November 10, 2011 06:42
static ip 設定用シェルスクリプト
# ./vif eth1 10.10.1.1
cat <<EOF > /etc/sysconfig/network-scripts/ifcfg-$1
DEVICE=$1
BOOTPROTO=static
NETMASK=255.255.255.0
IPADDR=$2
ONBOOT=yes
EOF
cat /etc/sysconfig/network-scripts/ifcfg-$1
@eqhmcow
eqhmcow / hfsc-shape.sh
Last active October 22, 2024 13:55
HFSC - linux traffic shaping's best kept secret
#!/bin/bash
# As the "bufferbloat" folks have recently re-discovered and/or more widely
# publicized, congestion avoidance algorithms (such as those found in TCP) do
# a great job of allowing network endpoints to negotiate transfer rates that
# maximize a link's bandwidth usage without unduly penalizing any particular
# stream. This allows bulk transfer streams to use the maximum available
# bandwidth without affecting the latency of non-bulk (e.g. interactive)
# streams.