Skip to content

Instantly share code, notes, and snippets.

View JacobJohansen's full-sized avatar

Jacob Johansen JacobJohansen

View GitHub Profile
@JacobJohansen
JacobJohansen / postgres_queries_and_commands.sql
Created March 29, 2024 19:05 — forked from rgreenjr/postgres_queries_and_commands.sql
Useful PostgreSQL Queries and Commands
-- show running queries (pre 9.2)
SELECT procpid, age(clock_timestamp(), query_start), usename, current_query
FROM pg_stat_activity
WHERE current_query != '<IDLE>' AND current_query NOT ILIKE '%pg_stat_activity%'
ORDER BY query_start desc;
-- show running queries (9.2)
SELECT pid, age(clock_timestamp(), query_start), usename, query
FROM pg_stat_activity
WHERE query != '<IDLE>' AND query NOT ILIKE '%pg_stat_activity%'
@JacobJohansen
JacobJohansen / s3-to-alb-with-lambda.py
Created November 18, 2021 20:11 — forked from Burekasim/s3-to-alb-with-lambda.py
access s3 objects with ALB using lambda
import os
import json
import boto3
from botocore.exceptions import ClientError
def lambda_handler(event, context):
# use 'AWS_REGION' environment variable from lambda built-in variables
aws_region = os.environ['AWS_REGION']
bucket_name = os.environ['BUCKET_NAME']
@JacobJohansen
JacobJohansen / convert-pgp-to-ssh.sh
Created November 18, 2021 18:14 — forked from mdellavo/convert-pgp-to-ssh.sh
Convert PGP Public Key to OpenSSH
# import the public key
gpg --import ../alice.asc
gpg --export $KEYID | openpgp2ssh $KEYID
@JacobJohansen
JacobJohansen / apple-keychain-pass-import.md
Created December 11, 2020 15:16 — forked from santigz/apple-keychain-pass-import.md
Import Apple Keychain into pass

Import Apple Keychain into pass

This guide shows how to import into pass your passwords stored in Apple's Keychain Access.

Find your keychain file

The default kaychain file is ~/Library/Keychains/login.keychain.

Passwords under the "Local Items" keychain (the default since Mavericks to sync with iCloud) use a different file format and can not be exported via the Apple's security tool we use. If that is you case, create a new keychain and drag-and-drop the keys. Your new keychain should have the .keychain extension.

@JacobJohansen
JacobJohansen / merge-maps.kt
Created November 5, 2020 05:03 — forked from cy6erGn0m/merge-maps.kt
Merge two maps with custom reduce function for Kotlin
private fun <K, V> Map<K, V>.mergeReduce(other: Map<K, V>, reduce: (V, V) -> V = { a, b -> b }): Map<K, V> {
val result = LinkedHashMap<K, V>(this.size() + other.size())
result.putAll(this)
other.forEach { e ->
val existing = result[e.key]
if (existing == null) {
result[e.key] = e.value
}
else {
@JacobJohansen
JacobJohansen / ca_and_cert_golang_demo.go
Created January 3, 2020 16:28 — forked from shaneutt/LICENSE
Golang: Demonstrate creating a CA Certificate, and Creating and Signing Certs with the CA
package main
import (
"bytes"
"crypto/rand"
"crypto/rsa"
"crypto/tls"
"crypto/x509"
"crypto/x509/pkix"
"encoding/pem"
@JacobJohansen
JacobJohansen / inactivity.js
Created August 14, 2019 18:45 — forked from gerard-kanters/inactivity.js
Inactivity timeout javascript
<script type="text/javascript">
function idleTimer() {
var t;
//window.onload = resetTimer;
window.onmousemove = resetTimer; // catches mouse movements
window.onmousedown = resetTimer; // catches mouse movements
window.onclick = resetTimer; // catches mouse clicks
window.onscroll = resetTimer; // catches scrolling
window.onkeypress = resetTimer; //catches keyboard actions
@JacobJohansen
JacobJohansen / webpack4upgrade.md
Created March 9, 2018 13:19 — forked from gricard/webpack4upgrade.md
Just some notes about my attempt to upgrade to webpack 4

Hmm... I don't see any docs for 4.0 on https://webpack.js.org. I guess I'll just wing it. All I need to do is npm i -D webpack@next, right?

+ webpack@4.0.0-beta.2
added 1 package, removed 20 packages and updated 4 packages in 13.081s

Cool! Ok...

@JacobJohansen
JacobJohansen / AuthyToOtherAuthenticator.md
Created October 20, 2017 15:12 — forked from gboudreau/AuthyToOtherAuthenticator.md
Export TOTP tokens from Authy

Generating Authy passwords on other authenticators


There is an increasing count of applications which use Authy for two-factor authentication. However many users who aren't using Authy, have their own authenticator setup up already and do not wish to use two applications for generating passwords.

Since I use 1Password for all of my password storing/generating needs, I was looking for a solution to use Authy passwords on that. I couldn't find any completely working solutions, however I stumbled upon a gist by Brian Hartvigsen. His post had a neat code with it to generate QR codes (beware, through Google) for you to use on your favorite authenticator.

His method is to extract the secret keys using Authy's Google Chrome app via Developer Tools. If this was not possible, I guess people would be reverse engineering the Android app or something like that. But when I tried that code, nothing appeared on the screen. My gues

#!/bin/sh
VERSION=0.8.0.0
BUILD_TYPE=debug
echo ============================
echo Set version $VERSION
echo ============================
TAG=$VERSION
python ./build/set_version.py $VERSION > ./src/version.h