Skip to content

Instantly share code, notes, and snippets.

@latentflip
latentflip / Instrumentor.js
Created October 27, 2012 12:20
Instrumentor
#depends on underscore
_.isConstructor = (thing) ->
if thing.name && thing.name[0].toUpperCase() == thing.name[0]
true
else
false
class Instrumentor
constructor: (namespace) ->
@latentflip
latentflip / backbone-demo.coffee
Created October 27, 2012 11:35
Demo Backbone App
App = {
Views: {}
}
class App.Views.ListItem extends Backbone.View
events:
'hover' : 'onHover'
'click a[rel=delete]' : 'onDelete'
initialize: ->
@latentflip
latentflip / index.html
Created October 15, 2012 10:49
Bootstrap Example
<!DOCTYPE html>
<html>
<head>
<title>Bootstrap 101 Template</title>
<!-- Bootstrap -->
<link href="css/bootstrap.min.css" rel="stylesheet">
</head>
<body>
<body>
@latentflip
latentflip / 1-ComputedPropertyMixin.md
Created October 11, 2012 08:14
Backbone Computed Properties

Not sure that reading the code does this justice at the moment, but here it is:

If you mix this into your backbone model, and devine a "properties" hash you'll have computed properties in backbone.

Example usage:

class MyModel extends Backbone.Model
  @mixin Backbone.Mixins.WithComputedProperties
@latentflip
latentflip / app.coffee
Created September 25, 2012 20:58
Books
App.BookView = Ember.View.extend
templateName: 'book'
App.BooksController = App.ListController.extend()
App.BooksView = Ember.View.extend
templateName: 'books'
@latentflip
latentflip / gist:3722894
Created September 14, 2012 16:04
Off the cuff ember and backbone thoughts from a non-expert.

Some very off the cuff thoughts on ember and backbone

Here's where I am at with things for Float:

  • done a load of stuff with backbone, and it's what we use in production
  • played with ember, but nothing too serious. Thinking it might be good for Float, but it's got a steep learning curve initially, so it may never happen.

Having read http://trek.github.com and worked through the examples, and compared it to what I've done in backbone. My thoughts are:

@latentflip
latentflip / doctor.erl
Created September 4, 2012 12:42
Erlang Day 3.1
-module(doctor).
-export([loop/0]).
loop() ->
process_flag(trap_exit, true),
receive
new ->
io:format("Creating and monitoring process.~n"),
register(translator, spawn_link(fun translate_service:loop/0)),
loop();
@latentflip
latentflip / npmnew.rb
Created July 12, 2012 10:28
Copy npmnew to your path and chmod +x it, to get a new package.json generator.
#!/usr/bin/env ruby
if File.exists?("package.json")
puts "Already got a package.json in this directory."
puts "Continue? y/n"
confirm = gets.chomp[0]
unless confirm == "y"
exit
require 'active_support/all'
require 'active_model'
class Foo
A_CONSTANT = 3.14
def greet
puts "Hi! + #{A_CONSTANT}"
end
@latentflip
latentflip / notes.md
Created July 4, 2012 20:47
This is ridiculous, never ever do this.

So @MattWynne totally nerd-sniped me this evening, by asking this:

Is is possible to dynamically add ActiveModel::Naming compliance to an object at runtime? My meta-fu is letting me down.

As far as I can figure out, it's not doable, but I can get 'pretty' close, here's what I learned: