Skip to content

Instantly share code, notes, and snippets.

View assertnotnull's full-sized avatar
🏠
Working from home

Patrice Gauthier assertnotnull

🏠
Working from home
View GitHub Profile
* {
font-size: 12pt;
font-family: monospace;
font-weight: normal;
font-style: normal;
text-decoration: none;
color: black;
cursor: default;
}
@assertnotnull
assertnotnull / concurrent.js
Last active August 29, 2015 14:20
Q promises concurrency test
var Q = require('q');
var debug = require('debug')('test');
var func1 = function() {
return Q.promise(function(resolve, reject) {
setTimeout(function() {
debug('concurrent func1?');
resolve(1);
}, 4000);
});
@assertnotnull
assertnotnull / socketlogger.js
Created June 11, 2015 16:14
somewhat reusable socket logger
//somewhat reusable module socketlogger - it requires the usage of global.socket
//so it's not passed to every log function.
function SocketLogger() {}
var getLogger = function(categoryName) {
SocketLogger.prototype = log4js.getLogger(categoryName);
['Trace','Debug','Info','Warn','Error','Fatal', 'Mark'].forEach(
function (levelString) {
var level = log4js.levels.toLevel(levelString);
@assertnotnull
assertnotnull / reduce.js
Created September 3, 2015 16:12
Simple sum of promises
var Q = require('q');
var myarr = [1,2,3,4,5];
Q.resolve(myarr).then(function (results) {
return results.reduce(function (prev, current) {
console.log(prev, current);
return prev + current;
})
}).then(function (sum) {
@assertnotnull
assertnotnull / cookie.html
Created November 10, 2015 18:48
Simple riot tag update
@assertnotnull
assertnotnull / RiotControl.js
Last active November 18, 2016 13:56
Autonomous riot.js paging
var RiotControl = {
_stores: [],
addStore: function(store) {
this._stores.push(store);
}
};
['on','one','off','trigger'].forEach(function(api){
RiotControl[api] = function() {
var args = [].slice.call(arguments);
@assertnotnull
assertnotnull / asClassv1.js
Last active April 22, 2016 13:41
Ways to define modules in node
var onedep = require('one');
var self;
function AsClass(param) {
this.param = param;
}
AsClass.prototype.doSomething(param) {
console.log('can access',self.param);
onedep('whatever', function() {
@assertnotnull
assertnotnull / .screenrc
Created April 28, 2016 18:33
screen config
hardstatus alwayslastline
hardstatus string '%{= kG}[ %{G}%H %{g}][%= %{= kw}%?%-Lw%?%{r}(%{W}%n*%f%t%?(%u)%?%{r})%{w}%?%+Lw%?%?%= %{g}][%{B} %m-%d %{W}%c %{g}]'
@assertnotnull
assertnotnull / README.md
Last active May 13, 2016 14:19
Graphite events

Graphite annotations

##Using graphite tags

I suggest use of tags like: appname, environment, host, eventtype

So we can search them

Using graphite sets

@assertnotnull
assertnotnull / index.js
Created May 27, 2016 18:30
forward seneca logging to bunyan
var config = {
log: {fileinfo: {level: 'INFO', filename: 'whitelabel'}, console: {level: 'DEBUG'}, name: 'whitelabel'},
seneca: {level: 'INFO'}
}
var bunyan = require('bunyan-loader')(config) //setup bunyan
bunyan.info('Using node', process.version)
var seneca = require('seneca')
var logger = bunyan.child({scope: 'seneca'})
seneca = seneca({
log: {