This file contains 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
# -*- coding: utf-8 -*- | |
from glob import glob | |
from exiftool import ExifToolHelper | |
from datetime import datetime | |
from datetime import timedelta | |
# Requires exiftool and pyexiftool. See: <https://sylikc.github.io/pyexiftool/installation.html#pyexiftool-dependencies> | |
photos = sorted(glob('**/*.jpg')) |
This file contains 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
#!/usr/bin/env python3 | |
# -*- coding: utf-8 -*- | |
import argparse | |
from binascii import unhexlify, hexlify | |
from itertools import cycle | |
def encrypt(data, key): | |
return hexlify(bytes(x ^ y for x, y in zip(bytes(data, "utf-8"), cycle(unhexlify(key))))) |
This file contains 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 | |
# This hook is run after this virtualenv is activated. | |
# To be in $VIRTUALENV_HOME/bin/postactivate | |
if [[ -n $DJANGO_SETTINGS_MODULE ]] | |
then | |
export DJANGO_SETTINGS_MODULE_BACKUP=$DJANGO_SETTINGS_MODULE | |
fi | |
export DJANGO_SETTINGS_MODULE=YOUR.VALUE |
This file contains 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 unittest import TestCase | |
import mock | |
from django import models | |
from django.core.exceptions import ObjectDoesNotExist | |
class Foo(models.Model): | |
# ... | |
@property | |
def has_pending_related(self): | |
try: |
This file contains 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 | |
set -x | |
service postgresql stop | |
TMPDIR=/tmp/tmp_psql | |
MOUNTPOINT=/var/lib/postgresql | |
mount -t tmpfs -o size=512M,nr_inodes=10k,mode=0777 tmpfs $TMPDIR | |
rsync --archive $MOUNTPOINT/ $TMPDIR/ | |
mount -o bind $TMPDIR $MOUNTPOINT | |
service postgresql start |
This file contains 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
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import sys | |
import os | |
import glob | |
from lxml import etree | |
def tests_elements(nodes): | |
for elm in nodes: |
This file contains 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
[user] | |
name = Your Name | |
email = [email protected] | |
[color] | |
ui = true | |
[pull] | |
default = current | |
[push] | |
default = current | |
[alias] |
This file contains 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
#!/usr/bin/env python | |
import os | |
import sys | |
import re | |
import subprocess | |
from functools import partial | |
# Fabric requirement just for easy colour output | |
from fabric.colors import red, green, yellow |
This file contains 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 unittest import TestCase | |
import inspect | |
class AssertExample(object): | |
def __create_method(self, tc, name): | |
def method(self, *args, **kwargs): | |
return tc.__getattribute__(name)(self, *args, **kwargs) | |
return method |
This file contains 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
# post-checkout hook (on <path-to-project>/.git/hooks/post-checkout file) | |
# to avoid errors for old pyc files when checkout. | |
# Remember execution privileges (chmod +x <path-to-project>/.git/hooks/post-checkout). | |
#!/bin/bash | |
# Start from the repository root | |
cd ./$(git rev-parse --show-cdup) | |
# Delete pyc and empty directories | |
echo "[post-checkout] Deleting .pyc and empty directories" | |
find . -name "*.pyc" -delete |
NewerOlder