Skip to content

Instantly share code, notes, and snippets.

View wnstn's full-sized avatar

Winston Hearn wnstn

View GitHub Profile
@wnstn
wnstn / shipping.js
Created October 2, 2013 23:07
FoxyCart flat rate shipping based on product count
<script type="text/javascript" charset="utf-8">
FC.checkout.config.customShipping = {
onLoad: true, // Set to false if you don't want shipping calculated when the checkout loads
onLocationChange: true // Set to true if your shipping logic relies on updating whenever the shipping location for the order changes
};
function calculateShipping() {
var shippingCost = 0;
/* BEGIN CUSTOM SHIPPING LOGIC */
@wnstn
wnstn / newTest.js
Last active August 29, 2015 14:16
LocalStorage Testing
// OLD
function canUseLocalStorage() {
return typeof localStorage === 'object' && localStorage.setItem;
};
// NEW
function canUseLocalStorage() {
var ls = "vox";
@wnstn
wnstn / transitionqueue.js
Created June 30, 2015 18:29
queue transitions for synchronous firing
// http://davidwalsh.name/vendor-prefix
var prefix = (function () {
var styles = window.getComputedStyle(document.documentElement, ''),
pre = (Array.prototype.slice
.call(styles)
.join('')
.match(/-(moz|webkit|ms)-/) || (styles.OLink === '' && ['', 'o'])
)[1],
dom = ('WebKit|Moz|MS|O').match(new RegExp('(' + pre + ')', 'i'))[1];
return {
@wnstn
wnstn / day-1.js
Last active December 3, 2015 22:12
Advent Answers
function stepThrough() {
var instructions = document.getElementsByTagName('pre')[0].textContent;
var regexp = /[()]/g;
var split = instructions.match(regexp);
var floor = 1;
var i = 0;
do {
floor = split[i] === "(" ? floor + 1 : floor - 1;
i++;
} while (floor > 0)
@wnstn
wnstn / SassMeister-input.scss
Created December 8, 2015 16:41
Generated by SassMeister.com.
// ----
// libsass (v3.2.5)
// ----
$reveal: nil;
@media only screen and (min-width: 1025px) {
// tests whether or not a reveal is true, if so it changes bg attachment to fixed
@mixin testReveal($r: null) {
@wnstn
wnstn / gulpfile.js
Created January 22, 2016 14:26
Rails, Gulp, and Browsersync together at last
var gulp = require('gulp');
var browserSync = require('browser-sync').create();
var setupWatchers = function() {
gulp.watch(['./app/views/**/*.erb',
'./app/assets/javascripts/**/*.js'], ['reload']);
gulp.watch(['./app/assets/stylesheets/**/*.scss'], ['reloadCSS'])
};
gulp.task('reload', function(){

Keybase proof

I hereby claim:

  • I am wnstn on github.
  • I am wnstn (https://keybase.io/wnstn) on keybase.
  • I have a public key whose fingerprint is 305A 7753 6A93 3113 79BB 11F5 C00B 7B7E 64EB 49D9

To claim this, I am signing this object:

<div id="google_ads_iframe_/172968584/verge/front_page_3__container__" style="border: 0pt none;"><iframe id="google_ads_iframe_/172968584/verge/front_page_3" title="3rd party ad content" name="google_ads_iframe_/172968584/verge/front_page_3" width="300" height="250" scrolling="no" marginwidth="0" marginheight="0" frameborder="0" src="javascript:&quot;<html><body style='background:transparent'></body></html>&quot;" style="border: 0px; vertical-align: bottom;"></iframe></div>
<html><head>
<script type="text/javascript" async="" src="//assets.tapad.com/idsync-1.1.2.js"></script><script>var inDapIF=true;</script>
<script src="https://s0.2mdn.net/879366/express_html_inpage_rendering_lib_200_118.js" type="text/javascript" crossorigin="anonymous"></script><script src="//pixel.tapad.com/idsync/multi/urls?protocol=http&amp;callback=__tapad_partners"></script><script type="text/javascript" charset="UTF-8" src="//pagead2.googlesyndication.com/pagead/js/lidar.js"></script></head><body marginwidth="0" marginheight="0"><s
  • A metric starts its journey being added on the frontend, in Hymnal, as an impression tracker (in the tracker sidepanel). You can add as many trackers as you want per ad.
  • Separately, a clickthrough url is added, and notably, there is only one of these per ad.
    • In the refactor, we'll need to update how clickthrough urls are handled, since currently they're handled by metrics_instrumentation, but we'll be refactoring HymnalAd to be the one responsible for keeping track of an ad's clickthrough url.
    • We'll also need to update the rake task I wrote to migrate the current clickthrough_urls over to HymnalAds, from MetricsInstrumentation
  • From there, the tracker form is submitted, and for every tracker that was added, a new tracker object is created/saved in the db (after a check to make sure the url entered is a valid url)
@wnstn
wnstn / fb-ad-disapprovals.js
Created December 12, 2017 15:49
Facebook's Ad Banning Categories
__d("CROWAdDisapprovalReasonEnum", [], (function a(b, c, d, e, f, g) {
f.exports = {
UNKNOWN: 0,
IRREGULAR_APP_INSTALL: 1,
TEXT_OVERLAY: 2,
ADULT_CONTENT: 3,
ADULT_HEALTH: 4,
ALCOHOL: 5,
ANIMATED_IMAGE: 6,
BEFORE_AND_AFTER: 7,