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/python3 | |
""" | |
>>> some_unicode = u'èṽèṙẏbody ♥ utf8' | |
>>> | |
>>> some_unicode.encode('ascii', errors='replace') | |
b'?????body ? utf8' | |
>>> | |
>>> import unicodedata | |
>>> unicodedata.normalize('NFKD', some_unicode).encode( |
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
Spaces = ```Fn + F8``` | |
Screenshots | |
----------- | |
* the whole screen, press ```⌘-⇧-3``` | |
* part of the screen, press ```⌘-⇧-4``` and select the area you want | |
* to the Clipboard instead of saving as a file press: | |
* ```^-⌘-⇧-3``` to copy the entire screen | |
* ```^-⌘-⇧-4``` to copy the selected area | |
* for curent window, press ```⌘-⇧-4``` then ```Spacebar``` |
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 |
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
# 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
### 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)) |
- optimize for happiness
- best argument wins
- make decisions from first principals (values)
- create superfans
- be awseome and change the wolrd