Skip to content

Instantly share code, notes, and snippets.

View ricardobeat's full-sized avatar

Ricardo Tomasi ricardobeat

View GitHub Profile
@ricardobeat
ricardobeat / task.js
Last active November 4, 2020 10:27
minimal task runner
#!/usr/bin/env node
const _tasks = {}
function task (name, fn) {
_tasks[name] = fn
}
task.run = async function (name, wait) {
if (!name) return console.warn(`Usage: node task [name]`)
if (!_tasks[name]) return console.warn(`No task named ${name}`)
@ricardobeat
ricardobeat / search.sh
Created April 10, 2017 14:47
Git: digging for lost code - unlabeled stashes etc
git fsck --no-reflogs | awk '/dangling commit/ {print $3}'| while read hash; do
echo "$hash"
git show $hash | grep -H -C4 svg
done

Simple comparison between Atomic CSS vs 'standard' CSS. Might not be representative of larger files.

results

file raw gzip
with-atomic.css 576b 325b
with-atomic.html 1183b 254b
without-atomic.css 1676b 324b
without-atomic.html 714b 199b
function AbortablePromise (fn) {
var abortHandler;
function onAbort (abortFn) {
abortHandler = abortFn;
}
var promise = new Promise(function (resolve, reject) {
fn.call(null, resolve, reject, onAbort);
Verifying I am +ricardobeat on my passcard. https://onename.com/ricardobeat
Promise.prototype.spread = function (fn) {
this.then(function (values) {
fn.apply(this, values)
})
}
function when () {
var requirements = Array.prototype.slice.call(arguments, 0)
return Promise.all(requirements.map(function(name){
@ricardobeat
ricardobeat / stupid-ie7-console-log.js
Last active August 29, 2015 14:13
IE7 panel for console.*
;(function () {
var doc = document.documentElement
var IE7 = navigator.userAgent.indexOf('MSIE 7') > 0
logpane = document.createElement('div')
var height = 180
var width = 480
document.body.appendChild(logpane)
logpane.style.background = '#fff'
logpane.style.padding = '10px'
logpane.style.position = IE7 ? 'absolute' : 'fixed'
@ricardobeat
ricardobeat / chess.js
Last active August 29, 2015 14:13
compiling chess results with node streams
#!/usr/bin/env node
var fs = require('fs')
var path = require('path')
var dir = process.argv[2]
if (!dir) throw new Error('Usage: ./chess.js path-to-pgn-files/ ')
var white = 0
var black = 0
@ricardobeat
ricardobeat / .prompt
Created December 3, 2014 10:46
simpler prompt
function _e () {
local color; local escape; local newline; local bold=0
if [[ $1 == "bold" ]]; then
shift; bold=1
fi
case $1 in
white ) color=37 ;;
red ) color=31 ;;
green ) color=32 ;;
yellow ) color=33 ;;