“...I've been working since 2008 with Ruby / Ruby on Rails, love a bit of Elixir / Phoenix and learning Rust. I also poke through other people's code and make PRs for OpenSource Ruby projects that sometimes make it. Currently working for InPay...”

Rob Lacey
Senior Software Engineer, UK

Three things that were invaluable today

Quick and dirty database migration on the console

When a database migration failed to roll back properly, stripping one column but not all, we had to put back the original column without changing the migration and re-running. It always feels very dangerous when a multipart migration fails halfway through. So….you can actually call migration commands on ActiveRecord::Migration directly, just be careful to test in development first as accidents can and will happen.

Rails pro >> ActiveRecord::Migration.add_column :somethings, :thing_file_name, :string, before: :thing_file_name
-- add_column(:somethings, :thing_file_name, :string, {:before=>:splash_content_type})
   (4838.6ms)  ALTER TABLE `somethings` ADD `thing_file_name` varchar(255)

Cherry picking changes in a different branch with Git.

I had to give up on a recent branch because refactoring had caused more problems than it intended to solve. Without wanting to start over I was able to pick the files that I cared about individually rather than sifting through and reverting parts of a previous commit.

git checkout feature/somefeature -- config/blah.yml

While I’m there, ever wanted to ditch your local changes in a conflict over the merged in changes from another branch?

git checkout --theirs config/routes.rb

Rails partials as layouts

Ever had a Rails partial and wanted to re-use it in a specific situation but with a small change? A partial can also be used as a layout, it appears a partial can be a layout that takes a block.

app/views/somethings/_dave.html.haml

= form_for(@dave) do |f|
  = f.text_field :full_name

app/views/somethings/thing.html.haml

= render partial: 'dave'

I really want to add an way to to re-use the form and add to it. How about this?

app/views/somethings/_dave.html.haml

= form_for(@dave) do |f|
  - if block_given?
    = yield
  = f.text_field :full_name

app/views/somethings/thing.html.haml

= render layout: 'dave' do
  %p A MESSAGE TO PLONK AT THE TOP OF THE FORM

TBG Secret Santa

Another mini-project. A Secret Santa app, Facebook login, address data collection, will then select a suitable Gift Recipient, mark gifts as shipped and reciprocol gifts received.

https://iplayred.co.uk/secret_santa

Hosted on https://iplayred.co.uk

Mammothfest Facebook Tab / Spotify Playlist

Created just a quick widget, although it did require buying an SSL key in order to host the app through Facebook. The playlist itself was tirelessly compiled by Fox James for the MammothFest 2015 line-up.

<!-- full width 810px -->
<iframe src="https://robl.me/mammothfest" width="810" height="920"></iframe>

<!-- width limited to 560px, width 20px border -->
<iframe src="https://robl.me/mammothfest?width=560" width="580" height="920"></iframe>

Just a demo of it in action. https://www.facebook.com/uncleanmusic/app_1686134591618166
It can be installed via https://www.facebook.com/dialog/pagetab?app_id=1686134591618166&redirect_uri=https://robl.me/appadded

This really just boils down to using the Spotify embedding as below served via Facebook.

<iframe allowtransparency="true" frameborder="0" height="600" src="https://embed.spotify.com/?uri=spotify:user:mammothfest:playlist:0OJn0Ky6GjedhLINTjZ2Fe" width="520"></iframe>

update embed test

VEVO embedding

Raging Speedhorn PledgeMusic project


Raging Speedhorn are back and looking to do a new album, best way to test if embedding is working I suppose. https://www.pledgemusic.com/projects/raging-speedhorn

The REAL Pixels movie

Petty Annoyance of the day #1

Methods that return different object types given different input. I understand why this does what it does but when you forget the 2nd argument and an Enumerator arrives unexpectedly….

2.1.2 :068 > 'somestring'.gsub(':').class
 => Enumerator 
2.1.2 :069 > 'somestring'.gsub(':','').class
 => String

Not sure why its Enumerator

2.1.2 :085 > 'string'.gsub(/(s)trin(g)/).each do |blah|
2.1.2 :086 >     puts blah
2.1.2 :087?>   end
string
2.1.2 :099 > 'string'.gsub('staobasf').map(&:object_id)
 => [] 
2.1.2 :100 > 'string'.gsub('staobasf').map
 => #<Enumerator: #<Enumerator: "string":gsub("staobasf")>:map>

I am pretty sure I don’t need to know but hey.

SSL Certificate - CSR generation

In order to generate a *.csr and *.key file for your SSL Certificate.

openssl req -new -newkey rsa:2048 -nodes -keyout somedomain.key -out somedomain.csr
Generating a 2048 bit RSA private key
............+++
...................................+++
writing new private key to 'somedomain.com.key'
-----
You are about to be asked to enter information that will be incorporated
into your certificate request.
What you are about to enter is what is called a Distinguished Name or a DN.
There are quite a few fields but you can leave some blank
For some fields there will be a default value,
If you enter '.', the field will be left blank.
-----
Country Name (2 letter code) [AU]:GB
State or Province Name (full name) [Some-State]:East Sussex
Locality Name (eg, city) []:Brighton
Organization Name (eg, company) [Internet Widgits Pty Ltd]:Some Limited Company Limited
Organizational Unit Name (eg, section) []:
Common Name (e.g. server FQDN or YOUR name) []:*.somedomain.com
Email Address []:

Please enter the following 'extra' attributes
to be sent with your certificate request
A challenge password []:
An optional company name []:

DNS / host commands

Want a few simple DNS details for a domain from the command line?

Robs-iMac:~ roblacey$ host -t mx robl.me
robl.me mail is handled by 9 xen1.robl.me.
robl.me mail is handled by 10 mailforward.lcn.com.

Robs-iMac:~ roblacey$ host -t txt robl.me
robl.me descriptive text "google-site-verification=E4g5ZQVgm9j01RsxbiGISNBaOvtH614IHSF1RGHHGJE"

Robs-iMac:~ roblacey$ host -t a robl.me
robl.me has no A record

Robs-iMac:~ roblacey$ host -t a www.robl.me
www.robl.me is an alias for xen1.robl.me.
xen1.robl.me has address 207.192.74.149

Robs-iMac:~ roblacey$ host -t cname www.robl.me
www.robl.me is an alias for xen1.robl.me.
GPK of the Day Mad DONNA