Skip to content

Instantly share code, notes, and snippets.

Avatar

Brian Mock wavebeem

View GitHub Profile
View gist:668561
#!/usr/bin/env ruby
#
# Ruby, ruby, ruby
#
DATA.each{|line| puts "#{DATA.lineno}: #{line}"}
__END__
Line one
Line two
Line three :D
View gist:668574
#!/usr/bin/ruby
#
# Allow the user to query the status of several running totals via multiple
# background threads
code = lambda do
Thread.current[:x] = 0
loop do
Thread.current[:x] += 1
Thread.pass
@wavebeem
wavebeem / gist:765817
Created Jan 5, 2011
Refactored hexy script
View gist:765817
#!/usr/bin/python2
import sys
arg = sys.argv
if len(arg) != 3:
exit(1)
infile = arg[1]
outfile = arg[2]
@wavebeem
wavebeem / gist:768535
Created Jan 6, 2011
Benchmarking for word frequency programs
View gist:768535
Ruby
real 0m2.820s
user 0m1.887s
sys 0m0.040s
------------------------------------------------------------------------------
Perl
real 0m1.344s
user 0m1.047s
View gist:777498
#!/usr/bin/ruby
data = DATA.read
data.gsub! '\:', "\0"
pieces = data.split ":"
pieces.each do |piece|
piece.gsub! "\0", '\:'
end
puts pieces
__END__
5082333~GBP~ACTIVE~0~1~NR\: (RSA) <br>8. Fan Mail (0%,11\:07), 6(2.5%,11\:08)~true~5.0~1162835723938~6. Earlswood,9.08,2.5;8. Fan Mail,9.07,2.4;Y:1058616~0~6.04~8.4~~11.9~false||:670160~1~6.18~17.5~~4.2~false||:113 2008~2~9.78~5.2~~20.4~false||:894820~3~140.02~4.6~~20.4~false||1.01~5.0~B~1~:1414415 ~4~8.2~6.2~~16.0~false||:575636~5~5.54~11.5~~8.6~false||:1433455~6~0.0~~~0.4~false|| :1433456~7~0.0~~~0.9~false||:746753~8~5.54~11.5~~5.2~false||:1433457~9~0.0~~~4.2 se||:1147548~10~0.0~~~2.6~false||:1433458~11~62.46~2.0~~3.5~false||:1433459~12~0.0~~ ~ 0.9~false||:1433460~13~0.0~~~0.9~false||
View gist:779230
#!/usr/bin/env python2
# Python
# lolz
occurences = {}
string = raw_input('string> ')
for character in string:
occurences[character] = occurences.get(character, 0) + 1
View gist:782608
#=====================================================================#
# General #
#=====================================================================#
# Min | Hour | Mday | Month | Wday | Command #
#=====================================================================#
# * * * * * $HOME/bin/gmail.rb
0 5 * * * $HOME/bin/dotbackup.rb
# */15 * * * * $HOME/bin/temp-help.sh
#=====================================================================#
View gist:784028
module Main where
-- Define the BST data type
data BST a = Node (BST a) (BST a) a
| Tip
deriving (Show, Eq)
-- Make a leaf node
leaf y = Node Tip Tip y
View gist:784115
module List where
data List a
= Null
| Node (List a) a
deriving (Show, Eq)
build = build' Null
where
build' Null [] = Null
@wavebeem
wavebeem / bst.hs
Created Jan 20, 2011
Haskell binary search tree
View bst.hs
module BST where
-- Define the BST data type
data BST a
= Node (BST a) (BST a) a
| Tip
deriving (Show, Eq)
-- Make a leaf node
leaf y = Node Tip Tip y