Skip to content

Instantly share code, notes, and snippets.

View zaneclaes's full-sized avatar

Zane Claes zaneclaes

View GitHub Profile
@zaneclaes
zaneclaes / Analytics.swift
Created February 23, 2016 17:19
A basic Swift analytics class
//
// Analytics.swift
// ForeverMaze
//
// Created by Zane Claes on 2/7/16.
// Copyright © 2016 inZania LLC. All rights reserved.
//
import Foundation
@zaneclaes
zaneclaes / DynamicObject.swift
Last active February 22, 2016 20:49
Automatically detect changes to an object in Swift
//
// GameStatic.swift
// ForeverMaze
//
// Created by Zane Claes on 11/20/15.
// Copyright © 2015 inZania LLC. All rights reserved.
//
import SpriteKit
import Firebase
@zaneclaes
zaneclaes / coordinate.swift
Last active November 18, 2016 13:20
Coordinate System in Swift
//
// Coordinate.swift
// ForeverMaze
//
// Created by Zane Claes on 1/18/16.
// Copyright © 2016 inZania LLC. All rights reserved.
//
import Foundation
import SpriteKit
(function(i,s,o,g,r,a,m){i['GoogleAnalyticsObject']=r;i[r]=i[r]||function(){
(i[r].q=i[r].q||[]).push(arguments)},i[r].l=1*new Date();a=s.createElement(o),
m=s.getElementsByTagName(o)[0];a.async=1;a.src=g;m.parentNode.insertBefore(a,m)
})(window,document,'script','//www.google-analytics.com/analytics.js','ga');
function getCookie(cname) {
var name = cname + "=";
var ca = document.cookie.split(';');
for(var i=0; i<ca.length; i++) {
var c = ca[i];
<?php
// SET UP THESE VARIABLES;
$GOOGLE_ANALYTICS_ID = '';
$IOS_STORE_URL = '';
$PATH_TO_GOOGLE_ANALYTICS_FILE = '';// This is where the Google Analytics Helper Script is located
function loadGAN($id = null) {
global $gan, $PATH_TO_GOOGLE_ANALYTICS_FILE;
if($gan) {
return $gan;
<?php
class GAN {
function __construct($id) {
$this->id = $id;
}
protected function gaParseCookie() {
if (isset($_COOKIE['_ga'])) {
list($version,$domainDepth, $cid1, $cid2) = preg_split('[\.]', $_COOKIE["_ga"],4);
$contents = array('version' => $version, 'domainDepth' => $domainDepth, 'cid' => $cid1.'.'.$cid2);
<?php
if(!isset($_POST['device']) || !isset($_POST['os_version'])) {
die('missing params');
}
$params = $_POST;
$params['ip'] = sha1($_SERVER['REMOTE_ADDR']);
// Now we'd query the database for a Referral object match on device, os_version, and ip
// We could also restrict our query to recently created Referral objects and/or objects
if(!isset($_POST['device']) || !isset($_POST['os_version'])) {
die('missing params');
}
$params = $_POST;
$params['ip'] = $_SERVER['REMOTE_ADDR'];
// Now we'd query the database for a Referral object match on device, os_version, and ip
// We could also restrict our query to recently created Referral objects and/or objects
// which have not been "Claimed."
static NSString * const kKeyHasAttributedReferral = @"hasAttributedReferral";
- (void)attributeReferral {
if([[NSUserDefaults standardUserDefaults] boolForKey:kKeyHasAttributedReferral]) {
return;
}
// Attribute referrals
NSMutableDictionary *params = [NSMutableDictionary dictionary];
params[@"device"] = [[UIDevice currentDevice].model componentsSeparatedByString:@" "].firstObject;
//
// Detect's the user's mobile client
// If it is a matched client, creates a referral item in parse and returns a redirect URL for the AppStore
//
function createReferral($params = array()) {
require_once '../cms/Mobile_Detect.php';
$detect = new Mobile_Detect;
$ios_url = 'https://itunes.apple.com/us/app/aftermath-pvp-guilds-strategy/id702615597?ls=1&mt=8';
$clients = array('iPhone'=>$ios_url,