Skip to content

Instantly share code, notes, and snippets.

/**
* A simple lease-based cache in javascript used for node.js
*
* This cache allows to insert key-value pairs that will be automatically removed after a distinct lease time.
* A cache object has a capacity. If the capacity limit is hit, it will automatically remove the oldest entries.
* Entries can't be removed from the cache. However, they can be overwritten.
*
* Note that this is not exactly the same than a LRU cache, although it works similar. It has been used for caching
* authentication data. Only after lookups fail, the data will be caught from the database. The additional time-out
* prevents the usage of too old entries and allows some efficient caching between distributed nodes sharing
@berb
berb / Barrier points for Node.js
Created July 5, 2010 09:36
barrier point coordination class for node.js
/**
* A simple barrier point coordination class for node.js
*
* See http://www.ioexception.de/2010/07/05/barrier-points-in-node-js/ for more details.
*
* @author Benjamin Erb | http://www.benjamin-erb.de
*
*/
/**
var sys = require('sys');
var http = require('http');
for ( var i = 0; i < 24; i++)
{
var google = http.createClient(80, 'www.google.com');
var request = google.request('GET', '/', {
'host' : 'www.google.com'
});
@berb
berb / geocouch_filler.js
Created December 10, 2010 16:32
GeoCouch data generator
var http = require('http');
var util = require('util');
var host = "localhost";
var port = 5984;
var db = "geotemp";
function getRandomArbitary(min, max) {
return Math.random() * (max - min) + min;
}
var url = require('url');
var http = require('http');
var stream = require('stream');;
http.createServer(function(req, res) {
res.writeHead(200, {
'Content-Type' : 'text/plain'
});
var url = require('url');
var http = require('http');
var stream = require('stream');;
var path = require('path');
http.createServer(function(req, res) {
res.writeHead(200, {
'Content-Type' : 'text/plain'
});
@berb
berb / geodatabases.md
Created May 27, 2011 11:29 — forked from kashif/geodatabases.md
GeoDatabases - a discussion

GeoDatabases

What is a GeoDatabase? and how is it diff from a regular db

  • Stores geometries
  • multi-dimensional
  • R-Tree indexing (Query planner uses it?)
  • projections
  • Supports Datums ?
  • Vector and raster support
@berb
berb / gist:1133601
Created August 9, 2011 08:22
JSON Example with Link Relations
{
"blogpost":{
"link":{
"rel":"self",
"href":"http://blog/post/4711"
@berb
berb / IfLoop.java
Created October 25, 2013 12:06
"If Loops in Java" Also see: http://www.if-schleife.de/
public class IfLoop {
public static void main(String[] args) {
IF: do {
if (true) {
// do something...
continue IF;
}
} while (true);
}