Skip to content

Instantly share code, notes, and snippets.

Avatar

Nick Treadway ntreadway

View GitHub Profile
View uninitialized constant MemCache (NameError) fix rails 2.3.2
config.after_initialize do
Workling::Remote.dispatcher = Workling::Remote::Runners::StarlingRunner.new
end
View Factory Girl and cucumber
#factories setup w/ cucumber.
#(env.rb)
require 'factory_girl'
Before do
require File.join(RAILS_ROOT, 'test', 'factories')
end
#Then in your (setups.rb) you can create your object using one line.
View Dymanic embed code from inside Flash
// load root vars setup URL and Code to copy
var myRoot = root;
var player:String = "http://cdn.cloudfiles.mosso.com/c38342/wc_video_player.swf"
var EmbedCode:String = '<object classid="clsid:D27CDB6E-AE6D-11cf-96B8-444553540000" id="wc_video" width="552" height="335" codebase="http://download.macromedia.com/pub/shockwave/cabs/flash/swflash.cab">';
EmbedCode += '<param name="movie" value="'+ player +'" />';
EmbedCode += '<param name="allowScriptAccess" value="always" />';
EmbedCode += '<param name="FlashVars" value="mediaType=video&mediaSrc=' + myRoot.strSource +'&addToCanvas='+ myRoot.canvas +'&page='+ myRoot.page +'" />';
EmbedCode += '<embed src="'+ player +'" quality="high" width="552" height="335" name="Example" align="middle" play="true" loop="false" quality="high" allowScriptAccess="always" type="application/x-shockwave-flash" pluginspage="http://www.macromedia.com/go/getflashplayer" FlashVars="mediaType=video&mediaSrc=' + myRoot.strSource +'&addToCanvas='+ myRoot.canvas +'&page='+ myRoot.page +'"></em
@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
@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 / 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");
});
}
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
################################################################################
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
@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
@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 ->