Skip to content

Instantly share code, notes, and snippets.

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:

require 'json'
COLORS = {
'#' => '#216e39',
'+' => '#30a14e',
':' => '#40c463',
'-' => '#9be9a8',
'.' => '#ebedf0',
' ' => nil,
}
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
@tomdalling
tomdalling / 1_without_details.txt
Last active August 8, 2020 02:12
TestBench output
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 05:56
Alternative naming for `DelegatedTypes`
# 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 February 3, 2019 01:54
Tom's Narrow Guide to Melbourne

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 January 20, 2019 02:32
Mutant RSpec error output

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 April 18, 2018 13:06
jekyll-include_snippet gem usage behind article: https://www.rubypigeon.com/posts/super-secret-methods/
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 March 13, 2018 08:09
value object stuff

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 April 19, 2022 00:33
Refactoring a controller action
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