Skip to content

Instantly share code, notes, and snippets.

Tom Dalling tomdalling

Block or report user

Report or block tomdalling

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
tomdalling /
Last active Feb 3, 2019
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 /
Created Jan 20, 2019
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]

  stack level too deep
tomdalling /
Last active Apr 18, 2018
jekyll-include_snippet gem usage behind article:
title layout date snippet_source
Super Secret Methods

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

Method names can not contain a period character.

tomdalling /
Created Mar 13, 2018
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 / after.rb
Last active Jul 7, 2019
Refactoring a controller action
View after.rb
class CommentsController
def create
result =, @user)
if result.ok?
render :partial => "comments/postedreply", :layout => false,
:content_type => "text/html", :locals => { :comment => result.value }
when :story_not_found
render :plain => "can't find story", :status => 400
tomdalling / benchmarks.txt
Created Jun 13, 2017
Benchmarking input validation
View benchmarks.txt
Using Ruby 2.4.1
Code being benchmarked:
Warming up --------------------------------------
RSchema 3.1.1 1.640k i/100ms
(coerced) 673.000 i/100ms
(built + coerced) 142.000 i/100ms
ActiveModel 5.1.1 103.000 i/100ms
dry-validation 0.10.7
759.000 i/100ms
tomdalling / rschema_pluggable_coercion.rb
Last active May 7, 2017
Pluggable/composable coercion upcoming in RSchema v3
View rschema_pluggable_coercion.rb
# params usually come in as strings, regardless of the actual type they are
params = {
'fruit' => 'banana',
'harvested_at' => '2017-05-08T01:46:16+10:00',
'unwanted_framework_crap' => 'DHH',
# you can declare what the types are _supposed_ to be with a schema
schema = RSchema.define {{
fruit: _Symbol,
tomdalling / simple_authentication.rb
Created May 23, 2016
A simple Sinatra app that demonstrates basic authentication
View simple_authentication.rb
#!/user/bin/env ruby
require 'bundler/inline'
gemfile(true) do
source ''
gem 'sinatra', '~> 1.4'
gem 'bcrypt', '~> 3.1'
require 'sinatra/base'
tomdalling / app_cell.rb
Last active Apr 11, 2016
Cells Erbse automatic escaping
View app_cell.rb
require 'cell'
class AppCell < Cell::ViewModel
include ::Cell::Erb
def show
def template_options_for(*args)
tomdalling / fragment-shader.txt
Created Nov 26, 2014 OpenGL article 2 modified to use two textures
View fragment-shader.txt
#version 150
uniform sampler2D tex;
uniform sampler2D tex2;
in vec2 fragTexCoord;
out vec4 finalColor;
void main() {
You can’t perform that action at this time.