Skip to content

Instantly share code, notes, and snippets.

@rgreenjr
rgreenjr / postgres_queries_and_commands.sql
Last active July 25, 2024 08:07
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%'
@kevin-smets
kevin-smets / iterm2-solarized.md
Last active July 23, 2024 04:22
iTerm2 + Oh My Zsh + Solarized color scheme + Source Code Pro Powerline + Font Awesome + [Powerlevel10k] - (macOS)

Default

Default

Powerlevel10k

Powerlevel10k

# Rootユーザに変更
sudo su -
# virtualenvインストール
pip install -U virtualenv
virtualenv /www/sentry/
source /www/sentry/bin/activate
@analogue
analogue / stracetree.py
Created June 23, 2015 18:11
strace an existing process tree
#!/usr/bin/python
# strace an existing process tree. `strace -f` only follows newly spawned
# processes which is not always what you want.
import os
import sys
import subprocess
# /proc/[pid]/task/* == directory of threads including self
# /proc/[pid]/task/[pid]/children == child processes
@raineorshine
raineorshine / human-readable-hash-comparisons.md
Last active July 21, 2024 20:31
An aesthetic comparison of a few human-readable hashing functions.

An Aesthetic Comparison of Human-Readable
Hashing Functions

The following compares the output of several creative hash functions designed for human readability.

sha1's are merely used as arbitrary, longer, distributed input values.

input 1 word output 2 word output 3 word output
@metacollin
metacollin / Polycarbonate.ini
Last active May 6, 2024 10:17
Slic3r settings for high quality, low-warp, high-strength printing of polycarbonate without an enclosure on a Prusa i3 MK2S
# generated by Slic3r 1.37.2-prusa3d on Thu Dec 7 09:48:20 2017
# Figured out by trial and error engineer metacollin
# Released as public domain.
# USE GLUESTICK FOR PRINT BED ADHESION
avoid_crossing_perimeters = 0
bed_shape = 0x0,250x0,250x210,0x210
bed_temperature = 110
before_layer_gcode = ;BEFORE_LAYER_CHANGE\n;[layer_z]\n\n
bottom_solid_layers = 8
bridge_acceleration = 1000
@ricmello
ricmello / http.service.ts
Created November 24, 2019 17:06
Http service that allows disable interceptors or pass misc data to Angular httpClient
import {
Inject,
Injectable,
InjectionToken,
Injector,
Optional
} from '@angular/core';
import {
HttpClient,
HttpEvent,
@dvanders
dvanders / btrfs-smr-balance.py
Last active May 5, 2020 15:08
btrfs-smr-balance.py
#!/usr/bin/env python3
# The goal of this is to gradually balance a btrfs filesystem which contains DM-SMR drives.
# Such drive are described in detail at https://www.usenix.org/node/188434
# A normal drive should be able to balance a single 1GB chunk in under 30s.
# Such a stripe would normally be written directly to the shingled blocks, but in the case
# it was cached, it would take roughly 100s to clean.
# So our heuristic here is: