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
@lukecampbell
lukecampbell / convert.py
Created December 19, 2014 19:44
convert.py
#!/usr/bin/env python
from netCDF4 import Dataset
import os
import argparse
import numpy as np
import sys
import glob
import logging
@lukecampbell
lukecampbell / watch.py
Created December 10, 2014 17:55
Script to watch for a reset file and then restart a service
import sys
import time
import argparse
import os
import shutil
import sh
import logging
from sh import sudo
from watchdog.events import FileSystemEventHandler, DirCreatedEvent
@lukecampbell
lukecampbell / shortcut.json
Created December 5, 2014 17:00
New Response
{
"CP": {
"CP02PMCI-RII01": {
"display_name": "Pioneer Central Inshore Profiler Mooring - Mooring Riser",
"instruments": {
"CP02PMCI-RII01-00-ENG000000": {
"display_name": "Engineering Data",
"streams": {}
},
"CP02PMCI-RII01-02-ADCPTG000": {
@lukecampbell
lukecampbell / example.py
Created November 18, 2014 16:26
Why I hate namespaces
import requests
from lxml import etree
def main():
url = 'https://raw.githubusercontent.com/oceanobservatories/dataset-spring/master/res/spring/ooi-ctdgv-m-glider-decode.xml'
response = requests.get(url)
if response.status_code != 200:
raise IOError("Failed to read XML document")
@lukecampbell
lukecampbell / log.txt
Last active August 29, 2015 14:08
ERDDAP Log
*** constructing EDDTableFromFiles dataset_id
Table.readFlatNc /scratch/erddap/dataset/id/dataset_id/dirTable.nc
Table.readFlatNc done. nColumns=1 nRows=1 TIME=0
1 rows in dirTable
Table.readFlatNc /scratch/erddap/dataset/id/dataset_id/fileTable.nc
Table.readFlatNc done. nColumns=55 nRows=1 TIME=12
1 rows in fileTable
1 files found in /data/data/erddap/test-output
regex=.*\.nc recursive=false time=0ms
old nBadFiles size=0 nMissing=0
parsed:
--------------------------------------------------------------------------------
{u'CE4D0268': [(u'HM',
datetime.datetime(2013, 7, 26, 16, 30, tzinfo=<UTC>),
4.94),
(u'HM',
datetime.datetime(2013, 7, 26, 17, 0, tzinfo=<UTC>),
4.41),
(u'PA',
datetime.datetime(2013, 7, 26, 16, 30, tzinfo=<UTC>),
@lukecampbell
lukecampbell / example.py
Created November 4, 2014 13:53
example.py
#!/usr/bin/env python
'''
somepackage.module
Example Class
'''
from somepackage.base import BaseClass
class Example(BaseClass):
@lukecampbell
lukecampbell / Example.java
Created October 29, 2014 01:57
Example Java application to demonstrate system properties
/*
* To use as example run with:
* Does nothing
* java Example
* Displays Debug
* java -Ddebug Example
*/
public class Example {
public static void main(String[] args) {
/*
@lukecampbell
lukecampbell / bases.py
Created October 16, 2014 16:57
OOI Stuff
#!/usr/bin/env python
from flask import Flask
from datetime import datetime
import json
app = Flask("ooi_services")
@app.route("/")
def index():