This gist shows how to create a GIF screencast using only free OS X tools: QuickTime, ffmpeg, and gifsicle.
To capture the video (filesize: 19MB), using the free "QuickTime Player" application:
{% load pagination_tags %} | |
{% load sorting_tags %} | |
{% block body %} | |
{% autosort filter.qs as sorted_objects %} | |
{% autopaginate sorted_objects 10 as object_list %} | |
{% for object in object_list %} | |
{{ object }} |
# Put this in your ~/.gitconfig or ~/.config/git/config | |
# Windows users: "~" is your profile's home directory, e.g. C:\Users\<YourName> | |
[user] | |
name = Your Full Name | |
email = your@email.tld | |
[color] | |
# Enable colors in color-supporting terminals | |
ui = auto | |
[alias] | |
# List available aliases |
Either copy the aliases from the .gitconfig
or run the commands in add-pr-alias.sh
Easily checkout local copies of pull requests from remotes:
git pr 4
- creates local branch pr/4
from the github upstream
(if it exists) or origin
remote and checks it outgit pr 4 someremote
- creates local branch pr/4
from someremote
remote and checks it outfrom django.core.management.base import BaseCommand | |
from mymodule import main | |
import logging | |
class Command(BaseCommand): | |
help = 'Do foo' | |
def handle(self, *args, **options): |
This can be used to daemonize anything that would normally run in the foreground; I picked Redis. Put this in /etc/systemd/system/redis.service
:
[Unit]
Description=Redis
After=syslog.target
[Service]
ExecStart=/usr/local/bin/redis-server /etc/redis/redis.conf
RestartSec=5s
def valid_date_type(arg_date_str): | |
"""custom argparse *date* type for user dates values given from the command line""" | |
try: | |
return datetime.datetime.strptime(arg_date_str, "%Y-%m-%d") | |
except ValueError: | |
msg = "Given Date ({0}) not valid! Expected format, YYYY-MM-DD!".format(arg_date_str) | |
raise argparse.ArgumentTypeError(msg) | |
def valid_datetime_type(arg_datetime_str): | |
"""custom argparse type for user datetime values given from the command line""" |
Things I wish I knew when starting python | |
improve the basic interpreter | |
PYTHONSTARTUP is an environment variable you can use to fix the command prompt, i.e. provide autocomplete via tab, and suggestions. | |
set $PYTHONSTARTUP=~/.pythonstartup in .bashrc | |
export PYTHONSTARTUP=~/.pythonstartup | |
turn off creation of .pyc files | |
PYTHONDONTWRITEBYTECODE=1 |
from __future__ import print_function | |
import platform | |
import sys | |
import threading | |
import time | |
class UnsyncedBankAccount(object): | |
"""Bank account with no synchronization lock, prone to race condition.""" |
Python's tarfile documentation leaves the following nasty warning:
Warning Never extract archives from untrusted sources without prior inspection. It is possible that files are created outside of path, e.g. members that have absolute filenames starting with "/" or filenames with two dots "..".
Let's see what that exactly means.