Skip to content

Instantly share code, notes, and snippets.

View hkb's full-sized avatar

Hans-Kristian Bjerregaard hkb

View GitHub Profile
@hkb
hkb / lalala
Created September 9, 2015 15:59
lalalala
@hkb
hkb / tsd.html
Last active December 20, 2015 17:28 — forked from fadur/tsd.html
Closed tag
<script type="text/javascript" charset="utf-8">
TheSocialDigits.config({
key: "1234567890",
templateFormatters: {my_link: function(absolute_url) {
return "href='"+absolute_url+"'"
}
},
});
</script>
@hkb
hkb / README.md
Last active October 13, 2015 22:48

Simple click tracking jQuery plugin

This is a simple plugin for tracking relations betweens product clicks and sales. It has configarable backends to handle recommendations. The two current backends logs recommendations as Google Analytics events and reports to The Social Digits.

Configuration

In the jquery.splittest.js file there is a global configuration object with the following entries:

@hkb
hkb / jQuery.log_click.js
Created March 22, 2012 11:53 — forked from fadur/jQuery.log_click.js
a plugin that binds a click event
(function() {
items = {
_call: function(id, href) {
API_KEY = ''; // <-- api key here
url = 'http://api.thesocialdigits.com/v1/__log_click?callback=?';
payload = {'key': API_KEY, 'product': id, 'metadata': {'api': 'search', 'args': {}}};
var t = setTimeout('window.location.href = "' + href + '";', 500);
$.getJSON(url, {'payload': JSON.stringify(payload)}, function(data) {
if (data.status === 'error') {
@hkb
hkb / log_click.js
Created March 21, 2012 17:30 — forked from fadur/log_click.js
atach event to list
function bind_click_logging() {
$('.product_items > a').click(function() {
// fetch link destination
var href = $(this).attr('href');
// extract product id
var _href = href.split('/');
var id = parseInt(_href[_href.length-2]);
// set timeout
@hkb
hkb / decorator_skeleton.py
Created January 2, 2012 16:11
Basic skeleton for python decorators.
# A base skeleton to simplify decorator implementations.
#
# All decorator classes needs only to extend this class by implementing the
# _init() and _call() methods and do not have to worry about the inconsistency
# of python decorators.
#
# _init: The method is called once when the decorator is created. The decorator
# arguments, if any, will be passed on to this method.
# _call: Implements the function call, all arguments to the function will be
# passed on to this method.
@hkb
hkb / ChainTreeScene.java
Created March 31, 2011 11:35
A wrapper for the J3DScene for working with entire ChainTrees.
package tool;
import j3dScene.J3DScene;
import java.awt.Color;
import java.util.Collection;
import java.util.HashMap;
import java.util.List;
import java.util.Map;