Skip to content

Instantly share code, notes, and snippets.

Keybase proof

I hereby claim:

  • I am thequux on github.
  • I am thequux (https://keybase.io/thequux) on keybase.
  • I have a public key whose fingerprint is D3F4 3C11 0147 B6BD A90E D97B C262 C9B2 FA65 AB11

To claim this, I am signing this object:

@thequux
thequux / symboltable.py
Created May 11, 2014 19:17
A sketch of a symbol table
import collections
import contextlib
import itertools
class SymbolTable(collections.MutableMapping):
__slots__ = ('_content')
def __init__(self):
self._content = []
def _top_dict(self):
if not self._content:
@thequux
thequux / namedop.cpp
Created July 24, 2014 05:27
Named operators! In C++!
template<class Self, typename L, typename R, typename Ret>
class Op {
public:
typedef L left_arg_type;
typedef R right_arg_type;
typedef Ret return_type;
//Ret operator() (L left, R right);
};
@thequux
thequux / Makefile
Created October 28, 2014 14:01
Make-based scanning frontend
# Usage: make name=<document name> t<arget>
# Start with the init target, then use "scan" to run the scan. Finally, run "pdf" to get a compressed PDF file.
# Parameters that can be set in a Makefile.defs include:
# papersize: Provides defaults for papersize_width and papersize_height; defaults to a4
# papersize_{width,height}: Width and height of page in px
# resolution: resolution of scan in dpi
# rotate: Rotation angle (0,90,180,270). Applied during compression.
@thequux
thequux / btsync.conf
Created November 27, 2014 01:53
POC||GTFO Quick Setup
{
"device_name": insert_your_hostname_here,
"listening_port" : 0, // 0 - randomize port
/* storage_path dir contains auxilliary app files
if no storage_path field: .sync dir created in the directory
where binary is located.
otherwise user-defined directory will be used
*/
//"storage_path" : "",
@thequux
thequux / spritz.c
Created April 2, 2015 18:20
Spritz in C
// This file was written by TQ Hirsch <thequux@thequux.com>.
// It may be used under any of the following licenses, at your
// discretion:
// - Public Domain
// - WTFPLv2
// - CC-0
// - MIT
// - ISC
# -*- Makefile -*- vim: ft=Makefile
# This expects to be built with make -f
H Ha Hb Hc:
echo halted
define Nr
$(foreach post,a b c,$(eval $(call Nr0,$(1),$(2),$(post))))
endef
<?php
// This is designed to be used with the IP list from
// https://rules.emergingthreats.net/fwrules/emerging-Block-IPs.txt
//
// To use:
// $ipset = new IPSet("emerging-Block-IPs.txt");
// if ($ipset->check_ip($_SERVER['REMOTE_ADDR'])) {
// // Block the request
// }
@thequux
thequux / gist:6034448
Created July 19, 2013 01:35
Putative C++ bindings for hammer
// Bindings MUST have a consistent mapping from the base Hammer API to
// the binding, suitable for mechanical translation. The binding MAY
// also support additional convenience methods. (see +type+ for an
// example)
const hammer::Parser& init_parser() {
// The default constructor gives you an +h_indirect()+ parser.
static hammer::Parser ret;
hammer::Parser &domain = init_domain();
@thequux
thequux / cfdec.py
Created October 1, 2013 11:10
Dump an uncompressed colorforth image (eg, for the GreenArrays IDE) to an easier-to-work-with JSON. The output format is a list of blocks, each block being a list of "words", where a "word" is a list of tag, text, and optional value. This code will mangle binary blocks; the first useful block for the GA IDE is 18.
#!/usr/bin/python
# This code is utter crap; that said, it's intended to be a quick and dirty hack.
# To dump JSON from a Colorforth image:
# - Load the image into colorforth
# - type '0 !back '
# - At your terminal, run "python cfdec.py <OkadBack.cf >Okad.json"
#
# On Windows, you will find OkadBack.cf in C:\GreenArrays\EVB001\OkadBack.cf
# On Linux, it's in ~/.wine/dosdevices/c:/GreenArrays/EVB001/OkadBack.cf