Skip to content

Instantly share code, notes, and snippets.

View unixmonkey's full-sized avatar

David Jones unixmonkey

View GitHub Profile
@scpike
scpike / incompat_71.rb
Last active February 28, 2024 16:26
Check for silent gem incompatibilities in Rails 7.1
#!/usr/bin/env ruby
# Run like `ruby incompat_71.rb ~/path/to/Gemfile.lock`
# From the team at infield.ai
#
PACKAGES = [['activerecord-import', '1.5.0'],
['anycable-rails', '1.4.1'],
['blazer', '3.0.1'],
['bullet', '7.1.2'],
['data_migrate', '9.2.0'],
['database_cleaner-active_record', '2.1.0'],
@andynu
andynu / show_method_history.rb
Created August 26, 2022 18:56
Given a ruby file and method name shows you all the different versions across the git history.
#!/usr/bin/env ruby
# Given a file and method_name
# Show all the different implementations across the git history (first commit per implementation).
#
# show_method_history <file> <method_name> --html
#
# e.g. show_method_history test/test_helper.rb sign_in --html
#
# WARNING: the --html output just dumps html files into your current folder.
#
@andynu
andynu / gem-bisect
Last active August 17, 2022 06:36
Find the last version that passes the tests by doing a binary search through a range of versions
#!/usr/bin/env ruby
#
# Find the last version that passes the tests by doing
# a binary search through a range of versions
#
# Usage: gem-bisect <gem_name> [<from_version> [<to_version>]]
#
# Example
# ❯ gem-bisect rack-attack 6.3 6.6.1
# Checking versions 6.6.1, 6.5.0, 6.4.0, 6.3.1
@nettofarah
nettofarah / newrelic_instrumenter.rb
Created March 13, 2017 21:46
sample newrelic instrumenter for graphql-ruby
# NewRelic instrumenter for GraphQL-ruby
#
# In your controller:
# ::NewRelic::Agent.add_custom_attributes({
# user_id: @user.try(:id),
# query_string: @query_string,
# query_arguments: @query_variables
# })
#
# @document = self.class.trace_execution_scoped(["GraphQL#parse"]) do
@juanca
juanca / github_load_all_diffs.js
Created March 2, 2017 18:42
Github PR bookmarklet: Load all file diffs
javascript:
document.querySelectorAll('.load-diff-button').forEach(node => node.click())
@lengarvey
lengarvey / staging.rb
Created June 29, 2014 11:28
Enabling Rails 4.1 mail previews in staging (or any other env besides development)
# put this in your staging.rb file. Obviously you'll need more config than this it's just an example.
Rails.application.configure do
config.action_mailer.preview_path ||= defined?(Rails.root) ? "#{Rails.root}/test/mailers/previews" : nil
config.autoload_paths += [config.action_mailer.preview_path]
routes.append do
get '/rails/mailers' => "rails/mailers#index"
get '/rails/mailers/*path' => "rails/mailers#preview"
end
@soulcutter
soulcutter / capyconsole.rake
Created May 5, 2014 14:53
Capyconsole rake task
desc "Launch a Capybara session in a console"
task capyconsole: :environment do
require "capybara"
require "pry"
driver = case ENV.fetch('DRIVER', 'phantomjs')
when 'phantomjs'
require "capybara/poltergeist"
Capybara.register_driver :poltergeist_debug do |app|
@xaviershay
xaviershay / build_frontend.sh
Last active December 24, 2015 20:49
SASS + Coffee + Concatenation in prod
#!/bin/bash
set -exo pipefail
BUILD_ENV=$1
if [ `uname` == 'Darwin' ]; then
OSX=1
JSCOMPRESSOR="yuicompressor --type js"
else
OSX=
OFFERING_TERM_FIELDS = [:loan_interest_rate, :loan_term, :revenue_share_percentage, :revenue_share_term, :revenue_share_return_cap, :revenue_share_payment_frequency, :revenue_loan_target_rate, :revenue_loan_term, :equity_valuation, :equity_percentage_offered]
included do
store :offering_terms, accessors: OFFERING_TERM_FIELDS
end
@SlexAxton
SlexAxton / .zshrc
Last active April 25, 2023 03:57
My gif workflow
gifify() {
if [[ -n "$1" ]]; then
if [[ $2 == '--good' ]]; then
ffmpeg -i $1 -r 10 -vcodec png out-static-%05d.png
time convert -verbose +dither -layers Optimize -resize 600x600\> out-static*.png GIF:- | gifsicle --colors 128 --delay=5 --loop --optimize=3 --multifile - > $1.gif
rm out-static*.png
else
ffmpeg -i $1 -s 600x400 -pix_fmt rgb24 -r 10 -f gif - | gifsicle --optimize=3 --delay=3 > $1.gif
fi
else