til

2025

Nov 5

command to get just the changed files from git and run in rubocop:

git ls-files -m | xargs ls -1 2>/dev/null | grep '\.rb$' | xargs rubocop
Apr 17

if you need to inject a message into a wall of text printed to the screen, like when starting jekyll or astro or rails server, you can read lines and print it at the appropriate time.

#!/bin/bash

pnpm run dev | while read line
do
  echo "$line"
  if [[ "$line" == *"Local"* ]]; then
    echo "✅ Your site is live! 🎉"
  fi
done

2024

Jan 22

Interesting links from week 3 of 2024.

Here are some interesting things I’ve found this week. I’m just getting started with this, so it may be a slow ramp up.

Elixir

TIL

Jan 19

Running mix ecto.dump creates a structure.sql file in ./priv/repo.

This is easy to forget to keep updated, so one easy way is to add this in the aliases() function in mix.exs:

"db.migrate": ["ecto.migrate", "ecto.dump"]
"db.rollback": ["ecto.rollback", "ecto.dump"]
Jan 19

I keep forgetting how to change the remote for a git repo.

1) View existing remotes

git remote -v
origin https://github.com/user/repo.git (fetch) origin https://github.com/user/repo.git (push)

2) Change the ‘origin’ remote’s URL

git remote set-url origin https://github.com/user/repo2.github

3) Verify new remote URL

git remote -v
origin https://github.com/user/repo2.git (fetch) origin https://github.com/user/repo2.git (push)
Jan 19

How to get a random number in Elixir.

iex(1)> :rand.uniform(6)

iex(2)> Enum.random(1..6)

Sometimes you need a unique integer, and of course Elixir has you covered. This is very useful for Factories if you want to implement something like sequences to avoid errors due to database unique constraints.

iex(1)> System.unique_integer(~w[monotonic positive]a)
1
iex(2)> System.unique_integer(~w[monotonic positive]a)
2
iex(3)> System.unique_integer(~w[monotonic positive]a)
3

2022

Jul 18

Another css example I want to hang on to.

It’s pushable!

Code:

<button
  class="mb-4 p-2 w-32 transition ease-in-out duration-100 outline outline-1 shadow-[0_5px_0px_0px_rgba(0,0,0,0.6)] active:shadow-none active:translate-y-1 "
>
  pushable button
</button>

There’s a lot of more examples at Josh Comeau’s site and hnldesign

Jul 17

quick example of some css tailwind stuff when hovering over an image