Skip to content

Instantly share code, notes, and snippets.

@joemccann
joemccann / redis.conf
Created December 6, 2011 21:51
Standard Redis Conf with Authentication
# Redis configuration file example
# Note on units: when memory size is needed, it is possible to specifiy
# it in the usual form of 1k 5GB 4M and so forth:
#
# 1k => 1000 bytes
# 1kb => 1024 bytes
# 1m => 1000000 bytes
# 1mb => 1024*1024 bytes
# 1g => 1000000000 bytes
@Rob-ot
Rob-ot / Draggable.js
Created December 16, 2011 23:46
Draggable and dropable views for backbone, uses html5 drag and drop api, requires jquery and underscore, not tested in IE yet
return View.extend({
initialize: function () {
this.el.attr("draggable", "true")
this.el.bind("dragstart", _.bind(this._dragStartEvent, this))
},
_dragStartEvent: function (e) {
var data
if (e.originalEvent) e = e.originalEvent
e.dataTransfer.effectAllowed = "copy" // default to copy
@youtalk
youtalk / node-jquery-autocomplete.js
Created January 12, 2012 06:40
Keyword search using Node.js server and jQuery-autocomplete client
// Server-side
app.get('/keyword/search',
function (req, res, next) {
var query = new RegExp('^' + req.query.q + '.*$', 'i');
var result = [];
mongodb.keywords.find(
{ word: query }, [ 'word' ], { limit: 5 },
function (err, keywords) {
keywords.forEach(function (k) {
result.push(k.word);
@founddrama
founddrama / moment-in-node.js
Created March 24, 2012 12:53
Moment.js examples
// node:
var moment = require('moment');
moment().add('days', 2).fromNow();
// 'in 2 days'
moment().subtract('days', 2).fromNow();
// '2 days ago'
moment('November 1977').fromNow()
@InternetExplorer
InternetExplorer / scoreboardProjection.example.js
Created April 2, 2012 22:11
Justafriend.ie - Scoreboard Projection Example
function scoreboardProjection(frame_offset) {
if (frame_offset == null) frame_offset = 0;
var canvas, proj;
var score_img_1,
score_img_2,
overlay,
board_canvas,
score_canvas_1,
score_canvas_2;
@nf
nf / hello-node.js
Created July 6, 2012 21:14
Hello world web server that scales across multiple processors
var cluster = require('cluster');
var http = require('http');
var numCPUs = require('os').cpus().length;
if (cluster.isMaster) {
// Fork workers.
for (var i = 0; i < numCPUs; i++) {
cluster.fork();
}
cluster.on('exit', function(worker, code, signal) {
@turtlesoupy
turtlesoupy / nginx.conf
Created July 8, 2012 21:16
node.js upstream nginx config
http {
proxy_cache_path /var/cache/nginx levels=1:2 keys_zone=one:8m max_size=3000m inactive=600m;
proxy_temp_path /var/tmp;
include mime.types;
default_type application/octet-stream;
sendfile on;
keepalive_timeout 65;
gzip on;
gzip_comp_level 6;
@scttnlsn
scttnlsn / README.md
Created July 30, 2012 22:16
Pub/sub with MongoDB and Node.js

Pub/sub with MongoDB and Node.js

Setup:

$ mongo
> use pubsub
> db.createCollection('messages', { capped: true, size: 100000 })
> db.messages.insert({})
@adammw
adammw / README.md
Created August 3, 2012 06:30
Node.js for Raspberry Pi

Node.js for Raspberry Pi

Pre-built binaries

Recent releases have been pre-built using cross-compilers and this script and are downloadable below.

If you have found these packages useful, give me a shout out on twitter: @adammw

@heisters
heisters / colorThreshold.cpp
Last active October 9, 2015 19:17
Function for elegantly performing range thresholding with arbitrary colors and ranges with OpenCV
// This code is modified from the working version to remove coupling with the original
// application, and hasn't been tested in its new form. So, it's enough to give you
// the basic idea, but may not entirely work ;)
//
// It assumes the src image is in HSV and the dst image is grayscale.
//
// CvScalar red = cvScalar(179, 255, 255);
// CvScalar lowOffset = cvScalar(-20, -150, -150); // find colors down to h = 159, s = 105, v = 105
// CvScalar highOffset = cvScalar(20, 0, 0); // find colors up to h = 19, s = 255, v = 255 (h wraps/is mod 179)
// colorThreshold(img, thresholded, red, lowOffset, highOffset);