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
{% load fixture_tags %} | |
[ | |
{% genfixtures "1:5" %} | |
{ | |
"pk": {{ fixture.pk }}, | |
"model": "auth.user", | |
"fields": { | |
"username": "{% gen_char "my_custom_username_generator" %}", | |
"first_name": "{% gen_char "first_name" %}", | |
"last_name": "{% gen_char "last_name" %}", |
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
test |
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 django.contrib import admin | |
from django.conf import settings | |
from django.utils.translation import ugettext_lazy as _ | |
from easy_thumbnails.files import get_thumbnailer | |
class AdminThumbnailMixin(object): | |
thumbnail_options = {'size': (60, 60)} | |
thumbnail_image_field_name = 'image' | |
thumbnail_alt_field_name = None |
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
def getLastDateModification(self): | |
qs = self.themefile_set.order_by('-date_modified') | |
# NEVER !! | |
return qs[0].date_modified | |
# The most efficient/failsafe way (this will add LIMIT 1 to the query): | |
rs = list(qs[:1]) | |
return rs and rs[0].date_modified or None |
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
def dotted_line(**kwargs): | |
out = [] | |
width = kwargs.get('right') - kwargs.get('left') | |
dash = kwargs.pop('dash') | |
dashcount = width / dash | |
new_kwargs = kwargs.copy() | |
new_kwargs['left'] = kwargs.get('left') - (dash * 2) | |
for d in range(0, int(dashcount)): | |
new_kwargs['left'] = new_kwargs['left'] + dash + dash | |
new_kwargs['right'] = new_kwargs['left'] + dash |
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 | |
# Credits: | |
# v1 (original code): Ian Vaughan (http://stackoverflow.com/a/4960140/105905) | |
# v2 (Minor changes): Maxime Haineault (https://gist.github.com/h3/5446756) | |
sha=0 | |
previous_sha=0 | |
update_sha() |
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
def get_dict_from_list(l, k, v): | |
""" | |
Returns a dict from a dict list given a matching key value pair | |
and returns None if no matches. | |
>>> test = [{'A': 'a1', 'B': 'b1'}, {'B': 'b2', 'A': 'a2', }] | |
>>> get_dict_from_list('A', 'a2') | |
{'B': 'b2', 'A': 'a2', } | |
""" |
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/sh | |
RESTART="/etc/init.d/networking restart" | |
FILEPATH="/etc/network/interfaces" | |
BACKUPPATH="$FILEPATH.BAK" | |
RESET_TIME="now + ${1:-5min}" | |
sudo cp -fp $FILEPATH $BACKUPPATH && \ | |
sudoedit $FILEPATH && \ | |
sudo bash -c "echo 'cp -fp $BACKUPPATH $FILEPATH && $RESTART' | at $RESET_TIME" && \ |
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
$ pip install pip | |
Collecting pip | |
Using cached pip-9.0.1-py2.py3-none-any.whl | |
Installing collected packages: pip | |
Successfully installed pip-8.1.1 | |
You are using pip version 8.1.1, however version 9.0.1 is available. | |
You should consider upgrading via the 'pip install --upgrade pip' command. | |
$ pip install pip --upgrade pip |
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 __future__ import unicode_literals | |
import re | |
import sys | |
def c(i): | |
""" |
OlderNewer