This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require("sys"); | |
var http = require("http"); | |
var connections=[]; | |
function update() { | |
if (connections.length) { | |
// do stuff | |
for (var c in connections) { | |
sys.puts(c); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require("sys"); | |
var http = require("http"); | |
var connections=[]; | |
function update() { | |
if (connections.length) { | |
connections.forEach(function(c) { | |
sys.puts(JSON.stringify(c)); | |
c.sendBody('oi\n'); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
var sys = require("sys"); | |
var http = require("http"); | |
// http://search.twitter.com/search.json?q= | |
// http://search.twitter.com/search.json?q=%s&since_id=%s | |
var twitter_search = http.createClient(80, "search.twitter.com"); | |
var since_id=0; | |
var timeo=2000; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# coding: utf-8 | |
import re | |
from socket import socket, SO_REUSEADDR, SOL_SOCKET | |
from threading import Thread | |
class WebSocketServer(Thread): | |
HDR_ORIGIN = re.compile('Origin\:\s+(.*)') | |
HDR_LOCATION = re.compile('GET\s+(.*)\s+HTTP\/1.1', re.I) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
;fix over http://snippets.dzone.com/posts/show/2816 so it can run on Mac OS | |
; also, it serves as an elegant reminder on how to use external libraries :) | |
(setq SHA1 (import "libssl.dylib" "SHA1")) | |
(join (map (lambda (x) (format "%02x" (& x 0xff))) (unpack (dup "c" 20) (get-string (SHA1 "abc" 3 0))))) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#! /bin/sh | |
### BEGIN INIT INFO | |
# Provides: mongodb | |
# Required-Start: $all | |
# Required-Stop: $all | |
# Default-Start: 2 3 4 5 | |
# Default-Stop: 0 1 6 | |
# Short-Description: starts the mongodb data-store | |
# Description: starts mongodb using start-stop-daemon |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
import os, sys | |
sys.path.append(os.path.abspath('/usr/lib/python-django')) | |
sys.path.append(os.path.abspath('/path/to/django/app')) | |
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings' | |
from admin.models import Category, User |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import crypt | |
import sys | |
if len(sys.argv) == 3: | |
print("%s:%s" % (sys.argv[1], crypt.crypt(sys.argv[2], sys.argv[2]))) | |
else: | |
print 'python htpasswd.py <user> <pass> >> /path/to/your/htpass_file |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
%% Author: bokner ([email protected]) | |
%% Created: Apr 10, 2010 | |
%% Description: HTTP digest authentication | |
%% Note: the code follows particular explanation given on Wikipedia. | |
%% Disclaimer: Use on your own risk. The author disclaims any liability | |
%% with regard to using this code. | |
-module(digest_auth). | |
%% | |
%% Include files |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
# author Gleicon Moraes | |
# q&d for provisioning VirtualBox images for a Hadoop project | |
# works on Mac Os X Snow Leopard. | |
# fill in for the ubuntu iso path (must be absolute or put it on VBox HDD dir) | |
# | |
if [ "$#" -lt 1 ]; then | |
echo "use as createvm <VMName>" | |
exit |
OlderNewer