Skip to content

Instantly share code, notes, and snippets.

View zavan's full-sized avatar
🏠
Working from home

Felipe Zavan zavan

🏠
Working from home
View GitHub Profile
@zavan
zavan / lorena.rb
Last active December 3, 2016 23:34
class Teste
include Enumerable
attr_reader :n
def initialize(n)
@n = valid?(n) ? n.to_i : 100
end
def each
@zavan
zavan / dry-validation.pt-BR.yml
Created February 15, 2017 07:19
dry-validation pt-BR I18n error messages
pt-BR:
errors:
or: "ou"
array?: "deve ser um array"
empty?: "deve estar vazio"
excludes?: "não pode incluir %{value}"
excluded_from?:
@zavan
zavan / perf.rake
Created March 31, 2017 16:23
Clarance auth strategy for derailed_benchmarks
# See: https://github.com/thoughtbot/clearance/blob/3e9529a643cff20beb9bb49eacedb90dee49d465/lib/clearance/testing/controller_helpers.rb
class ClearanceAuth < DerailedBenchmarks::AuthHelper
def setup
require 'clearance/session'
@user = User.first # Change to fit your needs
end
def call(env)
env[:clearance] = Clearance::Session.new(env)

Keybase proof

I hereby claim:

  • I am zavan on github.
  • I am zavan (https://keybase.io/zavan) on keybase.
  • I have a public key ASB4ihhy842Chr2enc96nl_Z7X-q2ifWY5sdm45FnDPk9wo

To claim this, I am signing this object:

@zavan
zavan / playbook.yml
Last active May 9, 2023 01:23
Import system timezones to MySQL and configure its default timezone with Ansible
vars:
timezone: America/Sao_Paulo
- name: Get current MySQL timezone
become: yes
mysql_variables:
variable: time_zone
register: mysql_tz
- set_fact:
@zavan
zavan / rbenv.yml
Created April 28, 2020 14:55
Ansible role for installing rbenv and ruby
---
- name: Find user home
set_fact:
user_home: "{{ ansible_env.HOME }}"
- name: Set rbenv dir
set_fact:
rbenv_dir: "{{ user_home }}/.rbenv"
- name: Set rbenv bin path
@zavan
zavan / typing_pwn.js
Created June 2, 2020 22:20
Fooling typing.com and breaking records
// Just open a test page on typing.com and run this on the browser console:
// Tested on Safari.
// If you get errors, increase the setTimeout time.
$('.letter').each(function(i) {
setTimeout(() => {
const text = $(this).text();
let char = text;
let charCode = char.charCodeAt(0);
@zavan
zavan / typingtest_pwn.js
Created June 6, 2020 23:36
Fooling typingtest.com and breaking records
let time = 10; // Increase this if you're getting typing errors
function pressKey(key, code, eventType = 'keypress') {
console.log(`Typing "${key}" (${code}) with event ${eventType}`);
let event = new KeyboardEvent(eventType, {
key: key,
keyCode: code,
which: code,
charCode: code
@zavan
zavan / mysql2-monterey.md
Last active May 5, 2022 10:18 — forked from fernandoaleman/mysql2-mojave.md
Install mysql2 gem on MacOS Monterey

For MacOS Catalina, visit Install mysql2 on MacOS Catalina

Problem

Installing mysql2 gem errors on MacOS Monterey.

Solution

Make sure openssl is installed on Mac via Homebrew.

@zavan
zavan / check_spell.rb
Last active September 4, 2020 11:48
Parsing aspell CLI output with Ruby for TinyMCE
# See https://stackoverflow.com/a/63740582/1415262
class TinymceController < ApplicationController
skip_forgery_protection
respond_to :json
def spellcheck
suggestions = check_spelling_new(
spellcheck_params[:text],