Skip to content

Instantly share code, notes, and snippets.

View martijnarts's full-sized avatar
🏳️‍🌈
Living my best life

Martijn Arts martijnarts

🏳️‍🌈
Living my best life
View GitHub Profile
@martijnarts
martijnarts / proof.md
Last active October 24, 2023 13:10
AST proof

aspe:martijnarts.com:XYN5VR5KPKSK7CXLPD4S5ITHLI

@martijnarts
martijnarts / clean-dbs.sh
Created October 14, 2023 22:04
Clean up Zero2Prod (UUID) testing databases
#!/usr/bin/env bash
LAST_WEEK_SEC="$(date -j -v-1w +'%s')"
psql -tc "SELECT json_build_object('date', (pg_stat_file('base/'||oid ||'/PG_VERSION')).modification AT TIME ZONE 'UTC', 'databaseName', datname) FROM pg_database" \
| jq -r --arg LAST_WEEK_SEC "$LAST_WEEK_SEC" '
[inputs]
| map(
select(
.databaseName
@martijnarts
martijnarts / spider.ts
Created September 14, 2023 09:44
Spider operator
interface Result<
// these types need to extend object, or they won't have props to access.
Ok extends object,
Err extends object
> {
map<NewOk extends object>(cb: (e: Ok) => NewOk): Result<NewOk, Err>;
mapErr<NewErr extends object>(cb: (e: Err) => NewErr): Result<Ok, NewErr>;
unwrapOk(): Ok | never;
unwrapErr(): Err | never;
[𐳱]: {
@martijnarts
martijnarts / CHANGE_GITHUB_DEFAULT_BRANCH.md
Last active June 17, 2020 15:43
Change Github repository default branches from CLI

Change Github repository default branches from CLI

⚠ These scripts perform DESCTRUCTIVE actions on your Github repositories. I strongly recommend against using this if you don't understand what the code does.

Will create a new branch on Github and change the default branch to it, and then delete the old one. You'll need JQ and the Github CLI for this.

@martijnarts
martijnarts / git-stats.sh
Last active December 8, 2015 14:55
Git commands by usage
history | awk '{ if ($2 == "git") print $3 }' | sort | uniq -c | sort -bgr
### Keybase proof
I hereby claim:
* I am TotempaaltJ on github.
* I am totem (https://keybase.io/totem) on keybase.
* I have a public key whose fingerprint is EB52 570E 744B 6347 0B2D 6BD2 63D1 3203 8086 9004
To claim this, I am signing this object:
@martijnarts
martijnarts / storytime.py
Created May 21, 2013 09:44
A very simple script I wrote after I'd seen a script my friend made in Pascal. It was so ugly I had to redo it.
import random
DICE = (
('lightbulb', 'speech bubble', 'arrow', 'someone sleeping', 'house',
'clock'),
('lightning bolt', 'walking stick', 'mobile phone', 'alien', 'scales',
'pointer arrow'),
('turtle', 'dice', 'hand', 'scary shadow', 'dung beetle',
'magnifying glass'),
('bee', 'crescent moon', 'bridge', 'wand', 'book', 'abacus'),
@martijnarts
martijnarts / supervisord.conf
Created April 29, 2013 01:33
nginx, Supervisor, uWSGI and Flask: config samples for nginx and Supervisor.
; Change {domain} to your domain name (or whatever you want to call the program)
; Change {modulename} to the Python module where you create your Flask app (for example, run if your file is called run.py)
; Change {website_root} to the directory wherever this module is located (/home/user/website/, for example)
[program:{domain}]
command=/usr/bin/uwsgi
--socket=/home/uwsgi/{domain}.sock
--pythonpath=/
--touch-reload=/app.wsgi
--chmod-socket=664
--uid=uwsgi