Skip to content

Instantly share code, notes, and snippets.

Peter Lindberg plindberg

Block or report user

Report or block plindberg

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

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

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
plindberg / README.md
Last active Jun 27, 2018
Dump PostgreSQL table with JSONB column as TSV file, pasteable into Google Sheets
View README.md

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
plindberg / git-foreach-remote-show-latest-commit.sh
Last active May 21, 2018
Show most recent commit of each Git remote
View git-foreach-remote-show-latest-commit.sh
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 https://explorer.blockstack.org/address/1KV2ZFAsWsPWLx7NVadUNSwAPpQtw3jsxw
@plindberg
plindberg / README.md
Created Aug 5, 2017
How to set up an AWS Lambda function for returning S3 pre-signed URLs for uploading files.
View README.md

README

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. https://onename.com/plindberg
@plindberg
plindberg / dump-watson-dialog-conversation-history.sh
Last active Jun 21, 2016
Quick and dirty dump of Watson Dialog conversation history (using httpie and jq)
View dump-watson-dialog-conversation-history.sh
http -b -a ${WATSON_DIALOG_USERNAME}:${WATSON_DIALOG_PASSWORD} \
https://gateway.watsonplatform.net/dialog/api/v1/dialogs/${WATSON_DIALOG_ID}/conversation\
\?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)"
else
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
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"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance">
<flow>
<folder label="Main">
<output id="start">
<prompt>
<item>Write stuff and I’ll SHOUT it back to you.</item>
</prompt>
You can’t perform that action at this time.