Like many web developers today I work with a variety of technologies to deliver a compelling product. Technology frameworks like Rails do a pretty good job of abstracting the more complex bits to allow the developer to focus on building the core functionality of the web app. Unfortunately, the typical web stack still has a lot of moving parts, so as you jump from the various languages and technologies it can be difficult to remember specific syntax or commands. So how do you remember everything?
Why worry about remembering everything..that is what your computer is for!
When developing I usually have several terminal windows open for running unit tests, REPL, db consoles, etc. The problem is if I need to remember a specific syntax or command for something I usually have to open up a browser window to do quick look up, which can really break my development flow.
Cheat sheets are great ways to remember those types of things and for years my cheat sheets have been text files that I would a grep for looking up notes. That approach worked, but was a little cumbersome. So I decided to throw a little Ruby at the problem and what emerged was Cheater, a simple Rake based tool for looking up cheat sheets for common code & console commands.
Cheater uses rake tasks to read YAML files that contain the cheat sheet commands & descriptions to print to your terminal window.
$ rake cheater:docs Available Cheat Sheets rake cheater:capybara # Cheat Sheet for capybara. rake cheater:git # Cheat Sheet for git. rake cheater:rspec # Cheat Sheet for rspec. $ rake cheater:capybara CAPYBARA Navigating visit('/projects') # Navigates to given path. visit(post_comments_path(post)) # Navigates to given path; named route. current_path # Path of the current page, without any domain information; i.e. current_path.should == post_comments_path(post). CAPYBARA Clicking links and buttons click_link('id-of-link') # Clicks link based on id of the anchor. click_link('Link Text') # Clicks link based on the text of the anchor. click_button('Save') # Clicks the button based on the text. click_on('Link Text') # Clicks on either links or buttons. ... $ rake cheater:git GIT CREATE COMMANDS git clone ssh://firstname.lastname@example.org/repo.git # Clone an existing repository. git init # Create a new local repository. GIT LOCAL CHANGES COMMANDS git status # Changed files in your working directory. git diff # Changes to tracked files. git add # Add all current changes to the next commit. git add -p # Add some changes in to the next commit. git commit - a # Commit all local changes in tracked files. git commit # Commit previously staged changes. git commit --amend # Change the last commit. GIT COMMIT HISTORY COMMANDS git log # Show all commits starting with newest. git log -p # Show changes over time for a specific file. git blame # Who changed what and when in ... $ rake cheater:rspec RSpec::Expectations Equivalence actual.should eq(expected) # Passes if actual object == expected object. actual.should == expected # Passes if actual object == expected object. actual.should eql(expected) # Passes if actual.eql?(expected). RSpec::Expectations Identity actual.should be(expected) # Passes if actual.equal?(expected). actual.should equal(expected) # Passes if actual.equal?(expected). RSpec::Expectations Comparisons actual.should be > expected # Passes if actual is greater than expected.
To add to cheater you simply create a new cheater_[cheatsheet].yml file and drop it into the cheater directory. Then from your terminal run rake cheater:[cheatsheet].