Skip to content

Instantly share code, notes, and snippets.

View rainerborene's full-sized avatar

Rainer Borene rainerborene

View GitHub Profile
@rainerborene
rainerborene / dom.js
Last active February 17, 2022 14:54
rails-ujs is a past thing. Here is how you can accomplish almost the same behaviour with Stimulus and Hotwire.
export function reduceToParams(elements) {
return elements.reduce((hash, node) => Object.assign(hash, { [node.name]: node.value }), {})
}
export function stopEverything(e) {
e.preventDefault()
e.stopPropagation()
e.stopImmediatePropagation()
}
@rainerborene
rainerborene / bunny.rb
Last active June 26, 2020 14:35
Ruby integration for generating URLs for Bunny CDN.
# frozen_string_literal: true
class Bunny::Url
attr_reader :path, :expires_in, :options
def initialize(path, options = {})
@path = path.respond_to?(:key) ? path.key : path
@expires_in = options.delete(:expires_in) || 1.week
@options = options
end
Error:
Api::V1::ScoresControllerTest#test_should_rescue_validation_errors:
NameError: undefined local variable or method `view_context' for #<Api::V1::ScoresController:0x000055e37a95b470>
Did you mean? view_runtime
/home/virtualbox/.asdf/installs/ruby/2.6.1/lib/ruby/gems/2.6.0/gems/active_decorator-1.2.0/lib/active_decorator/monkey/action_controller/base/rescue_from.rb:10:in `rescue_with_handler'
/home/virtualbox/.asdf/installs/ruby/2.6.1/lib/ruby/gems/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal/rescue.rb:25:in `rescue in process_action'
/home/virtualbox/.asdf/installs/ruby/2.6.1/lib/ruby/gems/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal/rescue.rb:21:in `process_action'
/home/virtualbox/.asdf/installs/ruby/2.6.1/lib/ruby/gems/2.6.0/gems/actionpack-5.2.3/lib/action_controller/metal/instrumentation.rb:34:in `block in process_action'
/home/virtualbox/.asdf/installs/ruby/2.6.1/lib/ruby/gems/2.6.0/gems/activesupport-5.2.3/lib/active_support/notifications.rb:168:in `block
import { useState, useEffect } from 'react'
const store = {
state: {},
setters: []
};
export function setStore(value) {
store.state = value;
store.setters.forEach(setter => setter(store.state));
<style>
.nav-item-ranking { display: none }
</style>
<style>
:root {
--invite-bg: url("https://store-images.s-microsoft.com/image/apps.56149.13510798887023509.52cb7b9d-27cf-417d-b33e-e4e758263928.1129934f-d053-41a1-935a-20913a56ea70?mode=scale&q=90&h=720&w=1280");
}
</style>
function! s:setup_insmode()
inoremap <buffer> <silent> <nowait> <Esc> <C-r>=lexima#insmode#escape()<CR><Esc>
endfun
function! Multiple_cursors_before()
let b:lexima_disabled = 1
silent! iunmap <buffer> <esc>
augroup lexima
au!
augroup END
endfunction
WITH RECURSIVE lectures AS (
SELECT lessons.id, title, ancestry, section_id, lessons.position FROM lessons
JOIN sections ON sections.id = section_id AND sections.deleted_at IS NULL
WHERE lessons.course_id = ? AND lessons.deleted_at IS NULL
ORDER BY ancestry ASC NULLS FIRST, sections.position ASC, sections.created_at ASC, lessons.position ASC
),
nodes AS (
SELECT ARRAY[section_id] AS path, * FROM lectures
WHERE ancestry IS NULL
<style>
.button.is-primary,
.button.is-primary:hover,
.button.is-primary:active,
.button.is-primary:disabled {
background-color: red; /* COR DO BOTÃO */
}
.notification.is-info {
background-color: blue; /* COR DA CAIXA */
gonano@data.db.5.1:/data $ aws
Traceback (most recent call last):
File "/data/bin/aws", line 19, in <module>
import awscli.clidriver
File "/data/lib/python2.7/site-packages/awscli/c
import botocore.session
File "/data/lib/python2.7/site-packages/botocore
import botocore.configloader
File "/data/lib/python2.7/site-packages/botocore
from botocore.compat import six