Skip to content

Instantly share code, notes, and snippets.


Peter Lindberg plindberg

View GitHub Profile
plindberg /
Last active Jul 4, 2018
Dump PostgreSQL table with JSONB column, qualifying by some JSON value, formatting for presentation using Heroku Dataclips

A while back, I wrote [a script to do daily dumps of a PostgreSQL table with a JSONB column][old one]. This was something an intern did daily for a client.

However, as summer came, we needed to automate this. The simplest and quickest solution turned out to do this using Heroku Dataclips.

I wasn’t aware of the [JSON functions and operators][json ops] of PostgreSQL, allowing you to both SELECT stuff from inside the JSON, and use in WHERE predicates. (It appears that you can even set up indexes on JSON values.)

plindberg /
Last active Jun 27, 2018
Dump PostgreSQL table with JSONB column as TSV file, pasteable into Google Sheets

This script is one I wrote to dump a PostgreSQL table with a JSONB column into TSV put on your pasteboard (on macOS) such that you can just paste it into a Google Sheet.

I needed this for a client and it was a bit of work, so I thought it might be useful to someone out there.

plindberg /
Last active May 21, 2018
Show most recent commit of each Git remote
git remote | \
xargs -n1 -I{} \
git log --oneline -1 --pretty=format:"%C(red)%h%d%C(reset) %s /%an, %ar" {}/master
View gist:9087fefcfae261929466df81f2083177
Verifying my Blockstack ID is secured with the address 1KV2ZFAsWsPWLx7NVadUNSwAPpQtw3jsxw
plindberg /
Created Aug 5, 2017
How to set up an AWS Lambda function for returning S3 pre-signed URLs for uploading files.


Granted, this is little more than an obfuscated way of having a publicly writable S3 bucket, but if you don’t have a server which can pre-sign URLs for you, this might be an acceptable solution.

For this to work, you take the following steps:

  1. Create a Lambda func, along with a new IAM role, keeping the default code.
  2. Create an API in the API Gateway.
View gist:0e50b45913fdd08b25ce3d399c8f1d12

Rich Hickey on becoming a better developer

Sorry, I have to disagree with the entire premise here.

A wide variety of experiences might lead to well-roundedness, but not to greatness, nor even goodness. By constantly switching from one thing to another you are always reaching above your comfort zone, yes, but doing so by resetting your skill and knowledge level to zero.

Mastery comes from a combination of at least several of the following:

  • Knowledge
  • Focus
View gist:eddae68cb37551c5b3fe648b553f4f80
Verifying that +plindberg is my blockchain ID.
plindberg /
Last active Jun 21, 2016
Quick and dirty dump of Watson Dialog conversation history (using httpie and jq)
\?date_from='2016-01-27 00:00:00'\&date_to='2016-06-22 00:00:00' \
|jq '
.conversations[] | .messages |
.[] |
if .from_client == "true" then
"> \(.text)"
View generator-reduce.js
'use strict';
const co = require('co');
// Like `reduce()` but accepting a generator function, such that it can be used asynchronously
// within a generator function invoked by `co()`.
function* reduceg(arr, genfn, initial) {
let acc = initial;
for (let x of arr) {
acc = yield genfn(acc, x);
plindberg / ibm-watson-dialog-with-inline-javascript-function.xml
Last active Jun 22, 2016
A minimal example of a Watson Dialog XML script with an inline Javascript function.
View ibm-watson-dialog-with-inline-javascript-function.xml
<?xml version="1.0" encoding="UTF-8" ?>
<dialog xsi:noNamespaceSchemaLocation="WatsonDialogDocument_1.0.xsd"
<folder label="Main">
<output id="start">
<item>Write stuff and I’ll SHOUT it back to you.</item>