Skip to content

Instantly share code, notes, and snippets.

View lucindo's full-sized avatar

Renato Lucindo lucindo

  • São Paulo, Brazil
View GitHub Profile
import sqlite3, contextlib, logging
# from: http://docs.python.org/library/sqlite3.html#sqlite3.Connection.row_factory
def dict_factory(cursor, row):
d = {}
for idx, col in enumerate(cursor.description):
d[col[0]] = row[idx]
return d
@contextlib.contextmanager
;; pattern matching em CL é meio assim gents:
;; exemplo classics
(defgeneric fact (n))
(defmethod fact ((n (eql 0)))
1)
(defmethod fact ((n number))
(* n (fact (- n 1))))
if ((not message and not hamdir and not spamdir) or
(message and (hamdir or spamdir)) or
(not message and ((hamdir and not spamdir) or (spamdir and not hamdir))))
{
usage(argv[0]);
return 1;
}
import urllib, sys
from BeautifulSoup import BeautifulSoup
if __name__ == '__main__':
if len(sys.argv) != 2:
print "usage: %s <amazon s3 url>" % sys.argv[0]
sys.exit(1)
base_url = sys.argv[1]
xml = urllib.urlopen(base_url).read()
soup = BeautifulSoup(xml)
# from: http://www.tornadoweb.org/documentation#running-tornado-in-production
user nginx;
worker_processes 1;
error_log /var/log/nginx/error.log;
pid /var/run/nginx.pid;
events {
worker_connections 1024;
use epoll;
(defun make-erlang ()
(interactive)
(let* ((my-buffer (current-buffer))
(my-file (file-name-nondirectory buffer-file-name)))
(when (switch-to-buffer "*erlang*")
(goto-char (point-max))
(insert (concat "make:files([" my-file "], [netload])."))
(comint-send-input))
(switch-to-buffer my-buffer)))