Skip to content

Instantly share code, notes, and snippets.

View gleicon's full-sized avatar

Gleicon Moraes gleicon

View GitHub Profile
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);
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');
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;
# 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)
;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)))))
#! /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
#!/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
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
%% Author: bokner (boris.okner@gmail.com)
%% 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
#!/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