“Rubber Matrix” and “Sparse Montage” wrapper for ImageMagick

Last night, I was working on a bunch of images and I really wanted to just get a visual overview along the lines of a scatter plot, but with images rather than dots. Unfortunately, no matter what I searched for, I couldn’t find anything to do what I wanted.

ImageMagick’s montage tool can do it… but you have to manually fill in the empty cells with the special filename null:

…so I wrote a script to do just that.

Oh, and I got carried away and wrote a “rubber matrix” class to abstract away the actual generation of the grid. Basically, it’s a DictMixin-based class that insists on consistently sized tuples as keys and then adds some extra methods to traverse them as sparse points in a matrix dynamically sized to only the rows/columns/etc. which exist.

I haven’t yet decided on what command-line syntax I want, so you have to import it, but it works perfectly in my preliminary tests.

Posted in Geek Stuff | Leave a comment

Exporting Firefox Tab Groups

TL;DR: Use this script. Non-Linux users, feed it the path to a sessionstore JSON file. Try --tiddlywiki for more copy-pastable output.

Because of the relatively high UX overhead of things like Firefox’s built-in bookmarking or Delicious.com, I recently found myself with over 1000 tabs in my Firefox tab groups.

Lazy-loading after a browser restart or not, this was very far from ideal so I whipped up a quick little script which contains not only the code I used to dump my sessionstore.js, but also the code I used as an aid to reverse-engineering the tab groups part of it since, as far as I can tell, the Mozilla guys didn’t bother to document that.

The code’s definitely not pretty and I can’t guarantee the --make-schema and --check-schema parts still work, but the dumping works perfectly and I didn’t want to spend too much time on it because I’ve heard Mozilla wants to move away from JSON for saved sessions in favour of a custom binary format specifically designed to help them minimize the amount of time internal data structures need to stay locked in order to write them out on a potentially memory-constrained device. (Remember, Firefox on Desktop shares code with Firefox OS.)

It was originally developed to operate on sessionstore.js but, between when I started developing it and now, things changed a bit so, now, it reads sessionstore-backups/recovery.js instead.

It can take one or more paths but, if you don’t provide one, it’ll assume a Linux desktop and try to export every tab group from every Firefox profile in your user account. As written, it always dumps to the tabs.html file in the current working directory.

Normally, it produces a nice-looking HTML output, complete with favicons for list bullets but, If you pass the --tiddlywiki option, it’ll generate a nice compromise that can be copy-pasted into TiddlyWiki. (Including hidden !!! prefixes for the headers so that you can copy-paste a bunch of groups in one go.)

Enjoy. :)

Posted in Geek Stuff | Leave a comment

A confirmation dialog for URxvt’s Print Screen key

I use urxvt’s kuake plugin as a lighter replacement for Yakuake and, as a result, I’m using it with F12 as my “toggle terminal” keybind.

…unfortunately, that means that, every time my finger slips, I hit Print Screen.

As such, I wrote this little script you can use to Print Screen to file, with a confirmation dialog to avoid the need to keep deleting unwanted printouts.

confirm_print.sh (fixed commit ID)

To use it:

  1. Copy it to somewhere like ~/bin/confirm_print.sh
  2. Make sure zenity is installed
  3. Add these lines to your ~/.Xresources
    Rxvt.print-pipe: ~/bin/confirm_print.sh
    URxvt.print-pipe: ~/bin/confirm_print.sh
    
  4. Run xrdb -merge ~/.Xresources
  5. Restart any terminals you may have. (You are using screen or tmux, right?)
Posted in Geek Stuff | Leave a comment

Useful bits for GOG Linux Users

Over the last little while, I’ve written or researched a few little things to make my life as a Linux-using player of GOG.com games a bit simpler. As such, I thought I’d share them.

1. GOG.com – Updated Thread Count in Title

This Greasemonkey script adds the unread count for your favourited forum threads to the favicon so you can select “Pin Tab” and have an alternative to manually polling for new replies.

It’s not RSS, but it still takes a load off your mind.

2. find_broken_symlinks.sh

While not specifically focused on GOG.com or even gaming, this multi-mode script has proven very useful.

Modes of operation:
--all-external
  Show all symlinks targeted outside the current directory
--all-home
 Show all symlinks targeted inside /home
--all-my-home
 Show all symlinks targeted inside the current user's home directory
(anything else)
 Show all broken symlinks originating inside the current directory

