Skip to content

Instantly share code, notes, and snippets.

View bsodmike's full-sized avatar

Michael de Silva bsodmike

View GitHub Profile
@bsodmike
bsodmike / gist:1194725
Created September 5, 2011 11:22
URL matching regex (generic)
(\bhttp://[a-z0-9\.\-_:~@##%&/?+=;]+)
@bsodmike
bsodmike / database.yml
Created September 13, 2011 15:10
Default Rails database.yml
# SQLite version 3.x
# gem install sqlite3
#
# Ensure the SQLite 3 gem is defined in your Gemfile
# gem 'sqlite3'
development:
adapter: sqlite3
database: db/development.sqlite3
pool: 5
timeout: 5000
@bsodmike
bsodmike / engine.rb
Created September 20, 2011 10:24 — forked from workmad3/gist:1228805
Another approach to dynamically defining application routes in Rails engine
module ActionDispatch::Routing
class Mapper
def engine_routing
#define your routes here. You can use all the normal route DSL stuff
resources :dashboard
end
end
end
module OilChange
@bsodmike
bsodmike / invitations_controller.rb
Created September 20, 2011 12:39
Rescue saves the day (MailChimp); See begin-rescue block.
Hominid::APIError in InvitationsController#create
<214> foo@bar.com is already subscribed to list LIST NAME. <a href="http://domain.us2.list-manage.com/subscribe/send-email?u=521Y29t">Click here to update your profile.</a>
@bsodmike
bsodmike / oa-openid_override.rb
Created September 21, 2011 07:32 — forked from Vaevictusnet/oa-openid_override.rb
config/initializers/omniauth.rb - Used to customise openid as a bespoke provider, with customised interface
require 'omniauth/openid'
require 'openid/store/filesystem'
module OmniAuth
class Form
def shard_field(name)
@html << "\n<select id='#{name}' name='#{name}'>"
@html << "\n<option value='5' selected='selected'>Tale 5: Amunet</option>"
@html << "\n<option value='5b'>Tale 5: Bastet</option>"
@html << "\n<option value='6'>Tale 6</option>"
@bsodmike
bsodmike / application.rb
Last active September 27, 2015 07:08
Modified config/application.rb to print out initialization points for Rails 3.2.11
require File.expand_path('../boot', __FILE__)
require 'rails/all'
if defined?(Bundler)
# If you precompile assets before deploying to production, use this line
Bundler.require(*Rails.groups(:assets => %w(development test)))
# If you want your assets lazily compiled in production, use this line
# Bundler.require(:default, :assets, Rails.env)
end
@bsodmike
bsodmike / fix.haml
Created September 21, 2011 19:34 — forked from Znow/gist:1233062
#employees_index.nivoSlider
- @employees.each do |employee|
= image_tag "employees/#{employee.image}", :height => 150, :width => 120, :title => '#htmlcaption'
- @employees.each do |employee|
#htmlcaption.nivo-html-caption
#employees_index_info
%ul
%li= employee.name
%li= employee.title
%li= employee.email
@bsodmike
bsodmike / env.rb
Created September 27, 2011 16:57 — forked from jmandala/env.rb
features/support/env.rb for Rails + Cucumber + Spree + Spork
require 'rubygems'
require 'spork'
Spork.prefork do
ENV["RAILS_ENV"] ||= "cucumber"
require File.expand_path(File.dirname(__FILE__) + '/../../config/environment')
require 'cucumber'
require 'cucumber/rails'
require 'cucumber/formatter/unicode' # Comment out this line if you don't want Cucumber Unicode support
@bsodmike
bsodmike / signing_in.feature
Created September 27, 2011 18:01 — forked from jonpaul/signing_in.feature
Cuke feature to handle devise sign-in with confirmable module
Feature: Signing in
In order to use the site
As a user
I want to be able to sign in
Scenario: Signing in via confirmation
Given there are the following users:
| email | password | unconfirmed |
| user@ticketee.com | password | true |
And "user@ticketee.com" opens the email with subject "Confirmation instructions"
@bsodmike
bsodmike / _form.html.erb
Created October 10, 2011 18:15 — forked from jonpaul/_form.html.erb
Multiple file uploads--
<%= form_for :vehicle_listing_images, :html => { :multipart => true } do |f| %>
<%= hidden_field_tag :listing_id, @listing_id %>
<div id="file_upload_area">
</div>
<% end %>
<div id="image-container">
<button id="primary_photo" class="btn right"><strong>Select Primary photo</strong></button>
<input type="hidden" name="vehicle_listing[primary_photo_id]" value="<%= @listing.primary_photo_id %>" id="primary_photo_id" />
<ul id="images">