Skip to content

Instantly share code, notes, and snippets.

@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 / # qgis2 - 2017-05-26_12-13-28.txt
Created May 26, 2017 19:48
qgis2 (osgeo/osgeo4mac/qgis2) on macOS 10.12.5 - Homebrew build logs
Homebrew build logs for osgeo/osgeo4mac/qgis2 on macOS 10.12.5
Build date: 2017-05-26 12:13:28
@oeon
oeon / # qgis3-dev - 2017-05-15_15-40-08.txt
Created May 17, 2017 04:05
qgis3-dev (qgis/qgisdev/qgis3-dev) on macOS 10.12.5 - Homebrew build logs
Homebrew build logs for qgis/qgisdev/qgis3-dev on macOS 10.12.5
Build date: 2017-05-15 15:40:08
@oeon
oeon / vt.geojson
Created May 5, 2017 03:25
vermont counties, simplified with mapshaper
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@oeon
oeon / email-after-process.md
Created January 31, 2017 21:05
Send an email/text after a script finishes
@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 / 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 / cartodb-update-trigger.md
Last active May 31, 2016 15:37
a PostgreSQL trigger used in CartoDB which runs an UPDATE statement after another table is UPDATE(d )

here's the original UPDATE statement we're wanting to automate when there's an UPDATE on another table

UPDATE hydrant_grid SET point_count = (SELECT count(*)
FROM fire_hydrant_inventory WHERE status='true' AND ST_Intersects(fire_hydrant_inventory.the_geom, hydrant_grid.the_geom))

here's the trigger and function

CREATE OR REPLACE FUNCTION updatecount()
RETURNS trigger AS $$
@oeon
oeon / fulcrum_download_timedatestamp.py
Last active May 11, 2016 17:54 — forked from bmcbride/fulcrum_download.py
Python script for fetching a Fulcrum data share and saving it locally with a date & time stamp.
import urllib2
import datetime
def timeStamped(fname, fmt='%Y-%m-%d-%H-%M-%S_{fname}'):
return datetime.datetime.now().strftime(fmt).format(fname=fname)
url = 'https://web.fulcrumapp.com/shares/6e158acd08cacfad.csv'
u = urllib2.urlopen(url)
localFile = open('fulcrum_data.csv', 'w')
localFile.write(u.read())
localFile.close()
with open(timeStamped('fulcrum_data.csv'),'w') as outf: