Say you have a package with this layout:
my_project/
my_app/
files/
im_a_file.txt
__init__.py
run_my_app.py
| # this is not actually a shell script, just some self-reminders for stuff to do on new systems. mind the git configs. | |
| # lets be serious | |
| sudo apt-get install aptitude | |
| # git. | |
| sudo aptitude install git meld | |
| git config --global user.name "Your Name Here" | |
| git config --global user.email "[email protected]" |
| In [1]: class RaiseEWithCaret(object): | |
| ...: def __xor__(self, exponent): | |
| ...: from math import exp | |
| ...: return exp(exponent) | |
| ...: | |
| In [2]: e = RaiseEWithCaret() | |
| In [3]: e^1 | |
| Out[3]: 2.718281828459045 |
| >>> class AttrDict(dict): | |
| ... """A class that is annoyingly difficult to get right in python.""" | |
| ... def __getattr__(self, attr): | |
| ... """access items by key with dot notation""" | |
| ... try: | |
| ... return super(AttrDict, self).__getitem__(attr) | |
| ... except KeyError as e: | |
| ... raise AttributeError(e) # translate the error where applicable yay | |
| ... | |
| >>> |
| #!/bin/bash | |
| # This hook is run after every virtualenv is activated. | |
| export CONFIG=$VIRTUAL_ENV/bin/postactivate |
Say you have a package with this layout:
my_project/
my_app/
files/
im_a_file.txt
__init__.py
run_my_app.py
| """ | |
| The class decorator screws up the inheritance, so super() gets confused and doesn't super superly. | |
| """ | |
| def make_awesome(cls): | |
| class Awesomefied(cls): | |
| """make this class awesomer""" | |
| return Awesomefied | |
| // Sometimes solves kortaggio's 5x5 variant of 2048: http://kortaggio.github.io/2048/ | |
| // Open the javascript console with ctrl+j (in chromium), and copy past this in. | |
| // export the game manager into the global namespace | |
| GameManager.prototype.__original_actuate = GameManager.prototype.actuate; | |
| GameManager.prototype.actuate = function() { | |
| window.gm = this; | |
| this.__original_actuate(); | |
| GameManager.prototype.actuate = GameManager.prototype.__original_actuate; | |
| }; |
| """ | |
| Defines a function `auto_insert` to help with | |
| `pygit2.Repository.TreeBuilder`s. | |
| Just create the top-level `TreeBuilder`, and it will handle all subtree | |
| creation if you give it paths. | |
| """ | |
| import shutil | |
| from tempfile import mkdtemp |
| 55 | |
| 35 | |
| 30 | |
| 46 | |
| 38 | |
| 60 | |
| 77 | |
| 77 | |
| 57 | |
| 30 |