Skip to content

Instantly share code, notes, and snippets.

View andyferra's full-sized avatar

Andy Ferra andyferra

View GitHub Profile
RSpec.configure do |config|
config.before_tag :javascript do
setup_javascript_shit!
end
config.after_tag :javascript do
teardown_javascript_shit!
end
validates_presence_of :salesrep, :days_discounted, :discount_percent, :days_until_due
validates_presence_of :name, :address, :number, :phone_number, :start_on
validates_uniqueness_of :name, :number
validates_numericality_of :days_discounted, :greater_than_or_equal_to => 0, :only_integer => true
validates_numericality_of :discount_percent, :greater_than_or_equal_to => 0
validates_numericality_of :days_until_due, :greater_than_or_equal_to => 0, :only_integer => true
named_scope :like, case_insensitive_query_on(:name)
ENV["RAILS_ENV"] ||= 'test'
require File.dirname(__FILE__) + "/../config/environment" unless defined?(RAILS_ROOT)
require 'spec/autorun'
require 'spec/rails'
require File.dirname(__FILE__) + '/factories'
# Requires supporting files with custom matchers and macros, etc,
# in ./support/ and its subdirectories.
var AppState = Class.create({
PORTRAIT: 0,
LANDSCAPE: 1,
orientation: -1,
initialize: function() {
this.orientation = this.PORTRAIT; // default for desktop browser
this.setUpOrientationListener();
},
setUpOrientationListener : function() {
// add listener to window if it's orientation-capable
// From: http://www.krisbailey.com/2009/01/creating-code-39-barcodes-in-pure-javascript/
function print_html_code39_barcode(
content,
height,
insertCheckDigit,
printContent,
fontPointSize,
thinBarWidth,
barWidthRatio){
# default.gems generated gem export file. Note that any env variable settings will be missing. Append these after using a ';' field separator
aasm -v2.1.5
actionmailer -v2.3.5
actionmailer -v2.3.2
actionpack -v2.3.5
actionpack -v2.3.2
activerecord -v2.3.5
activerecord -v2.3.2
activeresource -v2.3.5
activeresource -v2.3.2
mvim://open?url=file:///path/to/file.rb&line=10
format.json do
response = {}
if lot = @location.customer_product_lots.find_by_barcode(params[:barcode])
product = lot.customer_product
response['lotInfo'] = {
'domId' => "customer_product_lot_#{ lot.id }",
'lotNumber' => lot.lot_number,
'expirationDate' => lot.expires_on.strftime('%x'),
FakeWeb.allow_net_connect = false
FakeWeb.register_uri :any, 'https://bigredape-test.s3.amazonaws.com/', :status => ["200", "OK"], :body => ''
FakeWeb.register_uri :get, 'https://s3.amazonaws.com/', :status => ["200", "OK"], :body => %{<?xml version="1.0" encoding="UTF-8"?><ListAllMyBucketsResult xmlns="http://s3.amazonaws.com/doc/2006-03-01/"><Owner><ID>6a3801b3d3f91f3d2a67cc127f18d8a532b86831e5457814b2ed2ab929f98547</ID><DisplayName>led</DisplayName></Owner><Buckets><Bucket><Name>bigredape-development</Name><CreationDate>2010-02-15T08:10:19.000Z</CreationDate></Bucket><Bucket><Name>bigredape-test</Name><CreationDate>2010-02-15T08:58:13.000Z</CreationDate></Bucket></Buckets></ListAllMyBucketsResult>}, :content_type => 'application/xml'
FakeWeb.register_uri :get, /http(s?):\/\/bigredape-test\.s3\.amazonaws\.com\/\?prefix=works(.*?)images(.*?)thumbnail(.*?)face\.jpg/, :status => ["200", "OK"], :bo
@andyferra
andyferra / gist:305011
Created February 15, 2010 21:24
chat with dkubb about dm-validations :email_format
conekt: question... can you think of a case where 'user@something' without a .com would be a valid email?
conekt: or a .anything...
dkubb: some internal email systems would accept it, but for it to be routed internet you would need a valid tld
conekt: apparently :format => :email_address allows that...
dkubb: a valid tld being a gTLD, ccTLD or arpa
conekt: agreed, but if my intention is to validate user input in a web application, that feels like bad input just waiting to happen
dkubb: hmm, that is probably a bug. can you submit a ticket with that problem?
conekt: sure, I agree with the current implementation in principal... maybe if :email_address only matched web friendly examples and there was another built in pattern that would matching those other cases that would blow up on the web
conekt: for the issue, you want the whole example file with specs and everything I assume?
dkubb: the email address regexp matches emails according to the RFC's, except the RFC's are more generic than what an internet