Skip to content

Instantly share code, notes, and snippets.

Avatar

tomholford

View GitHub Profile
@tomholford
tomholford / install_pg_gem.md
Last active Jan 14, 2022
Install postgresql gem `pg` on macOS
View install_pg_gem.md

Installing pg gem on macOS

If you're trying to install the postgresql gem pg and it is failing with the following error message:

Installing pg 1.2.3 with native extensions
Gem::Ext::BuildError: ERROR: Failed to build gem native extension.

    current directory: ~/.rbenv/versions/3.0.0/lib/ruby/gems/3.0.0/gems/pg-1.2.3/ext
~/.rbenv/versions/3.0.0/bin/ruby -I ~/.rbenv/versions/3.0.0/lib/ruby/3.0.0 -r ./siteconf20210125-97201-pycpo.rb extconf.rb
@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"