Skip to content

Instantly share code, notes, and snippets.

(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)))
# 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;
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)
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;
}
;; 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))))
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
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
#include "Event.hh"
#include "TCPSocket.hh"
#include "TCPServer.hh"
#include <string>
#include <iostream>
class EchoSocket : public TCPSocket
{
public:
#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)
class MutexGuard
{
private:
Mutex & mutex_;
public:
MutexGuard(Mutex & mutex) : mutex_(mutex)
{
mutex_.aquire();
}