Skip to content

Instantly share code, notes, and snippets.

View NikolasTzimoulis's full-sized avatar

Nikolas NikolasTzimoulis

View GitHub Profile
@NikolasTzimoulis
NikolasTzimoulis / findDifferentModels.py
Created April 10, 2018 22:14
Compares two files and finds the models they don't have in common.
filenames = ("TILS2(4).model", "TILS2(4').model")
index = [set(), set()]
for i in (0,1):
filename = filenames[i]
model = ""
for line in open(filename):
if line.startswith('interpretation'):
index[i].add(model)
model = ""
@NikolasTzimoulis
NikolasTzimoulis / witness_lz4d.py
Last active March 2, 2024 07:01 — forked from mfgmfg/witness_lz4d.py
Extract .SOUND files from the videogame The Witness
import struct
import sys
import os
MAX_OUTPUT_SIZE = 1 << 24 # 16 megabytes
def load_binary_file(fn, nbytes=100000000):
data = []
with open(fn, "rb") as src:
byte = src.read(1)
@NikolasTzimoulis
NikolasTzimoulis / teammateCheck.py
Last active January 17, 2017 17:46
Background check your dota teammates and enemies to see if the trench is real.
import requests, json, time, pickle, re, os
myAccount = 68186278 #REPLACE THIS WITH YOUR STEAM ID
matchCountMe = 0 # how many of my latest matches to look for players in (set to 0 to fetch current live match)
matchCountOthers = 10 # how many matches from each other player to look at
matchExtra = 5 # buffer of extra matches to fetch for other players in case some need to be thrown out
steamKeyFileName = 'steamwebapikey.txt'
serverLogFile = 'C:\Program Files (x86)\Steam\steamapps\common\dota 2 beta\game\dota\server_log.txt'
logFileName = 'teammates.txt'
#!/usr/bin/python
import json
import urllib
import urlparse
import time
import os
searchTerm = "software engineer"
websites = ["indeed.com", "monster.com"]
@NikolasTzimoulis
NikolasTzimoulis / GetMatchHistoryBySequenceNum.py
Created January 16, 2015 15:05
Dota API, Get match history by sequence number
import requests, json, pickle, time, datetime, sqlite3 as lite, sys
steamKeyFileName = 'steamwebapikey.txt'
matchesFileName = 'matches.pkl'
# get steam api key
try:
steamKeyFile = open(steamKeyFileName, 'rb')
steamKey = pickle.load(steamKeyFile)
steamKeyFile.close()
@NikolasTzimoulis
NikolasTzimoulis / googlePlusOnes.py
Last active December 17, 2015 11:49
A scrapper / parser that downloads the list of plus ones (+1's) from a user's public google+ profile. The output is an html file with each link in a separate paragraph.
import urllib2
profileId = "103814799814962680687"
fileName = "C:\\Users\\Nikolas\\Dropbox\\public\\plusones.html"
response = urllib2.urlopen('https://plus.google.com/_/plusone/get?oid='+profileId)
text = response.read().decode("utf-8")
textLines = text.split('\n')
linkList = []
for line in textLines:
@NikolasTzimoulis
NikolasTzimoulis / centipede.py
Last active December 13, 2015 19:48
Probabilistic forward-backward induction for solving centipede-style games.
leavePayoffs = ( (0, 0), (-1, 3), (2, 2), (1, 5), (4, 4), (3, 7), (6, 6), (5, 9), (8, 8), (7, 11), (10, 10) )
#leavePayoffs = ( (0, 0), (-1, 1), (2, -2), (-3, 3), (4, -4), (-5, 5), (6, -6), (-7, 7), (8, -8), (-9, 9), (10, -10) )
backgroundPriors = [(0.99999, 1.0)]
lambdas = [(sum([lam[0] for lam in backgroundPriors])/len(backgroundPriors) , sum([lam[1] for lam in backgroundPriors])/len(backgroundPriors))]*len(leavePayoffs)
expectedPayoffs = [(0.0, 0.0)]*len(leavePayoffs) # initial values are overwritten, don't fret over them
lambdasGivenStay = [(0.0, 1.0)]*(len(leavePayoffs)-1) # initial values are overwritten, don't fret over them
getPlayer = lambda node: node%2 # returns 0 for player 1's decision nodes and 1 for player 2's nodes
other = lambda player: (player+1)%2 # returns the other player
lambdaThreshold = lambda a1, a2, b1, b2: (float(a2) - b2) / (-a1 + a2 + b1 - b2)
maxRounds = 10
@NikolasTzimoulis
NikolasTzimoulis / deckgame.py
Created May 31, 2012 20:55
Finds the best strategy for a simplistic decentralised POMDP game
from random import shuffle
from itertools import chain, combinations
def powerset(iterable):
"powerset([1,2,3]) --> () (1,) (2,) (3,) (1,2) (1,3) (2,3) (1,2,3)"
s = list(iterable)
return chain.from_iterable(combinations(s, r) for r in range(len(s)+1))
players = 15
@NikolasTzimoulis
NikolasTzimoulis / GetExtensions.java
Created May 31, 2012 20:48
A simple programme that finds all the file extensions of the files in a directory and recursively in its subdirectories
package main;
import java.io.File;
import java.util.LinkedList;
import java.util.Scanner;
public class GetExtensions
{
private static int fileCounter;
@NikolasTzimoulis
NikolasTzimoulis / MachineLibrary.java
Created May 31, 2012 20:44
A simple implementation of a Turing Machine in Java (which I wrote the night before a Theory of Computation exam instead of studying)
package tm;
public final class MachinesLibrary
{
private MachinesLibrary() {}
public static TuringMachine EqualBinaryWords()
{
TuringMachine newTM = new TuringMachine();
newTM.addState("q1");