Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Treadway ntreadway

View GitHub Profile
View capybara-helpers.rb
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 Apr 18, 2012
Simple page inject for JQuery Mobile and Rails Partials
View page_inject.coffee
# 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)
View 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 Mar 5, 2012
Style your HTML Select Field using CoffeeScript and JQuery
View Select Field Styling using coffee script
$(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 Jan 19, 2012
Compass outputting to /public
View gist:1643685
/*
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
View gist:1377438
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
View custom_steps.rb
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 Nov 17, 2010
Simple iphone js onclick function to simulate :hover
View iphone-jquery-hover.rb
- 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 Nov 13, 2010
Jquery ipad /Haml detection
View 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 Aug 19, 2009
Jquery tools tabs css to sass
View tabs.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