Skip to content

Instantly share code, notes, and snippets.

View jballanc's full-sized avatar

Joshua Ballanco jballanc

View GitHub Profile
(defproject bebop "1.0.0-SNAPSHOT"
:description "Space Cowboy"
:dependencies [[ring/ring-jetty-adapter "1.1.5"]
[cheshire "4.0.2"]
[hiccup "1.0.1"]
[org.clojure/clojure "1.4.0"]
[tnrglobal/bishop "1.2.0"]]
:immutant {:content-path "/"})
@jballanc
jballanc / a.rb
Created August 19, 2012 21:07 — forked from ahoward/a.rb
threads are so dang awesome
strategy =
String(ARGV.shift || 'thread')
n =
Integer(ARGV.shift || 4)
mb =
class MyGroupedListController < UIViewController
attr_accessor :posts
attr_accessor :sections
class TableViewSection
attr_accessor :title
attr_accessor :items
def initialize(params={})
@title = params[:title]
(def foo {:hello "World"})
(def bar (ref {:hello "World"}))
(map :hello [foo bar])
;; => ("World" nil)
(map #(% :hello) [foo bar])
;; => ("World" "World")
@jballanc
jballanc / mixin_is_multi_inheritance.rb
Created June 25, 2012 07:41
If this isn't multiple inheritance, then what is?
module A
def report
puts "reporting from A"
end
end
class B
def report
puts "reporting from B"
end
@jballanc
jballanc / example.rb
Created May 28, 2012 17:22
Prototype Ruby
class ORMConnection
attr_accessor :orm_driver
def connect
# do some stuff...
@orm_driver = some_driver
end
end
my_connection = ORMConnection.new.connect
@jballanc
jballanc / Background.md
Created May 20, 2012 16:14
Golfing Rule 110

What is Rule 110?

Rule 110 is an algorithm for a cellular automaton. The automaton works on of an infinite tape of 1s and 0s. It has a write head that can write to a specific position on the tape, and a read head that reads the position under the write head as well as the positions to either side. The set of three values read determines the value written by the write head according to the following rules:

Values Read111110101100011010001000
Value Written01101110

If you notice, the value to write for each set of three values read corresponds to the position of the bits in the binary representation of the number 110. Hence, the name of the rule. Wikipedia has more information here.

@jballanc
jballanc / gist:2295688
Created April 3, 2012 21:38
Ruby Gems using Proc#curry
backports
hello.bundle:
Load command 0
cmd LC_SEGMENT_64
cmdsize 552
segname __TEXT
vmaddr 0x0000000000000000
vmsize 0x0000000000001000
fileoff 0
filesize 4096
maxprot 0x00000007
class Pass
def self.===(o)
false
end
end
module Case
def test_it(test)
case test
when (self.kind_of?(Class) ? self : Pass)