Skip to content

Instantly share code, notes, and snippets.

@RSpace
RSpace / feature.rb
Created August 15, 2012 19:55
Browser testing with Test::Unit, Capybara, Poltergeist and PhantomJS
class Feature < Test::Unit::TestCase
include Capybara::DSL, FactoryGirl::Syntax::Methods
def teardown
Capybara.reset_sessions!
Capybara.use_default_driver
end
add_teardown_hook do |context|
context.instance_eval do
@RSpace
RSpace / gist:2932380
Created June 14, 2012 19:26
Podio app auth + read item example (Restsharp reference required)
using System;
using RestSharp;
using RestSharp.Deserializers;
namespace Podio
{
class Program
{
static void Main(string[] args)
{
function Location(id, data) {
// Public variables
this.id = id;
this.latitude = data["location"]["latitude"];
this.longitude = data["location"]["longitude"];
this.postal_district_id = data["location"]["postal_district_id"];
this.area_from = data["location"]["area_from"];
this.area_to =
class CustomFailure < Devise::FailureApp
# Never do http authentication through Devise
def http_auth?
false
end
def redirect_url
send(:"new_#{scope}_session_path", :format => (request.xhr? ? 'js' : nil ))
end
class User < ActiveRecord::Base
devise :database_authenticatable, :openid_authenticatable, :recoverable, :rememberable, :trackable, :validatable
# Handle creation of user authenticated via OpenID
def self.create_from_identity_url(identity_url)
User.new(:identity_url => identity_url)
end
# Set email as a required field from the Open ID provider
...
gem 'devise'
gem 'warden_oauth'
source :gemcutter
gem 'rails', '2.3.8'
# Bundle edge Rails instead:
# gem 'rails', :git => 'git://github.com/rails/rails.git'
gem 'rails', '2.3.8'
gem 'postgres'
gem 'aws-s3', '0.6.2'
Mime::Type.register "application/vnd.ms-excel", :xls
ActionController::Renderers.add :xls do |object, options|
instance = object.respond_to?(:first) ? object.first : object
options = instance.respond_to?(:xls_options) ? instance.xls_options : {}
self.send_data object.to_xls_data(options), :type => :xls
end
<%= form_for(@production) do |form| %>
<%= form.label :title, 'Title' %>
<%= form.text_field :title %>
<%= form.fields_for :employee_roles do |role_form| %>
<%= form.label :employee_id %></dt>
<%= form.select :employee_id, ... %>
<%= form.label :role_id %></dt>
<%= form.select :role_id, ... %>
<% end %>
Rails.configuration.to_prepare do
# Makes the the send_later_with_i18n method available to all objects
Object.send(:include, LocalizedJob::InstanceMethods)
end