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
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>
@vvo
vvo / should-I-pin-npm-dependencies?.md
Last active March 8, 2017 22:12
About authoring frontend libraries, building them, publishing to npm and dependencies

You have a nice library published on npm but asking yourselve if you should declare your dependencies as lodash: "3.10.0" (known as "pin" a dependency) or lodash: "^3.10.0"?

As library authors we should not pin dependencies but ask our users to do use npm shrinkwrap in their own app.

Here's why:

Pinning dependencies will result in duplicated code and modules in builds

If you pin your dependencies the issue is that anyone using your module will may not benefit from shared dependencies. If your module user has lodash: "^3.11.0" then since you declared