Imaginary Robots

Recent Posts

Exporting Krita layers for use in Spriter

I'm currently working on a game where the characters are hand-painted in Krita (an amazing digital painting tool!). I'm then using Spriter (also awesome!) to put together 2d animations. My original workflow for getting the images from Krita to Spriter is very manual and error-prone, so I've put together an automated script to do it for me.

While Krita itself has the ability to save its layers as PNGs, it only works if the layers are all at the top-level, i.e. no nested layer groups. Since I'm working with 50+ layers, that would be painful! I tried just removing the layer groups every time I wanted to export, but that was almost as bad.

UPDATE: Originally, I was exporting to PSD, but the Krita developers got in touch and pointed out that .ORA files are really just zips. My updated workflow is to export as a .ORA file, then use a script to unzip them then manipulate with ImageMagick for the final resizing.

The script has to read the data from the stack.xml file, but it's not as complicated as reading the PSD data using imagemagick.

Here is the updated script:

https://gist.github.com/jessevanherk/6ba7712eb64040a9ea2b

Read More

Fixing a Failed Safepoint on WD MyBookLive NAS

TL;DR: If you're syncing linux computers to your NAS then creating a safepoint to an external drive, that drive needs to be linux-formatted or you'll get errors.

I recently bought a portable hard drive in order to make backups of my Western Digital MyBook Live Duo NAS.  While trying to create a Safepoint using the Web UI, it chugs for 15 hours, then shows an unhelpful error. Trying to re-do or update the safepoint leads to a similarly unhelpful error:

There was an error updating your safepoint.
2 - There was an error updating your safepoint NAS_Offline_Backup on the My_Passport_07A8 share on MyBookLiveDuo.
Luckily my NAS runs linux and I can find out more!  SSHing into the NAS, I can see the following in /var/log/wdalerts.log:

MyBookLiveDuo nas: warn:  1102: There was an error updating your safepoint. +;NAS_Offline_Backup;My_Passport_XXXX;MyBookLiveDuo;2;-

That's a start, but doesn't say much more than the web UI.  Looking around, there's a second log file with more info at /var/log/wdnas.log:

Status: FAILED; Failed to complete rsync command to copy data - rsync failed with error, 23

That's definitely progress. Rsync is failing with error 23, which according to rsync docs is "Partial transfer due to error". Searching the web, I found a reference saying that the actual error might be:

"some files/attrs were not transferred"

So it looks like the root cause is mis-matched filesystems - I'm copying data from my linux laptop to the linux NAS to the windows-formatted external drive, the permissions are not making it all the way and rsync complains.  If I were running windows on my laptop, the files on the NAS wouldn't have any extra permissions, and they would be happily copied to the NTFS drive without errors.

The solution for me is to reformat the portable hard drive as ext4, then try creating the safepoint.  I reformatted it by plugging the portable drive directly into my laptop, then launching GParted in Ubuntu. Make sure you select the removable drive when partitioning, or you will lose all of your data!

Once it was repartitioned, I plugged it back into the NAS, kicked off another safepoint, waited 15 hours, and got a nice "success!" message in the web UI.

Read More

Sinatra-like Microframeworks Roundup

I've been using Perl Dancer for my personal webapps for a few years now, and am incredibly happy with it. I've also recently started deploying them with nginx+uwsgi, which (once you get the config right) is a great combination. I've recently been looking at what the equivalent would be in other popular languages. Since Dancer is inspired by Sinatra and most other languages have similarly inspired projects, it was a fairly simple list to put together.

Note that where multiple options exist, I've tried to pick the most popular alternative that most closely matches the setup that I am used to - your own projects may have different requirements. I also haven't tried using all of these, so there may be better ways to set up some of this.

Language Framework App Server Web Server Packaging
Perl Dancer uWSGI Nginx CPAN
Ruby Sinatra Rack Nginx Gems
Python Flask uWSGI Nginx pip/PyPi
PHP Slim Fastcgi Lighttpd PECL
JS Express Nodejs Nodejs npm
Java Spark N/A Tomcat N/A

The most obvious conclusion from this list is that micro-frameworks based on Sinatra's original DSL are very popular. In fact, the code written in each looks incredibly similar regardless of the language used.

It's also interesting that both Java and PHP have Sinatra-like frameworks, but no simple way to run them as separate app servers or package/distribute the app (FastCGI is close but isn't quite a separate app server). Even more interesting is that a spec for JWSGI exists and is supported by the Uwsgi server, but the Spark microframework doesn't seem to use it. I assume that's because Tomcat/Apache do a good enough job that no one has seen the need to split the app server out.

Read More

Headless Mac Mini Hardware Hack

A few months ago I installed Ubuntu on my old 2009 Mac Mini (and apparently neglected to write about it), which went well except that it would only boot up properly if there was a monitor attached. For something that I’m using as a headless server, that amounts to a giant pain in the butt. We had a power outage last night and the thing once again didn’t boot up, so I finally did something about it.

Read More