Skip to content

Instantly share code, notes, and snippets.

@kulbirsaini
kulbirsaini / devise.rb
Created March 13, 2011 06:43
Devise configuration to allow username or email address for sign_in, confirmation, unlock, forgot password instructions.
################################################################
# For views/migrations etc. check http://tinyurl.com/3xfx3zm #
################################################################
# File : RAILS_APP/config/initializers/devise.rb
# Change the following only. Rest can stay same
# NOTE : You must use devise master or any version released after Mar 13, 2011 to get everything mentioned here working.
config.authentication_keys = [ :login ]
config.confirmation_keys = [ :login ]
config.unlock_keys = [ :login ]
<script>
// (c) Copyright 2016 Caroline Schnapp. All Rights Reserved. Contact: mllegeorgesand@gmail.com
// See https://docs.shopify.com/themes/customization/navigation/link-product-options-in-menus
var Shopify = Shopify || {};
Shopify.optionsMap = {};
Shopify.updateOptionsInSelector = function(selectorIndex) {
@postpostmodern
postpostmodern / rails_bootstrap_delete_confirmation_modal.md
Created February 19, 2012 07:38 — forked from trey/rails_bootstrap_delete_confirmation_modal.md
A nice delete confirmation modal in Rails courtesy of Bootstrap

Here's what you get.

Some CoffeeScript (verbosely commented for clarity)

# Override Rails handling of confirmation

$.rails.allowAction = (element) ->
  # The message is something like "Are you sure?"
  message = element.data('confirm')
@mrdanadams
mrdanadams / application.js
Created March 28, 2012 20:41
Updating a DIV with partials after remote AJAX form submit in Rails 3
$(function() {
/* Convenience for forms or links that return HTML from a remote ajax call.
The returned markup will be inserted into the element id specified.
*/
$('form[data-update-target]').live('ajax:success', function(evt, data) {
var target = $(this).data('update-target');
$('#' + target).html(data);
});
});
class ApplicationController < ActionController::Base
...
#Problem:
#In rails 3.0.1+ it is no longer possible to do this anymore;
# rescue_from ActionController::RoutingError, :with => :render_not_found
#
#The ActionController::RoutingError thrown is not caught by rescue_from.
#The alternative is to to set a catch-all route to catch all unmatched routes and send them to a method which renders an error
#As in http://techoctave.com/c7/posts/36-rails-3-0-rescue-from-routing-error-solution
@olistik
olistik / gist:2627011
Last active August 12, 2021 06:39
Ubuntu 12.10 setup (rbenv/RVM, Janus, PostgreSQL)

Ubuntu 12.10 setup (rbenv/RVM, Janus, PostgreSQL)

Basic pre-requisites

  • Some utilities:
sudo apt-get install vim tmux git curl
  • Copy/paste from the command line:
@kazpsp
kazpsp / passwords_controller.rb
Created August 14, 2012 16:40 — forked from guilleiguaran/passwords_controller.rb
StrongParameters with Devise
# app/controllers/users/password_controller.rb
class Users::PasswordsController < Devise::PasswordsController
def resource_params
params.require(:user).permit(:email, :password, :password_confirmation)
end
private :resource_params
end
@iros
iros / API.md
Created August 22, 2012 14:42
Documenting your REST API

Title

<Additional information about your API call. Try to use verbs that match both request type (fetching vs modifying) and plurality (one vs multiple).>

  • URL

    <The URL Structure (path only, no root url)>

  • Method:

@SteveBenner
SteveBenner / brewfix1-osxfuse.rb
Last active April 4, 2022 22:47 — forked from yiufung/truecrypt_fix.bash
Homebrew fix - unexpected files and libs from ‘osxfuse'
#!/usr/bin/env ruby
#
# Homebrew fix 1 - osxfuse dylibs
#
# original solutions: https://gist.github.com/aaronzirbes/3239033
# https://gist.github.com/trinitronx/5437061
#
# Fixes the following:
#
# > Warning: Unbrewed dylibs were found in /usr/local/lib.
@freakdesign
freakdesign / new-content-for-header.liquid
Last active October 15, 2021 23:38
Detect if an admin is logged into Shopify using liquid.
<!--
Simple method for detecting an Admin in Shopify using liquid.
Quick code by jason at freakdesign.com.au
Related Blog post: http://freakdesign.com.au/blogs/news/34154561
-->
{% capture CFH %}{{ content_for_header }}{% endcapture %}{{ CFH }}
{% if CFH contains 'admin_bar_iframe' %}