This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
[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" \ |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"io" | |
"log" | |
"mime/multipart" | |
"net/http" | |
"os" | |
"path/filepath" | |
"runtime" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# 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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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 |
先前在《開源應用程式架構》 一書中,我介紹了 SocialCalc 這個在瀏覽器中運行的試算表編輯器,以取代伺服器為中心的 WikiCalc 架構。SocialCalc 在瀏覽器中執行所有的運算,只有在載入和儲存試算表時才會使用伺服器。
追求效能是 Socialtext 團隊在 2006 年時設計 SocialCalc 的主要目的。重點在於:在 JavaScript 環境下執行客戶端運算,儘管在當年的速度僅有伺服器端 Perl 運算的十分之一,但仍然勝過 AJAX 來回傳輸資料造成的網路延遲:
******
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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: |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# ./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 |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/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. |
NewerOlder