Skip to content

Instantly share code, notes, and snippets.

View MaiAbuthraa's full-sized avatar
:octocat:
Work remotely

Mai Abuthraa MaiAbuthraa

:octocat:
Work remotely
View GitHub Profile
@dbridges
dbridges / _comment.html.slim
Last active August 25, 2022 18:51
Stimulus.js and Rails remote forms with error handling
- # app/views/comments/_comment.html.slim
li data-controller="comment" data-action="click->comment#hello"
= "#{comment.message} by #{comment.user.email}"
@primaryobjects
primaryobjects / collapsible.png
Last active April 22, 2022 22:35
Collapsible tabs example in Bootstrap 4 alpha. Resize the page to see the tabs collapse into a dropdown menu. See demo https://plnkr.co/edit/6WVKhJcqfRNP6pDoq85N?p=preview
collapsible.png
@davidbella
davidbella / person.rb
Created October 10, 2013 13:37
Ruby: Dynamic meta-programming to create attr_accessor like methods on the fly
class Person
def initialize(attributes)
attributes.each do |attribute_name, attribute_value|
##### Method one #####
# Works just great, but uses something scary like eval
# self.class.class_eval {attr_accessor attribute_name}
# self.instance_variable_set("@#{attribute_name}", attribute_value)
##### Method two #####
# Manually creates methods for both getter and setter and then