Skip to content

Instantly share code, notes, and snippets.

View samsonjs's full-sized avatar

Sami Samhuri samsonjs

View GitHub Profile
#!/usr/bin/env narwhal
// Usage: $ wtf-api file
// $ wtf-api file isDirectory rmtree
var args = require('system').args
, m = require(args[1])
if (args.length > 2)
args.slice(2).forEach(function(prop) {
@implementation CPView (RelativeCoordinates)
- (CGPoint) coordinatesRelativeToView: (CPView)rootView
{
var viewFrame = [self frame];
var x = viewFrame.origin.x;
var y = viewFrame.origin.y;
var curParentView = [self superview];
while (curParentView != rootView) {
var http = require('http'),
sys = require('sys'),
params = {
text: '"some text" with +symbols',
page: 3
},
props = Object.getOwnPropertyNames(params),
body = props.map(function(p){return escape(p) + '=' + escape(params[p])}).join('&'),
client = http.createClient(80, 'example.com'),
request = client.request('POST', '/search', {'content-type': 'application/x-www-form-urlencoded')
parseComment :: Parser LispVal
parseComment = do skipMany space
char ';'
skipMany $ noneOf "\n\r"
return $ Null False
parseAtom :: Parser LispVal
parseAtom = do first <- letter <|> symbol
rest <- many (letter <|> digit <|> symbol)
#!/bin/sh
FILENAME="$1"
git checkout $(git rev-list -n1 HEAD -- "$FILENAME")^ "$FILENAME"
cd /tmp
wget http://rubyforge.org/frs/download.php/70696/rubygems-1.3.7.tgz
tar zxf rubygems-1.3.7.tgz
cd rubygems-1.3.7
ruby setup.rb --prefix=/usr/local
ln -svf /usr/local/bin/gem1.8 /usr/local/bin/gem
export RUBYLIB=/usr/local/lib
echo "export RUBYLIB=/usr/local/lib" >> /root/.bashrc
loop do
uptime = `uptime`.split(' ')[-3]
user = "YOUR_USERNAME"
`curl http://loadaverages.elliottkember.com/statistics -s -d statistic\\[computer_id\\]=#{user}\\&statistic\\[uptime\\]=#{uptime}`
puts uptime
sleep 5
end
var http = require('http'),
qs = require('querystring'),
url = require('url'),
sys = require('sys'),
handlePOST = function(request, callback){
var data = new Buffer(4096),
size = 0;
request.addListener('data', function(chunk){
chunk.copy(data, size, 0);
size += chunk.length;
//////////////////////////////////////////////
// REDUCTION: http://gist.github.com/553200
//////////////////////////////////////////////
// Somehow we've managed to push the right buttons causing Node to get
// into a broken state. After hitting our web server anywhere from
// 5-5000 times JSON.stringify begins to produce corrupt output. Where
// the ascii chars 'null' should appear for null values,
// JSON.stringify instead emits these 4 bytes: \002\000\000\000
//
#!/usr/bin/env node
// Reduction of corrupted JSON bug, Object.freeze is broken
//
// Related? http://groups.google.com/a/chromium.org/group/chromium-bugs/browse_thread/thread/d9b1ff90110eda2d
console.log('Good JSON: ' + JSON.stringify({x: null}))
var i = 0
while (true) {
Object.freeze({})