Skip to content

Instantly share code, notes, and snippets.

View gerardosandoval's full-sized avatar
:octocat:

Gerardo Sandoval gerardosandoval

:octocat:
View GitHub Profile
@gerardosandoval
gerardosandoval / toggle_comments.js
Last active May 4, 2018 19:23
Toggle Github Comments Bookmarklet
// Help you see referenced PR's And issues faster by hidding comments
javascript:(document.querySelectorAll(".edit-comment-hide").forEach(function(el){if (el.style.display === "none") {el.style.display = "block";} else {el.style.display = "none";}}))
@gerardosandoval
gerardosandoval / refactor.txt
Created May 22, 2018 23:34
Refactoring checklist
Taken from expertise.jetruby.com
Controller checklist
- the controller doesn’t have any business logic
- the controller doesn’t have any controlling constructions (except from “if success? then respond_with_success else respond_with_error end”)
- the controller doesn’t know anything about how the data is arranged (to make the user active, you need to call “current_user.activate!”, not current_user.update(status: ‘active’))
- there’s no duplicated logic for new, create and edit, update actions. The records should be in “before_action”
- in the “action” methods there is no validation of whether those methods can be executed (put all of that in “before_filter”).
@gerardosandoval
gerardosandoval / break_bm.rb
Created March 19, 2019 16:48
Benchmark break while loop
require 'benchmark'
n = 10000000
def with
remaining = 5000
step = 200
while remaining > 0
if remaining < step
@gerardosandoval
gerardosandoval / .rubocop.yml
Last active July 17, 2019 18:13
Rubocop configuration
Metrics/LineLength:
Description: 'Limit lines to 120 characters.'
StyleGuide: '#120-character-limits'
Enabled: true
Max: 120
Metrics/ClassLength:
Enabled: false
Metrics/AbcSize:
---
openapi: 3.0.3
info:
title: Arcus AutoPay
description: "Arcus \"Autopay\" es un servicio que permite el registro de facturas para pagos recurrentes y pagos únicos\n\n# Autenticación\n\n## Descripción\n\nEste sección del documento describe el método de autenticación requerido para habilitar la comunicación de servidor a servidor con Arcus API.\n\n## Método de Autenticación\n\nArcus API usa autenticación JSON Web Token, como se define en RFC7519. La generación del token se realiza del lado del cliente, mientras que Arcus se realizara las validaciones del token generado por el cliente.\n\n## Definición JWT\n\n### Header\n\nEl header debe contener los siguientes valores\n\n| Claim | Description | \n| ----- | ----------- |\n| alg | El algoritmo principal en uso para firmar, para Arcus API debe ser siempre HS256 que presenta HMAC usando un algoritmo hash SHA-256 |\n| typ | El tipo de medio de JWT, para Arcus API siempre debe ser JWT |\n\nUn ejemplo de un header con buen formato es:\n\n```json\n{ \"alg\":\"