git add -p
git rebase -i HEAD~5
# last five commits
db.logs.aggregate({$group: {_id: {'exchangeType': '$result.exchangeType'}, soma: {$sum: 1}}}) |
#!/bin/bash | |
echo "Running tests..." | |
pytest tests/ | |
code=$? | |
if [ "$code" -eq "0" ]; then | |
echo | |
echo | |
echo "All tests passed. Continuing..." |
# Taken from: https://cito.github.io/blog/f-strings/ | |
import timeit | |
format = """ | |
def format(name, age): | |
return f'He said his name is {name} and he is {age} years old.' | |
""", """ | |
def format(name, age): | |
return 'He said his name is %s and he is %s years old.' % (name, age) |
""" | |
Hugo new post | |
> python newpost.py --title="Regex pra quem não sabe Regex" --lang=pt-br --editor=atom | |
Same of: | |
hugo new regex-pra-quem-não-sabe-regex.pt-br.md --editor=atom | |
""" | |
import argparse |
class DbWorker: | |
"""Doing the hard work on the DB.""" | |
def __init__(self, queries): | |
self.queries = queries # old tables | |
def _connect(self, credentials): | |
# TODO here only db connection stuff - must return the cursor | |
# TODO must thrown an exception in error cases | |
pass |
from celery.signals import task_failure, after_task_publish | |
@app.task(bind=True) | |
def my_task(self): | |
print(1/0) # this line will cause an exception | |
@after_task_publish.connect(sender='mymodule.tasks.my_task') | |
def task_sent_handler(sender=None, headers=None, body=None, **kwargs): |
$ git reflog my-branch # get the hash of the commit you want to be the HEAD (to be the last one in your git log) | |
$ git reset --hard a91ab06a5 |
#!/usr/bin/python | |
""" | |
Pre-commit hook for git written in Python. | |
Check if there is any migration number used more than one in each | |
migrations folder of South or Django >= 1.7. | |
You can install this pre-hook by executing the command: | |
ln -s ./git-pre-commit-hook .git/hooks/pre-commit | |
chmod +x .git/hooks/pre-commit | |
Or by calling the current script or check_migrations_files() in your | |
own file. |