Skip to content

Instantly share code, notes, and snippets.

@arturopuente
arturopuente / preloadable.rb
Last active February 29, 2024 19:17
JSON-API Preloadable concern
module Preloadable
extend ActiveSupport::Concern
# A very common issue with APIs is that we want to preload relationships to
# avoid N+1 queries, something like this: /api/projects?include=users
# and this works well for attributes like the user name or their email, but
# what happens when you try to access their avatar? Yup. N+1.
# JSON:API, being a more generic standard, doesn't really know or give you
# tools to deal with Rails relationships and preloads easily. While this makes
@arturopuente
arturopuente / vimium
Last active April 21, 2019 08:55
vimium custom keyboard bindings
unmap /
unmap m
unmap `
unmap o
unmap O
unmap b
unmap B
unmap g0
unmap g$
unmap n
@arturopuente
arturopuente / iterm-word-movement-bindings.md
Last active June 7, 2017 15:15
iTerm word movement bindings

Preferences > Profiles > Keys

Delete to beginning of word

Option + Delete
Send Hex Codes
0x1B 0x17

Keybase proof

I hereby claim:

  • I am arturopuente on github.
  • I am arturopuente (https://keybase.io/arturopuente) on keybase.
  • I have a public key whose fingerprint is 5273 E705 07A9 9BC3 30EF 91EA 7753 66B7 6912 CF6B

To claim this, I am signing this object:

@arturopuente
arturopuente / git-lg.sh
Last active June 4, 2019 17:27
git lg
git config --global alias.lg "log --color --graph --pretty=format:'%Cred%h%Creset%C(red)%d%Creset %s %Cgreen(%ar) %C(bold blue)<%an>%Creset' --abbrev-commit"
# gem install ruby-mp3info
require 'mp3info'
# Formato: # Pista [espacio] Nombre
# Ejemplo de filtros:
# Antes: 05 - Run Run Run - The Velvet Underground.mp3
# filters = ["- ", " - The Velvet Underground"]
# Después: 05 Run Run Run.mp3
def prepare(name)