Skip to content

Instantly share code, notes, and snippets.

<?php
/**
* Return the coefficient of two items based on Jaccard index
* http://en.wikipedia.org/wiki/Jaccard_index
*
* Example:
*
* $tags1 = "code, php, jaccard, test, items";
* $tags2 = "test, code";
@involer
involer / Background Cover in CSS (for IE)
Created January 21, 2013 21:57
Make background-size: cover; work in IE.
<div style="filter: progid:DXImageTransform.Microsoft.AlphaImageLoader(src='image.png', sizingMethod='scale'); -ms-filter: \"progid:DXImageTransform.Microsoft.AlphaImageLoader(src='image.png', sizingMethod='scale')\";"></div>
class Calq {
public static function trackSignup($action) {
self::trackLogin($action);
}
public static function trackLogin($action) {
try {
self::updateUserIdentity();
self::setupUserProfile();
@involer
involer / example.rb
Created January 19, 2015 14:15
Paddle Webhook Validation (Ruby)
#test data
data = {
'customer_email' => "test-user@blackhole.io",
'customer_name' => "Test User",
'p_country' => "US",
'p_coupon' => "",
'p_coupon_savings' => 0,
'p_currency' => "",
'p_earnings' => "[]",
'p_order_id' => 261205,
@involer
involer / gist:d4a1d820823596a6cb39
Created February 13, 2015 20:07
Paddle Analytics - Track Custom Events

Tracking Custom Events

As well as the default events tracked by Paddle Analytics you can also track any number of custom events throughout your app. Simply use the track method:

+ (void)track:(NSString *)action properties:(NSDictionary *)properties;

This methods accepts an identifier for the action along with a dictionary of properties associated with the action. Take a look at the following example where we're tacking how many PDF Documents are exported from our example app:

@involer
involer / gist:bd02cfdba89f8fd15429
Created April 17, 2015 16:37
Listening to Paddle Checkout Events
var event_method = window.addEventListener ? "addEventListener" : "attachEvent";
var my_eventer = window[event_method];
var message_event = event_method == "attachEvent" ? "onmessage" : "message";
// Listen to message from child window
my_eventer(message_event, function(event) {
if(event.data.action == 'complete') {
console.log('Checkout Complete');
} else if(event.data.action == 'close') {
console.log('Checkout Closed');
@involer
involer / River
Created April 3, 2016 11:51
Webhook Validation
// ksort() and serialize the fields
ksort($fields);
foreach($fields as $k => $v) {
if(!in_array(gettype($v), array('object', 'array'))) {
$fields[$k] = "$v";
}
}
$data = serialize($fields);