Skip to content

Instantly share code, notes, and snippets.

is_landscape : ->
really_landscape = =>
w = $(window)
w.width() >= w.height()
if @options.state.device.desktop
really_landscape()
else if window.orientation?
Math.abs(window.orientation) is 90
else if window.matchMedia?
is_event_supported : (event) ->
eventName = "on#{event}"
element = document.createElement('div')
supported_in_ff = ->
element.setAttribute eventName, 'return;'
typeof element[eventName] is 'function'
supported = eventName in element || supported_in_ff()
element = null
-- Change all http:// references to https://
UPDATE wp_posts SET post_content=REPLACE(post_content, 'http://', 'https://');
-- Change site's url and homepage
UPDATE wp_options SET option_value=REPLACE(option_value, 'http://', 'https://') WHERE option_name IN ('siteurl', 'home');
CREATE VIEW emails AS (
SELECT email FROM users
UNION
SELECT other_email AS email FROM more_users
UNION
select other_other_email AS email FROM even_more_users
);
SELECT 1 FROM emails WHERE email = 'email@email.com';
@yoavmatchulsky
yoavmatchulsky / gist:7a04a6008ca06a65e9de
Created October 8, 2015 11:00
Mobile detection configuration for nginx
# /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;
@yoavmatchulsky
yoavmatchulsky / gist:cdd94aaae24040d0c38f
Created October 8, 2015 11:00
Mobile detection configuration for nginx.
# /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;
RewriteCond %{QUERY_STRING} ^lang=(\w{2})/(.*)$
RewriteRule .* http://%1.example.com/%2 [L,R=301]
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
@yoavmatchulsky
yoavmatchulsky / application.rb
Created June 15, 2015 08:56
Rails with Angular's application.rb
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
@yoavmatchulsky
yoavmatchulsky / mobile-experiment.html
Last active August 29, 2015 14:08
Only show GA content experiment to mobile traffic
<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());
},