Skip to content

Instantly share code, notes, and snippets.

View gist:a00076db27b0008b0cc622d93df357f1

A farmer is looking for some extra help on the farm, so he hires a farmhand. On the first day he puts him to work pounding in fence posts, it's absolutely grueling work under the hot sun, but the farmhand excels at this. He sets up more fence posts than any other farmhand ever has in a day, more than the farmer ever could. The farmer is astounded at how fast the hand worked.

So, the next day, the farmer sets the farmhand up harvesting corn. It's tedious work, there are rows and rows and rows of corn and all day the farmhand is plucking ears of corn in an endlessly monotonous task. At the end of the day, the farmhand delivers a massive collection of corn. He's done it again - he's worked harder and better than anyone could ever do. At this rate the farmer is going to run out of work!

So on the third day, the farmer is trusting the farmhand to make decisions. He leads him into the root cellar and shows him the potatoes. There's a whole heap of them, a weeks worth of work. The farmer says, "I want you to sort

elliottkember /
Created Oct 13, 2014
A layer that fades between images depending on its state
class ImageSwappingLayer extends Layer
images: {}
imageSubLayer: false
imageTransitionTime: 0.5
constructor: (options={}) ->
super options
@imageTransitionTime = options.imageTransitionTime if options.imageTransitionTime
elliottkember /
Last active Mar 14, 2019
Framer.js per-transition animationOptions!
myLayer.states.stateAnimationOptions =
time: 0.1
time: 0.8
time: 0.5
a: opacity: 1
Layer.prototype.destroyRecursively = ->
layer.destroyRecursively() for layer in @subLayers
class Configurator
constructor: (options) ->
@values = {}
@options = options
@callbacks = {}
elliottkember /
Created Jul 23, 2014
Load in CoffeeScript files with Framer
load = (scripts...) ->
for script in scripts
script = "#{script}.coffee" if script.indexOf '.' == -1
eval CoffeeScript.compile(Utils.domLoadDataSync(script))
load 'finderWindow', 'appStateMachine'
elliottkember /
Last active Aug 9, 2018
A simple application framework for Framer
EventEmitter = (require?("./EventEmitter") || Framer).EventEmitter
class AppStateMachine extends EventEmitter
constructor: ->
@states = []
# Start the state machine with the document's hash, or the given route
start: (name) ->
@go if document.location.hash then document.location.hash[1..-1] else name
elliottkember /
Last active Dec 14, 2021
Layer browser for imported Sketch / PSD files in Framer
class LayerBrowser
constructor: (options) ->
@objects = []
@restore = options.restore
@add options.import if options.import
add: (object) ->
@objects.push object
elliottkember /
Last active Aug 29, 2015
When clicked, a layer can have an alternate image, an alternate background color, or an overlay!
Layer.define "alternateBackgroundColor",
exportable: true
default: ""
get: ->
@_getPropertyValue "alternateBackgroundColor"
set: (alternateBackgroundColor) ->
return if alternateBackgroundColor == @_getPropertyValue "alternateBackgroundColor"
@_setPropertyValue "alternateBackgroundColor", alternateBackgroundColor
originalBackgroundColor = @backgroundColor
App.SpinnerView = Ember.View.extend
shadow: false
color: '#000'
tagName: 'span'
classNameBindings: [':loading-spinner', 'isButton:button', 'centered:centered']
didInsertElement: ->
opts =
lines: 13, # The number of lines to draw
length: 4, # The length of each line
width: 2, # The line thickness
App.ApplicationSerializer = DS.ActiveModelSerializer.extend
serialize: (record, options) ->
json = @_super record, options
record.eachAttribute (name, attribute) ->
if attribute.options.readOnly
App.Object = Ember.Model.extend
name: DS.attr 'string', readOnly: true