This file contains 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 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) { |
This file contains 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
@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) { |
This file contains 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
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') |
This file contains 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
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) |
This file contains 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
#!/bin/sh | |
FILENAME="$1" | |
git checkout $(git rev-list -n1 HEAD -- "$FILENAME")^ "$FILENAME" |
This file contains 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
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 |
This file contains 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
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 |
This file contains 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
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; |
This file contains 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
////////////////////////////////////////////// | |
// 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 | |
// |
This file contains 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 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({}) |