Making Latex work with Anki

Been using Anki for years without realizing it could leverage Latex equations, so I installed MikTex (if you know better and smaller Latex distributions for Windows please let me know) and was unfortunately greeted by the following error “dvipng: GUI framework cannot be initialized.”.

The solution is simple but was not well explained anywhere.

1. Go to your miktex bin folder (in my case C:\Program Files (x86)\MiKTeX 2.9\miktex\bin)
2. Right click mo_admin.exe and run as admin
3. In the General tab, switch “Install missing packages on-the-fly:” to “No”
4. Click OK

Et voila! Nice Latex equations in Anki

Downloading APKs directly from Google without installing them

One of my too many hobbies is to tweak, improve and customize the firmware of some of my android devices. This often results in having to reinstall all the applications I like to have on a given device. It is possible to perform and restore backups but clean installs can be better when you are dealing with stability issues.

APK Downloader used to be a great website, but it has not worked for a while. I decided to look into alternative and found a simple PC program allowing you do to something similar. It is called APK Leecher and works really well. I recommend creating a dummy Google id to ensure you are not leaking your personal information, but so far it has worked great for me.

Connecting your Nexus 7 FHD (2013) on a HDMI display

To connect your Nexus 7 FHD to your TV or monitor using an HDMI cable, you need a Slimport cable that you connect in the micro USB port of your Nexus 7 FHD on one end, and to your HDMI cable on the other hand. Do NOT buy a cheaper MHL cable which will not work; I had a couple of those at home for other devices and none of them worked with the Nexus 7 FHD.

Some people report prices above $50 in some cases for a Slimport / Micro USB cable, so decided to look into it and found much more affordable alternatives like this Slimport MyDP Micro USB to HDMI HDTV for under $13 including free shipping and taxes.

I have received and tested this cable with my Nexus 7 FHD, so I recommend it. Beware it takes a while for the Nexus 7 to start outputting video when you first connect the cable (took me over one minute the first time).

If you find a working and even cheaper alternative, please let me know.

Running OSX through VirtualBox within Windows 7 environment running Bootcamp

I have a great MacBook Pro with awesome retina display, but I mostly run Windows 7 on it through bootcamp. Given that I often have to make iOS related tests, and that switching back and forth between OSX and Windows 7 was quite painful, I decided to try to run OSX as a virtual OS within Windows instead of Windows as a virtual OS within OSX.

If you want to do the same here are the simple things you need to do

1. Open regedit to export a backup of HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\AppleHFS and HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\AppleMNT
2. Keep regedit opened and delete HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\AppleHFS and HKEY_LOCAL_MACHINE\SYSTEM\CurrentControlSet\services\AppleMNT
3. Reboot and make sure the OSX drive is not visible anymore as D: drive
4. Run in command line “C:\Program Files\Oracle\VirtualBox\VBoxManage.exe” internalcommands createrawvmdk -filename c:\RawAppleDisk.vmdk -rawdisk \\.\PhysicalDrive0
5. Open VirtualBox, create a new type “Mac OS X” with version “Mac OS X (64-bit)” virtual machine.
6. When asked to create a drive, select “Use an existing virtual hard drive file” and click the orange folder button, select the RawAppleDisk.vmdk that you created in step #4, it should be at the root of C: but you can move it anywhere you like before adding it to the virtual machine.

Et voila! Now your virtual machine should boot and run OS X as a virtual OS within Windows 7 running native on genuine Apple hardware :)

You can learn more about VirtualBox guest limitations for OSX here. And how to change the guest screen resolution here.

Extracting Javascript From PDF, and Replacing Javascript Into PDF

Not being able to find easy to use tools to extract the javascript code contained in a pdf file in plaintext, nor tools to update the javascript in a pdf without changing anything else. I wrote those two small command line java tools using the excellent iText library.

PDF2JS will extract the javascript from the pdf passed as argument. On windows an example way to use it is: “java -jar pdf2js.jar myinput.pdf”, and it will output the javascript in myinput.pdf.ps.

JS2PDF will replace the javascript in the input pdf file, and write the result into the output pdf file. On windows and example way to use it is: “java -jar js2pdf.jar original.pdf javascript.js output.pdf”, the file output.pdf will contain the updated javascript.

For those interested the very simple code for each tool is provided within the archives.

Also if the pdf file you are working with has usage restrictions, make sure you remove them using the excellent qpdf with the following command line: qpdf –decrypt protected.pdf output_unprotected.pdf

Impressive archiver with high compression rates: NanoZip

I have been using 7-zip for years as my default archiver, it is fast, it unpacks zip and rar files, and compresses into .7z files much smaller than similar zip or rar archive.

However, I just discovered NanoZip which although in early alpha is truly outstanding with decent compression speed and much smaller files than 7zip. So head and shoulders above zip and rar. The interface is still clunky but if you have an urgent need to fit more data into a small amount of space try NanoZip.

For more info check CompressionRatings.com and MaximumCompression.com.

Using Eclipse as IDE and Debugger for Python

Having decided to clean-up my machine, I had to find a solution for the Python mess. Having Eclipse for Java and C++, I decided to give it a try for Python.

Here are some of the benefits I found:

1. You can reuse the dev environment without additional install
2. Eclipse with PyDev is a unified IDE and debugger
3. It is a familiar environment
4. You can use both Python 2.x and 3.x for different projects in your workspace
5. Download and disk footprint are smaller than the best alternatives
6. It is super easy to install and use

Here are the simple steps to install:

1. Run Eclipse, go to Help menu, and click “Install New Software…”
2. Click the “Add” button, enter “http://pydev.org/updates” in location and click OK
3. Select PyDev, click Next and follow the install steps accepting the licence

Here is how to make a simple Python test project

1. Go to File menu, click New then PyDev Project
2. Enter your project name, select the grammar version, and interpreter. If you have not set up any yet, just click “Click here to configure an interpreter not listed”, click New, browse to your python.exe directory and click Ok.
3. Right click your project, then New, then Source folder
4. Right click your source folder, then New, then PyDevModule

Lightweight and free alternatives to iTunes for Windows

I love Apple products but iTunes has to be one of the worst piece of software I ever used on Windows. So I decided this week-end to find free alternatives, and I am glad I did.

1. Install iphone/ipod drivers without installing itunes with CopyTransDrivers. This will still require you to download iTunesSetup.exe but it is capable of extracting and installing only the drivers.
2. Use CopyTransManager to manage your playlists and copy music on your device
3. Use iFunBox to add data files to your apps

Enjoy your uncluttered machine now :)