Skip to content

Instantly share code, notes, and snippets.

View amandarae's full-sized avatar

amanda rae amandarae

View GitHub Profile
@amandarae
amandarae / gist:3314217
Created August 10, 2012 13:28
OOC if statement found to refactor
def welcome
@show_splash = false
if @current_user
redirect_to home_path(@current_brand)
else
@ct_deal = nil
@biz_deal = nil
@kidz_deal = nil
Deal.live_by_brand(MasterBrand.first, @current_region).each do |chkdeal|
if check_for_exclusive_deal_access(chkdeal, @current_user)
@amandarae
amandarae / gist:3352114
Created August 14, 2012 19:39
refactor to be scalable (ruby iteration)
def my_deals
#@orders = @current_user.orders.joins(:brand).where{|q| q.brand.slug == @current_brand.slug }.ordered.order('created_at DESC').paginate(:page => params[:page], :per_page => 10)
#other_brands = @current_user.orders.ordered.joins(:brand).includes(:brand).where{|q| q.brand.slug != @current_brand.slug }.map{|o| o.brand}.uniq
#@other_brands = BrandDecorator.decorate(other_brands)
@brands = SimpleBrand.all + NormalBrand.all
@orders = Array.new
@brands.each do |b|
@orders << @current_user.orders.ordered.joins(:brand).where{|q| q.brand.slug == b.slug}.ordered.order('created_at DESC').paginate(:page => params[:page], :per_page => 3)
end
@amandarae
amandarae / iterm2.md
Created August 15, 2012 21:35 — forked from sockmonk/iterm2.md
iterm2 cheatsheet
Function Shortcut
previous tab ⌘ + left arrow
next tab ⌘ + right arrow
go to tab ⌘ + number
close a tab ⌘ + w
go to window ⌘ + Option + Number
go to split pane by direction ⌘ + Option + arrow
go to split pane by order of use ⌘ + ] , ⌘ + [
split window horizontally (same profile) ⌘ + D

tmux cheatsheet

As configured in my dotfiles.

start new:

tmux

start new with session name:

@amandarae
amandarae / vim_cheatsheet.md
Created August 15, 2012 21:39 — forked from zefer/vim_cheatsheet.md
My newbie Vim cheatsheet

#Vim Cheat Sheet by jessedearing

  • gqip - Reformats paragraph to textwidth
  • gq - Reformats selection
  • :Tab /= - Equally spaces based on the = symbol (requires Tabular vim plugin)
  • :setf language - Changes current language
  • :set language=language - Changes current language
  • <C-a> - Increments the number under the cursor
  • <C-x> - Decrements the number under the cursor
  • ~ - Toggles case and moves to next character in normal mode
@amandarae
amandarae / gist:3418466
Created August 21, 2012 19:15
strip all :focus from spec files
alias unfocus="for file in $(grep -irl ', :focus' spec) ; do sed -i '' 's/, :focus//' $file; done"
-courtesy of richard gould
@amandarae
amandarae / cookies_js.js
Created September 7, 2012 21:42
The forever floating around cookie js script
function createCookie(name,value,days) {
if (days) {
var date = new Date.getTime()+(days*24*60*60*1000));
var expires = "; expires="+date.toGMTString();
}
else var expires = "";
document.cookie = name+"="+value+expires+"; path=/";
}
function readCookie(name) {
@amandarae
amandarae / gist:3772129
Created September 23, 2012 16:01
query string append
redirect_to region_home_path(@user.region) << '?acc=nu'
def new_user_created
@new_user_created = false
if params[:acc] == "nu"
@new_user_created = true
end
end