Skip to content

Instantly share code, notes, and snippets.

View ntreadway's full-sized avatar

Nick Treadway ntreadway

  • Yeti Media
  • Orange County, Ca
  • X @nicktea
View GitHub Profile
@ntreadway
ntreadway / capybara-helpers.rb
Created April 20, 2012 23:46 — forked from jc00ke/capybara-helpers.rb
Capybara helpers
def set_mobile_agent
page.driver.header('User-Agent', 'iPhone')
end
def js_click(selector)
page.driver.execute_script "$('##{selector}').click()"
end
def screenshot
require 'capybara/util/save_and_open_page'
@ntreadway
ntreadway / page_inject.coffee
Created April 18, 2012 17:27
Simple page inject for JQuery Mobile and Rails Partials
# Used to dynamically add a rails page view when using Jquery Mobile
# Author Nick Treadway @nicktea
@insert_page = (id, content) ->
page = $("<article id="+id+" data-role='page' data-url="+id+" data-add-back-btn='true'>" + content + "</article>")
page.appendTo('body')
$('a' + '#' + id).click ->
$.mobile.changePage(page, {transition: "slide"})
# Use (your-view.haml)
@ntreadway
ntreadway / responsive-h5bp
Created March 22, 2012 01:49
Responsive h5bp
<!doctype html>
<!--[if lt IE 7]> <html class="no-js ie6 oldie" lang="en"> <![endif]-->
<!--[if IE 7]> <html class="no-js ie7 oldie" lang="en"> <![endif]-->
<!--[if IE 8]> <html class="no-js ie8 oldie" lang="en"> <![endif]-->
<!--[if gt IE 8]><!--> <html class="no-js" lang="en"> <!--<![endif]-->
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge,chrome=1">
<title>Your Sick Page</title>
<meta name="description" content="">
@ntreadway
ntreadway / Select Field Styling using coffee script
Created March 5, 2012 20:49
Style your HTML Select Field using CoffeeScript and JQuery
$(document).ready ->
unless $.browser.opera
$("select.option_id").each ->
title = $(this).attr("title")
title = $("option:selected", this).text() unless $("option:selected", this).val() is ""
$(this).css(
"z-index": 10
opacity: 0
"-khtml-appearance": "none"
).after("<span class=\"select\">" + title + "</span>").change ->
@ntreadway
ntreadway / gist:1643685
Created January 19, 2012 23:25
Compass outputting to /public
/*
Syntax error: File to import not found or unreadable: partials/base.
Load paths:
Compass::SpriteImporter
/Users/ntreadway/rentwb/public/stylesheets/sass
/Users/ntreadway/rentwb/app/assets/stylesheets
/Users/ntreadway/.rbenv/versions/1.8.7-p352/lib/ruby/gems/1.8/bundler/gems/compass-520df2b17331/frameworks/blueprint/stylesheets
/Users/ntreadway/.rbenv/versions/1.8.7-p352/lib/ruby/gems/1.8/bundler/gems/compass-520df2b17331/frameworks/compass/stylesheets
on line 7 of /Users/ntreadway/rentwb/app/assets/stylesheets/front_facing.css.scss
before do
@store ||= Factory(:capybara_store, :depot => true)
@order ||= Factory(:order, :state => "processed", :store_id => @store.id, :shipping_address_id => user.default_address.id, :user => user)
<<<<<<< HEAD
@item ||=Factory(:rental_item, :order => @order, :created_at => 32.days.ago, :from => 32.days.ago, :source_status => 'shipped')
login(user)
=======
@rental_item ||= Factory(:rental_item, :order => @order, :created_at => 32.days.ago, :from => 32.days.ago, :source_status => 'shipped')
>>>>>>> 6450894835d13bbca6b80cb5811f7099d4857a29
end
Given /^I visit subdomain "(.+)"$/ do |sub|
#host! "#{sub}.example.com" #for webrat
Capybara.default_host = "#{sub}.example.com" #for Rack::Test
Capybara.app_host = "http://#{sub}.example.com:9887" if Capybara.current_driver == :culerity
################################################################################
# As far as I know, you have to put all the {sub}.example.com entries that you're
# using in your /etc/hosts file for the Culerity tests. This didn't seem to be
# required for Rack::Test
################################################################################
@ntreadway
ntreadway / iphone-jquery-hover.rb
Created November 17, 2010 02:14
Simple iphone js onclick function to simulate :hover
- content_for :js do
- javascript_tag do
if((navigator.userAgent.match(/iPhone/i)) || (navigator.userAgent.match(/iPod/i))
||(navigator.userAgent.match(/iPad/i))) {
$(".nav li a").click(function(){
$(".nav li a").removeClass("hover");
$(this).addClass("hover");
});
}
@ntreadway
ntreadway / haml detection
Created November 13, 2010 03:34
Jquery ipad /Haml detection
- content_for :js do
- javascript_tag do
var agent=navigator.userAgent.toLowerCase();
var is_ipad = (agent.indexOf('ipad')!=-1);
if (is_ipad) {
$('body').css('-webkit-background-size', '1024px 1024px');}
@ntreadway
ntreadway / tabs.sass
Created August 19, 2009 06:32
Jquery tools tabs css to sass
/* root element for tabs */
ul.tabs
margin:0 !important
padding: 0
height: 30px
border-bottom: 5px solid #ddd
/* single tab */
ul.tabs li
float: left