View
External content

lang/unicode_utils · GitHub

UnicodeUtils implements Unicode algorithms for case conversion, normalization, text segmentation and more in pure Ruby code.

If you don't need the ton of features that UnicodeUtils offers, try stringex.

Edge Rider: Power tools for ActiveRecord scopes

In our continued quest to extract proven code snippets from makandropedia into tested and upgradable gems, we have released Edge Rider.

Edge Rider was created with two intents:

  1. Provides a number of utility methods to facilitate hardcore work with scopes.
  2. Provide a stable API for working with scopes across multiple versions of Rails, since Rails has a tradition of breaking details of its scope API every other release.

The gem bundles multiple patches and initializers we've been using for hard…

CSS: Set content from other attributes

You can use the content CSS attribute to set an element's content – which is especially useful for the :before and :after pseudo elements:

a:before {
  content: 'Click me: ';
}

The above example would prepend "Click me:" to any link on the page.

Note that you can also refer the contents of other attributes of the element. So, if your links have a helpful title set, you could do this:

a:before {
  content: attr(title) ": ";
}

There also is a jsFiddle for the examp…

External content

hint.css - A tooltip library in CSS

A tooltip library that does not use Javascript. Works in IE9+.

This library (or the technique used by it) could be a great choice for projects with a lot of tooltips, which are hard to do fast with Javascript.

Useful methods to process tables in Cucumber step definitions

When you accept a table in your Cucumber step definition, that table object will have the cryptic type Cucumber::Ast::Table. Don't immediately call table.raw to convert it into an array of arrays! Cucumber::Ast::Table has a lot of useful methods for tasks such as:

table.raw
Turn the table into an array of arrays
table.hashes
Convert the table to an array of hashes, where the keys are the table headers from the first row

table.headers

git "fatal: bad config file line" after checking out branch

If git gives you an error message such as "fatal: bad config file line 123 in .git/config" after you tried to checkout a branch with a very long branch name, you very likely come across a bug in git version < 1.8.

You should ask someone with a newer git version (someone pushed the branch right?) to rename the branch to something shorter:

git -m old-very-very-long-branch-name new-short-branch-name

How to fix: RVM does not offer recent Ruby versions

RVM needs to be updated regularly to know of Ruby versions released since installation (or last update).

So if you say rvm install 1.9.3, but get an old version (basically anything below 1.9.3-p385 when writing this card), your RVM is outdated. \
Fix that by saying:

rvm get stable

After that, rvm install 1.9.3 should install the latest 1.9.3 version.

External content

CSS 3D Clouds

This is awesome.

Only ran smoothly in Chrome. Is a slideshow in Firefox.

MySQL: For each group, retrieve a comma-separated list of values in a given column

The technique described in this card has an important caveat: The result of GROUP_CONCAT is truncated to the maximum length that is given by the group_concat_max_len system variable, which has a default value of 1024. This will cause horrible, data-destroying bugs in production. For this reason you should probably not use GROUP_CONCAT ever. At least you must set the value of group_concat_max_len to an insanely high value on every database server your application runs on.


Lik…

High Performance Networking in Google Chrome

About Chrome's network stack and optimizations to load web pages faster.

External content

What The Rails Security Issue Means For Your Startup

January has been a very bad month for Ruby on Rails developers, with two high-severity security bugs permitting remote code execution found in the framework and a separate-but-related compromise on rubygems.org, a community resource which virtually all Ruby on Rails developers sit downstream of. Many startups use Ruby on Rails. Other startups don’t but, like the Rails community, may one day find themselves asking What Do We Do When Apocalyptically Bad Things Happen On Our Framework of Choice? I thought I’d explain that for the general c…

Migrating IMAP accounts from server to server

Do not investigate in the 2342 tools that exist for migrating IMAP accounts from one server to another. They all suck.

Try your luck with imapsync.
We have no clue why the guys suggest buying the script on their site, maybe they missed removing that part after this April fool's trick.

Go to https://fedorahosted.org/released/imapsync/ and get the sources there.

How to fix: "Error Bundler::HTTPError during request to dependency API"

If bundle install shows the following message for you …

Error Bundler::HTTPError during request to dependency API

… upgrade to Bundler ≥ 1.2.4:

gem install bundler

Apparently, it just hides the message.

Prevent double clicks on link_to_remote (simple case)

This works well in the simplified case, when your link disappears after it was clicked.

Let link_to_remote behave as „disabled“ after the first click. Use the :before hook to replace the orignal link with a link that does nothing but looks like the original link:

```
:ruby
label = "do_something"
dummy_link = link_to(label)
other_attributes_hash = { :url => …, :method => …, … }

disable_link_option = { :before => "$('your_link_selector').html('#{escape_javascript(dummy_link)}'" } # jquery

= link_to_remote(label, other_att…

External content

5 reasons why I won't steal your idea

Since I'm a software architect and a web developer, I get often approached by people with their new ideas. In most cases, for some quality feedback, and on lucky days, for a rough quote about the costs of such a project. These people are usually very secretive about what they have, making me explain to them that it's far from my interest to steal that idea. (…) Focus on your product, and don't worry about me stealing your idea. I won't. I have at least five reasons not to.

How to test your website for different Internet Explorer versions?

Virtualization

Microsoft provides images with different IE and Windows combinations for different hosts.
There are also Virtual Box images for Linux hosts.

IETester

IETester is a web browser for Windows which allows you to use different IE rendering and JavaScript engines.

How to express ordinality with numbers in Rails

If you have an integer and want to use it to represent an element's position (like "1st" for 1, or "2nd" for 2), you can use ActiveSupport's ordinalize:

1.ordinalize     # => "1st"
2.ordinalize     # => "2nd"
1002.ordinalize  # => "1002nd"
1003.ordinalize  # => "1003rd"
-11.ordinalize   # => "-11th"
-1001.ordinalize # => "-1001st"

Test that a form field is visible with Cucumber/Capybara

Spreewald now comes with a step that tests if a form field is visible:

Then the "Due date" field should be visible
But the "Author" field should not be visible

The step works by looking up the field for the given label, then checks if that field is hidden via CSS (or Javascript).

It is not currently tested if the label is visible or hidden. For this see: [Check that an element is visible or hidden via CSS with Cucumber/Capybara](https://makandracards.com/makandra/1049-check-that-an-elem…

View
3390 cards