Tuesday, 23 June 2015

Bootcamp, a late 2010 Macbook Air, Win 8 Pro, an SD card, and a SL of BS

Bootcamp does not agree to my custom, partitioned drive.
Depending on the target version of windows, running from an SD card may be possible (see Vanderi's blog).

Backing up everything.

Using disk utility, I un-partitionned without re-installing OS-X (Select the HD, go to the 'partition' section then remove all but the boot partition and recover unused space).

Bootcamp is asking for an optical drive. I want to install windows from my SD card. This is only a warning. Ignoring it (for now).

Next it's complaining that I don't have USB drive plugged in. Confusing but, actually, bootcamp is trying to download drivers needed to run windows on my Mac.
Let's get a USB drive.
Needs to be FAT formatted.

Bootcamp tells me that it can download drivers for Windows 7. Pity, because I don't have that, which MS aren't selling anymore. No support, no problem (says Ars Technica)? Apple's compatibility chart insists that I can't.

Success story installing Win7 then upgrading.

Bootcamp is being pissy about my Windows install files sitting inside an SD card. Apple confirm it's not okay.

Maybe I can install windows 8 without Bootcamp. Software 7 blogged about it.

Windows wants NTFS but all we can make is a FAT partition, which is fine.
Back to Disk Utility let's make a FAT partition.
I now have a FAT partition, Wakugumi.

Looks like I might get a chance to install Win 8, if I hold down the option key at restart, and should expect a bumpy ride.

Nice, except it doesn't work. Proposed solution. Oh wait. Look here. And... well. After trying everything else, what worked for me was simply to make some "free space" instead of creating an actual FAT partition with Disk Utilities. Then start installing windows, and create the partition using the provided interface.

Software 7 suggests a patch to improve stability; I didn't wait to verify whether it was stable or not, I applied the patch.

Software 7 signal other issues; to mitigate this I tried running my Bootcamp drivers. The top exe refuses to run outright but I was able to run a batch of semi-randomly selected drivers, which somewhat improved the behaviour of the track-pad. Apparently it used to be possible to download the Win 8.x drivers without fuss (meaning, from Apple), no longer. Got them from a free DL site. Still waiting. Oh wait... can still download them from Apple.
  • Track-pad not working. Works better now but still no 2 fingers scroll.
  • Can't adjust volume and brightness. Not solved. My display is bright, and there is no sound.
Downloaded 8.1 Bootcamp drivers. Driver won't be fooled, still doesn't run. I can selectively install device drivers.

Upon restarting, Windows indicates that the 'PC' needs repairing, undoes all my changes, reruns minor installation cores.

From there...
  • Using BootCamp5.1.5621 as downloaded from Apple
  • Installed AppleMultiTouchTrackPadInstaller64 otherwise trackpad is really sluggish. Even after installing this, you still have half of a trackpad running with no scrolling gesture, no right button. Suggestions here.
Searching, I found useful suggestions:
  • Bypass bootcamp's compatibility check
  • Run bootcamp in Windows 7 compatibility mode
  • Run with enough privileges.
Bypassing compatibility checks and running with sufficient privileges is explained here and here's a little more details:
  • Don't run via 'Setup'. Instead, run via BootCamp\Drivers\Apple\Bootcamp (depending on your package this may be called BootCamp64 or similar)
  • You can disable the compatibility check by running "trouble shoot compatibility" in BootCamp context menu.
  • Run the suggested command via cmd.exe.
I tried this with drivers downloaded from apple, and I tried this with the Windows 7 drivers downloaded via bootcamp. A clean re-run appeared to work fine initially. That is, until I accidentally closed the MBA's lid while installing Visual Studio. Following this, the MBA rebooted and Windows went into repair mode.

Sunday, 14 June 2015

MultiSub

In July 2014 (one year ago!) I did a little work on a sub multiplexing application. Its purpose is very simple and practical: allow viewers whose native language differs to share subs on a single screen.

Finding Chinese subs

Finding Chinese subtitles has become difficult since shooter.cn went down (but see here). Downloading subs in a foreign language is a roundabout routine anyway.

  • Often, I need to find the name of the movie in its original language.
  • Go to Wikipedia zh, searching the film's original title. This is to retrieve the Chinese name.
  • I use subhd.com to find Chinese subtitles. At the time of writing it looks like subhd.com doesn't support Safari anymore.
  • There are a few subtitle formats around. I use Jubler to convert from substation alpha (*.ass, *.ssa) to SubRip (*.srt).
  • I often process videos in *.mkv format. One problem with this is that subs are baked into the mkv file. On OS-X I use MKVToolNix via homebrew. Once installed, in terminal (this is a command line tool):

    mkvinfo FILENAME.mkv

    => sift through the output to get the subtitle track index and the encoding (often, *.ass or *.srt)

    mkvextract tracks "FILENAME.mkv" TRACK_INDEX:OUTPUT_FILENAME.xxx

    => self explanatory?

Combining subs

Trivially, my utility parses the sub lists, merges, re-indexes. My player (VLC) manages overlaps gracefully. It would be cleaner to do this while merging the subs, but it's a lot more work.

A user interface

Today I built a trivial user interface for multiuser. Took 2 or 3 hours I guess; it is very, very simple.

Plans

I guess I'll try to submit MultiSub to the mac app store. Since I'm not planning on selling it, I could also make it available on free download sites.


Wednesday, 10 June 2015

Squashing: the destructive workflow (git/github)

A while back I attempted my first contribution to an open source project on github. 21 commits laters I was asked to squash them (my commits) to clean things up.

You can do it the right way. But then again, you might not want to. After all, it's a stupid ass pain: modal, raises non-existent merge conflicts, knows better than you do, never heard of user control, wants you to use vim or emacs.

Why do it?

Information hiding. What's 21 commits for me should be an atomic change for the rest of the team.
Since git doesn't have a concept of private/public commits, or whatever non-destructive solution you might come up with, we are stuck with a revisionist, unsafe, destructive approach to collaboration.

Before we start

At some point you may wish to revert local changes. Sadly "revert local changes" can mean a whole bunch of stuff from git's revisionist perspective. See here.
We are trying to collapse a bunch of commits into a single, unique commit, so, in this case, "revert local changes" maps to:

git fetch
git reset --hard origin/master

This will reset clean to your latest remote.

Hint: if you have been rebasing over and over while working on your branch, the number of commits you want to squash is less than the number of commits on your branch. Check the commit history to distinguish your commits from others'.

Squashing without squashing

I'm assuming that all your changes are already committed. One of the methods explained here shows how to non-interactively 'squash' N commits:

git reset --soft HEAD~N 
git commit -m "shiny new commit"
git push -f

Where "N" is the number of commits to squash. Done 21 commits, want a single commit instead? N = 21.

Tip: calling reset HEAD~1 twice is equivalent to reset HEAD~2.

I gather that...
  • "git reset --soft" rolls back our commit number to 'N before now' but without actually changing local files.
  • "git commit..." commits changes locally, with the specified commit message.
  • "git push -f" (so called force push) tells the server to discard previous changes, replacing them with the latest local commit.
No love lost on the git workflow.

Sunday, 7 June 2015

Do not represent an object's life cycle using enums

Avoid 'summarising' the state of an object using enums.

While it is often convenient to idealise an object's life cycle as a linear sequence of states, such representations are inherently inaccurate and fragile; over time they become a source of bugs.

The OOgtech blog, archived

From 2009 to 2013, I ran a game dev blog covering a variety of topics, from OpenGL to agile game development.
You can still find it using way-back machine.

The OOgtech blog

I will refresh my best articles and put them on this blog.

Tuesday, 2 June 2015

Git and Github: setting up to work on an open source project.

In order to test Git and Github, I created a repository, apqa, featuring a nice vector/math library I wrote a while back.

From a project's owner point of view, committing changes is trivial. However, I am exploring Github from a contributor's point of view.

So, after I created my repository and logged a couple of issues, I logged in as a different user and let's get to work.

Setup: Fork, clone and sync.

[web interface] Fork to create a copy of the target repository on the Github server. Said new copy is linked to your github account.

[web interface] Clone your copy of the repository. This creates a copy inside your local machine.
!!! for this to work, you need to download install github's desktop front end and you should be logged into your user account in both the front end application and the web interface.

[command line] cd to your copy of the repo, then:

 git checkout master
 git remote -v
 git remote add upstream https://github.com/ACME/REPO.git
 git remote -v

And the reply to the latest command should be something like.

 BVLC  https://github.com/ACME/REPO.git (fetch)
 BVLC  https://github.com/ACME/REPO.git (push)
 origin  https://github.com/MY_COMPANY/REPO.git (fetch)
 origin  https://github.com/MY_COMPANY/REPO.git (push)
 upstream https://github.com/BVLC/REPO.git (fetch)

 upstream https://github.com/BVLC/REPO.git (push)

[command line] to update master to the latest changes:

 git fetch upstream
 git checkout master
 git merge upstream/master

References