Skip to content

Instantly share code, notes, and snippets.

View datapimp's full-sized avatar

Jonathan Soeder datapimp

View GitHub Profile
# add to user model
has_many :authentications, :dependent => :destroy
# config/routes.rb
match '/auth/:provider/callback' => 'authentications#create'
match '/auth/failure' => redirect('/users/sign_in')
# config/initializers/omniauth.rb
require 'openid/store/filesystem'
App.util.parse_content_location = (location)->
# parts = ["content_packages","1","sections","1"]
# parent class, parent id, content item class, content item id
parts = location.split(':')
App.util.find_object_for_location = (content_location)->
[pkg, pkg_id, store, object_id] = App.util.parse_content_location(content_location)
# find the table based on the store variable
collection = Store(store)
@datapimp
datapimp / gist:1049943
Created June 27, 2011 21:53
nested attributes example
class ExamResult
has_many :answers, :dependent => :destroy
accepts_nested_attributes_for :answers
# for cleaner API
alias_method :user_answers=, :answers_attributes=
end
class Answer
belongs_to :exam_result
@datapimp
datapimp / backbone-ext.js
Created March 30, 2011 17:21
Before / After filters for backbone controllers
_.extend(Backbone.Controller.prototype, Backbone.Events, {
route : function(route, name, callback) {
Backbone.history || (Backbone.history = new Backbone.History);
if (!_.isRegExp(route)) route = this._routeToRegExp(route);
Backbone.history.route(route, _.bind(function(fragment) {
var args = this._extractParameters(route, fragment);
if( _.isFunction( this.before ) ){
this.before.apply(this, args)
}
class SectionsController < ApplicationController
before_filter :require_client
def index
cache_key = "#{ current_package.id }:sections"
@sections = Rails.cache.read cache_key
if !@sections
@sections = Section.tree_for( current_package )
We couldn’t find that file to show.
PassengerHighPerformance on
PassengerMaxPoolSize 30
PassengerPoolIdleTime 0
RailsAutoDetect off
RailsSpawnMethod smart
PassengerStatThrottleRate 10
RailsAppSpawnerIdleTime 0
<p>Hello <%= @resource.email %>!</p>
<p>Someone has requested a link to change your password, and you can do this through the link below.</p>
<p><%= link_to 'Change my password', edit_password_url(@resource, :reset_password_token => @resource.reset_password_token) %></p>
<p>If you didn't request this, please ignore this email.</p>
<p>Your password won't change until you access the link above and create a new one.</p>
<p>Welcome <%= @resource.email %>!</p>
<p>You can confirm your account through the link below:</p>
<p><%= link_to 'Confirm my account', confirmation_url(@resource, :confirmation_token => @resource.confirmation_token) %></p>
require 'net/https'
module SecurityModule
class HighSecurity
class ReallyHighSecurity
def self.turn_on_safe_connections
OpenSSL::SSL::VERIFY_NONE
end
end
end