Skip to content

Instantly share code, notes, and snippets.

class MyMixinClass:
@classmethod
def share_me_about_a_bit(cls):
pass
def share_me_too(self):
pass
class Shape:
@gma
gma / insane-magic.spec
Last active September 13, 2022 17:18
What's so bad about RSpec?
require 'rspec'
describe 'Rspec' do
it 'should not allow you to make shit up' do
[1, 2, 3].should have(4).potatoes
end
end
@gma
gma / vscode-auto-format-astro-on-save.md
Last active April 26, 2022 11:08
Configuring VS Code to format Astro files with Prettier

Configuring VS Code to format Astro files with Prettier

There's an Astro extension for VS Code that provides syntax highlighting, completion and emmet support, but as of April 2022 it doesn't support auto-formatting.

There's a prettier plugin for Astro. We can install that and then configure VS Code to run Prettier when we save a file.

Installing prettier

Let's start by installing prettier and the Astro plugin into our project:

npm install -D prettier prettier-plugin-astro
@gma
gma / x230-screen-and-aspm.patch
Last active December 7, 2021 05:02
Linux kernel patch for ThinkPad X230 with FHD (1080p) screen mod
diff -aur linux-5.13.0/drivers/acpi/pci_root.c linux-5.13.0-x230/drivers/acpi/pci_root.c
--- linux-5.13.0/drivers/acpi/pci_root.c 2021-09-14 20:19:11.000000000 +0100
+++ linux-5.13.0-x230/drivers/acpi/pci_root.c 2021-09-18 10:33:18.099360328 +0100
@@ -508,7 +508,6 @@
* flag here, to defer the action until after the ACPI
* root scan.
*/
- *no_aspm = 1;
}
}
@gma
gma / pacman.py
Created September 16, 2021 18:33
Python NW group coding session
# Pac-man orientation: v < > ∧
# . . .
# .V.
# . . .
grid = [
[1, 1, 1, 1, 1],
@gma
gma / tm.sh
Last active September 12, 2021 21:07
tm script for launching tmux via fzf
#!/bin/sh
TM_ROOT="${TM_ROOT:-$HOME/Projects}"
TM_DEPTH=${TM_DEPTH:-4}
TM_PROJECT_CONTAINS="${TM_PROJECT_CONTAINS:-.git}"
TM_CRITERIA="${TM_CRITERIA:--type d -name $TM_PROJECT_CONTAINS}"
TM_FILTER="${TM_FILTER:-cat}"
TM_EDITOR="${TM_EDITOR:-vi -c 'set number relativenumber'}"
## Functions
@gma
gma / cheat.sh
Created September 8, 2021 22:18
Script that hits cht.sh with query, results in a new tmux window
#!/bin/bash
## Functions
usage()
{
echo "Usage: $(basename $0) <arg> [args...]" 1>&2
exit 1
}
#!/bin/bash
GIGABYTES="${1:-1}"
ITERATIONS="${2:-1}"
MOUNT="/mnt/tank"
sshhh() {
grep -v "+0 records"
}
@gma
gma / soc-to-the-max.rb
Created July 17, 2012 09:55 — forked from rlivsey/soc-to-the-max.rb
Separation of concerns sketch
class TasksController < ApplicationController
def complete
# add responder as listener, or could subscribe etc...
# task could be the actual task, or pass through the ID
task.add_subscriber(TaskCompletedResponse.new(self))
task.add_subscriber(TaskEmail.new)
task.add_subscriber(TaskIndex)
task.complete_by(person)
end
@gma
gma / sync-staging-database.sh
Created February 14, 2014 10:37
Copy production backup to staging (Heroku)
#!/bin/bash
PRODUCTION_REMOTE="production"
STAGING_REMOTE="staging"
STAGING_DATABASE_NAME="HEROKU_POSTGRESQL_COBALT"
## Functions
reset_staging_database()
{