Skip to content

Instantly share code, notes, and snippets.

var
PARALLEL_CONNECTS = 10,
http = require('http'),
sys = require('sys'),
connectionCount = 0,
messageCount = 0;
lastMessages = 0;
function addClient() {
@briancavalier
briancavalier / simple-promise-retry.js
Created February 24, 2011 18:35
A few general patterns for retries using promises
function keepTrying(otherArgs, promise) {
promise = promise||new Promise();
// try doing the important thing
if(success) {
promise.resolve(result);
} else {
setTimeout(function() {
keepTrying(otherArgs, promise);
@netroy
netroy / 000-server.js
Created November 5, 2011 11:30
Using cluster to scale existing Express/Connect apps
var cluster = require('cluster'),
app = require('./app');
var workers = {},
count = require('os').cpus().length;
function spawn(){
var worker = cluster.fork();
workers[worker.pid] = worker;
return worker;
@maccman
maccman / juggernaut_channels.rb
Created June 26, 2012 04:56
Sinatra Server Side Event streaming with private channels.
# Usage: redis-cli publish message.achannel hello
require 'sinatra'
require 'redis'
conns = Hash.new {|h, k| h[k] = [] }
Thread.abort_on_exception = true
get '/' do
@dsamarin
dsamarin / UndoStack.js
Created July 5, 2012 00:37
Easy undo-redo in JavaScript.
function UndoItem (perform, data) {
this.perform = perform;
this.data = data;
}
/**
* UndoStack:
* Easy undo-redo in JavaScript.
**/
@nijikokun
nijikokun / strings.js
Created October 9, 2012 20:29
Handlebars.js Filters for Strings
/**
* Basic Standard Filters for strings:
*
* {{size "Plus"}}
*
* Would give you 4!
*
* @author: Nijiko Yonskai
*/
var strings = {

Answering the question

First answer should be easiest/simple. Either brute force or first thing that comes to mind

Any optimzation problem

  • Brute Force
  • loops
  • hashing
  • sorting
  • space vs time complexity trade offs
@dypsilon
dypsilon / frontendDevlopmentBookmarks.md
Last active November 10, 2024 03:45
A badass list of frontend development resources I collected over time.