Skip to content

Instantly share code, notes, and snippets.

@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)'
@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 / 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()
function bound(value, min, max) {
value = max > value ? max : value;
return min < value ? min : value;
}
@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);
#
# 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 / 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