This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid | |
import psycopg2 | |
from secret import REDSHIFT_CREDS | |
from secret import AWS_ACCESS_KEY, AWS_SECRET_KEY | |
def get_primary_keys(tablename, db): | |
c = db.cursor() | |
sql = "select indexdef from pg_indexes where tablename = '%s';" % tablename | |
c.execute(sql) | |
result = c.fetchall()[0][0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env python | |
# -*- coding: utf-8 -*- | |
import argparse | |
import gzip | |
import json | |
import os | |
from boto.s3.connection import S3Connection | |
from boto.s3.key import Key | |
import cStringIO |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
redshift=> SELECT DISTINCT column1 from test_table; | |
column1 | |
--------- | |
1 | |
3 | |
1 | |
2 | |
(4 rows) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import uuid | |
import psycopg2 | |
from secret import REDSHIFT_CREDS | |
from secret import AWS_ACCESS_KEY, AWS_SECRET_KEY | |
def get_primary_keys(tablename, db): | |
c = db.cursor() | |
sql = "select indexdef from pg_indexes where tablename = '%s';" % tablename | |
c.execute(sql) | |
result = c.fetchall()[0][0] |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/usr/bin/env bash | |
# This script clones all repos in a GitHub org | |
# It requires the GH CLI: https://cli.github.com | |
# It can be re-run to collect new repos and pull the latest changes | |
set -euo pipefail | |
USAGE="Usage: gh-clone-org <user|org>" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
USAGE="Usage: bulk-clone <mine|user|org> [name]" | |
[[ $# -eq 0 ]] && echo >&2 "missing arguments: ${USAGE}" && exit 1 | |
# set protocol to ssh | |
gh config set git_protocol ssh -h github.com | |
# check if gh cli is installed |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
DO $$ | |
DECLARE | |
r RECORD; | |
BEGIN | |
FOR r IN | |
( | |
SELECT table_name | |
FROM information_schema.tables | |
WHERE table_schema=current_schema() | |
) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#!/bin/bash | |
if [ -z "$1" ]; then | |
echo "waiting for the following arguments: username + max-page-number" | |
exit 1 | |
else | |
name=$1 | |
fi | |
if [ -z "$2" ]; then |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import requests | |
import json | |
class DiaryDB: | |
def __init__(self, name, api_key, url): | |
self.api_key = api_key | |
self.name = name | |
self.url = url |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sqlite3 | |
# A Self Contained Database Wrapper written for Admiral | |
class Database: | |
# Note: Primary Key ID's in SQLite start autoincrementing at 1 | |
def __init__(self, name=None): | |
self.conn = None |
NewerOlder