Skip to content

Instantly share code, notes, and snippets.

View ralphtheninja's full-sized avatar
🏠
Working from home

ralphtheninja

🏠
Working from home
View GitHub Profile
@ralphtheninja
ralphtheninja / overload.js
Last active August 29, 2015 13:55
overloading functions in javascript (from DailyJS)
var __slice = [].slice
var __toString = {}.toString
var __noop = function (){}
function typeOf(x) {
return __toString.call(x).slice(8,-1)
}
function overload(fs) {
return function () {

This article has been given a more permanent home on my blog. Also, since it was first written, the development of the Promises/A+ specification has made the original emphasis on Promises/A seem somewhat outdated.

You're Missing the Point of Promises

Promises are a software abstraction that makes working with asynchronous operations much more pleasant. In the most basic definition, your code will move from continuation-passing style:

getTweetsFor("domenic", function (err, results) {
 // the rest of your code goes here.
@ralphtheninja
ralphtheninja / image-size.sh
Created July 12, 2014 22:42
parse out image size from calling identify
#!/bin/bash
SIZE=$(identify $1 | awk '{print $3}')
W=${SIZE%%x*}
H=${SIZE##*x}
echo $SIZE $W $H
var execFn = function(cmd, opts) {
opts = opts || {}
return function(cb) {
console.log(cmd)
exec(cmd, opts, function(error, stdout, stderr) {
if (error) {
console.error(error);
} else {
console.log('ok')
}
@ralphtheninja
ralphtheninja / genesis.js
Created August 15, 2014 21:21
reversed genesis block
var mirror = new Buffer('6FE28C0AB6F1B372C1A6A246AE63F74F931E8365E15A089C68D6190000000000', 'hex')
console.log('buffer length should be 32 bytes (or 32 * 8 = 256 bits)', mirror.length)
console.log('mirrored genesis block (bitpay does this for some odd reason):')
console.log(mirror)
var length = mirror.length
var genesis = new Buffer(length)
for (var i = 0; i < length; ++i) {
genesis.writeUInt8(mirror.readUInt8((length - 1) - i), i)
}
console.log('real genesis block:')
@ralphtheninja
ralphtheninja / zetacoind.conf
Last active August 29, 2015 14:05
upstart conf for zetacoind
# save this file as: /etc/init/zetacoind.conf
#
# start zetacoind: 'sudo start zetacoind'
#
# stop zetacoind: 'sudo stop zetacoind'
#
# restart zetacoind: 'sudo restart zetacoind'
# note, if you change this configuration file, a restart is not enough,
# you need to stop and start
#
function synchCallback(opts, cb) {
if (!opts.someImportantProperty) return cb(new Error('Missing important property'))
doSomeStuff(opts, function(err, result) {
console.log(err, result)
// ..
cb(err, result)
})
}
synchCallback({}, function(err, results) {
@ralphtheninja
ralphtheninja / Makefile
Last active August 29, 2015 14:13 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
@ralphtheninja
ralphtheninja / Makefile
Last active August 29, 2015 14:13 — forked from isaacs/Makefile
# Hello, and welcome to makefile basics.
#
# You will learn why `make` is so great, and why, despite its "weird" syntax,
# it is actually a highly expressive, efficient, and powerful way to build
# programs.
#
# Once you're done here, go to
# http://www.gnu.org/software/make/manual/make.html
# to learn SOOOO much more.
#squatconf 2, Kickoff
Hi there, Some of us started to talk about the 2nd edition of squatconf, and this mailing list if a perfect point to start a broader discussion about it and share the infos for the one that was not there
what was actually talked about :
Location :
- BARCELONA
- Amsterdam (ping realitygaps, webmind)