Skip to content

Instantly share code, notes, and snippets.

View soldair's full-sized avatar

Ryan Day soldair

  • Google
  • San Jose CA
View GitHub Profile
@soldair
soldair / tarball-rewrite-file-paths.js
Last active February 14, 2019 21:20
easiest way to create a tarball with a file called seahorse.txt with the contents and attributes of a file called file.txt
//@ts-check
// easiest way to create a tarball with a file called seahorse.txt
// with the contents and attributes of a file called file.txt
let Header = require('tar/lib/header')
let ReadEntry = require('tar/lib/read-entry')
let Pack = require('tar/lib/pack.js')
let modeFix = require('tar/lib/mode-fix')
let fs = require('fs')
@soldair
soldair / package.json
Last active February 23, 2018 21:46
coverage doesn't include service worker js reduced test case
{
"name": "pupeteer-service-worker-coverage-test",
"version": "1.0.0",
"description": "",
"main": "index.js",
"bin": {
"b48a0022dbef999f241881f80d7575a9": "./service-worker-test.js"
},
"author": "Ryan Day",
"license": "MIT",
@soldair
soldair / query_local.js
Created October 26, 2017 21:45
query/parse out all /mydb/_local keys in your couchdb data file
var fs = require('fs')
var rs = fs.createReadStream(PATH TO YOUR DATABASE FILE.couch)
var match = new Buffer('_local/')
var matchi = 0
rs.on('data',function(b){
for(var i=0;i<b.length;++i) bite(b,i)
})
@soldair
soldair / gist:c8b7479ad69d7e2e257b30c92802e7d0
Created October 13, 2017 00:45
underscore named packages
curl -s https://replicate.npmjs.com/registry/_changes | grep 'id":"_'
{"seq":2,"id":"_design/scratch","changes":[{"rev":"1-4136ab2028eaa41eeb63e22b028172a0"}]},
{"seq":3,"id":"_design/app","changes":[{"rev":"1-4136ab2028eaa41eeb63e22b028172a0"}]},
@soldair
soldair / readonly.sh
Created September 5, 2017 20:46
make a read only npm token
curl -sLi -X PUT -H 'content-type: application/json' -d '{"name": "USERNAME", "token": true, "password": "PASSWORD", "readonly": true, "email": "EMAIL"}' 'https://registry.npmjs.org/-/user/org.couchdb.user:USERNAME'
@soldair
soldair / inode-debug.sh
Created February 20, 2017 16:40
idnoe debug commands
# list inode use for /
df -Ti /
# find dirs with lots of files
sudo find / -xdev -printf '%h\n' | sort -T /mnt/tmp | uniq -c | sort -T /mnt/tmp/ -k 1 -n
# run apt autoremove with a different cache dir
sudo apt-get -o dir::cache::archives="/mnt/tmp" autoremove -f
@soldair
soldair / etag halp.md
Last active June 30, 2016 13:33
etag halp
@soldair
soldair / versions.json
Created March 25, 2016 19:44
versions that failed to publish.
[
["angular-zinfinitescroll","1.1.2"],
["conforma","1.19.9"],
["jscripty","2.1.1"],
["cue-cli","1.5.18"],
["rdfw","0.0.1"],
["rdfw","0.0.2"],
["binder-utils","1.0.0"],
["tidying-media-codec-audio","0.2.1"],
["tidying-media-codec-audio-aac","0.2.1"],
@soldair
soldair / tailfd-dir.js
Last active February 8, 2016 15:12
tailfd directory example
var fs =require('fs')
var path = require('path')
// these will need to be in the package.json
var tailfd = require('tailfd')
var through = require('through2')
// use:
// var taildir = require('./')
// var stream = taildir(dir)
// stream.on('data',function(data){
// console.log(data.line)
@soldair
soldair / read-end-of-file.js
Created August 26, 2015 21:40
read the end of a file
var fs = require('fs')
// usage example:
// var t = require('./this-file.js')
// t('/var/log/boot.log',1024,function(err,data){ console.log(data+'')})
//
module.exports = function(file,lastNBytes,cb){
var fd, size, called
var orig = cb
var start = function fn(err,data){