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"

MySQL: Can I speed up LIKE queries by adding an index?

For string columns, MySQL indexes the left side of a string. That means an index can speed a like query that has a wildcard on the right side:

SELECT * FROM foo WHERE field LIKE "bar%" # will be faster with an index

It can not speed up a query that has a variable left side:

SELECT * FROM foo WHERE field LIKE "%bar%" # will not be faster with an index

That also means if you use the ancestry gem you should index your ancestry column if you use scopes like descendants or `su…

Why stubbing on associated records does not always work as expected

Be careful when stubbing out attributes on records that are defined by associations. Nothing is as it seems to be.

The associated record has its own universe of things; when delegating calls to it, you ca not stub methods on the associated record and expect them to be around. That is a general issue with this pattern/approach.

What's happening?

Consider these classes:

class Post < ActiveRecord::Base
  belongs_to :thread
  
  def thread_title
    thread.title
  end
end

class Thread < Acti...

Asset pipeline: Reasons why your stylesheet is empty

It might be one of the following:

  • You are looking at a manifest file (like application.css) which is always empty during development
  • Your Sass file has a syntax error it did not handle properly

ReText

ReText is a cross-platform WYSIWYG-ish Markdown editor.

Toggle editor and preview layout with Ctrl+E.\
Press Ctrl+L to split the window for a live preview.

I use it to copy Pivotal Tracker story descriptions over, switch to the preview and have it as a small always-on-top window in a corner of one of my screens.


On Ubuntu, you can use a PPA to install:

sudo add-apt-repository ppa:mitya57/ppa
sudo apt-get update
sudo apt-get install retext
External content

Silencing Your Staging Environment - The Hashrocket Blog

Testing with real live production data does come with at least one catch. All those real live users in your production environment have real live email addresses that receive real live emails.

The post includes monkey patch for ActionMailer that rewrites the domain of all recipients. It's a different take on the problem than our own mail_magnet gem.

Don't follow Ajax requests with a redirect

The behaviour of browsers is very inconsistent when an Ajax request is answered with a redirect. Highlights are:

  • IE 9 will follow a DELETE request with a second DELETE. You never want that.
  • Firefox will follow a POST request with a GET, as you might expect. If a PUT is redirected however, you will get a confirmation dialog, where you can choose to follow with a second PUT or simply abort. You don't want that either.

See some workarounds here.

RubyMine: Accessing views and partials from controllers

You can quickly access views that belong to a controller by using the tiny "page with arrow" icon in the gutter: icon

Access a method's view file

Click the icon next to the method definition in the controller.

If a view file does not yet exist, RubyMine will prompt you for its filename.

All views & partials associated to a controller

For a list of all views and partials that belong to the current …

External content

Git Landscaping

I recently worked on a project with 60+ old feature branches. Most of them had been merged into master and were subsequently abandoned. We decided we wanted to clean up a bit, and git made that easy.

External content

Firebug tip: Log DOM Events

This Firebug feature is called simply Log Events and allows developers to log DOM events into the Console panel.

All you need to do is right click on an element in the HTML panel, pick Log Events from the context menu and switch to the Console panel to see the logs in action.

External content

Twitter Bootstrap: Base CSS

Explanation of the "bootstrap 2" base CSS.

Contains information about:

  • Typography
  • Code
  • Tables
  • Forms
  • Buttons
  • Icons

Fix error: Missing the mysql2 gem

So you got this error, even though your Gemfile bundles mysql2:

!!! Missing the mysql2 gem. Add it to your Gemfile: gem 'mysql2'

or

Please install the mysql adapter: `gem install activerecord-mysql-adapter` (mysql is not part of the bundle. Add it to Gemfile.)

The reason for this confusing error message is probably that your Gemfile says mysql2, but your database.yml still uses the mysql adapter. Change it to use the mysql2 adapter:

```raw
development:
adapter: mysql2
database: myproject_developm…

External content

RubyMine 4.5.1: Sass/SCSS Support Improvements

A number of issues concerning Sass/SCSS autocompletion and syntax highlighting were submitted as a feedback for RubyMine 4.5. Web development with Rails can’t do without Sass/SCSS code writing so we’ve decided to fix the most annoying bugs as soon as possible.

Mock the browser time or time zone in Selenium features

In Selenium features the server and client are running in separate processes. Therefore when mocking time with a tool like Timecop, the browser controlled by Selenium will still see the unmocked system time.

SinonJS allows you to mock the client's time by monkey-patching into Javascript core classes.
We use SinonJS in combination with the Timecop gem to synchronize the local browser time to the time currently mocked with Timecop.

To integrate those two, we include and act…

Unfinished

STI and LoadError (Expected script/../config/../app/models/sub_model.rb to define SubModel) Exception

I was using single table inheritance lately and experienced the problem that a parent class did not know about its subclasses in development mode. The inheritance structure was like follows:

class Event < ActiveRecord::Base
end

class GlobalEvent < Event
end

class NewRegistrationEvent < GlobalEvent
end

class ConsultingRequestEvent < GlobalEvent
end

When I tried to load all global events in a controller, all I recieved by GlobalEvent.all was an empty set even though there were some new registr…

External content

Test your CSS rendering output with GreenOnion

No one wants to cry over regression issues in views; does testing HTML and CSS have to be such a back and forth between designers and devs? Why is it that the rest of the stack can have TDD and BDD but not the presentation layer? Well, GreenOnion is here to help you get the same results on testing front-end styling that you've enjoyed in your unit and integration tests up to now.
GreenOnion records 'skins', which are snapshots of the current state of a view (or any page that a browser can navigate to). The first time that it is run on a view…

External content

jQuery 1.8 Released

No big features, but many improvements under the hood:

  • Faster selector engine
  • Many bug fixes

Note that jQuery 2.0, scheduled for early 2013, will remove support for IE6 and 7. Before that there will be one more minor release with 1.9 that still has support for ancient IEs.

rspec_candy 0.2.0 now comes with our most popular matchers

Our rspec_candy gem now gives you three matchers:

be_same_number_as

Tests if the given number is the "same" as the receiving number, regardless of whether you're comparing Fixnums (integers), Floats and BigDecimals:

100.should be_same_number_as(100.0)
50.4.should be_same_number_as(BigDecimal('50.4'))

Note that "same" means "same for your purposes". Internally the matcher compares normalized results of #to_s.

be_same_second_as

External content

MySQL 5.6 will expose tables as key/value stores through memcached, might be awesome

The next version of MySQL will include a built-in memcached daemon. This daemon can quickly get and set key/value pairs from and to InnoDB tables while completely bypassing the parsing and planning overhead of SQL.

This could potentially be very awesome because we would then have a distributed key/value store that stores data in a way it can also be queried with complex SQL queries.

3086 cards