Skip to content

Instantly share code, notes, and snippets.

/*!
* IpcManager.js
*
* Responsible for communicating between node processes
*/
var IpcManager = {
HandleMessageOnWorker: function(message){
if(message != null && message.type != null){
@jmcguirk
jmcguirk / Main.go
Last active August 29, 2015 14:15
Golang Gplay IAB Receipt Verify
package main
import (
"crypto"
"crypto/rsa"
"crypto/sha1"
"crypto/x509"
"encoding/base64"
"fmt"
)
@jmcguirk
jmcguirk / main.go
Created February 13, 2015 16:45
Golang Gplay IAB Receipt Verify
package main
import (
"crypto"
"crypto/rsa"
"crypto/sha1"
"crypto/x509"
"encoding/base64"
"fmt"
)
@jmcguirk
jmcguirk / example.sql
Created December 16, 2014 23:08
7D ARPU by country/device
SELECT install.os,
install.country,
Count(DISTINCT install.device_tag) AS installs,
Count(DISTINCT economy.device_tag) AS spenders,
Sum(economy.spend_amount) AS total_spent
FROM install
LEFT OUTER JOIN economy
ON ( install.device_tag = economy.device_tag
AND economy.spend_type = 'cash_purchase'
AND Datediff('day', economy.ingest_datetime,
@jmcguirk
jmcguirk / gist:16368c90142c483ecd93
Created December 16, 2014 19:38
Funnel Example
SELECT To_char(install.ingest_datetime, 'YYYY-MM-DD') AS install_date,
install.os,
install.country,
Count(DISTINCT install.device_tag) AS installs,
Count(DISTINCT( CASE
WHEN event.kingdom = 'FTUE.Comic.Start' THEN
event.device_tag
ELSE ''
end )) - 1 AS "FTUE.Comic.Start",
Count(DISTINCT( CASE
@jmcguirk
jmcguirk / funnel.sql
Created November 24, 2014 20:34
Funnel ex
SELECT To_char(Date_trunc('day',cohort.local_datetime), 'MM-DD-YYYY') AS date,
cohort.os,
Count(DISTINCT cohort.device_tag) AS installs,
100*Cast(Count(DISTINCT step1.device_tag) AS FLOAT)/Cast(Count(DISTINCT cohort.device_tag) AS FLOAT) AS "FTUE.Comic.Start",
100*Cast(Count(DISTINCT step2.device_tag) AS FLOAT)/Cast(Count(DISTINCT cohort.device_tag) AS FLOAT) AS "FTUE.Comic.End",
100*Cast(Count(DISTINCT step3.device_tag) AS FLOAT)/Cast(Count(DISTINCT cohort.device_tag) AS FLOAT) AS "FTUE.Commander.LoadComplete",
100*Cast(Count(DISTINCT step4.device_tag) AS FLOAT)/Cast(Count(DISTINCT cohort.device_tag) AS FLOAT) AS "FTUE.Commander.Tapped",
100*Cast(Count(DISTINCT step5.device_tag) AS FLOAT)/Cast(Count(DISTINCT cohort.device_tag) AS FLOAT) AS "FTUE.Commander.Confirmed"
FROM (
SELECT install.device_tag,
@jmcguirk
jmcguirk / funnel.sql
Created November 24, 2014 20:28
Funnel ex
SELECT allsteps.device_tag,
allsteps.os,
Max(CASE
WHEN allsteps.kingdom = 'FTUE.Comic.Start' THEN 1
ELSE 0
end) AS "step1",
Max(CASE
WHEN allsteps.kingdom = 'FTUE.Comic.END' THEN 1
ELSE 0
end) AS "step2"
@jmcguirk
jmcguirk / app.sh
Created November 3, 2014 19:08
GO init.d wrapper
#!/bin/sh
. /etc/rc.d/init.d/functions
USER="root"
DAEMON="/etc/rpcs/Main"
SCRIPT="$(basename $0)"
PIDFILE="/var/run/$SCRIPT.pid"
@jmcguirk
jmcguirk / main.js
Created October 21, 2014 16:57
Node Webapp Server
require('./classes/gamelog.js')
require('./classes/proto.js');
require('./classes/service-locator.js');
fs = require('fs');
var context = require("./classes/context.js");
var cluster = require('cluster');
var os = require("os");
var hostname = os.hostname();
//console.log("hostname is " + hostname!);
var IS_MASTER_SHUTTING_DOWN = false;
var vertices = [];
var edges = [];
vertices.push("A");
vertices.push("B");
vertices.push("C");
vertices.push("D");
vertices.push("E");
edges.push(["A", "B"]);