Skip to content

Instantly share code, notes, and snippets.

@chengfred
chengfred / gist:979204
Created May 18, 2011 18:35
Simplenote iOS note encoding
NSString *notestring = [[currentNote noteDictionaryWithContent: YES] JSONRepresentation];
// notestring now contains a JSON string with note data
NSString *encodedString = (NSString *)CFURLCreateStringByAddingPercentEscapes(
NULL,
(CFStringRef)notestring,
NULL,
(CFStringRef)@"!*'();:@&=+$,/?%#[]",
kCFStringEncodingUTF8 );
NSData *data = [encodedString dataUsingEncoding:NSUTF8StringEncoding];
@chengfred
chengfred / gist:1314847
Created October 26, 2011 00:01
sasl error log
{rw,quorum}],
63485258401}],
[{bucket,<<"app-preservers-d70_indexes">>}|
{meta_entry,
[{allow_mult,true},
{name,<<"app-preservers-d70_indexes">>},
{n_val,3},
{last_write_wins,false},
{precommit,[]},
{postcommit,[]},
@chengfred
chengfred / gist:1315049
Created October 26, 2011 00:41
erlang.log.1
=====
===== LOGGING STARTED Wed Oct 26 00:37:01 UTC 2011
=====
{gen_fsm,
handle_msg,
7},
{proc_lib,
init_p_do_apply,
3}]},
@chengfred
chengfred / gist:1318510
Created October 27, 2011 01:08
websocket close error
2011-10-26_23:58:30.12356 [E 111026 23:58:30 periodic:46] Error in periodic callback
2011-10-26_23:58:30.12359 Traceback (most recent call last):
2011-10-26_23:58:30.12360 File "/home/ubuntu/test/libs/tornadio/tornadio/periodic.py", line 42, in _run
2011-10-26_23:58:30.12361 next_call = self.callback()
2011-10-26_23:58:30.12361 File "/home/ubuntu/test/libs/tornadio/tornadio/conn.py", line 141, in _heartbeat
2011-10-26_23:58:30.12362 self.close()
2011-10-26_23:58:30.12363 File "/home/ubuntu/test/libs/tornadio/tornadio/conn.py", line 85, in close
2011-10-26_23:58:30.12363 self._protocol.close()
2011-10-26_23:58:30.12364 File "/home/ubuntu/test/libs/tornado/tornado/websocket.py", line 121, in close
2011-10-26_23:58:30.12364 self.ws_connection.close()
@chengfred
chengfred / gist:3213536
Created July 31, 2012 04:11 — forked from danparsons/gist:3195652
How to stream the London 2012 Olympics

How to stream the London 2012 Olympics

There have been several HOWTOs posted regarding streaming the 2012 Olympics using HTTP / SOCKS proxies via SSH and other similar methods. None of these actually work using the latest Flash on Mountain Lion (with Firefox, Chrome or Safari). Additionally, the third-party streaming sites don't provide BBC's amazing interface, which lets you quickly skip to individual competitors and events. However, setting up an OpenVPN server does work, with some tweaks. You'll get the exact same UX that people in England receive.

Every 2.0s: echo stats | nc 127.0.0.1 11211 Wed Feb 20 00:28:04 2013
STAT pid 14642
STAT uptime 957426
STAT time 1361320083
STAT version 1.4.5
STAT pointer_size 64
STAT rusage_user 8751.490000
STAT rusage_system 20988.540000
STAT curr_connections 38
@chengfred
chengfred / fork.c
Created March 15, 2013 21:58 — forked from nb/fork.c
#include <unistd.h>
#include <stdlib.h>
#include <stdio.h>
#include <errno.h>
/* MB of memory to allocate */
#define MB 100
/* How many processes to spawn */
#define FORKS 50
/* How many random elements to change in the child process */
Notice: Undefined index: oauth_verifier in /var/subdomains/eversimple.stephanis.me/html/inc/parts/callback.php on line 5 Fatal error: Uncaught exception 'OAuthException' with message 'Invalid auth/bad request (got a 400, expected HTTP/1.1 20X or a redirect)' in /var/subdomains/eversimple.stephanis.me/html/inc/evernote-lib/Evernote/Client.php:55 Stack trace: #0 /var/subdomains/eversimple.stephanis.me/html/inc/evernote-lib/Evernote/Client.php(55): OAuth->getAccessToken('https://sandbox...', '', '') #1 /var/subdomains/eversimple.stephanis.me/html/inc/parts/callback.php(13): Evernote\Client->getAccessToken('georgestephanis...', '523A4A459E713FC...', NULL) #2 /var/subdomains/eversimple.stephanis.me/html/inc/bootstrap.php(38): include('/var/subdomains...') #3 /var/subdomains/eversimple.stephanis.me/html/index.php(1): require_once('/var/subdomains...') #4 {main} thrown in /var/subdomains/eversimple.stephanis.me/html/inc/evernote-lib/Evernote/Client.php on line 55
function parse_git_dirty {
[[ $(git status 2> /dev/null | tail -n1) != "nothing to commit (working directory clean)" ]] && echo "*"
}
function parse_git_branch {
git branch --no-color 2> /dev/null | sed -e '/^[^*]/d' -e "s/* \(.*\)/[\1$(parse_git_dirty)]/"
}
function git_current_branch() {
git symbolic-ref HEAD 2> /dev/null | sed -e 's/refs\/heads\///'
@chengfred
chengfred / gist:6559732
Created September 14, 2013 07:49
Configure delay for port
sudo ipfw add pipe 1 ip from any to any out dst-port 7002
sudo ipfw pipe 1 config delay 100
# 100ms propagation delay on any connection to port 7002
sudo ipfw show