Skip to content

Instantly share code, notes, and snippets.

@oeon
oeon / fire_fatalities_slu.geojson
Created February 28, 2024 04:36
Fire fatality stories from an old SLU Pre-fire project (no longer online) http://slocountyfire.org/FireFatalities/
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@oeon
oeon / gist:84b54ace2090904ca7ac08f2b1cbdfcc
Created November 8, 2019 19:04
run this to fix that: RUBY_CONFIGURE_OPTS="--with-openssl-dir=/usr/local/opt/openssl" asdf install ruby 2.2.4
ruby-build: using openssl from homebrew
Downloading ruby-2.2.4.tar.bz2...
-> https://cache.ruby-lang.org/pub/ruby/2.2/ruby-2.2.4.tar.bz2
Installing ruby-2.2.4...
WARNING: ruby-2.2.4 is past its end of life and is now unsupported.
It no longer receives bug fixes or critical security updates.
ruby-build: using readline from homebrew
^[[A
@oeon
oeon / powerbi-postgres-cert-steps.md
Last active June 19, 2023 07:27
Steps covering new Postgres-SSL cert creation and import into Windows for connecting to PowerBI.

Essentially, the problem is that the default SSL cert for Postgres /etc/ssl/certs/ssl-cert-snakeoil.pem does not have enough information when copied over to the Guest machine running PowerBI which is trying to connect to Postgres, specifically, the Common Name field.

There are various posts out there about this e.g. https://community.powerbi.com/t5/Desktop/PostgreSQL-powerbi-desktop-connection-error/m-p/90689. This one was good to point me at npgsql 3.1.8 specifically https://blogs.msdn.microsoft.com/chmitch/2018/06/04/complete-guide-to-setting-up-power-bi-connecting-to-postgres-w-refresh-enabled/

  1. create a new SSL certificate (roughly) following these guides: https://uit.stanford.edu/service/ssl/selfsigned + https://www.postgresql.org/docs/9.1/static/ssl-tcp.html be sure to set the Common Name field value to the IP address of the server which is hosting the Postgres instance you're connecting to from PowerBI. -days 3650 will set the expiration in 10 years, default is 30 days if not specified.
@oeon
oeon / index.html
Created March 1, 2023 00:23
test html for OPENEXTENSION demo in gist
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8" />
<title>App Extension Example</title>
<!-- Fulcrum extension script -->
<script>(()=>{var t=(e,n)=>()=>(n||e((n={exports:{}}).exports,n),n.exports);var d=t((w,o)=>{var a=new URLSearchParams(location.search),u,r=(u=c(a.get("extension")))!=null?u:{};function c(e){try{return JSON.parse(e)}catch(n){return null}}var l;o.exports=window.Fulcrum={id:r.id,url:r.url,data:(l=r.data)!=null?l:{},origin:r.origin,init:()=>{var e;Fulcrum.isReady=!0,(e=Fulcrum.onReadyOnce)==null||e.call(Fulcrum)},ready:e=>{Fulcrum.onReadyOnce=()=>{Fulcrum.isReady&&!Fulcrum.onReadyCalled&&(Fulcrum.onReadyCalled=!0,e(Fulcrum))},Fulcrum.onReadyOnce()},send:(e,{close:n=!1}={})=>{var i;e=e!=null?e:{};let s={id:Fulcrum.id,url:Fulcrum.url,data:e,close:n};(i=window.webkit)!=null&&i.messageHandlers?window.webkit.messageHandlers.extensionListener.postMessage(JSON.stringify(s)):window.parent&&window.parent.postMessage({extensionMessage:s},Fulcrum.origin)},finish:e=>{Fulcrum.send(e,
@oeon
oeon / base64-encode-decode.js
Created August 23, 2016 17:35 — forked from JavaScript-Packer/base64-encode-decode.js
Perfect ATOB/BTOA alternatives (Base64 encoder/decoder) for JavaScript/Jscript.net Demo on http://jsfiddle.net/1okoy0r0/
function b2a(a) {
var c, d, e, f, g, h, i, j, o, b = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789+/=", k = 0, l = 0, m = "", n = [];
if (!a) return a;
do c = a.charCodeAt(k++), d = a.charCodeAt(k++), e = a.charCodeAt(k++), j = c << 16 | d << 8 | e,
f = 63 & j >> 18, g = 63 & j >> 12, h = 63 & j >> 6, i = 63 & j, n[l++] = b.charAt(f) + b.charAt(g) + b.charAt(h) + b.charAt(i); while (k < a.length);
return m = n.join(""), o = a.length % 3, (o ? m.slice(0, o - 3) :m) + "===".slice(o || 3);
}
function a2b(a) {
var b, c, d, e = {}, f = 0, g = 0, h = "", i = String.fromCharCode, j = a.length;
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@oeon
oeon / pgRouting_intro.md
Last active February 27, 2022 09:44
basic steps with pgRouting to make alpha shape of isochrone
  1. createdb with postgres > create postgis/pgrouting extension > load road data with ogr2ogr or shp2pgsql or SPIT in QGIS

  2. create vertices_tmp table with id/geom columns

select pgr_createTopology('roads', 0.5, 'geom', 'id');

  1. from 29788 = to the nearest 'vertices_tmp' node id to Station 15, select #all nodes less than 10 units (minutes) of cost
SELECT id, id1 AS node, id2 AS edge, cost, the_geom
INTO "20_10min_nodes"
@oeon
oeon / fulcrum-report-rename.sh
Last active August 14, 2020 01:27 — forked from bmcbride/fulcrum-report-rename.sh
Fulcrum PDF reports are named with the record's unique fulcrum_id. This bash script loops through the parent CSV file and renames the PDF files based on the index of user-specified fields.
#!/bin/bash
INPUT=fire_hydrants.csv
OLDIFS=$IFS
IFS=,
[ ! -f $INPUT ] && { echo "$INPUT file not found"; exit 99; }
while read -a csv_line
do
mv ${csv_line[0]}.pdf ${csv_line[8]}-${csv_line[0]}.pdf
done < $INPUT
@oeon
oeon / st_intersects_within.sql
Created January 12, 2020 17:28
where ESA is a polygon layer. Use PostGIS to test in/out
-- inside ESA
UPDATE htmp points SET esa = 'yes'
FROM
(SELECT DISTINCT(poi.*)
FROM vm_esa pol
JOIN htmp poi
ON (ST_Within(poi.geom, pol.geom))) inside
WHERE points.legacy_fulcrum_id = inside.legacy_fulcrum_id;
-- outside ESA
@oeon
oeon / gist.sql
Created January 7, 2020 05:59
unnested photo array - captions...aggregated back together
select _record_id, string_agg(unnest, ', ') as photos, string_agg(photos_captions, ', ') as photos_captions from (select r._record_id, r.unnest, k.labels as photos_captions from records r join rek k on k.photo = r.unnest order by _record_id) a group by _record_id order by _record_id