Skip to content

Instantly share code, notes, and snippets.

@jmwelch
Last active July 11, 2017 14:46
Show Gist options
  • Save jmwelch/581564bd9adb9a59158e1c0e94b81855 to your computer and use it in GitHub Desktop.
Save jmwelch/581564bd9adb9a59158e1c0e94b81855 to your computer and use it in GitHub Desktop.
Fun Things To Do
JS_PATH = "app/assets/javascripts/**/*.js";
Dir[JS_PATH].each do |file_name|
begin
Uglifier.compile(File.read(file_name))
print '.'
rescue
puts "\n#{file_name}"
end
end
https://stackoverflow.com/a/43662000/1507845
var object = { top_level: 2, attrs: { foo: { baz: 'bang' } } }
object.attrs.nope.no #=> Uncaught TypeError: Cannot read property 'no' of undefined
_.chain(object).get('attrs').get('nope').get('no', 'default').value(); #=> 'default'
# Nice % sign at end of input
config.wrappers :with_addon, tag: 'div', class: 'form-group with-addon', error_class: 'has-error' do |b|
b.use :html5
b.use :label, class: 'control-label', wrap_with: { tag: 'span', class: 'label-block' }
b.wrapper tag: 'span', class: 'input-group input-right' do |ba|
ba.use :input, class: 'form-control'
ba.wrapper tag: 'span', class: 'input-group-addon' do |ao|
ao.use :hint
end
end
b.use :error, wrap_with: { tag: 'span', class: 'help-block' }
end
# Usage
= f.input :tax_amount, wrapper: :with_addon, hint: '%'
# Definition
def checkbox_no_form(label: nil, **options)
capture do
concat content_tag :div, class: 'xcitee-checkbox', & -> do
concat content_tag :label, & -> do
concat label
concat content_tag :input, nil, { type: 'checkbox', **options }
concat content_tag :span, nil, class: 'x-checkbox'
end
end
end
end
# Usage
= checkbox_no_form(class: 'active-only', label: t('.active_only'), checked: checked)
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment