Skip to content

Instantly share code, notes, and snippets.

Avatar
💭
RIP Jazon ❤️

Lars-Magnus Skog ralphtheninja

💭
RIP Jazon ❤️
  • Pergas
  • Linköping, Sweden
View GitHub Profile
@ralphtheninja
ralphtheninja / overload.js
Last active Aug 29, 2015
overloading functions in javascript (from DailyJS)
View overload.js
var __slice = [].slice
var __toString = {}.toString
var __noop = function (){}
function typeOf(x) {
return __toString.call(x).slice(8,-1)
}
function overload(fs) {
return function () {
View promises.md

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 Jul 12, 2014
parse out image size from calling identify
View image-size.sh
#!/bin/bash
SIZE=$(identify $1 | awk '{print $3}')
W=${SIZE%%x*}
H=${SIZE##*x}
echo $SIZE $W $H
View execfn.js
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 Aug 15, 2014
reversed genesis block
View genesis.js
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 Aug 29, 2015
upstart conf for zetacoind
View zetacoind.conf
# 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
#
View zalgo.js
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) {
View 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.
View 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.
View squatconf ml
#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)