August 30, 2014

Play Child of Light in English on PS Vita

If you want to play Child of Light on PS Vita, you will not only need to download the online update, you will also need to set your system language to English (US). If you have it set as English (UK) then you will continue seeing the game in Japanese.

I know right?

August 27, 2014

From Lyx/Latex to Word

This is sort of a placeholder post. Busy meeting a deadline, but this should help future Steve and anyone else when you need to turn your Lyx document into a Word document while keeping the format mostly sane. Broken, but sane.
  1. Export as Latex (plain).
  2. Run
    • latex <name of tex file, with or without extension>

  3. Run
    • bibtex <filename>

  4. Run
    • latex <filename>

  5. Run
    • latex <filename>

  6. Try to run
    • htlatex <filename> "html,0,charset=utf-8" "" -dhtml/
      • html: format to output
      • 0: normally chapters go into their own page, putting 0 here forces everything into a single page
      • charset=utf-8: let us be civilised
      • -dhtml/: puts the output files in a html sub-directory. Note that you can't have a space between -d and the html/

  7. If the above fails with something like 'illegal storage address', and you get a warning about text4ht.env not been found, then you need to find where it is in your TeX installation, and:
    • export TEX4HTENV and try again
    • Copy text4ht.env into your working directory
      • This approach also lets you affect locally some export parameters. More on this later...

  8. Open the html to verify correctness. You might object to the poor graphics quality. In this case copy text4ht.env into the working directory if you haven't done so, and then modify it so it uses a high density when converting images.
    • See this tex.stackexchange.com answer for more details
    • In my case, since dvipng was been used, I replaced all instances of
      • -D 96
    • with
      • -D 300

  9. It also helps if you
    • strip away html comments
      • These look like <!-- xxx -->
    • centre aligned image divs
    • remove <hr/> instances

  10. These changes will make the import into Libre/OpenOffice go easier

  11. Open the html file in Libre/OpenOffice

  12. File > Export > ODT

  13. Close html file

  14. Open exported ODT

  15. Edit > Links

  16. Select all links

  17. Break Links

  18. Verify that the ODT file is now much larger!

  19. File > Save As > Word 97 (doc)

Phew! To help future visitors, a simple python script to fix up the html as I have described is included at the end of this post. You will need lxml and cssselector installed. Cheers, Steve
#!/usr/bin/env python

from lxml.html import parse, HtmlComment
from lxml import etree

def main(*args):
  if len(args) == 0:
    return 1

  doc = parse(args[0]).getroot()

  body = doc.cssselect('body')[0]

  # replace <hr/> with <br/> to make doc conversion easier
  for hr in body.cssselect('hr'):
    p = hr.getparent()
    p.remove(hr)

    br = etree.Element('br')
    p.append(br)

  # remove comments because for some reason libreoffice opens up 
  # html comments as document comments, slowing things down
  for node in doc.getiterator():
    if isinstance(node, HtmlComment):
      node.getparent().remove(node)

  # centre align all figures
  for div in doc.cssselect('div.figure'):
    div.attrib['style']='text-align:center'

  print etree.tostring(doc, method='html', encoding='utf-8')
if __name__ == '__main__':
  import sys
  sys.exit(main(*sys.argv[1:]))

July 27, 2014

Reading Metadata Out of Nikon NIS Elements Generated TIFFs

Fluorescence image of 
cavitation effects,visualised 
using FITC-Dextran.
If, like me, you use Nikon's NIS Elements to do fluorescence imaging, you would have also noticed that nothing other than NIS Elements can read the metadata that is saved with TIFFs. ImageJ can't read it, the GIMP can't read it, tiffinfo can't read it. This means the only way to recover that metadata, which contains important things like exposure time and pixel size is to open the image in NIS Elements.

This sucks, because NIS Elements isn't exactly easily or widely available, and NIS Elements Viewer doesn't help either - it only opens ND3 files.

Fret not, however. The metadata isn't encoded in any particularly nasty way, and with a little exploration I was able to put together a small python script which will dump out all the relevant information.

Hope this helps someone. It would be nice if Nikon used the standard TIFF tags instead of putting everything in their own tags.

Cheers,
Steve

May 20, 2013

Go Away AVN

