Skip to content

Instantly share code, notes, and snippets.

@tomholford
tomholford / README.md
Created May 15, 2020
Extend Rails application layouts
View README.md

extends

An elegant way to nest Rails layouts.

Example Usage

# devise.html.erb
<%= extends :application do %>
  <div class="devise-container">
@tomholford
tomholford / newface.sh
Created Apr 24, 2020
Get a new neural-net generated face jpg via This Person Does Not Exist
View newface.sh
curl https://thispersondoesnotexist.com/image -o ~/$(date +%s).jpg
@tomholford
tomholford / external_link_to.md
Last active Oct 19, 2019
Rails link_to helper for external links that open a new tab
View external_link_to.md
@tomholford
tomholford / classifier.rb
Created Jun 7, 2018
even / odd classifier using proc
View classifier.rb
f = proc do |p|
Hash.new.merge(
->{ p.odd? }.call => 'odd',
->{ p.even? }.call => 'even'
).fetch(true)
end
=> #<Proc:0x00007ff91188af38@(irb):1>
> f[1]
=> "odd"
You can’t perform that action at this time.