Skip to content

Instantly share code, notes, and snippets.

View StanBoyet's full-sized avatar

Stanislas Boyet StanBoyet

View GitHub Profile
@StanBoyet
StanBoyet / wpa_supplicant.conf
Created April 18, 2020 14:03
Raspberry Pi Headless Wifi Setup
# To place /etc/wpa_supplicant/wpa_supplicant.conf
# Adapted from https://www.raspberrypi.org/documentation/configuration/wireless/wireless-cli.md
# Needed for compability with the latest Buster Raspbian release
ctrl_interface=DIR=/var/run/wpa_supplicant GROUP=netdev
update_config=1
country=FR
network={
ssid="ssid name"
@StanBoyet
StanBoyet / recursive_replace.rb
Last active September 28, 2018 08:28
Recursively replace a value `initial` by `replacement`
def denilize(h, initial, replacement)
h.each_with_object({}) { |(k,v),g|
g[k] = (Hash === v) ? denilize(v) : v == initial ? replacement : v }
end
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

@StanBoyet
StanBoyet / authentication_with_bcrypt_in_rails_4.md
Created November 21, 2016 08:42 — forked from thebucknerlife/authentication_with_bcrypt_in_rails_4.md
Simple Authentication in Rail 4 Using Bcrypt

#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

##Steps

@StanBoyet
StanBoyet / named_reference.md
Created November 4, 2016 09:36
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
Verifying that +stanboyet is my blockchain ID. https://onename.com/stanboyet
@StanBoyet
StanBoyet / rspec_model_testing_template.rb
Last active May 6, 2016 08:32 — forked from SabretWoW/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…
# 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
StanBoyet / mysql_installation_error.md
Created November 25, 2015 11:11
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
StanBoyet / gist:0b23d695164f2125dfdf
Created November 12, 2015 19:36 — forked from saetia/gist:1623487
Clean Install – OS X 10.11 El Capitan

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
StanBoyet / get_pg_db.md
Last active December 17, 2015 10:13 — forked from kagemusha/gist:1569836
Dump Heroku Postgres DB and load locally