Skip to content

Instantly share code, notes, and snippets.

@lukeramsden
lukeramsden / renew-gpgkey.md
Created September 24, 2023 17:13 — forked from krisleech/renew-gpgkey.md
Renew Expired GPG key

Renew GPG key

Given that your key has expired.

$ gpg --list-keys
$ gpg --edit-key KEYID

Use the expire command to set a new expire date:

@lukeramsden
lukeramsden / DslInterpreter.java
Created May 16, 2023 22:24
GPT's example of a test DSL
public class DslInterpreter {
private final EcommerceSystem system = new EcommerceSystem();
public void interpret(String script) {
String[] lines = script.split("\n");
for (String line : lines) {
String[] parts = line.split(" ");
switch (parts[0]) {
case "createUser":
system.createUser(parts[1]);
@lukeramsden
lukeramsden / midString.sql
Created June 24, 2020 08:01
PL/pgSQL implementation of a LexoRank-style lexicographical rank generator function
-- https://stackoverflow.com/questions/38923376/return-a-new-string-that-sorts-between-two-given-strings
create or replace function app_public.mid_string(prev text, next text) returns text as $$
declare
v_p int;
v_n int;
v_pos int := 0;
v_str text;
begin
LOOP -- find leftmost non-matching character
v_p := CASE WHEN v_pos < char_length(prev) THEN ascii(substring(prev from v_pos + 1)) ELSE 96 END;
@lukeramsden
lukeramsden / keybase.md
Created September 18, 2019 20:49
Keybase proof

Keybase proof

I hereby claim:

  • I am lukeramsden on github.
  • I am lukeramsden (https://keybase.io/lukeramsden) on keybase.
  • I have a public key whose fingerprint is D1F1 56D9 39EE AF22 6620 F70A B9E6 4DE9 AAB8 7659

To claim this, I am signing this object:

@lukeramsden
lukeramsden / prog.py
Created May 17, 2019 12:06
2019 May/June CIE IGCSE 0478/21 Pre-release Tasks
day_names = ['Monday', 'Tuesday', 'Wednesday', 'Thursday', 'Friday']
short_day_names = list(map(lambda d: d[:3], day_names))
route_names = ['Bus A', 'Bus B', 'Bus C', 'Bus D', 'Bus E', 'Bus F']
supplied_data = {
0: { # week 1
day_names[0]: [0, 0, 2, 1, -1, 0], # monday
day_names[1]: [0, 1, 0, 0, -1, -5], # tuesday
day_names[2]: [0, 0, -1, 0, -1, -5], # wednesday
day_names[3]: [2, 0, -1, 0, -2, -5], # thursday
day_names[4]: [2, 1, -2, 0, -4, -4] # friday
@lukeramsden
lukeramsden / EMS_SHIPPING.gs
Created April 8, 2019 17:11
EMS Shipping Calculator
/**
* Calculates shipping cost to ship X grams with EMS.
* @param {Range} range Range or cell containing the shipping weights.
* @param {Number} firstCost Cost of first interval. (Default 20.91)
* @param {Number} additionalCost Cost of additional intervals. (Default 6.31)
* @param {Number} interval Interval size. (Default 500)
* @return Shipping cost in USD.
* @customfunction
*/
function EMS_SHIPPING(range, firstCost, additionalCost, interval) {
@lukeramsden
lukeramsden / README.md
Last active December 3, 2018 16:50
screenFetch custom lines
@lukeramsden
lukeramsden / README.md
Last active August 2, 2018 13:04 — forked from bartoszmajsak/prepare-commit-msg.sh
How to automatically prepend git commit with a branch name
curl https://gist.githubusercontent.com/lukeramsden/81e029be19a686261dda4204c8002873/raw/bff6973325b159254a3ba13c5cb9ac8fda8e382b/prepare-commit-msg.sh > ~/.git-hooks/prepare-commit-msg
chmod u+x ~/.git-hooks/prepare-commit-msg
git config --global core.hooksPath ~/.git-hooks
@lukeramsden
lukeramsden / index.js
Last active April 15, 2022 14:04
Accept All Steam Trade Offers With Steam Inventory Helper
// http://jsfiddle.net/dandv/47cbj/
function RateLimit(fn, delay, context) {
var queue = [], timer = null;
function processQueue() {
var item = queue.shift();
if (item)
fn.apply(item.context, item.arguments);
if (queue.length === 0)
clearInterval(timer), timer = null;
@lukeramsden
lukeramsden / README.md
Last active May 22, 2018 10:24
ZSH function to commit to Git

Usage:

commit                      # opens default editor for commit message
commit updated readme.md    # commits with message "updated readme.md"