Skip to content

Instantly share code, notes, and snippets.

View johnsyweb's full-sized avatar

Pete Johns johnsyweb

View GitHub Profile
@natematykiewicz
natematykiewicz / unroutable_routes.rake
Last active June 9, 2022 19:47
Find routes that will raise a routing error when requested
desc 'Find routes that will raise a routing error when requested'
task unroutable_routes: :environment do
# A lot of this code was taken from how `rake routes` works
# https://github.com/rails/rails/blob/f95c0b7e96eb36bc3efc0c5beffbb9e84ea664e4/railties/lib/rails/commands/routes/routes_command.rb
require 'action_dispatch/routing/inspector'
unroutables = Rails.application.routes.routes.
map { |r| ActionDispatch::Routing::RouteWrapper.new(r) }.
reject { |r| r.internal? || r.engine? || r.path.starts_with?('/rails/') || !r.controller }.
@KoryNunn
KoryNunn / handshake-airdrop.md
Last active March 12, 2024 07:03
Handshake airdrop for github users.

Had 15 github followers in 2019? You can get about $4kAUD of crypto for minimal effort.

Explain this scam

That's legitimately a good default position to hold, however, in this case, the free money is a function of time, and not only charity.

In February 2020, in order to promote Handshake (HNS) to developers, an airdrop was offered to any Github user with more than 15 followers. The Airdrop would give you 4246HNS, at the time worth around at $0.08USD per coin, for a total of $339.68USD, pretty generous!

Today, 4246HNS is worth around $4000 dollarydoos, and there are plenty of github users who haven't claimed theirs.

@afgomez
afgomez / git-checkout-branch-fuzzy
Last active April 9, 2023 18:04
FZF git-checkout
#!/bin/bash
branch=`git branch -a | sed 's/^\*//; s/^[ \t]*//; /HEAD.*/d; /^remotes\/origin\/$/d' | fzf --height 40% --border --reverse --preview 'git log --color=always {} -10' | sed 's/remotes\/origin\///'`
if [[ $branch ]]; then
git checkout $branch
fi
@davidlee
davidlee / gist:81dea1165b09b707f7f9982f0940d17b
Last active December 15, 2016 08:19
What do developers mean by "technical debt"?
It has been aptly said that programming is the art of managing
complexity.
A large software project, in the best possible case, is understood as a
researcher understands a library. You may have read a number of the
books, and might even know a few of them intimately. If you want to find
a book – even one you've never seen before – it's usually easy as long
as you know the ISBN, the exact name, or at least the author.
You'll spend most of your time reading though, trying to find a clue or
@davetron5000
davetron5000 / god.rb
Last active August 29, 2015 14:00
Since we don't need TDD anymore, this is the best way to write tests after you've hand-crafted your code to be beautiful
class God < ActiveRecord::Base
has_many :purchases
has_many :orders
has_many :login_attempts
has_many :friends
acts_as_taggable because: "all tags are the same"
scope :alive, -> { where.not(:status => :dead) }
scope :active, -> { where(:inactive => false) }
@seangeo
seangeo / churn histogram
Last active December 28, 2015 20:49
Generate a histogram of file churn in a git repo.
#
# This was created by smashing together two scripts. One from Gary Bernhardt and one from Small Labs.
#
# See also https://github.com/garybernhardt/dotfiles/blob/master/bin/git-churn
# And http://www.smallmeans.com/notes/shell-history/
#
git log --all -M -C --name-only --format='format:' "$@" | sort | grep -v '^$' | uniq -c | sort | awk '{print $1 "\t" $2}' | sort -g | awk '{print $1}' | uniq -c | sort -rn --stable | awk '!max{max=$1;}{r="";i=s=60*$1/max;while(i-->0)r=r"#";printf "%15s files changed %5d times %s %s",$1,$2,r,"\n";}'
@ejoubaud
ejoubaud / sort_ids_by_cat_for_migration.sh
Last active December 17, 2015 02:48
Parses Excel spreadsheets from the review team for big category changes by item ID
# Parse category migrations by ID from Excel files
#
# Just:
# * paste from the spreadsheet into Sublime
# * paste this line in Shell Turtlestein (plugin) invite
# * replace $4 and $1 by $<category_column_index> and $<id_column_index> (1-based index)
#
# Can be easily adapted for VIM, it's just awk
$p-base03: #002b36
$p-base02: #073642
$p-base01: #586e75
$p-base00: #657b83
$p-base0: #839496
$p-base1: #93a1a1
$p-base2: #eee8d5
$p-base3: #fdf6e3
$p-yellow: #b58900
$p-orange: #cb4b16
@colbyr
colbyr / gist:2155434
Created March 22, 2012 03:34
Install Tomcat 6 with Homebrew
cd /usr/local/Library/Formula
git checkout 9e18876 tomcat.rb
brew install tomcat
@sj26
sj26 / README.md
Created January 19, 2012 07:41
Run MailCatcher in the background, always, on OS X

Place me.mailcatcher.plist into ~/Library/LaunchAgents, then run launchctl load ~/Library/LaunchAgents/me.mailcatcher.plist.

If you use pow, echo 1080 > ~/.pow/mailcatcher and go to http://mailcatcher.dev, otherwise use http://localhost:1080.

Currently pow doesn't seem to pass websockets through correctly. Looking into this.