Skip to content

Instantly share code, notes, and snippets.

View trustin's full-sized avatar
🌄
▂▃▅▇█▓▒░۩۞۩░▒▓█▇▅▃▂

Trustin Lee trustin

🌄
▂▃▅▇█▓▒░۩۞۩░▒▓█▇▅▃▂
View GitHub Profile
@trustin
trustin / gist2uml.rb
Created April 5, 2013 08:31
A Sinatra-based webapp that retrieves the content of a gist and generates the PlantUML image URL from it. Apparently, I'm a Ruby beginner. Please feel free to fork and make it better.
#!/usr/bin/env ruby
require 'rubygems'
require 'open-uri'
require 'open3'
require 'json'
require 'sinatra'
require 'zlib'
'
' http://img.motd.kr/uml/gist/:gist_id
'
' The image URL of this gist is:
' http://img.motd.kr/uml/gist/5317079
'
' The source code of the web application:
' https://gist.github.com/trustin/5317595
'
$ cat ~/.local/bin/simple-httperf
#!/bin/bash
if [[ $# -ne 6 ]]; then
echo "Usage: $0 <num_conns> <num_reqs_per_conn> <burst_len> <host> <port> <path>"
exit 1
fi
exec httperf --num-conns "$1" --num-calls "$2" --burst-length "$3" --server "$4" --port "$5" --uri "$6" --rate 10000000
@trustin
trustin / gist:4081911
Last active October 12, 2015 20:18
Trustin's CrashPlan exclusion regular expressions for Mac OS X (crashplan)
/Users/[^/]+/.*(~|\.(log|tmp|bak|lock))
/Users/[^/]+/\.(bash_history|scala_history|mysql_history|lesshst)
/Users/[^/]+/\.m2/repository/.*
/Users/[^/]+/\.ivy2/(cache|local)/.*
/Users/[^/]+/Library/Application Support/(Firefox|Thunderbird)/.*
/Users/[^/]+/[Ww]orkspaces?/.*/target/.*
/Users/[^/]+/[Ww]orkspaces?/openjdk/(sources|OBF_DROP_DIR)/.*
/Users/[^/]+/[Vv]irtualization/[^/]+\.vmwarevm/.*
/Users/[^/]+/[Ss]3/.*
/Users/backup/.*
@trustin
trustin / pf.conf
Created November 15, 2012 06:52
Trustin's /etc/pf.conf for Mac OS X
# 1. Put this file to /etc/pf.conf
# 2. Install init boot scripts using IceFloor then - http://www.hanynet.com/icefloor/
# I tried to use IceFloor to configure everything but it didn't work very well.
# 3. Once done, you can confirm the rules were loaded with 'sudo pfctl -sr'
# 4. At System Preferences -> Security -> Firewall -> Firewall Options,
# check 'Block all incoming connections' to prevent annoying per-app dialogs.
set skip on lo0
set block-policy drop
@trustin
trustin / private.xml
Created November 13, 2012 02:32
Trustin's KeyRemap4MacBook configuration
<?xml version="1.0"?>
<root>
<appdef>
<appname>PATHFINDER</appname>
<equal>com.cocoatech.PathFinder</equal>
</appdef>
<item>
<name>Change Shift+Space to Command+Space</name>
<identifier>private.shiftspace_to_cmdspace</name>
$ git config alias.merge-pullreq '!git-merge-pullreq'
$ git merge-pullreq 1234
Fetching the pull request 1234 from netty/netty ..
Running: git am /tmp/pullreq.XXXXXXXX
Applying: ...
#!/bin/bash
if [[ $# -lt 0 ]] || [[ $# -gt 2 ]]; then
echo "Usage: $0 <pull request id> [<directory>]"
fi
PULL_REQ_ID="$1"
if [[ "x$2" != 'x' ]]; then
cd "$2" || exit 1
// Before:
ServerBootstrap b = new ServerBootstrap();
try {
b.eventLoop(new NioEventLoop(), new NioEventLoop()); // <-- HERE
...
} finally { b.shutdown(); }
// After:
ServerBootstrap b = new ServerBootstrap();
try {
// No more dynamicBuffer() - use buffer().
ByteBuf buf = ByteBuf.buffer();
// Increase the capacity of the buffer.
buf.capacity(1024);
...
// Decrease the capacity of the buffer (the last 512 bytes are deleted.)
buf.capacity(512);