Skip to content

Instantly share code, notes, and snippets.

View derhuerst's full-sized avatar

Jannis R derhuerst

View GitHub Profile
@derhuerst
derhuerst / a.coffee
Last active January 21, 2016 12:32
minimal test using intravenous
factory = (a) -> foo: 'bar'
module.exports = factory
@derhuerst
derhuerst / test.coffee
Last active February 4, 2016 10:28
another intravenous bug
container = require('intravenous').create
onDispose: (m) -> delete m.data
originalId = Math.random()
container.register 'bucket', {original: originalId}, 'singleton'
@derhuerst
derhuerst / maybe.coffee
Created February 7, 2016 14:37
something like a maybe monad? not sure…
maybe = ->
fns = []
monad = (input) -> fns.reduce ((v, fn) -> fn v), input
Object.assign monad, with: (fn) ->
fns.push (v) -> if v? then fn v else null
monad
@derhuerst
derhuerst / benchmark.coffee
Last active February 8, 2016 18:27
`n + … + 0` in JS
sum = require './sum'
for name, fn of sum
start = Date.now()
i = 500000
while i > 0
n = fn 1000, 0
i--
end = Date.now()
console.log name, end - start
@derhuerst
derhuerst / docker.sh
Last active February 10, 2016 12:57
RPLAN on OS X, using Docker
# assuming you are in the rplan repo
brew update
brew upgrade
brew install docker docker-compose
brew cask install vmware-fusion
ln -s /opt/homebrew-cask/Caskroom/vmware-fusion/8.0.2-3164312/VMware\ Fusion.app /Applications/VMware\ Fusion.app
@derhuerst
derhuerst / bind.js
Created February 14, 2016 18:13
fp helpers in JS ✨
var bind = function () {
var args = Array.from(arguments)
var fn = args.shift()
return function () {
return fn(...args.concat(Array.from(arguments)))
}
}
@derhuerst
derhuerst / readme.md
Last active February 17, 2016 23:14
detect iterables in JavaScript
@derhuerst
derhuerst / escape-regex.js
Created February 20, 2016 14:15
escaping regular expression chars
// from http://blog.simonwillison.net/post/57956816139/escape
module.exports = (regex) => regex.replace(/[-[\]{}()*+?.,\\^$|#\s]/g, '\\$&')
@derhuerst
derhuerst / 0-readme.md
Created February 20, 2016 19:57
comment regexes for a lot of languages

Taken from the wonderful sloc tool.

@derhuerst
derhuerst / install-grub.sh
Created March 5, 2016 01:23
grub 2 with chroot from live stick
sudo mkdir /foo
sudo mount /dev/sda1 /foo # system partition
sudo mount /dev/sda2 /foo/boot/efi # EFI System Partition
sudo mount -o bind /dev /foo/dev
sudo mount -o bind /sys /foo/sys
sudo mount -t proc /proc /foo/proc
sudo cp /proc/mounts /foo/etc/mtab
sudo chroot /foo /bin/bash
# in root shell: