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
http://airbnb.io/superset/index.html |
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
os.chdir(path) | |
os.path.dirname(os.path.abspath(__file__)) | |
os.path.dirname(os.path.realpath(__file__)) | |
os.path.abspath(os.path.dirname(sys.argv[0])) | |
# Long | |
import os | |
print('Path at terminal when executing this file') | |
print(os.getcwd() + '\n') |
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 IPython.display import SVG, 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
dir > a.txt 2>&1 |
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 SimpleNamespace: | |
def __init__(self, **kwargs): | |
self.__dict__.update(kwargs) | |
def __repr__(self): | |
keys = sorted(self.__dict__) | |
items = ('{}={!r}'.format(k, self.__dict__[k]) for k in keys) | |
return '{}({})'.format(type(self).__name__, ', '.join(items)) |
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 types | |
class Timed(object): | |
def __init__(self, f): | |
self.func = f | |
def __call__(self, *args, **kwargs): | |
start = dt.datetime.now() | |
ret = self.func(*args, **kwargs) | |
time = dt.datetime.now() - start |
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
- http://www.devdungeon.com/content/working-binary-data-python | |
- https://docs.python.org/2/library/shutil.html#shutil.make_archive |
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
Fixing Settings | |
We’re on a mission to fix your bad settings files here. We show this layout to new clients and I’m constantly surprised how few people know this is even possible to do. I blame the fact that while everyone knows that settings are just Python code, they don’t think about them as Python code. | |
So let’s fix up our settings. For our foo project we’re going to have 4 environments: dev, stage, jenkins, and production. So let’s give each it’s own file. The process to do this is: | |
In foo/foo/ make a settings directory and create an empty __init__.py file inside it. | |
Move foo/foo/settings.py into foo/foo/settings/base.py | |
Create the individual dev.py, stage.py, jenkins.py, and prod.py files in foo/foo/settings/. Each of these 4 environment specific files should simply contain the following: | |
from base import * |
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
/* | |
* This function scans through all files in the wp-content/uploads | |
* folders and imports them into the media library. This should be | |
* included in your theme's functions.php file. Simply visit your | |
* website, including the URL param: | |
* http://www.example.org/?import_non_existing_media_library_entries=1 | |
* | |
* Plan on it timing out a few times. Just keep refreshing. It won't | |
* duplicate files being imported. | |
*/ |