Skip to content

Instantly share code, notes, and snippets.

@dpmcnevin
dpmcnevin / gist:48c0cf022fa0ca610e12
Created October 12, 2014 01:57
Set iTerm2 Background Color per Git Repo (zsh)
set_color() {
local HEX_FG=$1
local HEX_BG=$2
local OPACITY=$3
local FG_R=`echo $HEX_FG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$1 * 257)}'`
local FG_G=`echo $HEX_FG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$2 * 257)}'`
local FG_B=`echo $HEX_FG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$3 * 257)}'`
local BG_R=`echo $HEX_BG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$1 * 257)}'`
local BG_G=`echo $HEX_BG | sed 's/../0x&,/g' | awk -F "," '{printf("%d",$2 * 257)}'`
require 'test_helper'
class HostsControllerTest < ActionController::TestCase
context "Logged in as admin" do
setup do
@user = Factory.build(:admin_user) ## build, not create since it won't hit the database then
HostsController.any_instance.stubs(:current_user).returns(@user)
end
context "on INDEX action" do
Factory.define :admin_user, :class => "user" do |f|
f.email "daniel.mcnevin@something.com"
f.first_name "Daniel"
f.last_name "McNevin"
end
class ApplicationController < ActionController::Base
include Esc::Authentication
before_filter :require_user
before_filter :set_user
end
class User < ActiveRecord::Base
establish_connection(
YAML.load_file("#{Rails.root}/config/sessions_database.yml")[Rails.env]
)
end
rvm install jruby
rvm use jruby
gem install redcar
function rc() {
rvm jruby -S ~/.rvm/gems/jruby-1.5.1/bin/redcar $@ 1> /dev/null 2>&1 &
}
ActionController::Base.session = {
:key => '_sso_session',
:secret => 'a really long hex string'
}
config.action_controller.session = {
:domain => ".rails.local"
}
Rails.application.config.session_store :cookie_store, {
:domain => '.rails.local',
:key => '_sso_session',
:secret => 'the same really long hex string'
}