Skip to content

Instantly share code, notes, and snippets.

View mrmicahcooper's full-sized avatar
🥋
Focusing

Micah Cooper mrmicahcooper

🥋
Focusing
View GitHub Profile
@mrmicahcooper
mrmicahcooper / triangle.rb
Created January 5, 2012 16:04
Neat little solution for the Koans triangle
#Determine the type of triangle by inputing in all the lengths.
def triangle(a, b, c)
case [a,b,c].uniq.size
when 1
:equilateral
when 2
:isosceles
when 3
:scalene
@mrmicahcooper
mrmicahcooper / deploy.rake
Created February 3, 2012 21:25
Rake task for deploying to heroku for production and staging
namespace :deploy do
desc 'Deploy to staging'
task :staging do
remote = "addyourherokustagingpathhere"
app = "appnamehere"
system "heroku maintenance:on --app #{app}"
system "git push -f #{remote} master"
system "heroku run rake db:migrate --app #{app}"
system "heroku maintenance:off --app #{app}"
@mrmicahcooper
mrmicahcooper / terrible-boat-names.md
Created March 27, 2012 17:21
The Worst Boat Names You Can Think Of
  • Shore Enuff
  • Row Boat Cop
  • Boat
  • Oh Buoy
  • Bust a Capsize
  • Current Events
  • Frayed Knot
  • Hull Lotta Love
  • A Seaworthy Cause
  • Tide To Go
@mrmicahcooper
mrmicahcooper / form_builder.rb
Created March 28, 2012 15:51
Helpful Form builder for Rails
class FormBuilder < ActionView::Helpers::FormBuilder
def label(method, text = nil, options = {}, &block)
text = text || method.to_s.humanize
unless object.nil? || options[:hide_errors]
errors = object.errors[method.to_sym]
if errors
text += " <span class=\"error\">#{errors.is_a?(Array) ? errors.first : errors}</span>"
end
@mrmicahcooper
mrmicahcooper / flashes.html.haml
Created March 28, 2012 15:52
Neatly display flashes
-flash.keys.each do |type|
#flash.flash{class: type}
%p= flash[type]
@mrmicahcooper
mrmicahcooper / harvest.sh
Created July 24, 2012 18:19
Get your git log goodies for tracking
#written by therubymug
#add to your ~/.bashrc.local
harvest() {
dow=$(date "+%u")
if [ -n "$2" ]; then
date=$2
else
if [ $dow = "1" ]; then
@mrmicahcooper
mrmicahcooper / example.html
Created August 30, 2012 01:59
html sample
<!DOCTYPE html>
<html>
<head>
<script src="http://code.jquery.com/jquery-1.8.0.min.js"></script>
<script src="http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.23/jquery-ui.min.js"></script>
<head>
<body>
@mrmicahcooper
mrmicahcooper / setup.markdown
Created October 1, 2012 23:26
Setup Rails environment for Ubuntu

#Rails for ubuntu 12.04

Install curl

sudo apt-get install curl

install git

@mrmicahcooper
mrmicahcooper / .vimrc.local
Created December 17, 2012 14:32
Preferred vim for Andy and Micah
set number
" display cursorline in active buffer
autocmd BufEnter * set cursorline
autocmd BufLeave * set nocursorline
" open quickfix window after grep commands
autocmd QuickFixCmdPost *grep* cwindow
" Turbux shortcuts
@mrmicahcooper
mrmicahcooper / .tmux.conf.local
Created December 17, 2012 14:34
Preferred setting for Andy and Micah
# reclaim default C-b behavior
if-shell 'test "$(tmux -V)" = "tmux 1.5"' 'set -g prefix C-z'
if-shell 'test "$(tmux -V)" = "tmux 1.6"' 'set -g prefix2 C-z'
if-shell 'test "$(tmux -V)" = "tmux 1.7"' 'set -g prefix2 C-z'
# mimic vi expectations
setw -g mode-keys vi
# faster reaction time
set -sg escape-time 1