Skip to content

Instantly share code, notes, and snippets.

@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
@joaocc
joaocc / run-gitlab-as-dind.multi.sh
Last active November 15, 2017 23:08
Gitlab-runner as dind
#!/usr/bin/env bash
set -e
set -o pipefail
THIS_DIR="$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )"
T_STAMP=$(date -u +"%Y%m%d_%H%M%SZ")
set -x
# docker rm -f gitlab-runner-dind gitlab-dind-host
@joaocc
joaocc / mk-zfs.external-drives.sh
Last active November 27, 2016 03:48
mac osx zfs ops
#!/usr/bin/env bash
set -e
set -x
MY_DIR=$( cd "$( dirname "${BASH_SOURCE[0]}" )" && pwd )
pushd "${MY_DIR}"
MY_SDXC=/var/run/disk/by-serial/SD_Card_Reader-000000000000
diskutil info $MY_SDXC
@joaocc
joaocc / ConfigureRemotingForAnsible.ps1
Last active November 10, 2016 11:02
Windows-Easy-Bootstrapping (2016-11)
# Configure a Windows host for remote management with Ansible
# -----------------------------------------------------------
#
# This script checks the current WinRM/PSRemoting configuration and makes the
# necessary changes to allow Ansible to connect, authenticate and execute
# PowerShell commands.
#
# Set $VerbosePreference = "Continue" before running the script in order to
# see the output messages.
# Set $SkipNetworkProfileCheck to skip the network profile check. Without
@joaocc
joaocc / gist:137f6b44ceefb864e0c09b2dcaa28a5f
Created September 10, 2016 11:02
Terraform panic on "terraform state show"
panic: runtime error: invalid memory address or nil pointer dereference
[signal 0xb code=0x1 addr=0x30 pc=0x4bc772]
goroutine 1 [running]:
panic(0x33b5860, 0xc820012090)
/opt/go/src/runtime/panic.go:481 +0x3e6
github.com/hashicorp/terraform/command.(*StateShowCommand).Run(0xc8201ad200, 0xc82000a1c0, 0x0, 0x0, 0xc8202227d0)
/opt/gopath/src/github.com/hashicorp/terraform/command/state_show.go:53 +0x702
github.com/hashicorp/terraform/vendor/github.com/mitchellh/cli.(*CLI).Run(0xc8201ca900, 0xc8202e0360, 0x0, 0x0)
/opt/gopath/src/github.com/hashicorp/terraform/vendor/github.com/mitchellh/cli/cli.go:153 +0x56e
#!/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">
@joaocc
joaocc / win2012r2--hyperv.boxst
Last active November 6, 2016 09:40
Deploy--boxstarter--win2012r2
#
# v1.1.5 2015-08-28 HighSkillz Ltd
#
# START http://goo.gl/bVJNzp
# START http://boxstarter.org/package/url?https://bitbucket.org/api/2.0/snippets/highskillz-deploy/KAMLg/files/win2012r2--hyperv.boxst
#
# START http://goo.gl/yVuh3L
# START http://boxstarter.org/package/url?https://gist.githubusercontent.com/joaocc/f61f9a8e59a5575220ce/raw/win2012r2--hyperv.boxst
# ================================================================