Skip to content

Instantly share code, notes, and snippets.

still a bad fish and free bird

Russell Norris rsl

still a bad fish and free bird
Block or report user

Report or block rsl

Hide content and notifications from this user.

Learn more about blocking users

Contact Support about this user’s behavior.

Learn more about reporting abuse

Report abuse
View GitHub Profile
View gist:bada9e358caf0a985da70a51fac8ba12
Mozilla/5.0 (Windows NT 6.1) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/52.0.2743.116 Safari/537.36
rsl / routes_snippet.rb
Created Jul 14, 2016
Routing fix for devise_saml_authenticatable
View routes_snippet.rb
# Snip snip snip
devise_for :users, skip: [:registrations, :saml_authenticatable], controllers: {sessions: 'devise_sessions'}
# Manually add user editing but disallow registrations [above]
as :user do
get 'users/edit' => 'devise_registrations#edit', as: 'edit_registration'
patch 'users' => 'devise_registrations#update', as: 'registration'
# To avoid conflict saml_authenticatable routes are manually defined here.
# Also we override the controller.
resource :session, as: 'saml_session', only: [], controller: 'devise_saml_sessions', path: '/companies/:id/saml' do
View user.rb
class User < ActiveRecord::Base
# Owned events
has_many :events, dependent: :nullify
has_many :event_memberships, dependent: :nullify
has_many :member_events, through: :event_memberships, source: :user
View user.rb
class User < ActiveRecord::Base
View controller.rb
class ApplicationController < ActionController::Base
whitelist_params user: [:name, :email], comment: [:body, :email] #...
# Creates user_params, comment_params with expected whitelisting
View posts_controller.rb
class PostsController < ApplicationController
# Automatically create the strong parameters required method
def PostsController.filter_parameters(options = {})
options[:for] = [options[:for]] if options[:for].is_a?(Symbol)
options[:for].each do |action_name|
define_method("#{action_name.to_s}_params") do
base = options[:require].keys.first
View valid.rb
def foo
return unless
puts 'oh yeah'
def bar
return if
puts 'oh no'
rsl / scrollfix.js
Last active Aug 29, 2015
Page scroll fix for jQuery Sortable [ not jQuery UI version]
View scrollfix.js
onDrag: function ($item, position, _super, event) {
var $window = $(window);
var itemTop = $item.offset().top;
if (itemTop > ($window.scrollTop() + $window.height())) {
if (!window.lastItemTop || (itemTop > window.lastItemTop)) {
window.scrollBy(0, 10);
} else if (itemTop < $window.scrollTop()) {
if (!window.lastItemTop || (itemTop < window.lastItemTop)) {
rsl / some.css.scss
Created Jul 17, 2014
don't conditionally set "display: none" as style. set a conditional class and leverage nested SCSS rules.
View some.css.scss
#survey_search {
&.hide {
display: none;
// Other rules
View body_class.rb
def body_class(string = nil)
[string].tap do |names|
# Standard
names << controller_name << action_name
# App-specific
names << 'foo' if foo? # Et cetera
end.compact.join ' '
You can’t perform that action at this time.