Saturday, May 26, 2018

My Photoshop-ish Keyboard Shortcuts for The Gimp 2.10

I've downloaded the popular Photoshop-ish Keyboard Shortcuts for The Gimp 2.8 several times. It has been super helpful. I made a few more small changes to fit my tastes. I post it here so I can easily download it on other computers or after a re-install.

My own Photoshop-ish Keyboard Shortcuts for The Gimp 2.10.6

On Windows, the latest version of Gimp stores settings in a new location. Rename the file to menurc and copy it to

%userprofile%\AppData\Roaming\GIMP\2.10

Updated 4 Nov 2018

Thursday, July 28, 2016

My Windows 10 fresh install upgrade checklist

Upgrading my Windows 7 machines. I alternate installs between 2 HDD.

  1. Download all Windows 10 drivers for my hardware
  2. Download latest version of all programs for reinstall (some 40+ programs, Ninite can help with the basics)
  3. Make sure I have a copy of my Windows 7 license
  4. Run Windows 10 update tool
  5. Download Windows 10 ISO
  6. Burn ISO to DVD
  7. Upgrade to Windows 10
  8. Swap to new HDD
  9. Fresh install of Windows 10, disabling all privacy settings
  10. Install all drivers
  11. Disable remaining privacy settings
  12. Disable Fast Startup
  13. Copy over files from original HDD
  14. Uninstall preinstalled Windows 10 junk
  15. Install Winaero Tweaker
  16. Tweak things for optimal settings
  17. Install all my programs and tweak configurations everywhere

My original HDD is still there and can still be booted up in case I forgot to copy over anything. The process from start to finish takes me about 12 hours.

Wednesday, October 1, 2014

java.text.MessageFormat sucks

More on that in a minute.

In related news: Throwable.getLocalizedMessage() is practically useless, to the point it might as well be deprecated. I may be the only developer in the history of the Java language to actually implement that method.*

// java -Duser.language=fr
void printError(MyAwesomeException e) {
   System.out.println(e.getMessage()); // "by jove!"
   System.out.println(e.getLocalizedMessage()); // "sacrebleu!"
}

* Gross exaggeration

Now back to MessageFormat. By default it will only handle the formates built in to the JRE. Extending it is done per instance, by argument.

class ExceptionFormat extends Format {
    @Override
    public StringBuffer format(Object obj, StringBuffer toAppendTo, FieldPosition pos) {
        if (!(obj instanceof Throwable)) throw new IllegalArgumentException();
        Throwable t = (Throwable) obj;
        String sMsg = t.getLocalizedMessage();
        if (sMsg == null) sMsg = t.getMessage();
        if (sMsg == null) sMsg = t.getClass().getName();
        toAppendTo.append(sMsg);
        return toAppendTo;
    }
    @Override
    public Object parseObject(String source, ParsePosition pos) {
        throw new UnsupportedOperationException();
    }
}

// java -Duser.language=fr
void printError(MyAwesomeException e) {
    MessageFormat mf = new MessageFormat("Error: {0}");
    mf.setFormatByArgumentIndex(0, new ExceptionFormat());
    System.out.println(mf.format(new Object[]{e})); // "Error: sacrebleu!"
}

Unfortunately, not only would be a hassle to manually set a custom format every time, it wouldn't even work half the time.

// java -Duser.language=fr
void logError(Exception e) {
   Logger log = Logger.getAnonymousLogger("fish");
   log.log(Level.WARN, "Error: {0}", new Object[] { e }); // "Error: by jove!"
   // NO!
}

MessageFormat is nested deep within the bowels of the JRE/JDK and many 3rd party libraries. It's permanently infected, so there's no way to override many cases.

While you can't get rid of MessageFormat entirely, there are a few better alternatives available.

ICU MessageFormat

