Skip to content

Instantly share code, notes, and snippets.

View will123195's full-sized avatar

Will Schmid will123195

View GitHub Profile
@will123195
will123195 / errorHandler.js
Created June 30, 2022 19:06
Express error handler for user-friendly postgres errors
import { errorHandler } from 'express-rest-error'; // need version 1.2.0+
// Make postgres errors more user-friendly
const pgErrorPatterns = [
{
regex: /null value in column "(.*)" violates not-null constraint/,
assign: (match) => ({
message: `${match[1]} is required`,
required: [match[1]],
}),
import sss from 'shamirs-secret-sharing'
const { crypto } = window
const u8ToB64 = u8 => Buffer.from(u8).toString('base64')
const b64toU8 = b64 => Buffer.from(b64, 'base64')
async function sssDemo() {
const keypair = await crypto.subtle.generateKey(
{
name: 'RSA-OAEP',
@will123195
will123195 / get-local-timezone.sql
Last active March 13, 2020 11:57
Postgres: How to return timestamp with local timezone
select
id,
"utcStartTime",
"utcOffset",
"localStartTime" || "utcOffset" as "startTime"
from (
select
id,
"startTime" as "utcStartTime",
("startTime" at time zone 'UTC' at time zone "timezoneOffset")::timestamp as "localStartTime",

Keybase proof

I hereby claim:

  • I am will123195 on github.
  • I am will123195 (https://keybase.io/will123195) on keybase.
  • I have a public key ASDCXpSPFVw6LDAhdRGr2tPYDgW0eN2VvxyisAg9yJzY1wo

To claim this, I am signing this object:

New IntelliJ Project for Spark/Scala/Mongo

  1. Install IntelliJ
  2. IntelliJ > Preferences > Plugins > Install Scala > Restart IntelliJ
  3. Create New Project > Scala > SBT
    • JDK: 1.8
    • SBT: 0.13
    • Scala: 2.11
  4. Add this to build.sbt: