Skip to content

Instantly share code, notes, and snippets.

View netroy's full-sized avatar

कारतोफ्फेलस्क्रिप्ट™ netroy

View GitHub Profile
@netroy
netroy / Connect-Websocket.js
Created January 5, 2012 10:31
Connect with Websockets
var connect = require('connect'),
WebSocketServer = require('websocket').server,
app = connect.createServer();
app.use(connect.static(process.cwd()));
app.use(connect.router(function(app){
app.get("/", function(req, resp) {
resp.write("Hola !");
resp.end();
@netroy
netroy / A better IndexedDB IMHO.md
Last active October 28, 2015 01:58
A better IndexedDB IMHO

--------- Work In progress ---------

##Context Multiple discussion threads spun out after this tweet mentioning my talk on Full-Text Search in IndexedDB using Inverted Indices at BerlinJS.

Only the beginning of my talk was about my discontent with the current IDB API and how it is a much needed technology. Unfortunately it's not terrific as a spec and has rather messy implementations across browsers. The API is way too low-level and needs a decent amount of abstraction for everyday web-developers to work with it.

Sharing my slides isn't going to be of much help, and neither is discussing about them in 140 chars.

@netroy
netroy / idb-in-production.md
Created September 3, 2012 19:00
IndexedDB in Production

IndexedDB in Production

Lets mantain a public list of apps, libs & developers (twitter/github) using IndexedDB for more than just experimentation.

Fork, Update & Post the link in the comments.

We can use this :

  • to get feedback on the spec
  • improve documentation on MDN
@netroy
netroy / Control-Flow.js
Created September 10, 2012 22:03
Control-Flow
function series(actions, callback) {
'use strict';
var i = 0;
function preTick() {
var next = actions[i++];
var data = Array.prototype.slice.call(arguments, 0);
@netroy
netroy / streams.js
Created October 13, 2012 21:31
File Upload with streams
/*global require, console, __dirname*/
(function() {
'use strict';
var express = require('express');
var app = express();
var fs = require('fs');
var path = require('path');
@netroy
netroy / clustered.js
Created July 10, 2013 11:48
1 second server
var cluster = require('cluster');
var workers = {};
var count = 5 * require('os').cpus().length;
function spawn() {
var worker = cluster.fork();
workers[worker.process.pid] = worker;
return worker;
}
@netroy
netroy / primes.js
Created September 16, 2013 21:24 — forked from rakeshpai/primes.js
var primes = [2];
var n = 3; // The number we are testing. Will be incremented.
function checkNextNumber() {
// It's sufficient to check if there are any prime factors up to sqrt(n)
n++;
var limitForChecking = Math.floor(Math.sqrt(n));
@netroy
netroy / pre-commit
Created September 24, 2013 09:02
JSHint precommit hook
#!/bin/sh
files=$(git diff --cached --name-only --diff-filter=ACM | grep ".js$")
if [ "$files" = "" ]; then
exit 0
fi
pass=true
for file in ${files}; do
@netroy
netroy / disabled-console.js
Last active August 29, 2015 13:56
Dat FB console ... for academic purposes only
(function (window) {
'use strict';
var realConsole = window.console || {};
var warnings = {
'Sorry, Your console is disabled for security reasons.': 'color: red; font-size: 36px; line-height: 40px;'
};
@netroy
netroy / rethinkdb-clustering.md
Created March 16, 2014 14:57
RethinkDB clustering with docker

Get my rethinkdb base image

docker pull netroy/rethinkdb

Start master

docker run -P -d rethinkdb

Start others

docker run -P -d rethinkdb [IP OF THE MASTER]