Skip to content

Instantly share code, notes, and snippets.

@joaocc
joaocc / .mateuszwenus--save_restore_dependencies.sql
Last active October 25, 2023 07:28 — forked from mateuszwenus/save_restore_dependencies.sql
PostgreSQL: How to handle table and view dependencies
Forked from https://gist.github.com/mateuszwenus/
@joaocc
joaocc / README.md
Created March 15, 2023 21:25 — forked from forivall/README.md
git-credential-manager reaper script

Simple background script to kill git-credential-manager when it hits the 100% cpu bug

@joaocc
joaocc / UUID_v7_for_Postgres.sql
Created February 7, 2023 18:18 — forked from kjmph/A_UUID_v7_for_Postgres.sql
Postgres PL/pgSQL function for UUID v7 and a bonus custom UUID v8 to support microsecond precision as well. Read more here: https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
-- Based off IETF draft, https://datatracker.ietf.org/doc/draft-peabody-dispatch-new-uuid-format/
create or replace function uuid_generate_v7()
returns uuid
as $$
declare
unix_ts_ms bytea;
uuid_bytes bytea;
begin
unix_ts_ms = substring(int8send(floor(extract(epoch from clock_timestamp()) * 1000)::bigint) from 3);
@joaocc
joaocc / check_multi_namespaces.sh
Last active March 27, 2022 11:03 — forked from lisawolderiksen/secrets_without_certificates.sh
Script to detect "orphaned" TLS secrets when Cert manager (cainjector) complains about "unable to fetch certificate that owns the secret", because deleting a Certificate will not (default) delete the Secret. (Ref. https://cert-manager.io/docs/usage/certificate/#cleaning-up-secrets-when-certificates-are-deleted)
#!/usr/bin/env bash
set -eo pipefail
set -x
while [ "$1" != "" ]
do
bash secrets_without_certificates.sh -n "$1"
shift
done
@joaocc
joaocc / inf_refresh_recursive.sql
Created March 4, 2019 00:45 — forked from bitdivine/inf_refresh_recursive.sql
Refresh postgres materialized views recursively
-- Refresh materialized views recursively
-- DEPENDS:
-- List the tables that a view depends on.
-- Thanks to Dave: http://stackoverflow.com/questions/4229468/getting-a-list-of-tables-that-a-view-table-depends-on-in-postgresql
create or replace function inf_view_dependencies(v text)
returns table (kind text, name text) as $$
SELECT cl_d.relkind::text as kind
, cl_d.relname::text AS name
FROM pg_rewrite AS r
@joaocc
joaocc / fulldump.sh
Created March 4, 2019 00:44 — forked from marcolino/fulldump.sh
Postgres full dump script
#!/bin/bash
# $Id: fulldump.sh,v 1.4 2013/10/31 14:25:36 postgres Exp postgres $
# $Source: /var/lib/postgresql/8.2/RCS/fulldump.sh,v $
# $Log: fulldump.sh,v $
#
# Revision 1.4 2013/10/31 14:25:36 postgres
# Removed pg_dump '-D' option, added $RETVAL
# default value for the initial case - MS.
#
# Revision 1.3 2007/09/28 13:29:07 postgres
#!/bin/bash
set -o nounset
##########################################
# Defaults
##########################################
: ${recipient:=}
: ${host:=localhost}
: ${port:=5432}
: ${databases:=}
@joaocc
joaocc / .gitattributes
Created November 24, 2017 15:47 — forked from nemotoo/.gitattributes
.gitattributes for Unity3D with git-lfs
## Unity ##
*.cs diff=csharp text
*.cginc text
*.shader text
*.mat merge=unityyamlmerge eol=lf
*.anim merge=unityyamlmerge eol=lf
*.unity merge=unityyamlmerge eol=lf
*.prefab merge=unityyamlmerge eol=lf
#!/bin/bash
if [ "$(id -u)" != "0" ]; then
echo "This script must be run as root" 1>&2
exit 1
fi
cat <<MAXFILES > /Library/LaunchDaemons/limit.maxfiles.plist
<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
---
# ^^^ YAML documents must begin with the document separator "---"
#
#### Example docblock, I like to put a descriptive comment at the top of my
#### playbooks.
#
# Overview: Playbook to bootstrap a new host for configuration management.
# Applies to: production
# Description:
# Ensures that a host is configured for management with Ansible.