Skip to content

Instantly share code, notes, and snippets.

@andreyp
andreyp / postgres_queries_and_commands.sql
Created December 26, 2018 08:05 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@andreyp
andreyp / fix-sequences-all-postgresql
Created April 28, 2018 13:29 — forked from mdamaceno/fix-sequences-all-postgresql
Fix all sequences in Postgresql
SELECT
'SELECT SETVAL(' ||quote_literal(S.relname)||
', MAX(' ||quote_ident(C.attname)||
') ) FROM ' ||quote_ident(T.relname)|| ';'
FROM
pg_class AS S
,pg_depend AS D
,pg_class AS T
,pg_attribute AS C
WHERE
@andreyp
andreyp / tmux.md
Last active August 29, 2015 14:21 — forked from andreyvit/tmux.md

tmux cheat sheet

(C-x means ctrl+x, M-x means alt+x)

Prefix key

The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:

remap prefix to Control + a

@andreyp
andreyp / fail.js
Created September 3, 2014 11:30
Как же так получается???
var a = '0';
var b = '1';
a == true
//false
a == false
//true
b == true
//true
b == false
//false
#!/usr/bin/env python
#
# Vkontatke OAuth 2.0 wrapper
# Copyright 2011, Adil Khashtamov [[email protected]]
# http://khashtamov.kz
#
#
import logging
@andreyp
andreyp / __init__.py
Created November 2, 2013 06:08
/System/Library/Frameworks/Python.framework/Versions/2.7/Extras/lib/python/PyObjC/Foundation/
'''
Python mapping for the Foundation framework.
This module does not contain docstrings for the wrapped code, check Apple's
documentation for details on how to use these functions and classes.
'''
import objc as _objc
#import ApplicationServices
from CoreFoundation import *
#! /bin/sh
### BEGIN INIT INFO
# Provides: znc
# Default-Start: 2 3 4 5
# Default-Stop: 0 1 6
# Short-Description: znc initscript
# Description: This is the init-Script for znc.
### END INIT INFO
# Author: Henner M. Kruse
class BaseRequestHandler(tornado.web.RequestHandler):
"""Base class for all SimpleGeo request handlers."""
def _handle_request_exception(self, e):
status_code = getattr(e, 'status_code', 500)
self.set_status(status_code)
error = {
'code' : status_code,
'message' : str(e)
[easy_install]
index_url = https://pypi.crate.io/simple/