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 / dafuq.md
Last active Aug 29, 2015
That one was nice
View dafuq.md

The bug

/*
  The model is something like:
  Person: { name: String }
  Car: { name: String, driver: {type: Schema.Types.ObjectId, ref: 'Person'} }
*/

// Somewhere we do this…
View random-data.js
var _ = require('lodash')
var utils = require('./mongo-utils')
var docs = require('./random-fixtures')(50000)
var db = utils.connect('mongodb://localhost/test')
db
.then(utils.collection('articles'))
.then(utils.clear)
View ninvoke.js
function wrap (fn, args, thisArg) {
return function () {
return Promise(function (resolve, reject) {
fn.apply(thisArg, (args || []).concat([function (err, res) {
if (err) reject(err)
else resolve(res)
}]))
})
}
}
@naholyr
naholyr / editors.md
Last active Aug 29, 2015
Mon ressenti sur les éditeurs
View editors.md

Contexte

Pour du web (HTML/JS/CSS) + Node sous Ubuntu.

Actuellement : SublimeText, mais pas de visibilité sur le futur du projet (d'où recherche d'alternative).

Challengers

@naholyr
naholyr / index.js
Created Sep 8, 2014
My usual nconf wrapper
View index.js
"use strict";
/**
Save as config/index.js
Config files =
- config/config.json
- config/config.$NODE_ENV.json
- config/config.$NODE_ENV.$USER.json
**/
@naholyr
naholyr / fixtures.js
Created Sep 8, 2014
My usual fixtures loader
View fixtures.js
// TODO comments (lol)
"use strict";
/**
Usage:
- Put your data in data.json
- Require from your test files `var fixtures = require('./path/to/fixtures')
- Load and clear with `before(fixtures.clear)`, `before(fixtures.load)`, `after(fixtures.clear)`
View Promise.defer.js
function defer () {
var _resolve, _reject;
var promise = new Promise(function (resolve, reject) {
_resolve = resolve;
_reject = reject;
});
return {
"promise": promise,
View pathsToTree.js
console.log(JSON.stringify(pathsToTree([
"a/b",
"a/c/d",
"e"
]), null, " "));
/*
{
"e": null,
"a": {
@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 jeu.sh
gnome-terminal --zoom=5 -e ~/bin/tts.sh
You can’t perform that action at this time.