Skip to content

Instantly share code, notes, and snippets.

@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.
@kjlubick
kjlubick / ArrayListString.java
Created April 9, 2015 23:43
String ArrayList. Targeted at AP Computer Science Students. Used with https://www.youtube.com/watch?v=JcTA3grnERo
public class ArrayListString{
private String[] arr;
private int capacity;
private int size;
public ArrayListString() {
arr = new String[10];
capacity = 10;
size = 0;
// The Grid component allows an element to be located
// on a grid of tiles
Crafty.c('Grid', {
init: function() {
this.attr({
w: Game.map_grid.tile.width,
h: Game.map_grid.tile.height
});
},
@kjlubick
kjlubick / track.js
Created April 1, 2015 17:33
Track Reddit's "the button" http://www.reddit.com/r/thebutton
var saveAs=saveAs||"undefined"!=typeof navigator&&navigator.msSaveOrOpenBlob&&navigator.msSaveOrOpenBlob.bind(navigator)||function(e){"use strict";if("undefined"==typeof navigator||!/MSIE [1-9]\./.test(navigator.userAgent)){var t=e.document,n=function(){return e.URL||e.webkitURL||e},o=t.createElementNS("http://www.w3.org/1999/xhtml","a"),r="download"in o,i=function(n){var o=t.createEvent("MouseEvents");o.initMouseEvent("click",!0,!1,e,0,0,0,0,0,!1,!1,!1,!1,0,null),n.dispatchEvent(o)},a=e.webkitRequestFileSystem,c=e.requestFileSystem||a||e.mozRequestFileSystem,s=function(t){(e.setImmediate||e.setTimeout)(function(){throw t},0)},u="application/octet-stream",f=0,d=500,l=function(t){var o=function(){"string"==typeof t?n().revokeObjectURL(t):t.remove()};e.chrome?o():setTimeout(o,d)},v=function(e,t,n){t=[].concat(t);for(var o=t.length;o--;){var r=e["on"+t[o]];if("function"==typeof r)try{r.call(e,n||e)}catch(i){s(i)}}},p=function(t,s){var d,p,w,y=this,m=t.type,S=!1,h=function(){v(y,"writestart progress write writeen
@kjlubick
kjlubick / random.java
Created March 27, 2015 13:27
Fun with randoms. Uses random seeds to print out Hello, World. Found by guess and check.
import java.util.Random;
public class FunWithRandoms {
public static void main(String[] args)
{
Random helloWorld = new Random(95945573131518);
for(int i =0 ;i< 6;i++) { //Hello,
System.out.print((char)testRandom.nextInt(maxChar));
}
@kjlubick
kjlubick / j.java
Created February 9, 2015 17:16
Platform independent way to detect if an xls file has a macro using apache poi
//see http://www.rgagnon.com/javadetails/java-detect-if-xls-excel-file-contains-a-macro.html
public void processPOIFSReaderEvent(POIFSReaderEvent event) {
POIFSDocumentPath path = event.getPath();
if (path.length() == 0) {
return;
}
String firstFolder = path.getComponent(0);
if(firstFolder.startsWith("Macro") || firstFolder.startsWith("_VBA")) {
macroDetected = true;
}
@kjlubick
kjlubick / stop_nginx.py
Created January 22, 2015 15:50
Ansible Runner to stop nginx
import ansible.runner
from ansible.inventory import Inventory
runner = ansible.runner.Runner(
module_name='shell',
module_args='nginx -s stop',
pattern='*',
sudo=True,
forks=10,
@kjlubick
kjlubick / LICENSE
Last active May 1, 2022 22:26
Exports a THREE.js scene mesh to STL, making it suitable for 3d printing
The MIT License
Copyright © 2010-2016 three.js authors
Permission is hereby granted, free of charge, to any person obtaining a copy
of this software and associated documentation files (the "Software"), to deal
in the Software without restriction, including without limitation the rights
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
copies of the Software, and to permit persons to whom the Software is
furnished to do so, subject to the following conditions:
@kjlubick
kjlubick / visitor.java
Last active August 29, 2015 14:07
Alternate version of Literal String Comparison quickfix, with types. See http://kjlubick.github.io/#/blog/post/3?building-your-first-eclipse-quick-fix
//make sure resolveBindings() returns true in the Resolution class
@Override
@SuppressWarnings("unchecked")
public boolean visit(MethodInvocation node) {
if (this.lscMethodInvocation != null) {
return false;
}
// for checking the type of the receiver. Although it is tempting to try
// node.resolveTypeBinding(), that refers to the return value.
@kjlubick
kjlubick / activepresenterStart.au3
Last active August 29, 2015 14:06
Automatically running ActivePresenter 4.0.1 to record screencasts (record desktop activities) at 5 fps with no control panel/hotkeys
Local $id = InputBox("Participant ID", "Enter userid (e.g. P123)")
If $id <> "" Then
Run("C:\Program Files (x86)\ATOMI\ActivePresenter\ActivePresenter.exe")
WinWaitActive("ActivePresenter")
Send("^n")
Send($id)