Skip to content

Instantly share code, notes, and snippets.

View hrwgc's full-sized avatar

Chris Herwig hrwgc

  • Google
  • San Francisco
View GitHub Profile
@hrwgc
hrwgc / evernote_parse.py
Last active January 1, 2022 10:13
Evernote note export wrangling to sqlite -> markdown jekyll data
#!/usr/bin/python
# -*- coding: utf-8 -*-
import sqlite3
import sys
import re
import uuid
from bs4 import *
import lxml
import unicodedata
@hrwgc
hrwgc / translate.sh
Created December 12, 2012 20:34
Command line translator application using Bing's free Translator service.
#!/bin/bash
if [ -z "$1" ] || [ -z "$2" ] || [ -z "$3" ]; then
echo 'Usage: translate.sh ["Original Text"] ["Source Language"] ["Target Language"]'
echo 'Example: translate.sh "Hello World" "en" "fr"'
declare -a LANG_NAMES=('Arabic' 'Czech' 'Danish' 'German' 'English' 'Estonian' 'Finnish' 'French' 'Dutch' 'Greek' 'Hebrew' 'Haitian Creole' 'Hungarian' 'Indonesian' 'Italian' 'Japanese' 'Korean' 'Lithuanian' 'Latvian' 'Norwegian' 'Polish' 'Portuguese' 'Romanian' 'Spanish' 'Russian' 'Slovak' 'Slovene' 'Swedish' 'Thai' 'Turkish' 'Ukrainian' 'Vietnamese' 'Simplified Chinese' 'Traditional Chinese');
declare -a LANG_CODES=('ar' 'cs' 'da' 'de' 'en' 'et' 'fi' 'fr' 'nl' 'el' 'he' 'ht' 'hu' 'id' 'it' 'ja' 'ko' 'lt' 'lv' 'no' 'pl' 'pt' 'ro' 'es' 'ru' 'sk' 'sl' 'sv' 'th' 'tr' 'uk' 'vi' 'zh-CHS' 'zh-CHT');
for IX in $(seq 0 $((${#LANG_CODES[@]} - 1))); do
echo ${LANG_CODES[$IX]}: ${LANG_NAMES[$IX]};
done
@hrwgc
hrwgc / gdal_outlines.sh
Created November 2, 2012 01:11
gdal trace raster outlines
## run in a directory with many raster images containing nodata values that make their gdalinfo extents unreliable. output is a csv containing filename and data-containing extents, to be imported into postgis, sqlite, etc for running spatial queries.
## usage:
echo "file;GEOMETRY" > index.csv
declare -a FILES=$(ls -1 *tif);
for FILE in ${FILES[@]}; do
FILE=${FILE%.tif}
echo "$FILE.tif;" > $FILE.txt
gdal_trace_outline $FILE.tif -ndv '0 0' -out-cs en -wkt-out $FILE.wkt
cat $FILE.wkt >> $FILE.txt
@hrwgc
hrwgc / hirise.sh
Created October 20, 2012 15:23
Scrape University of Arizona HiRise FTP archive for metadata files
#!/bin/bash
## Usage: ./hirise.sh
## This is a self-contained script to scrape the University of Arizona's HiRise imaging experiment FTP archive. it generates a single file (FILES.txt) containing urls for each Mars image in the archive. This makes it easier to programatically access the metadata .LBL files and ultimately, the source images (.jp2).
declare -a DIRECTORIES=('ORB_011200_011299' 'ORB_011300_011399' 'ORB_011400_011499' 'ORB_011500_011599' 'ORB_011600_011699' 'ORB_011700_011799' 'ORB_011800_011899' 'ORB_011900_011999' 'ORB_012000_012099' 'ORB_012100_012199' 'ORB_012200_012299' 'ORB_012300_012399' 'ORB_012400_012499' 'ORB_012500_012599' 'ORB_012600_012699' 'ORB_012700_012799' 'ORB_012800_012899' 'ORB_012900_012999' 'ORB_013000_013099' 'ORB_013100_013199' 'ORB_013200_013299' 'ORB_013300_013399' 'ORB_013400_013499' 'ORB_013500_013599' 'ORB_013600_013699' 'ORB_013700_013799' 'ORB_013800_013899' 'ORB_013900_013999' 'ORB_014000_014099' 'ORB_014100_014199' 'ORB_014200_014299' 'ORB_014300_014399' 'ORB_014
@hrwgc
hrwgc / index.html
Created July 13, 2012 02:49 — forked from bsudekum/Interact.txt
Files for GitHub tiles
<DOCTYPE html>
<html>
<head>
<title>Stop and Frisk</title>
<meta charset="utf-8" />
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--[if lte IE 8]><link rel="stylesheet" href="js/ext/wax/ext/leaflet.ie.css" /><![endif]-->
<script src="js/ext/wax/ext/leaflet.js"></script>
<script src='js/ext/wax/dist/wax.leaf.min.js' type='text/javascript'></script>
<link rel="stylesheet" href="js/ext/wax/ext/leaflet.css" />