Skip to content

Instantly share code, notes, and snippets.

@michaelavila
michaelavila / gist:5341611
Created April 8, 2013 23:46
OmniGraffle links from AB
A bunch of stenciles for wireframing, data & user flow diagrams and more:
Empty Chrome Browser Window:
https://www.graffletopia.com/stencils/938
Twitter Bootstrap UI:
https://www.graffletopia.com/stencils/934
Google Web GUI:
https://www.graffletopia.com/stencils/10431
#
# Each new term in the Fibonacci sequence is generated by adding the previous
# two terms. By starting with 1 and 2, the first 10 terms will be:
#
# 1, 2, 3, 5, 8, 13, 21, 34, 55, 89, ...
#
# By considering the terms in the Fibonacci sequence whose values do not exceed
# four million, find the sum of the even-valued terms.
#
def problem_2_algorithm input
@michaelavila
michaelavila / state-bot.js
Last active April 30, 2024 10:32
Fight Code Game robot barebones statemachine bots
// Store all of the robots and their states so
// that they can be referenced throughout the robots
var ROBOT_STATES = {}
// states
// find and attack enemy with reckless abandon
var SEEK = {
onIdle: function(ev) {
ev.robot.turn(360);
function bound(value, min, max) {
value = max > value ? max : value;
return min < value ? min : value;
}
@michaelavila
michaelavila / orc.coffee
Created September 30, 2013 07:23
Orc vs Promises 1
getData = ->
xhr new XMLHttpRequest
xhr.open 'GET', 'data', true
handleXMLHTTPRequest = ->
if xhr.status is not 200
orc.fail()
xhr.addEventListener 'load', orc.waitFor(handleXMLHTTPRequest), false
xhr.send()
@michaelavila
michaelavila / orc.coffee
Last active December 24, 2015 06:59
Orc vs Promises 2
url = 'http://fiddle.jshell.net'
step1 = ->
$.ajax url,
complete: orc.waitFor()
error: (error) ->
console.log 'Step 1 failed: Ajax request'
step2 = ->
setTimeout orc.waitFor(->
@michaelavila
michaelavila / gist:6986046
Created October 15, 2013 03:22
xfiles + selecta (add to zshrc/bashrc)
# you need to install selecta before this works
# https://github.com/garybernhardt/selecta
alias xf='$(find . -perm +111 -type f | selecta)'
var events = require('events')
var emitter = new events.EventEmitter();
emitter.addListener('hello', sayHello);
function doSomething() {
emitter.emit('hello');
console.log('This should run last');
}
@michaelavila
michaelavila / nand2tetris.md
Last active December 27, 2015 15:19
Information for Nand2Tetris MeetUp

What is it?

A meetup of people planning to work through "The Elements of Computing System". The tl;dr is simple: we're building a computer from scratch. Well, almost anyway, we'll be building machines from Nand gates. This will all happen on hardware simulators. More information about the project can be found here: http://nand2tetris.org

What do I need to bring?

A computer. Any modern computer should do.

What do I need to know?

-----BEGIN PGP PUBLIC KEY BLOCK-----
Version: GnuPG v1.4.15 (Darwin)
mQENBFKBokYBCACotuKzQUS+JEkL1UQBh9Vlqqbev2mfIJOcReMXWEIv+k5ekiqu
1JvQKN3C4CeAfoJ6OBAJ8Ut8VczWUhYdXN9qert1A2xaL7LunVLNJBrdCrvOC3L7
vRD8T3WqZQMrQhvYKqL7OGgUkBss4RFEJGKWK4Lhpb3TTxa+HIvdjJGuoGoRAMtJ
y7ad5mHjT93kodq4dRio1tYh1M1Fcp5Mf6ZsEJbtx8A+rX0BFhk7mSkeHVh7pDLM
3mf5X7980jFVft/L6F0AWQEEgg5xXbFdpx3tK6Q3XJPi0mwR+oHZYD6GGAjRZLoP
Z2sVGnNuO+60T8wt4313qGPrZDr9LLs44GBZABEBAAG0I01pY2hhZWwgQXZpbGEg
PG1lQG1pY2hhZWxhdmlsYS5jb20+iQE4BBMBAgAiBQJSgaJGAhsDBgsJCAcDAgYV