Skip to content

Instantly share code, notes, and snippets.

View vvo's full-sized avatar
🌱
Growing indie hacker

Vincent Voyer vvo

🌱
Growing indie hacker
View GitHub Profile
@vvo
vvo / rethinkdb.js
Created May 27, 2014 06:45
rethinkdb native driver
var async = require('async');
var r = require('rethinkdb');
var debug = require('debug')('rethinkdb');
// first get some warming data to insert
var warmMessages = require('./generate-messages.js')(10000);
var host = process.env.HOST || 'localhost';
// get real data to insert
var async = require('async');
var r = require('rethinkdbdash')();
var debug = require('debug')('rethinkdb');
// first get some warming data to insert
var warmMessages = require('./generate-messages.js')(10000);
var host = process.env.HOST || 'localhost';
// get real data to insert
var async = require('async');
var MongoClient = require('mongodb').MongoClient;
var debug = require('debug')('mongodb');
// first get some warming data to insert
var warmMessages = require('./generate-messages.js')(10000);
// get real data to insert
var messages = require('./generate-messages.js')(process.env.NB_MESSAGES);
var writes = require('./result')('mongodb_writes');
package main
import "code.google.com/p/go-tour/tree"
import "fmt"
// Walk walks the tree t sending all values
// from the tree to the channel ch.
func Walk(t *tree.Tree, ch chan int) {
if t.Left != nil {
Walk(t.Left, ch)
@vvo
vvo / the-simplest-config-module.js
Last active August 29, 2015 14:08
The simplest configuration module you will ever need
// This module will load ./process.env.APP_ENV.json and exports it
// And will also read args from command line and merge them, i.e.:
// node index.js --server.hostname=192.168.56.1
// will work.
// Usually this module should be in ./config/index.js
// And then you use var config = require('./config');
// You must set an APP_ENV
if (!process.env.APP_ENV) {
@vvo
vvo / gist:44b02018504db10c7f7a
Last active August 29, 2015 14:08
deeply remove "private _properties" of JavaScript objects
function removePrivateProperties(dirty) {
return Object.keys(dirty).reduce(function(clean, keyName) {
if (keyName.indexOf('_') === 0) {
return clean;
}
var value = dirty[keyName];
if (typeof value === 'object' && Object.keys(value).length > 0) {
value = removePrivateProperties(value);
@vvo
vvo / index.js
Created December 4, 2014 10:48
requirebin sketch
var test = require('tape');
var jade = require('jade');
test('it should keep whitespace between tags if any', function(t) {
t.plan(1);
var fn = jade.compile('input\ninput');
t.equal(fn(), '<input/> <input/>');
});
@vvo
vvo / index.js
Created March 6, 2015 16:52
requirebin sketch
var AlgoliaSearch = require('algolia-search');
var client = new AlgoliaSearch('latency', '6be0576ff61c053d5f9a3225e2a90f76');
var index = client.initIndex('contacts');
index.search('a', function() {
console.log(arguments);
});
@vvo
vvo / index.js
Last active August 29, 2015 14:17
requirebin sketch
// hello world
var algoliasearch = require('algoliasearch');
var client = algoliasearch('latency', '6be0576ff61c053d5f9a3225e2a90f76', {protocol: 'http:'});
var query = 'ab';
client.startQueriesBatch();
client.addQueryInBatch(
'contacts', // index name
query, {
@vvo
vvo / examples-index.html
Created June 9, 2015 09:40
webpack example
<!DOCTYPE html>
<html>
<head>
<title></title>
</head>
<body>
<h1>Title</h1>
<script src="/bundle.js"></script>
</body>