Skip to content

Instantly share code, notes, and snippets.

@squarism
squarism / cli_replacements.md
Last active April 8, 2024 16:39
Modern CLI Replacements

There are a few lists already, I thought I'd create another one so we can have a long list of lists someday. 🤠 Ordered by approximately which ones I actually use often.

Modern CLI Replacements

  • zoxide - A smarter cd command. Supports all major shells.
  • mcfly - Fly through your shell history. Great Scott!
  • Procs - A modern replacement for ps written in Rust
  • sd - Intuitive find & replace CLI (sed alternative)
  • dust - A more intuitive version of du in rust
  • hyperfine - A command-line benchmarking tool
@squarism
squarism / stop_sms_spam_on_ios.md
Last active February 15, 2024 19:29
How to send STOP to SMS spam using iOS automation

Credit to Time Johnsen

How to Automatically Reply Stop to SMS Spam

  1. Open Shortcuts
  2. Click the bottom tab Automation at the bottom center. It's not Shortcuts, it's Automation.
  3. Create a new Automation using + at the top. This will open Personal Automation and you'll be looking at a list.

image

@squarism
squarism / alice_has_a_ball.txt
Last active December 19, 2023 17:40
Demonstrating what a machine learning evaluation is like.
Ground Truth is me, a human, asserted the answer. GPT 4.0 did 10/10 (over ChatGPT voice on the mobile app no less).
This is a really terrible ML eval, it's accuracy only. The more real version of this would be hundreds of questions,
lots of data and lots of work. If you aren't putting the work in then your users are. It's the same as functional
testing except with a new-ish data concept, many things in AI/ML are like this. The data is the foreign part to general
software dev.
Perplexity is https://labs.perplexity.ai/
@squarism
squarism / lockrebase_demo.md
Created December 5, 2023 19:31
lockrebase Demo

Creating a Merge Conflict on Purpose

For this demo, we will be using node/javascript and NPM, only because it is sort of a lingua franca.

Let's create a merge conflict. It's pretty easy to do.

  1. Fork a branch, add a dependency.
  2. On the main branch, add another dependency.
  3. Now the poor person on the feature branch will get a merge conflict on the lock file when they "catch up on main".
@squarism
squarism / preseed.txt
Last active November 2, 2023 20:18
A debian 12 preseed
#_preseed_V1
# <CHECK_THIS>
d-i debian-installer/locale string en_US
d-i keyboard-configuration/xkb-keymap select us
@squarism
squarism / client.rb
Created September 14, 2023 16:35
Ruby DRB quicksummary
require 'drb/drb'
DRb.start_service
remote = DRbObject.new_with_uri("druby://localhost:8787")
remote.pid
# => <some pid>
# you can verify the PIDs with top and you can filter by process name like ruby or irb or something
@squarism
squarism / postgres_15_prisma.sh
Last active July 31, 2023 18:15
Postgres 15.x development databases setup with Prisma
# Things have changed in postgres 15.x+
$ createdb -O <your shell uid> foo_dev
$ createuser foo
$ psql
psql> grant all privileges on database foo_dev to foo;
psql> alter user foo with encrypted password 'random-password';
# enter the database that you just created
@squarism
squarism / main.rs
Last active June 3, 2023 17:55
Railroad Error Handling in Rust
// User password resets could benefit from railroad error handling
// because there are so many things to go wrong along the way
//
// 1. I forgot my password, send me a link
// 2. I got the link, let me enter a new password
// 3. Password and confirmation must match
// 4. Password must be at least 8, etc
// 5. Password was saved successfully
//
// There are many things that can go wrong and having a transaction
@squarism
squarism / .gitlab-ci.yml
Created May 30, 2023 21:37
Gitlab and Vitest Code Coverage with c8
# stages:
# - whatever
# - test
vitest:
stage: test
script:
# assuming scripts: has "test": "vitest" ...
# run your tests with coverage output
- npm test -- run --coverage
@squarism
squarism / main.rs
Created May 28, 2023 20:30
Mocking in Rust with a working mockall example
#[cfg(test)]
use mockall::{automock, predicate::*};
pub struct Visa {}
#[cfg_attr(test, automock)]
pub trait Chargable {
fn charge_credit_card(&self) -> u32;
}