Skip to content

Instantly share code, notes, and snippets.

View shimondoodkin's full-sized avatar

Shimon Doodkin shimondoodkin

View GitHub Profile
@shimondoodkin
shimondoodkin / .htaccess
Created December 3, 2011 15:49
apache nodejs reverse proxy, note this is half tested
RewriteEngine On
RewriteRule ^$ http://127.0.0.1:8080/ [P,L]
RewriteCond %{REQUEST_FILENAME} !-f
RewriteCond %{REQUEST_FILENAME} !-d
RewriteRule ^(.*)$ http://127.0.0.1:8080/$1 [P,L]
# see 'proxy|P' (force proxy) http://httpd.apache.org/docs/2.0/mod/mod_rewrite.html
@shimondoodkin
shimondoodkin / \\etc\\init\\APPNAME.conf
Created August 3, 2011 21:37
an Upstart script for node.js app I used once ago, it demonstrates how to use nave from within a script, just replace node with nave use with node version
#!upstart
description "APPNAME node.js server"
author "Shimon Doodkin"
# license: public domain
start on runlevel [2345]
stop on runlevel [06]
#pre-start script
# exec touch /var/log/APPNAME.nodejs.log
@shimondoodkin
shimondoodkin / WebKit contentEditable focus bug workaround.html
Created July 13, 2011 19:28
WebKit contentEditable focus bug workaround
<!DOCTYPE html>
<html>
<head>
<meta http-equiv="content-type" content="text/html; charset=UTF-8">
<title>WebKit contentEditable focus bug workaround</title>
<script type='text/javascript' src='http://code.jquery.com/jquery-1.6.2.js'></script>
<script type='text/javascript'>
//<![CDATA[
$(function(){
@shimondoodkin
shimondoodkin / APPNAME
Created July 2, 2011 17:33 — forked from peterhost/node_debian_init.sh
init.d script for node.js for debian
#! /bin/sh
# ------------------------------------------------------------------------------
# SOME INFOS : fairly standard (debian) init script.
# Note that node doesn't create a PID file (hence --make-pidfile)
# has to be run in the background (hence --background)
# and NOT as root (hence --chuid)
#
# MORE INFOS : INIT SCRIPT http://www.debian.org/doc/debian-policy/ch-opersys.html#s-sysvinit
# INIT-INFO RULES http://wiki.debian.org/LSBInitScripts
# INSTALL/REMOVE http://www.debian-administration.org/articles/28
@shimondoodkin
shimondoodkin / server.js
Created May 13, 2011 18:20
nodejs RestStore dojo.store.JsonRest - parital
var fs=require('fs'),
path = require("path");
var http = require('http'),
urlparse = require('url').parse;
urlresolve = require('url').resolve;
var util = require('util'),
exec = require('child_process').exec;
var linq = require('jsinc').jsinc(__dirname+'/node_modules/jslinq/scripts/JSLINQ.js').window.JSLINQ;// http://jslinq.codeplex.com
@shimondoodkin
shimondoodkin / testsandbox.js
Created December 23, 2010 00:09
this is a follow up to my previous post about run in same context bug/future that contexts are not referenced when using multiple times runInNewContext with the same context - a solution is test 3 here
//licensed public domain
Array.prototype.next=function(){var z=this.shift();if(z)z();};
var simpleasync;
function test1()
{
//test1.js
console.log("\r\n\r\n this test should fail: \r\n");
<?php
while(ob_get_level())
ob_end_clean();
//header("Content-Encoding:");
header("Content-Type: text/plain");
function flv_parse_header($file)
{
$content = fread($file,9);
//echo urlencode($content);
@shimondoodkin
shimondoodkin / contextbug.js
Created October 24, 2010 01:23
demonstrates that the contexts are not referenced in runInNewContext when running in same context
//licensed public domain
var sandbox = { setTimeout: setTimeout, console:console};
var myscript=0;
function run_scripts_in_same_context(text)
{
process.binding('evals').Script.runInNewContext(text,sandbox,'myfile'+(myscript++)+'.js');
}
run_scripts_in_same_context('var x="1"; function showx(){console.log("x="+x);} setTimeout(function(){showx();},100)');
/* This code is PUBLIC DOMAIN, and is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND. See the accompanying
* LICENSE file.
*/
#include <v8.h>
#include <node.h>
#include <unistd.h>
/* This code is PUBLIC DOMAIN, and is distributed on an "AS IS" BASIS,
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND. See the accompanying
* LICENSE file.
*/
#include <v8.h>
#include <node.h>
#include <unistd.h>