Skip to content

Instantly share code, notes, and snippets.

View jcrugzz's full-sized avatar

Jarrett Cruger jcrugzz

View GitHub Profile
@max-mapper
max-mapper / index.js
Last active May 9, 2021 02:20
fast loading of a large dataset into leveldb
// data comes from here http://stat-computing.org/dataexpo/2009/the-data.html
// download 1994.csv.bz2 and unpack by running: cat 1994.csv.bz2 | bzip2 -d > 1994.csv
// 1994.csv should be ~5.2 million lines and 500MB
// importing all rows into leveldb took ~50 seconds on my machine
// there are two main techniques at work here:
// 1: never create JS objects, leave the data as binary the entire time (binary-split does this)
// 2: group lines into 16 MB batches, to take advantage of leveldbs batch API (byte-stream does this)
var level = require('level')
@dominictarr
dominictarr / CYPHERLINK.md
Last active April 24, 2024 16:17
Cypherlinks
@indexzero
indexzero / swap.sh
Created May 18, 2013 01:24
Increased swap space
dd if=/dev/zero of=/swap bs=1024 count=4194304
mkswap /swap
echo "/swap swap swap sw 0 0" >> /etc/fstab
@indexzero
indexzero / styleguide.md
Last active June 27, 2016 21:29
A working draft of an "official" Nodejitsu Javascript style guide.

Javascript Styleguide

If you have comments on this or disagree about rules then please reach out to me directly. I want to hear it!

Table of Contents

Basics

@indexzero
indexzero / reduce-dir.js
Created March 23, 2013 22:13
Recursively build an object of all files and directories in a directory tree.
var fs = require('fs'),
path = require('path'),
async = require('async');
function reduceDir(dir, mem, callback) {
if (!callback && typeof mem === 'function') {
callback = mem;
mem = null;
}
@SlexAxton
SlexAxton / .zshrc
Last active April 25, 2023 03:57
My gif workflow
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else
@blakmatrix
blakmatrix / gist:4956455
Last active December 13, 2015 18:38
get last 100 lines from logs nodejitsu
curl -X POST -H "Content-Type: application/json" \
https://api.nodejitsu.com/logs/<username>/<appname> \
-d '{"from":"NOW-1DAY","until":"NOW","rows":100}' \
-u <username>:<password/token> | node -e \
"process.stdin.resume();
process.stdin.setEncoding('utf8');
var str = '';
process.stdin.on('data', function (chunk) {str += chunk.toString();});
process.stdin.on('end', function () {
JSON.parse(str).data.forEach(function(i){process.stdout.write(i.json.message);});});"

Hi, all.

Encouraged by my successful experiment with a Node.js view server, I am now working on a branch, nodejs_couchdb, with the following properties:

  • Remove couchjs from the project
  • Remove dependency on SpiderMonkey, libjs, 1.8.whatever...all that is gone
  • Remove dependency on libcurl
  • (Thus, simplified autoconf version dependency Hell)

Phase 1: Dependency on a "couchjs" executable which you install via npm install couchjs

@ndarville
ndarville / business-models.md
Last active January 13, 2024 17:27
Business models based on the compiled list at http://news.ycombinator.com/item?id=4924647. I find the link very hard to browse, so I made a simple version in Markdown instead.

Business Models

Advertising

Models Examples
Display ads Yahoo!
Search ads Google
@jhs
jhs / example.js
Created December 10, 2012 03:16
My Node.js modules these days
// Short module explanation // Something to gather my thoughts
// // I think this looks cool.
//
module.exports = the_exported_function // Modules are a function. Always.
//
module.exports.extra = extra // Additional API entry points if
module.exports.other = other // desired.
//
var util = require('util') // Other packages from npm or core
var assert = require('assert') // No comma-first due to lots of