Zeus promises to make rails development faster

I am talking about development speed. When your application starts growing and you start adding gems, it starts to take really long to start up, be it the server, console or just running a single spec.

Zeus is smart, you don’t have to put it in your Gemfile or run it with Bundler, all you need to do is create a JSON config file via zeus init and then start the server zeus start.

After that, you’re ready to go, all you need to do is prefix every command with zeus. That means rails server becomes zeus server, `rails console...

A jQuery plugin for producing bar charts from tables.

As the title says: this jQuery plugin creates bar charts from HTML tables. It comes in some different flavors.

Check the examples page: http://alphagov.github.com/magna-charta/.

Git: Show current branch name only

While git branch will show you all branches and highlight the current one with an asterisk, it can be too cumbersome when working with lots of branches.

To show only the branch you are currently on, use:

git rev-parse --abbrev-ref HEAD

Git: How to look at the stash

Browsing the git stash is a bit tricky. Here is how to see the changes without applying them:

git command on the console

The following will give you the diff of the topmost stash item:

git stash show -u

But what about other items on the stash?
Well, you can list them like this:

$ git stash list
stash@{0}: WIP on feature/foo
stash@{1}: WIP on feature/bar
stash@{2}: WIP on fix/baz

All those stashed changes have their own reference (like branch names) that you can look at, like `stas...

Spreewald: Old-school cucumber steps, freshly pickled

Cucumber_rails' old-school web-steps have been deprecated for a while, urging developers to write high-level step definitions that directly use Capybara or Webrat.

We think that's a bit drastic. More high-level steps are good, but ticking the odd check box with a general step is not always bad.

