Skip to content

Instantly share code, notes, and snippets.

View tdd's full-sized avatar

Christophe Porteneuve tdd

View GitHub Profile
@tdd
tdd / gist:fb863904b337347cabde
Created June 19, 2014 08:49
Prompt PS1 Bash Git avec les couleurs
export PS1='\[\e[0;36m\][\A] \u@\h:\[\e[0m\e[0;32m\]\W\[\e[1;33m\]$(__git_ps1 " (%s)")\[\e[0;37m\] \$\[\e[0m\]'
@tdd
tdd / findOrCreateByAuth.js
Created December 4, 2014 16:59
findOrCreateByAuth
userSchema.statics.findOrCreateByAuth = function findOrCreateByAuth(id, name, provider, done) {
var User = this;
User.update(
{ _id: id, provider: provider },
{ name: name, provider: provider },
{ upsert: true },
function(err, numAffected, details) {
if (err) {
return done(err);
}
@tdd
tdd / .jshintrc.js
Last active August 29, 2015 14:13
Ma config JSHint par défaut
// Configuration globale au projet de JSHint
// =========================================
//
// (Y compris celui intégré à votre EDI/éditeur, normalement)
//
// [Liste complète des options possibles](http://www.jshint.com/docs/options/)
{
// Options de restriction
// ----------------------
@tdd
tdd / partial.js
Created February 3, 2015 13:55
Partial application
function add(a, b, c) {
return a + b + c;
}
function partial(fx) {
var initial = Array.prototype.slice.call(arguments, 1);
return function() {
var args = Array.prototype.slice.call(arguments);
return fx.apply(this, initial.concat(args));
};
@tdd
tdd / INTRO.md
Last active August 29, 2015 14:15
My roadmap for NodeSchool workshops

Keybase proof

I hereby claim:

  • I am tdd on github.
  • I am porteneuve (https://keybase.io/porteneuve) on keybase.
  • I have a public key whose fingerprint is 4158 4B60 C64C BEC9 D680 C01E F68C 6547 0C78 E0E5

To claim this, I am signing this object:

@tdd
tdd / splice.js
Last active November 17, 2015 10:04
splice exo
var items;
// insertAt //////////////////////////////////
function insertAt(arr, pos, item) {
}
items = ['one', 'two', 'three'];
console.assert(insertAt(items, 1, 'yo') === 4);
@tdd
tdd / web-learning-and-watchind.md
Last active December 9, 2015 13:46
Quelques ressources pour faire sa veille technique et apprendre mieux autour du web

Lisez plutôt…

cet article détaillé que j'ai écrit ensuite…

Je laisse le Gist ici pour ne pas casser vos liens, mais bon 😄

Par e-mailing/RSS/etc.

Chaque jour ou chaque semaine :

@tdd
tdd / backbone-localstorage-sync.js
Created January 30, 2013 13:47
Quick run-through of syncing a Backbone.Collection with a localStorage cache
// Assumes http://brian.io/lawnchair/ and http://backbonejs.org/
var collection = new MyCollection();
var localStore = new Lawnchair({ name: 'my-cache' }, $.noop);
// First load from the cache, then fetch
function initialLoad() {
localStore.all(function(items) {
collection.reset(items, function() {
collection.fetch();
@tdd
tdd / throttle.js
Created June 6, 2013 16:38
Exo de programmation fonctionnelle à trous : Throttling
Function.prototype.throttle = function(/* … */) {
var f = this;
// …
return function() {
// …
return f.apply(this, arguments);
};
};