Skip to content

Instantly share code, notes, and snippets.

View jessiel-hacke's full-sized avatar

Jessiel Hacke jessiel-hacke

  • Currently at Shopify
  • Raleigh, North Carolina
View GitHub Profile
#!/bin/bash
set -euo pipefail
# GIT_DIR isn't set for all hook events. Read this as GIT_DIR ||=
export GIT_DIR="${GIT_DIR-$(dirname "$(dirname "${BASH_SOURCE[0]}")")}"
if [[ -p /dev/fd/0 ]]; then # Check if STDIN is a pipe (i.e. we're getting input from Git)
INPUT=$(</dev/stdin)
fi
while read -r hook; do
if [[ -z "${INPUT+x}" ]]; then
"${hook}" "$@"
##############################
## POSTGRESQL BACKUP CONFIG ##
##############################
# Optional system user to run backups as. If the user the script is running as doesn't match this
# the script terminates. Leave blank to skip check.
BACKUP_USER=postgres
# Optional hostname to adhere to pg_hba policies. Will default to "localhost" if none specified.
HOSTNAME=localhost
@jessiel-hacke
jessiel-hacke / backup.config
Last active October 22, 2019 19:46
PG Backup
##############################
## POSTGRESQL BACKUP CONFIG ##
##############################
# Optional system user to run backups as. If the user the script is running as doesn't match this
# the script terminates. Leave blank to skip check.
BACKUP_USER=postgres
# Optional hostname to adhere to pg_hba policies. Will default to "localhost" if none specified.
HOSTNAME=localhost
require 'date'
require 'set'
def normalize_requests(requests)
start_work = DateTime.strptime('8', '%H').to_time
end_work = DateTime.strptime('17', '%H').to_time
requests = requests.map do |c|
c = c.split(',')
tp = [DateTime.strptime(c.first, '%H:%M%P').to_time, c.last.strip.to_i]
@jessiel-hacke
jessiel-hacke / flatten_alternatives
Created December 20, 2016 13:10
Benchmark flatten alternatives
# methods defined on main:Object
def iron(array)
a = []
array.each do |element|
if element.is_a? Array
a.push(*iron(element))
else
a.append(element)
end
end