Skip to content

Instantly share code, notes, and snippets.

# Reserved Strings
#
# Strings which may be used elsewhere in code
undefined
undef
null
NULL
(null)
nil
@czzarr
czzarr / bash
Created March 6, 2019 14:27
extract the "users" branch from the database via streaming
jq -nc --stream '
def atomize(s):
fromstream(foreach s as $in ( {previous:null, emit: null};
if ($in | length == 2) and ($in|.[0][0]) != .previous and .previous != null
then {emit: [[.previous]], previous: $in|.[0][0]}
else { previous: ($in|.[0][0]), emit: null}
end;
(.emit // empty), $in) ) ;
atomize(1|truncate_stream(inputs | select(.[0][0] == "users")))' fb_yamm_data.json > yamm_users.json

Keybase proof

I hereby claim:

  • I am czzarr on github.
  • I am stan (https://keybase.io/stan) on keybase.
  • I have a public key whose fingerprint is E532 512A 6F94 3EC0 71F7 7225 A3CC 07A9 BD2F 588F

To claim this, I am signing this object:

@czzarr
czzarr / gist:7988649
Created December 16, 2013 15:15
piping data to feedgnuplot in a child process
var spawn = require('child_process').spawn
var feedgnuplot = spawn('feedgnuplot', ['--stream 0.02', '--xlen 200', '--lines'])
someReadableStream.pipe(feedgnuplot.stdin)
@czzarr
czzarr / head.html
Created July 9, 2013 09:52 — forked from juliangruber/head.html
requirebin sketch
<style type='text/css'> html, body { margin: 0; padding: 0; border: 0; } </style>
@czzarr
czzarr / head.html
Created July 9, 2013 09:49 — forked from juliangruber/head.html
made with requirebin.com
<style type='text/css'> html, body { margin: 0; padding: 0; border: 0; } </style>
@czzarr
czzarr / index.js
Created July 9, 2013 08:46
requirebin sketch
// require something
console.log('beep baaaaap boop biiiiiip');
var url = require('url');
@czzarr
czzarr / streams2.js
Last active December 19, 2015 05:09
Transform a Readable objects stream into a buffer stream with a Transform stream.
var stream = require('stream');
var through = stream.Transform();
through._writableState.objectMode = true;
through._transform = function (chunk, encoding, done) {
this.push(JSON.stringify(chunk));
this.push('\n');
done();
};
@czzarr
czzarr / grunt.js
Created July 28, 2012 14:54
Custom grunt directive processing in config?
module.exports = function (grunt) {
// custom helper
grunt.registerHelper('concat_two_strings', function (a,b) {
return a + b;
}
// config
grunt.initConfig({
lint: { files: ['<concat_two_strings:need:linting>/*.js'] } // is this supposed to work or not?
});