Skip to content

Instantly share code, notes, and snippets.

View libbyschuknight's full-sized avatar
🏡
Working remotely

Libby Schumacher-Knight libbyschuknight

🏡
Working remotely
View GitHub Profile
@libbyschuknight
libbyschuknight / if-unless.rb
Last active February 26, 2016 02:16
how to re-write if/else with unless
json_error = JSON.parse(error.response.body)["error"]
if json_error == "error:price_not_found"
nil
else
raise error
end
# better like this, does same thing
json_error = JSON.parse(error.response.body)["error"]
raise error unless json_error == "error:price_not_found"
# Built-in config:
# https://github.com/bbatsov/rubocop/blob/master/config/default.yml
# We do not typically use/need class documentation
Documentation:
Enabled: false
Metrics/LineLength:
Max: 120
@libbyschuknight
libbyschuknight / pr_emojis.md
Last active November 5, 2017 23:05
Pull Request Emojis

PR Emojis

When reviewing a Pull Request, the more Emoji the better ✨. These ones have a defined meaning:

  • 💡 FYIs (such as: "💡In another service, we solve a similar problem in this way")
  • ⚠️ blocking (such as: "⚠️ I don't think this will work for these edge cases")
  • 🐘 non-blocking (such as: "🐘 This could be more elegant by doing it a different way")
  • 🍄 code smell (such as: "🍄 This seems like a lot of logic for a view")
  • 💭 thought (such as: "💭I wonder if we could use this pattern in other services?")
  • compliments (such as: "✨This is some great code, computer friend!")
#!/usr/bin/env ruby
require "pathname"
root = Pathname.new(".")
libs = root.children.select(&:directory?).collect(&:realpath)
libs.each do |lib|
Dir.chdir(lib.realpath.to_s) do
system "yard"
@libbyschuknight
libbyschuknight / env.rb
Created January 4, 2018 20:47
Getting fixtures working for features when using cucumber
# IMPORTANT: This file is generated by cucumber-rails - edit at your own peril.
# It is recommended to regenerate this file in the future when you upgrade to a
# newer version of cucumber-rails. Consider adding your own code to a new file
# instead of editing this one. Cucumber will automatically load all features/**/*.rb
# files.
require 'cucumber/rails'
require_relative 'fixture_access'
# Capybara defaults to CSS3 selectors rather than XPath.
@libbyschuknight
libbyschuknight / service_object_spec.rb
Created January 12, 2018 01:34
testing initialize or not
RSpec.describe CreateInvoice, type: :service do
describe "#initialize" do
context "when CreateInvoice is instantiated " do
fixtures :users
let(:user) { users(:customer_with_read) }
let(:valid_params) do
{
"invoice_date(3i)" => "13",
describe Location do
describe ".in_region" do
it "returns locations in the named region" do
region = create(:region, name: "expected")
other_region = create(:region, name: "other")
create(:location, region: region, name: "in-expected-region-one")
create(:location, region: region, name: "in-expected-region-two")
create(:location, region: other_region, name: "in-other-region")
describe Person do
describe ".in_region" do
it "returns people in the named region" do
region = create(:region, name: "expected")
other_region = create(:region, name: "other")
in_region = create(:location, region: region)
in_other_region = create(:location, region: other_region)
create(:person, location: in_region, name: "in-expected-region-one")
create(:person, location: in_region, name: "in-expected-region-two")
create(:person, location: in_other_region, name: "in-other-region")
sudo npm install node-sass --save-dev
> [email protected] install /Users/SchuKnight/code/learning/udemy/advanced-sass-css/natours-site/node_modules/node-sass
> node scripts/install.js
Unable to save binary /Users/SchuKnight/code/learning/udemy/advanced-sass-css/natours-site/node_modules/node-sass/vendor/darwin-x64-67 : { Error: EACCES: permission denied, mkdir '/Users/SchuKnight/code/learning/udemy/advanced-sass-css/natours-site/node_modules/node-sass/vendor'
at Object.mkdirSync (fs.js:773:3)
at sync (/Users/SchuKnight/code/learning/udemy/advanced-sass-css/natours-site/node_modules/mkdirp/index.js:71:13)
at Function.sync (/Users/SchuKnight/code/learning/udemy/advanced-sass-css/natours-site/node_modules/mkdirp/index.js:77:24)
at checkAndDownloadBinary (/Users/SchuKnight/code/learning/udemy/advanced-sass-css/natours-site/node_modules/node-sass/scripts/install.js:114:11)
@libbyschuknight
libbyschuknight / attribute.css
Created March 21, 2019 04:44
CSS attribute value
/* from https://css-tricks.com/almanac/selectors/a/attribute/ */
[data-value] {
/* Attribute exists */
}
[data-value="foo"] {
/* Attribute has this exact value */
}