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
elliottkember / imageSwappingLayer.coffee
Created Oct 13, 2014
A layer that fades between images depending on its state
View imageSwappingLayer.coffee
class ImageSwappingLayer extends Layer
images: {}
imageSubLayer: false
imageTransitionTime: 0.5
constructor: (options={}) ->
super options
@imageTransitionTime = options.imageTransitionTime if options.imageTransitionTime
@elliottkember
elliottkember / stateAnimationOptions.coffee
Last active Mar 14, 2019
Framer.js per-transition animationOptions!
View stateAnimationOptions.coffee
myLayer.states.stateAnimationOptions =
'a-b':
time: 0.1
'b-c':
time: 0.8
'c-d':
time: 0.5
myLayer.states.add
a: opacity: 1
View Configurator.coffee
Layer.prototype.destroyRecursively = ->
layer.destroyRecursively() for layer in @subLayers
@destroy()
class Configurator
constructor: (options) ->
@values = {}
@options = options
@callbacks = {}
@elliottkember
elliottkember / load.coffee
Created Jul 23, 2014
Load in CoffeeScript files with Framer
View load.coffee
load = (scripts...) ->
for script in scripts
script = "#{script}.coffee" if script.indexOf '.' == -1
eval CoffeeScript.compile(Utils.domLoadDataSync(script))
load 'finderWindow', 'appStateMachine'
@elliottkember
elliottkember / AppStateMachine.coffee
Last active Aug 9, 2018
A simple application framework for Framer
View AppStateMachine.coffee
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
elliottkember / layerbrowser.coffee
Last active Dec 14, 2021
Layer browser for imported Sketch / PSD files in Framer
View layerbrowser.coffee
class LayerBrowser
constructor: (options) ->
@objects = []
@restore = options.restore
@_setup()
@add options.import if options.import
add: (object) ->
@objects.push object
@elliottkember
elliottkember / framer-alternate-states.coffee
Last active Aug 29, 2015
When clicked, a layer can have an alternate image, an alternate background color, or an overlay!
View framer-alternate-states.coffee
Layer.define "alternateBackgroundColor",
exportable: true
default: ""
get: ->
@_getPropertyValue "alternateBackgroundColor"
set: (alternateBackgroundColor) ->
return if alternateBackgroundColor == @_getPropertyValue "alternateBackgroundColor"
@_setPropertyValue "alternateBackgroundColor", alternateBackgroundColor
originalBackgroundColor = @backgroundColor
View spinnerView.coffee
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
View serializer.coffee
App.ApplicationSerializer = DS.ActiveModelSerializer.extend
serialize: (record, options) ->
json = @_super record, options
record.eachAttribute (name, attribute) ->
if attribute.options.readOnly
delete json.name
json
App.Object = Ember.Model.extend
name: DS.attr 'string', readOnly: true