Skip to content

Instantly share code, notes, and snippets.


Stanislas Boyet StanBoyet

View GitHub Profile
StanBoyet / wpa_supplicant.conf
Created Apr 18, 2020
Raspberry Pi Headless Wifi Setup
View wpa_supplicant.conf
# To place /etc/wpa_supplicant/wpa_supplicant.conf
# Adapted from
# Needed for compability with the latest Buster Raspbian release
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
ssid="ssid name"
StanBoyet / recursive_replace.rb
Last active Sep 28, 2018
Recursively replace a value `initial` by `replacement`
View recursive_replace.rb
def denilize(h, initial, replacement)
h.each_with_object({}) { |(k,v),g|
g[k] = (Hash === v) ? denilize(v) : v == initial ? replacement : v }
h = { "a"=>{ "b"=>{ "c"=>nil } } }
denilize(h) #=> { "a"=>{ "b"=>{ "c"=>"" } } }
h = { "a"=>{ "b"=>{ "c"=>nil , "d"=>3, "e"=>nil}, "f"=>nil } }
denilize(h) #=> { "a"=>{ "b"=>{ "c"=>"" , "d"=>3, "e"=>""}, "f"=>"" } }

macOS 10.12 Sierra Setup

Custom recipe to get macOS 10.12 Sierra running from scratch, setup applications and developer environment. This is very similar (and currently mostly the same) as my 10.11 El Capitan setup recipe and 10.10 Yosemite setup recipe. I am currently tweaking this for 10.12 Sierra and expect to refine this gist over the next few weeks.

I use this gist to keep track of the important software and steps required to have a functioning system after a semi-annual fresh install. I generally reinstall each computer from scratch every 6 months, and I do not perform upgrades between releases.

This keeps the system performing at top speeds, clean of trojans, spyware, and ensures that I maintain good organizational practices for my content and backups. I highly recommend this.

You are encouraged to fork this and modify it to your heart's content to match your o


#Simple Authentication with Bcrypt

This tutorial is for adding authentication to a vanilla Ruby on Rails app using Bcrypt and has_secure_password.

The steps below are based on Ryan Bates's approach from Railscast #250 Authentication from Scratch (revised).

You can see the final source code here: repo. I began with a stock rails app using rails new gif_vault


StanBoyet /
Created Nov 4, 2016
Foreign key for named relations

In Rails 4.2+ you can also set foreign keys in the db as well, which is a great idea.

For simple associations this can be done also on t.references adding foreign_key: true, but in this case you'll need two lines.

    # The migration
    add_reference :posts, :author, references: :users, index: true
    add_foreign_key :posts, :users, column: :author_id

    # The model
View blockchain
Verifying that +stanboyet is my blockchain ID.
StanBoyet / rspec_model_testing_template.rb
Last active May 6, 2016 — forked from kyletcarlson/rspec_model_testing_template.rb
Rails Rspec model testing skeleton & cheat sheet using rspec-rails, shoulda-matchers, shoulda-callbacks, and factory_girl_rails. Pretty much a brain dump of examples of what you can (should?) test in a model. Pick & choose what you like, and please let me know if there are any errors or new/changed features out there. Reddit comment thread: http…
View rspec_model_testing_template.rb
# This is a skeleton for testing models including examples of validations, callbacks,
# scopes, instance & class methods, associations, and more.
# Pick and choose what you want, as all models don't NEED to be tested at this depth.
# I'm always eager to hear new tips & suggestions as I'm still new to testing,
# so if you have any, please share!
# @kyletcarlson
# This skeleton also assumes you're using the following gems:
StanBoyet /
Created Nov 25, 2015
ERROR: Error installing mysql: ERROR: Failed to build gem native extension

Another way for MacOS users

If you used "brew" to install mysql:

gem install mysql2 -v 'x.x.x' -- --with-mysql-config=/usr/local/Cellar/mysql/y.y.y/bin/mysql_config

x.x.x = version of the mysql2 gem you want to install

StanBoyet / gist:0b23d695164f2125dfdf
Created Nov 12, 2015 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan
View gist:0b23d695164f2125dfdf

OS X Preferences

most of these require logout/restart to take effect

# Enable character repeat on keydown
defaults write -g ApplePressAndHoldEnabled -bool false

# Set a shorter Delay until key repeat
StanBoyet /
Last active Dec 17, 2015 — forked from kagemusha/gist:1569836
Dump Heroku Postgres DB and load locally
You can’t perform that action at this time.