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
set-option -g default-command "reattach-to-user-namespace -l bash; echo running default command now" | |
unbind C-b | |
# I'm tempted to use C-a, but I want 'beginning of line' | |
set -g prefix C-q | |
bind-key q send-prefix | |
bind-key C-q send-prefix | |
set -g history-limit 1000000 |
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
diff --git a/libreadline.a b/libreadline.a | |
index 904a7ab..6c0aec9 100644 | |
Binary files a/libreadline.a and b/libreadline.a differ | |
diff --git a/readline.c b/readline.c | |
index 3550b35..8c0a221 100644 | |
--- a/readline.c | |
+++ b/readline.c | |
@@ -301,7 +301,7 @@ rl_set_prompt (prompt) | |
/* Read a line of input. Prompt with PROMPT. An empty PROMPT means | |
none. A return value of NULL means that EOF was encountered. */ |
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 asyncio | |
import urllib.parse | |
import sys | |
import os | |
from oldchat import CharacterAtATime | |
def red_on_blue(msg): | |
sys.stdout.write('\x1b[31m\x1b[44m' + msg + '\x1b[49m\x1b[39m') | |
sys.stdout.flush() |
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 random | |
def write_data(filename, num_bytes=1000000): | |
with open(filename, 'w') as f: | |
for _ in range((num_bytes / 1000) + 1): | |
f.write(''.join(random.choice('ab') for _ in range(1000))) | |
def read_chunks(filename, num_bytes=1000): | |
with open(filename, 'r') as f: | |
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 Board(object): | |
""" | |
>>> Board().rows | |
((' ', ' ', ' '), (' ', ' ', ' '), (' ', ' ', ' ')) | |
>>> print Board() | |
| | | |
----- | |
| | | |
----- |
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 Trie(object): | |
"""Simple Trie | |
>>> t = Trie() | |
>>> t.add('hi') | |
>>> t.add('hello') | |
>>> t.data.keys() | |
['h'] | |
>>> print t.display(), |
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
def parse_term_state(s): | |
"""Returns TerminalState tuple given a terminal state diagram | |
>>> parse_term_state(''' | |
... label | |
... +-----+ | |
... |ABC | | |
... +-----+ | |
... |BC | | |
... |abc@ | | |
... | | |
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
### current bpython session - file will be reevaluated, ### lines will not be run | |
class Mapping(object): | |
def __init__(self): | |
self.data = [] | |
def add_key_value_pair(self, key, value): | |
self.data.append([key, value]) | |
def get_value(self, key): | |
for k, value in self.data: | |
if k == key: | |
return value |
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
### current bpython session - file will be reevaluated, ### lines will not be run | |
class Mapping(object): | |
def __init__(self): | |
self.dict = {} | |
def add_key_value_pair(self, key, value): | |
self.dict[key] = value | |
def get_value(self, key): | |
return self.dict[key] | |
def remove_key(self, key): | |
del self.dict[key] |
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
""" Evidence the += method is bad: | |
In [4]: def plusequals(): | |
...: s = '' | |
...: for x in 'asdf'*1000: | |
...: s += x | |
In [5]: plusequals() | |
In [6]: def joinmethod(): | |
...: l = 'asdf'*1000 |