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"

Fix capistrano errors: "no such file to load -- net/ssh/authentication/agent/socket" or "uninitialized constant Net::SSH::KnownHosts::SUPPORTED_TYPE"

There is a conflict between current capistrano versions and the 2.5.1 net-ssh gem. Make sure you upgrade to 2.5.2, then it should work again.

Remove space after links in Haml

Gist: Do it like this: %p #{link_to "www.makandra.com", "http://www.makandra.com"}!. Details below.


Haml is a great engine for writing shorter, readable HTML. However, there is one thing that troubles me regularly. Consider this Haml code:

%p
  Visit our homepage at
  = link_to "www.makandra.com", "http://www.makandra.com"
  !

Haml will insert a space around the generated link, the result is this (see the space before the exclamation mark!):

<p>
  Visit our website at <a href="http://www.makandra.com">www....

Rails 3 routing: Be careful with matching routes *including their format*

Today, this line made me trouble. Can you spot the mistake?

match 'sitemap.xml' => 'feeds#sitemap', :constraints => { :format => 'xml' }, :as => 'sitemap'

The mistake is to match sitemap.xml. Rails will by default strip any dot-anything, remember it as desired format and forward the rest of the request to the routing engine. Since we're making .xml part of the match, it is not available for format determination and Rails will set the format to html.

Unfortunately, the constraint won't complain in this case and Rails even ren…

External content

OCRA

OCRA (One-Click Ruby Application) builds Windows executables from Ruby source code. The executable is a self-extracting, self-running executable that contains the Ruby interpreter, your source code and any additionally needed ruby libraries or DLL.

ocra [option] script.rb

Will package “script.rb“, the Ruby interpreter and all dependencies (gems and DLLs) into an executable named “script.exe“.

rspec_candy is now a gem

Our awesome collection of rspec helpers (formerly known as "spec_candy.rb") is now available as a gem. It works, it is tested and there will be updates.

##Usage

Add rspec_candy to your Gemfile.

Add require 'rspec_candy/helpers' to your spec_helper.rb, after the rspec requires.

List of features

See on GitHub

External content

wysihtml5 - A better approach to rich text editing

wysihtml5 is an open source rich text editor based on HTML5 technology and the progressive-enhancement approach. It uses a sophisticated security concept and aims to generate fully valid HTML5 markup by preventing unmaintainable tag soups and inline styles.

Howto properly use vertical-align to align elements vertically

Note: We have card with all CSS centering options. You probably want to head over there and get an overview over what techniques are available for your use case and browser requirements.


Say you want to vertically align a div box inside a div container. This is how you do it:

HTML

<div id="container">
  <div class="box">
    <span> Some text...<br />in two lines. </span>
  </div>
</div>

CSS

External content

Get Rid of That Code Smell – Duplication

Removing duplication from the code is a seemingly easy task. In many cases it is pretty straight-forward – you look at similar bits of code and you move them to a common method or class that is reusable in other places. Right? No, not really. It is true that code that looks similar might be an indicator that there’s a duplication but it’s not the definitive way of determining the smell.

If we look for duplication in our code we should look for duplicated concepts instead of similarly looking lines of code.

Fix error: can’t find executable rails

If you get an error like this …

 can’t find executable rails for rails-3.2.3 (Gem::Exception)

… one of several things might be wrong.

  1. You're using RVM

It's possible that you have a system-wide gem executable (like rails) that requires a gem that is not available in the current RVM Ruby or gemset. Check what Ruby you are using (rvm current) and look out for .rvmrc files in your current directory (which change your Ruby upon entering the directory).

  1. You killed a gem install process ———-…

How to fix: RubyMine does not remember last used monitor (on Ubuntu)

Every time I started RubyMine, it opened the main window on the left monitor – when moving it to the center monitor and closing it, the next time it still opened up on the left one.

Here is how I forced RubyMine to start up on a different screen:

  1. Un-maximize the main window
  2. Move it to your preferred monitor
  3. Close RubyMine (keep it unmaximized)
  4. Start RubyMine again.
  5. You may now maximize your main window; the next time you start up RubyMine, it will open on the correct screen, maximized.

That's crazy!

IE9: Linear gradients remove border-radius and inset box-shadows

When you add a linear gradient to an element, IE9 removes all border-radius and inset box-shadows. This is because you probably are doing linear gradients with this weirdo Microsoft filter:

filter: progid:DXImageTransform.Microsoft.gradient(startColorstr='#0A284B', endColorstr='#135887');

filter hijacks the rendering of the entire element box, so you're out of luck. IE9 doesn't support CSS gradients.

A forward-looking workaround is to not use gradients and [emulate your gradients with box-shadows](https://makandracards.com/m…

MySQL 5.1: Switch to InnoDB Plugin for better performance

MySQL version 5.1 comes with an alternative, faster InnoDB implementation (called "InnoDB Plugin").

Switching is easy:

  • Stop your mysqld with sudo stop mysql
  • Add the following lines to your /etc/mysql/my.cnf under the [mysqld] section
    ignore-builtin-innodb
    plugin-load=innodb=ha_innodb_plugin.so
  • Start your mysqld with sudo start mysql

The file format has not changed, your tables should survive this.

Note: This is not necessary in MySQL 5.5, where the new implementation is the default.

When using time zones, beginning_of_day / end_of_day is broken in Rails 2 for any Date or DateTime

Using beginning_of_day or end_of_day on Date or DateTime objects in Rails 2.x applications will never respect time zones, which is horrible.\
This is fixed in Rails 3, though.

Even when using Date.current or DateTime.current you will get regular Time or DateTime objects:

>> Date.current.beginning_of_day.class
=> Time # not a ActiveSupport::TimeWithZone as expected
>> DateTime.current.beginning_of_day.class
=> DateTime ...
External content

Aspect Oriented Programming in Ruby

Slides presenting ways to integrate the ideas of Aspect-Oriented Programming in Ruby.

Outline

  • Why Aspect-Oriented Programming?
  • AOP in Java and AspectJ (a Review).
  • AOP in Ruby.
    • What you can do today.
    • Example AOP-isms in Ruby on Rails.
  • Aspect-Oriented Design.
  • The AOP Promise for Tomorrow.
External content

Three quick Rails console tips

How to call routes, make requests and try out helpers from the Rails console.

External content

salesking/king_dtaus

DTAUS & DTAZV are formats for German bank transfers and is short for "Datenträgeraustausch". The format itself totally sucks because it was established in the last century, to be used on floppy disks. Still almost all German banks use it (they only seem innovative at robbing), and it is therefore supported in common banking programs too.

This gem saves you all the trouble when generating DTAUS- or DTAZV-text.

You cannot use :before or :after on img in CSS

Though the W3C even gives it as an example, no browser actually supports this CSS:

img:before {
  content: "something";
}

Browsers will simply not render anything when doing that on images (Fun fact: It worked in an older version of Opera but got dropped).\
The same applies to the :after pseudo-element.

This makes me sad.

You can try using jQuery instead.

3019 cards