This file contains 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
(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))) |
This file contains 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
# 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; |
This file contains 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 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) |
This file contains 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
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; | |
} |
This file contains 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
;; 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)))) |
This file contains 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 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 |
This file contains 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
CXX = g++ | |
CPPFLAGS = -Wall -ansi -O2 | |
LDFLAGS = -lACE | |
bin = server client | |
cpps := $(wildcard *.cpp) | |
objects := $(foreach file, $(cpps), $(basename $(file)).o) | |
link_objects := $(filter-out $(foreach b, $(bin), $b.o), $(objects)) | |
all: obj binaries |
This file contains 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
#include "Event.hh" | |
#include "TCPSocket.hh" | |
#include "TCPServer.hh" | |
#include <string> | |
#include <iostream> | |
class EchoSocket : public TCPSocket | |
{ | |
public: |
This file contains 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
#lang racket | |
(define (pontos x) | |
(define (soma-lista x) (apply + x)) | |
(define (strike? x) (= (length x) 1)) | |
(define (spare? x) (= (soma-lista x) 10)) | |
(define (pontos2 jogada-anterior jogadas) | |
;; devolve a proxima jogada, que pode ter um ou dois lances | |
(define (proxima-jogada) | |
(if (= (first jogadas) 10) |
This file contains 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
class MutexGuard | |
{ | |
private: | |
Mutex & mutex_; | |
public: | |
MutexGuard(Mutex & mutex) : mutex_(mutex) | |
{ | |
mutex_.aquire(); | |
} |
OlderNewer