Skip to content

Instantly share code, notes, and snippets.

@nodokodo
nodokodo / iptables-redirect-lo-hi.sh
Created August 27, 2011 01:24
IPTables: Redirect Privileged to Stealthed, Non-Privileged Port
#!/bin/sh
FW='/sbin/iptables'
IP='123.123.123.123' # public ip
LO=80 # privileged port
HI=8000 # non-privileged port
PM=0x2a # packet mark - 32bit integer
# allow input on both ports
@nodokodo
nodokodo / gist:1274870
Created October 10, 2011 08:33
node-canvas pre-requisites for ubuntu 11.04
sudo apt-get install libcairo2-dev libjpeg8-dev libgif-dev
# Author: Pieter Noordhuis
# Description: Simple demo to showcase Redis PubSub with EventMachine
#
# Update 7 Oct 2010:
# - This example does *not* appear to work with Chrome >=6.0. Apparently,
# the WebSocket protocol implementation in the cramp gem does not work
# well with Chrome's (newer) WebSocket implementation.
#
# Requirements:
# - rubygems: eventmachine, thin, cramp, sinatra, yajl-ruby
@nodokodo
nodokodo / update-node.sh
Created February 26, 2012 16:43
Node.JS Update from Source
#!/bin/sh
[ $# -eq 0 ] && { echo "Usage: ${0} version-string" ; exit 1; }
VERSION=$1
BUILD_DIR=/usr/local/src/node
ARC="node-v${VERSION}.tar.gz"
mkdir -p $BUILD_DIR
cd $BUILD_DIR
@nodokodo
nodokodo / mv-script-to-body.sh
Created March 4, 2012 02:47
Move <script> tags to bottom of <body> using sed
#!/bin/sh
# warning: only tested on single line script tags, no doubt broken on multi-line
# useful for includes!
[ $# -eq 0 ] && { echo "Usage: ${0} file-name" ; exit 1; }
$FILE=$1
sed -in '/script/{h;d};/\/body/{H;g}' $FILE
@nodokodo
nodokodo / style_guide.md
Created April 18, 2012 02:22 — forked from dominictarr/style_guide.md
style guide

High level style in javascript.

Opinions are like assholes, every one has got one.

This one is mine.

Punctuation: who cares?

Punctuation is a bikeshed. Put your semicolons, whitespace, and commas where you like them.

@nodokodo
nodokodo / gist:3937508
Created October 23, 2012 07:47 — forked from robertjd/gist:2974075
socket.io service as controller
;
(function(exports, undefined) {
angular.module('module.Socket', [], function($provide) {
$provide.factory('Socket', ['$rootScope', function socketController($rootScope) {
var scope = $rootScope.$new()
scope.socket = io.connect('/')
scope.send = function(message) {
try {
var m = JSON.stringify(message)
@nodokodo
nodokodo / app.js
Created December 4, 2012 15:39 — forked from katanacrimson/app.js
nodejs app - expressjs 3.0 + socket.io v9 + passport + redis
var express = require('express'),
passport = require('passport'),
LocalStrategy = require('passport-local').Strategy,
connect = require('connect'),
http = require('http'),
path = require('path'),
util = require('util'),
fs = require('fs'),
redis = require('redis'),
cookie = require('cookie'),
@nodokodo
nodokodo / example.js
Created December 15, 2012 00:19 — forked from jhs/example.js
// Short module explanation // Something to gather my thoughts
// // I think this looks cool.
//
module.exports = the_exported_function // Modules are a function. Always.
//
module.exports.extra = extra // Additional API entry points if
module.exports.other = other // desired.
//
var util = require('util') // Other packages from npm or core
var assert = require('assert') // No comma-first due to lots of
validate = (customer, next)->
console.log 'validating...'
#VALIDATE HERE
next()
insert = (customer, next)->
console.log 'inserting...'
# insert into DB (asynchronously of course), and then call...
next()