Skip to content

Instantly share code, notes, and snippets.

View scottbarrow's full-sized avatar

Scott Barrow scottbarrow

View GitHub Profile
### Keybase proof
I hereby claim:
* I am scottbarrow on github.
* I am scottbarrow (https://keybase.io/scottbarrow) on keybase.
* I have a public key ASD_SKprBc0b4SWsmhDBFVPYoffyloIVFZTq9RP4RP5qGAo
To claim this, I am signing this object:
@scottbarrow
scottbarrow / README.md
Created October 28, 2020 15:21 — forked from leastbad/README.md
stimulus-websocket preview

This controller can be put on body or any other element.

  1. Adds a websocket accessor to the element
  2. Controller exposes a connected boolean getter
  3. Controller bails with a warning if no shared consumer is available
  4. Element will have data-action-cable-connected or data-action-cable-disconnected attributes which can be used for CSS selectors
  5. Element will emit action-cable:connected or action-cable:disconnected events only when state is flipping
  6. Errors => Disconnected to keep things simple

I intend to document the navigator.onLine accessor and the window:online/offline events so devs can handle PWA modes.

@scottbarrow
scottbarrow / form.html.erb
Created October 3, 2020 20:06 — forked from julianrubisch/form.html.erb
StimulusReflex Form Reset Controller
<%= form_with(model: model, data: {controller: "reflex-form", reflex_form_reflex: "ExampleReflex#submit"}) do |form| %>
<%= form.button data: {action: "click->reflex-form#submit"} %>
<% end %>
@scottbarrow
scottbarrow / populate_stripe_input.js
Created October 17, 2019 03:13 — forked from mbrochh/some_test.js
Controlling a Stripe payent popup with Cypress.io
// for this to work you need to set `"chromeWebSecurity": false` in cypress.json
describe('Make Stripe Payment', function() {
before(function() {
cy.visit('http://localhost:3000/en/stripe/checkout/')
Cypress.Cookies.preserveOnce('sessionid')
})
it('should enter credit card details and finalise payment', function() {
cy.get('[data-test="button-FormStripeCart-PayWithCreditCard"]').click()
@scottbarrow
scottbarrow / rubocoper
Created October 3, 2019 01:28 — forked from deivid-rodriguez/rubocoper
Adds RuboCop to a project, one commit per cop
#!/usr/bin/env ruby
require 'open3'
#
# Adds RuboCop to a project, one cop per commit
#
class RuboCoper
def run
autocorrect_all
desc 'Run the entire suit of tests and linters'
task :default do
border = '=' * 80
tasks = %w[rspec bundle:audit]
puts "The following Rake tasks will be run: #{tasks.to_sentence}"
tasks.each do |task|
puts "\n#{border}\nRunning `rake #{task}`\n#{border}"
Rake::Task[task].invoke
end
@scottbarrow
scottbarrow / brew_symlink_error_sierra.md
Created August 14, 2018 18:32 — forked from dalegaspi/brew_symlink_error_sierra.md
Homebrew Symlink errors in Mac OSX High Sierra
require 'nokogiri'
+
+RSpec::Matchers.define :have_xml do |xpath, condition|
+ match do |body|
+ doc = Nokogiri::XML::Document.parse(body)
+ nodes = doc.xpath(xpath)
+ expect(nodes).not_to be_empty
+
+ if condition
+ condition.keys.each do |key|
# Converts :hover CSS to :active CSS on mobile devices.
# Otherwise, when tapping a button on a mobile device, the button stays in
# the :hover state until the button is pressed.
#
if 'ontouchstart' of document.documentElement
sheetI = document.styleSheets.length - 1
while sheetI >= 0
sheet = document.styleSheets[sheetI]
# Verify if cssRules exists in sheet and they are same origin
# (Chrome throws an exception for cross-origin requests on stylesheets)
aws cloudfront list-distributions
aws cloudfront create-invalidation --distribution-id=ENTER_DIST_ID --paths / 1