Skip to content

Instantly share code, notes, and snippets.

var app = express.createServer();
var publicPath = './public';
var adminPath = './admin';
app.use(express.static( path.resolve( publicPath ) ) );
app.use(function(req,res,next){
// if req.path starts with /admin/ and user is logged in call next
// else redirect to login page
@milani
milani / node_gui_webkit_view.cc
Created March 27, 2012 01:41
buggy Webkit widget for node-gui
#include <webkit/webkit.h>
#include "node_gui_webkit_view.h"
namespace clip {
Persistent<FunctionTemplate> WebkitView::constructor_template;
void WebkitView::Init (Handle<v8::Object> target) {
ATTACH_CONSTRUCTOR("WebkitView", WebkitView, (Constructor<WebkitView, webkit_web_view_get_type>));
ATTACH_INHERITANCE(Container);
function formatTag(tag){
var elements = $('content').getElementsBySelector(tag);
elements.forEach(function(P,index){
// calculate frequency of characters for the first few characters ( 30 )
var charCode,
arabicFreq = 0,
englishFreq = 0,
length = 30,
parentDir = $(P).getStyle('direction'),
text = P.innerText;
@milani
milani / advanced_collision_detection.js
Created March 16, 2011 21:15
Collision detection with javascript using interval tree
// Collision detection with javascript using semi-interval tree.
// Add elements using insert function, then check collision using hasCollision.
var collisionTree = {
LEFT: 1,
RIGHT: 0,
INTERSECT: 2,
nodes:null,
margin: 1,
init: function(margin){
this.nodes = new Array();