Skip to content

Instantly share code, notes, and snippets.

@sent-hil
Created October 2, 2012 17:42
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save sent-hil/3821532 to your computer and use it in GitHub Desktop.
Save sent-hil/3821532 to your computer and use it in GitHub Desktop.
HS: +1 Node noodles

Debug in node

See: https://github.com/dannycoates/node-inspector

# Install node npm
npm -g install node-inspector

# Start debugger
node-inspector &
node --debug launch.js

# Open in chrome
http://127.0.0.1:8080/debug?port=5858

# Click on Script tab and arrow key to find js file
# Click on line number to set break there

Loading exports from a module efficiently

See: http://blog.maxaller.name/2011/10/coffeescript-in-node-js/

MyClass = require("./my_class").MyClass

// same as
{MyClass} = require("./my_class")

Call string as f()

> hash = {}; for (var key in Faker.Address) {
    hash[key]=eval("Faker.Address."+key+"()");
}

// Faker.Address.key() same as Faker.Address['key']()
> hash = {}; for (var key in Faker.Address) {
    hash[key]=Faker.Address[key]();
}
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment