Skip to content

Instantly share code, notes, and snippets.

View rafasoares's full-sized avatar
☠️
Metal is the law

Rafael Soares rafasoares

☠️
Metal is the law
View GitHub Profile
@rafasoares
rafasoares / replace_pack_media.rb
Last active May 26, 2020 21:56
Updates old, flat media/ webpacker paths to use the proper nested path, from manifest.json
require 'json'
regex = /(?<quote>['"])media\/(?<name>.*?)\k<quote>/
manifest = JSON.load File.read('./public/packs/manifest.json')
glob = File.join 'app', '**', '*.*'
Dir[glob].each do |filename|
next unless filename =~ /^app\/.*\.(erb|rb|js|css|sass|scss|coffee|es6|jsx)$/
@rafasoares
rafasoares / block_bad_requesters.py
Created April 30, 2020 17:20
Lambda@Edge function to add IPs requesting known exploitable URLs
import boto3
import json
import logging
import os
from base64 import b64decode
LOCAL_IPS = ['::1', '127.0.0.1', '0.0.0.0']
ENCRYPTED_ACL_ID = os.environ['encryptedAclId']
@rafasoares
rafasoares / README.md
Last active August 24, 2020 23:46
Generates a changelog from Git commits since previous version (macOS)

Git Changelog ZSH/Oh My Zsh plugin (macOS)

This function generates a nicely formatted changelog, great for GitHub releases, from the commit summaries since the specified revision/tag.

Usage:

$ gchlg v1.0.0
## CHANGELOG
@rafasoares
rafasoares / Mega.ipynb
Created December 27, 2019 15:52
Mega generator
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rafasoares
rafasoares / Mega.ipynb
Created December 27, 2019 15:52
Mega generator
Sorry, something went wrong. Reload?
Sorry, we cannot display this file.
Sorry, this file is invalid so it cannot be displayed.
@rafasoares
rafasoares / nvm.sh
Created December 10, 2019 17:02
Adds NVM support to the shell and automatically loads the correct Node version if a folder has a .nvmrc file
export NVM_DIR="$HOME/.nvm"
[ -s "$NVM_DIR/nvm.sh" ] && \. "$NVM_DIR/nvm.sh" # This loads nvm
[ -s "$NVM_DIR/bash_completion" ] && \. "$NVM_DIR/bash_completion" # This loads nvm bash_completion
autoload -U add-zsh-hook
load-nvmrc() {
local node_version="$(nvm version)"
local nvmrc_path="$(nvm_find_nvmrc)"
if [ -n "$nvmrc_path" ]; then
@rafasoares
rafasoares / unsample.sh
Created December 2, 2019 22:28
Copies .sample/.example files, removing the .sample/.example extension
# Copies .sample/.example files, removing the .sample/.example extension
function unsample() {
for file in **/?(.)*.@(sample|example); do
cp $file ${file/.(sample|example)/}
done
}
@rafasoares
rafasoares / copy_and_rename_sample_files.sh
Created August 9, 2019 16:19
Copying `.sample` files removing the `.sample` extension (one liner)
for file in *.sample; do cp $file ${file/.sample/}; done
@rafasoares
rafasoares / devise.pt-BR.yml
Last active September 13, 2017 16:43 — forked from mateusg/devise.pt-BR.yml
pt-BR translations for Devise
# encoding: UTF-8
# pt-BR translations for Devise
pt-BR:
devise:
confirmations:
confirmed: "Sua conta foi confirmada com sucesso. Você está logado."
send_instructions: "Dentro de minutos, você receberá um e-mail com instruções para a confirmação da sua conta."
send_paranoid_instructions: "Se o seu endereço de e-mail estiver cadastrado, você receberá uma mensagem com instruções para confirmação da sua conta."
failure:
already_authenticated: "Você já está logado."
@rafasoares
rafasoares / Assembla instructions
Last active August 29, 2015 14:07
Assembla Instructions
How to Setup Assembla's Perforce repo on your machine
=============================================
1. Install the P4V client.
_During setup, there'll be a wizard to help you connect. Feel free to go through it, but it probably won't work, due to some special configurations Assembla requires._
1. Create a file named `p4config.txt` somewhere on your computer (preferably somewhere you have write access)
1. Copy this into it (replace `[username]` with your Assembla username):
```
P4PORT=perforce.assembla.com:1666
P4HOST=beings-of-light.tribal-phase