Skip to content

Instantly share code, notes, and snippets.

@lkptrzk
lkptrzk / script-boilerplate.js
Created Oct 23, 2015
nodejs script boilerplate
View script-boilerplate.js
var Async = require('async');
exports.script = function () {
var options = internals.parseOptions();
var context = {
options: options,
state: {},
View dynamodb-doc-test.js
var Aws = require('aws-sdk');
var DynamoClient = require('dynamodb-doc').DynamoDB;
// This script uses the Shared Credentials File. See reference below for more:
// http://docs.aws.amazon.com/AWSJavaScriptSDK/guide/node-configuring.html
Aws.config.update({ region: 'us-east-1' });
var internals = {};
@lkptrzk
lkptrzk / fetch-s3-folder.js
Created Nov 14, 2014
fetch all files from s3 bucket with given prefix and stream them to disk
View fetch-s3-folder.js
// fetch-s3-folder.js
//
// usage: node fetch-s3-folder.js bucketName folderPath
// ex: node fetcb-s3-folder.js our-bucket /my-folder/cool-subfolder
//
// to install dependencies, run following in same folder as this script:
// mkdir node_modules && npm install async knox mkdirp
//
// also expects a `config.json` in same directory with AWS credentials
View serialport-sniff.js
var SerialPort = require('serialport').SerialPort;
var util = require('util');
if (!process.argv[2]) {
console.error('specify device');
process.exit(1);
}
var PATH = process.argv[2];
var DATA = {};
@lkptrzk
lkptrzk / check-git
Created Nov 9, 2014
check state of a git repo
View check-git
#!/bin/bash
git pull && \
git remote prune origin && \
git status && \
git stash list && \
git branch -a
View plain-js-date-math.js
var thirtyDays = 1000 * 60 * 60 * 24 * 30;
var today = new Number(new Date());
new Date(today + thirtyDays);
@lkptrzk
lkptrzk / pretty-json
Created May 15, 2014
pretty print json from stdin
View pretty-json
#!/usr/bin/env node
var concat = require('concat-stream');
process.stdin.pipe(concat(function (data) {
var json = JSON.parse(data);
var str = JSON.stringify(json, null, 2);
View node-irc-bot.js
// quick sketch based on http://davidwalsh.name/nodejs-irc
var Irc = require('irc')
var settings = {
channels: [
'#node.js'
],
server: 'irc.freenode.net',
botName: 'idlebot'
@lkptrzk
lkptrzk / get-spumko-makefiles.js
Last active Aug 29, 2015
get-spumko-makefiles.js
View get-spumko-makefiles.js
// node get-spumko-makefiles.js && vim *.Makefile
var Async = require('async')
var Fs = require('fs')
var Request = require('request')
Request({
uri: 'https://api.github.com/orgs/spumko/repos',
headers: {
'User-Agent': ' '
@lkptrzk
lkptrzk / index.js
Created Mar 13, 2014
requirebin sketch
View index.js
console.log('logging:')
console.log(asdf)
console.log(foo)
function asdf () {
// noop
}
var foo = function () {
// asdf