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
Related cards:
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 ...
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...
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 ```...
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...
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...
ActiveRecord::NamedScopes (2.3.x) obtaining the SQL conditions
It's a good pratice to chain several named scopes like:
Property.listable.for_2_or_more_guests.best_10_properties
Now, to make the lesson more valuable let's assume the following code:
Property.scoped(:conditions => "foo = 2").scoped(...
Cleaner Rspec
When simply checking equality or truthiness then
Instead of:
it "should have role set to admin" do
@user.role.should eql('admin')
end
it "should be valid" do
@user.valid?.should be_true
end
Do:
it { @user.role.shou...
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...
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).
##...
Method return value should always be of same type
One of the main source of bugs and complexity in the code is when a functional method (that we expect to return a value) return different values under different circumstances.
For example, we ruby programmers have a bad habit of returning nil fro...