Skip to content

Instantly share code, notes, and snippets.

View leastbad's full-sized avatar
🤠
Keeping it real for the rest of us.

leastbad leastbad

🤠
Keeping it real for the rest of us.
View GitHub Profile
@leastbad
leastbad / struct.rb
Created May 7, 2021 10:15 — forked from KonnorRogers/struct.rb
Using hashes for structs
# using a predefined hash
hash = { field1: "foo", field2: "bar" }
HashStruct = Struct.new(*hash.keys, keyword_init: true)
hash_struct = HashStruct.new(hash)
hash_struct.field1 # => "foo"
hash_struct.field2 # => "bar"
hash_struct.field3 # => ERROR!
<div class="card">
<div class="card-header">
<h3 class="card-title">
<%= notification.to_notification.in_app_subject %>
</h3>
</div>
<div class="card-body">
<%= notification.to_notification.in_app_body %>
</div>
</div>
@leastbad
leastbad / slim_select_controller.js
Created February 9, 2021 02:21 — forked from rickychilcott/slim_select_controller.js
Slim-select stimulus controller
import { Controller } from "stimulus"
import SlimSelect from "slim-select"
import "slim-select/dist/slimselect.min.css"
import "../style/slimselect-customized.css"
export default class extends Controller {
connect() {
const limit = this.data.get("limit")
const placeholder = this.data.get("placeholder")
const searchText = this.data.get("no-results")
@leastbad
leastbad / plink-plonk.js
Created February 15, 2020 18:35 — forked from tomhicks/plink-plonk.js
Listen to your web pages