Skip to content

Instantly share code, notes, and snippets.

View Whatapalaver's full-sized avatar

Angela Wolff Whatapalaver

View GitHub Profile
@Whatapalaver
Whatapalaver / bulma.html
Created September 13, 2018 11:35
Bulma html
<!--
hero: https://bulma.io/documentation/layout/hero/
section: https://bulma.io/documentation/layout/section/
image: https://bulma.io/documentation/elements/image/
columns: https://bulma.io/documentation/columns/basics/
media: https://bulma.io/documentation/layout/media-object/
icon: https://bulma.io/documentation/elements/icon/
breadcrumb: https://bulma.io/documentation/components/breadcrumb/
level: https://bulma.io/documentation/layout/level/
-->
@Whatapalaver
Whatapalaver / ruby-setup.md
Last active June 11, 2021 19:57
Setting up Simple ruby Project with RSpec
  • cd into new directory
  • gem install bundler
  • bundle init to create new Gemfile
  • Add the following to Gemfile:
gem 'rake'
gem 'rubocop', '0.56.0'

group :test do
  gem 'rspec'
@Whatapalaver
Whatapalaver / using_wkhtmltopdf.md
Created September 6, 2018 11:27
Converting GitHub markdown to pdf

How to convert your github cv to pdf

This technique produces a pdf document with clickable links from your GitHub readme (also works for any html page)

  1. Download and install wkhtmltopdf which is a command line tool
  2. Open your GitHub README.md in atom - edit as required .
  3. Preview the markdown in atom by pressing shift-ctrl-M
  4. Save this preview with the .html extension
  5. Open the html file in chrome
  6. Go back to the command line and cd into the relevant directory
@Whatapalaver
Whatapalaver / carrierwave.rb
Last active September 5, 2018 13:27
Carrierwave and AWS S3
# config/initializers/carrierwave.rb
CarrierWave.configure do |config|
config.fog_provider = 'fog/aws'
config.fog_credentials = {
provider: 'AWS',
aws_access_key_id: ENV["AWS_ACCESS_KEY_ID"],
aws_secret_access_key: ENV["AWS_SECRET_ACCESS_KEY"],
region: 'us-east-2'
}
@Whatapalaver
Whatapalaver / carrierwave1b.rb
Created September 5, 2018 12:37
medium blog embeds
# config/initializers/carrierwave.rb
CarrierWave.configure do |config|
if Rails.env.staging? || Rails.env.production?
config.fog_provider = 'fog/aws'
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'],
:region => 'us-east-2'
}
@Whatapalaver
Whatapalaver / carrierwave1a.rb
Created September 5, 2018 12:35
medium blog embeds
# config/initializers/carrierwave.rb
CarrierWave.configure do |config|
if Rails.env.staging? || Rails.env.production?
config.fog_provider = 'fog/aws'
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY']
}
@Whatapalaver
Whatapalaver / carrierwave1.rb
Created September 5, 2018 12:30
Embeds for medium blog
# config/initializers/carrierwave.rb
CarrierWave.configure do |config|
if Rails.env.staging? || Rails.env.production?
config.fog_provider = 'fog/aws'
config.fog_credentials = {
:provider => 'AWS',
:aws_access_key_id => ENV['AWS_ACCESS_KEY_ID'],
:aws_secret_access_key => ENV['AWS_SECRET_ACCESS_KEY'],
:region => 'us-east-2'
@Whatapalaver
Whatapalaver / attr_accessor.md
Last active July 19, 2018 11:04
Attr_Reader || Attr_Writer || Attr_Accessor

If you write:

attr_writer :age

It is the equivalent of:

def age=(value)
  @age = value
end
@Whatapalaver
Whatapalaver / RSpec_snippets.md
Last active July 18, 2018 17:37
RSpec cheatsheet

RSpec snippets

Explicit declaration of subject:

subject(:card) {described_class.new}

Setting doubles with let

let(:entry_station){ double :station }

Testing for gets vs puts

@Whatapalaver
Whatapalaver / Hash_woes.md
Last active July 19, 2018 11:04
Hash woes

Here's an example of producing output of an array of hashes, grouped by one of the keys

In this case students is an array of hashes showing student names and the cohort they are enrolled in
The output summarises by cohort and lists the relevant enrolled student names

def print_by_category(students)
  # print the students grouped by cohort
  cohort_array = []
    students.each do |hash|
 cohort_array.push(hash[:cohort]).uniq!