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 / full.js
Created Jan 9, 2011
Liste des auteurs triés par nombre de livre
View full.js
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 Mar 9, 2011
Stupid basic autocompletion, broken by PHP
View autocompletion_fail.sh
_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
View config.yml
services:
dumb:
class: Acme\DumbService
arguments:
- "name"
- "hello": { "world": { "foo": %mailer_host% } }
View DashboardLayout.java
/*
* 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
View default.vcl
backend default {
.host = "test-esi.localhost";
.port = "8000";
}
sub vcl_fetch {
esi;
}
@naholyr
naholyr / es5.js
Created May 25, 2011
Object destructuring for function parameters
View es5.js
function ajax(options) {
options = Object.extend({
"method": "POST",
"error": function() {},
"success": function() {},
// ...
}, options || {})
try {
@naholyr
naholyr / app.js
Created May 27, 2011
Application bidon "forum" d'exemple
View app.js
/** 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() {
@naholyr
naholyr / enableMultipleViewRoots.js
Created May 27, 2011
Allow multiple views roots in Express.js
View enableMultipleViewRoots.js
// Usage:
// var express = require('express')
// require('enableMultipleViewRoots')(express)
module.exports = function(express) {
var old = express.view.lookup;
function lookup(view, options) {
// If root is an array of paths, let's try each path until we find the view
if (options.root instanceof Array) {
@naholyr
naholyr / app.js
Created May 27, 2011
Embedding another application with Express
View app.js
var express = require('express')
var app = express.createServer()
// Configuration
app.configure(function() {
this.set('views', __dirname + '/views')
.set('view engine', 'jade')
.use(express.static(__dirname + '/public'))
.set('view options', {title: 'Express'})
@naholyr
naholyr / class.php
Created Jun 6, 2011
PHP Sadness... Callbacks as arguments
View class.php
<?php
class c {
public $f;
public function __construct() {
$this->f = function() { echo 'coucou'; };
}
}
// Note: "public $f = function() {...}" is a syntax error...
You can’t perform that action at this time.