Skip to content

Instantly share code, notes, and snippets.

@rmwpl
rmwpl / gist:18082c6a8c5485e4b1ae2396aa1d547e
Created August 16, 2016 13:09
PostgreSQL countdown to a specified date, displayed in weeks, days, hours, minutes and seconds
with seconds as (
select extract(epoch from ('2016-09-16 10:15:00'::timestamp - now()::timestamp)) as value
), minutes as (
select value/60 as value from seconds
), hours as (
select value/60 as value from minutes
), days as (
select value/24 as value from hours
), weeks as (
select value/7 as value from days
TOKEN="`curl -s -u <username>:<password> 'https://auth.docker.io/token?service=registry.docker.io&scope=repository:monterail/solarcapture-server:pull' | jq -r .token`"
DOWNSTREAM_DIGEST=$(curl -v -H "Accept: application/vnd.docker.distribution.manifest.v2+json" -H "Authorization: Bearer ${TOKEN}" https://index.docker.io/v2/monterail/solarcapture-server/manifests/latest 2>&1 | grep 'Docker-Content-Digest' | cut -d' ' -f3)
docker inspect localhost:5000/server/server:latest | jq -r ".[].RepoDigests | .[] | endswith(\"${REMOTE_DIGEST}\")"
@rmwpl
rmwpl / tf-prompt.sh
Created January 11, 2018 16:07
Terraform bash prompt, to be used with bash-git-prompt
#!/bin/bash
__terraform_ps1()
{
# get current workspace
WORKSPACE=$(terraform workspace show)
if $(pwd | /bin/grep -q 'terraform'); then
if [ -n "$WORKSPACE" ]; then
echo -ne "${White}(terraform: "