Skip to content

Instantly share code, notes, and snippets.

@charliefmoran
charliefmoran / percent_75.js
Last active December 22, 2015 23:26
Optimizely event for 75% completion of video in PDK player
$(window).load(function() {
var isAd = false;
$pdk.controller.addEventListener("OnMediaStart", function(event) {
if(event.data.baseClip.isAd === true) {
isAd=true;
} else {
isAd = false;
window['optimizely'] = window['optimizely'] || [];
window.optimizely.push(["trackEvent", "video_start"]);
}
@charliefmoran
charliefmoran / _semi_transparent_background.scss
Created June 23, 2014 05:01
SCSS Mixin for Cross-Browser Semi-Transparent Background
@mixin semi-transparent-background($color, $opacity) {
$red: red($color);
$green: green($color);
$blue: blue($color);
$hex_color: rgb($red,$green,$blue);
$hex_color_with_alpha: rgba($color,$opacity);
$ie_hex_color: ie-hex-str($hex_color_with_alpha);
background: $hex_color;
background: $hex_color_with_alpha;
-ms-filter: progid:DXImageTransform.Microsoft.gradient(startColorstr=#{$ie_hex_color}, endColorstr=#{$ie_hex_color});
@charliefmoran
charliefmoran / reload.js
Created June 17, 2014 17:43
Track when a page reloads in Chrome console
window.addEventListener("beforeunload", function() { var currentdate = new Date(); console.log("refreshing at " + currentdate);}, false);
@charliefmoran
charliefmoran / scroll.js
Created June 13, 2014 16:36
Custom Optimizely event when scrolling to bottom of any DOM object
$(document).ready(function(){
(function($){
var timeoutID;
var scrolledToTarget = false;
var $target = $(".your-object");
var target_bottom = $target.offset().top - $target.outerHeight();
function stopCheck() {
timeoutID = null;
@charliefmoran
charliefmoran / sass_compile.php
Last active August 29, 2015 14:02
Run SASS from a PHP script in shared hosting environment
<?php
// run this gist to compile your SASS files in a shared hosting environment (I'm on Dreamhost)
// you must have SASS installed and running fine from the command line already http://sass-lang.com/
// this file will echo your success/failure, and if there's an error create a file detailing what it is
$descriptorspec = array(
0 => array("pipe", "r"), // stdin is a pipe that the child will read from
1 => array("pipe", "w"), // stdout is a pipe that the child will write to
2 => array("file", "./error-output.txt", "a") // stderr is a file to write to
);
@charliefmoran
charliefmoran / gist:a8250aa231298535a962
Created May 20, 2014 20:33
Optimizely scroll start custom event
$(document).ready(function(){
(function($, document){
$(document).scroll(function() {
window['optimizely'] = window['optimizely'] || [];
window.optimizely.push(["trackEvent", "scroll_start"]);
$(this).off("scroll");
});
})(window.$, document);
@charliefmoran
charliefmoran / gist:e510b4c0dac292be1bce
Created May 19, 2014 22:20
Fire Custom Optimizley Event at 25% Scroll Depth
$(document).ready(function(){
(function($){
var timeoutID;
var scrolledTo25Pct = false;
function stopCheck() {
timeoutID = null;
}