Skip to content

Instantly share code, notes, and snippets.

This recipe is a work in progress and has never been run as-is.

  • timeouts are in ms
  • lock timeout: in postgres, when a statement that wants a restrictive lock waits on another lock, other statements that want locks can't jump the queue. so even though the statement that is waiting might only take a very short amount of time, when it starts running, while it is waiting no other statements can begin. So we set the lock timeout pretty low and retry if we don't get it.
  • statement timeout: we set a short statement timeout before statements which do lock and which we expect to take a short amount of time, just in case something about our assumptions/understanding is wrong and the statement ends up taking a long time. if this happens the statement will bail early without causing harm, and we can investigate what is wrong with
@ezekg
ezekg / profile.md
Last active March 3, 2024 23:52
iTerm key bindings

Open the iTerm preferences ⌘+, and navigate to the Profiles tab (the Keys tab can be used, but adding keybinding to your profile allows you to save your profile and sync it to multiple computers) and keys sub-tab and enter the following:

Delete all characters left of the cursor

⌘+←Delete Send Hex Codes:

  • 0x18 0x7f – Less compatible, doesn't work in node and won't work in zsh by default, see below to fix zsh (bash/irb/pry should be fine), performs desired functionality when it does work.
  • 0x15 – More compatible, but typical functionality is to delete the entire line rather than just the characters to the left of the cursor.

Delete all characters right of the cursor

⌘+fn+←Delete or ⌘+Delete→ Send Hex Codes:

  • 0x0b
@ezekg
ezekg / checklist.md
Last active January 23, 2024 03:09
Deployment Checklist

Deployment Checklist

Pre-Development

  • Hosting is set up with full control panel access and we have log in credentials
  • All email addresses are known for each form and all emails has been confirmed active
  • Person responsible for DNS switch knows client's current email management service and understands how to route the DNS

Post-Development

  • Person responsible for deployment has obtained SSH access to server
  • All required system packages have been installed on the server e.g. recent versions of php (greater than v5.4, if at all possible), mysql, git, wp-cli, magerun (if Magento project), openssl (if https), rsync, etc.
@ezekg
ezekg / example.html
Last active January 8, 2024 23:18
Example of validating a node-locked license from an Electron app
<!DOCTYPE html>
<html>
<head>
<meta charset='UTF-8'>
<title>Node-locked License Validation Example</title>
</head>
<body>
<button type='button' id='validate-license'>
Validate License
</button>
@ezekg
ezekg / _README.md
Last active August 19, 2023 10:30
How to verify a signed license key using C#, Ed25519 and the NSEC crypto package. See: https://keygen.sh

Setup dependencies

dotnet --version
# => 6.0.101

dotnet add package NSec.Cryptography

Run the example

@ezekg
ezekg / README.md
Created May 4, 2023 14:49 — forked from ascendbruce/README.md
Use macOS-style shortcuts in Windows

Use macOS-style shortcuts in Windows / keyboard mappings using a Mac keyboard on Windows

Make Windows PC's shortcut act like macOS (Mac OS X) (using AutoHotkey (ahk) script)

With this AutoHotKey script, you can use most macOS style shortcuts (eg, cmd+c, cmd+v, ...) on Windows with a standard PC keyboard.

There is a new, alternative project that does similar things and more, check it out at https://github.com/stevenilsen123/mac-keyboard-behavior-in-windows

How does it work

<?php
// These are required!
$product_token = getenv('KEYGEN_PRODUCT_TOKEN');
$account_id = getenv('KEYGEN_ACCOUNT_ID');
// Retrieve the request's body and parse it as JSON
$body = @file_get_contents('php://input');
$event_json = json_decode($body);
@ezekg
ezekg / keygen.js
Created March 13, 2023 15:34
How to verify a signed and encrypted license file using Node.js (see https://keygen.sh)
import * as crypto from 'crypto'
const PUBLIC_KEY = 'MCowBQYDK2VwAyEA6GAeSLaTg7pSAkX9B5cemD0G0ixCV8/YIwRgFHnO54g='
const LICENSE_KEY = '988214-879010-F1185E-B37E91-E53AF5-V3'
const LICENSE_FILE = `-----BEGIN LICENSE FILE-----
eyJlbmMiOiJXV0tacURadUtaMlVHcFZ4WDdabnJWL2VwbnpsemxjWnU4WXo4
TlMzTEk2S25DL3RiUVhQRkQ3N2FOSWRCY1IvK2ZSYU5BZjdrZEVneGhidFA3
b1diTTBlZGI1dFhxVHNIaFZSKzBZcUhqUXpNT2UxOGVuT3ROb29reW9PWUFx
bGJHMFNpb0QzbFc2T2lvTUFjZEwxa1d3MGd5OXBrV09lR05xV3o5T0tHaXZT
UWhOcHZpT005MmorQW1nSjNjMGVDL0dyNmh1ZzJrbVJFSHF6UlVPNUN3aTM3
@ezekg
ezekg / import-store-locations.php
Last active December 22, 2022 08:35
Import CSV script for WP Store Locator plugin
<?php
/**
* This is a quick and dirty script. This should NEVER be run on a production server.
*
* Include this script at the bottom of your functions.php file, e.g.
*
* ```php
* // Your functions.php file
* // ...
@ezekg
ezekg / readme.md
Created November 10, 2022 13:41 — forked from jeremywall/readme.md
R2, CORS, Presigned Put Object URLs, and uploading directly from browser side JavaScript

First and foremost you need to set the CORS configuration for your bucket. I'm a Java developer so here's the code I wrote using the AWS Java SDK v2 to define the CORS configuration for my R2 bucket. Alternatively you can also edit your bucket CORS configuration using Postman following the tutorial at https://kian.org.uk/configuring-cors-on-cloudflare-r2/

// update the config section here with your information first
String bucketName = "YOUR_BUCKET";
String accessKeyId = "YOUR_R2_ACCESS_KEY_ID";
String secretAccessKey = "YOUR_R2_SECRET_ACCESS_KEY";
String accountId = "YOUR_ACCOUNT_ID";
URI uri = new URI("https://" + accountId + ".r2.cloudflarestorage.com");