This file contains hidden or 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/perl -w | |
use strict; | |
while (<>) { | |
s/\t/|/g; # Convert Tabs to Pipes | |
s/\r?\n/[]\r\n/g; # Add [] at EOL and Convert to CRLF | |
s/^\|+\[\]\r\n//g; # Remove Empty Lines | |
print; |
This file contains hidden or 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 <iostream> | |
#include <ctime> | |
#include <string> | |
using namespace std; | |
string convert(unsigned long n) { | |
static char *formats[16] = { | |
"", "%s%s%s", "%s%s", "%s%s-%s", | |
"%s hundred", "%s hundred and %s%s", "%s hundred and %s", "%s hundred and %s-%s", |
This file contains hidden or 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 -e | |
# Usage: license | |
# Prints an MIT license appropriate for totin' around. | |
# | |
# $ license > COPYING | |
#!/bin/sh | |
echo "Copyright (c) `date +%Y` `git config --get user.name` | |
Permission is hereby granted, free of charge, to any person obtaining | |
a copy of this software and associated documentation files (the |
This file contains hidden or 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
local ruby18='ruby-1.8.7-p334' | |
local ruby19='ruby-1.9.2-p180' | |
function rb18 { | |
if [ -z "$1" ]; then | |
rvm use "$ruby18" | |
else | |
rvm use "$ruby18@$1" | |
fi | |
} |
This file contains hidden or 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
util = require 'util' | |
after = (time, args..., callback) -> setTimeout callback, time, args... | |
class Game | |
score: 0 | |
score_step: 20 | |
constructor: (@client, @difficulty = 800) -> | |
@send 'HELO :Welcome to Pong!' | |
@send 'HELP :When you receive a PING <code>,' | |
@send 'HELP :reply quickly with PONG <code>,' |
This file contains hidden or 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
@create: (msg, opts) -> | |
title = opts.title if typeof opts.title is 'string' | |
type = typeof msg | |
if type is 'object' | |
title or= msg.attr('title') | |
type = msg.get(0).nodeName | |
switch type | |
when 'string' then break | |
when 'INPUT', 'SELECT', 'TEXTAREA' | |
msg = msg.attr('value') |
This file contains hidden or 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
def process(filename) | |
File.open filename, 'r' do |f| | |
ln = 0 | |
begin | |
while l = f.gets | |
l.strip! | |
ln += 0 | |
yield l, ln | |
end |
This file contains hidden or 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
def estimated_tax | |
line1 = expected_agi | |
line2 = deductions | |
line3 = line1 - line2 | |
line4 = 3700 * exemptions | |
line5 = line3 - line4 | |
line6 = tax(line5) | |
line7 = alt_min_tax | |
line8 = line6 + line7 | |
line9 = credits |
This file contains hidden or 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
module Helpers | |
def each_ln(filename) | |
File.open filename, 'r' do |f| | |
ln = 0 # Line Number | |
begin | |
while l = f.gets | |
l.strip! | |
ln += 1 | |
yield l, ln | |
end |
This file contains hidden or 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
def biggest(list) | |
list.inject do |a, b| | |
a < b ? b : a | |
end | |
end | |
# Even more concise: | |
def biggest(list) | |
list.inject { |a, b| a < b ? b : a } |