Skip to content

Instantly share code, notes, and snippets.

View Sillson's full-sized avatar
🛰️
🌲 🔥 🎄 🔥

Stuart Illson Sillson

🛰️
🌲 🔥 🎄 🔥
View GitHub Profile
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@Sillson
Sillson / StateBoundaries.sql
Created November 3, 2019 20:24 — forked from jakebathman/StateBoundaries.sql
The approximate max/min latitude and longitude for all states and major territories
-- Create the table
CREATE TABLE IF NOT EXISTS `StateBoundaries` (
`State` varchar(10) DEFAULT NULL,
`Name` varchar(255) DEFAULT NULL,
`MinLat` varchar(50) DEFAULT NULL,
`MaxLat` varchar(50) DEFAULT NULL,
`MinLon` varchar(50) DEFAULT NULL,
`MaxLon` varchar(50) DEFAULT NULL
) ENGINE=InnoDB DEFAULT CHARSET=utf8;
@Sillson
Sillson / tile-composite.R
Created June 28, 2019 16:32
Slippy Map Tile Composite
library(slippymath)
library(sf)
library(purrr)
library(curl)
library(glue)
library(raster)
library(rgdal)
# pass map.bounds() & zoom from leaflet
# xmin <- map.getBounds()["_southWest"]['lat']
@Sillson
Sillson / capitalize.js
Created September 19, 2018 23:13
capitalize function in bigquery
CREATE TEMPORARY FUNCTION capitalize(str STRING)
RETURNS STRING
LANGUAGE js AS """
return str.replace(
/\\w\\S*/g,
function(txt) {
return txt.charAt(0).toUpperCase() + txt.substr(1).toLowerCase();
}
);
""";
@Sillson
Sillson / modern-geospatial-python.md
Created July 24, 2018 21:07 — forked from jqtrde/modern-geospatial-python.md
Modern remote sensing image processing with Python
@Sillson
Sillson / jsonb_to_pg_array.sql
Created June 26, 2018 03:36
jsonb_to_pg_array
CREATE OR REPLACE FUNCTION jsonb_array_to_text_array(
p_input jsonb
) RETURNS TEXT[] AS $BODY$
DECLARE v_output text[];
BEGIN
SELECT array_agg(ary)::text[]
INTO v_output
@Sillson
Sillson / constraint_dropper.sql
Created January 16, 2018 19:15
Drop all Postgres Constraints that match
BEGIN transaction;
DO $$DECLARE r record;
BEGIN
FOR r IN SELECT table_name,constraint_name
FROM information_schema.constraint_table_usage
WHERE table_name IN ('table_1', 'table_2', 'table_3') /* here be the tables to select. refactor if you want to select all */
AND constraint_name ~'\d$' /* pattern matcher */
LOOP
EXECUTE 'ALTER TABLE ' || quote_ident(r.table_name)|| ' DROP CONSTRAINT '|| quote_ident(r.constraint_name) || ';';
CREATE OR REPLACE VIEW public.active_locks AS
SELECT t.schemaname,
t.relname,
l.locktype,
l.page,
l.virtualtransaction,
l.pid,
l.mode,
l.granted
FROM pg_locks l
@Sillson
Sillson / GetOutMyRailsConsole
Last active August 30, 2017 03:44
Boot sorry suckers out of a heroku rails console
## Boot chumps from your heroku free dynos
## PS the app
heroku ps -a [APP]
## Find that one-off process, snag that pid
=== run: one-off processes (1)
run.4570 (Free): up 2016/03/03 10:01:16 -0800 (~ 8m ago): bin/rails console
## Tossed like a chump