Skip to content

Instantly share code, notes, and snippets.

View rgwozdz's full-sized avatar

Rich Gwozdz rgwozdz

  • Esri
  • Bellingham, WA
View GitHub Profile
@rgwozdz
rgwozdz / gist:9ac5ec00e826fa00587fe6384c83abd1
Created September 19, 2017 16:43
Find 10 largest files
#Type the following command at the shell prompt to find out top 10 largest file/directories:
du -a / | sort -n -r | head -n 10
@rgwozdz
rgwozdz / tim-date.sql
Created September 1, 2017 20:41
Compare timestamp to date in Postgres
SELECT *
FROM table
WHERE update_date >= '2013-05-03'::date
AND update_date < ('2013-05-03'::date + '1 day'::interval);
@rgwozdz
rgwozdz / geotrellis-cell-value.scala
Created July 27, 2017 15:32
sketch of getting cell values from geotrellis
val crs_coord_1 = ???
val crs_coord_2 = ???
// you first want to create a Raster
// assuming your rdd is a single tile representing the whole image, i.e. rdd.count == 1
val first = rdd.take(1)
val projExtent = first(0)._1
val tile = first(0)._2
// rgwozdz: My rdd isn't a single tile. On ingest my layer is tiled
// across zooms 0 - 6. Should I be reading a particular zoom level?
@rgwozdz
rgwozdz / java-service-example.sh
Created July 10, 2017 19:49
Setting up Ubuntu java service
# /usr/local/bin/service-name-restart.sh, owner: root, group: root, mode: 0755
#!/bin/bash
# /usr/local/bin/service-name-restart.sh
#
if [ -f "<java program working dir>/RUNNING_PID" ]; then kill -9 `cat <java program working dir>/RUNNING_PID`; fi
if [ -f "<java program working dir>/RUNNING_PID" ]; then rm <java program working dir>/RUNNING_PID; fi
cd <java program working dir>/bin
env JAVA_OPTS="-Xms4096m -Xmx4096m" ./geotrellis-api -Dconfig.file=<java program working dir>/conf/application.conf -Dhttp.port=7777 -Dplay.crypto.secret=abcdefghijk > <the-log-path> 2>&1
#########################################################################################################
@rgwozdz
rgwozdz / layerThumbnail.scala
Created July 6, 2017 17:21 — forked from echeipesh/layerThumbnail.scala
GeoTrellis Samples
s3 > test:console
[info] Starting scala interpreter...
[info]
Welcome to Scala 2.11.11 (Java HotSpot(TM) 64-Bit Server VM, Java 1.8.0_131).
Type in expressions for evaluation. Or try :help.
scala> import geotrellis.raster._
import geotrellis.vector._
import geotrellis.proj4._
import geotrellis.spark._
@rgwozdz
rgwozdz / insert-into.sql
Last active June 16, 2017 20:00
INSERT INTO FROM SELECT
INSERT INTO table_target (col1,col2) (SELECT col1, col2 FROM table_source);
@rgwozdz
rgwozdz / 0_reuse_code.js
Created May 4, 2017 16:24
Here are some things you can do with Gists in GistBox.
// Use Gists to store code you would like to remember later on
console.log(window); // log the "window" object to the console
SELECT n.nspname as "Schema",
p.proname as "Name",
pg_catalog.pg_get_function_result(p.oid) as "Result data type",
pg_catalog.pg_get_function_arguments(p.oid) as "Argument data types",
CASE
WHEN p.proisagg THEN 'agg'
WHEN p.proiswindow THEN 'window'
WHEN p.prorettype = 'pg_catalog.trigger'::pg_catalog.regtype THEN 'trigger'
ELSE 'normal'
END as "Type"
@rgwozdz
rgwozdz / pg-grant-cheatsheet.sql
Created March 9, 2017 18:40
Postgres Privledge cheatsheet
REVOKE ALL ON SCHEMA public FROM PUBLIC;
GRANT ALL ON SCHEMA public TO postgres;
GRANT USAGE ON SCHEMA public TO <app_user>;
GRANT ALL ON SCHEMA public TO PUBLIC;
REVOKE ALL ON FUNCTION <function-name>(<signature>) FROM PUBLIC;
GRANT ALL ON FUNCTION <function-name>(<signature>) TO <app_user>;
@rgwozdz
rgwozdz / api-integration-testing.yml
Created September 21, 2016 03:17
Psuedo Ansible Playbook for API/DB integration testing - Mocha.js, Express.js, PostgreSQL
- name: Run DB/API integration test suite
hosts: localhost
become: True
become_method: sudo
tasks:
- name: Use PSQL to Close Postgres DB connection to the master database
become: True
become_user: postgres