Skip to content

Instantly share code, notes, and snippets.

:shipit:
Focusing

Jay Dorsey jaydorsey

:shipit:
Focusing
Block or report user

Report or block jaydorsey

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View pry_instance.rb
# This file lives in the pry gem. This patch strips out backtrace information from the gems, so I
# only see _my_ code files related to an error when I'm in a pry session
#
# Replace the content in the begin block inside the +show_result+ method
#
# @todo Make this a separate gem that I can install to patch this method without having to edit my
# bundled pry gem
relevant_context = e.backtrace.reject { |b| b =~ /(ruby\/gem)|(asdf\/installs)/ }
output.puts "(pry) output error: #{e.inspect}\n\nRelevant files:\n\n#{relevant_context.join("\n")}\n\n"
@jaydorsey
jaydorsey / Aptfile
Last active Oct 15, 2019
Notes on Poppler/ActiveStorage on Heroku
View Aptfile
libgirepository-1.0-1
libgirepository1.0-dev
libpoppler-glib-dev
@jaydorsey
jaydorsey / gist:6221c3e93f6ce114db772bcc3bdc628b
Created Aug 18, 2019
Generate rdoc documentation for local gems
View gist:6221c3e93f6ce114db772bcc3bdc628b
# Generates docs
gem list | awk '{ print $1 }' | xargs gem rdoc
# Starts server
gem server
View gist:3a5397c24955ec8788828eb364682448
{
"$schema": "http://json-schema.org/draft-04/schema#",
"definitions": {
"attributes": {
"additionalProperties": false,
"description": "Members of the attributes object (\"attributes\") represent information about the resource object in which it's defined.",
"patternProperties": {
"^(?!relationships$|links$)\\w[\\w_-]*$": {
"description": "Attributes may contain any valid JSON value."
}
@jaydorsey
jaydorsey / bug_report.rb
Last active Jul 26, 2019
jsonapi-resources bug report
View bug_report.rb
begin
require 'bundler/inline'
require 'bundler'
require 'pry'
require 'pry-byebug'
rescue LoadError => e
STDERR.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
View tmux-cheatsheet.markdown

tmux shortcuts & cheatsheet

start new:

tmux

start new with session name:

tmux new -s myname
@jaydorsey
jaydorsey / remove.js
Created Nov 19, 2018
Scummy facebook advertisers
View remove.js
// Automatically clicks the "Remove" button for all the advertisers
// that are showing from this page: https://www.facebook.com/ads/preferences/?entry_product=ad_settings_screen
// under the "Advertisers who you've interacted with" (who I actually have never
// interacted with), "Who use a contact list added to facebook" (that they likely
// bought 2nd hand because I've never done business with them)
//
// Click the "More" button multiple times to display them all, then run this script
var buttons = document.querySelectorAll("[data-tooltip-content='Remove']");for (i = 0; i< buttons.length; i++) { buttons[i].click();};
@jaydorsey
jaydorsey / post-receive
Created Nov 2, 2018
Notify of file changed after git pull
View post-receive
#!/bin/sh -eu
# This file goes in .git/hooks/post-receive
if git diff-tree --name-status -t -r --root HEAD | grep -q 'development.sql'
then
echo "Your db/data/development.sql file changed. You may want to run rails gs:load"
fi
@jaydorsey
jaydorsey / factory_doctor.rb
Last active Oct 17, 2018 — forked from palkan/factory_doctor.rb
FactoryDoc: detect useless data generation in tests
View factory_doctor.rb
module FactoryGirl
module Doctor
module FloatDuration
refine Float do
def duration
t = self
format("%02d:%02d.%03d", t / 60, t % 60, t.modulo(1) * 1000)
end
end
end
@jaydorsey
jaydorsey / update_gems.sh
Created Jul 12, 2018
Update all your local gems
View update_gems.sh
# Don't run this unless you know why you're running this
gem outdated | awk '{print $1}' | xargs gem update $1
You can’t perform that action at this time.