Skip to content

Instantly share code, notes, and snippets.

Nicolas Chambrier naholyr

Block or report user

Report or block naholyr

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
@naholyr
naholyr / app1.js
Last active Jan 21, 2016
Time a middleware
View app1.js
// generic reusable
app.use(timeMiddleware('session', session));
//
function timeMiddleware (description, middleware) {
return function (req, res, next) {
var start = process.hrtime();
middleware(req, res, function (err) {
@naholyr
naholyr / client.js
Created Dec 21, 2015
Express + socket.io CLI client
View client.js
var Promise = require('bluebird');
var request = require('request-promise');
var io = require('socket.io-client');
var jar = request.jar();
/**
* Connect to web interface
*/
request({
uri: loginActionUrl,
View index.js
// foo() fait une opération compliquée
// mais c'est codé un peu avec les pieds et un des EventEmitter déclaré (et non exposé)
// dans la fonction émet parfois un "error" non catché qui pète mon application :(
var foo = require("./module-pourri");
// Ça fait parfois péter mon app :(
//foo();
View keybase.md

Keybase proof

I hereby claim:

  • I am naholyr on github.
  • I am naholyr (https://keybase.io/naholyr) on keybase.
  • I have a public key whose fingerprint is EC19 8266 EF73 F79E 84AA E931 B111 3B99 36F2 E232

To claim this, I am signing this object:

View tree-async.js
function dirTree (filename, cb) {
fs.lstat(filename, function (err, stat) {
if (err) {
return cb(err);
}
var info = {
"path": filename,
"name": path.basename(filename)
View jeu.sh
gnome-terminal --zoom=5 -e ~/bin/tts.sh
@naholyr
naholyr / README.md
Last active Aug 29, 2015
React trivial keys
View README.md

See the discussion

Before (not good):

return <ul>{ paragraphs.map(p => <li>{ p }</li>) }</ul>;
// Each child in an array should have a unique "key" prop. Check the render method of RoomSpace. See http://fb.me/react-warning-keys for more information.

Uglier (not sure better):

View pathsToTree.js
console.log(JSON.stringify(pathsToTree([
"a/b",
"a/c/d",
"e"
]), null, " "));
/*
{
"e": null,
"a": {
@naholyr
naholyr / Makefile
Last active Mar 6, 2018
browserify-friendly Makefile
View Makefile
# Main entry point
SOURCE = src/app.js
# The dependencies (other than node_modules/**)
LIBS = $(shell ls src/lib/*.js src/components/*.js)
# The target
TARGET = build/app.js
# Compilation flags
View Promise.defer.js
function defer () {
var _resolve, _reject;
var promise = new Promise(function (resolve, reject) {
_resolve = resolve;
_reject = reject;
});
return {
"promise": promise,
You can’t perform that action at this time.