-
Create an account on NPM https://www.npmjs.com
-
Init your project
mkdir example cd example yarn init
-
Create a JavaScript file
This file contains 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
# app/reflexes/examples_reflex.rb | |
class ExamplesReflex < ApplicationReflex | |
include CableReady::Broadcaster | |
before_reflex :surgical_update, only: [:noop] | |
def surgical_update | |
cable_ready["example"].inner_html( | |
selector: "#example-container", | |
html: ExampleController.render( |
This file contains 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
# app/presenters/presenter.rb | |
require "delegate" | |
class Presenter < SimpleDelegator | |
attr_reader :model, :controller | |
def initialize(model, controller) | |
@controller = controller | |
super(@model = model) |
Successfully upgraded to WebSocket (REQUEST_METHOD: GET, HTTP_CONNECTION: Upgrade, HTTP_UPGRADE: websocket)
Finished "/cable/" [WebSocket] for 127.0.0.1 at 2018-11-16 08:32:24 -0700
An unauthorized connection attempt was rejected
This file contains 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
#!/usr/bin/env ruby | |
# checkout the readme from the master branch | |
`git checkout gh-pages; git checkout master README.md` | |
path = `pwd`.gsub(/\n/, "") | |
readme_path = File.join(path, "README.md") | |
index_path = File.join(path, "index.md") | |
# write the index readme file |
This file contains 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
brew link libffi --force | |
export PKG_CONFIG_PATH="/usr/local/opt/libffi/lib/pkgconfig" | |
gem install ffi |
This file contains 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
group :development do | |
gem "ruby-prof" | |
end |
This file contains 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
class AssignableJob < ApplicationRecord | |
has_many :assignments, as: :record, dependent: :destroy | |
scope :assigned, -> do | |
subquery = Assignment.where(record_type: name).where(Assignment.arel_table[:record_id].eq(arel_table[:id])).select(Assignment.arel_table[Arel.star].count) | |
where "(#{subquery.to_sql}) > 0" # TODO: move to Arel & remove string interpolation | |
end | |
end |
This file contains 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
<% 100.times do |i| %> | |
user_<%= i %>: | |
id: <%= SecureRandom.uuid %> | |
first_name: <%= Faker::Name.first_name %> | |
last_name: <%= Faker::Name.last_name %> | |
email: <%= Faker::Internet.email %> | |
phone: <%= Faker::PhoneNumber.cell_phone %> | |
<% end %> |