Skip to content

Instantly share code, notes, and snippets.

#!/bin/sh
if [ -z "$1" ]; then
echo "argument required"
exit 1
else
jq "[.[].$1 | if (type) == \"array\" then .[] else [][] end] | length"
fi
@olivierrr
olivierrr / index.js
Created December 19, 2014 20:27
requirebin sketch
// very require
console.log(require('events'))
@olivierrr
olivierrr / index.js
Created December 22, 2014 01:34
requirebin sketch
var timer = null
elem.addEventListener('click', function(){
if(timer) {
clearTimeout(timer)
doStuff()
}
else timer = setTimeout(doStuff, 3000)
})
@olivierrr
olivierrr / index.js
Created December 29, 2014 01:27
requirebin sketch
var state = new (require('objectstate'))()
, write = require('dom-replace-html-stream')
, events = require('dom-event-stream')
, values = require('dom-value-stream')
var $input = document.body.appendChild(document.createElement('input'))
var $output = document.body.appendChild(document.createElement('h1'))
var input = events($input, 'input').pipe(values())
var output = write($output)
;(function(){
// @lib https://github.com/bgrins/javascript-astar/blob/master/astar.js
!function(t){if("object"==typeof module&&"object"==typeof module.exports)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();window.astar=n.astar,window.Graph=n.Graph}}(function(){function t(t){for(var n=t,i=[];n.parent;)i.push(n),n=n.parent;return i.reverse()}function n(){return new o(function(t){return t.f})}function i(t,n){n=n||{},this.nodes=[],this.diagonal=!!n.diagonal,this.grid=[];for(var i=0;i<t.length;i++){this.grid[i]=[];for(var o=0,s=t[i];o<s.length;o++){var r=new e(i,o,s[o]);this.grid[i][o]=r,this.nodes.push(r)}}this.init()}function e(t,n,i){this.x=t,this.y=n,this.weight=i}function o(t){this.content=[],this.scoreFunction=t}var s={search:function(i,e,o,r){i.cleanDirty(),r=r||{};var h=r.heuristic||s.heuristics.manhattan,c=r.closest||!1,u=n(),a=e;for(e.h=h(e,o),u.push(e);u.size()>0;){var f=u.pop();if(f===o)return t(f);f.closed=!0;for(var p=i.neighbors(f),l=0,d=p.length;d>
;(function(){
// @lib https://github.com/bgrins/javascript-astar/blob/master/astar.js
!function(t){if("object"==typeof module&&"object"==typeof module.exports)module.exports=t();else if("function"==typeof define&&define.amd)define([],t);else{var n=t();window.astar=n.astar,window.Graph=n.Graph}}(function(){function t(t){for(var n=t,i=[];n.parent;)i.push(n),n=n.parent;return i.reverse()}function n(){return new o(function(t){return t.f})}function i(t,n){n=n||{},this.nodes=[],this.diagonal=!!n.diagonal,this.grid=[];for(var i=0;i<t.length;i++){this.grid[i]=[];for(var o=0,s=t[i];o<s.length;o++){var r=new e(i,o,s[o]);this.grid[i][o]=r,this.nodes.push(r)}}this.init()}function e(t,n,i){this.x=t,this.y=n,this.weight=i}function o(t){this.content=[],this.scoreFunction=t}var s={search:function(i,e,o,r){i.cleanDirty(),r=r||{};var h=r.heuristic||s.heuristics.manhattan,c=r.closest||!1,u=n(),a=e;for(e.h=h(e,o),u.push(e);u.size()>0;){var f=u.pop();if(f===o)return t(f);f.closed=!0;for(var p=i.neighbors(f),l=0,d=p.length;d>
var http = require('http')
, moment = require('moment')
module.exports = function(ziggy) {
ziggy.on('message', handle)
function handle(user, channel, message) {
var arg
@olivierrr
olivierrr / index.js
Created January 29, 2015 23:43
requirebin sketch
var knob = require('dom-knob')
var elem = document.body.appendChild(document.createElement('div'))
elem.style.background = 'red'
elem.style.padding = '100px'
elem.style.fontSize = '30px'
knob(elem, function(deg) {
elem.innerHTML = deg
#!/bin/bash
# compile brainf*ck to groot
# "+" "i am groot"
# "-" "I am Groot"
# "." "I AM GROOOT"
# ">" "I AM GROOT"
# "<" "I am groot"
# "," "I am grooot"
@olivierrr
olivierrr / mandlebrot.groot
Last active August 29, 2015 14:14
mandlebrot in groot lang
i am groot
i am groot
i am groot
i am groot
i am groot
i am groot
i am groot
i am groot
i am groot
i am groot