- Read lots of code.
- Write lots of code.
- Don’t be afraid to throw it away.
- Don’t be afraid to share it.
- Find your happy place writing tests.
- You’ll probably spend more time writing tests and debugging than writing code. Embrace this. Make it a key part of your workflow.
- Tests are one of the first things I read in a module. That and the example(s). Probably before API docs.
- Don’t know where to start. Write some tests for a module you like. This benefits everyone.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//the rule evaluation function is determined by properties: api || (module & api) | |
//the arguments passed to the api will be (req,rules) | |
//where rules is the property *rules* in ruleSet | |
//if just api is set, then rule engine would invoke that function with arguments assuming it is accessible in the namespace | |
//if module + api is set, then rule engine would require that module and invoke speced api on it. | |
//if neither module nor api is set, then the rule engine will try to evaluate on locals | |
//the rule implementation should return true/false | |
//rules will be evaluated with a switch case mentality. WHichever evaluates to truthy first will win |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
function generateConfig(baseDir, protocols, overrides) { | |
var deferred, factory; | |
deferred = q.defer(); | |
factory = confit({ basedir: baseDir, protocols: protocols }); | |
overrides.forEach(function(entry) { | |
factory.override(entry); | |
}); | |
factory.create(function (err, config) { | |
var ovride; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
// make a config object use a confit factory in order to merge two configs | |
exports.create = function create(options) { | |
var deferred, protocols, baseFactory, appFactory; | |
deferred = q.defer(); | |
protocols = createHandlers(options); | |
//create a baseFactory | |
baseFactory = confit({ basedir: path.join(path.dirname(__dirname), 'config'), protocols: protocols }); |
I hereby claim:
- I am pvenkatakrishnan on github.
- I am pvenkatakrishnan (https://keybase.io/pvenkatakrishnan) on keybase.
- I have a public key whose fingerprint is E132 0585 11D8 B8B3 A464 B889 FD38 BC72 3297 F41D
To claim this, I am signing this object:
- Small functions < 30 lines
- Monomorphic (preferable same type arguments)
- Dont leak 'arguments' or dont pass it around
- While working with modifying big arrays, better to for loop through it than create new arrays to modify it (apparently iterating is much faster than memory allcocation time)
Ability to :
- set up a logger before lifecycle events of a kraken app - like when requiring some utility files, talking to services outside of app startup events.
- ability to add category for a logger in addition to tagging them.
- maybe even add capability based on specific labels on logging events ? unsure if we need multiple levels of filtering enabled
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
//the pluginSpec from the instrument module | |
var plugin = { | |
name: 'aPLugin', | |
spec: { | |
'onTransport': { | |
'clients' : 'someClient' /*or*/ ['clienta', 'clientb', 'clientc' ...] /*or * if none specified */, | |
'action': 'exec:./doSomething' | |
}, | |
'onStats': | |
{ |
- Cherry picking args to invoke can lose the
this
context if it were a class instance.
//in path/to/controller
var express = require('express');
var router = express.Router();
router.get('/login', require('path/to/loginMiddleware'));
router.post('/login', require('path/to/loginPostMiddleware'));
router.get('/some/other/route', require('path/to/otherRouteMiddleware'));
OlderNewer