Skip to content

Instantly share code, notes, and snippets.

View awead's full-sized avatar
🏠
Working from home

Adam Wead awead

🏠
Working from home
View GitHub Profile
@awead
awead / template.rb
Last active February 8, 2022 03:49
Rails template with RSpec for Ruby on Rails Tutorial
add_source 'https://rubygems.org'
gem 'bootsnap', '>= 1.4.4', require: false
gem 'jbuilder', '~> 2.7'
gem 'puma', '~> 5.0'
gem 'rails', '~> 6.1.4', '>= 6.1.4.4'
gem 'sass-rails'
gem 'turbolinks', '~> 5'
gem 'webpacker', '~> 5.0'
@awead
awead / bowling.rb
Last active December 7, 2021 16:49
# @abstract Representation of a bowling frame. It can be any number of "throws" but a frame is complete if it is either
# open, a strike, or spare. Open frames occur when the player does not knock down all the pins within two throws. Closed
# frames mean all the pins were knocked down either with a strike or spare.
class Frame
attr_accessor :throws
def initialize
@throws = []
end
> {}.fetch("i-dont-exist") # Raises error for a required key
KeyError: key not found: "i-dont-exist"
from (pry):2:in `fetch'
> {}.fetch("with-a-default", "default-value") # Provide a default value as the second argument
=> "default-value"
> {}.fetch("something-special") { puts "do something special here" } # Yields to a block for custom stuff
do something special here
=> nil
@awead
awead / gist:de165eb04bd9e390767a28e729919354
Created May 13, 2019 18:15
Running multiple_fields_spec
bundle exec rspec spec/cho/work/submissions/multiple_fields_spec.rb
/Users/agw13/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/valkyrie-1.4.0/lib/valkyrie/types.rb:110: warning: already initialized constant #<Module:0x00007fcd350fabe0>::Int
/Users/agw13/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/dry-types-0.12.3/lib/dry/types.rb:119: warning: previous definition of Int was here
/Users/agw13/.asdf/installs/ruby/2.6.3/lib/ruby/gems/2.6.0/gems/shoulda-matchers-3.1.2/lib/shoulda/matchers/active_model/validate_inclusion_of_matcher.rb:273: warning: BigDecimal.new is deprecated; use BigDecimal() method instead.
Capybara starting Puma...
* Version 3.12.0 , codename: Llamas in Pajamas
* Min threads: 0, max threads: 4
* Listening on tcp://127.0.0.1:60976
2019-05-13 14:12:23 DEBUG Webdrivers Looking for Site: https://chromedriver.storage.googleapis.com
2019-05-13 14:12:23 DEBUG Webdrivers Get response: #<Net::HTTPOK 200 OK readbody=true>
Current:
> Schema::MetadataField.all.first.attributes
=> {:id=>#<Valkyrie::ID:0x007f86fc140250 @id="06de9786-ff39-401b-92f0-bf64bbaabeff">,
[...]
:default_value=>nil,
}
With RC4:
> Schema::MetadataField.all.first.attributes
FormFields (ff) is a js webpack that will key off of some CSS class selectors and add functionality for adding and removing
fields. I want to use the same CSS classes that Boottrap is using for fomatting, but not have to rely on them explicity.
So I prefaced each one I was using with ff-, ex: ff-input-group and ff-form-control. The others that are not based off of
Boostrap are ff-multiple, ff-remove, and ff-add, to keep the namespacing consistent.
Is this a BEM-approved method of naming? Alternatives might be formFields-, form_fields-, form-fields--, or other combinations.
<div class="form-group form-multiple-ff subject">
<label for="archival_collection_subject">Subject</label>
<div class="input-group input-ff">
@awead
awead / gist:c1d5eb9d8b5501ca6a8a2c161d2cf95f
Last active April 2, 2019 14:05
Multiple text inputs
Scholarsphere:
<div class="form-group">
<label>Title</label>
<ul>
<li>
<input/>
<span>Remove me</span>
</li>
</ul>
@awead
awead / mkmf.log
Created February 19, 2019 17:05
Error when installing clamav
have_header: checking for clamav.h... -------------------- no
"clang -o conftest -I/Users/agw13/.asdf/installs/ruby/2.4.1/include/ruby-2.4.0/x86_64-darwin18 -I/Users/agw13/.asdf/installs/ruby/2.4.1/include/ruby-2.4.0/ruby/backward -I/Users/agw13/.asdf/installs/ruby/2.4.1/include/ruby-2.4.0 -I. -I/Users/agw13/.asdf/installs/ruby/2.4.1/include -D_XOPEN_SOURCE -D_DARWIN_C_SOURCE -D_DARWIN_UNLIMITED_SELECT -D_REENTRANT -O3 -Wno-error=shorten-64-to-32 -pipe conftest.c -L. -L/Users/agw13/.asdf/installs/ruby/2.4.1/lib -L. -L/Users/agw13/.asdf/installs/ruby/2.4.1/lib -fstack-protector -L/usr/local/lib -lruby-static -framework CoreFoundation -lpthread -lgmp -ldl -lobjc "
checked program was:
/* begin */
1: #include "ruby.h"
2:
3: int main(int argc, char **argv)
4: {
5: return 0;
These are the updated clamav files that are causing things to break on QA:
{ssjobs1qa-new:root}~ :rpm -qa | grep clam
clamav-lib-0.101.0-1.el7.x86_64
clamd-0.101.0-1.el7.x86_64
clamav-0.101.0-1.el7.x86_64
clamav-update-0.101.0-1.el7.x86_64
clamav-data-0.101.0-1.el7.noarch
clamav-devel-0.101.0-1.el7.x86_64
clamav-filesystem-0.101.0-1.el7.noarch
@awead
awead / gist:b4092b971adb773b3c2f09f2e1c412e6
Last active February 8, 2019 06:26
PBCore xml export
def save_xml_file(id)
av = ArchivalVideo.find(id)
av.summary = av.abstract if av.summary == [""]
xml = av.to_pbcore_xml
license = Array.wrap(av.license).first
if license.present?
prs = Nokogiri::XML::Node.new("pbcoreRightsSummary", xml)
xml.at("/xmlns:pbcoreDescriptionDocument").add_child(prs)
rs = Nokogiri::XML::Node.new("rightsSummary", xml)
rs.content = license