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 / modal.slim.html
Created September 8, 2014 09:46
Boostrap Modal in Slim
/ Simple Slim translation of Bootstrap modal
.modal.fade.bs-example-modal-lg id="myModal" tabindex='-1' role='dialog' aria-labelledby="Modal Title" aria-hidden='true'
.modal-dialog.modal-lg
.modal-content
.modal-header
button.close type='button' data-dismiss='modal'
span aria-hidden='true' ×
span.sr-only Close
h4.modal-title = "Modal Title"
@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
@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:
Verifying that +stanboyet is my blockchain ID. https://onename.com/stanboyet
# RSpec's subject method, both implicitly and explicitly set, is useful for
# declaratively setting up the context of the object under test. If you provide a
# class for your describe block, subject will implicitly be set to a new instance
# of this class (with no arguments passed to the constructor). If you want
# something more complex done, such as setting arguments, you can use the
# explicit subject setter, which takes a block.
describe Person do
context "born 19 years ago" do
subject { Person.new(:birthdate => 19.years.ago }
it { should be_eligible_to_vote }
@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