Skip to content

Instantly share code, notes, and snippets.

View stefanfrede's full-sized avatar

Stefan Frede stefanfrede

View GitHub Profile
@stefanfrede
stefanfrede / ddev-debug.txt
Created November 11, 2022 12:44
DDEV Debug Output
Running bash [-c /tmp/test_ddev.sh]
OS Information: Linux wyn-lin-01 5.15.0-10052-tuxedo #58~20.04.1tux1 SMP Mon Oct 24 12:05:31 UTC 2022 x86_64 x86_64 x86_64 GNU/Linux
User information: uid=1001(sfrede) gid=1001(sfrede) groups=1001(sfrede),27(sudo),46(plugdev),131(vboxusers),996(docker),997(rslsync),1000(support)
DDEV version: ITEM VALUE
DDEV version v1.21.3
architecture amd64
db drud/ddev-dbserver-mariadb-10.4:v1.21.3
dba phpmyadmin:5
ddev-ssh-agent drud/ddev-ssh-agent:v1.21.3
docker 20.10.21
@stefanfrede
stefanfrede / machine.js
Created January 29, 2021 16:15
Generated by XState Viz: https://xstate.js.org/viz
const fetchMachine = Machine(
{
id: 'fetch',
initial: 'idle',
context: {
data: null,
error: null,
},
states: {
idle: {
@stefanfrede
stefanfrede / yubikey+gpupgp+ssh_howto.md
Created January 9, 2021 11:09 — forked from xirkus/yubikey+gpupgp+ssh_howto.md
Security Adventures 1. How to get yubikey+gpg+ssh+gitbhub working on MacOS

I've spent the day trying to get this setup working with GitHub and given the number of gotcha's I encountered, it seemed like a good idea to document how I finally got this working with as few hacks as possible. There's a lot of documentation out there (some of it old and misleading) and committing here for posterity will help me remember this when I inevitably need to do this again.

Rationale

Passwords are simply not enough these days. Regardless of the company, breaches (and the associated Personally Identifiable Information harvested) are a matter of not if, but when. There are a number of things you can do to protect yourself, but being on the tin-foil-hat side of paranoia, means there are a few Commandents that I adhere to (and recommend for other folks)[Insert link to Fight Club Rules for the Secure Internet].

That being said, if you use 2-factor authentication and have committed to using a hardware token such as the Yubikey, then you're already ahead of the curve. The problem is that wh

@stefanfrede
stefanfrede / unique_id.js
Created January 15, 2020 12:42
Generate a unique id in the browser without a library
function randomId() {
const uint32 = window.crypto.getRandomValues(new Uint32Array(1))[0];
return uint32.toString(16);
}
const rid = randomId();
@stefanfrede
stefanfrede / async_chained_api.js
Created December 17, 2019 17:45
Chained APIs with Asynchronous Functions
// Given
class Solar {
getBaseMap(callback) {
setTimeout(function() {
callback();
console.log('Getting Base Map');
}, 600);
}
drawRoofOutline(callback) {
setTimeout(function() {
@stefanfrede
stefanfrede / gpg-import-and-export-instructions.md
Created November 7, 2019 14:37 — forked from chrisroos/gpg-import-and-export-instructions.md
Instructions for exporting/importing (backup/restore) GPG keys

Every so often I have to restore my gpg keys and I'm never sure how best to do it. So, I've spent some time playing around with the various ways to export/import (backup/restore) keys.

Method 1

Backup the public and secret keyrings and trust database

cp ~/.gnupg/pubring.gpg /path/to/backups/
cp ~/.gnupg/secring.gpg /path/to/backups/
cp ~/.gnupg/trustdb.gpg /path/to/backups/

or, instead of backing up trustdb...

@stefanfrede
stefanfrede / switch-delegator.js
Created June 29, 2019 05:41
A alternate approach to write a switch statement that supports composability and reusability.
// Example returns for illustration only.
const cases = {
alpha() {
return [ "Alpha", arguments.length ];
},
beta() {
return [ "Beta", arguments.length ];
},
_default() {
return [ "Default", arguments.length ];
@stefanfrede
stefanfrede / README-Template.md
Created June 20, 2019 18:58 — forked from PurpleBooth/README-Template.md
A template to make good README.md

Project Title

One Paragraph of project description goes here

Getting Started

These instructions will get you a copy of the project up and running on your local machine for development and testing purposes. See deployment for notes on how to deploy the project on a live system.

Prerequisites

@stefanfrede
stefanfrede / uuidv4.js
Created November 29, 2018 21:37
A RFC4122 version 4 compliant UUID solution
function uuidv4() {
return ([1e7]+-1e3+-4e3+-8e3+-1e11).replace(/[018]/g, c =>
(c ^ crypto.getRandomValues(new Uint8Array(1))[0] & 15 >> c / 4).toString(16)
)
}
console.log(uuidv4());
@stefanfrede
stefanfrede / SimpleStore.js
Last active July 28, 2017 13:32 — forked from ksafranski/SimpleStore.js
Simple localStorage function with Cookie fallback for older browsers.
/**
* Simple [local|session]Storage with Cookie Fallback
* v.1.2.0
*
* USAGE:
* ----------------------------------------
* Set New / Modify:
* store({
* storage: {
* key: 'my_key',