Skip to content

Instantly share code, notes, and snippets.

View tym-xqo's full-sized avatar
🖤

Thomas Yager-Madden tym-xqo

🖤
View GitHub Profile
@tym-xqo
tym-xqo / namer.py
Last active October 5, 2015 12:14
arbitrary two-word name generator
#!/usr/bin/env python3
#coding: utf-8
import random
from AppKit import NSPasteboard, NSArray
def namer():
adjectives = ("aliased",
"angelic",
"anonymous",
@tym-xqo
tym-xqo / k8s_deploy_oao-postgres.sh
Last active December 23, 2015 22:16
(Re)deploy postgres at GCE with kubernetes
#!/bin/bash
git clone [email protected]:OAODEV/k8s-resources.git
kubectl replace --force -f k8s-resources/warehouse/postgres.yaml
@tym-xqo
tym-xqo / deploy_oao-postgres.sh
Last active October 13, 2016 20:08
Running oao-postgres and dbadmin at Rackspace
#!/bin/bash
gcloud docker -a
docker pull us.gcr.io/lexical-cider-93918/oao-postgres:_build.72c78d4
docker run -id --name=oao-postgres-data us.gcr.io/lexical-cider-93918/oao-postgres:_build.72c78d4 tail -F /dev/null
sleep 20
docker run -d --name=oao-postgres-service --volumes-from=oao-postgres-data us.gcr.io/lexical-cider-93918/oao-postgres:_build.72c78d4
docker pull us.gcr.io/lexical-cider-93918/dbadmin:_build.f00437d
docker run -id --name=dbadmin-data us.gcr.io/lexical-cider-93918/dbadmin:_build.f00437d script tail -F /dev/null
sleep 20
docker run -d --name=dbadmin-service --volumes-from=dbadmin-data --link oao-postgres-service:postgres us.gcr.io/lexical-cider-93918/dbadmin:_build.f00437d
@tym-xqo
tym-xqo / entry.sh
Last active October 9, 2015 19:53
env file to kubernetes conversion functions
#!/bin/bash
# Use this in Dockerfile ENTRYPOINT directive to source variables from /secret/env and export to the P1 environment
if [ -f /secret/env ]; then
set -a
. /secret/env
# Below keeps this idempotent if deployed to non-k8s environment (assuming the same env file is passed via --env-file at runtime)
else
mkdir -p /secret
#!/bin/bash
# Standard `docker exec -t` doesn't create a full tty, and has no $TERM set.
# This creates problems for me sometimes (I like the `clear` command, and
# psql complains a bit if the client is not a functional terminal).
# I do the command below enough that I made this script.
# Pass it the name or ID of a running container, and Bob's your uncle.
while true;
@tym-xqo
tym-xqo / psql2json.sh
Last active June 12, 2024 07:50
Export table to json
psql -h qa.iadops.com -p 5433 -U<username> \
-c "select row_to_json(<table>) from <table>;" \
-d oao_trial -At > <table>.json
@tym-xqo
tym-xqo / forecast.py
Last active August 29, 2015 14:21
Quick location and weather from Forecast.io - (I removed the location.py because of Whereami. This whole gist will be deleted eventually)
#!/usr/bin/env python
# coding: utf-8
import os
import forecastio
import json
from time import strftime
# Get an API key at https://developer.forecast.io
# and add to your local environment
@tym-xqo
tym-xqo / psql-client-install.sh
Last active August 29, 2015 14:20
Install CLI psql client
#!/bin/bash
# Add add a line for the Postgres repository
echo "deb http://apt.postgresql.org/pub/repos/apt/ trusty-pgdg main" >> /etc/apt/sources.list.d/pgdg.list
# Import the repository signing key
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | \
sudo apt-key add -
# Update the package lists, and install psql client
sudo apt-get update && apt-get install postgresql-client-9.4
@tym-xqo
tym-xqo / sha-1.sql
Last active August 29, 2015 14:19
pgsql SHA-1 function
BEGIN;
CREATE EXTENSION pgcrypto;
CREATE OR REPLACE FUNCTION sha1(text)
RETURNS character varying AS
$BODY$
BEGIN
RETURN ENCODE(public.DIGEST($1, 'sha1'), 'hex');
END;
@tym-xqo
tym-xqo / local-vs-remote-query-timing.md
Created April 22, 2015 19:01
local machine vs. qa database execution timing

Same query EXPLAIN plan run from my local machine vs. from shell on qa.iadops.com

My laptop:

oao_trial=> explain analyze insert into test values (7418880);
                                         QUERY PLAN
--------------------------------------------------------------------------------------------
 Insert on test  (cost=0.00..0.01 rows=1 width=0) (actual time=0.280..0.280 rows=0 loops=1)
   ->  Result  (cost=0.00..0.01 rows=1 width=0) (actual time=0.002..0.004 rows=1 loops=1)