Skip to content

Instantly share code, notes, and snippets.

View HashNotAdam's full-sized avatar

Adam Rice HashNotAdam

  • Melbourne, Australia
View GitHub Profile
@HashNotAdam
HashNotAdam / rails_admin_subclassed_sti_model.rb
Last active May 6, 2016 02:46
Example of how to reproduce rails_admin issue #2627
# == Schema Information
#
# Table name: companies
#
# id :integer not null, primary key
# name :string(255) not null
# type :string(255) not null
# created_at :datetime
# updated_at :datetime
#
@HashNotAdam
HashNotAdam / tailwindcss_webpacker_import_issue.css
Last active June 5, 2019 06:59
Media queries in Tailwind 1.0.1 are being imported after all other styles (including custom styles) when using Rails 5.2.2.1 and Webpacker 3.5.5
/*! normalize.css v8.0.1 | MIT License | github.com/necolas/normalize.css */
/* Document
========================================================================== */
/**
* 1. Correct the line height in all browsers.
* 2. Prevent adjustments of font size after orientation changes in iOS.
*/
require 'benchmark/ips'
require 'active_model'
require 'dry-validation'
require 'dry/schema/version'
GOOD_INPUTS = [
{ name: 'Tom', age: 904 },
{ name: 'Piotr', age: nil },
{ name: 'Dane', age: 44, password: 'wigwam' },
]
@HashNotAdam
HashNotAdam / working_with_legacy_code-chapter_6_summary.md
Last active February 18, 2021 10:32
Working with Legacy Code — Chapter 6 — I don't have much time and I have to change it

Working Effectively with Legacy Code — Chapter 6 —I don't have much time and I have to change it

  • Sometimes it feels like tests take too long to write but it's easy to overlook how long changes take without them
  • Often, if you are changing code now it's likely the code will change again soon

Sprout method

  • For code to be testable, every "unit" should have a single responsibility
  • If you need to inject a new operation into a method, consider extracting that to a new method