Skip to content

Instantly share code, notes, and snippets.

View scottweisman's full-sized avatar

Scott Weisman scottweisman

View GitHub Profile
@scottweisman
scottweisman / current.rb
Created May 7, 2012 16:25
Using current_kase method in views
# concerns#current
module Current
extend ActiveSupport::Concern
...
def current_kase
@current_kase ||= Kase.find_by_id(params[:kase_id])
end
# To include methods in views
@scottweisman
scottweisman / users_test.rb
Created May 19, 2012 18:02
Users signin request spec
require 'spec_helper'
describe "Users" do
before :each do
@user = FactoryGirl.create(:user)
end
it "allows users to sign in" do
visit login_url
@scottweisman
scottweisman / gist:2782213
Created May 24, 2012 15:23 — forked from JeffCohen/gist:2782207
Vending Machine Fun
class VendingMachine
# attr_accessor :money
def initialize(number_of_cans)
@cans = []
number_of_cans.times do
@cans << 'Coke'
end
# => ['Coke', 'Coke', 'Coke', 'Coke']
@scottweisman
scottweisman / githubrecipe.txt
Created June 1, 2012 19:01
WarRoom Github Recipe
git checkout -b new_feature
...do some work...
git add .
git commit -am "did some work"
git push origin new_feature
go to github and create pull request for new_feature branch
- team reviews changes on github
- add comments, make changes, click merge pull request when accepted
@scottweisman
scottweisman / bash_profile.bash
Created June 5, 2012 20:24
bash_profile - github branch
function parse_git_branch () {
git branch 2> /dev/null | sed -e '/^[^*]/d' -e 's/* \(.*\)/ (\1)/'
}
RED="\[\033[0;31m\]"
YELLOW="\[\033[0;33m\]"
GREEN="\[\033[0;32m\]"
NO_COLOUR="\[\033[0m\]"
PS1="\W$GREEN\$(parse_git_branch)$NO_COLOUR\$ "
@scottweisman
scottweisman / gist:2949454
Created June 18, 2012 17:07
nav_link content_tag
def nav_link(link_text, link_path)
class_name = current_page?(link_path) ? 'active' : ''
content_tag(:li, :class => class_name) do
link_to link_text, link_path
end
end
@scottweisman
scottweisman / rails_setup.rb
Last active October 7, 2015 01:48
New Rails App Setup
rails new <project name> -d postgresql --skip-bundle --skip-test-unit
remove turbolinks
1. Remove the gem 'turbolinks' line from your Gemfile.
2. Remove the //= require turbolinks from your app/assets/javascripts/application.js.
3. Remove the two "data-turbolinks-track" => true hash key/value pairs from your app/views/layouts/application.html.erb.
git init
#.gemfile
@scottweisman
scottweisman / bootstrap_flash.html.erb
Created August 9, 2012 15:49
Rails Twitter Bootstrap Flash Messages
<% flash.each do |name, msg| %>
<div class="alert alert-<%= name == :notice ? "success" : "error" %>">
<a class="close" data-dismiss="alert">&#215;</a>
<%= content_tag :div, msg, :id => "flash_#{name}" if msg.is_a?(String) %>
</div>
<% end %>
@scottweisman
scottweisman / foundation.scss
Created August 18, 2012 15:40
Foundation SCSS Variables
// Settings file containing Foundation defaults
// Grid Settings
$rowWidth: 1000px !default;
$columnGutter: 30px !default;
$totalColumns: 12 !default;
$mobileTotalColumns: 4 !default;
// Colors Settings
@scottweisman
scottweisman / gist:3484894
Created August 27, 2012 01:24 — forked from lucasfais/gist:1207002
Sublime Text 2 - Useful Shortcuts

Sublime Text 2 – Useful Shortcuts (Mac OS X)

General

⌘T go to file
⌘⌃P go to project
⌘R go to methods
⌃G go to line
⌘KB toggle side bar
⌘⇧P command prompt