Skip to content

Instantly share code, notes, and snippets.

View simonrentzke's full-sized avatar

Simon Rentzke simonrentzke

View GitHub Profile
@simonrentzke
simonrentzke / gist:343418
Created March 25, 2010 10:54
content types
def set_content
case self.content_type
when "video/mpeg", "video/quicktime", "video/x-msvideo", 'video/x-ms-wmv', 'video/mp4', 'video/avi'
self.content = VIDEO
when 'image/gif', 'image/jpeg', 'image/png', "image/pjpeg", "image/x-png"
self.content = IMAGE
when 'audio/wav', 'audio/x-wav', 'audio/x-ms-wma', 'audio/mpeg', 'audio/x-m4a', 'audio/m4a'
self.content = AUDIO
when "application/msword", 'application/pdf', 'application/rtf', 'text/plain', 'text/rtf'
self.content = DOCUMENT
# Then /^"([^\"]*)" should be in the autocomplete menu$/ do |name|
# xpath_to_auto_complete_selection = "//ul[contains(@class, 'ui-autocomplete')]"
#
# # wait until auto complete menu appears
# page.should have_xpath(xpath_to_auto_complete_selection)
# page.evaluate_script('$("#show_title").attr("value", "my p")')
# page.evaluate_script('e = jQuery.Event("keydown")')
# page.evaluate_script('e.which = 67')
# page.evaluate_script('$("#show_title").trigger("focus").trigger(e)')
#
Failing Scenarios:
cucumber features/award/applying.feature:12 # Scenario: Applying for an award with no questions
cucumber features/award/applying.feature:23 # Scenario: Applying for an award with questions
cucumber features/award/applying.feature:47 # Scenario: Applying for my second award
cucumber features/award/applying.feature:82 # Scenario: A volunteer is nominates which organisation should validate the award before, during and after submission.
cucumber features/organiser/upload_photo.feature:3 # Scenario: Uploading a photo as organiser
cucumber features/schools/school_adviser/managing_schools.feature:23 # Scenario: Creating a school
cucumber features/volunteer/edit_my_profile.feature:29 # Scenario: Editing my interests
cucumber features/volunteer/photo_uploads.feature:65 # Scenario: Uploading an image and seeing it in the activity stream
To remove vendor and public directories in textmate project (if it is loading too slow).
Click [i] in the tray, and edit the root folder pattern to this:
!.*/(\.[^/]*|public|vendor|CVS|_darcs|_MTN|\{arch\}|blib|.*~\.nib|.*\.(framework|app|pbproj|pbxproj|xcode(proj)?|bundle))$
@simonrentzke
simonrentzke / gist:1030872
Created June 17, 2011 04:29
Cruise Control automated Heroku script.
if CruiseControl::invoke_rake_task 'spec'
puts "Pushing on heroku... [Start]"
`git push heroku master`
puts "Pushed on heroku. [Done]"
puts "Running migrations... [Start]"
`heroku rake db:migrate`
puts "Migrated... [Done]"
puts "Prepare test db... [Start]"
`heroku rake db:test:prepare`
puts "Test database ready [Done]"
@simonrentzke
simonrentzke / gist:1842486
Created February 16, 2012 06:00
Forcing Card Type with ActiveMerchant Testing
Factory.define :user_credit_card do |cc|
cc.card_type "bogus"
cc.card_number 1
cc.verification_value "123"
cc.expiration_date Time.now + 1.year
end
@simonrentzke
simonrentzke / mergeable models
Created October 18, 2012 10:47
Merging one record into another - take care of all associated data.
module Mergeable
def merge_associated_records_and_destroy(throwaway_object, special_cases = {})
#look for any fields that match field name
field_name_to_update = "#{self.class.to_s.downcase}_id"
Dir[Rails.root.to_s + '/app/models/**/*.rb'].each { |file| require(file)}
message = []
models = ActiveRecord::Base.subclasses.collect
begin
models.each do |m|
if m.columns_hash["#{self.class.to_s.downcase}_id"]
@simonrentzke
simonrentzke / test.haml
Created May 7, 2013 00:20
haml template
!!! 5
%html
%head
%title= "Your Website"
%meta{ :content => "", :name => "description" }
%meta{ :content => "", :name => "author" }
%meta{ :content => "3 days", :name => "revisit-after" }
%link{ :href => "http://creativecommons.org/licenses/by/3.0/", :rel => "license", :title => "Creative Commons Attribution 3.0 Unported License" }
%link{ :href => "/css/screen.css", :media => "screen", :rel => "stylesheet" }
%body
@simonrentzke
simonrentzke / gist:5856414
Last active September 30, 2023 03:18
Array of array subtraction
function remove_selected_from_options(arr1, arr2) {
var filtered_options = [];
for (var i=0; i < arr1.length; i++) {
var included = false;
for (var z=0; z < arr2.length; z++) {
if (arr2[z][0] == arr1[i][0]) {
included = true;
break;
}
}
@simonrentzke
simonrentzke / setup_edge_rails.sh
Last active August 31, 2015 00:16
Setup an Edge Rails 5 application from Scratch
mkdir rails-5-test-app
cd rails-5-test-app
touch .ruby-version
echo 'ruby-2.2.2' > .ruby-version
touch Gemfile
printf "source 'https://rubygems.org'\nruby '2.2.2'\n\n\ngem 'rails', github: 'rails/rails'\ngem 'arel', github: 'rails/arel'\ngem 'rack', github: 'rack/rack'" >> Gemfile
bundle
bundle exec rails new . --dev --force
bundle exec rails s