nruth/show_me_the_cookies - GitHub

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.

paul/progress_bar - GitHub

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.

Git: Moving a commit between repositories

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 # Note the ~
git format-patch HEAD~ # Shortcut for the latest commit

This will create a .patch file that describes this commit.

Apply the patch

In the target repository, restore the commit from the patch file with

gi...

Git: Diff staged changes

Saying git diff only shows unstaged changes relative to the index (or HEAD if the index is empty, alternatively any hash or branch you supplied) but leaves out files you already staged for the next commit.

To diff your added changes with HEAD, say:

git diff --cached

Effectively, this gives you the changes you will commit when you run git commit without the -a switch.

Using Solr with Sunspot

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
 ...

gammons/fake_arel - GitHub

Gem to get Rails 3's new ActiveRecord query interface (where, order) and the new scope syntax (chaining scope definitions) in Rails 2.

You also get #to_sql for scopes.

marcandre/backports - GitHub

Gem to get Ruby 1.9 features in Ruby 1.8.

colszowka/simplecov - GitHub

Code coverage for Ruby 1.9 with a powerful configuration library and automatic merging of coverage across test suites.

Note that rcov won't ever have support for Ruby 1.9, you're supposed to use rcov for 1.8 and simplecov for 1.9.

Git: What to do when "git log" does not show commits that touch a file

Let's say you have commits that change a file (and looking at the commit details show you the changes, etc). Now, when you do a git log you see them, but when you say git log that.file these commits don't show up? This is for you.

The reason is that the file got deleted deleted/re-added/renamed (any or all of those).

Instead of ...

git log master -- some.file

... you need to say:

git log --follow master -- some.file

Then your commits will show up.

Note that tig also understands --follow.


Kudos to Julien...

How to revert features for deployment, merge back, and how to stay sane

Removing features and merging those changes back can be painful. Here is how it worked for me.\
tl;dr: Before merging back: reinstate reverted features in a temporary branch, then merge that branch.

Scenario

Consider your team has been working on several features in a branch, made many changes over time and thus several commits for each feature.\
Now your client wants you to deploy while there are still stories that were rejected previously and can't be deployed.
...

How to print Github wiki pages

I have no idea how it's supposed to work (or why the don't have a print CSS), but this works for pages written with Markdown:

  1. "Edit" the wiki page
  2. Copy all text
  3. Run a Markdown interpreter and pipe its result, e.g.: kramdown > /tmp/github.html
  4. Paste your markdown
  5. Press Ctrl-D to finalize your input
  6. Open the generated HTML file and print it.

O_o

Improved gitpt now part of geordi

Our gitpt script to generate git commits from Pivotal Tracker stories has been tweaked and polished and is now part of the geordi gem.

Install the freshly released version 0.7 now:

gem install geordi

This update will bring you commit with an initial "setup wizard" (that asks for your PT API key and initials) and prettier output: stories are colored by their state and thos...

monperrus/ExpandAnimations - GitHub

ExpandAnimations is a LibreOffice/OpenOffice.org Impress extension to expand presentation animations before exporting to PDF. This way the exported PDF will have one page per animation stage.

tanoku/redcarpet - GitHub

Ruby bindings for Sundown, a fast and full-featured Markdown parser that lets you define renders for arbitrary output formats.

davetron5000/methadone - GitHub

Framework to write command-line apps in Ruby. Comes with a nice way of processing parameter options, some utility classes and Cucumber steps for testing your CLI app.

Git instaweb

Git has a built-in repository viewer for your web browser. a bit similar (but less awesome) than github.

If you have apache installed, simply go to your repository, and enter
git instaweb --httpd apache2
otherwise, simply install lighttpd and just run
git instaweb

This should open a brower automatically pointing to your repository. If not, try to connect to localhost:1234.

You can stop the server with
git instaweb --stop

How to ignore new files or changed files in git

How to ignore new files

Globally

Add the path(s) to your file(s) which you would like to ignore to your .gitignore file (and commit them). These file entries will also apply to others checking out the repo.

Locally

Add the path(s) to your file(s) which you would like to ignore to your .git/info/exclude file. These file entries will only apply to your local working copy.

How to ignore changed files (temporarily)

In order to ignore changed files to being listed...

See with tig which git commits touch a file or files or folders

tig path_to_file_or_files_or_path_with_wildcard

Rails 3.1 error message: Could not find a JavaScript runtime

After starting the Rails server in a freshly generated Rails 3.1 project you could see an error message such as

/usr/lib/ruby/gems/1.8/gems/execjs-1.3.0/lib/execjs/runtimes.rb:50:in `autodetect': Could not find a JavaScript runtime. See https://github.com/sstephenson/execjs for a list of available runtimes. (ExecJS::RuntimeUnavailable)

Just add a JavaScript runtime to your Gemfile and the error vanishes.

Examples:

gem 'therubyracer'
gem 'extjs'

Creating a patch in git and how to apply patches

You can convert git commits into patch files. Those can be used to apply to a different repository [1] or by someone else (e.g. sent when sent to them via e-mail).

Creating a patch in git


  1. Make your changes and commit them.
  2. Run git format-patch COMMIT_REFERENCE to convert all commits since the referenced commit (not including it) into patch files.

For example, let's say you prepared 2 commits. Run:

git format-patch HEAD~~ 

This will create 2 files, one for each commit since HEAD~~, like these:

00...

How to install a debian/ubuntu package without dependencies

Please note that you can break your system with this! This is not recommended.

Sometimes the package repository has errors. If you can't install a package because you can't install the dependencies with the package manager you can try this:

(You have to download the deb first e.g. from here or here)

dpkg -x bad-package.deb common
dpkg --control bad-package.deb

Then you have to edit DEBIAN/control with an editor. You can delete the broken dependencies t...

Git: Change author of a commit

Using git rebase can be painful but luckily you can resort to cheating with git reset and committing anew.
Now what if you wanted to rebase commits of other people and still wish them to be the authors of their code? Easy: make them the author of a commit you made.

When you have freshly staged changes that are ready to be committed, just use the --author switch:

git commit -m "Hello Universe" --author="Philip J Fry <someone@example.com>"

If...

How to fix: Gems are unavailable although they are installed

  • If Rails or Rake are complaining about a missing gem that is listed in your Gemfile.lock and the listed version is properly installed, something is seriously wrong and needs to be fixed.
  • If you accidently executed bundle install some_gem although you wanted bundle update some_gem

What is wrong

Let's say your Gemfile asks for some-gem which you can see when running gem list but bundle show some-gem just gives you an error:

Could not find gem 'some-gem', in any of the sources

Another indicator: Doing a `...

Git: List remote branches

Sometimes you may need to figure out what branches exist on a remote repository so you can pull them down and check them out, merge them into your local branches, etc. You can see the remote branches by saying

git branch -r

Or, if you want to see both local and remote branches, you can say

git branch -a