PikachuEXE PikachuEXE

View default_params.rb
1 2 3 4 5 6 7 8 9 10
# https://github.com/rspec/rspec-rails/issues/255
require 'active_support/concern'
 
module DefaultParams
extend ActiveSupport::Concern
 
included do
let(:default_params) { {locale: I18n.locale} }
 
def process_with_default_params(action, http_method = 'GET', *args)
View routing.rb
1 2 3 4 5 6 7 8 9 10
#lib/routing.rb
 
# SO: http://stackoverflow.com/questions/16720514/how-to-use-url-helpers-in-lib-modules-and-set-host-for-multiple-environments
module Routing
extend ActiveSupport::Concern
include Rails.application.routes.url_helpers
 
included do
def default_url_options
{ :locale => I18n.locale }
View check_for_memcached.rb
1 2 3 4 5 6 7 8 9
# Use a different cache store based on memcached is running or not
begin
# check if memcached is running; if it is, use that instead of the default memory cache
Timeout.timeout(0.5) { TCPSocket.open("localhost", 11211) { } }
config.cache_store = :dalli_store, %w(localhost:11211), {namespace: Rails.application.class.parent_name, expires_in: 1.day, compress: true}
$stderr.puts "Using memcached on localhost:11211"
rescue StandardError
$stderr.puts "memcached not running, caching to memory"
end
View toggle-display.js.coffee
1 2 3 4 5 6 7 8 9 10
###
Toggle Display
Put the data attributes on a button or link
 
Required attributes:
data-toggle: 'display'
data-target: selector of target element
 
Optional attibutes:
data-effect: 'slide', 'fade', other values (no effect)
View hoverable.scss
1 2 3 4 5 6 7 8 9 10
// This class use direct selector '>' since you might want to use it nested way
// Like hover menu, then hover button
 
.hoverable-container {
& > .hoverable-content.on-hover {
display: none;
}
 
&:hover {
// Hide the default one
View toggleable.js.coffee
1 2 3
jQuery ($) ->
$(document).on "click", '.js-toggleable-container', ->
$(this).toggleClass("is-toggled")
View placeholder.js
1 2 3 4 5 6 7 8 9 10
/**
* This hack creates the placeholder effect on old browsers
*
* Source: http://www.hagenburger.net/BLOG/HTML5-Input-Placeholder-Fix-With-jQuery.html
* Dependency: jQuery & Modernizr
*
* It also add a class to the input so you can style it to look like normal placeholder
*/
 
jQuery(function($) {
Something went wrong with that request. Please try again.