Skip to content

Instantly share code, notes, and snippets.

@Hornwitser
Hornwitser / exchange_string_decoder.js
Last active May 18, 2021 02:06
Factorio Map Exchange String Decoder.
const zlib = require("zlib");
const util = require("util");
class Parser {
constructor(buf) {
this.pos = 0;
this.buf = buf;
this.last_position = { x: 0, y: 0 };
}
@Hornwitser
Hornwitser / control.lua
Created November 12, 2019 18:55
Client specific GUI update POC
local mod_gui = require("mod-gui")
local current_player_index
local name_element
local tick_element
script.on_init(function()
current_player_index = 0
end)
script.on_event(defines.events.on_player_joined_game, function(event)
@Hornwitser
Hornwitser / dark python 3.js
Last active June 13, 2018 12:50
Dark Python 3 docs greasemonkey script
// ==UserScript==
// @name Dark Python 3
// @namespace Hornwitser
// @include https://docs.python.org/3*
// @version 1
// ==/UserScript==
// This is probably missing a few uncommon elements.
var rules = [`
/*
* Hornwitser's silly calculator app v0.1
*/
#include <vector>
#include <string>
#include <sstream>
#include <stdexcept>
#include <iostream>
@Hornwitser
Hornwitser / backoff.py
Created June 18, 2016 14:56
Truncated Exponential Bacoff Algorithm
import random
import time
class ExponentialBackoff:
"""An implementation of the exponential backoff algorithm
Provides a convenient interface to implement an exponential backoff
for reconnecting or retrying transmissions in a distributed network.
@Hornwitser
Hornwitser / config.py
Last active October 19, 2015 10:36
Simple python configuration
# Read the config file
config = eval(open('cfg.py').read())
# Use it like any other dict
config['Hello'] = 'Modified World'
# Write the changed config file back
lines = [' {!r}: {!r},'.format(k, config[k]) for k in sorted(config)]
open('cfg.py', 'w').write('\n'.join(['# Modified config', '{']+lines+['}']))