Skip to content

Instantly share code, notes, and snippets.

View gleicon's full-sized avatar

Gleicon Moraes gleicon

View GitHub Profile
#! /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
%% 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
# 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
<!DOCTYPE html PUBLIC "-//W3C//DTD HTML 4.01//EN"
"http://www.w3.org/TR/html4/strict.dtd">
<html lang="en">
<head>
<meta http-equiv="Content-Type" content="text/html; charset=utf-8">
<title>RestMQ - Redis based message queue</title>
<link rel="stylesheet" href="style.css" type="text/css" media="screen">
</head>
<body>
<div id="wrapper">
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <hiredis/libevent.h>
void getCallback(redisContext *c, redisReply *reply, const void *privdata) {
printf("argv[%s]: %s\n", (const char*)privdata, reply->reply);
/* Disconnect after receiving the reply to GET */
redisDisconnect(c);
@gleicon
gleicon / base_62.rb
Created March 26, 2012 20:56 — forked from juanplopes/base_62.rb
base 62 encoding in ruby (versão devops)
# monkey patch to have base62 encoding over Integers and Strings
class Integer
def to_base62()
alphabet = "0123456789ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz"
return alphabet[0] if self == 0
num = self
arr = []
base = alphabet.size
while num > 0 do
@gleicon
gleicon / gist:2917748
Created June 12, 2012 14:06 — forked from defnull/gist:1224387
Deploy a Bottle app on Heroku
mkdir heroku
cd heroku/
virtualenv --no-site-packages env
source env/bin/activate
pip install bottle gevent
pip freeze > requirements.txt
cat >app.py <<EOF
import bottle
import os
@gleicon
gleicon / gist:3038646
Created July 3, 2012 09:05 — forked from mbrochh/gist:964057
Fast Forward Your Fork
# kudos to https://github.com/drewlesueur
# stolen from here: https://github.com/blog/266-fast-forward-your-fork#comment-11535
git checkout -b upstream/master
git remote add upstream git://github.com/documentcloud/underscore.git
git pull upstream master
git checkout master // [my master branch]
git merge upstream/master
git push origin master
@gleicon
gleicon / tcp-proxy.py
Created February 22, 2013 19:40 — forked from fiorix/tcp-proxy.py
#!/usr/bin/env python
# coding: utf-8
# http://musta.sh/2012-03-04/twisted-tcp-proxy.html
import sys
from twisted.internet import defer
from twisted.internet import protocol
from twisted.internet import reactor
from twisted.python import log
@gleicon
gleicon / cyclone-dropbox-oauth2.py
Last active August 29, 2015 14:06 — forked from andreadipersio/tornado-dropbox-oauth2.py
forked from tornado-dropbox-oauth2
import cyclone.web
import cyclone.auth
from cyclone import escape, httpclient
from cyclone.options import parse_command_line, define, options
from twisted.python import log
from twisted.internet import task, defer, reactor
import sys
try:
import urllib.parse as urllib_parse # py3