Skip to content

Instantly share code, notes, and snippets.

View zeke's full-sized avatar
🍊
Busy! @-message me directly if I'm slow to respond.

Zeke Sikelianos zeke

🍊
Busy! @-message me directly if I'm slow to respond.
View GitHub Profile
@zeke
zeke / buttons.coffee
Created March 3, 2012 05:16 — forked from mathias/buttons.coffee
Haml + Coffeescript Tweet button and Like button
((d, s, id) ->
js = undefined
fjs = d.getElementsByTagName(s)[0]
return if d.getElementById(id)
js = d.createElement(s)
js.id = id
js.src = "//connect.facebook.net/en_US/all.js#xfbml=1"
fjs.parentNode.insertBefore js, fjs
) document, "script", "facebook-jssdk"
@zeke
zeke / foo.rb
Created February 10, 2012 22:17 — forked from wolfklinker/foo.rb
class Dingo
def self.bark
"woof"
end
def self.eat
"A dingo ate my baby!"
end
@zeke
zeke / split_random.rb
Created January 24, 2012 23:13 — forked from willf/split_random.rb
Another version of split random
class Array
# split array into groups up to n items, randomly choosing the size.
def split_random(n)
size == 0 ? self : (size == 1 ? [self] : self[1..-1].reduce([[self[0]]]){|ll, elt| (rand(n)==(n-1) || ll[-1].size==n) ? ll + [[elt]] : ll[0..-2] + [ll[-1] +[elt]]})
end
end
@zeke
zeke / split_random.rb
Created January 23, 2012 21:14 — forked from willf/split_random.rb
Split into random slices from an array in Ruby
class Array
def split_random(n)
def td(n)
[take(n),drop(n)]
end
def split_random_acc(n,l, acc)
head,tail = l.td(rand(n)+1)
return (acc + [head]) if tail==[]
split_random_acc(n, tail, acc + [head])
@zeke
zeke / inject_vs_readability.rb
Created January 13, 2012 07:56 — forked from bbwharris/inject_vs_readability.rb
Inject vs. Readability
# There is more than one way to skin a cat, different coders prefer different methods.
include ActionView::Helpers
class Link < Struct.new(:title, :url); end
a = Link.new("Google", "http://www.google.com")
b = Link.new("Hacker News", "http://news.ycombinator.com")
array_of_links = [a, b]
@zeke
zeke / gist:1506900
Created December 21, 2011 17:35 — forked from sr3d/gist:1434897
UberLogger
(function() {
if(typeof(console) == 'undefined') {
(function() {
/* Shim for window.console */
var methods = ['log', 'info', 'warn', 'error'];
window.console = {};
for(var i = 0; i < methods.length; i++){
window.console[ methods[i] ] = function() {};
}
})();
@zeke
zeke / 0_selector_hacks.scss
Created December 7, 2011 07:32 — forked from chriseppstein/0_selector_hacks.scss
This gist demonstrates some uses of the new sass feature: Passing content blocks to mixins.
@mixin ie6 { * html & { @content } }
#logo {
background-image: url("/images/logo.png");
@include ie6 { background-image: url("/images/logo.gif"); }
}
@zeke
zeke / unicorn
Created April 1, 2011 17:22 — forked from hobbeswalsh/unicorn
/
.7
\ , //
|\.--._/|//
/\ ) ) ).'/
/( \ // /
/( J`((_/ \
/ ) | _\ /
// once the google maps is loaded, put a Raphael canvas on top of it
// be sure to apply margin:0 to the body in this case
var point = new GLatLng(46.065375, 5.448974);
var pixel = map.fromLatLngToContainerPixel(point);
var paper = Raphael(0, 0, 400, 300);
var circle = paper.circle(pixel.x, pixel.y, 10);
circle.attr("fill", "#f00");
circle.attr("stroke", "#fff");
@zeke
zeke / gist:282216
Created January 20, 2010 20:25 — forked from qrush/gist:156368
post errors to hoptoad from actionscript
protected function sendToHoptoad (msg:String):void {
var yamlData:String = 'notice: \n'
+ ' api_key: YOUR_API_KEY\n'
+ ' error_message: "' + msg + '"\n'
+ ' backtrace: \n'
+ ' request: {}\n'
+ ' session: {}\n'
+ ' environment: \n'
+ ' RAILS_ENV: [YOUR_ENV_HERE]\n';