If you are serious about localizing your app, it's just a matter of time before you start using the ICU library. It's pretty much an industry standard. The best part is it fixes the notorious apostrophe (') issue. You can also add arguments by name, as well as number. Unfortunately it doesn't solve my problem.

Apache lang ExtendedMessageFormat

Lets you register format factories, but only at the instance level.

class ExceptionFormatFactory implements FormatFactory {
    public Format getFormat(String name, String arguments, Locale locale) {
        if (!"exception".equals(name)) throw new IllegalArgumentException();
        return new ExceptionFormat();
    }
}

// java -Duser.language=fr
void printError(MyAwesomeException e) {
    Map<String, ExceptionFormatFactory> registry = new Map<String, ExceptionFormatFactory>();
    registry.put("exception", new ExceptionFormatFactory());
    ExtendedMessageFormat mf = new ExtendedMessageFormat("Error: {0,exception}");
    System.out.println(mf.format(new Object[]{e})); // "Error: sacrebleu!"
}

When using "choice" subformats, support for nested formatting instructions is limited to that provided by the base class.

Here is an example where there's no way around the notorious MessageFormat.

Humanize [Extended]MessageFormat

By jove this might be as good as it gets. This appears to actually let you register formatters at a global level so all uses of this class will automatically benefit.

public static class ExceptionFormatProvider implements FormatProvider {
    @Override
    public FormatFactory getFactory() {
        return new ExceptionFormatFactory();
    }
    @Override
    public String getFormatName() {
        return "exception";
    }
}

// java -Duser.language=fr
void printError(MyAwesomeException e) {
    System.out.println(Humanize.format("Error: {0,exception}", e)); // "Error: sacrebleu!"
}

Friday, June 28, 2013

Ubuntu on OEM Production 2550L2D-MxPC

One of the cheapest bare-bones mini PC on Newegg is the OEM Production 2550L2D-MxPC. I thought all the reasonably positive reviews meant it would be a good buy. I also saw it had an Intel graphics chip, which I know is well supported on Linux. Unfortunately I was wrong on both counts.

Summary:

  • Ubuntu 32-bit ONLY. Probably have to run 12.04.1 unless your googlefu and linuxfu is better than mine.
  • Do not bother buying more than 4GB of RAM! The kernel will ignore anything more.
  • A note in the box says the machine supports "800MHz and some 1066MHz DDR3 memory module. 1333MHz DDR3 memory module is not guarantee to work. [sic]" I got lucky that the 1066MHz G.SKILL F3-8500CL7S-4GBSQ I ordered worked.

The graphics chip is Intel GMA 3650, which is in the family of infamous GMA 3600s. These are the unwanted step children of Intel graphics chips.

For Windows, there is a Windows 7 (only) driver which plays full screen HD video smooth a butter.

Only a single proprietary binary Linux driver is available, and I hear no further support will be available for this kind of chip. Ubuntu appears to have officially stopped supporting this one driver because it's based on an old Linux kernel (3.2).

Note that both the Windows and Linux drivers are 32-bit only, so don't expect to run a 64-bit operating system and watch HD video.

This is how I got Ubuntu working on this thing.

I tried many different versions of Ubuntu, Mythbuntu, and Linux Mint before finally finding something that worked: Ubuntu 32-bit 12.04.1. This version of Ubuntu still uses a kernel compatible with the graphics driver. I tried starting with 12.04.2 then downgrading the kernel, but ended with X failing to start.

After Ubuntu was installed I did not download and apply any updates. This again would mess up my kernel. Magnus Deininger posted vital info about getting the right kernel. Running these commands removes the PAE version of the kernel. PAE allows 32-bit operating systems to support RAM > 4GB. Unfortunately the graphics driver is incompatible with it.

$ sudo apt-get install linux-headers-generic linux-image-generic
$ sudo apt-get remove linux-headers-.*generic-pae linux-image-.*generic-pae

I then rebooted. Checking for "Additional Hardware", the graphics driver appeared, and I installed it. The command-line to install it is

$ sudo cp /etc/lightdm/lightdm.conf /etc/lightdm/lightdm.conf.bak
$ sudo jockey-text --enable=kmod:cedarview_gfx
$ sudo cp /etc/lightdm/lightdm.conf.bak /etc/lightdm/lightdm.conf

The installation overwrites the /etc/lightdm/lightdm.conf file, so my login settings were messed up a bit. That's why I created a backup so I just restored the old version.

Finally I downloaded and installed Ubuntu updates. Sadly the Update Manager would hang forever at the very end. So after rebooting I'd run it again to have it tell me there were no more updates to apply. The kernel stays within the 3.2 family.

Unfortunately that's not the end. Silky full screen HD still didn't work because the video player needs VA-API (Video Acceleration API) support. Someone has made a special build of mplayer that supports VA API. A fine post shows how to install VA-API mplayer for Ubuntu.

$ sudo add-apt-repository ppa:sander-vangrieken/vaapi
$ sudo apt-get update
$ sudo apt-get install mplayer-vaapi

Once installed, open SMPlayer (or whatever MPlayer GUI you're using: Gnome Mplayer, KMPlayer, etc.) and in its Preferences, on the Video tab (in SMPlayer: General Video > Output driver) set the video output driver to "vaapi"

This fine post by paulzhol also suggests adding the following

Edit /usr/share/intel-cdv/X11/xorg.conf.d/61-cdv-pvr.conf to enable AIGLX

Section "ServerLayout"
        Identifier  "default screen"
        Option      "AIGLX"             "On"
EndSection

sigh. 5+ days pounding at this thing. It would be really nice if Ubuntu centered its update dependencies on these critical drivers. Also I'm pretty sure the Newegg reviews are being astro-turfed. Any comment about how Linux support sucks is heavily voted as not useful.

Saturday, January 12, 2013

Giana Sisters: Twisted Dreams

Recently picked up this fun and awesome looking game. Did some hacking on its massive data file Game.pak. Searching for its header SBPAK V 1.0 led me to a forum post and a nearly compatible QuickBMS script. I converted the script to Python to dump all the data.

Wednesday, March 23, 2011

Smartphone as PDA

After posting about potential PDAs 4 months ago, and spending several more hours researching alternatives, I finally concluded that the HTC Touch Diamond really is the perfect (or as close as the market will allow) device for me. Even better that it occasionally shows up on sale for about 30% off at Newegg, so I recently picked one up.

Several more hours of investigation have followed. I've seen it may be possible to upgrade the device to Windows Mobile 6.5, and even install Andorid. Not being ready for that kind of commitment, I've just been finding various programs and tweaks to turn it into my new PDA.

Thus begins the migration from my Palm z22 to Windows Mobile 6.1 HTC Touch Diamond

Programs

First programs I install are .NET Compact Framework 3.5, SQLServerCompact 3.5 Core, and full featured Japanese Display and Input.

After a reset, Dred Sensor, OpenMobileMaps, (Japanese) Pocket Dictionary (along with EDICT), JWPce (be sure to use the ARM "palm" version), Pocket Digital Clock, Total Commander Pocket.

System tweaks

  • Settings -> Personal -> Menus -- Remove Phone
  • Settings -> Sounds & Notifications -> Notifications
    • All Phone and Messaging options -- Disable all sounds/notifications
    • Event: Reminders -- Disable visible calendar popups
  • Settings -> Today -> Items -- Deselect TouchFLO 3D and select Pocket Digital Clock and Calendar
  • Settings -> Today -> Items -> Pocket Digital Clock Options -- Disable seconds display
  • Settings -> System -> Error Reporting -- Disable it
  • Settings -> Comm Manager -> Always keep Phone turned off

I hunted a long time for a (free) program to change button behavior. Dred Sensor had all the power I needed. Using Dred Sensor, I replace all the Send and End button behavior as shortcuts to Calendar and Notepad (similar to how my Palm was setup). I also set a long-press shortcut of one of the buttons to open Comm Manager for quick toggle of WiFi setting.

Copy a pic to the phone, then browse to it and select it, then set it as the background to change its translucency setting (you can't set that from Settings -> Today)

Google Maps is a very nice program, but pretty much requires constant connectivity--something I (thankfully) don't have (to pay for). So to save maps for OpenMobileMaps, first start OpenMobileMaps so it can setup its cache folders. Then download a fixed version of JTileDownloader, browse an area of interest on the OpenMaps site, download the tiles, and copy them into the cache folders on the Diamond.

I haven't yet needed to tweak the registry, but MobileRegistryEditor is my editor of choice.

Transferring Data

I've used HandyShopper on the Palm for years -- it's a brilliant program. Thankfully it's also available for Windows Mobile. Transferring the shopping list is a breeze. Just find the backed up database in %USERPROFILE%\Documents\Palm OS Desktop\<id>\Backup\HS2_Shopping.PDB and simply copy it to the device. Browse to the PDB file on the device and just click on it. Your list is now available on the Diamond.

The biggest issue I had was getting the Palm Note Pad scribbles off the z22. Since Palm all but dropped support for the Palm OS and Windows 7, I had to download their latest (and final) version of the desktop client off their website. Unfortunately that version of Palm Desktop doesn't provide an interface for Note Pad. Forum posts suggested I had to find a computer with WinXP and install the older software that came with the z22 to sync those Note Pad images off the device.

While I still have XP on my lappy, it sure seemed like a hassle -- and what about people who don't have XP anymore? So I turned to Open Source for help. After installing all variations of Palm related software in Ubuntu, nothing seemed to provide a GUI for getting those Note Pad images. Then I happened upon a man page for a command-line tool called pilot-read-notepad. To my surprise, the following command actually worked

pilot-read-notepad --type=png -p usb: > list.txt

After pressing sync on the device, I found myself with all the images exported (some of the note titles with illegal characters had to be tweaked).

Blogging with Markdown

I haven't done much blogging lately, so most of the asciidoc esoteric syntax is gone from me. Meanwhile, I've been using Markdown on a couple of popular web sites. Markdown has come a long way since I first investigated a blogging markup language with code highlighting. There is now a Python module with the built-in CodeHilite extension. This post gave me the confidence that Markdown was ready for primetime.

Here's how I setup my new blogging solution with Markdown*:

  • Install Python 2.5+
  • Download Markdown source code
  • Download Pygments source code
  • Uncompress the Markdown directory
  • Uncompress the Pygments directory
  • From the Pygments directory, move the pygments and external sub-directories into the Markdown directory
  • Apply this patch to the Markdown source files so noclasses configuration is exposted and fenced_code is also highlighted (I'm bummed this patch isn't included in the downloaded source)
  • Download and install the jEdit syntax and Notepad++ syntax files

Now the following command will do the work**:

python markdown.py input.md -o html4 -x "codehilite(noclasses=True)" -x fenced_code -f output.html

I still have to manually create the blog post in Blogger, but then it's just a copy-paste of the html, and I'm done.

* I don't like installing Python modules because I rarely use them--hence the simple uncompressing and use in-place.

** Like with my previous blogging solution, I like the syntax CSS to be inline.