Skip to content

Instantly share code, notes, and snippets.

@nk23x
nk23x / haproxy.cfg
Created July 15, 2022 23:08 — forked from wiredmax/haproxy.cfg
Sample HA-Proxy configuration for load balancing SockJS running on Node.JS servers.
global
maxconn 10000 # Total Max Connections. This is dependent on ulimit
nbproc 2
defaults
mode http
option redispatch
maxconn 2000
contimeout 5000
clitimeout 50000
@nk23x
nk23x / format_java_exception.sh
Last active January 26, 2022 12:17
make java exception messages readable
#!/bin/bash
##
## patterns copied from
## https://raw.githubusercontent.com/staxmanade/ExceptionMessageBeautifier/master/src/ExceptionMessageBeautifier.js
## see also:
## https://superuser.com/a/747905
##
PERL_CMD="perl -pe 's/ at/\\r\\n at/g; s/ ---> /\\r\\n ---> /g; s/\) at /\\r\\n at /g; s/ --- End of inner exception stack trace ---/\\r\\n --- End of inner exception stack trace ---/g;'"
@nk23x
nk23x / postgres-cheatsheet.md
Last active December 1, 2021 11:50 — forked from Kartones/postgres-cheatsheet.md
PostgreSQL command line cheatsheet

PSQL

Magic words:

psql -U postgres

Some interesting flags (to see all, use -h or --help depending on your psql version):

  • -E: will describe the underlaying queries of the \ commands (cool for learning!)
  • -l: psql will list all databases and then exit (useful if the user you connect with doesn't has a default database, like at AWS RDS)
@nk23x
nk23x / ncatproxy.sh
Created February 25, 2021 10:45 — forked from calaveraInfo/ncatproxy.sh
How to create extremely simple (http) reverse proxy using netcat (nmap flavor) and a named pipe
mkfifo reply
ncat -kl 8765 < reply | ncat 127.0.0.1 4567 > reply # listens on port 8765 and redirects to localhost:4567. Runs until C-c.
rm reply # cleanup after end
@nk23x
nk23x / openshift-cheatsheet.md
Created February 22, 2021 17:02 — forked from rafaeltuelho/openshift-cheatsheet.md
My Openshift Cheatsheet

My Openshift Cheatsheet

Openshift build secrets for cloning git repos using SSH Keys

  • To create ssh secret:
oc create secret generic sshsecret \
    --from-file=ssh-privatekey=$HOME/.ssh/id_rsa
@nk23x
nk23x / postgres_queries_and_commands.sql
Created February 22, 2021 13: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%'
@nk23x
nk23x / read-access.sql
Created January 29, 2021 08:50 — forked from oinopion/read-access.sql
How to create read only user in PostgreSQL
-- Create a group
CREATE ROLE readaccess;
-- Grant access to existing tables
GRANT USAGE ON SCHEMA public TO readaccess;
GRANT SELECT ON ALL TABLES IN SCHEMA public TO readaccess;
-- Grant access to future tables
ALTER DEFAULT PRIVILEGES IN SCHEMA public GRANT SELECT ON TABLES TO readaccess;
@nk23x
nk23x / ca.md
Created September 14, 2020 11:51 — forked from soarez/ca.md
How to setup your own CA with OpenSSL

How to setup your own CA with OpenSSL

For educational reasons I've decided to create my own CA. Here is what I learned.

First things first

Lets get some context first.

@nk23x
nk23x / make_sha1_gravatar.txt
Last active January 8, 2021 10:07
gravatar: avatar sha1
## https://www.gravatar.com/avatar/[sha1 hash]?d=retro
## if needed use f.e. https://sha1generator.de/ to create sha1 hash
RewriteRule ^shavatar/(.*)$ https://www.gravatar.com/avatar/$1?d=retro
@nk23x
nk23x / curl.md
Created April 15, 2020 11:24 — forked from subfuzion/curl.md
curl POST examples

Common Options

-#, --progress-bar Make curl display a simple progress bar instead of the more informational standard meter.

-b, --cookie <name=data> Supply cookie with request. If no =, then specifies the cookie file to use (see -c).

-c, --cookie-jar <file name> File to save response cookies to.