Skip to content

Instantly share code, notes, and snippets.

View fernandes's full-sized avatar
🤓
Programming

Celso Fernandes fernandes

🤓
Programming
View GitHub Profile
@lazaronixon
lazaronixon / dropzone_controller.js
Last active June 19, 2024 19:43
Dropzone.js + Stimulus + Active Storage
import { Controller } from "stimulus"
import { DirectUpload } from "@rails/activestorage"
import Dropzone from "dropzone"
import { getMetaValue, findElement, removeElement, insertAfter } from "helpers"
Dropzone.autoDiscover = false
export default class extends Controller {
static targets = [ "input" ]
@thbar
thbar / _readme.md
Last active March 27, 2020 19:42
Using minitest to regression test your Jekyll static site

Using minitest to regression-test your Jekyll static site

I recently had to upgrade my blog, which involved changes such as:

  • Replacing a sitemap plugin
  • Upgrading from jekyll 2.5.3 to 3.8.4
  • Upgrading from jekyll-assets 0.7.8 to 3.0.11
  • (etc)

The upgrading process was not trivial, and some parts (e.g. RSS, sitemap, or twitter cards tags) are not immediately visible, so I decided to add unit tests on the generated content.

files: ./spec/**/*_spec.cr
run: crystal spec %file%
---
files: ./src/**/*.cr
run: crystal spec
POST /oauth/token HTTP/1.1
Content-Type: application/json

{
  "grant_type": "password",
  "client_id": "CLIENT_ID",
  "owner_type": "OWNER_TYPE",
  "username": "OWNER_EMAIL",
 "password": "OWNER_PASSWORD"
@Ravenstine
Ravenstine / reactor.cr
Created September 8, 2015 05:29
A very simple event loop written in Crystal. (crystal-lang.org)
module Reactor
class Task
property :block
def initialize(timestamp=Time.now, milliseconds=0, &block : Loop ->)
@block = block
@timestamp = timestamp.epoch_ms
@milliseconds = milliseconds
end
def run reactor
# Additional translations at https://github.com/plataformatec/devise/wiki/I18n
# Utilize-o em 'config/locales/', com o nome de 'devise.pt-BR.yml'.
# Em 'config/application.rb', utilize => config.i18n.default_locale = :'pt-BR'
pt-BR:
devise:
confirmations:
confirmed: "Sua conta foi confirmada com sucesso."
send_instructions: "Você receberá um e-mail para confirmar sua conta em alguns minutos."
@sstur
sstur / dom-to-json.js
Last active October 8, 2023 04:17
Stringify DOM nodes using JSON (and revive again)
function toJSON(node) {
let propFix = { for: 'htmlFor', class: 'className' };
let specialGetters = {
style: (node) => node.style.cssText,
};
let attrDefaultValues = { style: '' };
let obj = {
nodeType: node.nodeType,
};
if (node.tagName) {