Skip to content

Instantly share code, notes, and snippets.

View okiwan's full-sized avatar

Sergio Ocaña Gálvez okiwan

View GitHub Profile
@okiwan
okiwan / postgres_queries_and_commands.sql
Last active April 6, 2022 07:03 — 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%'
@okiwan
okiwan / remove_pritunl_osx.sh
Created August 23, 2020 17:42 — forked from opragel/remove_pritunl_osx.sh
remove_pritunl_osx.sh
#!/bin/bash
# Disclaimer: it's your funeral
APP_PROCESS_NAME="Pritunl"
DAEMON_PATHS=( "/Library/LaunchAgents/com.pritunl.client.plist" \
"/Library/LaunchDaemons/com.pritunl.service.plist" \
"/Library/LaunchDaemons/net.sf.tuntaposx.tap.plist" \
"/Library/LaunchDaemons/net.sf.tuntaposx.tun.plist" )
@okiwan
okiwan / clean_code.md
Created March 3, 2019 17:15 — forked from jeremyjackson89/clean_code.md
Summary of 'Clean code' by Robert C. Martin

Code is clean if it can be understood easily – by everyone on the team. Clean code can be read and enhanced by a developer other than its original author. With understandability comes readability, changeability, extensibility and maintainability.


General rules

  1. Follow standard conventions.
  2. Keep it simple stupid. Simpler is always better. Reduce complexity as much as possible.
  3. Boy scout rule. Leave the campground cleaner than you found it.
  4. Always find root cause. Always look for the root cause of a problem.

Design rules

#!/bin/bash
#
# Tomcat 8 start/stop/status init.d script
# Initially forked from: https://gist.github.com/valotas/1000094
# @author: Miglen Evlogiev <[email protected]>
#
# Release updates:
# Updated method for gathering pid of the current proccess
# Added usage of CATALINA_BASE
# Added coloring and additional status
@okiwan
okiwan / pglag.sh
Created November 13, 2013 07:50 — forked from dansimau/pglag.sh
#!/bin/bash
#
# Show replication lag for one or more postgresql slaves in streaming replication.
#
# [email protected]
# 2012-01-09
#
psql="which psql"
psql_extra_opts=""