Skip to content

Instantly share code, notes, and snippets.

def read_fixture_files
if File.file?(yaml_file_path)
read_yaml_fixture_files
elsif File.file?(csv_file_path)
read_csv_fixture_files
else
raise FixturesFileNotFound, "Could not find #{yaml_file_path} or #{csv_file_path}"
end
end
def read_yaml_fixture_files
yaml_string = (Dir["#{@fixture_path}/**/*.yml"].select { |f|
File.file?(f)
} + [yaml_file_path]).map { |file_path| IO.read(file_path) }.join
if yaml = parse_yaml_string(yaml_string)
# If the file is an ordered map, extract its children.
yaml_value =
if yaml.respond_to?(:type_id) && yaml.respond_to?(:value)
yaml.value
@willrjmarshall
willrjmarshall / gist:1221290
Created September 16, 2011 05:46
Backbone hates me
#= require_self
#= require_tree ./templates
#= require_tree ./models
#= require_tree ./views
#= require_tree ./routers
window.Opjam =
Models: {}
Collections: {}
Routers: {}
Java Plug-in 1.6.0_26
Using JRE version 1.6.0_26-b03-383-11A511 Java HotSpot(TM) 64-Bit Server VM
User home directory = /Users/willmarshall
----------------------------------------------------
c: clear console window
f: finalize objects on finalization queue
g: garbage collect
h: display this help message
l: dump classloader list
m: print memory usage
class Opjam.Models.Track extends Backbone.Model
paramRoot: 'track'
# Set of tracks, scope to a particular broadcast
class Opjam.Collections.TrackCollection extends Backbone.Collection
model: Opjam.Models.Track
url: ->
"/broadcasts/:broadcast_id/tracks"
resources :broadcasts do
resources :tracks
end
window.Opjam =
Models: {}
Collections: {}
Routers: {}
Views: {},
init: ->
window.Player = new Opjam.Models.Player
window.PlayerView = new Opjam.Views.PlayerView { model: Player }
class Opjam.Models.Wall extends Backbone.Model
paramRoot: 'wall'
defaults:
numColumns: 16
numRows: 4
radius: 600 # Radius of the virtual circle
currentRotation: -12 # Initial position, measured in columns
animationDegree: 0.25 # Degrees per frame of animation
animateRotate: (frames, increment, current) ->
if frames > 0
current = current + increment
transform = 'translateZ(900px) rotateY(' + current + 'deg)'
for ring in @rings
ring.style.webkitTransform = transform
requestAnimFrame (=>
@animateRotate((frames - 1), increment, current)
), 0.1
else
class Opjam.Models.Playlist extends Backbone.Model
paramRoot: 'playlist'
defaults:
name: "Untitled playlist"
playlistEntries: new Opjam.Collections.PlaylistEntriesCollection([], url : 'playlists/:id/playlist_entries')