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
# To display final query with also arguments. | |
from sqlalchemy.dialects import postgresql | |
print(query.statement.compile(dialect=postgresql.dialect(), compile_kwargs={"literal_binds": True})) |
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
function timer_start { | |
timer=${timer:-$SECONDS} | |
} | |
function timer_stop { | |
timer_show=$(($SECONDS - $timer)) | |
if [[ $timer_show -ge '10' ]]; then | |
tput bel | |
fi | |
unset timer |
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
[ui] | |
username = "" | |
verbose = True | |
[defaults] | |
glog = --color always | |
[pager] | |
pager = LESS='FSRX' less | |
#ignore = version, help, update, serve, record |
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
export GREP_OPTIONS='--color=auto' | |
export GREP_COLOR='1;31' | |
export HISTCONTROL=erasedups # Ignore duplicate entries in history | |
export HISTSIZE=100000 # Increases size of history | |
export HISTIGNORE="&:ls:ll:la:l.:pwd:exit:clear:clr:[bf]g" | |
shopt -s histappend # Append history instead of overwriting | |
shopt -s cdspell # Correct minor spelling errors in cd command | |
shopt -s dotglob # includes dotfiles in pathname expansion | |
shopt -s checkwinsize # If window size changes, redraw contents |
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 re | |
text = "SPITFIRE 1950S STYLE CAT EYE WAYFARER SUNGLASSES WITH CLEAR ACETATE FRAME SILVER METAL ARMS BLACK BROW DETAIL AND GREEN LENSES." | |
rtn = re.split('([.!?] *)', text) | |
result = ''.join([each.capitalize() for each in rtn]) | |
# print(result) | |
# Spitfire 1950s style cat eye wayfarer sunglasses with clear acetate frame silver metal arms black brow detail and green lenses. |
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 resource | |
print(resource.getrusage(resource.RUSAGE_SELF).ru_maxrss / 1000) |
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
def scale(image, max_size, method=Image.ANTIALIAS): | |
""" | |
resize 'image' to 'max_size' keeping the aspect ratio | |
and place it in center of white 'max_size' image | |
""" | |
im_aspect = float(image.size[0])/float(image.size[1]) | |
out_aspect = float(max_size[0])/float(max_size[1]) | |
if im_aspect >= out_aspect: | |
scaled = image.resize((max_size[0], int((float(max_size[0])/im_aspect) + 0.5)), method) | |
else: |
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
# initialization | |
import logging | |
import logging.handlers | |
LOGGING_SYSLOG_ADDRESS = '/tmp/log' | |
LOGGING_FORMATTER = logging.Formatter('%(asctime)s %(levelname)s %(name)s %(message)s') | |
LOGGING_LEVEL = logging.INFO | |
LOGGING_LOGGER_WEB = 'artifact3028' | |
logger_web = logging.getLogger(LOGGING_LOGGER_WEB) |
NewerOlder