Skip to content

Instantly share code, notes, and snippets.

View trvrfrd's full-sized avatar
👹

Trevor Ford trvrfrd

👹
View GitHub Profile
@searls
searls / rails_bisect_step
Created February 1, 2023 20:34
Used in conjunction with [this script](https://gist.github.com/searls/5c6b77213dbc7202ca39f4e70d975eee) to make it easier to git bisect rails apps whose database changes during the affected sha range
#!/usr/bin/env bash
# Usage:
#
# First, be sure you're running `git bisect start --no-checkout`, so you can
# checkout the bisect head yourself and do some pre-flight stuff like rewind
# migrations
#
# $ git bisect good
# Bisecting: 22 revisions left to test after this (roughly 5 steps)
#!/usr/bin/env bash
# Useful when you want to git bisect in a rails app and know
# you need to `bin/rake db:migrate VERSION="SOMETHING"` before
# you check out the next commit so the database is in the right
# state, but you don't know what SOMETHING is.
# Usage:
#
# $ migration_version_at_ref <REF>
# Okasaki style Functional Red Black Tree
# https://www.cs.tufts.edu/comp/150FP/archive/chris-okasaki/redblack99.pdf
#
# leaves and root are black
# BST
# No red node has a red child
# Every path from the root to a leaf has the same number of black nodes
module RBTree
class Leaf
@conor-f
conor-f / github_heatmap_writer.py
Last active February 27, 2023 04:00
This script will let you write short phrases on your Github contributions heatmap on your profile for a particular year.
### github_heatmap_writer.py
#
# Overview:
# This script will let you write short phrases on your Github contributions
# heatmap on your profile for a particular year. It does this by modifying the
# commit date/time.
#
# Usage:
# - Make a Github repo (public or private) and clone it locally.
# - Modify this script to specify what year you want to display on and what
@infews
infews / be.rb
Last active July 5, 2021 22:51
a "better" be "alias" for bundle exec, prioritizing local binstubs
#!/usr/bin/env ruby
# Smarter be for ruby projects that prioritizes local project binstubs
# - uses zsh when needed, assuming MacOS Catalina or later
# - save on your path
# - drop the .rb
# - chmod +x
# - always type `be <command>` and the right thing should happen
#
# - inspired by Justin Searls (@searls)
@tomhicks
tomhicks / sweep-swoop.js
Last active December 10, 2021 10:02
Listen to your web pages
const audioCtx = new window.AudioContext();
const oscillator = audioCtx.createOscillator();
oscillator.connect(audioCtx.destination);
oscillator.type = "sine";
let numItems = 0
oscillator.frequency.setValueAtTime(
1,
audioCtx.currentTime
@tomhicks
tomhicks / plink-plonk.js
Last active March 18, 2024 02:23
Listen to your web pages

Here's a neat trick.

I treat my git clones as disposable between computers, but keep my project-specific dotfiles (usually containing environment variables, individual configurations, and so on) synced across devices in iCloud. Then, this script is just a matter of adding symlinks for each of the dotfiles I've saved for each of my projects to each of their clones.

So if my dotfiles are saved like this:

$ tree -a ~/icloud-drive/dotfiles/project-dotfiles/
/Users/justin/icloud-drive/dotfiles/project-dotfiles/
├── searls
@munificent
munificent / generate.c
Last active May 14, 2024 05:30
A random dungeon generator that fits on a business card
#include <time.h> // Robert Nystrom
#include <stdio.h> // @munificentbob
#include <stdlib.h> // for Ginny
#define r return // 2008-2019
#define l(a, b, c, d) for (i y=a;y\
<b; y++) for (int x = c; x < d; x++)
typedef int i;const i H=40;const i W
=80;i m[40][80];i g(i x){r rand()%x;
}void cave(i s){i w=g(10)+5;i h=g(6)
+3;i t=g(W-w-2)+1;i u=g(H-h-2)+1;l(u
@amrabdelwahab
amrabdelwahab / Research.md
Last active July 1, 2021 19:43
What is wrong with Ruby Project

What is wrong with Ruby? - Research project

Introduction

Our industry has a tendency to follow hypes without backing it with solid constructive claims. Over the past few years, trashing Ruby was one of these hypes, I also find that the so called "Senior Engineers" tend to promote hypes to appear more opinionated without really trying to explain the logical claims behind it, leaving the community beginners and new joiners really confused.

Goals of the project

  • Solidifying the claims behind the hype (Because I believe it stems from real problems, not just an empty hype) and eventually passing this to Ruby core team as an input from the community.
  • Explain these problems in a much simpler language to beginners and community new joiners.

Initial Focal points