Skip to content

Instantly share code, notes, and snippets.

SELECT
sum(heap_blks_read) as heap_read,
sum(heap_blks_hit) as heap_hit,
sum(heap_blks_hit) / (sum(heap_blks_hit) + sum(heap_blks_read)) as ratio
FROM
pg_statio_user_tables;
@jarrekk
jarrekk / postgres_queries_and_commands.sql
Created December 26, 2018 08:22 — 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%'
@jarrekk
jarrekk / tmux.md
Created January 19, 2018 04:30 — forked from andreyvit/tmux.md
tmux cheatsheet

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

@jarrekk
jarrekk / git-clearHistory
Created September 27, 2017 08:46 — forked from stephenhardy/git-clearHistory
Steps to clear out the history of a git/github repository
-- Remove the history from
rm -rf .git
-- recreate the repos from the current content only
git init
git add .
git commit -m "Initial commit"
-- push to the github remote repos ensuring you overwrite history
git remote add origin [email protected]:<YOUR ACCOUNT>/<YOUR REPOS>.git
@jarrekk
jarrekk / Ansible-Vault how-to.md
Created July 6, 2017 03:29 — forked from tristanfisher/Ansible-Vault how-to.md
A short tutorial on how to use Vault in your Ansible workflow. Ansible-vault allows you to more safely store sensitive information in a source code repository or on disk.

##Working with ansible-vault

I've been using a lot of Ansible lately and while almost everything has been great, finding a clean way to implement ansible-vault wasn't immediately apparent.

What I decided on was the following: put your secret information into a vars file, reference that vars file from your task, and encrypt the whole vars file using ansible-vault encrypt.

Let's use an example: You're writing an Ansible role and want to encrypt the spoiler for the movie Aliens.

@jarrekk
jarrekk / gflist.py
Last active July 6, 2017 07:55
Add/delete/query domain in shadowsocks/gfwlist.js
#!/usr/bin/env python
from __future__ import print_function
import getopt
import sys
import os
filePath = "/Users/jack/Dropbox/Sync/ShadowsocksX/gfwlist.js"
try:
opts, args = getopt.getopt(sys.argv[1:], "a:d:q:h:", ["help=", "add=", "delete=", "query="])
@jarrekk
jarrekk / jsonp-in-flask.py
Last active June 22, 2020 13:41 — forked from farazdagi/jsonp-in-flask.py
JSONP in Flask
from functools import wraps
from flask import request, current_app, jsonify, Flask
app = Flask(__name__)
def jsonp(f):
"""Wraps JSONified output for JSONP"""
@wraps(f)