Skip to content

Instantly share code, notes, and snippets.

View amatellanes's full-sized avatar

Adrián Matellanes amatellanes

View GitHub Profile
@amatellanes
amatellanes / pytest.sh
Last active April 20, 2024 08:31
Useful py.test commands.
py.test test_sample.py --collect-only # collects information test suite
py.test test_sample.py -v # outputs verbose messages
py.test -q test_sample.py # omit filename output
python -m pytest -q test_sample.py # calling pytest through python
py.test --markers # show available markers
@amatellanes
amatellanes / celery.sh
Last active April 19, 2024 11:31
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.#'),
@amatellanes
amatellanes / chrome.sh
Created November 12, 2013 11:10
Install Google Chrome 64-bit version on Ubuntu 14.04 LTS (Trusty Tahr)
wget https://dl.google.com/linux/direct/google-chrome-stable_current_amd64.deb
sudo dpkg -i google-chrome-stable_current_amd64.deb;
sudo apt-get -f install
@amatellanes
amatellanes / sublime.sh
Last active October 26, 2021 20:34
Install Sublime Text 3 on Ubuntu 14.04 LTS (Trusty Tahr)
sudo add-apt-repository ppa:webupd8team/sublime-text-3;
sudo apt-get update;
sudo apt-get install sublime-text-installer;
sudo ln -s /usr/lib/sublime-text-3/sublime_text /usr/local/bin/sublime;
@amatellanes
amatellanes / mdcharm.sh
Last active June 11, 2021 12:58
Install MdCharm 1.2 on Ubuntu 14.04 LTS (Trusty Tahr)
wget https://github.com/zhangshine/MdCharm/releases/download/1.2.0/mdcharm_1.2_amd64.deb;
sudo dpkg -i mdcharm_1.2_amd64.deb;
sudo apt-get -f install
@amatellanes
amatellanes / oracle_java8.sh
Last active June 8, 2021 23:37
Install Oracle Java 8 on Ubuntu 14.04 LTS (Trusty Tahr)
sudo add-apt-repository ppa:webupd8team/java;
sudo apt-get update;
sudo apt-get install oracle-java8-installer;
sudo update-alternatives --config java;
java -version;
@amatellanes
amatellanes / handy_git_commands.sh
Last active May 4, 2021 22:31
Handy Git commands
$ git reset --hard HEAD~1
$ git push -f # removes last commit.
$ git diff --staged # will show you the diff that you're about to commit.
$ git commit -am "First commit" # adds all changes to tracked files and uses the commit message from the command-line.
$ git diff -M # only considers a file that disappeared as the source of a rename.
$ git diff -b # the -b means ignore whitespace, useful since we've changed some html indenting.
@amatellanes
amatellanes / forms.py
Last active February 19, 2021 09:55
A Yes/No field for Django.
from django import forms
class Form(forms.Form):
field = forms.TypedChoiceField(coerce=lambda x: x =='True',
choices=((False, 'No'), (True, 'Yes')))
@amatellanes
amatellanes / parallel_fibonacci.py
Last active December 5, 2019 23:22
Fibonnaci series by using threading module in Python.
import threading
from Queue import Queue
fibo_dict = {}
shared_queue = Queue()
input_list = [3, 10, 5, 7]
queue_condition = threading.Condition()
@amatellanes
amatellanes / .hg_check_issue_id
Created March 24, 2019 16:10
Check that a commit comment mentions the current branch name (potentially tracking issue ID)
#!/usr/bin/env bash
HG_COMMIT_MESSAGE="$(hg tip --template {desc})"
HG_BRANCH="$(hg identify -b)"
if [[ ${HG_COMMIT_MESSAGE=} = *${HG_BRANCH}* ]]; then
exit 0
fi
exit 1