Skip to content

Instantly share code, notes, and snippets.

function dirTree (filename, cb) {
fs.lstat(filename, function (err, stat) {
if (err) {
return cb(err);
}
var info = {
"path": filename,
"name": path.basename(filename)

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:

// 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();
@naholyr
naholyr / full.js
Created January 9, 2011 22:25
Liste des auteurs triés par nombre de livre
m = function() {
this.nb_books = this.books.length;
emit(this._id, this);
}
r = function(k,v) {
return v[0];
}
db[db.authors.mapReduce(m, r).result].find().sort({nb_books:-1})
@naholyr
naholyr / autocompletion_fail.sh
Created March 9, 2011 22:34
Stupid basic autocompletion, broken by PHP
_test_completion()
{
php -r "echo 'coucou';" > /dev/null # useless call to PHP
# Any call to PHP will make this occur: I was trying to parse the output of Symfony2's app/console
# and had a huge headache before I just made this test... and gave up.
COMPREPLY=( $(compgen -W "world myself everyone") )
}
complete -o default -F _test_completion hello
services:
dumb:
class: Acme\DumbService
arguments:
- "name"
- "hello": { "world": { "foo": %mailer_host% } }
/*
* Copyright 2011 Google Inc.
*
* Licensed under the Apache License, Version 2.0 (the "License");
* you may not use this file except in compliance with the License.
* You may obtain a copy of the License at
*
* http://www.apache.org/licenses/LICENSE-2.0
*
* Unless required by applicable law or agreed to in writing, software
@naholyr
naholyr / default.vcl
Created March 29, 2011 20:16
index.html
backend default {
.host = "test-esi.localhost";
.port = "8000";
}
sub vcl_fetch {
esi;
}
@naholyr
naholyr / es5.js
Created May 25, 2011 13:06
Object destructuring for function parameters
function ajax(options) {
options = Object.extend({
"method": "POST",
"error": function() {},
"success": function() {},
// ...
}, options || {})
try {
@naholyr
naholyr / app.js
Created May 27, 2011 14:39
Application bidon "forum" d'exemple
/** Liste des threads du forum */
const threads = [
{ id: 1, title: 'First thread' },
{ id: 33, title: 'Oh noes, Jesus died' },
{ id: 42, title: 'Ze answer' }
]
/** Déclaration de l'application */
var app = require('express').createServer().configure(function() {