Skip to content

Instantly share code, notes, and snippets.

View saterus's full-sized avatar

Alex Burkhart saterus

View GitHub Profile
@saterus
saterus / gist:828691
Created February 16, 2011 01:44
Print Methods
# terminal color constants!
unless defined?(IRB_CONSTS_LOADED)
ANSI_BLACK = "\033[0;30m"
ANSI_GRAY = "\033[1;30m"
ANSI_LGRAY = "\033[0;37m"
ANSI_WHITE = "\033[1;37m"
ANSI_RED = "\033[0;31m"
ANSI_LRED = "\033[1;31m"
ANSI_GREEN = "\033[0;32m"
ANSI_LGREEN = "\033[1;32m"
@saterus
saterus / gist:861338
Created March 8, 2011 23:17
Haml/Sass/Compass 5min Rundown

Haml: HTML Templating Engine

  • No <> or </>
  • Significant Indentation

Implicit Divs

  • .stuff
  • .things
  • #header
  • .many.classes.and#an_id

CSS-selector-like naming

  • %h1.foo
@saterus
saterus / gist:865048
Created March 10, 2011 22:14
Git Config Aliases for stdsun.cse.ohio-state.edu
[alias]
lg = !git --no-pager log
df = !git --no-pager diff
hist = !git --no-pager log --pretty=format:\"%h %ad | %s%d [%an]\" --graph --date=short
@saterus
saterus / gist:1045824
Created June 24, 2011 22:37
Instructions Idea
public interface Instruction {
/** Executes an instruction on the Machine.
* @param m The machine upon which to execute the instruction.
* @return true if the executed instruction modified a general purpose register.
*/
public boolean execute(Machine m);
}
@saterus
saterus / categorize_subreddits.rb
Created June 28, 2011 04:06
Subreddit Categorization
#!/bin/env ruby
have_ap = require 'awesome_print'
if have_ap
def fancy_print(s)
ap s
end
else
def fancy_print(s)
@saterus
saterus / gist:1637080
Created January 19, 2012 01:48
Ruby Shuffle
# Shuffles all the unused cards in the shoe. Uses the
# Fisher-Yates shuffling algorithm.
# Returns nil.
def shuffle!
(@contents.size-1).downto(2) { |n|
m = rand(n+1)
@contents[n], @contents[m] = @contents[m], @contents[n]
}
nil
end
@saterus
saterus / gist:1776445
Created February 9, 2012 01:56
koans.watchr
watch( '.*\.rb' ) {|md| system("ruby path_to_enlightenment.rb") }
@saterus
saterus / file_summonator.rb
Created November 8, 2012 05:14
Sums Files
dir = ARGV.shift.strip
sum = 0
Dir.glob(dir + "/*.txt").each do |file|
vals = IO.read(file).scan(/\(([0-9]+)\//).flatten.map(&:to_i)
puts "Values extracted: ", vals
s = vals.inject(:+)
puts "File Sum: #{s}"
sum += s
puts "Total Sum: #{sum}"
end
I ((a verb, past tense)) to the sandwich shop across the street for lunch
yesterday. I go there at least ((a number)) times a week. They have the best
Philly Cheesesteak, full of ((a plural noun)) and ((a plural noun)) and gooey,
stringy ((a noun)). They prepare it just right, ((a verb ending in ing)) it
until the meat breaks up and browns, but is still ((an adjective)) and juicy.
Then they add special ((a plural noun)) and place two pieces of delicious ((a
color)) provolone cheese on top of the meat. As soon as it melts, they scoop the
whole thing up and plop it on a ((an adverb)) toasted bun. The juice ((a verb
ending in s)) into the bread and runs down your ((a body part)) when you bite
into it. Perfect! My mouth was watering just thinking about it. I ((an adverb))
For my ((a family member))'s ((an event)) present about ((a number)) years ago,
I got him a ((gift:a noun)). Not a ((an adjective)) ((gift)) or a loud one or
even a ((an adjective)) ((gift)) that runs around chasing its ((a body part))
and drooling on the ((a noun)). I got them a ((a proper noun)), bred in China
thousands of years ago to be the ((a plural noun)) of the royal family. We
named it ((a proper name)).