Monday, November 18, 2013

How to print a large image on multiple pages, using Python!

I recently received a high-resolution image of a famous historical figure (details to come soon...). Naturally, my roommates and I wanted to print this famous person out and create a life-size cardboard cutout. Since I only have the capability to print on standard 8.5 x 11 inch paper, I needed a way to split the image onto multiple pages to print.

I found web-based tools that can do this, or you could use Photoshop or some other proprietary software, but I didn't find any good tools I could use on Ubuntu to maintain resolution. I whipped up a Python script that can do this, relying on the Pillow implementation of PIL (Python Image Library). You can download it from Github. Feel free to submit pull requests if you flesh it out further, as it is rather basic right now (it's licensed under GPLv3).

Tuesday, May 21, 2013

Installing Ubuntu 13.04 Raring Ringtail on a MacBook Pro for Dual Booting

I recently installed Ubuntu onto my MacBook alongside OSX for dual booting, and learned a few lessons throughout the process. Below are the steps that I took. I have a MacBookPro 8,1 but these instructions might be applicable to other models as well. Be sure to also read the "official" Ubuntu installation guide. I also found a post by James Jesudason to be helpful.

These instructions are fairly sparse, but should help point you in the right direction if you are less experienced with any of the steps.

  1. Reduce partition size in the OSX "disk utility" tool. I dragged the partition size until I had enough free space left on the disk for my Ubuntu partition (I wanted 50gb but less should be ok). This took several hours.
  2. Install the rEFInd boot manager. I downloaded the most recent binary file (0.6.11) and ran, which worked without any other options. rEFInd was installed into the /EFI on my root filesystem.
  3. Install the ext4 driver in rEFInd. The driver is packaged with the binaries, but must be copied into /EFI/refind/drivers in order to be active. I had to create the drivers directory in /EFI with "sudo mkdir /EFI/refind/drivers" as it did not already exist. I then copied (as root) "ext4_x64.efi" from refind-bin-0.6.11/refind/drivers_x64 into the newly created drivers directory.
  4. Load the Ubuntu installer CD (must be the special Mac version of Ubuntu - labeled on that page as "64-bit Mac (AMD64) desktop image"). Instead of choosing to install Ubuntu, choose to try it out instead. Open up a terminal and run "ubiquity -b" and then proceed with the installation. Running with the -b flag tells Ubuntu not to install a bootloader, which won't be necessary as rEFInd can boot a kernel directly. During the install process, the default option should be to install in the disk free space, but you should verify this. I chose to manually create an ext4 partition for my root mount point and a 2gb swap partition instead of using the automatic option.
  5. After the installation finishes, select the option to continue to try Ubuntu. In the terminal, run something like "sudo blkid /dev/sda*". Look for the UUID corresponding to your Ubuntu root mount point.
  6. With Ubuntu still loaded off the LiveCD, find the /boot partition in your new install. This should probably be mounted somewhere in /media. In /media/.../boot, create a file called refind_linux.conf. Save the below options (from the rEFInd documentation), replacing the UUID with the one you noted in the last step corresponding to your Ubuntu install, into this file
    "Boot with standard options" "root=/dev/sda3 ro quiet splash vt.handoff=7"
    "Boot to single-user mode"   "root=UUID=1cd95082-bce0-494c-a290-d2e642dd82b7 ro single"
    "Boot with minimal options"  "root=UUID=1cd95082-bce0-494c-a290-d2e642dd82b7 ro" 
  7. When you restart, Ubuntu should automatically be detected and available to use in the rEFInd boot menu. You can make it the default boot option by setting default_selection in /EFI/refind/refind.conf accordingly
I modified these steps slightly from the ones that I took, so please let me know in the comments if you run into any problems. Hope this helps!

Tuesday, March 19, 2013

March madness python bracket generator

I created a simple python script to read in Nate Silver's march madness predictions and generate random brackets based on his given probabilities. This will give a diverse, non-deterministic, set of potential brackets as results. You can also run the simulation until you get a desired champion.

If you are interested in the script, it is available on GitHub.

Go bears...hopefully
Creative Commons License
Except where otherwise noted, content on What's Life by Kyle Barlow is licensed under a Creative Commons Attribution-ShareAlike 3.0 Unported License.