Skip to content

Instantly share code, notes, and snippets.

View nesquena's full-sized avatar

Nathan Esquenazi nesquena

View GitHub Profile
# example of my desired syntax for behaviors in red
# /public/javascripts/red/example.red
class ExampleBehavior < Behavior
def initialize(options={})
self.something = 5
end
def on_click(event)
self.element.hide
// public/javascripts/example.js
ExampleBehavior = Behavior.create({
initialize : function() {
this.something = 5;
},
onclick : function() {
this.element.hide();
// ... more stuff
},
@nesquena
nesquena / reset.css
Created November 20, 2008 10:45
CSS Reset
/* v1.0 | 20080212 */
html, body, div, span, applet, object, iframe,
h1, h2, h3, h4, h5, h6, p, blockquote, pre,
a, abbr, acronym, address, big, cite, code,
del, dfn, em, font, img, ins, kbd, q, s, samp,
small, strike, strong, sub, sup, tt, var,
b, u, i, center,
dl, dt, dd, ol, ul, li,
fieldset, form, label, legend,
@nesquena
nesquena / using rg
Created December 3, 2008 13:07
How to use rg
http://github.com/jeremymcanally/rg/tree/master/lib/builtin/thoughtbot.rb
# installing
$ sudo gem install jeremymcanally-rg
# or download the .zip from github and then
$ rake gem
$ gem install pkg/rg-*
# builtin thoughtbot, bort, entp
$ rg -i http://gist.github.com/31533
@nesquena
nesquena / nesquena-rg.rb
Created December 3, 2008 23:25
My rails template for rg
template(:nesquena) do
gem 'json'
gem 'mislav-will_paginate'
gem 'mocha'
gem 'thoughtbot-shoulda'
gem 'quietbacktrace'
gem 'haml'
gem 'authlogic'
plugin 'squirrel', :git => 'git://github.com/thoughtbot/squirrel.git'
# /app/views/families/show.html.haml
= link_to 'Send Message', new_family_message_path(:family_id => @family.id, :category => 'Family')
# /app/controllers/messages_controller.rb
def new
@category = params[:category]
render :action => "messages/#{@category}_form", :layout => true
end
##
# Calendar helper with proper events
# http://www.cuppadev.co.uk/webdev/making-a-real-calendar-in-rails/
#
# (C) 2009 James S Urquhart (jamesu at gmail dot com)
# Derived from calendar_helper
# (C) Jeremy Voorhis, Geoffrey Grosenbach, Jarkko Laine, Tom Armitage, Bryan Larsen
# Licensed under MIT. http://www.opensource.org/licenses/mit-license.php
##
# controller when you post an update
Ping.notify
// Looks like "Updated " + date.toRelativeString() + " ago"
Date.prototype.toRelativeString = function(){
var now = new Date;
var later = this;
var offset = later.getTime() - now.getTime();
var distanceInMinutes = (offset.abs() / 60000).round();
if (distanceInMinutes == 0) { return 'a few seconds'; }
else if ($R(0,1).include(distanceInMinutes)) { return 'a minute'; }
else if ($R(2,44).include(distanceInMinutes)) { return distanceInMinutes + ' minutes';}
else if ($R(45,89).include(distanceInMinutes)) { return '1 hour';}
max = 0
999.downto(100) { |x|
999.downto(x) { |y|
prod = x * y
max = prod if (prod > max and prod.to_s == prod.to_s.reverse)
}
}
puts max