Skip to content

Instantly share code, notes, and snippets.

@Tug
Tug / index.html
Created May 8, 2015 20:44
Exemple de customization du chat Nirror: chat en Français
<html>
<head>
</head>
<body>
<script type="text/template" id="nirror-chat-template">
<div class="nirror-box" data-bind="visible: visible">
<div class="nirror-bubble" data-bind="visible: bubbleVisible">
<span data-bind="text: infoMessage"></span>
<span style="float: right; cursor: pointer;" data-bind="click: closeBubble">x</span>
@Tug
Tug / isgmail.js
Created February 24, 2015 18:24
is gmail ?
function is_gmail(email, callback) {
var email_host_regex = /.*@(.+)$/;
var gmail_servers_regex = /(\.google\.com|\.googlemail\.com)$/i;
var m = email_host_regex.exec(email);
if(m && m.length > 1) {
var host = m[1] && m[1].toLowerCase();
if(host == "gmail.com") {
return callback(null, true);
} else {
dns.resolveMx(host, function(err, result) {
@Tug
Tug / gist:9191667
Last active August 29, 2015 13:56
Server Benchmark
/*
* Tests run on Ubuntu Server 12.04 LTS x86-64
*/
/*****************************************************************************/
/* DISK */
/*****************************************************************************/
/* 15 GB File Random IO */
#sysbench --test=fileio --file-total-size=15G prepare
@Tug
Tug / after native_parser=true
Created January 10, 2014 21:28
profiling of nirror with and without the use of the native parser in node-mongodb-native
Statistical profiling result from v8.log, (49355 ticks, 90 unaccounted, 0 excluded).
[Unknown]:
ticks total nonlib name
90 0.2%
[Shared libraries]:
ticks total nonlib name
36960 74.9% 0.0% /lib/x86_64-linux-gnu/libc-2.17.so
6486 13.1% 0.0% /usr/local/bin/node
var express = require("express"),
app = express();
app.configure(function(){
app.use(express.static(__dirname + '/public'));
});
app.listen(13000);
@Tug
Tug / a.js
Created December 16, 2013 13:59
`a.js` is called before `b.js`. (There is some asynchronous stuff going one between the 2 calls). Here Visit is going to be undefined when required in `b.js`, no error thrown. If I call `require_public('models/Visit')` at position 1, it works fine. Even in `b.js`, Visit will be defined (probably because it's kept in memory once loaded).
modules.exports = function (app) {
var requirejs = require("requirejs");
var path = require("path");
requirejs.config({
baseUrl: path.join(app.config.paths.root, "public/js")
});
app.require_public = requirejs;
@Tug
Tug / code.js
Created December 2, 2012 23:39
issue with node-mongodb-native commit 5fd127e
function openFile(db, filename, callback) {
var gs = new mongodb.GridStore(db, filename, "r");
gs.open(function(err, gs) {
if(err) {
callback(err, gs);
return;
}
callback(null, gs);
@Tug
Tug / gist:4137177
Created November 23, 2012 20:37
Document not found when read_secondary is true
var mongoose = require('mongoose');
var mongoConfig = {
servers : [
'localhost:27017/test-replset'
, 'localhost:27018'
, 'localhost:27019'
]
, options : {
@Tug
Tug / gist:4124267
Created November 21, 2012 10:51
Mongoose : objects not found after synchronous saves
var mongoose = require('mongoose');
var File = new mongoose.Schema({
servername : { type: String, index: { unique: true } }
, originalname : String
});
var FileModel = mongoose.model('File', File);
@Tug
Tug / gist:4114656
Created November 19, 2012 22:57
success! (except for last one)
var mongodb = require('mongodb')
, Db = mongodb.Db
, Server = mongodb.Server
, ReplSetServers = mongodb.ReplSetServers;
var mode = process.argv.slice(2)[0] || 'server';
var mongoConfig = {
replset : {