Skip to content

Instantly share code, notes, and snippets.

View koenbok's full-sized avatar

Koen Bok koenbok

View GitHub Profile
@koenbok
koenbok / Makefile
Created February 13, 2016 11:36
Updating subprojects in Makefiles
# Preferred way to deal with subprojects, because we want to avoid submodules.
# This way we do everything explicitly, and can verify everything in commits.
# We need to always keep master in good condition.
TMP = ./tmp
PROJECT_TEMP = $(TMP)/FramerSketch
PROJECT_GIT = [email protected]:motif/FramerSketch2.git
update%project:
@mkdir -p $(TMP)
@koenbok
koenbok / advanced.md
Last active May 5, 2019 14:34
Learn Programming

Advanced Programming

Programming setup

  • Instant visual output.
  • Fast startup time, fast execution.
  • Sensible errors, with code locations.
  • Easy to set up and get working.

Architecture

layerA = new Layer
layerB = new Layer
# The old way
layerB.superLayer = layerA
print layerA.subLayers
# The new way
layerB.parent = layerA
print layerA.children
# Current click event
layerA.on Events.Click, -> ...
# With a shortcut
layerA.onClick -> ...
layerA = new Layer
# Enable pinching & panning
layerA.pinchable.enabled = true
layerA.draggable.enabled = true
layerA = new Layer
# Check the force value
layerA.on Events.ForceTap, (event) ->
print event.force
# Listen to an edge swipe on Screen
Screen.on Events.EdgeSwipeTop, ->
...
@koenbok
koenbok / programming.md
Created February 3, 2016 12:27
Programming Basics

Programming

Programming is hard because

  • Mix between English, logic and math.
  • It is very strict: tabs, spaces, commas and capitalization matters.
  • Errors can be hard to understand but often mean something simple.

Before we begin

# Gesture events
Gestures = {}
# Tap
Gestures.Tap = "tap"
Gestures.TapStart = "tapstart"
Gestures.TapEnd = "tapend"
Gestures.DoubleTap = "doubletap"
# Force Tap
logEventListeners = ->
return if window.__logEventListeners
window.__logEventListeners = true
addEventListener = Element::addEventListener
removeEventListener = Element::removeEventListener
Element::addEventListener = () ->
print "addEventListener", arguments[0], @