Skip to content

Instantly share code, notes, and snippets.

@gma
gma / vscode-auto-format-astro-on-save.md
Last active Apr 26, 2022
Configuring VS Code to format Astro files with Prettier
View vscode-auto-format-astro-on-save.md

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 / pacman.py
Created Sep 16, 2021
Python NW group coding session
View pacman.py
# Pac-man orientation: v < > ∧
# . . .
# .V.
# . . .
grid = [
[1, 1, 1, 1, 1],
@gma
gma / tm.sh
Last active Sep 12, 2021
tm script for launching tmux via fzf
View tm.sh
#!/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 Sep 8, 2021
Script that hits cht.sh with query, results in a new tmux window
View cheat.sh
#!/bin/bash
## Functions
usage()
{
echo "Usage: $(basename $0) <arg> [args...]" 1>&2
exit 1
}
View speedtest.sh
#!/bin/bash
GIGABYTES="${1:-1}"
ITERATIONS="${2:-1}"
MOUNT="/mnt/tank"
sshhh() {
grep -v "+0 records"
}
@gma
gma / build-kernel.sh
Created Apr 30, 2020
Work in progress to build patched Pop kernel
View build-kernel.sh
#!/bin/sh
set -e
apt-get source linux
pushd linux-*
# modify debian.master/changelog at this point
patch -p1 < <(curl URL of patch)
fakeroot debian/rules clean
fakeroot debian/rules binary-headers binary-generic binary-perarch skipmodule=true skipabi=true skipretpoline=true
popd
@gma
gma / x230-screen-and-aspm.patch
Last active Dec 7, 2021
Linux kernel patch for ThinkPad X230 with FHD (1080p) screen mod
View x230-screen-and-aspm.patch
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 / route.js
Created Dec 2, 2019
Stubbing XHR in Cypress
View route.js
import axios from 'axios';
describe('Cypress', function() {
it('stubs a GET request', function() {
cy.server();
const endpoint = 'http://my-api-host/path';
cy.route('GET', endpoint, {
attr: [{ thing: 1234 }]
@gma
gma / mkvenv.sh
Created Oct 19, 2019
function for making Python 3 virtual env
View mkvenv.sh
mkvenv()
{
local prompt="${1:-$(basename $(pwd))}"
shift
command -v deactivate >/dev/null && deactivate
[ -d .venv ] && echo "ERROR: .venv exists" 1>&2 && return 1
python3 -m venv .venv --prompt "\[\033[1;34m\]$prompt\[\033[0m\]" $*
activate
}
@gma
gma / stripe-fixtures-customer-ids.rb
Last active Nov 4, 2016
Creating fixtures for Stripe's JSON events
View stripe-fixtures-customer-ids.rb
customer_events = %w(
charge.captured.json
charge.failed.json
charge.refunded.json
charge.succeeded.json
charge.updated.json
customer.card.created.json
customer.card.deleted.json
customer.card.updated.json
customer.created.json