Skip to content

Instantly share code, notes, and snippets.

View mortenson's full-sized avatar
💧
Did you try to clear cache?

Samuel Mortenson mortenson

💧
Did you try to clear cache?
View GitHub Profile
@mortenson
mortenson / example_alpine_autocomplete.sfc
Created July 8, 2020 14:04
Drupal single file components livewire demo
<!--
This is a complex but realistic example of how you might use frameworks like
Alpine.js and dom-diffing libraries like morphdom to create components that
are re-rendered server-side. This example is heavily influenced by Livewire.
In production, it might make more sense for just the dynamic part of the
component to be AJAX-ified, in this case that would probably mean making the
autocomplete results their own component. There are lots of ways to do this!
-->
@mortenson
mortenson / composelist.sh
Last active March 21, 2025 05:46
List all Docker Compose projects currently running
#!/bin/bash
docker ps --filter "label=com.docker.compose.project" -q | xargs docker inspect --format='{{index .Config.Labels "com.docker.compose.project"}}'| sort | uniq
@mortenson
mortenson / create_migration.go
Last active July 28, 2024 13:03
Create sqlc migrations automatically using pg-schema-diff
package main
import (
"context"
"database/sql"
"flag"
"fmt"
"os"
"path/filepath"
"strings"
@mortenson
mortenson / manifest.json
Last active May 24, 2024 09:07
Another simple chrome extension to track your YouTube watch time
{
"manifest_version": 3,
"name": "count daily youtube watch time",
"description": "made by sam",
"version": "0.0.1",
"content_scripts": [
{
"matches": [
"https://www.youtube.com/*"
],
@mortenson
mortenson / sams_portland_stuff.md
Last active May 7, 2024 17:34
Sam's fun things to do in Portland

Portland recommendations by Sam

Sorted by location-ish. I tried to reduce the list to places I think are good for visitors vs. my absolute favorites, but I put a section at the bottom for places that may not be for everyone.

Breakfast / Brunch

Toki Restaurant (Downtown)

580 SW 12th Ave

My order: Grilled mackerel breakfast with a bloody mary. Their Dalgona coffee is quite good too.

@mortenson
mortenson / test-migrations.sh
Last active January 4, 2024 00:21
Example script that tests if migrations added in current working tree will break tests when applied to master. Good for PRs but can be used locally "safely"
#! /bin/bash
# Assumes migrations are stored in ./db/migrations as single files.
# Also assumes migrations are in (alphanumeric) order.
set -e
rm -rf /tmp/test-migrations
mkdir /tmp/test-migrations
cp -r db/migrations/* /tmp/test-migrations/
@mortenson
mortenson / wait-for-render.sh
Created January 2, 2024 00:33
Bash script to wait for the given Render services to finish deploying. Useful for triggering deploy hooks sequentially, or tracking deploy status in GitHub actions.
#! /bin/bash
# RENDER_SERVICE_NAMES should be a newline-separated list of service IDs (ex: srv-...)
# RENDER_API_TOKEN is your personal Render API token
max_attempts=200
while IFS= read -r RENDER_SERVICE_NAME; do
echo "Checking $RENDER_SERVICE_NAME ..."
attempt_counter=0
@mortenson
mortenson / block.js
Last active December 18, 2023 19:15
Very simple and stupid chrome extension to block arbitrary sites
document.body.innerHTML = 'get back to work'
@mortenson
mortenson / notes.md
Last active August 26, 2023 03:35
Dell XPS 13 9300 Ubuntu setup notes

Random notes from woring with a new XPS 13 9300 with Ubuntu

Notes from when I was on the default Dell OEM Ubuntu

Disable trackpad middle click:

sudo vim /usr/share/X11/xorg.conf.d/40-libinput.conf

Add Option "ButtonMapping" "1 1 3 4 5" under

@mortenson
mortenson / composer.json
Last active August 20, 2023 10:39
Example composer.json file for File Browser
{
"name": "mortenson/example",
"minimum-stability": "dev",
"authors": [
{
"name": "Samuel Mortenson",
"email": "samuel.mortenson@acquia.com"
}
],
"repositories": [