Skip to content

Instantly share code, notes, and snippets.

Avatar
:octocat:

Jared Davis Jared-Prime

:octocat:
View GitHub Profile
@Jared-Prime
Jared-Prime / dictionary_kata.rb
Created Apr 30, 2013
edit (4/30/2013 3:23pm) add a few comments
View dictionary_kata.rb
class DictionaryKata < Array
# we cheat, knowing how many characters we have to match
def initialize(word_size)
File.open("/usr/share/dict/words","r") do |words|
words.each do |word|
word.gsub!(/\n/,'')
self << word if word.size == word_size
end
end
View dictionary_kata.rb
class DictionaryKata < Array
def initialize(word_size)
File.open("/usr/share/dict/words","r") do |words|
words.each do |word|
word.gsub!(/\n/,'')
self << word if word.size == word_size
end
end
end
@Jared-Prime
Jared-Prime / gist:2371224
Created Apr 12, 2012
Taxi Fare - basic functions in JavaScript
View gist:2371224
// solution to Codeacademy.com project, "Taxi Fare"
// fare based upon miles traveled and the hour of the day
var taxiFare = function (milesTraveled, pickupTime) {
var baseFare = 2.50;
var costPerMile = 2.00;
var nightSurcharge = 0.50; // 8pm to 6am, every night
var cost = baseFare + (costPerMile * milesTraveled);
View article.css
article h1, article p {
padding: 18px; }
article h1 {
font-size: 200%; }
article blockquote {
width: 80%;
margin: auto; }
article img {
margin: auto; }
.articles article {
View gist:3125018
get '/webwork' do
haml :webwork
end
@Jared-Prime
Jared-Prime / gist:3036783
Created Jul 3, 2012
MadClojure - macros demo July 1
View gist:3036783
(ns my.namespace.core)
(if true 1)
(gensym)
(defn my-when [pred & body]
(let [x# pred]
`(if ~x# (do ~@body (println "done")))))
@Jared-Prime
Jared-Prime / chingu.rb
Created Jun 26, 2012
Q: how do I load the image?
View chingu.rb
require 'chingu'
class Player < Chingu::GameObject
def initialize
super
self.x, self.y = 200, 200
self.image = Gosu::Image["ship1.jpg"]
self.input = {
:holding_left => :move_left,
:holding_right => :move_right }
@Jared-Prime
Jared-Prime / lab_to_rgb.rb
Created Jun 9, 2012
conversions from L*a*b to RGB
View lab_to_rgb.rb
# port of David Dalrymple's GNU C code
# the original C code can be found at http://davidad.net/colorviz/
def lab_to_xyz(lab)
l = lab[0]
a = lab[1]
b = lab[2]
ill = [0.9643, 1.0, 0.8251]
@Jared-Prime
Jared-Prime / gist:2664038
Created May 12, 2012
survey reader for Think Stats
View gist:2664038
# finally, correctly rewrote the Python script "survey" in Think Stats to Ruby.
# burned the midnight candle to get this right. feels great to succeed
class Table < Hash
def initialize(name=nil)
self[:records] = []
self[:name] = name
end
@Jared-Prime
Jared-Prime / gist:2501154
Created Apr 26, 2012
sample of Sass responsive grid
View gist:2501154
@for $i from 1 through 4 {
.span#{$i} {
margin:0;
padding:0;
float:left;
@media (min-width:960px) {
width: percentage(1/$i);
}
@media (max-width:780px) and (max-width:959px) {