This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
(function(doc) { | |
var ref = doc.referrer; | |
if (ref.match(/google\./gi)) { | |
var query = ref.split('?')[1], | |
keyword = '(not provided)', | |
pathname = doc.location.pathname, | |
rank = null, | |
param; | |
if (query) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def set_locale | |
if @locale.nil? | |
I18n.locale = params[:locale] || I18n.default_locale | |
@locale = I18n.locale.to_sym | |
end | |
end | |
def default_url_options(options = {}) | |
set_locale if @locale.nil? | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
desc 'Cleanup tasks' | |
namespace :clean do | |
desc 'Clean sessions table (pass DAYS=X default is 30 days)' | |
task :sessions => :environment do | |
days = ENV['DAYS'].to_i | |
days = 30 if days <= 0 | |
result = ActiveRecord::Base.connection.execute("DELETE FROM sessions WHERE updated_at <= (CURRENT_DATE - INTERVAL '#{days} days')") | |
affected_rows = result.cmd_tuples | |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module ActiveSupport | |
module Inflector | |
def pluralize_with_parenthesis(word) | |
rule, replacement = find_inflections(word, inflections.plurals) | |
if replacement =~ /\A\w+\Z/ | |
word.gsub!(rule, "(#{replacement})") | |
else | |
pluralize(word) | |
end | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<script> | |
////// START EDITING HERE | |
var utmx_key = 'XXXXXXX-X', // change this to your experiment key | |
show_on = 'mobile', // Can be 'mobile' or 'desktop' | |
///// STOP EDITING HERE | |
/////////////////////////// | |
is_mobile = function () { | |
return /android|webos|iphone|ipad|ipod|blackberry|iemobile|opera\s?mini/i.test(navigator.userAgent.toLowerCase()); | |
}, |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
module RailsWithNg | |
class Application < Rails::Application | |
[...] | |
config.assets.paths << Rails.root.join('app', 'ng') | |
# Add bower CSS components | |
bower_path = Rails.root.join('vendor', 'assets', 'bower_components') | |
config.assets.paths << bower_path | |
config.sass.load_paths << bower_path |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
def z_score(variation_id) | |
# Taken from https://github.com/andrew/split/blob/master/lib/split/zscore.rb | |
n_1 = views_count(variation_id).to_f | |
n_2 = views_count(popup_id).to_f | |
p_1 = conversion_rate(variation_id) | |
p_2 = conversion_rate(popup_id) | |
if n_1 < 30 || n_2 < 30 || (p_1 * n_1 < 5) || (p_2 * n_2 < 5) | |
return false | |
end |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
RewriteCond %{QUERY_STRING} ^lang=(\w{2})/(.*)$ | |
RewriteRule .* http://%1.example.com/%2 [L,R=301] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /var/log/nginx/conf.d/mobile.conf | |
map $http_user_agent $mobile { | |
default 0; | |
~*(android|bb\d+|meego).+mobile|ip(hone|od)|opera\sm(ob|in)i|mobile.+firefox 1; | |
~*iemobile|phone|symbian|windows\sce|blackberry|up\.(browser|link) 1; | |
~*avantgo|bada\/|blazer|compal|elaine|fennec|hiptop|iris|kindle|lge\s|maemo 1; | |
~*midp|mmp|netfront|palm(\sos)?|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0 1; | |
~*treo|vodafone|wap|xda|xiino 1; | |
~*^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a\swa|abac|ac(er|oo|s\-)) 1; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# /var/log/nginx/conf.d/mobile.conf | |
map $http_user_agent $mobile { | |
default 0; | |
~*(android|bb\d+|meego).+mobile|ip(hone|od)|opera\sm(ob|in)i|mobile.+firefox 1; | |
~*iemobile|phone|symbian|windows\sce|blackberry|up\.(browser|link) 1; | |
~*avantgo|bada\/|blazer|compal|elaine|fennec|hiptop|iris|kindle|lge\s|maemo 1; | |
~*midp|mmp|netfront|palm(\sos)?|p(ixi|re)\/|plucker|pocket|psp|series(4|6)0 1; | |
~*treo|vodafone|wap|xda|xiino 1; | |
~*^(1207|6310|6590|3gso|4thp|50[1-6]i|770s|802s|a\swa|abac|ac(er|oo|s\-)) 1; |
OlderNewer