.

data.d – unmanaged memory wrapper for D

I have written a module containing classes to manage raw data in external memory. It provides semantics similar to built-in void[] arrays, but has the following advantages:

  • Faster allocation and deallocation, since memory is requested from the OS directly as whole pages
  • Greatly reduced chance of memory leaks due to stray pointers
  • Overall improved GC performance due to reduced size of managed heap
  • Memory is immediately returned to the OS when data is deallocated

Source and more info here: http://github.com/CyberShadow/data.d

Import Wikipedia page history to git

I’ve written a small tool which downloads the history of a Wikipedia article, converts it and imports it into a new git repository. The main motivation behind writing it is being able to perform a per-line blame of the article’s history. I had tried levitation, but that tool seemed to be oriented towards large imports (or it might just be buggy), as it attempted to create huge binary files and ran longer than my patience would allow when I gave it the history of just one article. Also, I wanted the tool to take care of the downloading and importing part – so I could be one command away from a git repository of any WP article.

The tool can be made faster (all the XML and string management stuff adds an overhead), but right now it’s fast enough for me. One thing that can be optimized is making it not load the entire input XML into memory – it’s possible to do the conversion by “streaming” the XML. Another current limitation is that it’s currently hard-wired to the English Wikipedia.

Requires curl and (obviously) git. You’ll need a D1 D2 compiler to compile the code.

August 2013 update: Updated to D2. Now creates the directory automatically. Added --keep-history switch.

Source, Windows binary.

GraphStudio fork

I have made a few improvements to GraphStudio, the open-source GraphEdit clone:

  • The limit for text entry in certain combo boxes has been removed
  • Basic XML graph saving support has been added (only filters and connections at the moment)
  • Pins are now referred by their indexes in XML rather than by ambiguous names
  • Added command-line /render parameter, which loads a graph, plays it and exits

XML support and /render allow scripted generation and rendering of XML graph files.

Source, download.

Update: Check out GraphStudioNext. Some or all of my patches have been merged into that project, and presumably will be in the next release (the one after 0.5.0.1).

Why is the amount of text I can type in my combo box limited by its width?

Once in a while you’ll stumble upon a combo box which doesn’t allow you to type past the right edge of the control. When normally typing more text would just scroll the contents, you’ll just get back an annoying beep. The amount of text you can enter is actually bound by the on-screen width of the text – thus, you may be able to enter 125 “i” characters, but only 25 “W” characters.

The cause of the problem is that the combo box was not created with the CBS_AUTOHSCROLL style:

CBS_AUTOHSCROLL
Automatically scrolls the text in the edit control to the right when the user types a character at the end of the line. If this style is not set, only text that fits within the rectangular boundary is allowed.

Visual Studio’s resource editor has a different name and description for this property:

Auto
Automatically scrolls text to the left when the user types a character at the end of the line.

Setting shared Google Talk / Gmail status programmatically

There are a few ways to programmatically set the Google Talk / Gmail status via XMPP, however they have some problems if you are signed in into the same account with Google Talk or Gmail chat:

  1. You need to keep the program running – otherwise, the status will revert when the connection is closed;
  2. Other logged-in applications will not see the status change.

Enter Google’s Shared Status Messages XMPP extension. Here’s a short Python script which uses the extension to set the status from the command line (needs xmpppy):

#!/usr/bin/env python

USERNAME = "thecybershadow"       # don't include @gmail.com
PASSWORD = "hunter2"
RESOURCE = "gmail.com"

import sys

if len(sys.argv) < 2:
	print 'Usage: python gstatus.py <show> [<status>]'
	print '		<show> is either "default" or "dnd"'
	print '		<status> is the status string (optional)'
	exit()

import warnings
warnings.filterwarnings("ignore") # silence DeprecationWarning messages
from xmpp import *

cl=Client(server='gmail.com',debug=[])
if not cl.connect(server=('talk.google.com',5222)):
	raise IOError('Can not connect to server.')
if not cl.auth(USERNAME, PASSWORD, RESOURCE):
    raise IOError('Can not auth with server.')
cl.send(Iq('set','google:shared-status', payload=[
		Node('show',payload=[sys.argv[1]]),
		Node('status',payload=[sys.argv[2] if len(sys.argv)>2 else ""])
]))
cl.disconnect()

Announcing: RABCDAsm

RABCDAsm (Robust ABC (ActionScript Bytecode) [Dis-]Assembler) is a collection of utilities including an ActionScript 3 assembler/disassembler, and a few tools to manipulate SWF files.

This package was created due to lack of similar software out there.
Particularly, I needed an utility which would allow me to edit ActionScript 3 bytecode (used in Flash 9 and newer) with the following properties:

  • Speed. Less waiting means more productivity. rabcasm can assemble large projects (>200000 LOC) in under a second on modern machines.
  • Comfortably-editable output. Each class is decompiled to its own file, with files arranged in subdirectories representing the package hierarchy. Class files are #included from the main file.
  • Most importantly – robustness! If the Adobe AVM can load and run the file, then it must be editable – no matter if the file is obfuscated or otherwise mutilated to prevent reverse-engineering. RABCDAsm achieves this by using a textual representation closer to the ABC file format, rather than to what an ActionScript compiler would generate.

Read more on the project’s homepage on GitHub.

WordPress “Pixel” theme – fixed background mod

I love fixed backgrounds. So, I made a version of Sam’s Pixel theme with a fixed background (which you can see on the blog already). It even supports IE6 (well, almost) – thanks, ie7-js!

Note: I re-exported the background from the original PSD as a PNG, since it’s too beautiful to be degraded by JPEG compression artifacts. The PNG is about 350kb in size – so, if that bothers you, convert it to JPEG and edit style.css accordingly.

Download