So we took the old web steps, improved them a bit, added some other favorites of ours (steps for emails, tables, [time travelling](/ma...

How to not leave trailing whitespace (using your editor or Git)

There is no reason to leave trailing whitespace characters in your project's files, so don't add any.

A git diff --check will tell you if there are any and you should not commit when you see them. So go ahead and switch your editor/IDE to automatically remove them for you.
Below are a few instructions on how to get them removed by your favorite IDE or editor.

Note that except for RubyMine, the following changes will remove trailing white-space on all lines, not only those that you changed.
While this should not be a problem if your proje...

Git basics: checkout vs. reset

Today I got a better understanding of how git works, in particular what git checkout and git reset do.

Git basics

  • A commit holds a certain state of a directory and a pointer to its antecedent commit.
  • A commit is identified by a so-called ref looking something like 7153617ff70e716e229a823cdd205ebb13fa314d.
  • HEAD is a pointer that is always pointing at the commit you are currently working on. Usually, it is pointing to a branch which is pointing to that commit.
  • Branches are nothing but pointers to commits. Y...

ActionMailer sometimes breaks e-mails with multiple recipients in Rails 2

The ActionMailer in Rails 2 depends on a buggy version of TMail, which sometimes inserts a blank line into the mail header when sending a mail to multiple recipients. This makes the header end prematurely.

The reason why this is not exploding in your face all the time is that when you are relaying your e-mail through an MTA like Exim, it will fix this for you.

Fix for Rails if you don't have an awesome MTA

TMail is no longer maintained. The bug is fixed...

Git: When committing, check the diff

When committing, you should always check the diff of your changes so you don't include any leftovers or irrelevant/bad changes. Any time spent on that is well invested as it saves you rejected merge requests or any mess you need to clean up later.

While you can just use git diff or git diff --cached (to diff staged changes), you can also have Git include the changes as a comment below the commit message:

git commit -v

That will open up the usual commit "file" in your preferred text editor, but it will include a diff below the s...

Limitations you should be aware of when Internet Explorer 9 parses CSS files

Internet Explorer until version 9 has some limitations when parsing CSS files

Summarized, these are:

  • Up to 31 CSS files or <style> tags per page.
  • Up to 4095 selectors per CSS file.
  • Up to 3 nested @import rules

To test the selector limit for a specific browser, check this CSS selector limitation test website.

When you run into this issue, the following links might be helpful to fix the problem. The Idea is to split up the css ...

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.

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

Git: How to rebase your feature branch from one branch to another

In a nutshell: Use git rebase --onto target-branch source-commit

  • target-branch means "branch you want to be based on"
  • source-commit means "commit before your first feature commit"

Let's say my-feature-branch is based on master and we want it to be based on production. Consider this history:

%%{init: { 'gitGraph': {'showCommitLabel': true, 'mainBranchName': 'production'}} }%%

gitGraph
  commit id: "1"
  commit id: "2"
  branch master
  commit id: "3"
  commit id: "4"
  branch my-feature...

When connecting to a second database, take care not to overwrite existing connections

Sometimes, you may want to open up a second database connection, to a read slave or another database. When doing that, you must make sure you don't overwrite an existing connection.

The problem

While this may look good, it will actually cause all kinds of trouble:

def with_other_database
  ActiveRecord::Base.establish_connection(slave_settings)
  yield
ensure
  ActiveRecord::Base.establish_connection(master_settings)
end

Putting aside that you are setting the general connection here (not generally a ...

Capistrano: How to find out which version of your application is currently live

When deploying, Capistrano puts a REVISION file into your application's release directory. It contains the hash of the commit which was deployed.

If you want to know the currently deployed release, simply SSH to a server and view that file.

$ cat /var/www/my-project/current/REVISION
cf8734ece3938fc67262ad5e0d4336f820689307

Capistrano task

When your application is deployed to multiple servers, you probably want to see a result for all of them.
Here is a Capistrano task that checks all servers with the :app role.

New cards feature: Explicit language declaration for syntax highlighting

Makandra cards will auto-detect the language used for syntax highlighting.

This auto-detection sometimes fails for short code snippets. In such cases you can explicitly declare the language for Github-style code blocks:

```css
body {
  font-size: 12px
}
```

Will turn into this:

body {
  font-size: 12px
}

To disable syntax highlighting entirely use the text language:

```text
I am nothing without pretend

...

Trouble changing filename casing in git

On case-insensitive file systems like Mac's HFS+ (per default – you may change this, but it won't work for all programs), git won't recognize when you change the casing of files in your repository.

Workaround

git mv -f oldfile.name Oldfile.name

Security fixes for Rails 2.3

Last week saw a security issue with rails 2.3 that required a fix. While an official patch was provided, the 2.3 branch is no longer maintained. So we forked it.

(I'm sure there are already 100 other forks doing absolutely the same, but they are not very easily discoverable.)

To use our fork, change the gem "rails"... line in your Gemfile to this:

gem 'rails', :git => 'https://github.com/makandra/rails.git', :branch => '2-3-fixes'

The intent is to make as few changes to the f...

Skype 4.0 for Linux

Promises unified window for all chat conversations, better call quality.

Upgrade seems to work fine. If you installed your old skype from a Ubuntu repository, you need to remove it first using:
sudo apt-get remove skype
Then simply install the .deb from the official page. You won't lose any settings.

Geordi: Use load-dump script to source a database dump into your database

This script loads a dump into your development database.

You can provide the full path to you database dump like this:

load-dump path/to/my.dump

When you call load-dump without any arguments it will show a menu with all dumps in your ~/dumps/ folder.

load-dump

This script is part of our geordi gem on github.

Visualized introduction how git works

Quick introduction to git internals for people who are not scared by words like Directed Acyclic Graph.


The linked page offers a simple yet concise explanation of how git is organized internally ('a directed acyclic graph with post-it notes'). Each feature is illustrated by a simple diagram, so you get a sound understanding of how each command affects git's structure.

How could it be that my database.yml disappears?

Probably was in the repository once and got deleted in a commit that you pulled.

Plotting graphs in Ruby with Gruff

Geoffrey Grosenbach has created Gruff for easily plotting graphs. It is written in pure Ruby and integrates with Rails applications.

It provides features as automatic sizing of dots and lines (the more values, the thinner the graph's elements), custom or predefined themes, different styles (bar, line, dot and many more) and multiple graphs in one chart.

Installation

In your Gemfile:

gem 'rmagick', :require => false
gem 'gruff'

Then run bundle install (and don't forget to restart your development server.)

Usage

This i...

The Ruby Toolbox – a collection of good gems

If you need a gem for a certain purpose, be sure to check this site.


The rankings are determined by counting up the number of forks and watchers of various github projects, so I'd view it less as "this is what I should be using," and more as "these are some things I should check out." At the very least, they're all likely to be under active development and fairly up to date, and it's very useful to see groups of gems broken down by category.