I originally wrote it because:

  • Some of my Linux-native ports store their save files in the game’s application folder
  • I symlinked the save files into my homedir so nightly backups cover them
  • My games folder is on an external USB drive
  • Supposing I ever want to let a friend try the games on their computer, I’ll need a way to identify the folders I need to mkdir -p to unbreak the symlinks.

Caution: It’s a bit of a hack and will get confused by folder/filenames containing newlines. (Doing it properly and efficiently is very awkward and painful without reinventing /usr/bin/find in something with more support for structured data than shell scripting.)

3. aptitude search ~o
A quick explanation of “aptitude” for Ubuntu users:

  1. Debian invented apt-get
  2. apt-get didn’t get the lovin’ it deserved
  3. aptitude was invented as an apt-get that doesn’t suck and Debian decided to include it in the base install.
  4. The more popular aspects of aptitude eventually got added to apt-get
  5. Ubuntu decided that apt-get was enough and you have to sudo apt-get install aptitude if you want it.

Basically, aptitude is apt-get on steroids.

What does aptitude search ~o do? It lists all installed packages which aren’t backed by a repository. (Packages you installed using dpkg -i or gdebi, packages which are still installed after you removed the PPA, etc.)

I used it to identify which Humble Bundle games had been installed as .debs so I could replace them with tarballs and move them to my new games drive.

Posted in Geek Stuff | Leave a comment

Working around a MonoGame joystick crash

TL;DR: Try adding unset SDL_JOYSTICK_DEVICE to your game’s launcher script.

Have you ever encountered an error that starts out like this when trying to start a Linux port based on MonoGame?

Number of joysticks: 5
Number of buttons for joystick: 0 - 11
Number of axes for joystick: 0 - 8
Number of PovHats for joystick: 0 - 0
Number of buttons for joystick: 1 - 11
Number of axes for joystick: 1 - 8
Number of PovHats for joystick: 1 - 0
Number of buttons for joystick: 2 - 11
Number of axes for joystick: 2 - 8
Number of PovHats for joystick: 2 - 0
Number of buttons for joystick: 3 - 11
Number of axes for joystick: 3 - 8
Number of PovHats for joystick: 3 - 0

Unhandled Exception:
System.IndexOutOfRangeException: Array index is out of range.
  at Microsoft.Xna.Framework.Input.GamePad.AutoConfig () [0x00000] in :0
  at Microsoft.Xna.Framework.Input.GamePad.PrepSettings () [0x00000] in :0
  at Microsoft.Xna.Framework.Input.GamePad.GetState (PlayerIndex playerIndex, GamePadDeadZone deadZoneMode) [0x00000] in :0
  at Microsoft.Xna.Framework.Input.GamePad.GetState (PlayerIndex playerIndex) [0x00000] in :0
  [...]

It’s basically saying that it found five joysticks, then got their characteristics wrong, then died when trying to access item 5 out of 4 in the listing.

In my case, the problem was as follows:

  1. On Linux, there are two APIs for accessing joysticks. An old, deprecated, joystick-specific one, and the generic “any input device” API which has no concept of calibration.
  2. My first joystick device is always my 3DConnexion SpaceNavigator, which isn’t a joystick but has stupid USB HID tables which cause the Linux kernel to expose a useless joystick device as the first joystick on the system.
  3. Some games only listen to the first joystick.

My solution for a lot of games was to set this environment variable in my .xsessionrc to force SDL to see my XBox 360 gamepad as the first joystick and to access it via the calibration-aware /dev/input/jsX API rather than the “expect hardware to not need calibration” /dev/input/eventX API.

# Make sure SDL uses a joystick device which can be calibrated
export SDL_JOYSTICK_DEVICE=/dev/input/js3

Adding unset SDL_JOYSTICK_DEVICE to the launcher script for the game fixed it… at the risk of requiring joystick support to be had via antimicro (a joy2key-like utility).

Posted in Geek Stuff | Leave a comment

FocusWriter… whether or not you need “distraction-free”

Those who know me well know that I’m a bit of a paradox when it comes to writing. On the one hand, I do have issues with distraction and I do approve of the concept of separating composition and typesetting, but, on the other, I can’t use an ordinary distraction-free writing tool for two reasons:

  1. The sheer novelty of it sends me spiralling off into the “technology geek” side of my mind, which is generally quite disjoint from the creative side.
  2. They’re simply too spartan

