Search_spinner Cross_grey Magnifier
help

Search syntax

  • Search for repeating cards with repeats:yes
  • Search for unfinished cards with unfinished:yes
  • Search for cards in a certain topic with topic:"name"
  • Search for phrases with "a phrase"
  • Exclude a word from search: -word
  • Exclude a phrase from search: -"a phrase"
  • Exclude a topic from search: -topic:"name"

Some useful Unicode chars

Copy and paste at will, they're free!

  • German quotation marks: „ “ (Ubuntu-Hotkey: AltGr+v and AltGr+b)
  • English quotation marks: “ ”
  • En dash: –
  • Em dash: —
  • Ellipsis: …

Some useful hints for users of Ubuntu Linux

  • Your Ubuntu comes with a searchable list of Unicode chars. Go to Accessories / Character map. Ctrl + F searches for a character by name.
  • If you want to write all of them (and more) yourself, [configure a compose key](https://makandracards.com/makandra/1030-insert-an…

Normalize characters in Ruby

Using ActiveSupport

ActiveSupport comes with a #transliterate method which replaces characters with their low-ASCII equivalent (to strip accents etc.:):

ActiveSupport::Inflector.transliterate('aäoöuü') # => "aaoouu"

You can also add custom rules in your I18n dictionary like this:

de:
  i18n:
    transliterate:
      rule:
        Ä: 'Ae'
        Ö: 'Oe'
        Ü: 'Ue'
        ä: 'ae'
        ö: 'oe'
        ü: 'ue'
        ß: 'ss'

With this you get:

ActiveSupport::Inflector.transliterate('a...
External content

GNOME3 Notifications For Skype ~ Web Upd8: Ubuntu / Linux blog

  • Also works on Gnome 2
  • Much prettier than Skype notifications
  • Better visibility

LibreOffice won't embed most fonts into PDFs (with fix)

Note: There's more to it than this card says. All we know right now is that sometimes PDFs generated by LibreOffice don't render properly on some machines, with e.g. characters appearing as dots. We don't know if the font is to blame, or LibreOffice, or particular versions of LibreOffice.


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.

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).

BigDecimal#inspect for people who aren't cyborgs

I wonder if the guy that wrote BigDecimal#inspect has a tragic backstory that explains why he hates humanity.

- Tim Pope

I finally gave up and made BigDecimal#inspect return BigDecimal#to_s:

p BigDecimal.new('2.3') #=> "2.3"

Use the attached initializer.

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.

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...

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…

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.

Updated: Puppet 2.6.x on Ubuntu lucid 10.04

New way to install an actual puppet version on ubuntu

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.

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 c…

External content

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?

External content

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.

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 #=> 3

MySQL has

SELECT QUARTER('2011-02-10'); #=> 1
3019 cards