Skip to content

Instantly share code, notes, and snippets.

View phaedryx's full-sized avatar
👍
webby goodness

Tad Thorley phaedryx

👍
webby goodness
View GitHub Profile
@phaedryx
phaedryx / destructured_assignment.coffee
Created November 10, 2011 15:12
coffeescript examples
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 November 19, 2011 21:52
Example code for my DragMarkers project (part 1)
#= 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 November 20, 2011 20:16
Example code for my DragMarkers project (part 2)
$ = 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 November 20, 2011 21:01
Example code for my DragMarkers project (part 3)
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
var Student;
var students;
var student1;
var student2;
var i, len, student;
Student = (function() {
function Student(fname, lname) {
this.firstName = fname;
this.lastName = lname;
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
(function() {
"use strict";
(42, eval)('var z = 5');
}());
def leppard
self.pour(@sugar)
end
module Debug
def whoAmI?
"#{self.type.name} (\##{self.id}): #{self.to_s}"
end
end
class Phonograph
include Debug
def initialize(title)
@title = title
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