Skip to content

Instantly share code, notes, and snippets.

@Demacr
Demacr / postgresql.md
Created February 16, 2020 14:57
Postgresql accept 0 or 1 as boolean

Digging in to the dark magic of postgresql, i discovered that the integer to boolean cast can be changed from an exlicit to an automatic coersion. Then changed back when done...

update pg_cast set castcontext='a' where casttarget = 'boolean'::regtype;

Then load with pg_dump.

When done, set back the casting to its default with...

sudo killall -HUP mDNSResponder; sudo killall mDNSResponderHelper; sudo dscacheutil -flushcache
@Demacr
Demacr / template.j2
Created April 15, 2020 18:59
Jinja header
#jinja2: trim_blocks: True, lstrip_blocks: True
@Demacr
Demacr / ssh.sh
Last active May 14, 2020 15:04
SSHoSSH proxy
ssh $USERNAME@$DESTINATION -o StrictHostKeyChecking=no -o ProxyCommand="ssh -W %h:%p -q $USERNAME@$PROXY_SSH_SERVER"
@Demacr
Demacr / unblock_elastic.sh
Created May 17, 2020 12:35
Unblock elasticsearch read only allow delete
curl -XPUT -H "Content-Type: application/json" http://localhost:9200/_all/_settings -d '{"index.blocks.read_only_allow_delete": null}'
brew install nmap
sudo ncat --sh-exec "ncat 10.211.55.5 80" -l 1000 --keep-open
@Demacr
Demacr / etc iptables rules.v4
Created June 28, 2020 12:01
Ubuntu conntrack blocks DNS queries, but has ESTABLISHED and RELATED
# Add to raw this block
#
*raw
:PREROUTING ACCEPT [0:0]
:OUTPUT ACCEPT [0:0]
-A PREROUTING -p udp -m udp --dport 53 -j CT --notrack
-A PREROUTING -p udp -m udp --sport 53 -j CT --notrack
-A OUTPUT -p udp -m udp --dport 53 -j CT --notrack
-A OUTPUT -p udp -m udp --sport 53 -j CT --notrack
COMMIT
@Demacr
Demacr / docker-compose.yml
Created June 28, 2020 20:09
Traefik 1.7 basic auth
version: '3'
services:
myservice:
image: myimage
labels:
- "traefik.frontend.rule=Host:mydomain.com"
- ...
- "traefik.frontend.auth.basic.users=<USER-PASSWORD-OUTPUT>"
@Demacr
Demacr / nginx.conf
Created July 22, 2020 17:28
Rabbitmq nginx %2F workaround
location ~* /rabbitmq/api/ {
if ($request_uri ~* "/rabbitmq/(.*)") {
proxy_pass http://localhost:15672/$1;
}