Skip to content

Instantly share code, notes, and snippets.

View lukecampbell's full-sized avatar

Luke Campbell lukecampbell

View GitHub Profile
@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"
#!/usr/bin/env python
import sys
def main(args):
return 0
if __name__ == '__main__':
from argparse import ArgumentParser
@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",
@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
#!/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 / 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
@tkafka
tkafka / LICENSE.txt
Last active May 17, 2024 02:08
Drop-in replacement for ReactCSSTransitionGroup that uses velocity.js instead of CSS transforms. Add your own transitions to `transitions` hash.
The MIT License (MIT)
Copyright (c) 2014 Tomas Kafka
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
#!/usr/bin/env python
'''
@author Luke Campbell
@file ion/util/h5_graph.py
'''
from struct import unpack
from StringIO import StringIO
import os
@lelandbatey
lelandbatey / whiteboardCleaner.md
Last active June 2, 2024 11:23
Whiteboard Picture Cleaner - Shell one-liner/script to clean up and beautify photos of whiteboards!

Description

This simple script will take a picture of a whiteboard and use parts of the ImageMagick library with sane defaults to clean it up tremendously.

The script is here:

#!/bin/bash
convert "$1" -morphology Convolve DoG:15,100,0 -negate -normalize -blur 0x1 -channel RBG -level 60%,91%,0.1 "$2"

Results

@cerivera
cerivera / foreach vs for loop
Last active April 6, 2017 14:14
Underscore.js foreach vs native for loop speed test
// Build 100000 alphabet dictionaries
var dict = {};
for (var i = 0; i < 100000; i++) {
dict[i] = {};
for (var c = 65; c < 65+26; c++) {
dict[i][String.fromCharCode(c)] = c;
}
}
// Loop through parent and child dictionaries in native JS