I hereby claim:
- I am somazx on github.
- I am somazx (https://keybase.io/somazx) on keybase.
- I have a public key ASC6zNYYHXFpwjIR-jMU4mCTT90NtXeNrzhD-k2mU-vd4go
To claim this, I am signing this object:
gem 'elasticsearch', '>= 1.0.15' | |
gem 'elasticsearch-model' | |
gem 'elasticsearch-rails' | |
gem 'patron' | |
gem 'faraday_middleware-aws-signers-v4' | |
gem 'searchkick' |
I hereby claim:
To claim this, I am signing this object:
Rails has several pain-points for more complex web applicatoins that frameworks like Hanami and Trailblazer attempt to address. By addressing theses issues your business logic is better isolated from the framework details/implementation, clearer responsibilities, easier reasoning about, cleaner code, creates opportunity for easy further abstraction when necessary, allows for simpler testing, etc.
Solutions: use custom autoload_paths/eager_load_paths in an initializer?
# config/application.rb | |
config.autoload_paths = Dir['app/domains/*/*/'] |
I wanted to store arbitrary nested data structures in a jsonb column and be able to retrieve and work with that data seemlessly within a Rails application. There are several tutorials covering different aspects of this, but none felt complete to me.
For this example we'll be working with a User
model that can define surveys. Each survey consists of n
multiple choices questions, and each question can have between two and ten answer options.
In this case we use Postgresql's JSONB support to store the data, but you could also use other forms of serializing such as a text
column and Rails' default YAML serializing. JSONB is chosen in this case because it leaves open the possiblity of querying the data with SQL. Also, apparently serializing to JSON is much faster.[1]
import { Controller } from "stimulus"; | |
export default class extends Controller { | |
static targets = ["counter", "input"]; | |
connect() { | |
this.updateCounter(); | |
} | |
trackLength() { |
import { Controller } from "stimulus"; | |
// Handles ordering elements on the page using | |
// buttons than can move the elements up or down. | |
// | |
// Usage: | |
// 1. Add data-controller orderable on a parent node. | |
// 2. (Optional) For persisting order to input fields: | |
// - add data-orderable-target="orderInput" | |
// 3. Wire up buttons or links to call up/down actions. |
/* | |
Purpose: easily obtain a list of your humble bundle games that haven't been redeemed. | |
Instructions: | |
1) Log into Humble Bundle as usual. | |
2) Navigate to https://www.humblebundle.com/home/keys | |
3) Open browser console and run the following script in the console | |
Script will dump to console the scraped list of all your unredeemed game keys. | |