This file contains hidden or 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
tab() { | |
printf '\e]1;%s\a' "$*" | |
} |
This file contains hidden or 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.db.transaction import * # NOQA | |
from django.utils.decorators import ContextDecorator | |
LOCK_MODES = ( | |
'ACCESS SHARE', | |
'ROW SHARE', | |
'ROW EXCLUSIVE', | |
'SHARE UPDATE EXCLUSIVE', | |
'SHARE', |
This file contains hidden or 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
source /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-completion.bash | |
source /Applications/Xcode.app/Contents/Developer/usr/share/git-core/git-prompt.sh | |
GIT_PS1_SHOWDIRTYSTATE=true | |
export PS1='\u@\h:\W$(__git_ps1)$ ' |
This file contains hidden or 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
GREEN='\e[32m' | |
DEFAULT='\e[39m' | |
PS1="\u@\h:\w$GREEN\$(git branch 2>/dev/null | grep '^*' | colrm 1 1)$DEFAULT\$ " |
This file contains hidden or 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
package main | |
import ( | |
"fmt" | |
"encoding/json" | |
"github.com/jackc/pgx" | |
"log" | |
) | |
var schema = ` |
This file contains hidden or 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
package main | |
import ( | |
"encoding/json" | |
"errors" | |
"database/sql/driver" | |
"fmt" | |
"github.com/jmoiron/sqlx" | |
_ "github.com/lib/pq" | |
"log" |
This file contains hidden or 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 functools | |
def kwargs_decorator(decorator): | |
""" Allows to easily create docorators with optional keyword argument. | |
Decorator must not be called with positional arguments. | |
""" | |
@functools.wraps(decorator) | |
def wrapper(wrapped=None, **kwargs): | |
if wrapped is None: |
This file contains hidden or 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 os | |
from django import template | |
from django.conf import settings | |
register = template.Library() | |
@register.simple_tag(name="vstatic") | |
def vstatic(path): | |
""" Return absolute URL to static file with versioning. """ |
This file contains hidden or 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
class IgnoreRequestDataReadError(logging.Filter): | |
def filter(self, record): | |
if record.exc_info: | |
exc_value = record.exc_info[1] | |
if isinstance(exc_value, IOError) and unicode(exc_value) == 'request data read error': | |
return False |
This file contains hidden or 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
class IgnoreHostError(logging.Filter): | |
def filter(self, record): | |
from django.core.exceptions import SuspiciousOperation | |
if record.name == 'django.security.DisallowedHost': | |
return False | |
if record.name == 'django.core.exceptions.DisallowedHost': | |
return False | |
if record.exc_info: | |
exc_value = record.exc_info[1] |