Skip to content

Instantly share code, notes, and snippets.

View sfkeller's full-sized avatar

Stefan sfkeller

View GitHub Profile
@sfkeller
sfkeller / ballparks2.sql
Last active April 4, 2021 20:31
Ballparks by James Fee
/*
---------------------------------
ballparks2.geojson from James Fee
---------------------------------
Note that there's attribute "Teams", which has a value of a JSON array of JSON objects.
QGIS 3 interprets this as string.
Turning this string into an array still is an array of JSON Objects.
So, this has to be treated first as a JSON object.
--
-- FUNCTION split_text_to_array(...)
-- Accepts a delimited text (string). Returns a sorted array of text.
--
--drop function if exists split_text_to_array(text, char(1));
create or replace function split_text_to_array(text_delimited text, delimiter text default ';')
returns text[]
as $$
select array(select regexp_split_to_table(lower(regexp_replace(text_delimited, '( )|'||delimiter||'$', '', 'g')), delimiter) order by 1);
$$ language sql immutable strict parallel safe;
@sfkeller
sfkeller / Oberseerundweg_Demo.md
Created October 29, 2020 19:16
Oberseerundweg - Demo

Oberseerundweg - Demo

@sfkeller
sfkeller / link_pg_server.sql
Created February 14, 2019 22:23
Stored Function link_pg_server() - Linking to a remote PostgreSQL db read-only.
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@sfkeller
sfkeller / map.geojson
Last active July 16, 2018 11:23
GR_NBK_2_modif_Stefan.geojson
Loading
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
SELECT
CASE WHEN GROUPING(movie.genre) = 1 then 'All Genres' else movie.genre end as Genre,
CASE WHEN GROUPING(customer.gender) = 1 then 'All Genders' else customer.gender end as Gender,
sum(sales.quantity) AS Quantity
FROM factsales sales, dimmovie movie, dimcustomer customer
WHERE sales.movieId = movie.movieId
AND sales.custID = customer.custID
GROUP BY CUBE(movie.genre, customer.gender);
/*
SELECT ST_AsText(way) geom,
COALESCE(name, '')||' '||osm_id AS label
FROM osm_polygon
WHERE tags->'building' > ''
AND ST_Intersects(way,
(SELECT way
FROM osm_polygon
WHERE osm_id=-1684362))
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<title>Embedded uMap Example</title>
<link rel="stylesheet" href="style.css">
<script src="script.js"></script>
</head>
<body>
<!-- page content -->