Skip to content

Instantly share code, notes, and snippets.

View jorgeas80's full-sized avatar
🎯
Focusing

Jorge Arévalo jorgeas80

🎯
Focusing
View GitHub Profile
@jorgeas80
jorgeas80 / oneliner_join.py
Last active October 4, 2018 14:44
Python one-liner to show a comma-separated string of all the not None elements of a list
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)))
@jorgeas80
jorgeas80 / celery.sh
Created June 18, 2018 13:23 — forked from amatellanes/celery.sh
Celery handy commands
/* 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.#'),
@jorgeas80
jorgeas80 / encodings y python
Last active May 23, 2018 12:04
encodings y python
- 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 :-(
# 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
@jorgeas80
jorgeas80 / get_sizes.sql
Created October 15, 2017 09:17
Get size of database objects
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;
@jorgeas80
jorgeas80 / initial_data.sh
Created May 12, 2017 11:13
Django dumpdata for initial data fixtures
python manage.py dumpdata app_name --indent=4 > initial_data.json
@jorgeas80
jorgeas80 / GIT Cheatsheet
Last active February 17, 2017 09:40
Some useful git commands
# 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
@jorgeas80
jorgeas80 / what_to_push_files.sh
Created January 19, 2017 10:00
Check the files we're about to push
#!/bin/bash
git diff --stat --cached $1
@jorgeas80
jorgeas80 / what_to_push_content.sh
Created January 19, 2017 09:59
Check the content of the files we're about to push
#!/bin/bash
git diff remote $1
@jorgeas80
jorgeas80 / check_conflicts.sh
Created January 19, 2017 09:55
Check git conflicts after a merge
#!/bin/bash
git diff --name-only --diff-filter=U