Boolean attributes and pretty enumerations in Cucumber Factory 1.7

Boolean attributes can now be set by appending "which", "that" or "who" at the end:

Given there is a movie which is awesome
And there is a movie with the name "Sunshine" that is not a comedy
And there is a director who is popular

Instead of "and" you can now also use "but" and commas to join sentences:

Given there is a movie which is awesome, popular and successful but not science fiction
And there is a director with the income "500000" but with the account balance "-30000"

Update with `sudo gem install cucumber_facto...

Spec correct routing of custom URLs

When you roll custom URLs with hacks like routing-filter, you can put a spec like this into spec/routing/routing_spec.rb:

jQuery autocomplete with multiple values

Autocomplete input that accepts multiple entries in one field using jQuery and jQuery UI styling; a temporary workaround before built-in multi-value support.

Testing validates_format_of with Shoulda matchers

validate_format_of can fail in odd ways with Shoulda; allow_value is the safer matcher for checking valid and invalid email formats.

Ruby Java Bridge

rjb is a bridge software. It connects Ruby and Java.

Get rid of US keyboard layout

Problem:

Keyboard layout reverting to US on (every) reboot

Cause:

I found the same problem, but only on my wife's account. I'd set her keyboard layout to UK through Gnome preferences and every time the US layout would reappear and be selected frustratingly.\
It turned out that on the gdm login screen her choice of keyboard layout in the discreet option bar at the bottom of the screen was set to US. That was then overriding the Gnome layout preference.

Solution:

Selecting the appropriate keyboard layout on the next login solved the...

schacon's showoff at master - GitHub

the best damn presentation software a developer could ever love

Regular Expressions - Cheat Sheet

Regular-expression syntax for matching characters, boundaries, alternation, quantifiers, look-arounds, and Ruby modifiers. Useful for writing and debugging patterns safely.

Default implementation of resource_controller actions

Default CRUD action flow for resource_controller with callbacks, flash handling, and success or failure responses around object loading and persistence.

Run a POP3 server on a directory of mail files with popthis

Serve a directory of generated mail files as a local POP3 mailbox for testing clients and inaction_mailer output.

Task Switch in Linux Console

To pause and send a task to the background
ctrl+z

to reactivate the task
fg

to run task in background
bg

to see a list of so running tasks
jobs

Multi-line step arguments in Cucumber

Passing long text blocks to Cucumber steps keeps feature files readable while preserving full Markdown content for step definitions.

Add a method to an existing object

Use the attached initializer to do stuff like this

str = "abc"
str.imbue(:foo => 'foo value', :bar => 'bar value')
puts str.foo # 'foo value'
puts str.bar # 'bar value'

Change Paperclip secrets the hard way

Paperclip secret changes can move attachment files to new locations and break existing paths. A semi-automatic migration preserves uploaded files when secrets were copied between projects.

Marry Capybara with SSL-enabled applications

Capybara can lose the HTTPS state when specs cross between secure and insecure Rails actions, causing request URLs to fall back to the wrong protocol.

Count lines of code

The following counts all the lines in all *.rb files in the app directory. Run several of these commands to get a rough estimate of the LOC.

find app -name *.rb -exec wc {} \; | awk '{a+=$1;print a}' | tail -1

Find out which PID listens on socket

Show all sockets (Unix & TCP/UDP), both listening and established ones:
netstat -anp

To limit the output e.g. to listening TCP sockets:
netstat -anp | grep tcp | grep LISTEN
...
tcp 0 0 0.0.0.0:3000 0.0.0.0:* LISTEN 28683/server
...

This means: A tcp v4 socket listening on port 3000 on all IP adresses (0.0.0.0 is synonym to 'all interfaces on the machine').

The last column includes the PID, kill -9 28683 should exit the process and clean up the socket.

traits.js - Traits for Javascript

traits.js is a minimal, standards-compliant trait composition library for Javascript.

Announcing YARD 0.6.0 (gnuu.org)

YARD 0.6 adds the ability to serve documentation for gems as well as the current project with yard server. Just like gem server in RubyGems, you can serve gem docs. The advantage to YARD’s server is that you don’t need to pre-generate the static docs (with a gem install) before running the server. If you installed your gem with --no-rdoc, YARD will just generate it on the fly!

Change the color of a <hr> in all browsers

The following Sass will do it:

hr
  color: #ddd
  background-color: #ddd
  border: none
  height: 1px

Ruby Reports

Ruport’s acts_as_reportable module provides support for using ActiveRecord for data collection. You can use it to get a Ruport::Data::Table from an ActiveRecord model. This cheatsheet covers the basic functionality of acts_as_reportable and some common use cases.

Order for SELECT ... IN (5,100,23) queries

IN queries return rows in undefined order; ORDER BY FIELD() preserves a custom sequence for matching IDs.

Riding Rails: Rails 3.0: It's ready!

Rails 3.0 has been underway for a good two years, so it’s with immense pleasure that we can declare it’s finally here. We’ve brought the work of more than 1,600 contributors together to make everything better, faster, cleaner, and more beautiful.

Build a JSON API for a Rails application

Try our Apify gem which solves many problems you will be having.