From | To | Expression |
---|
This file contains hidden or 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
package main | |
import ( | |
"flag" | |
"fmt" | |
"net" | |
"net/rpc" | |
"strings" | |
"time" |
This file contains hidden or 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
#!/usr/bin/env python | |
"""This is a demonstration of sharing file descriptors across processes. | |
It uses Tornado (need a recent post-2.0 version from github) and the | |
multiprocessing module (from python 2.6+). To run it, start one copy | |
of fdserver.py and one or more copies of testserver.py (in different | |
terminals, or backgrounded, etc). Fetch http://localhost:8000 and | |
you'll see the requests getting answered by different processes (it's | |
normal for several requests to go to the same process under light | |
load, but under heavier load it tends to even out). |
This file contains hidden or 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 django.db.backends import util, BaseDatabaseWrapper | |
class LoggingCursorWrapper(util.CursorDebugWrapper): | |
def execute(self, sql, *args): | |
print sql | |
return super(LoggingCursorWrapper, self).execute(sql, *args) if self.cursor.__class__ == util.CursorDebugWrapper else self.cursor.execute(sql, *args) | |
def create_wrapper_factory(old_cursor): | |
def cursor(self, *args, **kwargs): | |
return LoggingCursorWrapper(old_cursor(self, *args, **kwargs), self) |
This file contains hidden or 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
val raw = io.Source.fromFile("/tmp/proba.json").mkString |
This file contains hidden or 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
--- python2.6/os.py 2010-04-16 16:41:14.000000000 +0200 | |
+++ /usr/lib/python2.6/os.py 2012-10-02 00:31:53.000000000 +0200 | |
@@ -742,22 +742,3 @@ | |
_make_statvfs_result) | |
except NameError: # statvfs_result may not exist | |
pass | |
- | |
-if not _exists("urandom"): | |
- def urandom(n): | |
- """urandom(n) -> str |
This file contains hidden or 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 riak | |
def f(n=100): | |
client = riak.client.RiakClient() | |
b = client.bucket('ize') | |
for i in xrange(n): | |
try: | |
k = b.new_binary(str(i), str(i)) | |
x = k.store(w=3, dw=1) |
This file contains hidden or 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
babo@attila% find /apps/ocaml -name ocamlbuild\* | |
/apps/ocaml/bin/ocamlbuild | |
/apps/ocaml/bin/ocamlbuild.byte | |
/apps/ocaml/lib/ocaml/ocamlbuild | |
/apps/ocaml/lib/ocaml/ocamlbuild/ocamlbuild.cmo | |
/apps/ocaml/lib/ocaml/ocamlbuild/ocamlbuild_executor.cmi | |
/apps/ocaml/lib/ocaml/ocamlbuild/ocamlbuild_executor.cmo | |
/apps/ocaml/lib/ocaml/ocamlbuild/ocamlbuild_executor.cmx | |
/apps/ocaml/lib/ocaml/ocamlbuild/ocamlbuild_executor.o | |
/apps/ocaml/lib/ocaml/ocamlbuild/ocamlbuild_pack.cmi |
This file contains hidden or 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
#! /usr/bin/env python | |
import datetime | |
import tornado.auth | |
import tornado.httpserver | |
import tornado.web | |
class LoginHandler(tornado.web.RequestHandler): | |
def get_current_user(self): | |
return self.get_secure_cookie("user") |
This file contains hidden or 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
(ns pw.bot | |
(:gen-class :main true :prefix "-") | |
(:use [clojure.string :only (trim split-lines)] | |
pw.planetwars)) | |
;; Helpers for your bot | |
(defn my-strongest-planet | |
[pw] | |
((first (sort-by #(> (:num-ships %1) (:num-ships %2)) | |
(my-planets pw))) :planet-id)) |
NewerOlder