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
#### write a dataframe as a csv | |
write.table(df, file="<filename>", row.names=F, sep=",", quote=F) | |
#### select dataframe rows by column value | |
df[df$state=="<colname>",] | |
#### select columns | |
# by column index | |
want_cols <- c(7, 8, 12) | |
trimmed_df <- df[,want_cols] |
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
export GOROOT=/usr/local/go | |
export PATH=$PATH:$GOROOT/bin | |
export GOPATH=$HOME/go | |
export PATH=$PATH:$GOPATH/bin | |
eval `ssh-agent -s` | |
ssh-add $HOME/.ssh/github # for disco-files repo | |
ssh-add $HOME/.ssh/nn_trainer_key # for nn_trainer repo |
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 Queue import PriorityQueue | |
def backtrack(node, parent_map): | |
""" | |
Accepts a search node and a map from nodes to nodes representing the parent node | |
Returns a list of nodes that correspond to a path starting at start node and ending at given node | |
""" | |
parent = parent_map[node] | |
path = [node, parent] # assumes parent is not None | |
while True: |
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
class Search(object): | |
def __init__(self, state, *args, **kwargs): | |
self.state = state | |
self.cost_func = None | |
def actions(self): | |
""" | |
Returns a set of actions. |
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 sys | |
import logging | |
import os | |
from brubeck.request_handling import Brubeck, WebMessageHandler | |
from brubeck.connections import Mongrel2Connection | |
from ws4py.framing import Frame, \ | |
OPCODE_CONTINUATION, OPCODE_TEXT, \ | |
OPCODE_BINARY, OPCODE_CLOSE, OPCODE_PING, OPCODE_PONG |
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
setup_compress = """ | |
for i in xrange(10000): | |
r.hset(str(i), str(i), zlib.compress(10 * "my name is mud", 1))""" | |
setup_normal = """ | |
for i in xrange(10000): | |
r.hset(str(i), str(i), 10 * "my name is mud")""" |
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
// (launch with OSC_send.ck) | |
// the patch | |
// create our OSC receiver | |
OscRecv recv; | |
// use port 6449 | |
6449 => recv.port; | |
// start listening (launch thread) | |
recv.listen(); |
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
Tue, 03 Apr 2012 20:04:50 GMT [WARN] (src/register.c:336: errno: Resource temporarily unavailable) Killed 1 connections according to min_ping: 120, min_write_rate: 300, min_read_rate: 300 | |
Tue, 03 Apr 2012 20:04:50 GMT [WARN] (src/mongrel2.c:205: errno: Resource temporarily unavailable) Timeout task killed 1 tasks, waiting 10 seconds for more. |
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
# I am using http://isr.nu/ws/WebSocketTest.htm to help debug my websocket connection | |
# and I send websocket requests to ws://127.0.0.1:6767/websockets | |
######## IMPORTANT: | |
######## Add the websocket method to the MessageHandler class | |
## inside brubeck.request_handling- add 'websocket' method: | |
# HTTP_METHODS = ['get', 'post', 'put', 'delete', | |
# 'head', 'options', 'trace', 'connect', 'websocket'] | |
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
"""Implementation of JSONEncoder | |
Added pretty printing to html, wherein indents are " " and newlines are "<br>". | |
# added html keyword arg; default is html=False | |
json.dumps(obj[, skipkeys[, ensure_ascii[, check_circular[, allow_nan[, cls[, indent[, html[, separators[, encoding[, default[, **kw]]]]]]]]]]]) | |
Serialize obj to a JSON formatted str. | |
If html is True and indent is not None the encoder indents are printed as " " and newlines are "<br>" | |
""" | |
import re |