Skip to content

Instantly share code, notes, and snippets.

Avatar

Jared Beck jaredbeck

View GitHub Profile
View pt_issue_594_fixed.rb
# https://github.com/airblade/paper_trail/issues/594
# Use this template to report PaperTrail bugs.
# It is based on the ActiveRecord template.
# https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_gem.rb
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
@jaredbeck
jaredbeck / route_diff.rb
Created Oct 10, 2017
A better way to diff the before/after output of rake routes
View route_diff.rb
#!/usr/bin/env ruby
# frozen_string_literal: true
# Usage:
#
# ```
# bin/rake routes > tmp/routes_before
# # edit routes.rb
# bin/rake routes > tmp/routes_after
# bin/dev/route_diff.rb tmp/routes_before tmp/routes_after
View ccc_pr_427.rb
begin
require 'bundler/inline'
rescue LoadError => e
$stderr.puts 'Bundler version 1.10 or later is required. Please update your Bundler'
raise e
end
gemfile(true) do
source 'https://rubygems.org'
gem 'rails', '5.1.0' # use correct rails version
View abcd.sql
drop table if exists d;
drop table if exists c;
drop table if exists b;
drop table if exists a;
create table a (
id int not null auto_increment,
primary key (id)
);
View pt_issue_926.rb
# Use this template to report PaperTrail bugs.
# Please include only the minimum code necessary to reproduce your issue.
require "bundler/inline"
# STEP ONE: What versions are you using?
gemfile(true) do
ruby "2.3.3"
source "https://rubygems.org"
gem "activerecord", "4.2.7.1"
gem "minitest", "5.9.0"
View pt_issue_685.rb
# Use this template to report PaperTrail bugs.
# It is based on the ActiveRecord template.
# https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_gem.rb
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
@jaredbeck
jaredbeck / gist:ebfb3a2b579a5ed61ebf80edcdbb3e76
Last active Apr 11, 2016
yaml 356 bytes, json 346 bytes
View gist:ebfb3a2b579a5ed61ebf80edcdbb3e76
# with YAML
# ------------
irb(main):005:0> Widget.create(name: "asldkfj", a_text: "lsdkjflskdjf", an_integer: 11341, a_float: 1.3214, a_decimal: 14.31424, a_datetime: DateTime.new(), a_time: Time.current, a_date: Date.new(2016, 4, 11))
(0.1ms) begin transaction
SQL (0.4ms) INSERT INTO "widgets" ("name", "a_text", "an_integer", "a_float", "a_decimal", "a_datetime", "a_time", "a_date", "created_at", "updated_at") VALUES (?, ?, ?, ?, ?, ?, ?, ?, ?, ?) [["name", "asldkfj"], ["a_text", "lsdkjflskdjf"], ["an_integer", 11341], ["a_float", 1.3214], ["a_decimal", 14.3142], ["a_datetime", "-4712-01-01 00:00:00.000000"], ["a_time", "2016-04-11 05:25:31.453950"], ["a_date", "2016-04-11"], ["created_at", "2016-04-11 05:25:31.465095"], ["updated_at", "2016-04-11 05:25:31.465095"]]
SQL (0.2ms) INSERT INTO "versions" ("event", "created_at", "object_changes", "item_id", "item_type") VALUES (?, ?, ?, ?, ?) [["event", "create"], ["created_at", "2016-04-11 05:25:31.465095"], ["object_changes", "---\nname:\n- \n- as
View pt_issue_738.rb
# Use this template to report PaperTrail bugs.
# It is based on the ActiveRecord template.
# https://github.com/rails/rails/blob/master/guides/bug_report_templates/active_record_gem.rb
begin
require "bundler/inline"
rescue LoadError => e
$stderr.puts "Bundler version 1.10 or later is required. Please update your Bundler"
raise e
end
View jdickey.log
Updating heroku client ..
Updating Heroku v4 CLI to 4.27.15-535a059 (master)... panic: open /Users/jared/.heroku/heroku-cli.new: no such file or directory
goroutine 3 [running]:
main.fileSha1(0xc8204780f0, 0x23, 0x0, 0x0)
/Users/jdickey/src/github.com/heroku/heroku-cli/update.go:209 +0xb8
main.updateCLI(0x48fadc, 0x6)
/Users/jdickey/src/github.com/heroku/heroku-cli/update.go:121 +0x57e
main.Update.func1(0x48fadc, 0x6, 0xc82001a600)
/Users/jdickey/src/github.com/heroku/heroku-cli/update.go:61 +0x30
@jaredbeck
jaredbeck / student_teams.rb
Created Jan 20, 2016
Partitioning students into teams, brute force approach
View student_teams.rb
require 'pp'
require 'set'
# Which days are students available?
STUDENTS = [
# Mon. Tue. Wed. Thurs. Fri.
[ true, true, false, false, false], # Student 1
[ true, false, false, false, false], # Student 2
[false, true, true, false, false], # etc ...
[false, true, false, true, true],