So it turns out that if you google vaccination on google.com.au, Australian Vaccination Network (AVN) comes up as the second result, right after wikipedia.

Search results from google.com.au for
"vaccination" as of 20th of May 2013
As some of you may know, AVN is an anti-vaccination organisation, part of the anti-vaccination movement, whose core beliefs rests on a retracted paper published by a doctor who was struck off the UK medical register after been found guilty of unprofessional and unethical conduct.

Vaccination is a corner stone of public health policy, and the only means of protection for the most vulnerable amongst us who are unable to receive vaccinations. Through vaccination smallpox was eradicated in 1979, and no child was ever again killed or maimed by it.

A child with smallpox
Due to the efforts of groups like the AVN however, there has been recent decline in the number of children receiving vaccinations against common childhood whooping cough, leading an outbreak of whooping cough in Queensland, and sadly, the death of several infants.

While the Australian Government is taken action against the AVN, the fact it has such a prominent position in Google's search results is undermining the overall effort. Thankfully this is something you and I can do something about, and that is what this blog post is for: part of an effort to increase the PageRank of legitimate sources of vaccination like



If you have a blog, make a post like this one, google vaccination on google.com.au and click on every result that is NOT AVN.

Cheers,
Steve

December 16, 2012

Un/check all items in iTunes 11


I subscribe to The Moth, and had previously selected all episodes to be sync'd to my iPhone. Recently I found myself short on space, so I wanted to tell iTunes 11 to stop doing that. Previously, it was a simple case of multiple selection in a list and uncheck, but with iTunes 11, it looked like I was going to have to do it all by hand... for over 200 episodes!

By playing around, I found that if you command-click on a checkbox, it has the effect of un/checking all the checkboxes in the list. This made things more manageable.

Cheers,
Steve

October 17, 2012

Unknown control sequence \doublespacing

If you are getting the error
"Unknown control sequence: \doublespacing" when you try to compile your 
beamer presentation in Lyx, change
Document→Settings→Text Layout→Line spacing 
to Single.

Cheers,
Steve

September 14, 2012

Notes On Running Calibre On A Server

Calibre is a great tool, especially for converting between ebook formats. Here are some notes for getting it to run on a headless server.
  • The binary installer off the website works fine — ignore warnings about completion and desktop integration failing.
  • The installer will always pollute /usr/bin regardless of the installation directly you choose.
  • You will need the following libraries for mobi conversion:
    • libxi6
    • libxrandr2
    • libxfixes3
    • libxcursor1
  • If you get this message
    • SVG rasterizer unavailable, SVG will not be converted
    • You will need to install xvfb and use xvfb-run, like so:
xvfb-run ebook-convert blah.epub blah.mobi

Cheers,
Steve

Nook vs Kindle

Definitely the Kindle. Amazon offers an amazing service, especially their personal document service's email feature. That is simply divine. Furthermore, Amazon isn't nearly so annoying to use as a non-US citizen. I don't have to use a trick credit card or proxies to purchase ebooks. Amazon just sells them to me, easy peasy.

Disclaimer: I have a first generation Nook and a Kindle Touch. My comments above are however entirely based on the services provided, not the devices themselves. So this is probably more appropriate as Barnes and Noble vs Amazon.

Cheers,
Steve

August 28, 2012

Thoughts on The Design of SPOT2 GPS




  1. I love the fact the screws holding down the battery cover has little flip up handles so you can turn them with just your fingers, and that they are set so that they don't fall out once loosened. This is top quality design. However, the battery compartment door is not attached to the unit, and it should be, so there is no risk of losing that. Admittedly, it is pretty hard to lose something that is fairly large and orange
  2. Somewhat more importantly, the SOS button should be hooked into the power button, in the sense that if you press and hold the SOS button, it turns the device on and goes into SOS mode. As it is, activating SOS is a 2 step process, requiring you to first turn the device on.


Cheers,
Steve

August 23, 2012

Jumpcut is dead. Long live Jumpcut




I used to use Jumpcut a long time ago, and was a big fan of it. At some point, I think around 10.5, it stopped working, and I let it go -- too busy at the time to poke at it.

Recently however my interest in it was piqued again, and downloaded the 0.63 source. To my great delight, it compiles just fine, and once recompiled, works perfectly. Score one for good programming and open source!

