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
desc 'Uses graphviz to construct a graph of SuperCategories' | |
task :super_category_graph => :environment do | |
File.open('super_categories.dot', 'w') do |f| | |
f.puts "digraph super_categories {\n" | |
SuperCategory.all.each do |super_category| | |
super_category.children.each do |child| | |
f.puts %{"#{super_category.name}" -> "#{child.name}";\n} | |
end | |
end | |
f.puts '}' |
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
# Setup dir so changes to a ruby version and gemset on entry | |
rvm --rvmrc --create <ruby>@<gemset> | |
# Backup a mysql database | |
mysqldump -u [username] -p [databasename] > [backupfile.sql] | |
# Stop mac from sleeping | |
pmset noidle | |
# Strip quotes around digits in VIM |
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
" Disable toolbar | |
if has("gui_running") | |
set guioptions=egmrt | |
endif | |
color rootwater | |
set guifont=Monaco:h12 | |
set spell |
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
require 'rubygems' | |
require 'nokogiri' | |
require 'sqlite3' | |
require 'highline/import' | |
# Login to Forrst if we haven't already done so | |
unless File.exists?('f-cookie') | |
email = ask("Email Address or Username?") | |
password = ask("Password?") { |q| q.echo = 'x' } |
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
enable :inline_templates | |
get '/:username' do |username| | |
pass if username.blank? | |
resp = Net::HTTP.get_response(URI.parse("http://api.forrst.com/api/v2/users/posts?username=#{username}")) | |
data = resp.body | |
result = JSON.parse(data).with_indifferent_access | |
pass if result[:stat] == 'fail' | |
response['Cache-Control'] = "public, max-age=3600" |
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
list = [] | |
File.open("list.txt", "r") do |infile| | |
while (line = infile.gets) | |
list << line.strip | |
end | |
end | |
list.uniq.each do |l| | |
p l | |
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
require 'net/http' | |
url = URI.parse('http://localhost:7001/AppName') | |
class Producer | |
def initialize(thread_id) | |
@write_count = 0 | |
@thread_id = thread_id | |
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
import Data.Char | |
import Data.Maybe | |
import Data.List | |
import Data.Map hiding (map) | |
import Text.Printf | |
main = do | |
src <- readFile "grades.txt" | |
let pairs = map (split.words) (lines src) | |
let grades = foldr insert empty pairs |
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
myQS :: (Ord a) => [a] -> [a] | |
myQS [] = [] | |
myQS (x:xs) = myQS lessThanPivot ++ [x] ++ myQS greaterThanEqualToPivot | |
where lessThanPivot = [l | l <- xs, l < x] | |
greaterThanEqualToPivot = [l | l <- xs, l >= x] |
OlderNewer