Skip to content

Instantly share code, notes, and snippets.

View benjamin658's full-sized avatar
🎯
Focusing

Ben Who benjamin658

🎯
Focusing
View GitHub Profile
@benjamin658
benjamin658 / docker-compose.yml
Last active November 1, 2017 08:37
Setting up a consul cluster and registrator on Rancher.
version: '2'
services:
consul-lb:
image: rancher/lb-service-haproxy:v0.7.8
ports:
- 8400
- 8500
- 8600
expose:
@benjamin658
benjamin658 / gen-random.sh
Last active October 3, 2019 07:45
Generate random string by openssl
openssl rand 60 | openssl base64 -A
@benjamin658
benjamin658 / kill-slow-query.sql
Created November 5, 2020 06:10
PostgreSQL find out slow query and kill it
/* Find out the slow query */
SELECT pid, query FROM pg_stat_activity WHERE state = 'active';
/* Kill the slow query by pid */
select pg_terminate_backend(pid)
from pg_stat_activity
where pid = $pid;
@benjamin658
benjamin658 / promise-in-sequence.js
Last active December 21, 2020 09:28
Promise in sequence
const promises = []; // an array of promises.
promises.reduce((prev, next) => prev.then(next), Promise.resolve());
@benjamin658
benjamin658 / view-lock.sql
Last active December 24, 2021 09:37
Postgres Viewing locks with table names and queries
select
relname as relation_name,
query,
pg_locks.*
from pg_locks
join pg_class on pg_locks.relation = pg_class.oid
join pg_stat_activity on pg_locks.pid = pg_stat_activity.pid