Skip to content

Instantly share code, notes, and snippets.

@rmg
rmg / npm.md
Last active November 13, 2017 01:14
npm@3

npm install -g strongloop

This is a plain installation of the strongloop module in a fresh docker container with node-v0.10.39 (see Dockerfile or docker pull strongloop/strongbox:dev). The only difference between the 2 containers is the npm@3 container had npm install -g npm@3 run on it before these tests.

npm@2

strongbox@23e5cea0a3f1:~$ npm --version
2.11.3
strongbox@23e5cea0a3f1:~$ time npm install -g strongloop && du -sch /usr/local/lib/node_modules/strongloop
@rmg
rmg / usage.md
Last active August 29, 2015 14:08
CLI usage conventions

CLI usage is documented using the following conventions:

  • required parameters are indicated with angle brackets or all-caps:
    • ping <hostname>
    • ping HOSTNAME
  • optional parameters are indicated with square brackets:
    • mkdir [-p] <dirname>
  • repeated items are indicated with elipses:
    • cp <source1> [source2...] <dest>
  • mutually exclusive options are indicated with a vertical bar:
@rmg
rmg / README.md
Last active July 26, 2023 19:34
Dump current directory and all contents to a git branch

git-snapshot

Out of band syncing to a local git branch.

This started as an experiment to see how commits could be created without modifying the working directory, the index, or the state of HEAD. The end result is like a cross between rsync and git stash using a specified branch.

Benefits

@rmg
rmg / elasticsearch.log
Last active August 29, 2015 14:03
Log Aggregation
{"message":"ARGV: [\"/usr/local/bin/node\",\".\"]","@version":"1","@timestamp":"2014-06-20T16:13:29.117Z","host":"Ryans-StrongMac.local","path":"/var/log/strong-supervisor/logger-app.log","pid":"89371","worker":"1","level":"DEBUG","tags":["DEBUG"]}
{"message":"application started","@version":"1","@timestamp":"2014-06-20T16:13:29.118Z","host":"Ryans-StrongMac.local","path":"/var/log/strong-supervisor/logger-app.log","pid":"89371","worker":"1","level":"INFO","tags":["INFO"]}
{"message":"about to do something horrible!","@version":"1","@timestamp":"2014-06-20T16:13:29.118Z","host":"Ryans-StrongMac.local","path":"/var/log/strong-supervisor/logger-app.log","pid":"89371","worker":"1","level":"WARN","tags":["WARN"]}
{"message":"[Error: Something horrible!]","@version":"1","@timestamp":"2014-06-20T16:13:29.118Z","host":"Ryans-StrongMac.local","path":"/var/log/strong-supervisor/logger-app.log","pid":"89371","worker":"1","level":"ERROR","tags":["ERROR"]}
@rmg
rmg / console.txt
Created May 28, 2014 22:53
Bare miminimum LoopBack app
{
"error": {
"name": "Error",
"status": 404,
"message": "Shared class \"person\" has no method handling GET /",
"statusCode": 404,
"stack": "Error: Shared class \"person\" has no method handling GET /\n at Object.restRemoteMethodNotFound [as handle] (/Users/ryan/work/strong-remoting/lib/rest-adapter.js:205:17)\n at next (/Users/ryan/work/strong-remoting/node_modules/express/node_modules/connect/lib/proto.js:193:15)\n at Object.expressInit [as handle] (/Users/ryan/work/strong-remoting/node_modules/express/lib/middleware.js:30:5)\n at next (/Users/ryan/work/strong-remoting/node_modules/express/node_modules/connect/lib/proto.js:193:15)\n at Object.query [as handle] (/Users/ryan/work/strong-remoting/node_modules/express/node_modules/connect/lib/middleware/query.js:45:5)\n at next (/Users/ryan/work/strong-remoting/node_modules/express/node_modules/connect/lib/proto.js:193:15)\n at Function.app.handle (/Users/ryan/work/strong-remoting/node_modules/express/node_modules/conn
@rmg
rmg / USAGE.md
Created May 6, 2014 20:54
Testing basic auth proxy
  1. Use squid.conf with squid 3.2+
  2. export HTTP_PROXY=http://user:allow@localhost:3128/
  3. run your $HTTP_PROXY aware test for success case
  4. export HTTP_PROXY=http://user:fail@localhost:3128/
  5. run your $HTTP_PROXY aware test for auth failure case
  6. export HTTP_PROXY=http://user:error@localhost:3128/
  7. run your $HTTP_PROXY aware test for auth error case
@rmg
rmg / README.md
Last active August 29, 2015 13:57
GitHub Commits Report

Simple Ruby script for getting stats on commit activity.

Uses octokit for GitHub API access and terminal-table for output formatting:

$ gem install octokit terminal-table faraday-http-cache activesupport

You'll also need a GitHub API token stored in your ~/.gitconfig. Go to https://github.com/settings/tokens/new and generate a new token (will need repo and user access). Once you have your token, save it:

@rmg
rmg / scope.js
Created February 7, 2014 19:02
Dynamic scoping in JavaScript
name = 'global'; // skip var to make true global in node
var a = { name: 'a' };
var b = { name: 'b' };
// make a global variable 'named' and assing the function to it
// if we just do function named() {} then it is scoped as though we used var
named = function func(/* this, not a real argument */ arg) {
console.log("this:", this.name, "arg:", arg.name);
}
@rmg
rmg / 0_reuse_code.js
Created February 6, 2014 21:09
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
@rmg
rmg / gist:8656027
Created January 27, 2014 19:54
Behaviour of Node's require() under repl, module, and -e.
$ cat req.js
console.log('global.require', global.require)
console.log('bare require', require)
console.log('global.require === require', global.require === require)
$ node req.js
global.require undefined
bare require function require(path) {
return self.require(path);
}