To avoid using bundle exec or creating rvm gemsets
- Add to the end your .bash_profile
export PATH="./vendor/bundle/bin:$PATH"
- Also add
alias bi="bundle install --path vendor/bundle --binstubs=vendor/bundle/bin"
- Then to bundle install next time just use
bi
Now no more bundle exec
before any rake, cap, spec or anything else :)
Related cards:
Bundle install in parallel
Gave a shot to the new Bundler 1.4.0RC1 during the weekend and found out it now supports gem installation in parallel. To invoke you need to pass --jobs
parameter with number of threads you want it to run – for me the best performance was achiev...
Creating a gem in lib folder
Go to lib folder and use bundler to generate main files for a gem:
$ bundle gem test_gem
create test_gem/Gemfile
create test_gem/Rakefile
create test_gem/LICENSE
create test_gem/README.md
...
If you GROUP BY, make sure you ORDER BY NULL
TL;DR: If using :group => :some_field
you might want to :order => 'NULL'
.
According to the man
By default, MySQL sorts all GROUP BY col1, col2, ... queries as if you ...
Database: Scopes, migrations, and indices
Wether you modify an existing named scope or add a new one, or when you write a new query, make sure you have the proper indices.
This particularly applies if you're going to run non-trivial queries of course (admin backends, analytics, etc).
##...
How to run long scripts on production/staging server
In a nutshell, use screen
Why?
Sometimes we are concerned that if our connection gets closed, the process we are running will close too.
The processes or login sessions you establish through screen don't go away. You can resume your...
Avoid png file uploads with RSpec + Paperclip + Imagemagick
File uploads with .png are +10 times slower than using .jpeg or .gif.
# Bad
post :create, {
:property_id => property.id,
:photo => {
:image => File.open("#{Rails.root}/public/images/foo.png")
}
}
# Go...
When you set date attributes, you should not pass times
As you know, time zones make stuff a bit more difficult but are necessary.
A time-zoned record is converted to UTC using to_s(:db)
to be st...
Rebase your feature branches
Regularly, but at least before merging your feature branches, rebase them to get rid of "fix typo" and "wip" commits.
Getting rid of unnecessary commits
Let's say you do a git rebase -i HEAD~~~~
and have this...
Error: unable to read font `/usr/local/share/ghostscript/fonts/n019003l.pfb' @ error/annotate.c/RenderFreetype/1123: `(null)'
This happens when your machine does not have ghostscript installed, to fix it simply do
brew install ghostscript
DateTimes are Dates, beware
Given:
datetime = DateTime.now
date = datetime.to_date #or Date.today
will assert:
datetime.is_a? Date == true
datetime.is_a? DateTime == true
datetime.instance_of? Date == false
datetime.instance_of? DateTime == true
In case y...