Skip to content

Instantly share code, notes, and snippets.

View gleicon's full-sized avatar

Gleicon Moraes gleicon

View GitHub Profile
#!/bin/bash
# companion to create_vbox_vm.sh, clones an existing VM w/o graphical interface.
# used to provision quick images for a hadoop project.
export VMPATH=~/Library/VirtualBox/Machines/
export HDDPATH=~/Library/VirtualBox/HardDisks/
if [ "$#" -lt 2 ]; then
echo "use as clonevm <originalVM> <newVM>"
%% base62 encoding - initial idea based on riak's encoding, with no if's and fixed base
%% http://hg.basho.com/riak/src/661615e510dd/src/riak_util.erl
%% gleicon - 2010
-module(base62).
-export([base62range/2, base62range/1]).
range(I) when I >= 36 -> I-36+$a;
range(I) when I >= 10 -> I-10+$a;
%% base62 encoding - initial idea based on riak's encoding, with no if's and fixed base
%% this time its not so idiomatic, but makes decoding possible.
%%
%% gleicon - 2010
%%
%% testing:
%% 0> c(base62.erl).
%% 1> base62:decode(base62:encode(1000)) == 1000.
%%
%% base62 encoding - initial idea based on riak's encoding, with no if's and fixed base
%% gleicon - 2010
%%
%% testing:
%% 0> c(base62.erl).
%% 1> base62:decode(base62:encode(1000)) == 1000.
%% charlist removed thanks to freenode's #erlang
%%
-module(base62).
%% gleicon - 2010
%%
%% testing:
%% 0> c(base62.erl).
%% 1> base62:decode(base62:encode(1000)) == 1000.
%% rvirding-fication of the original code.
%%
-module(base62).
-export([encode/1, decode/1]).
-module(httpclient).
-export([start/2, timer/2, recv/1]).
start(Filename, Wait) ->
inets:start(),
spawn(?MODULE, timer, [10000, self()]),
This = self(),
spawn(fun()-> loadurls(Filename, fun(U) -> This ! {loadurl, U} end, Wait) end),
recv({0,0,0}).
# sinatra/thin based proxy
require 'rubygems'
require 'sinatra'
require 'nokogiri'
require 'open-uri'
require 'redis'
reddo = Redis.new
get '/url/*' do
url = params["splat"].to_s
# sinatra/thin based proxy
require 'rubygems'
require 'sinatra'
require 'nokogiri'
require 'open-uri'
require 'redis'
require 'digest/md5'
$KCODE = 'u' if RUBY_VERSION < '1.9'
before do
# minimal async sinatra app
# requires ruby 1.9.x
require 'sinatra'
require 'em-http'
require 'em-synchrony'
require 'em-synchrony/em-http'
require 'rack/fiber_pool'
use Rack::FiberPool
var net = require('net');
var sys = require('sys');
function repr(wot) {
sys.puts(sys.inspect(wot));
}
net.createServer(function (socket) {
//repr(socket);
client = net.createConnection(8888);