Skip to content

Instantly share code, notes, and snippets.

View foxbunny's full-sized avatar

Hajime Yamasaki Vukelic foxbunny

View GitHub Profile
@foxbunny
foxbunny / fib.erl
Last active February 23, 2017 17:43
-module(fib).
-export([fib/1, tests/0]).
fibOf(0) ->
0;
fibOf(1) ->
1;
fibOf(N) ->
fibOf(N-1) + fibOf(N-2).
@foxbunny
foxbunny / max.erl
Last active February 22, 2017 19:15
-module(max).
-export([maxThree/3, howManyEqual/3, xOr1/2, xOr2/2, xOr3/2, tests/0]).
maxThree(X, Y, Z) -> max(X, max(Y, Z)).
xOr1(X, Y) -> not (X == Y).
xOr2(X, Y) -> X =/= Y.
xOr3(X, Y) -> X == not(Y).
// updateSearchPct :: s -> s -> s
export const updateSearchPct = match(ADD_FLIGHTS,
state => R.assoc('searchPct',
Math.round(state.tickets.length / state.searchTotal) * 100, state))
module.exports = {
entry: './src/index.js',
output: {
path: './pub/static',
publicPath: '/static/',
filename: 'bundle.js',
}
}
var path = require('path')
module.exports = {
entry: './src/index.js',
output: {
path: './static',
publicPath: '/static/',
filename: 'app.js',
},
module: {
@foxbunny
foxbunny / chip-flash.sh
Created May 16, 2016 13:53
Script to flash CHIP
#!/bin/bash
#
# This script programs the CHIP's NAND flash using sunxi-tools' `fel` utiltiy,
# and U-Boot itself. The following tools must be present on the system:
#
# - dd (coreutils)
# - lsusb (usbutils)
# - fel (sunxi-tools)
# - mkimage (android-tools)
#
start on runlevel [2345]
stop on runlevel [06]
exec /path/to/start.sh
propset: (o, p, v=null) ->
[f, r...] = p.split('.')
if not f of o
o[f] = if not r.length then v else {}
h.propset o[f], r.join '.', v
@foxbunny
foxbunny / gist:6352500
Last active December 21, 2015 19:09
CoffeeScript UMD wrapper for modules that use CommonJS format. Also does some dependency checks when not using a module loader. The exported value is also put under a namespace `MyModule.somePath`.
define = ((root) ->
if typeof root.define isnt 'function' or not root.define.amd
if GLOBAL? and typeof module is 'object' and module.exports
(factory) ->
module.exports = factory(GLOBAL.require)
else
require = (dep) ->
(() =>
switch dep
when 'underscore' then @_
@foxbunny
foxbunny / router.coffee
Last active December 21, 2015 05:39
Highly customizable helper class for generating ExpressJS routes that provide a REST interface for Mongoose models
###!
Router
======
@author Branko Vukelic <branko@brankovukelic.com>
@license MIT
@version 0.0.1
###
###