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
.markdown { | |
body { | |
font-family: Helvetica, arial, sans-serif; | |
font-size: 14px; | |
line-height: 1.6; | |
padding-top: 10px; | |
padding-bottom: 10px; | |
background-color: white; | |
padding: 30px; } |
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
def sieve( n ) | |
s = (2..n).to_a | |
s.each { |p| next unless p; break if p**2 > n; (p**2).step(n, p) { |m| s[m-2] = nil } } | |
s.compact | |
end | |
def time | |
start = Time.now | |
yield | |
Time.now - start |
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
sum += e *= month_days[i] |
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 | |
# ## An Easy Way to Compile and Run Java Classes | |
# | |
# System utility for compiling and running Java classes | |
# in a specific directory structure. | |
# | |
# #### Recommended Installation | |
# Save this code to a file named `easyjava`, somewhere on your HD. Then | |
# in your `~/.bash_profile` add the following: |
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
private void assertEquals (String name, Object a, Object b) { | |
if (! a.equals(b)) { | |
System.out.println ("***** Test failed ***** " | |
+ name + ": " + totalTests); | |
System.out.println (" A => " + a); | |
System.out.println (" b => " + b); | |
totalErrors = totalErrors + 1; | |
} | |
totalTests = totalTests + 1; | |
} |
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/ruby | |
# encoding: utf-8 | |
# Mac OS X Battery Display | |
# | |
# ▐▐▐▐▐▐▐▐▐▐ | |
# | |
# by Nathan Lilienthal <nathanl@ccs.neu.edu> 2012 | |
# Distributed under the GNU General Public License, version 3.0. | |
# |
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
class Array | |
# Return the first element where the given block returns true for. | |
def get_if | |
each { |v| return v if yield v } | |
return false | |
end | |
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
module Vehicle | |
@@catigories = { | |
car: ["Focus", "Dart", "Civic"], | |
truck: ["F150", "Super Duty"], | |
van: ["Caravan", "Town and Country"], | |
} | |
def self.category(name) | |
@@catigories.each do |k,v| |
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 | |
# Detrail.rb (remove all the damn trailing whitespace) | |
# because god hates people that leave trailing whitespace, | |
# don't use \n and use \t | |
# | |
# Usage: | |
# detrail (will assume current directory) | |
# detrail path/to/folder or/directory | |
# |
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
# Get needed packages as root | |
sudo apt-get -q update | |
sudo apt-get install -qy build-essential openssl libreadline6 \ | |
libreadline6-dev curl git-core zlib1g zlib1g-dev libssl-dev libyaml-dev \ | |
libsqlite3-dev sqlite3 libxml2-dev libxslt-dev autoconf libc6-dev libgdbm-dev \ | |
ncurses-dev automake libtool bison pkg-config libffi-dev | |
sudo apt-get install -qy libqt4-dev # for capybara-webkit | |
sudo apt-get install -qy libpq-dev # for pg |