Skip to content

Instantly share code, notes, and snippets.

View danbernier's full-sized avatar

Daniel Bernier danbernier

View GitHub Profile
@danbernier
danbernier / twoDFlyingCircles
Last active August 29, 2015 14:24
2D flying circles
void setup() {
size(800, 600);
ballArray = new Ball[40];
for (int i = 0; i < ballArray.length; i++) {
ballArray[i] =
new Ball(random(width), random(height));
}
}
Ball[] ballArray;
import peasy.*;
PeasyCam camera;
PVector[] spherePos;
void setup() {
size(800, 600, P3D);
camera = new PeasyCam(this, 0,0,0, 200);
setUpSpheres();
}
@danbernier
danbernier / keybase.md
Created August 21, 2015 02:15
keybase.md

Keybase proof

I hereby claim:

  • I am danbernier on github.
  • I am danbernier (https://keybase.io/danbernier) on keybase.
  • I have a public key whose fingerprint is 1FAA B199 F574 EF19 B109 5666 05EF 0F12 A572 A5FA

To claim this, I am signing this object:

stop_words_arg = case stop_words_arg
when :guess then guess_language(string)
when Symbol then stop_words(stop_words_arg)
when Java::CueLangStop::StopWords then stop_words_arg
when nil then nil # is this one really necessary? it documents, but it seems overkill
end
module RSlow
class HtmlResource < ParsableResource
attr_accessor :doc, :scripts, :stylesheets, :images
def initialize(url)
super
@doc = Nokogiri::HTML(@contents)
@scripts = fetch_script_resources(".//script", 'src', JsResource)
@stylesheets = fetch_stylesheet_resources(".//link[@rel]", 'href', CssResource)
@images = fetch_image_resources(".//img", 'src', Resource)
module RSlow
class HtmlResource < ParsableResource
attr_accessor :doc, :scripts, :stylesheets, :images
def initialize(url)
super
@doc = Nokogiri::HTML(@contents)
@scripts = fetch_script_resources(".//script", 'src', JsResource)
@stylesheets = fetch_stylesheet_resources(".//link[@rel]", 'href', CssResource)
@images = fetch_image_resources(".//img", 'src', Resource)
@danbernier
danbernier / gist:1231073
Created September 21, 2011 02:38
Markdown insists my String is an Array
# @paragraphs is an Array of Strings - various puts'es confirm this.
@paragraphs.each do |paragraph|
renderer = HH::LessonParaRenderer.new(container)
markdown = Redcarpet::Markdown.new(renderer)
p paragraph # Just checking - it's a String!
# raises: <TypeError: wrong argument type Array (expected String)>
markdown.render(paragraph)
end
@danbernier
danbernier / gist:1240775
Created September 25, 2011 16:16
One way I could DRY up hunt_for_bugs and fix_bugs
def hunt_for_bugs(score, location)
bug_work(hidden_bugs(location), :hide_points).size
end
def fix_bugs(score, location)
just_fixed = bug_work(found_bugs(location), :hit_points)
@bug_list.reject! { |bug| bug.dead? }
just_fixed.size
end
@danbernier
danbernier / gist:1579738
Created January 8, 2012 21:20
Ruby lets you add instance variables at runtime
ruby-1.9.2-p290 :001 > class Foo
ruby-1.9.2-p290 :002?> def bonk
ruby-1.9.2-p290 :003?> @bonk = nil
ruby-1.9.2-p290 :004?> end
ruby-1.9.2-p290 :005?> end
=> nil
ruby-1.9.2-p290 :006 > f = Foo.new
=> #<Foo:0x007ff15c1e65b8>
ruby-1.9.2-p290 :007 > f.bonk
=> nil
@danbernier
danbernier / sketch.pde
Last active November 16, 2015 14:55
WordCram Processing sketch example for getting raw word count. Total hack!
import wordcram.*;
/*
This takes advantage of two nice WordCram features, and one accident of implementation:
- Feature 1: you can set and get any properties you want on your Words
- Feature 2: you can implement `void wordsCounted(Word[] words)` in your sketch,
and it'll be called after the words are counted up
WordCram normalizes the Word weights, so the most-frequent Word has a weight of 1, and