^A
move cursonr to Begin of line^E
move cursonr to End of line^D
delete current char^W
delete word left to current char^U
delete everything left to current char^K
delete everything right to current char^T
transpose^F
(right arrow) move cursonr to Next char^B
(left arrow) move cursonr to Prev char^P
bring Prev history cmd
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
"""Bisect based formula testing. | |
Implements bisect_lt, bisect_le, bisect_ge, bisect_gt from scratch using `yfun` | |
# http://code.google.com/codejam/contest/2418487/dashboard | |
>>> r, t = 10**16, 10**18 | |
>>> yfun = lambda x: (2*(10**16) + (2*x) -1) * x | |
Given bisect_le(yfun, y, range(N)) | |
>>> bisect_le(yfun, t, range(t)) | |
49 |
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
"""Got intriged with signal capabilities (http://docs.python.org/2/library/signal.html) | |
I define simple ``asyncall`` function thats takes numner seconds and deffered function (similar window.setTimeout(n_ms, func/code_literal)) | |
>>> asyncall(5, lambda *args: say('A')) | |
>>> asyncall(10, lambda *args: say('B')) | |
>>> asyncall(2, lambda *args: say('C')) | |
C | |
A | |
B |
- optimize for happiness
- best argument wins
- make decisions from first principals (values)
- create superfans
- be awseome and change the wolrd
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
### Plots | |
x <- seq(0, 4, 0.1) | |
y <- cos(x) | |
plot(x, y, col=rainbow(12)) # 2-RED, 3-GREEN, 4-BLUE | |
a <- c(5, 8, 3); names(a)<- c("England", "France", "Norway"); barplot(a) | |
abline(h, v, lty=3, col="lightgray") | |
barplot(sin(seq(0, 4, 0.1))) | |
qplot(Xvect, Yvects) | |
qplot(weights, prices, col=factor(types)) | |
abline(lm(X~Y)) |
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
# Ned's .pdbrc | |
# Print a dictionary, sorted. %1 is the dict, %2 is the prefix for the names. | |
alias p_ for k in sorted(%1.keys()): print "%s%-15s= %-80.80s" % ("%2",k,repr(%1[k])) | |
# Print the instance variables of a thing. | |
alias pi p_ %1.__dict__ %1. | |
# Print the instance variables of self. | |
alias ps pi 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
$ echo a b c d | |
a b c d | |
# PCA. - meaning previous command argument | |
$ echo !* ; # !* is all PCA == echo a b c d | |
a b c d | |
$ echo !^ ; # !^ is first PCA == echo a | |
a |
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 unittest2 as unittest | |
from mock import patch | |
from mock import Mock | |
from datetime import datetime as dt | |
class TestMock(unittest.TestCase): | |
NOW = datetime.datetime(1970, 1, 1, 0, 0) | |
datetime_mock = Mock(side_effect = lambda *args, **kw: | |
dt(*args, **kw)) | |
datetime_mock.now.return_value = NOW |