- Search for repeating cards with
- Search for unfinished cards with
- Search for cards in a certain topic with
- Search for phrases with
- Exclude a word from search:
- Exclude a phrase from search:
- Exclude a topic from search:
Some helpers for poking around at your Capybara driven browser's cookies in integration tests.
Supports Capybara's bundled drivers (rack-test, Selenium Webdriver), and adapters for other drivers may be added.
Mysql::Error: SAVEPOINT active_record_1 does not exist: ROLLBACK TO SAVEPOINT active_record_1 (ActiveRecord::StatementInvalid)
Possible Reason 1: parallel_tests - running more processes than features
If you run old versions of parallel_tests with more processes than you have Cucumber features, you will get errors like this in unexpected places:
This is a bug caused by multiple processes running the same features on the same database.
The bug is fixed in versions 0.6.18+.
The step definition below lets you say:
Then I should see a field "Password" But I should not see a field "Role"
Here is the step definition:
Then /^I should( not)? see a field "([^"]*)"$/ do |negate, name| expectation = negate ? :should_not : :should begin field = find_field(name) rescue Capybara::ElementNotFound # In Capybara 0.4+ #find_field raises an error instead of returning nil end field.send(expectation, be_present) end
Note that you might have to adapt the step defi…
If Sunspot does not work and fails with a backtrace similar to this:
/project/shared/bundle/ruby/1.8/gems/rsolr-1.0.6/lib/rsolr/client.rb:227:in `adapt_response' /project/shared/bundle/ruby/1.8/gems/rsolr-1.0.6/lib/rsolr/client.rb:164:in `execute' /project/shared/bundle/ruby/1.8/gems/rsolr-1.0.6/lib/rsolr/client.rb:158:in `send_and_receive' (eval):2:in `post'
schema.xml that is shipped with Sunspot is not loaded into Solr correctly.
Often the latter can be found in
/etc/solr/conf/schema.xml. So copy Sunspo…
If you defined your association via
class Article belongs_to "category" end
and you try
Article.scoped(:include => :category)
you will get an error message
in `preload_one_association': Association named 'category' was not found; perhaps you misspelled it? (ActiveRecord::ConfigurationError)
Always define your assocations via symbol
class Article belongs_to :category end
You can use
text-overflow to truncate a text using CSS but it does not fit fancy requirements.
Here is a hack for the special case where you want to truncate one of two strings in one line that can both vary in length, while fully keeping one of them. See this example screenshot where we never want to show an ellipsis for the distance:
![Flexible overflow with optional ellipsis](https://makandracards.com/makandra/5885-a-flexible-overflow-ellipsis/at…
Consider you have a file that uses improper encoding on special characters. Example: You see the latin1 version "
Ã±" for the UTF-8 "
ñ" but the file itself is stored as UTF-8 (meaning that the UTF-8 bytes are doubly encoded).
You can fix that easily with Vim:
Now you tell vim that the file's encoding is actually
latin1 (you can see what Vim is currently using by saying only
Write and reload the file:
All should be good now.
Adjust to your n…
Sometimes you need to restart the Gnome panel, e.g. when you installed a new Gnome panel widget but the widget list was cached before.
You often don't want to do sign out and back in for this.
Instead, just run:
This will terminate all
gnome-panel processes. On my machine (Ubuntu 11.04) the panel then restarted itself after a moment.
If the panel does not automatically come back, press
Alt+F2 to bring up the Gnome "run" box and start
gnome-panel from there.
In order to chain greps on log files that are opened via
tail -f test.log you have to use the
--line-buffered command line option for
Imagine you have the following content in your log file.
# content for log/test.log test foo bar test foo bar baz bla
Now if you would like to grep for lines that contain foo but not bar, you can use the following command chain:
$ tail -f log/test.log | grep --line-buffered "foo" | grep -v "bar" Output: test foo
The following snippet demonstrates how you could create excel files (with spreadsheet gem) and format columns so that they follow a specific number format like currencies or dates do.
require 'rubygems' require 'spreadsheet' Spreadsheet.client_encoding = 'UTF-8' book = Spreadsheet::Workbook.new sheet1 = book.create_worksheet :name => 'test' money_format = Spreadsheet::Format.new :number_format => "#,##0.00 [$€-407]" date_format = Spreadsheet::Format.new :num...
When using Rails to truncate strings, you may end up with strings that are still too long for their container or are not as long as they could be. You can get a prettier result using stylesheets.
The CSS property
text-overflow: ellipsis has been around for quite a long time now but since Firefox did not support it for ages, you did not use it. Since Firefox 7 you can!
Consider this HTML and Sass for a box that is not wide enough for its content:
<div id="greetings"> Hello universe! </di...
ProgressBar is a simple Ruby library for displaying progress of long-running tasks on the console. It is intended to be as simple to use as possible.
If you want to move a complete commit from one repository to another (and you don't want to add it as a remote), you can use these steps:
Create a patch
In the source repository, create a patch based on the commit by running
git format-patch SHA1_OF_COMMIT~..SHA1_OF_COMMIT
This will create a
.patch file that describes this commit.
Apply the patch
In the target repository, apply the patch with
git apply PATH_TO_PATCH
If the patch does not apply cleanly, git will not do anything. I…
git diff only shows unstaged changes against
HEAD (or any hash or branch you supplied) but leaves out files you already staged for the next commit.
To diff your added changes, say:
git diff --cached
Effectively, this gives you the changes you will commit when you run
git commit without the
This describes all the steps you'll need to get Solr up and running for your project using the Sunspot gem.
Prepare Sunspot on your development machine
What you want in your Gemfile:
gem 'sunspot_rails' gem 'sunspot_solr' gem 'progress_bar' # for sunspot:solr:reindex
Now define what should be indexed within Solr from your ActiveRecord models, e.g.,
class Article << ActiveRecord::Base searchable do text :title ...