Skip to content

Instantly share code, notes, and snippets.

View boxmein's full-sized avatar

Johannes Kadak boxmein

View GitHub Profile
@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 / -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 / 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 / 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 / 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 / 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 / scrape-users.rb
Created September 12, 2015 18:35
Quick script to scrape all the users of http://thepowdertoy.co.uk . Note: the admin of that site is handing out IP bans left and right!
require 'net/http'
require 'thread'
# If a request fails we queue it for later
$fail_queue = Queue.new
# Total # of accounts
accounts = 144903
# Amount of threads and piles of work
N = 4
@boxmein
boxmein / scrape-definitions.rb
Last active September 18, 2015 16:51
quick script to scrape definitions off of the Oxford Learner's Dictionary
#!/usr/bin/env ruby
# encoding: utf-8
# Dictionary Scraper
# sends a GET request to a dictionary, then scrapes the response with Nokogiri
# and returns the result
# usage: cat wordlist.txt | ruby scrape-definitions.rb 1>words.txt # 2>errors.txt
require 'open-uri'
require 'thread'
require 'nokogiri'
@boxmein
boxmein / echelon.py
Last active April 18, 2022 21:39
Python script to calculate row echelon matrices from non-row echelon matrices (for Gaussian elimination, say)
#!/usr/bin/env python3
# encoding: utf-8
# Row Echelon Calculator
# (for Gaussian Elimination)
# INPUT:
# Matrix of any dimensions in the following form:
# input := { row, "\n" }, ".\n"
# row := { num, " " }
# num := <float>
@boxmein
boxmein / porn.rb
Created October 24, 2015 16:35
get yourself some spicier ascii art
#!/usr/bin/env ruby
require 'net/http'
Net::HTTP.get_print URI("http://www.asciipr0n.com/pr0n/pinups/pinup#{( rand * 48 ).to_i}.txt")