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
# Инфа по коннектам | |
select max_conn,used,res_for_super,max_conn-used-res_for_super res_for_normal | |
from | |
(select count(*) used from pg_stat_activity) t1, | |
(select setting::int res_for_super from pg_settings where name=$$superuser_reserved_connections$$) t2, | |
(select setting::int max_conn from pg_settings where name=$$max_connections$$) t3 | |
# Текущие запросы | |
select pid, usename, client_addr,query_start, state_change, state, query from pg_stat_activity order by query_start; |
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
" включить подсветку синтаксиса | |
syntax on | |
setf dosini | |
" размер табуляции | |
set tabstop=2 | |
set shiftwidth=2 | |
set smarttab | |
set et |
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
# Delete old local branches (no longer on remote) | |
git fetch -p && \ | |
for branch in `git branch -vv | gawk '{print $1,$4}' | grep -e ' исчез' -e ' gone]' | awk '{print $1}'`; do | |
git branch -D $branch; | |
done |
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 time | |
import tornado | |
import tornadis | |
import redis | |
import asyncio | |
import asyncio_redis | |
N = 50000 | |
sync_client = redis.Redis('localhost') |
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
#!/bin/bash | |
# MacOS: | |
# brew install exiftool | |
# Debian/Ubuntu/RpP: | |
# sudo apt install libimage-exiftool-perl | |
show_help() { | |
cat << EOF | |
Usage: $(basename "$0") [OPTIONS] [PATH] |
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
""" | |
Place the script into your home folder and set PYTHONSTARTUP | |
variable like this: | |
export PYTHONSTARTUP=$HOME/.python-autocomplete.py | |
""" | |
import os | |
import sys | |
import readline |
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
# If you use virtualenvwrapper you might want to | |
# use this script for automatic change environment | |
# with 'cd' command. | |
# | |
# How to use: | |
# 1. Add this lines to ~/.bashrc | |
# 2. Place .env file in project folder. | |
# 3. And write environment name into the file. | |
# | |
# Use it at your own risk ;-) |
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 datetime import datetime, date | |
from sqlalchemy.orm.query import Query | |
def render_query(statement, bind=None): | |
""" | |
Generate an SQL expression string with bound parameters rendered inline | |
for the given SQLAlchemy statement. | |
This is some improvement variant of this code: | |
https://gist.github.com/gsakkis/4572159 |