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
# procrastination adventures | |
''' | |
RESULTS: (over 1m iterations) | |
Python 2.5 | Python2.6 | Python3.1 | |
test1: ~17.5s | ~14.6s | ~22.1s | |
test2: ~10.6s | ~10.3s | ~16.2s | |
just_join: ~0.7s | ~0.66s | ~0.63s | |
just_sample: ~10.5s | ~9.75s | ~15.7s | |
just_str: ~3.45s | ~3.1s | ~3.4s | |
''' |
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
<script type="text/javascript"> | |
jQuery(document).ready(function() { | |
$('#autocomplete').typeahead({ | |
source: someDataSource | |
, matcher: function (item) { | |
queryItems = this.query.toLowerCase().split(/, */); | |
queryLast = queryItems[queryItems.length-1]; | |
return ~item.toLowerCase().indexOf(queryLast) | |
} |
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
# related parts of motor.DataServer suggestion | |
# something along the lines of... | |
class DataServer(object): | |
@tornado.gen.engine | |
def stream(self, handler, file_id): | |
fs = yield motor.Op(motor.MotorGridFS(db).open) | |
try: | |
gridout = yield motor.Op(fs.get, file_id) |
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
# gief_new_branch <new_branch> [<start_point>] | |
# fetch 'upstream' named remote and branch out from 'upstream'/<start_point> | |
# git fetch upstream && git checkout -b <new_branch> upstream/[<start_point>] | |
function gief_new_branch() | |
{ | |
local EFG="\033[0;31m" | |
local QFG="\033[32m" | |
local NC="\033[0m" | |
echo -e "${EFG}" |
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 asyncore | |
import socket | |
import sys | |
class EchoHandler(asyncore.dispatcher_with_send): | |
def handle_read(self): | |
data = self.recv(8192) | |
if data: | |
self.send(data) |
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
# this original one uses values returned from 'brew info' | |
brew list --formula | xargs -n1 -P8 -I {} \ | |
sh -c "brew info {} | egrep '[0-9]* files, ' | sed 's/^.*[0-9]* files, \(.*\)).*$/{} \1/'" | \ | |
sort -h -r -k2 - | column -t | |
# faster alternative using 'du' | |
du -sch $(brew --cellar)/*/* | sed "s|$(brew --cellar)/\([^/]*\)/.*|\1|" | sort -k1h |
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
{ | |
"player_id": 0, | |
"turn": 0, | |
"map": [ | |
[{ | |
"occupants": [{ | |
"target": null, | |
"hit": 1, | |
"posy": 0, | |
"type": "Fort", |
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
extern crate kiss3d; | |
extern crate nalgebra; | |
extern crate rand; | |
extern crate serde; | |
#[macro_use] | |
extern crate serde_derive; | |
extern crate serde_json; | |
use kiss3d::camera::ArcBall; | |
use kiss3d::scene::SceneNode; |
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
extern crate kiss3d; | |
extern crate nalgebra; | |
extern crate rand; | |
extern crate serde; | |
#[macro_use] | |
extern crate serde_derive; | |
extern crate serde_json; | |
use kiss3d::camera::ArcBall; | |
use kiss3d::scene::SceneNode; |
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 logging | |
# more verbose %(asctime)s %(levelname)s [%(module)s.%(funcName)s():%(lineno)d] %(message)s | |
logging.basicConfig(format='%(asctime)s %(levelname)s %(message)s') | |
logger = logging.getLogger(__name__) | |
logger.setLevel(logging.INFO) |
OlderNewer