Skip to content

Instantly share code, notes, and snippets.

View wnstn's full-sized avatar

Winston Hearn wnstn

View GitHub Profile
@wnstn
wnstn / router.php
Created April 16, 2013 14:27
Wordpress router.php, for using the built in PHP server with WP sites.
<?php
$root = $_SERVER['DOCUMENT_ROOT'];
chdir($root);
$path = '/'.ltrim(parse_url($_SERVER['REQUEST_URI'])['path'],'/');
if(file_exists($root.$path))
{
if(is_dir($root.$path) && substr($path,strlen($path) - 1, 1) !== '/')
{
header('location: '.rtrim($path,'/').'/');
@wnstn
wnstn / ad-preview-test.html
Last active April 22, 2020 22:51 — forked from techsassy/ad-preview-test.html
Let's render ads
<html>
<head>
</head>
<body>
<script type="text/javascript">
window.hymnalAdConfig = {
id: 'f609c3cf-0a54-4d7f-a4ba-e8f3a7b96572',
slug: '_test_client_cannes_demo_storybook_f609c3cf-0a54-4d7f-a4ba-e8f3a7b96572',
adName: "Cannes Demo Storybook",
type: 'Athena Template',
@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,
const uploadInput = document.querySelector('input[type="file"]');
const awsFormData = JSON.parse(uploadEl.getAttribute('data-form-data'));
const formData = new FormData();
Object.keys(awsFormData).forEach((key)=>{
formData.append(key, awsFormData[key]);
});
uploadInput.addEventListener('change', function(ev){
ev.preventDefault();
@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 */
const uploadInput = document.querySelector('input[type="file"]');
const awsFormData = JSON.parse(uploadEl.getAttribute('data-form-data'));
const formData = new FormData();
Object.keys(awsFormData).forEach((key)=>{
formData.append(key, awsFormData[key]);
});
uploadInput.addEventListener('change', function(ev){
ev.preventDefault();
@s3_direct_post = ::S3.bucket
.presigned_post(key: thumbnail_upload_path,
success_action_status: '201',
content_type_starts_with: 'image/',
acl: 'public-read')
@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(){
  • 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 / test.css
Created August 1, 2012 19:09
SCSS Loops
#foo {
-webkit-animation: foo 2s 3s normal;
-moz-animation: foo 2s 3s normal;
-ms-animation: foo 2s 3s normal;
-o-animation: foo 2s 3s normal;
animation: foo 2s 3s normal; }