Following are notes I've compiled while researching the React ecosystems and frameworks/tools that people use within it.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| getClientLocation = -> | |
| new Promise (resolve, reject) -> | |
| success = (position) -> | |
| resolve(position.coords) | |
| error = (positionError) -> | |
| error = new Error("Error fetching client location: " + positionError.message) | |
| reject(error) | |
| navigator.geolocation.getCurrentPosition(success, error) |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| require "attr_extras" | |
| class SingleOrMultiple | |
| rattr_initialize :value | |
| def map(&block) | |
| result = | |
| if multiple_values? | |
| value.map(&block) | |
| else |
This gist includes a matcher, have_row, that makes it possible to assert that a table has a certain row. It also comes with a helper class, Features::Table, that makes it possible to convert a table into an array of arrays or array of hashes, or if you quickly want to find a row based the content of a cell inside it, you can do that too.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # This is a module that provides two methods, `expose` and `let`, which | |
| # allow you to cleanly and clearly define lazily-evaluated, memoized | |
| # values that you can use anywhere in your controllers and views. It's | |
| # very similar to the decent_exposure[1] gem, but it works more simply | |
| # (and doesn't have a default action when you don't pass a block to | |
| # #expose, to keep things very very simple). | |
| # | |
| # You will want to mix this into ApplicationController. | |
| # | |
| # == Rationale |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| # If you wanted to make a constructor that did some extra stuff | |
| # on the newly created object before giving it back to you | |
| # you might be tempted to write it like you would in Ruby: | |
| class Modal | |
| @load: -> | |
| modal = new this | |
| modal.load | |
| modal | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module TableHelpers | |
| VALID_FORMATS = [:html, :text] | |
| # Find a table on the page and convert it to an array of arrays. | |
| # | |
| # selector_or_node - A String CSS selector to find the table, or a | |
| # Nokogiri::XML::Node object (if you already have a | |
| # reference to the table). | |
| # options - Optional hash: | |
| # columns - An Integer or Range of Integers. Lets you |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module EnumerableMatchers | |
| # RSpec already lets you do this: | |
| # | |
| # arr.should be_any {|item| item["foo"] == 2 } | |
| # | |
| # However, that's kind of unwieldy to say. So we add this matcher so we | |
| # can say one of these alternatives instead: | |
| # | |
| # arr.should have_any {|item| item["foo"] == 2 } | |
| # arr.should have_an {|item| item["foo"] == 2 } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| module HashMatchers | |
| def contain(other) | |
| Matcher.new(other) | |
| end | |
| class Matcher | |
| def initialize(other) | |
| @other = other | |
| end |