Skip to content

Instantly share code, notes, and snippets.

Avatar

Lucas Caton lucascaton

View GitHub Profile
@lucascaton
lucascaton / cpf_cnpj_validators.rb
Created Jul 27, 2011 — forked from gouvermxt/cpf_cnpj_validators.rb
validação de CPF e CNPJ em Ruby
View cpf_cnpj_validators.rb
#------------------------------------------------------------------------------
# Rotinas para verificação de CPF e CNPJ
# Linguagem: Ruby
# Escrito por: André Camargo < andre@boaideia.inf.br > http://blog.boaideia.inf.br
# Use, copie, melhore a vontade! Patches são bem-vindos...
#------------------------------------------------------------------------------
def check_cpf(cpf=nil)
return false if cpf.nil?
nulos = %w{12345678909 11111111111 22222222222 33333333333 44444444444 55555555555 66666666666 77777777777 88888888888 99999999999 00000000000}
@lucascaton
lucascaton / reinstall.sh
Created Aug 16, 2012 — forked from tomas-stefano/reinstall.sh
Reinstalling Mysql on Mac via Homebrew
View reinstall.sh
brew remove mysql
brew cleanup
launchctl unload -w ~/Library/LaunchAgents/com.mysql.mysqld.plist
rm ~/Library/LaunchAgents/com.mysql.mysqld.plist
sudo rm -rf /usr/local/var/mysql
View iTunesMatchMetadata.rb
#!/usr/bin/env ruby
# by @tapbot_paul
# http://dump.beaugil.es/blog/itunesmatch/
# Don't blame me if this nukes your metadata, formats your drive, kills your kids
# This script goes through any iCloud Matched songs in your iTunes library and tries to update the
# metadata from the iTunes Store
# Will run against selected tracks or if nothing selected entire library
# install the required gems with the following commands
View Rails' time zones
* UTC -11:00 *
American Samoa
International Date Line West
Midway Island
Samoa
* UTC -10:00 *
Hawaii
* UTC -09:00 *
@lucascaton
lucascaton / haml2erb.rb
Last active Sep 24, 2020 — forked from 3zcurdia/haml2erb.rb
HAML to ERB converter with herbalizer
View haml2erb.rb
#!/usr/bin/env ruby
# frozen_string_literal: true
require "httparty"
class Converter
def initialize(filename)
@content = File.open(filename).read
end
attr_reader :content
@lucascaton
lucascaton / helo.asm
Created Aug 28, 2011
Um "Hello, World!" feito para ilustrar a palestra sobre programação para Atari 2600 (slides em http://slideshare.net/chesterbr)
View helo.asm
;
; hello.asm
;
; Um "Hello, World!" feito para ilustrar a minha palestra sobre programação
; para Atari 2600 (slides em http://slideshare.net/chesterbr).
;
; O código é livre (vide final do arquivo). Para compilar use o DASM
; (http://dasm-dillon.sourceforge.net/), através do comando:
;
; dasm hello.asm -ohello.bin -f3
@lucascaton
lucascaton / heroku-db-url-to-spring-boot.sh
Created Jan 4, 2020 — forked from wwerner/heroku-db-url-to-spring-boot.sh
Parse Heroku DB URL into Spring Boot Datasource Environment Variables
View heroku-db-url-to-spring-boot.sh
# Two possibilities to parse a Postgres DB URL from heroku into environment variables
# that Spring Boot understands.
# You would need that, if you do not build on heroku but push docker images
# from another source
# Does not need bash. Works on alpine linux / busybox. Tested with openjdk:8-jdk-alpine base image.
export DATABASE_URL=postgres://user:password@host:port/database
# Naive way, would break with [@:/] in username or password.
DB_TYPE=$(echo $DATABASE_URL | awk -F'[:@/]' '{print $1}')"ql"
View rails-credentials.md
Env Encrypted file Secret key path Command
Generic config/credentials.yml.enc config/master.key rails credentials:edit
Development config/credentials/development.yml.enc config/credentials/development.key rails credentials:edit --environment development
Test config/credentials/test.yml.enc config/credentials/test.key rails credentials:edit --environment test
Staging config/credentials/staging.yml.enc config/credentials/staging.key rails credentials:edit --environment staging
Production config/credentials/production.yml.enc config/credentials/production.key `rails credentials:e
View auth.js
document.addEventListener('DOMContentLoaded', () => {
const uri = URI(window.location.href);
const cookieName = uri.path() + '-auth';
const authParam = uri.query(true)['auth'];
const wbp = document.querySelector('head meta[name=wbp]').content;
if (isUserAuthenticated()) {
document.querySelector('body').setAttribute('style', ''); // Show page
} else {
if (checkWBP()) {