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
/** | |
* Render templates. | |
* | |
* @param {String} The template to use `<p>Hello {{name}}</p>` | |
* @param {String} The data `{ name: 'Alex' }` | |
* @return {String} The rendered template | |
**/ | |
function template(t, d) { | |
return t.replace(/{{([^}]*)}}/g, function(m, f, p, a) { | |
return d[f] || ''; |
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
/* | |
hasClassString x 2,290,290 ops/sec ±0.38% (86 runs sampled) | |
hasClassRegExp x 17,025 ops/sec ±0.45% (82 runs sampled) | |
Fastest is hasClassString | |
*/ | |
var Benchmark = require('benchmark') | |
, suite = new Benchmark.Suite |
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 bash | |
# Configuration | |
SERVER='myserver' | |
DEPLOY_TO='/path/to/app' | |
EXCLUDE='*.swp .git/ db/sphinx/ tmp/ log/' | |
DRY_RUN=false | |
DEPLOY_GEM_PATH='/opt/ec/ruby/1.8.7/lib/ruby/gems/1.8' |
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 ruby | |
require 'rubygems' | |
require 'nokogiri' | |
require 'open-uri' | |
name = 'alex_young' | |
doc = Nokogiri::HTML(open("http://twitter.com/#{name}")) | |
doc.search('#profile-image').each do |img| |
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
require.paths.unshift('./turing-test/lib'); | |
turing = require('../turing.core.js').turing; | |
var test = require('test'), | |
assert = require('assert'), | |
$t = require('../turing.alias.js'); | |
exports.testAlias = { | |
'test turing is present': function() { | |
assert.equal(turing.VERSION, '0.0.41', 'turing.core should have loaded'); |
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
#include <stdio.h> | |
#include <signal.h> | |
void sigfun(int sig) { } | |
int main() | |
{ | |
(void) signal(SIGINT, sigfun); | |
int c; | |
while ((c = getchar()) != 'q') { |
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
require 'rubygems' | |
require 'open-uri' | |
require 'json' | |
repositories = JSON::parse(open('http://github.com/api/v2/json/repos/search/ruby').read) | |
repositories['repositories'].each do |repo| | |
user = JSON::parse(open("http://github.com/api/v2/json/user/show/#{repo['username']}").read)['user'] | |
puts user['email'] | |
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
require 'rubygems' | |
require 'open-uri' | |
require 'zlib' | |
require 'faster_csv' | |
def get_csv(uri) | |
gz = Zlib::GzipReader.new open(uri) | |
FasterCSV.parse(gz) | |
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
NSArray *suffixes = [NSArray arrayWithObjects:@"th", @"st", @"nd", @"rd", nil]; | |
NSString *suffix = nil; | |
NSInteger birthday = [[goal valueForKey:@"beforeBirthday"] intValue]; | |
NSInteger offset = birthday % 10; | |
offset = (offset % 100) > 10 && (offset % 100) < 20 ? 0 : offset; | |
if (birthday > 0) { | |
suffix = offset > 3 ? @"th" : [suffixes objectAtIndex:offset]; | |
} else { | |
suffix = @""; |
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
Interval Since Last Panic Report: 9356825 sec | |
Panics Since Last Report: 1 | |
Anonymous UUID: DACAD640-50CA-4728-9F8B-6B39CDB98D5C | |
Wed Oct 27 18:10:35 2010 | |
panic(cpu 0 caller 0x2a8ab2): Kernel trap at 0x0046d801, type 14=page fault, registers: | |
CR0: 0x80010033, CR2: 0x00000018, CR3: 0x00100000, CR4: 0x000006e0 | |
EAX: 0x08bf0a9c, EBX: 0x08bf0a9c, ECX: 0x136cfe68, EDX: 0x00000000 | |
CR2: 0x00000018, EBP: 0x5c77bd08, ESI: 0x136cfe68, EDI: 0x0a61f968 | |
EFL: 0x00010293, EIP: 0x0046d801, CS: 0x00000008, DS: 0x022d0010 |