This file contains hidden or 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
# install on ubuntu | |
apt-get install iperf | |
# The quality of a link can be tested as follows: | |
# - Latency (response time or RTT): can be measured with the Ping command. | |
# - Jitter (latency variation): can be measured with an Iperf UDP test. | |
# - Datagram loss: can be measured with an Iperf UDP test. | |
# udp test | |
iptables -I INPUT -p udp --dport 5001 -j ACCEPT # firewall exclusion |
This file contains hidden or 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
./forward.sh 192.30.253.113 80 172.1.9.1 9000 | |
./forward.sh 192.30.253.113 443 172.1.9.1 9000 | |
vim forward.sh | |
# setup virtual ips | |
# detect os | |
if [ "$(uname -a | cut -d' ' -f1)" == "Linux" ]; then # Ubuntu | |
sudo ifconfig eth0:1 172.1.9.1 up | |
sudo ifconfig eth0:2 172.1.9.2 up | |
elif [ "$(uname -a | cut -d' ' -f1)" == "Darwin" ]; then # OS/X |
This file contains hidden or 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/env bash | |
# | |
# Whale: a simpler interface for docker cli | |
# LICENSE: GPLv3 | |
# | |
# - `whale build` # builds Dockerfile in current directory | |
# - `whale run` # runs last `whale build` container | |
# - `whale buildrun` # same as `whale build && whale run` | |
# - `whale sh` # opens `/bin/ash` on last `whale build` container (you can optionally specify another shell like `/bin/bash` as the first argument) | |
# - `whale buildrun -p 8080:80` # build and run the container with options |
This file contains hidden or 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
// use like: forEachAsyncSerial(Post.find(), (next, post) => { /* ... */ next(); }, () => { /* done! */ }); | |
static forEachAsyncSerial(a, each_cb, done_cb) { | |
let i = 0; | |
const next = () => { | |
if (i >= a.length || false === each_cb(next, a[i++])) { | |
if ('function' == typeof done_cb) done_cb(); | |
} | |
}; | |
process.nextTick(next); | |
} |
This file contains hidden or 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
# /etc/init/recover-swap.conf | |
# author: mike smullin <mike dot smullin at wildworks dot com> | |
# see also: http://askubuntu.com/a/90399 | |
# usage: start recover-swap; tailf /var/log/upstart/recover-swap.log | |
# | |
# WARNING: it is a little bit dangerous to swapoff while your service is still running; | |
# means OOM killer may come reap your process if it need to swap again while swapoff is going, | |
# which does take over an hour in our case. | |
# |
This file contains hidden or 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
// RxJava example | |
String names[] = new String[]{ "Ben", "George" }; | |
rx.Observable.from(names).subscribe((String s) -> { | |
System.out.println("Hey "+s+"!"); | |
}); |
This file contains hidden or 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
SELECT table_schema, table_name AS "Tables", | |
round(((data_length + index_length) / 1024 / 1024), 2) "Size in MB" | |
FROM information_schema.TABLES | |
ORDER BY (data_length + index_length) DESC | |
LIMIT 10; |
This file contains hidden or 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
module.exports = | |
class async | |
@serial: (a, cb) -> | |
return cb() unless a.length | |
a.push cb | |
(next = (err, result) -> | |
if err or 1 is a.length | |
a[a.length-1] err, result | |
a = [] | |
return |
This file contains hidden or 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
# oversimplified asynchronous flow control | |
module.exports = new: -> | |
Q = [] | |
Q.then = (fn, args...) -> Q.push(-> args.push Q.next; fn.apply null, args); @ | |
Q.next = (err) -> Q.splice 0, Q.length-1 if err; Q.shift()?.apply null, arguments | |
Q.finally = (fn, args...) -> Q.push(-> fn.apply null, args); Q.next() | |
Q |
This file contains hidden or 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
import java.lang.management.ManagementFactory | |
import javax.management.ObjectName | |
import scala.beans.BeanProperty | |
trait DamnitJimMBean { | |
def getCount(): Int | |
} | |
class DamnitJim extends DamnitJimMBean { | |
@BeanProperty var count = 0 |
NewerOlder