(C-x means ctrl+x, M-x means alt+x)
The default prefix is C-b. If you (or your muscle memory) prefer C-a, you need to add this to ~/.tmux.conf:
| # EC = 1/2*(2**exp-1) | |
| # ^equation | |
| def exp_backoff(upto) | |
| result = [ ] | |
| # ^ stores wait periods | |
| (1..upto).each do |iter| | |
| result << (1.0/2.0*(2.0**iter - 1.0)).ceil |
| ENV["RAILS_ENV"] = "test" | |
| require File.expand_path('../../config/environment', __FILE__) | |
| require 'rubygems' | |
| gem 'minitest' | |
| require 'minitest/autorun' | |
| require 'action_controller/test_case' | |
| require 'miniskirt' | |
| require 'capybara/rails' |
| describe "Shopping Cart Requests" do | |
| let!(:user) { Fabricate(:user) } | |
| before(:each) do | |
| login_user_post("admin", "admin") | |
| end | |
| context "when I visit the shopping cart" do | |
| it " show the logged in users' cart items " do | |
| #Test stuff |
| # Render Partials in ECO-Templates like in Rails-ERB | |
| # | |
| # usefull to clean up structure in spine.js and other js-mvc´s like backbone | |
| # | |
| # usage: | |
| # <%- render_partial 'path/to/partial' %> .. will render ../spine-app/views/path/to/_partial.jst.eco | |
| # <%- render_partial 'path/to/partial', foo: 'bar' %> .. will render ../spine-app/views/path/to/_partial.jst.eco .. locals = @foo | |
| # | |
| window.render_partial = ( path, options = {} ) -> | |
| # add the leading underscore (like rails-partials) |
FridayHug.com http://fridayhug.com
The Smallest Rails App http://thesmallestrailsapp.com
%w(action_controller/railtie coderay).each &method(:require)Locate the section for your github remote in the .git/config file. It looks like this:
[remote "origin"]
fetch = +refs/heads/*:refs/remotes/origin/*
url = git@github.com:joyent/node.git
Now add the line fetch = +refs/pull/*/head:refs/remotes/origin/pr/* to this section. Obviously, change the github url to match your project's URL. It ends up looking like this:
| # | |
| # Place this code to your .profile, .bashrc, .bash_profile or whatever | |
| # | |
| program_exists () { | |
| type "$1" &> /dev/null ; | |
| } | |
| if program_exists go; then |
Sometimes you want to use a gem on Heroku that is in a private repository on GitHub.
Using git over http you can authenticate to GitHub using basic authentication. However, we don't want to embed usernames and passwords in Gemfiles. Instead, we can use authentication tokens.
First you will need to get an OAuth Token from GitHub using your own username and "note"
In researching topics for RailsCasts I often read code in Rails and other gems. This is a great exercise to do. Not only will you pick up some coding tips, but it can help you better understand what makes code readable.
A common practice to organize code in gems is to divide it into modules. When this is done extensively I find it becomes very difficult to read. Before I explain further, a quick detour on instance_eval.
You can find instance_eval used in many DSLs: from routes to state machines. Here's an example from Thinking Sphinx.
class Article < ActiveRecord::Base