Skip to content

Instantly share code, notes, and snippets.

View render_with_sequencer.js
var BLOCKSIZE = 500;
var dataset = []; // Assuming, of course, that there's something in here..
var renderActions = [];
for (var i=0; i<dataset.length; i+= BLOCKSIZE) {
renderActions.push((function(offset) {
return function(callback) {
//
View simple_sequencer.js
Sequencer = function(lambdas) {
var self = this;
this.start = function() {
this.next();
}
this.next = function() {
if (lambdas.length != 0) {
@michiel
michiel / example-sequence-10k.js
Created Feb 9, 2011
Run 10000 async calls through a sequencer
View example-sequence-10k.js
//
// Example #1 : sequence 10000 async calls
//
function sequence(arr) {
var self = function() {
arr.length && arr.shift()(self);
}
self();
@michiel
michiel / example-sequence-10k-in-blocks-of-500.js
Created Feb 9, 2011
Run 10000 async calls through a sequencer in blocks of 500
View example-sequence-10k-in-blocks-of-500.js
//
// Example #2 : sequence 10000 async calls in blocks of 500 using a collector
//
function sequence(arr) {
var self = function() {
arr.length && arr.shift()(self);
}
self();
}
@michiel
michiel / example-10k-sequence-pipeline.js
Created Feb 10, 2011
Run 10000 async calls through a pipeline'd sequencer
View example-10k-sequence-pipeline.js
//
// Example #3 : sequence 10000 async calls in a pipeline, with max 500 open
//
function pipeline(arr, maxOpenCalls, finalCallback) {
var openCalls = 0;
function callback() {
if (--openCalls < maxOpenCalls) {
@michiel
michiel / sequencer.coffee
Created May 17, 2011
Sequencer in coffeescript
View sequencer.coffee
sequence = (arr) ->
self = ->
if arr.length then arr.shift() self
self()
async = (callback) ->
console.log "Calling callback after 1s"
setTimeout callback, 1000
sequence [async, async, async]
@michiel
michiel / cors-nginx.conf
Created Jul 5, 2011
Wide-open CORS config for nginx
View cors-nginx.conf
#
# Wide-open CORS config for nginx
#
location / {
if ($request_method = 'OPTIONS') {
add_header 'Access-Control-Allow-Origin' '*';
#
View multisort.js
//
// Ex. sort on attrs = [
// ["Name", "asc"],
// ["Description, "desc"]
// ]
//
// This is how we do just one column,
//
// function sortOn(objs, attr, order) {
// return objs.sort(
@michiel
michiel / sortingx.coffee
Last active Oct 2, 2015
some sorting in coffeescript
View sortingx.coffee
sort = (objs, attrs) ->
dojo.map(
(dojo.map objs, (obj) ->
arr = [obj]
dojo.forEach attrs, (attr) ->
arr.push obj.get(attr)
arr
).sort(
(attrsA, attrsB) ->
i = 1
View redcon.go
package main
import (
"log"
"io"
"os"
"crypto/tls"
"strings"
"net"
"flag"
You can’t perform that action at this time.