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
@aantonop
aantonop / gist:7787199
Created December 4, 2013 13:11
A script to find bitcoin addresses in Twitter @mentions (replies) responding to my offer to donate bitcoin.
import tweepy
import time
import re
import pycoin.encoding
import pickle
# Removed security tokens from gist, replaced with XXX.
auth = tweepy.OAuthHandler("XXX", "XXX")
auth.set_access_token('XXX', 'XXX')
var duplexify = require('duplexify')
var lpstream = require('length-prefixed-stream')
var ids = require('numeric-id-map')
var util = require('util')
function RPC () {
duplexify.call(this) // subclass yolo
this._encode = lpstream.encode()
this._decode = lpstream.decode()
this._pending = ids()
@JasonMore
JasonMore / backbone.htm
Created April 2, 2012 17:58
Backbone.js TODO app implemented in knockout.js
<!DOCTYPE html>
<html lang="en">
<head>
<title>Backbone.js Todos</title>
<link rel="stylesheet" href="todos.css"/>
</head>
<body>
{
"name": "utp-hole-punching",
"dependencies": {
"utp-native": "*",
"discovery-channel": "*"
}
}
@trevordixon
trevordixon / Routes.js
Last active May 9, 2016 16:59
Very simple Express-like routing for PhantomJS
var Routes = (function() {
var _ = {}, ctor = function(){};
_.bind = function bind(func, context) {
var bound, args, slice = Array.prototype.slice;
args = slice.call(arguments, 2);
return bound = function() {
if (!(this instanceof bound)) return func.apply(context, args.concat(slice.call(arguments)));
ctor.prototype = func.prototype;
var self = new ctor;
var result = func.apply(self, args.concat(slice.call(arguments)));
@nrn
nrn / gist:f818fa7decfd910362b7
Last active September 18, 2016 04:53
Wiki setup for empty ubuntu 14.04 box.
initscript="
start on started networking
stop on stopping networking
respawn
env HOME='/root'
exec wiki -f -p 80
"
@tavisrudd
tavisrudd / Lazy infinite streams in Bash
Last active May 23, 2017 14:30
Lazy, infinite recursive sequences in Bash (like in Haskell, if you squint). The result is ugly but interesting.
Lazy, infinite recursive sequences in Bash (like in Haskell, if you squint).
I was inspired by the beautiful Haskell zipWith implementation of the Fibonacci sequence `fibs = 0 : 1 : zipWith (+) fibs (tail fibs)`
to find an equivalent in bash using 'coroutines' and recursive pipes.
My original experiments were https://twitter.com/tavisrudd/status/367164339716751360
"fun w/ recursive pipes: e=echo;mkfifo fib;{ $e 0 1 1 >fib &};{ while read i j k; do $e $i >&2; $e $j $k $(($j+$k));sleep .4; done;}<fib>fib"
and https://twitter.com/tavisrudd/status/367142071489937408
"o=ouro;b=boros;mkfifo $o$b;e=echo; { $e $o > $o$b & }; { while read s;do $e $s>&2;case $s in $o)$e $b;;*)$e $o; esac; done; }<$o$b >$o$b"
var neat = require('neat-log')
var output = require('neat-log/output')
var progress = require('progress-string')
var crypto = require('crypto')
var hypercore = require('hypercore')
var hyperdiscovery = require('hyperdiscovery')
var feed = hypercore('data', process.argv[2], {valueEncoding: 'json'})
module levelup
version
downloads in the
last 30 days
total downloads
level-sublevel ~0.19.0 151,300 1,226,226
pouchdb 1.3.8 124,983 1,162,731
browserify-fs ^0.18.2 100,027 458,142
pouchdb-adapter-leveldb-core 1.3.8 97,566 419,461
level-packager ~1.3.0 74,165 758,119
merkle-patricia-tree ^1.2.1 13,231 127,025
dynalite ^1.3.3 10,553 258,090
mosca ^1.3.8 9,513 171,844
/**
* Simple userland heapdump generator using v8-profiler
* Usage: require('[path_to]/HeapDump').init('datadir')
*
* @module HeapDump
* @type {exports}
*/
var fs = require('fs');
var profiler = require('v8-profiler');