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.utils.crypto import get_random_string | |
hash_key = get_random_string(length=8) |
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
function my_beautful_ps1 { | |
local __path="\[\033[38;5;8m\][\w]\[$(tput sgr0)\]\[\033[38;5;15m\]" | |
local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`' | |
local __end_prompt="\[$(tput sgr0)\]\[\033[38;5;202m\]>\[$(tput sgr0)\]" | |
export PS1="$__path $__git_branch$__end_prompt " | |
} | |
my_beautful_ps1 |
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
function my_beautful_ps1 { | |
local __path="\[\033[38;5;8m\][\w]\[$(tput sgr0)\]\[\033[38;5;15m\]" | |
local __git_branch='`git branch 2> /dev/null | grep -e ^* | sed -E s/^\\\\\*\ \(.+\)$/\(\\\\\1\)\ /`' | |
local __end_prompt="\[$(tput sgr0)\]\[\033[38;5;202m\]>\[$(tput sgr0)\]" | |
export PS1="$__path $__git_branch$__end_prompt " | |
} | |
my_beautful_ps1 |
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 datetime | |
def d2t(t): | |
h = int(t) | |
m = (t * 60) % 60 | |
s = (t * 3600) % 60 | |
a = map(lambda x: int(x), [h, m, s]) | |
return datetime.time(*a) |
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
""" | |
Before | |
""" | |
def something(self, is_closed, is_out_of_time): | |
if is_closed: | |
return True | |
if not is_closed and is_out_of_time: | |
return True | |
return False |
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 _setup_changelist_queryset(self, params): | |
request = self.factory.get("/", params) | |
changelist = self._get_changelist(request, model, ma) | |
return changelist.get_query_set(request) | |
def _get_changelist(self, request, model, ma): | |
args = self._get_changelist_args(request, Leilao, self.ma) | |
return ChangeList(*args) | |
def _get_changelist_args(self, request, model, ma): |
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
SAVEIFS=$IFS | |
IFS=$(echo -en "\n\b") | |
for f in $(ls | grep -v git | grep -v salvar_documentos.py | grep -v dt18) | |
do | |
mv $f dt18/ | |
done | |
IFS=$SAVEIFS |
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
mplayer -vo xv tv:// -tv driver=v4l2:width=640:height=480:fps=30:device=/dev/video0 |
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.core.files import File | |
s = SimpleModel() | |
s.audio_file = File(open("media/testfiles/testaudio.wav")) | |
s.save() |
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
>>> import json | |
>>> import datetime | |
>>> from django.core.serializers.json import DjangoJSONEncoder | |
>>> di = {'now': datetime.datetime.now()} | |
>>> json.dumps(di, cls=DjangoJSONEncoder) | |
'{"now": "2015-12-10T23:32:42.344"}' | |