Skip to content

Instantly share code, notes, and snippets.

@tjmcewan
tjmcewan / slack.sh
Created July 18, 2021 11:01 — forked from andkirby/slack.sh
Shell/Bash script for sending slack messages.
#!/usr/bin/env bash
####################################################################################
# Slack Bash console script for sending messages.
####################################################################################
# Installation
# $ curl -s https://gist.githubusercontent.com/andkirby/67a774513215d7ba06384186dd441d9e/raw --output /usr/bin/slack
# $ chmod +x /usr/bin/slack
####################################################################################
# USAGE
# Send message to slack channel/user
@tjmcewan
tjmcewan / easy-copy.js
Created September 6, 2022 16:06
Bookmarklet to copy EasyRetro cards to your clipboard as markdown
javascript:
!(() => document.querySelectorAll('.easy-card-list').length < 1
? window.alert('EasyRetro board columns not found')
: (() => {
/* show all the comments first */
document.querySelectorAll('[aria-label="New comment"]').forEach(el => el.click());
navigator.clipboard.writeText(
[...document.querySelectorAll('.easy-card-list')]
/* for each column: get column header */
.map(l => [`# ${l.querySelector('.column-header').textContent.trim()}\n`]
@tjmcewan
tjmcewan / migration.sql
Last active December 31, 2023 17:13
Supabase Auth Hook for MFA/TOTP/AAL2 account lock
-- create a table to track failed MFA verification attempts
create table if not exists hub_admin.mfa_failed_verification_attempts(
user_id uuid not null references auth.users(id) on delete cascade
, factor_id uuid not null
, failed_at timestamp with time zone not null default now()
, deleted_at timestamp with time zone
);
create index if not exists idx_mfa_failed_verification_attempts_user_id on hub_admin.mfa_failed_verification_attempts(user_id);
-- a database function that takes a jsonb event and returns a jsonb response
@tjmcewan
tjmcewan / Hack Assembler.rs
Last active January 14, 2024 01:45
Hack Assembler in Rust
use std::collections::HashMap;
use std::env;
use std::fs::File;
use std::io::{Read, Write};
fn predefined_symbols() -> HashMap<&'static str, u16> {
let mut symbols: HashMap<&str, u16> = HashMap::new();
symbols.insert("SP", 0);
symbols.insert("LCL", 1);
symbols.insert("ARG", 2);