There’s not much I can do about the former, but I may not need to. When I’m writing something like a blog post or an essay, it’s the “sitting down to write” part that’s the biggest problem. (My troubles with writing fiction seem more oriented around mentally modelling the characters and world… and I’m in the process of  using a mockup to refine a potential solution for that.)

However, the latter point definitely is something worth mentioning in more detail. Distraction-free or not, word processors optimized for composition rather than typesetting are a greatly under-explored market. LyX works beautifully for academic papers, textbooks, and the like, but tools intended for fiction seem to either be too minimal (notepad.exe with chrome trim) or too heavy (MS Word with more task-specific features).

Perhaps the most visually-distinctive examples of the former category are “distraction-free” word processors, like WriteRoom, which take over your whole monitor and present no GUI elements.

Originally, I just assumed that I disliked them because thought these simply weren’t for me but, after reading someone else’s blog post, it dawned on me that, no, WriteRoom just sucks and some people are better at living with it than others.

That blog post introduces FocusWriter, a cross-platform, open-source writing tool that’s primarily intended to be distraction-free, but can still be run in a window if you want (Alt+Enter to switch) and has so many author-oriented features that, even if you don’t need distraction-free, you’ll probably still want it. (Payment is optional. Just choose “$0.00″ from the Tip drop-down.)

Like most distraction-free writing tools, FocusWriter is highly themable [1] [2] [3] [4] and can be fine-tuned with “experience features” like playing typewriter sounds when you press keys.

However, where WriteRoom and its clones are the digital version of fancy stationery in a typewriter, FocusWriter asks and answers the question “What does the writer need to be more productive?”

Here’s the mix of answers it came up with:

  1. Minimize distraction without killing discoverability by using auto-hiding menus, toolbars, panels, and a statusbar.
  2. Not everyone needs a fullscreen writing tool. Allow the user to toggle windowed mode via F11 or the menu system.
  3. Keep the author “in the zone” by offering basic standard word processor functionality like rich text support. (Not everyone natively thinks in Markdown-like languages)
  4. Trust skilled authors to know to separate writing and proofreading. Don’t force them to open a whole other program just to run operations like spell check or search/replace.
  5. Provide a tab bar. “Distraction-free” doesn’t necessarily mean “single document”.
  6. Support saving and loading sessions. People who can only spare a few minutes at a time are authors too, as are people who juggle multiple projects.
  7. Acknowledge that some people may need extra help focusing. Offer tricks like greying out all but the line, three lines, or paragraph that the user is actively working on.
  8. Recognize that authors don’t always write in a linear fashion. Provide a jump-to-scene panel on the left and a scrollbar on the right.
  9. Help people meet their goals. Offer to track a daily goal, measured in minutes or words, and support tracking how many consecutive days the user has met their goals.
  10. Make it easy to check your word count, paragraph count, page count, character count, time, and progress toward your goal. Put them in a configurable statistics panel hiding at the bottom of the screen.
  11. Provide a timer system so users can let the outside world fade away without missing that upcoming appointment.
  12. Support auto-saving everything… right down to cursor position.
  13. Allow the user to export in plain text, RTF, DOCX, or ODT formats for easy compatibility with whatever their pre-readers may be using.
  14. Themes are a great way for authors to really get into the right mindset. They should be easy enough to create that anyone can do it. (Ink on Parchment? Typewriter on coarse paper? Phosphor on a VT100? A snowy field or futuristic slum? Google up a background image and a font, open up the “new theme” dialog, and go wild.)

There’s even a Portable Apps release of the Windows version for when you can’t get into the zone on your phone, but didn’t bring along anything else bigger than a thumbdrive.

In summary, don’t prejudge FocusWriter for its status as a “distraction-free word processor”. It’s a very elegantly designed, highly customizable word processor for creative projects that just happens to have distraction-free writing support as its most visible feature.

Posted in Writing | Leave a comment

Free resources for making games

I got a little carried away while assembling a list of game-development resources as an activity for a course I’m taking, so I decided to share them. Enjoy.

Everything listed is free enough (in both senses of the word) to be used in an open-source project and can be used to produce games which, at minimum, target Windows, Linux, and OSX. With a few minor exceptions, which are noted, all tools also run on any of those three.

Note: This is only a portion of the list I maintain for my own use. If you don’t see what you want, feel free to ask me to check my bigger, more cluttered private list.

Articles (Sample Platter):