If like me you have given up on Jumpcut, it is time to add this nifty utility back to your toolbox.

Cheers,
Steve

P.S. If you don't have access to Xcode, or the idea of compiling a program sounds like a bit too much, drop me a line at freespace *at* gmail.com and I will make my copy available.

August 22, 2012

Acorn vs Pixelmator

Pixelmator wins hands down. Compared to Pixelmator Acorn is anaemic in terms of features and costs more than twice as much.

Disclosure:  I originally got Acorn as part of MacHeist, so I didn't pay full price for it. I did pay full price for Pixelmator.

Cheers,
Steve

August 18, 2012

Converting Excel 1.0 Files On OS X (or some other OS)


  1. Download SheepShaver
  2. Download "New World PPC ROM" from redundantrobot.com
  3. Extract the zip. This should produce newworld86.rom. Rename this file to ROM and put it in the same directory as SheepShaver.app
  4. At this point SheepShaver.app should run, showing you a folder with a blinking ? inside it
  5. Download "Mac OS 9 Boot Image (120 megs)", again from redundantrobot.com
  6. Unzip the downloaded file. This should produce OS9.img
  7. Access SheepShaver's Preferences, and add OS9.img to Volumes. Hit Save and restart SheepShaver
  8. SheepShaver should now boot into OS9. Ignore the warning about virtual memory
  9. On the desktop, there should be a Unix drive. This is your Mac's system volume. All your files can be accessed through this.
  10. Download Excel for Mac archive from Macintosh Garden
  11. Unzip, this should produce Microsoft Excel folder, inside you will find 5 versions of Excel
  12. Navigate to this folder OS9, and enter Excel 4.0 Folder
  13. Run Excel, and navigate to your Excel 1.0 files.
  14. Open each file, then save it again using Normal Format which is just Excel 3.0. Probably a good idea to add xls to avoid overwriting the original.
  15. Open the converted Excel 3.0 file in modern Excel. Microsoft Excel for Mac 2011 is capable of opening Excel 3.0 files.
At step 14 you might run into a problem I faced: Excel simply won't see any of the Excel 1.0 files! The problem is that Excel is using extended file attributes to determine which files it can open. On less sophisticated systems this is done via file extensions.

To see this, if you copy COMMANDS file out of Excel 1.03's sample directory (you have to convert the image first using Disk Utility), and run xattr on it, you will see this:

$ xattr COMMANDS 
com.apple.FinderInfo

Content of com.apple.FinderInfo is:

$ xattr -px com.apple.FinderInfo COMMANDS
58 4C 50 47 58 43 45 4C 01 00 00 00 00 00 00 00
00 00 00 00 00 00 00 00 00 00 00 00 00 00 00 00

This is the magic you need. Suppose you had a Excel 1.0 file called foo, you add this extended file attribute as follows:

$ xattr -wx com.apple.FinderInfo "$(xattr -px com.apple.FinderInfo COMMANDS)" foo

After doing this foo should show up in Excel inside ShavedSheep.

If all this sounds like too much for you, send me an email at freespace _at_ gmail.com with subject of "Excel 1.0 Conversion".

Update

An alternative to using Sheep Shaver and OS 9 is to use Mini vMac and System 6. This will let you run Excel 1.0.
  1. Download Mini vMac
  2. Download "Mac Classic ROM" from redundantrobot.com. Extracting the zip produces vmac.rom which is incidentally the exact filename Mini vMac expects
  3. Follow these instructions to get System 6.0.8 running
  4. Drag-n-drop the Excel 1.0 program img file (see above) directly into Mini vMac. You will now have access to Excel 1.0
  5. To get a read/writable disk, create a dmg in Disk Utility. Drag-n-drop this into Mini vMac and you will be asked to initalize and format it. Do so, and then drag-n-drop Excel into this new read-writable disk.
  6. Do your conversion, shutdown Mini vMac
  7. Open the dmg, and it should mount, despite having been initalized and formatted by System 6.0.8 -- backward compatibility for the win
Mini vMac is not as powerful as Sheep Shaver, and System 6.0.8 is as much as it can handle. It is however much smaller and easier to use than Sheep Shaver, and for the purpose of converting Excel 1.0 to a more manageable format is more than sufficient.

Note that you might need to do the xattr trick above.

Cheers,
Steve