Skip to content

Instantly share code, notes, and snippets.

View keybase.md

Keybase proof

I hereby claim:

  • I am tomdalling on github.
  • I am tomdalling (https://keybase.io/tomdalling) on keybase.
  • I have a public key ASDAMWx4M_UpLqjxz-ZUxQCZoDl8Tt18bKoclREuxqQo2go

To claim this, I am signing this object:

View gh.rb
require 'json'
COLORS = {
'#' => '#216e39',
'+' => '#30a14e',
':' => '#40c463',
'-' => '#9be9a8',
'.' => '#ebedf0',
' ' => nil,
}
View minimal_repro.txt
Mutant environment:
Matcher: #<Mutant::Matcher::Config match_expressions: [C]>
Integration: rspec
Jobs: 8
Includes: []
Requires: ["./c"]
Subjects: 1
Total-Tests: 90
Selected-Tests: 1
Tests/Subject: 1.00 avg
View 1_without_details.txt
Running test/automated/zettel/hashtag_query.rb
Zettel::HashtagQuery
matches the presence of a hashtag
with syntax: #a
provides logical NOT
with syntax: NOT #a
with syntax: not #a
with syntax: !#a
provides logical AND
with syntax: #a AND #b
@tomdalling
tomdalling / delegated_types.rb
Created May 22, 2020
Alternative naming for `DelegatedTypes`
View delegated_types.rb
# Schema: entries[ id, account_id, creator_id, created_at, updated_at, specialization_type, specialization_id ]
class Entry < ApplicationRecord
has_specialization types: %w[ Message Comment ]
belongs_to :account
belongs_to :creator
end
# Schema: messages[ id, subject ]
class Message < ApplicationRecord
is_specialization_of 'Entry'
@tomdalling
tomdalling / guide.md
Last active Feb 3, 2019
Tom's Narrow Guide to Melbourne
View guide.md

Tom's Narrow Guide to Melbourne

Places I like, for RubyConf AU attendees.

Coffee + Brunch Spots

  • Queen Victoria Markets
  • Degraves St
  • St Ali (South Melbourne, just outside the CBD. Must try the bottled iced lattes.)
  • Auction Rooms (North Melbourne, just outside the CBD)
@tomdalling
tomdalling / rspec_output.md
Created Jan 20, 2019
Mutant RSpec error output
View rspec_output.md

When I do puts method_name inside #respond_to_missing?, it outputs begin, so it looks like it's treating self as if it were a Range.

This is the RSpec output:

An error occurred while loading ./spec/value_semantics_spec.rb.
Failure/Error: first_letter = method_name[self]

SystemStackError:
  stack level too deep
@tomdalling
tomdalling / article.md
Last active Apr 18, 2018
jekyll-include_snippet gem usage behind article: https://www.rubypigeon.com/posts/super-secret-methods/
View article.md
title layout date snippet_source
Super Secret Methods
post
2017-07-16
code/super_secret_methods.rb

Here is a quirk of the Ruby language that I discovered a few weeks ago.

Method names can not contain a period character.

@tomdalling
tomdalling / notes.md
Created Mar 13, 2018
value object stuff
View notes.md

I like the idea of providing an RSpec shared example to test all these behaviours.

For the constructor, I would change "consider using keywords" to "should use keywords". Keywords should be the default, unless the order is really obvious.

Re: "Value construction options could be provided by keyword arguments." I would probably prefer value contruction options to be in separate class methods, instead of #new.

Re: caching. I would be hesitant to do this at the global level (e.g. stored in the class).

@tomdalling
tomdalling / after.rb
Last active Jul 7, 2019
Refactoring a controller action
View after.rb
class CommentsController
def create
result = CreateComment.call(params, @user)
if result.ok?
render :partial => "comments/postedreply", :layout => false,
:content_type => "text/html", :locals => { :comment => result.value }
else
case result.error.name
when :story_not_found
render :plain => "can't find story", :status => 400