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 operator import is_not | |
from functools import partial | |
fruits = ["apple", "banana", None, "pear", None, "peach", None, None, "grapes"] | |
# Prints: apple, banana, pear, peach, grapes | |
print(", ".join(filter(partial(is_not, None), fruits))) |
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
/* Useful celery config. | |
app = Celery('tasks', | |
broker='redis://localhost:6379', | |
backend='redis://localhost:6379') | |
app.conf.update( | |
CELERY_TASK_RESULT_EXPIRES=3600, | |
CELERY_QUEUES=( | |
Queue('default', routing_key='tasks.#'), |
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
- Encoding es una manera de transformar símbolos en bytes. | |
- Populares: ASCII (solo sabe transformar 127 símbolos), UTF-8 (sabe transformar todos los símbolos unicode, que son 1.1M) | |
- Python 2: usa ASCII como encoding por defecto => cuando intenta transformar un símbolo en bytes, aplica ASCII. Si encuentra algo que no entiende, por defecto peta :-( |
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
# I have followed PyImageSearch tutorial http://www.pyimagesearch.com/2015/07/20/install-opencv-3-0-and-python-3-4-on-ubuntu/ | |
# Ubuntu upgrade & update current libraries | |
sudo apt-get update | |
sudo apt-get upgrade | |
# Install dependancies | |
sudo apt-get install build-essential cmake git pkg-config | |
sudo apt-get install libjpeg8-dev libtiff4-dev libjasper-dev libpng12-dev | |
sudo apt-get install libavcodec-dev libavformat-dev libswscale-dev libv4l-dev |
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
SELECT | |
relname as "Table", | |
pg_size_pretty(pg_total_relation_size(relid)) As "Size", | |
pg_size_pretty(pg_total_relation_size(relid) - pg_relation_size(relid)) as "External Size" | |
FROM pg_catalog.pg_statio_user_tables ORDER BY pg_total_relation_size(relid) DESC; |
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
python manage.py dumpdata app_name --indent=4 > initial_data.json |
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
# Go back to the previous commit version of a file | |
```git checkout -- /path/to/file``` | |
# Go back to the previous commit version of everything | |
```git reset --hard HEAD``` | |
# Revert the last PUSHED commit and make a new one to amend the changes | |
```git revert HEAD``` | |
# Reset the last PUSHED commit and detach our working copy from the last commit |
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
#!/bin/bash | |
git diff --stat --cached $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
#!/bin/bash | |
git diff remote $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
#!/bin/bash | |
git diff --name-only --diff-filter=U |