Skip to content

Instantly share code, notes, and snippets.

View rvagg's full-sized avatar

Rod Vagg rvagg

View GitHub Profile
@rvagg
rvagg / README.md
Last active December 14, 2015 14:59
peerDependencies + gyp builds

peerDependencies + gyp builds

Background: I'm working on a native plugin mechanism for LevelDOWN, the pure-native component of LevelUP. Module authors can write native code and communicate with LevelDOWN via JS to provide a plugin to extends its functionality. LevelDOWN has to export symbols in its gyp build and plugins have to be able to find LevelDOWN in the require() path in order to link to it and include header files. The majority of people will be using/installing LevelUP which installs LevelDOWN. The is an additional JS-layer plugin mechanism being developed for LevelUP but that's a separate matter.

Make a new directory, put the package.json below in it and npm install. At first it breaks, run npm install again and it's fine.

The desired npm ls is this:

tmp@0.0.0
@rvagg
rvagg / README.md
Created March 8, 2013 13:42
LevelUP rangeDel() benchmarks

LevelUP rangeDel() benchmarks

Tests a native C++ .rangeDel() method via upper-rangedel/downer-rangedel against a JavaScript implementation of the same via level-delete-range.

  1. make files with contents below
  2. npm install (twice, first one will fail)
  3. node ./
  4. observe results
@rvagg
rvagg / index.js
Last active December 15, 2015 01:19
LevelUP fill'er'up
const loc = '/somewhere/for/a/massive.db' // somewhere you have space
const fs = require('fs')
, levelup = require('levelup')
, uuid = require('node-uuid')
, bogan = require('boganipsum')
, du = require('du')
, async = require('async')
var writing = 0
@rvagg
rvagg / secretz.js
Last active December 19, 2015 03:18
stream-adventure final
var crypto = require('crypto')
, concat = require('concat-stream')
, zlib = require('zlib')
, tar = require('tar')
, concat = require('concat-stream')
, parser = tar.Parse()
, stream = crypto.createDecipher(process.argv[2], process.argv[3])
parser.on('entry', function (e) {
if (e.type != 'File') return
@rvagg
rvagg / twrealtime.js
Created August 9, 2013 12:32
tw2console hacky thing for campjs
const NTwitter = require('ntwitter')
, secrets = require('./secrets')
, ent = require('ent')
require('colors')
var twit = new NTwitter(secrets.ntwitter)
twit.verifyCredentials(function (err, data) {
if (err) {
console.error('COULD NOT VERIFY TWITTER CREDENTIALS', err)
@rvagg
rvagg / npm-maintainers.js
Last active December 21, 2015 10:19
speeding up nodejs.org.au loading for dev
// download a copy of https://raw.github.com/polyhack/npm-github-data/master/githubusers_au.json
// and https://raw.github.com/polyhack/npm-github-data/master/allpackages.json
// and put them somewhere
//
// in node_modules/npm-maintainers-au/node_modules/npm-maintainers/npm-maintainers.js
// find fetch() and edit it like below:
function fetch (options, callback) {
var result = {}
, done = after(2, function (err) {
@rvagg
rvagg / persona-login-sequence.js
Last active December 21, 2015 18:49
Selenese (Selenium scripting) in node: experimenting with a DSLish interface to WebDriver. Can connect to saucelabs or a local server or other Selenium installation. Looks sync but is heavily async, lots of talking via WebDriver.
const assert = require('referee').assert
, refute = require('referee').refute
, fail = require('referee').fail
// magic pixie dust to get us initialised
const $ = require('selenese_node/sequence')(module)
const loginEmail = 'testmystuff@mockmyid.com'
// some state to maintain along the way
@rvagg
rvagg / _persona-id_transform.js
Created August 28, 2013 06:41
Replacing persona with stubbyid (http://toolness.github.io/stubbyid/) for testing when using Doorknob & Browserify
// replace persona-id's persona.js with stubbyid.js, modified to have an `exports`
// ./_persona-id_stubbyid_js is a copy of https://github.com/toolness/stubbyid/blob/gh-pages/stubbyid.js
const through = require('through2')
, fs = require('fs')
, path = require('path')
, stubbyidFile = path.join(__dirname, '_persona-id_stubbyid_js')
var stubbyid
@rvagg
rvagg / gdb
Created October 8, 2013 03:50
leveldown/leveldb errors
Program received signal SIGSEGV, Segmentation fault.
[Switching to Thread 0x7ffff6bca700 (LWP 25672)]
0x00007ffff4973674 in leveldb::DecodeFixed32 (ptr=0x8 <Address 0x8 out of bounds>)
at ../deps/leveldb/leveldb-1.14.0/util/coding.h:62
62 memcpy(&result, ptr, sizeof(result)); // gcc optimizes this to a plain load
(gdb) backtrace
#0 0x00007ffff4973674 in leveldb::DecodeFixed32 (ptr=0x8 <Address 0x8 out of bounds>)
at ../deps/leveldb/leveldb-1.14.0/util/coding.h:62
#1 0x00007ffff49854f4 in leveldb::WriteBatchInternal::Count (b=0x5698930)
at ../deps/leveldb/leveldb-1.14.0/db/write_batch.cc:83
@rvagg
rvagg / compile.txt
Created October 8, 2013 04:32
hyperleveldb compile warnings & error
CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-hyper/util/bloom.o
CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-hyper/util/env_posix.o
../deps/leveldb/leveldb-hyper/util/env_posix.cc: In member function ‘virtual leveldb::Status leveldb::{anonymous}::PosixEnv::CopyFile(const string&, const string&)’:
../deps/leveldb/leveldb-hyper/util/env_posix.cc:570:30: warning: ‘fd2’ may be used uninitialized in this function [-Wmaybe-uninitialized]
CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-hyper/util/env.o
CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-hyper/util/histogram.o
CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-hyper/util/coding.o
CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-hyper/util/hash.o
CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-hyper/util/logging.o
CXX(target) Release/obj.target/leveldb/deps/leveldb/leveldb-hyper/util/filter_policy.o