Skip to content

Instantly share code, notes, and snippets.

@fbparis
fbparis / kik.py
Last active June 2, 2020 00:18
A replacement for the indexed trie data-structure with a very low memory footprint!
"""
kik (key to index to key) is a new implentation of indexed trie (https://gist.github.com/fbparis/e114958a4a9be84146a1a579cf677e8d) reducing memory footprint by a factor 7 or more!
The main differences with indexed tries are:
* Trie nodes are no longer stored in Node objects but in a python list. An internal mechanism use the list to simulate a tree behaviour, without any recursive function.
* Nodes and values stored in the kik can be compressed with several compression levels:
* None: no compression at all
* 0: data are stored as pickle.dumps (memory use divided by 3-4)
* -1, 1 to 9: pickle.dumps are compressed with zlib
* Some internal methods can be cached with a custom implentation of a LRU cache.
@jeffposnick
jeffposnick / offline-analytics.js
Created April 22, 2016 14:57
Standalone offline analytics code
/*
Copyright 2016 Google Inc. All Rights Reserved.
Licensed under the Apache License, Version 2.0 (the "License");
you may not use this file except in compliance with the License.
You may obtain a copy of the License at
http://www.apache.org/licenses/LICENSE-2.0
Unless required by applicable law or agreed to in writing, software
distributed under the License is distributed on an "AS IS" BASIS,
WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
See the License for the specific language governing permissions and
@kjlubick
kjlubick / ISMCTS.py
Created September 21, 2015 01:18
An example of Information Set Monte Carlo Tree Search from http://www.aifactory.co.uk/newsletter/2013_01_reduce_burden.htm
# This is a very simple Python 2.7 implementation of the Information Set Monte Carlo Tree Search algorithm.
# The function ISMCTS(rootstate, itermax, verbose = False) is towards the bottom of the code.
# It aims to have the clearest and simplest possible code, and for the sake of clarity, the code
# is orders of magnitude less efficient than it could be made, particularly by using a
# state.GetRandomMove() or state.DoRandomRollout() function.
#
# An example GameState classes for Knockout Whist is included to give some idea of how you
# can write your own GameState to use ISMCTS in your hidden information game.
#
# Written by Peter Cowling, Edward Powley, Daniel Whitehouse (University of York, UK) September 2012 - August 2013.
@tmahesh
tmahesh / measurePageloadTimes.js
Created February 18, 2011 00:56
How fast is my site? integrate boomerang and google analytics
<script type="text/javascript">
BOOMR.init({
beacon_url: "/boomerang.gif",
BW: {
enabled: false
}
});
BOOMR.subscribe('before_beacon', trackInAnalytics);
var pageType = "homepage"; // customize this