Skip to content

Instantly share code, notes, and snippets.

@bruceh48
bruceh48 / gist:0e17ff2db16ccd9e4998c956c194c6e1
Last active April 9, 2016 08:45
Dump and Restore Single Postgres Table
pg_dump --host localhost --port 5432 --username USERNAME DBNAME --format plain -ignore-version --file dumpfile.sql --table THE_TABLENAME
su - postgres
psql -l # will list all databases on Postgres cluster
pg_restore -d DBNAME -U postgres /srv/dir/dumpfile.sql
@bruceh48
bruceh48 / Make Vagrant Box
Last active May 7, 2016 03:58
Vagrant - Setup a Ubuntu/nginx/PHP5 box
# ssh into VagrantBox
sudo apt-get clean
# this next line can take quite some time to run..
sudo dd if=/dev/zero of=/EMPTY bs=1M
sudo rm -f /EMPTY
cat /dev/null > ~/.bash_history && history -c && exit
vagrant ssh
sudo su - postgres
psql
CREATE DATABASE DATABASE_NAME WITH OWNER=USER_NAME LC_COLLATE='en_US.utf8' LC_CTYPE='en_US.utf8' ENCODING='UTF8' TEMPLATE=template0;
\c DATABASE_NAME
@bruceh48
bruceh48 / gist:b725e2c10d36442d8cd26a16e44e5e79
Last active December 1, 2022 21:56
Geoserver REST Example calls
// See this for important info :
http://docs.geoserver.org/stable/en/user/_sources/rest/examples/curl.txt
// Get all workspaces
curl -v -u admin:geoserver -GET http://localhost:8080/geoserver/rest/workspaces.xml
// Create a new WORKSPACE
curl -u admin:geoserver -v -XPOST -H 'Content-type:text/xml'
@bruceh48
bruceh48 / gist:4ba76c974cdcb03eae4c9a13b720f73a
Created February 16, 2017 03:39
Clip mask for Australia in WKT format
POLYGON ((115.6146240234375 -33.247875947924385, 115.28503417968751 -33.559706648411975, 114.87854003906251 -33.47727218776036, 114.8345947265625 -34.00713506435885, 115.0213623046875 -34.443158674505796, 116.65832519531251 -35.1468629067563, 117.9107666015625 -35.19176696594738, 118.5369873046875 -34.97600151317588, 118.74572753906251 -34.73258420612363,119.60266113281251 -34.4793919710481, 119.89929199218751 -34.01624188966702, 122.1844482421875 -34.24359472969739, 123.65661621093751 -34.161818161230386, 124.0521240234375 -33.642062504753675,124.28283691406251 -33.100745405144266, 127.3150634765625 -32.34284135639302, 128.15002441406253 -32.101189732320954, 128.9849853515625 -31.765537409484388, 132.18200683593756 -32.101189732320954,133.1597900390625 -32.58384932565664, 134.1925048828125 -33.19273094190688, 134.59899902343756 -33.34888479220169, 134.40124511718753 -33.65120829920495, 134.4232177734375 -33.86129311351553,134.82971191406253 -33.7243396617476, 135.1702880859375 -34.09815934521553,135.03845214
@bruceh48
bruceh48 / gist:22733a575c4faded54421ae4c5b4572e
Created February 16, 2017 04:49
Bounding Box of Australia in WKT format
POLYGON((112.76 -10.23, 155.48 -10.23, 155.48 -44.28, 112.76 -44.28, 112.76 -10.23))
@bruceh48
bruceh48 / gist:b7bb7fe309570e1c2f019a275ed94277
Created February 19, 2017 04:33
Sort an array of arrays in PHP
<?php
$r = array(
array('year'=>2017,'month'=>1,'day'=>15),
array('year'=>2017,'month'=>2,'day'=>16),
array('year'=>2017,'month'=>2,'day'=>15),
array('year'=>2017,'month'=>2,'day'=>14),
array('year'=>2017,'month'=>3,'day'=>15),
array('year'=>2017,'month'=>4,'day'=>15),
array('year'=>2016,'month'=>5,'day'=>15),
@bruceh48
bruceh48 / gist:b5c67f6db6e4ee161ed6364a97c81d9f
Created April 15, 2017 08:26
Compile and install WGRIB2
#!/bin/bash
apt-get update
apt-get install -y build-essential libaec-dev zlib1g-dev libcurl4-openssl-dev libboost-dev curl wget zip unzip bzip2 gfortran gcc g++
rm -rf /usr/local/grib2/
mkdir -p /usr/local/grib2/
cd /code/
if [ ! -f "/tmp/wgrib2.tgz" ]; then
wget ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz.v2.0.6c -O /tmp/wgrib2.tgz
fi
tar -xf /tmp/wgrib2.tgz
@bruceh48
bruceh48 / gist:15a6aa3bb0efeb944417f64d3f9aaeb7
Created April 15, 2017 08:27
Compile and install WGRIB2 - Installs WGRIB 2.0.6c
#!/bin/bash
apt-get update
apt-get install -y build-essential libaec-dev zlib1g-dev libcurl4-openssl-dev libboost-dev curl wget zip unzip bzip2 gfortran gcc g++
rm -rf /usr/local/grib2/
mkdir -p /usr/local/grib2/
cd /tmp/
if [ ! -f "/tmp/wgrib2.tgz" ]; then
wget ftp://ftp.cpc.ncep.noaa.gov/wd51we/wgrib2/wgrib2.tgz.v2.0.6c -O /tmp/wgrib2.tgz
fi
tar -xf /tmp/wgrib2.tgz
@bruceh48
bruceh48 / gist:b4bffac3bc6df98786856c064d583ba4
Created July 13, 2017 06:55
SLD for Polygon & centroid Label
<?xml version="1.0" encoding="ISO-8859-1"?>
<StyledLayerDescriptor version="1.0.0"
xsi:schemaLocation="http://www.opengis.net/sld StyledLayerDescriptor.xsd"
xmlns="http://www.opengis.net/sld"
xmlns:ogc="http://www.opengis.net/ogc"
xmlns:xlink="http://www.w3.org/1999/xlink"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<NamedLayer>
<Name>Landsat 8 scenes</Name>
<UserStyle>