Free Game Engines:

  • Godot
  • Panda3D (3D game engine developed by Disney specifically to enable high-quality games to be written in Python)
  • The Frogatto Engine (Anura) (Really impressive built-in level editing and dynamic reprogramming capabilities. Primarily targeted at 2D platformers, but can be repurposed.)
  • Sauerbraten and BananaBread (A Quake-like 3D game engine with as-you-play level editing and a WebGL port)
  • Various iD Tech engines that have been open-sourced
  • Spring Engine (Open-source 3D real-time strategy game engine)
  • EasyRPG (Open-source clone of the RPG Maker 2000/20003 editor and player. See MKXP for a clone of the RPG Maker XP runtime only.)
  • Adventure Game Studio (Open-source editor and engine for 2D games in the style of King’s Quest and Monkey Island. Editor runs on Windows. Engine ported to all major platforms.)
  • Ren’Py (The most popular engine for English-language visual novels and related types of games)
  • TADS (The most advanced engine for interactive fiction (text adventures), supporting rich text, illustrations, ambient sounds, hyperlinks, etc. The IDE is is Win32-only, but a fully-portable command-line toolchain is available and the IDE can be run in Wine if you use winetricks to install IE6.)

Free 3D Engines and Game Frameworks:

  • OGRE 3D (Highly-extensible, modular 3D engine as used by games like Torchlight and The Book of Unwritten Tales)
  • Irrlicht (3D engine used in proprietary games like Octodad and open-source ones like SuperTuxKart)
  • SDL 2.0 (The big name in providing a portable alternative to DirectX. With add-ons like SDL_mixer, the Render API provides a higher-level 2D experience comparable to Allegro)
  • HaxeFlixel (Port of the Flixel 2D engine from ActionScript to Haxe, a statically-typed derivative which compiles to SWF or native code)
  • Moai SDK (used by Broken Age. A.K.A. The DoubleFine Adventure)
  • MonoGame (Open-source XNA 4.0 clone for C# games. Used to port games like Bastion, Escape Goat, and Fez to non-Windows OSes. See MonoGame-SDL2 for best Linux backend.)
  • LWJGL (Portable Java game library used by Minecraft.)

Free Resources:

Relevant Steam Dev Days Talks:

Tools:

  • ASEprite (Allegro-based, open-source sprite editor. $10 for pre-built or compile it yourself for free)
  • Audacity (Free, open-source, cross-platform audio editor)
  • Git Extensions (An easy-to-install Windows distribution of the Git revision control system which provides comprehensive GUIs.)
  • Krita and MyPaint (Free, open-source digital painting tools which compete with Corel Painter and SAI… unlike GIMP which is even more specialized as a photo-retoucher than Photoshop.)
  • LMMS (Free, open-source, cross-platform music-composing tool. Ardour is even more powerful but only works on Linux and OSX and has a bit of a learning curve.)
  • Qt Creator (The free, portable, mature C/C++ IDE that Valve apparently prefers.)
  • TileEd (Free, open-source level/map editor for when you’re building your own game engine)
  • VirtualBox (Free, open-source competitor to VMWare. Has guest 3D drivers, which make it an easy way to quickly test new game builds on other platforms.)

Tools (3D):

  • Blender (Free, open-source professional-quality 3D modelling tool with built-in game engine and non-linear video editor.)
  • GtkRadiant and QuArK (Level editors for games based on the various iD Tech engines that have been open-sourced over the years)
  • MakeHuman (Free, open-source tool for generating humanoid 3D models quickly and easily)
  • ngPlant, Arbaro, Ivy Generator (Free, open-source, parametric generation of 3D plant models)
  • Terraineer, HME, and Picogen (Cross-platform, open-source terrain heightmap generators and/or editors. Geomorph and Terraform also exist, but they’re Linux-only.)
  • Wings 3D (Free, open-source subdivision modelling tool which may be easier to learn than Blender when that’s all you need.)

Free, Open-Source Installer Generators:

  • NSIS (As used by many many Windows programs and games)
  • InnoSetup (The other big, free installer generator. Used by all GOG.com Windows releases)
  • install.sh for Linux tarball releases (My own creation, so you can ask me for help with it. Used by the Linux releases of games like SteamWorld Dig and Desktop Dungeons)
  • Mojo Setup (For when you really need a binary Linux installer package… but there’s no “unpack it without running the install scripts” tool like cabextract or innoextract for it, so expect to piss off people like me if this is the only option you offer.)

Services Free to Projects Which Open-Source Their Code on GitHub:

Enjoy. :)

Posted in Geek Stuff | Leave a comment