Skip to content

Instantly share code, notes, and snippets.

View lukecampbell's full-sized avatar

Luke Campbell lukecampbell

View GitHub Profile
@lukecampbell
lukecampbell / ingest_postgresq.py
Created January 5, 2015 14:06
A standalone script ot ingest TSV files into postgres.
#!/usr/bin/env python
import argparse
import psycopg2
import psycopg2.extras
import csv
from getpass import getpass, getuser
def main(args):
'''
Inserts a TSV into table in postgresql
#!/bin/sh
BOOT2DOCKER_CERTS_DIR=/var/lib/boot2docker/certs
CERTS_DIR=/etc/ssl/certs
CAFILE=${CERTS_DIR}/ca-certificates.crt
for cert in $(/bin/ls -1 ${BOOT2DOCKER_CERTS_DIR}); do
SRC_CERT_FILE=${BOOT2DOCKER_CERTS_DIR}/${cert}
CERT_FILE=${CERTS_DIR}/${cert}
HASH_FILE=${CERTS_DIR}/$(/usr/local/bin/openssl x509 -noout -hash -in ${SRC_CERT_FILE} 2>/dev/null)
@lukecampbell
lukecampbell / glider_days.py
Last active August 29, 2015 14:15
Glider Days
#!/usr/bin/env python
'''
glider_days.py
Determines the glider days for a thredds catalog
'''
from dateutil.parser import parse
from datetime import datetime
from thredds_crawler.crawl import Crawl
@lukecampbell
lukecampbell / qcflags.sql
Created October 12, 2015 12:55
CBIBS QC Flags
-- get_bulk_qc_flags(site_code, start_time, end_time)
SELECT
DISTINCT ON (o.measure_ts, v.actual_name, l.elevation)
o.measure_ts,
s.site_code,
v.actual_name,
u.netcdf,
l.elevation,
o.obs_value,
qc.qa_code as "Primary QC",
#!/usr/bin/env python
import sys
def main(args):
return 0
if __name__ == '__main__':
from argparse import ArgumentParser
@lukecampbell
lukecampbell / create_ca.sh
Last active May 2, 2022 09:15
Generic script to create openssl based Certificate Authority
#!/bin/bash
set -e
echo "Creating new OpenSSL Certificate Authority"
echo -n "Enter path to CA [.]: "
read ca_path
ca_path=${ca_path:-$PWD}
if [[ "$ca_path" != /* ]]; then
ca_path="$PWD/$ca_path"