Geordi 1.0 released
Geordi 1.0 features a command line application geordi
, that holds most of Geordi's previous commands.
New features
-
command help and usage examples right within
geordi
(geordi help
andgeordi help <command>
) -
quick command access: type just the first few letters of a command, e.g.
geordi rs
orgeordi dev[server]
-
command dependencies, e.g.
geordi rspec
invokesgeordi bundle-install
(which bundles only if needed) -
no cluttered
/usr/bin
, but all commands in one handy tool -
template for easily adding new...
How to set up database_cleaner for Rails with Cucumber and RSpec
Add gem 'database_cleaner'
to your Gemfile. Then:
Cucumber & Rails 3+
# features/support/database_cleaner.rb
DatabaseCleaner.clean_with(:deletion) # clean once, now
DatabaseCleaner.strategy = :transaction
Cucumber::Rails::Database.javascript_strategy = :deletion
Cucumber & Rails 2
The latest available cucumber-rails
for Rails 2 automatically uses database_cleaner
when cucumber/rails/active_record
is required -- but only if transactional fixtures are off. To have database_cleaner
work correctly:
- Add the at...
Github: How to find the Readme for a certain version of a gem
When a gem author releases a new version to Rubygems, usually a tag with the version number (e.g. v1.2.0
) is created an pushed to Github, so everyone can check out or take a look at the source code at this point version release at a later time.
If you'd like to take a look at the Readme of a specific Gem version, you can easily switch to that git tag on Github.
Piro: Pivotal Tracker Rocket
Open Source Chrome Extension/App that can show you stories you're assigned over multiple projects and more.
Unobtrusive jQuery to toggle visibility with selects and checkboxes
Use this if you want to show or hide part of a form if certain options are selected or boxes are checked.
The triggering input gets an data-selects-visibility
attribute with a selector for the elements to show or hide, like
<%= form.select :advancedness, [['basic', 'basic'], ['advanced', 'advanced'], ['very advanced', 'very_advanced]], {}, :"data-selects-visibility" => ".sub_form" %>
The elements that are shown/hidden look like
<div class="sub_form" data-show-for="basic">
only shown for advancedness = basic
</div>
...
Debug Ruby code
This is an awesome gadget in your toolbox, even if your test coverage is great.
-
gem install ruby-debug
(Ruby 1.8) orgem install debugger
(Ruby 1.9) - Start your server with
script/server --debugger
- Set a breakpoint by invoking
debugger
anywhere in your code - Open your application in the browser and run the code path that crosses the breakpoint
- Once you reach the breakpoint, the page loading will seem to "hang".
- Switch to the shell you started the server with. That shell will be running an irb session where you can step thr...
Heads up: LibreOffice Calc AutoCorrect will change characters when pasting multi-line text
If you paste multiple lines of text into a cell, Calc's AutoCorrect will change the first character of the last line to uppercase:
foo => foo
bar bar
baz Baz
To fix this, go to Tools / AutoCorrect Options, choose the Options tab and uncheck every box. You're a programmer, you don't need wimpy AutoCorrect assistance.
Refile: Ruby file uploads, take 3
Jonas Nicklas, the author of Carrierwave and Capybara, has released Refile, a gem for handling file uploads in Rails. It handles direct uploads (also direct uploads to Amazon S3) better than Carrierwave.
The story and reasoning behind some of the decisions in Refile, and how it's different from Carrierwave, by the author himself, is a good read before deciding which way you'll go.
Big Caveat: Refile only stores the original image and r...
Spreewald 1.2.0 released: new "select field should be sorted" step
Usage:
Then the "sorted" select should be sorted
But the "unsorted" select should not be sorted
Rendering: repaint, reflow/relayout, restyle
Some insight into how browser rendering engines work. The article shows how the way you manipulate styles (and the DOM) can affect rendering performance by forcing the browser to re-paint large portions of the screens, or re-calculate the dimensions of a large subtree of DOM nodes.
Materialized views with Sequel
Sequel is an awesome ORM such as ActiveRecord. The linked article describes how easily you can implement and use materialized views with postgres as your underlying database.
Github: Search for a repo you've starred
Want to find that repo you've starred some time ago again? Here's where to search for it.
An alternative way to browse and search through your starred repos is Astral, where you'll see the Readme for each repo in a split screen.
How to circumvent Firefox's "Document expired" page in Selenium tests
When navigating back to a page that was received from a POST request, undesired side effects may happen. Therefore, modern browsers try to keep users from doing so, i.e. Firefox 24 displays an error page explaining what's wrong. If the user presses "Try Again", it shows an additional alert asking whether the user is certain.
Solution
If you need to circumvent this protection, e.g. to test that your application behaves correctly despite being misused, do this:
page.execute_script 'history.back()'
page.execute_script 'retryThis(this)...
ImageMagick: Cropping images
ImageMagick takes a string with several options when cropping an image. See the command line options for how to provide the expected image geometry for details.
Note that ImageMagick tends to preserve the original aspect ratio of the source image automatically.
Examples:
-
crop 200x200
means Maximum values of height and width given, aspect ratio preserved. -
crop 200x200!
means Width and height emphatically given, original aspect ratio ignored.
flag-icon-css: Scalable country flags
Use it like this for inline icons:
<span class="flag-icon flag-icon-de"></span> Germany
They also work as block elements:
<div class="flag-wrapper">
<div class="flag flag-icon-background flag-icon-de"></div>
</div>
Falsehoods programmers believe about addresses
Addressing is a fertile ground for incorrect assumptions, because everyone's used to dealing with addresses and 99% of the time they seem so simple. Below are some incorrect assumptions I've seen made, or made myself, or had reported to me.
Jasmine 2 cheat sheet for RSpec lamers
In the tradition of our PostgreSQL cheat sheet for MySQL lamers, here is a cheat sheet for Jasmine when you're used to RSpec.
Note that Jasmine syntax has changed with Jasmine 2, so if you're using Jasmine 1.x you might instead want to use an older cheat sheet.
Expectations
# RSpec
expect(foo).to.eq("value")
expect(foo).to_not eq("value")
# Jasmine
expect(foo).toBe("value")
expect(...
Jasmine: Reset the location when testing code that uses pushState / replaceState
When testing code that uses pushState / replaceState, your browser will appear to navigate away from http://localhost:3000/specs
(or wherever you run your Jasmine tests). This is inconvenient, since reloading the document will no longer re-run the test suite.
To remedy this, copy the attached file to a place like spec/javascripts/helpers
and #= require
it from your tests. It will store the current location before every test and reset if afterwards (using location.replaceState
).
velesin/jasmine-jquery
This jasmine plugin helps with testing DOM manipulation in two ways:
- It gives you DOM-related matchers like
toBeVisible()
ortoHaveCss(css)
- It gives you a function to load HTML from fixture files. Without this you would have to manually add elements to
<body>
and clean up afterwards.
Installing the typhoeus Rubygem on Ubuntu 14.04
Make sure you have libcurl3-dev
installed:
sudo apt-get install libcurl3-dev
gem install typhoeus
Cucumber: More patience for Selenium features
When running Selenium features with parallel_tests, some browser-server interaction might take longer than usual and the impatient Capybara will not wait enough to see results.
Put the attached file into features/support/
to make Capybara more patient in scenarios tagged @javascript
.
How to upgrade Cucumber on Rails 3+
-
Run
bundle update cucumber capybara cucumber-rails
to update to the newest versions. -
Backup your
features/support/path.rb
to be able to add your own paths again after the cucumber installation script in step 4. -
Backup your
features/support/env.rb
file to be able to reintegrate parts like your blueprints setup:ENV["RAILS_ENV"] ||= "cucumber" require File.expand_path(File.dirname(__FILE__) + '/../../config/environment') require 'spec/support/blueprints'
-
Run `$ rails generate cucumber:install --capyba...
yaronn/blessed-contrib
Build dashboards using ascii/ansi art and javascript
Awesome!
Making Sass talk to JavaScript with JSON | CSS-Tricks
Crazy hack. Might be useful one day.
The code required has since been extracted into a library.