This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Takes an string like "deep.nested.value" and an object like window | |
# and returns the value of window.deep.nested.value. useful for defining | |
# references on objects which don't yet exist, as strings, which get | |
# evaluated at runtime when such references will be available | |
Luca.util.resolve = (propertyReference, source_object)-> | |
return propertyReference unless _.isString(propertyReference) | |
try | |
source_object ||= (window || global) | |
resolved = _( propertyReference.split(/\./) ).inject (obj,key)-> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Add this in a config/initializer within your Rails Project. | |
# This makes it easy to package your shared javascript and css assets as Rails::Engine | |
# for use with the asset pipeline, similarly to how jquery-rails works. | |
# | |
# In development, it allows you to edit those gems in their normal project folder and get immediate feedback on the asset pipeline changes. | |
# Without requiring you to ship the assets to whatever you use to host your gem. | |
# You will need to set ENV['GEM_PROJECT_ROOT'] to something like /Users/datapimp/Projects |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class SectionMarkup extends Backbone.Model | |
html: ()-> | |
@raw = @get("html") | |
# we will receive html, doctype, html tag and all, and get a parsed version of the contents | |
# which will include some tags ( title tags, stylesheets, etc ) that we should leave out. | |
# also we need to adjust the src attribute of the images to point to the server paths | |
previewContent: ()-> | |
markup = @html() |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# So, I have some class defintiions | |
# written in coffeescript. I am writing | |
# an app in coffeescript, which reads these files | |
# on disk. I have access to the coffeescript compiler | |
# from inside of my app. | |
class SomeClass | |
doSomething: ()-> | |
1 + 1 = 2 | |
# |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
MyApplication = Luca.Application.extend | |
initialize: (@options={})-> | |
@router = new Luca.Router(app: @) | |
@router.bind "change:navigation", ()=> | |
@updateYourGoogleAnalytics() | |
Luca.Router = Backbone.Router.extend | |
routes: |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
sample = {} | |
headers = 20.times.collect {|n| "Header #{n}"} | |
sample = headers.inject({}) do |memo,header| | |
memo[ header ] = (rand(8).to_i).times.collect {|j| " item #{ j }"} | |
memo | |
end |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Everyone should be committing to master, or to their own respective feature branches. | |
# When it comes time to deploy, you should do the following: | |
# check out the staging branch | |
git checkout staging | |
# sync up with whatever is currently there | |
git pull origin staging | |
# merge your master branch into staging |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function() { | |
var Application, LocalStore, SocketManager, StateMachine, Viewport; | |
/* | |
There should be a viewport class | |
which watches over the whole area | |
of your single page app. global events | |
can be handled here. | |
*/ | |
Viewport = Backbone.View.extend({ |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# There should be a viewport class | |
# which watches over the whole area | |
# of your single page app. global events | |
# can be handled here. | |
Viewport = Backbone.View.extend | |
el: "#top-most-container" | |
StateMachine = Backbone.Model.extend | |
initialize: (@attributes)-> |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
{spawn, exec} = require 'child_process' | |
option '-p', '--prefix [DIR]', 'set the installation prefix for `cake install`' | |
async = require "async" | |
fs = require "fs" | |
path = require "fs" | |
_ = require "underscore" | |
stdout_handler = (data)-> |