Updated: Ruby doesn't sort strings with German umlauts correctly
I posted a solution which is awesome and also does natural sorting.
Don't use Ruby 1.9.2
Ruby 1.9.2 is very slow when loading files, especially starting Rails servers or running specs takes forever.
Do yourself a favor and upgrade to 1.9.3.
Order of multiple "rescue_from" statements might be unexpected
Take care when using rescue_from to rescue multiple errors.
The following will not work, because later rescue_from statements take precedence and so the first one will never be called:
rescue_from AccessDenied, :with => :redirect_to_home
rescue_from Exception, :with => :render_500
Simply reverse them.
GNOME3 Notifications For Skype ~ Web Upd8: Ubuntu / Linux blog
- Also works on Gnome 2
- Much prettier than Skype notifications
- Better visibility
Do not use "find" on Capybara nodes from an array
In a nutshell: Capybara's find will not work properly on nodes from a list. Don't find on elements from a list.
Background
Consider this HTML:
<div class="message">
<h2>Hello World</h2>
Lorem ipsum...
</div>
<div class="message">
<h2>Hello Universe</h2>
Lorem ipsum...
</div>
Now let's say you obtain a list of all such message containers as an array:
messages = page.all('.message')
And then you look at their titles like this:
messages[0].find('h2').text
=> "Hello W...
Use Nokogiri to convert CSS to XPath
CSS is a lot easier to write and read than clumsy XPath expressions. So when you need to use XPath, you can have Nokogiri help you out on creating it.
Simply use Nokogiri's xpath_for:
Nokogiri::CSS.xpath_for('#foo')
# => ["//*[@id = 'foo']"]
Nokogiri::CSS.xpath_for('#foo .bar:nth-of-type(2)')
# => ["//*[@id = 'foo']//*[contains(concat(' ', @class, ' '), ' bar ') and position() = 2]"]
Since XPath is more powerful you may still need to do some hardcore XPath hacking eventually. But at least you don't need to for simple cases.
LibreOffice won't embed most fonts into PDFs (with fix)
- LibreOffice Impress, Writer, etc. doesn't embed most fonts into the PDFs it generates.
- This means if you share a slide show with a font that is not Arial or Times, other people will get an error message "Cannot extract the embedded font 'XYZ Some characters may not display or print correctly" and unreadable text. Everybody loses.
- Some forums will recommend that you tick "PDF/A-1a" in the PDF options to make LibreOffice embed fonts. In reality, thi...
Rails 2's CookieStore produces invalid cookie data, causing tests to break
Note that this seems to affect only recent Rails 2 versions.
You will not encounter this until you are writing to the cookie more than once, but when doing so, integration tests (Cucumber) may break for you with this error:
You have a nil object when you didn't expect it!
You might have expected an instance of ActiveRecord::Base.
The error occurred while evaluating nil.[] (NoMethodError)
Background
The regular/short cucumber backtrace is not of any help but looking at the full trace reveals that ActionPack's `actio...
How much should I refactor?
The Rails community has been abuzz with object-oriented programming, SOLID principles, laws, design patterns, and other principles, practices, and patterns. We’ve (re)discovered new tools and techniques to separate and reuse logic, making code easier to test, understand, and maintain. Now that we’ve learned about all these new tools, when do we use them?
LibreOffice Impress: Distorted text letters in presentation mode
Upgade to LibreOffice 3.5.3+ or disable hardware accelleration in Tools → Options → LibreOffice → View → Graphic output.
CSS3 Media Queries have reached recommendation status
Media Queries have reached W3C Recommendation on June 19th 2012.
If you were interested in other (future) web standards you can have a look at recent W3C publications.
Using ENUMs with Rails - See John Code
This sounds promising:
The best part from the Rails side, is that you don’t have to change anything at all in your code to swap a varchar out for an ENUM.
Show hint in HTML 5 text fields
To have your text input field pre-filled in with some text that disappears as soon as the user selects it, use the attribute placeholder:
<input type="text" placeholder="User name here">
This will only work in recent browsers (IE >= 10, FF >= 4, Chrome >= 4, Safari >= 5, Opera >= 11.6).
Updated: Puppet 2.6.x on Ubuntu lucid 10.04
New way to install an actual puppet version on ubuntu
Calendar quarter calculations in Ruby and MySQL
ActiveSupport >= 3 has
Date.parse('2011-02-10').beginning_of_quarter #=> 2011-01-01
Date.parse('2011-02-10').end_of_quarter #=> 2011-03-31
You can manually calculate the quarter index like
(Date.parse('2011-02-10').month / 3.0).ceil #=> 1
Yes, you do actually divide by 3.0, not 4.0.
MySQL has
SELECT QUARTER('2011-02-10'); #=> 1
Preloaders.net - AJAX loading GIF and APNG spinners, bars and 3D animations generator
Generated animations are free to use without backlink obligations...
... WITH THE EXCEPTION of any other animated images generator applications
Haha :)
Trouble changing filename casing in git
On case-insensitive file systems like Mac's HFS+ (per default – you may change this, but it won't work for all programs), git won't recognize when you change the casing of files in your repository.
Workaround
git mv -f oldfile.name Oldfile.name
Mysql/Mysql2 agnostic database.yml
If you upgrade to the mysql2 gem, you will run into the problem that the server's database.yml (which is usually not under version control) needs to change exactly on deploy.
You can however make your database.yml work for mysql and mysql2 at the same time. Simpy do this
production:
adapter: <%= defined?(Mysql2) ? 'mysql2' : 'mysql' %>
#...
Security fixes for Rails 2.3
Last week saw a security issue with rails 2.3 that required a fix. While an official patch was provided, the 2.3 branch is no longer maintained. So we forked it.
(I'm sure there are already 100 other forks doing absolutely the same, but they are not very easily discoverable.)
To use our fork, change the gem "rails"... line in your Gemfile to this:
gem 'rails', :git => 'https://github.com/makandra/rails.git', :branch => '2-3-fixes'
The intent is to make as few changes to the f...
Skype 4.0 for Linux
Promises unified window for all chat conversations, better call quality.
Upgrade seems to work fine. If you installed your old skype from a Ubuntu repository, you need to remove it first using:
sudo apt-get remove skype
Then simply install the .deb from the official page. You won't lose any settings.
archan937/ruby-mass
Introspect the Ruby Heap by indexing, counting, locating references to and detaching (in order to release) objects.
The asset pipeline does not like files that look like fingerprints
If you have a file that looks like a precompilation fingerprint, the Rails asset pipeline will not see it. So don't have filenames like this:
8e21264d-f678-4005-b90c-8d8288a0d179.ttf
Updated: Helpers to render (money) amounts
- The
amounthelper now retrieves the decimal separator from your I18n dictionary (number.format.separator) instead of hardcoding it to a comma. -
money_amounthelper tunnels options toamount - New
money_amountoption:zero_as_dash
Responsive Inspiration
A collection of inspirational websites using media queries and responsive web design. Curated by Eivind Uggedal (@uggedal).