Skip to content

Instantly share code, notes, and snippets.

mping / nginx.conf
Created Sep 22, 2010
nginx config for reverse proxy based on url
View nginx.conf
# Simple basic nginx conf sample for setting up a reverse proxy
#user nobody;
worker_processes 1;
error_log logs/error.log info;
#pid logs/;
mping / page.html
Created Oct 14, 2010
xhtmlrenderer (Flying Saucer) with css3 header/footer
View page.html
<link href="print.css" rel="stylesheet" type="text/css" media="screen,print"/>
<div style="-fs-page-sequence: start; page-break-before: always">
<div style="position: running(current);">
<div id="page-header" class="small">
<span class="align-left">some stuff here</span>
<span class="align-right">some other stuff here</span>
<div class="line">&#160;</div>
mping /
Created Apr 12, 2011
Enables Flying Saucer (xhtmlrendered java lib) to process <img> tags with b64 data
import org.w3c.dom.Element;
import org.xhtmlrenderer.extend.FSImage;
import org.xhtmlrenderer.extend.ReplacedElement;
import org.xhtmlrenderer.extend.ReplacedElementFactory;
import org.xhtmlrenderer.extend.UserAgentCallback;
import org.xhtmlrenderer.layout.LayoutContext;
import org.xhtmlrenderer.pdf.ITextFSImage;
import org.xhtmlrenderer.pdf.ITextImageElement;
mping / cors-nginx.conf
Created Jun 9, 2012 — forked from michiel/cors-nginx.conf
Wide-open CORS config for nginx
View cors-nginx.conf
# Wide-open CORS config for nginx
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '';
mping / print.html
Created Jul 12, 2012
Using XHTMLRenderer for printing PDFs
View print.html
<!-- check -->
<div style="-fs-page-sequence: start; page-break-before: always">
<!-- header for each page -->
<div style="position: running(current);">
<div id="page-header" class="small">
<span style="text-align: left; float:left;">
<!-- header will appear on all pages -->
mping /
Created Oct 25, 2012 — forked from datagrok/
Minimal Race-free Deployment
N="`readlink \"$1\"`"
mv -T "$1.stage" "$1"
ln -s "$N" "$1.stage"
rm -rf "$N"
cp -aH "$1" "$N"
mping /
Created Oct 30, 2012
Redirect all traffic from one port to another, simulating slow connections
# will listen on 4444, redir to 4567, speed is 1024*32 = 32kbytes/sec (slow!)
redir --lport=4444 --cport=4567 --max_bandwidth $((1024*32))
mping / .bashrc
Created May 22, 2013
.bashrc git aliases
View .bashrc
# aliases
alias pserv='python -m SimpleHTTPServer $*'
alias wget='wget --trust-server-names --no-check-certificate'
alias ls='LC_COLLATE=C ls -lFha --group-directories-first --color '
alias grep='grep --color=always'
alias less='less -R'
View latency.txt
Latency Comparison Numbers
L1 cache reference 0.5 ns
Branch mispredict 5 ns
L2 cache reference 7 ns 14x L1 cache
Mutex lock/unlock 25 ns
Main memory reference 100 ns 20x L2 cache, 200x L1 cache
Compress 1K bytes with Zippy 3,000 ns
Send 1K bytes over 1 Gbps network 10,000 ns 0.01 ms
Read 4K randomly from SSD* 150,000 ns 0.15 ms
View mechanize.rb
require 'rubygems'
require 'mechanize'
cert_store =
cert_store.add_file 'cacert.pem' #get it at
a = do |agent|
agent.cert_store = cert_store