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
;; | |
;; Simple CD Database from PCL by Peter Siebel | |
;; Josh Sandlin <dydx@thenullbyte.org> | |
;; | |
(defvar *db* nil) | |
;; | |
;; functions for creating the database | |
;; |
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
# sqldql testing | |
require 'rubygems' | |
require 'sqldsl' | |
require 'sqlite3' | |
db = SQLite3::Database.new(':memory:') | |
puts "creating UserRoles table" | |
db.execute <<SQL |
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
# snip | |
# Gives error when a torrent is loaded that has a udp announcement. | |
# def check | |
# if @s.announce_list | |
# @s.announce_list.each do |tier| | |
# tier.each { |track| raise MetaInfoFormatError, "expecting HTTP URL in announce-list, got #{track} instead" unless track.is_a? URI::HTTP } | |
# end | |
# 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
# unnecessary.rb - Josh Sandlin - 3:13PM - 1/15/2010 | |
# An interpreter of the Unnecessary language | |
# raised when the source file is present | |
class CriticalError < Exception; end | |
# core of the interpreter | |
class Unnecessary | |
attr_accessor :source_file |
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
# jbfc.rb - Josh Sandlin - 7:27PM - 1/18/2010 | |
# Takes brainfuck source and compiles it to exe | |
# converts brainfuck code into C code | |
class BFToC | |
attr_accessor :source, :memory | |
def initialize( source, memory=30000 ) | |
if !File.exists? source |
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
# benchmarking.rb - Josh Sandlin - 1:58PM - 1/24/2010 | |
# benchmarking from the unofficial ruby usage guide | |
require 'benchmark' | |
include Benchmark | |
n = 1000000 | |
bm( 12 ) do |test| | |
test.report( "normal:" ) do | |
n.times do |x| |
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
-- weird-adder.hs - Josh Sandlin - 6:45PM - 2/14/2010 | |
-- Really weird way to add a range of numbers | |
-- takes an upper limit and returns a list of pairs | |
pairedRange :: Int -> [(Int, Int)] | |
pairedRange x = zip [ a | a <- [1..x], odd a ] [ b | b <- [1..x], even b ] | |
-- adds a list of pairs | |
addPairs :: (Num a) => [(a, a)] -> [a] | |
addPairs x = [ a + b | (a, b) <- x ] |
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
-- ackermann.hs - Josh Sandlin - 10:17PM - 2/28/2010 | |
-- Naive Ackermann function in Haskell | |
ackermann m n | |
| m == 0 = n + 1 | |
| n == 0 = ackermann (m-1) 1 | |
| otherwise = ackermann (m-1) (ackermann m (n-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
-- baby.hs - Josh Sandlin - 12:43AM - 2/14/2010 | |
-- example code from Learn You a Haskell for Great Good | |
doubleMe :: (Num a) => a -> a | |
doubleMe x = x + x | |
doubleUs :: (Num a) => a -> a -> a | |
doubleUs x y = doubleMe x + doubleMe y |
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
# number_parser.rb - Josh Sandlin - 2:03PM 3/28/2010 | |
# translating some Java ideas over to Ruby code. | |
require 'test/unit' | |
class Node | |
def evaluate; end | |
end |
OlderNewer