Skip to content

Instantly share code, notes, and snippets.

View scottbarrow's full-sized avatar

Scott Barrow scottbarrow

View GitHub Profile

Make it real

Ideas are cheap. Make a prototype, sketch a CLI session, draw a wireframe. Discuss around concrete examples, not hand-waving abstractions. Don't say you did something, provide a URL that proves it.

Ship it

Nothing is real until it's being used by a real user. This doesn't mean you make a prototype in the morning and blog about it in the evening. It means you find one person you believe your product will help and try to get them to use it.

Do it with style

@scottbarrow
scottbarrow / array_iteration_thoughts.md
Created April 13, 2018 20:32 — forked from ljharb/array_iteration_thoughts.md
Array iteration methods summarized

While attempting to explain JavaScript's reduce method on arrays, conceptually, I came up with the following - hopefully it's helpful; happy to tweak it if anyone has suggestions.

Intro

JavaScript Arrays have lots of built in methods on their prototype. Some of them mutate - ie, they change the underlying array in-place. Luckily, most of them do not - they instead return an entirely distinct array. Since arrays are conceptually a contiguous list of items, it helps code clarity and maintainability a lot to be able to operate on them in a "functional" way. (I'll also insist on referring to an array as a "list" - although in some languages, List is a native data type, in JS and this post, I'm referring to the concept. Everywhere I use the word "list" you can assume I'm talking about a JS Array) This means, to perform a single operation on the list as a whole ("atomically"), and to return a new list - thus making it much simpler to think about both the old list and the new one, what they contain, and

aws cloudfront list-distributions
aws cloudfront create-invalidation --distribution-id=ENTER_DIST_ID --paths / 1
# 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)
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|
@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
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 / 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
@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 / 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 %>