Skip to content

Instantly share code, notes, and snippets.

View boxmein's full-sized avatar

Johannes Kadak boxmein

View GitHub Profile
@boxmein
boxmein / tinystore.js
Created June 7, 2015 13:08
A really tiny JSON encrypted-and-compressed datastore
// Dead simple compressed and encrypted datastore
var crypto = require('crypto');
var zlib = require('zlib');
var fs = require('fs');
var stream = require('stream');
// Load the session store from #{filename} and decrypt it using #{method} with
// the key #{key}.
// @param filename {String} filename
// @param key the encryption key, can be a string or buffer
@boxmein
boxmein / csv-indexer.py
Created June 7, 2015 11:59
Indexes all CSV rows under the specified index in Elasticsearch. Uses a pre-defined array of column headers to parse the CSV into a dict.
#!/usr/bin/env python3
# encoding: utf8
# pip install elasticsearch for the elasticsearch shim :)
import csv
from elasticsearch import Elasticsearch, Urllib3HttpConnection
CSVFILE = "tptsaves.csv"
HTTP_AUTH_DETAILS = "username:password"
INDEX_NAME = "tptsaves"
DOC_NAME = "save"
@boxmein
boxmein / checker.py
Created April 29, 2015 01:10
ERC Checker v1
#!/usr/bin/env python3
## python3 {{f}}
# thepowdertoy.net Early Registration Code #2 Checker For MiningMarsh
# Code format: "ABCDEFG-HI-JKLMN-OPQ"
# where each letter can be [A-Z0-9].
import hashlib
# This is the hashed key for Challenge #2 (http://tpt.io/.286266)
# Hash = SHA512 ( ("lolhash:" + ERC).encode('UTF-8') )
# where ERC is literally in the format described above.
@boxmein
boxmein / numbers-game.md
Created April 21, 2015 00:31
A description of a number game

Some number game

It's a very easy game that isn't particularly easy on humans - but, as @mniip has demonstrated, is easy for computers. Describing it here because I need node-irc-bot to describe it to people but it's not good at long articles.

Requirements:

  • Paper, pen / text editor (you'd probably want to take notes)
  • At least two participants

Start of the game

@boxmein
boxmein / -server.py
Last active August 29, 2015 14:18
Tiny Flask/Pillow-based HTTP image gallery server
# Tiny Flask/PIL/Pillow based HTTP image gallery server
# Wow, uh, that was a mouthful. Okay, here's what this is all about.
# It serves image galleries. Download it, launch the script in an image folder, and
# this baby will make your image folder look like a fancy image gallery page. Magic
# huh?
#
# It uses arcane rarely-available technologies such as Flexbox and HTML. It auto-
# generates and stores thumbnails from the entire directory, making the first load
# of a directory listing *really* slow. Left as an exercise to the reader. I wanted
# the gallery quickly built, not decently!
@boxmein
boxmein / TuringMachine.hs
Created April 3, 2015 23:11
Turing machine thing in Haskell (quite literally a tape machine)
-- Turing machine thing in Haskell
-- (c) boxmein 2015 mit licensed blah blah
module TuringMachine
where
--
-- Tape
@boxmein
boxmein / webchat.user.js
Created March 22, 2015 21:02
Turns Powder Toy Forum's "Conversations" page into a tiny Freenode webchat box. Sorry if it's quite crappy - the script is a hundred years old!
// ==UserScript==
// @name Powder Toy site Webchat
// @description Replaces Powder Toy site "Conversations" with webchat window. Turn off by turning off the script.
// @namespace boxmein.net
// @include http://powdertoy.co.uk/*
// @version 1.0
// ==/UserScript==
/* Webchat.js
* Turns powdertoy.co.uk's Conversations window into a qwebirc IRC box for #powder and #powder-social
@boxmein
boxmein / undelete.user.js
Last active August 14, 2017 09:24
An userscript that un-deletes forum posts on http://powdertoy.co.uk. To run, save as file and drag into extensions folder (Chrome) or use an addon (GreaseMonkey for Firefox, TamperMonkey for Mozilla). http://puu.sh/fHN7l/58ea0cde48.png THIS is what I mean by removed!
// ==UserScript==
// @name Powder Toy Undelete Removed Comments
// @version 1.0.1
// @description Undeletes comments that have been removed, using a weird data leak.
// @author boxmein, Mrprocom
// @namespace http://boxmein.net
// @run-at document-end
// @match http://powdertoy.co.uk/Discussions/Thread/*
// ==/UserScript==
@boxmein
boxmein / gist:1118e156f2b8e8f89aab
Created January 28, 2015 22:09
how to write tpt elements, implies lua scripts

How to make a TPT Element

This is a followup from this tutorial, and will teach you the basics of how to write your very own TPT element. It doesn't, however, bother explaining what various functions do, or what properties mean. You can use my very own Lua reference (update pending), or the wiki for just that.

@boxmein
boxmein / gist:f4199c8807808b116521
Last active June 6, 2024 15:46
how to write lua scripts

Lua Coding Tutorial

You may use the contents of this document according to the CC BY-NC-SA license.

Also available on: 360 Tech Explorer

This is a really simple tutorial to get you started coding Lua for The Powder Toy. It tries to expect no programming knowledge of the reader, and tries to give the reader an idea of how to think algorithmically as well as how to