Skip to content

Instantly share code, notes, and snippets.

View hectorperez's full-sized avatar

Hector Perez hectorperez

View GitHub Profile
@hectorperez
hectorperez / tilde Spanish keyboard and the Spanish ISO
Created September 24, 2014 10:49
tilde Spanish keyboard and the Spanish (ISO) layout: alt + ñ
alt + ñ
# https://superuser.com/questions/406356/how-to-make-a-tilde-on-a-spanish-keyboard-set-to-english/468186#468186?newreg=a472f6df8a554bf29714d3dcc03403ef
@hectorperez
hectorperez / Create indexes in mongoid
Created September 23, 2014 16:59
Create indexes in mongoid
# after including:
index({attribute: 1}, {unique: true})
# run:
rake db:mongoid:create_indexes
# http://www.talkingquickly.co.uk/2013/06/indexes-with-mongoid-are-not-created-automatically/
@hectorperez
hectorperez / ProgressBar example - Thor tasks.rb
Last active August 29, 2015 14:06
ProgressBar example (for thor tasks)
users = User.all
progress_bar = ProgressBar.create({starting_at: 0, total: users.count, :format => '%e %B %P%% %t'})
users.each do |user|
# ...
progress_bar.increment
end
@hectorperez
hectorperez / .no_timeout after the query to run it without a timeout - Mongo
Created September 18, 2014 09:56
.no_timeout after the query to run it without a timeout (Mongo)
.no_timeout after the query to run it without a timeout (Mongo)
@hectorperez
hectorperez / stop - start heroku app
Created September 15, 2014 16:29
stop/start heroku app
heroku ps:scale web=0
heroku ps:scale web=1
or
heroku maintenance:on
heroku maintenance:off
# http://stackoverflow.com/questions/2811453/how-to-stop-an-app-on-heroku
@hectorperez
hectorperez / filter Rails logs which duration is greather than 500 ms.sh
Created September 4, 2014 17:18
filter Rails logs which duration > 500 ms
cat production.log | grep duration | awk 'a=$7,gsub(/[a-z=]/,"",a) {print a, $1, $2}' | awk '{if ($1 > 500) print $1, $2, $3}'
@hectorperez
hectorperez / cache classes - Rails.rb
Created August 29, 2014 13:44
cache classes (Rails)
# config/environments/development.rb
config.cache_classes = false¬
# In the development environment your application's code is reloaded on¬
# every request. This slows down response time but is perfect for development
# since you don't have to restart the web server when you make code changes.¬
@hectorperez
hectorperez / change url name for Rails resource.rb
Created August 27, 2014 15:09
change url name for Rails resource
resources :name, only: [:show], path: :url_name
@hectorperez
hectorperez / return from gf in Vim
Created August 27, 2014 14:13
return from 'gf' in Vim
Ctrl + o
@hectorperez
hectorperez / vim copy and paste to registers
Created August 22, 2014 10:56
vim copy and paste to registers
The default yank or delete goes into a place called a register (a register named "). If you need to delete some text before you paste, you need to avoid overwriting register x, as you've discovered. Fortunately, you can use any other letter or number to name a different register.
"ayy (yank a line into register a)
x, dd, etc. (delete some text into the unnamed register, ")
"ap (paste the text from register a)
# http://superuser.com/questions/371160/copy-delete-then-paste-in-vim