Skip to content

Instantly share code, notes, and snippets.

Avatar
👍
webby goodness

Tad Thorley phaedryx

👍
webby goodness
View GitHub Profile
View destructured_assignment.coffee
weatherReport = (location) ->
# Make an Ajax request to fetch the weather...
[location, 72, "Mostly Sunny"]
[city, temp, forecast] = weatherReport "Berkeley, CA"
futurists =
sculptor: "Umberto Boccioni"
painter: "Vladimir Burliuk"
poet:
@phaedryx
phaedryx / 1-application.js.coffee
Created Nov 19, 2011
Example code for my DragMarkers project (part 1)
View 1-application.js.coffee
#= require spine/spine
#= require spine/ajax
#= require_tree ./lib
#= require_self
#= require_tree ./models
#= require_tree ./controllers
#= require_tree ./views
#= require_tree .
@phaedryx
phaedryx / 2-markers_controller.js.coffee
Created Nov 20, 2011
Example code for my DragMarkers project (part 2)
View 2-markers_controller.js.coffee
$ = jQuery.sub()
Marker = App.Marker
class App.MarkersController extends Spine.Controller
elements:
"#map" : "mapEl"
".marker" : "markerIcons"
constructor: ->
super
@phaedryx
phaedryx / final-marker.js.coffee
Created Nov 20, 2011
Example code for my DragMarkers project (part 3)
View final-marker.js.coffee
class App.Marker extends Spine.Model
@configure 'Marker', 'latitude', 'longitude', 'icon'
@extend Spine.Model.Ajax
constructor: ->
super
@gmarker = new google.maps.Marker(
position: new google.maps.LatLng(@latitude, @longitude)
icon: @icon
draggable: true
View gist:1747038
var Student;
var students;
var student1;
var student2;
var i, len, student;
Student = (function() {
function Student(fname, lname) {
this.firstName = fname;
this.lastName = lname;
View gist:1803342
module Foo
class BarGenerator < Rails::Generators::Base
class_option :baz, :aliases => '-b', :type => :string, :default => 'quux', :desc => 'foobar is unfoo'
def bar
puts options[:baz]
end
end
end
View gist:2316002
(function() {
"use strict";
(42, eval)('var z = 5');
}());
View gist:2962074
def leppard
self.pour(@sugar)
end
View modules_with_methods.rb
module Debug
def whoAmI?
"#{self.type.name} (\##{self.id}): #{self.to_s}"
end
end
class Phonograph
include Debug
def initialize(title)
@title = title
View gist:3768744
class User < ActiveRecord::Base
has_many :items
...
def self.ranked(year)
select("rank() OVER(ORDER BY SUM(items.amount) DESC), users.*, SUM(items.amount) AS grand_total")
.joins(:items)
.where("EXTRACT(YEAR FROM items.sold_at)=:year", year: year)
.group("users.id")
end
end
You can’t perform that action at this time.