Skip to content

Instantly share code, notes, and snippets.

@caseywatts
caseywatts / README.md
Last active July 14, 2025 19:24
Auto-generating aasm-diagram from Rails models

How can we automate generation of AASM diagrams, so our documentation will always be up to date with our code?

This gist does two main things that the aasm-diagram repo doesn't do on its own as of today (May 2025):

  1. Finds all of the uses of aasm in our Rails models itself, so we don't have to list them out
  2. Updates a markdown file that embeds each of the AASM diagrams

When should we generate this?

rails-erd uses database migrations as the moment to auto-generate an ERD diagram, which makes a ton of sense!

@roycewilliams
roycewilliams / mastodon-filter-backup.sh
Last active January 23, 2025 06:57
a simple Mastodon filter JSON backup script
#!/bin/bash
# Ref/howto: https://infosec.exchange/@tychotithonus/110838547200953177
INSTANCE_NAME=inst.example
TOKEN=your-token-here
DATESTAMP=$(date "+%Y%m%d_%H%M%S")
OUTFILE="mastodon-filters_${INSTANCE_NAME}_${DATESTAMP}.json"
@prologic
prologic / LearnGoIn5mins.md
Last active January 13, 2026 22:47
Learn Go in ~5mins
@claraj
claraj / git_submodule_fix.md
Last active March 3, 2026 23:37
Fixing git submodule AKA git repo inside another git repo

Problem, and symptoms:

You experience one or more of these symptoms

  • you have code in a directory but it's not being pushed to GitHub. You just see an empty directory icon
  • you see this message when you add code to your git repository from the command prompt
hint: You've added another git repository inside your current repository.
hint: Clones of the outer repository will not contain the contents of
hint: the embedded repository and will not know how to obtain it.
@VirtuBox
VirtuBox / microsoft-dns-block.txt
Last active March 15, 2026 04:59
Blocking Microsoft DNS hosts file
0.0.0.0 feedback.microsoft-hohm.com
0.0.0.0 search.msn.com
0.0.0.0 a.ads1.msn.com
0.0.0.0 a.ads2.msn.com
0.0.0.0 a.rad.msn.com
0.0.0.0 ac3.msn.com
0.0.0.0 ads.msn.com
0.0.0.0 ads1.msn.com
0.0.0.0 b.ads1.msn.com
0.0.0.0 b.rad.msn.com
@jameswpm
jameswpm / pomodoro.sh
Last active December 27, 2023 15:53
Minimalistic Pomodoro Timer
#!/bin/bash
#
# Minimalistic_Pomodoro_Timer
#
# Based on the SU answer found here: https://superuser.com/questions/224265/pomodoro-timer-for-linux/669811#669811
#
# Tested in Ubuntu 16.04 and Arch
pomodorotime () {
notify-send "Time to Work" "Focus" -u normal -a 'Pomodoro' -i $HOME/Documentos/icon.png
paplay /usr/share/sounds/freedesktop/stereo/window-attention.oga
@lin-brian-l
lin-brian-l / download-repos.rb
Last active December 2, 2021 03:05
Clone all repos within an organization and pull all branches.
# Run 'gem install octokit' in terminal first
# 'getAllBranches.sh' and 'download-repos.rb' should be in the same directory.
# Run this file using 'ruby download-repos.rb' in your terminal.
# Organization name can be changed on line 29.
# Credits to @klkelley for writing the code upon which this was based (https://gist.github.com/klkelley/20fe2c35836110589966edd82772f5ca)
require 'Octokit'
require 'io/console'
def get_username
@ChrisChares
ChrisChares / AsyncAwaitGenerator.md
Last active September 30, 2022 13:26
async/await with ES6 Generators & Promises

async/await with ES6 Generators & Promises

This vanilla ES6 function async allows code to yield (i.e. await) the asynchronous result of any Promise within. The usage is almost identical to ES7's async/await keywords.

async/await control flow is promising because it allows the programmer to reason linearly about complex asynchronous code. It also has the benefit of unifying traditionally disparate synchronous and asynchronous error handling code into one try/catch block.

This is expository code for the purpose of learning ES6. It is not 100% robust. If you want to use this style of code in the real world you might want to explore a well-tested library like co, task.js or use async/await with Babel. Also take a look at the official async/await draft section on desugaring.

Compatibility

  • node.js - 4.3.2+ (maybe earlier with