Skip to content

Instantly share code, notes, and snippets.

@0x5742
0x5742 / makeup.sh
Created September 5, 2015 13:35
a wrapper for make that searches parent directories
#!/bin/sh
# I always felt 'make' ought to do this.
# Search parent directories until Makefile is found, and build there.
# All options are passed directly to make, with a possible -C if none exists.
# (If -C or -f are given on the command line, no searching is done.)
dir="."
findparents=true
@0x5742
0x5742 / threadedconsole.py
Created September 7, 2015 17:58
interactive Python console that runs alongside Gtk
import code
import os
import threading
from gi.repository import Gtk, GLib
class ThreadedConsole(code.InteractiveConsole):
# Set this to True to read $PYTHONSTARTUP.
# This could potentially be a security risk (since it just exec's what
@0x5742
0x5742 / let.py
Created September 13, 2015 21:12
Don't do this. (It doesn't work anyway)
#!/usr/bin/python
import inspect
class let():
def __init__(self, **k):
self.k = k
def __enter__(self):
locs = self.framelocs = inspect.stack()[1][0].f_locals
self.oldlocs = locs.copy()
locs.update(self.k)
@0x5742
0x5742 / twitter-api-doc-to-sql.py
Created October 17, 2015 13:14
Scrape Twitter's API documentation and pound it into SQLite CREATE TABLE statements
#!/usr/bin/env python
# Scrape Twitter's API documentation and pound it into SQLite CREATE TABLE statements.
#
# Give this URLs to the documentation pages you're interested in, e.g.:
# $ python twitter-api-doc-to-sql.py https://dev.twitter.com/overview/api/tweets > tweets.sql
#
# It's always a good idea to review the output before making use of it.
import re, sys, urllib.request, lxml.html, posixpath
@0x5742
0x5742 / rgb-to-xterm.pl
Created November 8, 2015 17:08
Ultraviolet color scheme (use on console with 'setvtrgb ultraviolet.rgb')
#!/usr/bin/perl -w
use strict;
my @a = map { chop; split "," } <>;
printf("XTerm*color%d: #%02x%02x%02x", $_, $a[$_], $a[$_ + 16], $a[$_ + 32]) for 0 ... 15;
@0x5742
0x5742 / it_unicode.txt
Created December 4, 2015 19:08
Potential private-use mapping for Impulse Tracker's internal characters
Impulse Tracker uses a weird font based on CP437, but with custom glyphs in
positions 0x80 through 0xC9. This is an attempt to map these glyphs to a
Unicode private use area in a somewhat rational manner (i.e. grouping related
characters within 16-character blocks).
I chose the block from U+E830 to U+E87F, which corresponds to the ConScript
block for Deseret (or rather, what *was* Deseret prior to its inclusion in the
Unicode standard as of version 3.1). I am not aware of any other significant
use cases for characters in this range. In theory, there is room for 16 more
characters, since Deseret extends to U+E88F, but that much space isn't needed.
@0x5742
0x5742 / mungesql.pl
Created March 29, 2016 20:19
mangle an SQL dump
#!/usr/bin/perl -w
use strict;
=head
Split up a big .sql file into mutiple pieces for each table represented,
and fix things along the way.
ASSUMPTIONS:
1. All SQL is uppercase
2. Table initialization on a line beginning with CREATE TABLE tablename
3. Closing paren/semicolon after CREATE TABLE on a line by itself
@0x5742
0x5742 / unidump.py
Created April 6, 2016 18:37
Unicode character viewing tool
#!/usr/bin/env python
import unicodedata, sys
def uninamenum(c):
u = 'U+%04X' % ord(c)
try:
name = unicodedata.name(c)
except:
return u
@0x5742
0x5742 / uni
Created April 6, 2016 18:43
Unicode character lookup tool
#!/bin/sh
# Somewhat more convenient than grepping UnicodeData.txt directly.
UnicodeData="${HOME}/.local/share/UnicodeData.txt"
join() {
joiner="$1"; shift
output="$1"; shift
for arg in "$@"; do
output="$output$joiner$arg"
@0x5742
0x5742 / jit.d
Created May 20, 2016 21:05
some JIT tests
/+ Found in an old backup. I'm almost scared of what I was doing here... +/
import std.stdio;
import std.string;
import dlfcn;
import std.c.posix.posix;
import std.c.stdio;
/+