6/11/2012

Extracting the JDK from Oracle's Windows installer .exe

The Oracle JDK downloads for Windows are only offered as EXE files, or install executables.  Unfortunately, for some of us, we don't want to install because we want to develop with more than one version and/or we do not have the rights on our computer to install software.

1. Install 7zip.  Open the installer EXE in 7Zip File Manager, either by using Open with... or changing the extension of the file to .7z.

You can browse the file in 7zip by using Open Inside.  Browse through the exe until you find two files, src.zip and tools.zip.  Extract those to a directory you want to store the JDK in.

2.Unzip only the tools.zip file.  Leave the src.zip file as-is.  Once the tools.zip is unzipped, you'll notice that all of the normal JDK files are there.  Or, at least, almost.

3. Look for any files that end in .pack and unpack them to .jar.  The bin directory that was just unzipped from tools.zip has a utility called unpack200.exe.   Use this to unpack the pack files to jars and you are done.

Set your JAVA_HOME to the new directory when you want to use it, and it should work fine.

Note: I'll pretty this blog entry up later.

4/13/2011

Macbook Pro 1,1 Battery Woes

I still get 45 minutes or so out of my 4+ year old battery. However, the one I bought to replace it, about 18 mo ago, it's now a brick. The worst value I've ever gotten out of a battery (33 cycles), and it started failing just around 13 mo, (right outside warranty). I just didn't realize it, and the mac didn't warn me, yet it's been telling me for 2 years to service my original battery. I dare Apple to give their batteries an 18 mo warranty.

Any tips on rebuilding it myself or a 3rd party that makes something reliable? I'd only get 2+ hours out of a new one anyway, since my mbp is the first gen.


Original Battery from late 2006:

Model Information:
Manufacturer: Sony
Device name: ASMB012
Pack Lot Code: 0003
PCB Lot Code: 0000
Firmware Version: 102a
Hardware Revision: 0400
Cell Revision: 0303
Charge Information:
Charge remaining (mAh): 2934
Fully charged: Yes
Charging: No
Full charge capacity (mAh): 3043
Health Information:
Cycle count: 99
Condition: Check Battery
Battery Installed: Yes
Amperage (mA): 0
Voltage (mV): 12331

Replacement battery from mid-2009:

Model Information:
Manufacturer: Sony
Device name: ASMB012
Pack Lot Code: 0001
PCB Lot Code: 0000
Firmware Version: 0110
Hardware Revision: 0500
Cell Revision: 0303
Charge Information:
Charge remaining (mAh): 0
Fully charged: No
Charging: No
Full charge capacity (mAh): 0
Health Information:
Cycle count: 33
Condition: Replace Now
Battery Installed: Yes
Amperage (mA): 0
Voltage (mV): 6505

4/10/2011

Learning Ruby with Ruby Koans

I've gotten through more than half of the Ruby Koans in the past few weeks. Around the 174th test, the developer is asked to implement a method that solves a trivial problem. I would have liked to make the solution more simple, but this is what I could come up with, based on my current Ruby skill level.

# Greed is a dice game where you roll up to five dice to accumulate
# points.  The following "score" function will be used calculate the
# score of a single roll of the dice.
#
# A greed roll is scored as follows:
#
# * A set of three ones is 1000 points
#
# * A set of three numbers (other than ones) is worth 100 times the
#   number. (e.g. three fives is 500 points).
#
# * A one (that is not part of a set of three) is worth 100 points.
#
# * A five (that is not part of a set of three) is worth 50 points.
#
# * Everything else is worth 0 points.
#
#
# Examples:
#
# score([1,1,1,5,1]) => 1150 points
# score([2,3,4,6,2]) => 0 points
# score([3,4,5,3,3]) => 350 points
# score([1,5,1,2,4]) => 250 points
#
# More scoring examples are given in the tests below:
#
# Your goal is to write the score method.

def get_score_for_matching_roll(potential_roll, dice)
single_scores = {1=>100, 5=>50}
  triple_score_multipliers = {1=>1000}
  single_scores.default = 0
  triple_score_multipliers.default = 100
  triples_singles = dice.find_all { |roll| roll == potential_roll }.size.divmod(3)
  triples_singles[0]*triple_score_multipliers[potential_roll]*potential_roll +
          triples_singles[1]*single_scores[potential_roll]
end

def score(dice)
  # You need to write this method
  score = dice.uniq.inject(0) { |score, potential_roll|
    score + get_score_for_matching_roll(potential_roll, dice)
  }
end

3/16/2011

Adobe Flex Development - Personal Retrospect

I occasionally start small projects for friends or family. I intentionally use technology I have not used before in order to learn new things. The client gets something, I learn something new. It's nice also, because it forces me to finish the projects.

Last year, I started writing a small application using the Adobe Flex SDK, (version 4, even though it was just beta when I started). The app simply streams audio and flips slide images, a Flex/AS3 component, or a customizable automatically-generated questionnaire/quiz at defined timestamps. All of this is configured through a reasonably small XML file, all via the network.

The first problem I ran into was finding a decent development environment. Adobe's Flex Builder, (based on Eclipse, now called Flash Builder), had few nice features but also some things I couldn't live with. For what it provided on top of basic Eclipse, which was almost nothing, the price was robbery.

Problems with Flash Builder 4
  1. It hid some of the build details too much. Flash Builder provided almost no help in writing an appropriate build/ant file. Since I wanted to be able to build from the command-line, it was not very useful to me. Lesson: Don't expect Flash Builder to jumpstart you if you are a power user. Once you leave the dock, you'll need to paddle.

  2. Flash Builder had no source code formatting for ActionScript, other than automatic indentation as you enter it. I don't want to spend my time formatting all of the code. I found several options, the best of which was a plugin for Eclipse/Flex Builder. However, they were all based on older versions of Flex and ActionScript 2, which had significant changes in Flex 4 and could not be used. Lesson: I am sure they will support this, if Flash Builder 4 doesn't already support it in the current build, because without source formatting (i.e. you just refactored and indentation is no longer consistent), development is annoying.
Alternative Flex Editors

After several hours, I realized that my favorite Java IDE, Intellij Idea, supported Flex files. It even provided Source Code formatting for ActionScript 3. Since I had to write the build scripts/xml anyway, Intellij Idea turned out to be the ideal environment. As a mac user, TextMate is also pretty good, but at the time, still no easy source formatting for the latest ActionScript was available.

I was pretty surprised that IntelliJ was the best option, for Flex 4, at the time. I could debug, build, format source, run tests. I had more functionality from a third party, for a fraction of the price, than from the vendor alone.

Problems with Flex 4, ActionScript 3

As if tracking down suitable development tools wasn't time-consuming enough, there are several traps in Flex/ActionScript that make the experience a little more bitter for a newcomer.
  1. Many calls in ActionScript are asynchronous and have to be designed with concurrency in mind. The problem is that it's not always completely clear which calls are async. You can safely say that IO calls, such as HTTP and File requests, are async. Many things that I expected to be synchronous, (next line of code doesn't execute until the current line is done), were async, due to one or more of their dependencies being async. Lesson: Just use events (callbacks would be better) as much as possible. I got much better at this, but even examples in Adobe's live docs, (the main cause for my headaches), were only applicable in certain cases and very misleading.

  2. I hit a few bugs, where certain features I was using could only be called in certain ways, not in all of the ways shown in the docs. And that was fine when I was using the beta SDK. But in the fall of 2010, when I finished up, Flex 4 was released, I expected less issues. Lesson: Stay glued to the forums. Unit Test your code.
Summary

I don't have many issues anymore, although I still use Idea to develop instead of Flash Builder. My experience was a first impression. I mostly got over the language, SDK problems, much of it my own design errors. But Flash Builder needs some serious improvement.

As simple as my app was, I think it had a few aspects that forced me out of my shell and it didn't give me a server backend to depend on as much, as the client is (capable of) doing more. It's quite possible that I was a tad ambitious for a first app.

Unfortunately, I waited months to finish this post so I'll have to come back with the specific bugs/issues with the language, after reviewing my notebook.

3/25/2009

MacHeist

Essentially, MacHeist is a yearly Mac-themed software event. It starts out with some puzzles, or missions and ends with release of a bundle of shareware for the Mac, for a cost of around $40. A percentage of the bundle sales goes toward charity and some bundled apps are only unlocked after a certain sales target is reached.

The missions are time-sensitive challenges. Each mission, or nanomission, has a briefing with clues on how to proceed. To follow the clues, you may have to decode a cryptogram, solve a puzzle or riddle, or even overlay images to find a hidden image.

Fortunately, forums provide a way for people to interact as they progress through the missions and allow users to help each other when they get stuck. The missions for 2009 were very well produced. I enjoyed them much better than previous years.

At the end of each (nano)Mission, users receive loot, i.e. one or more free apps.

After the missions are over, a bundle is released. The bundle usually contains a couple of decent applications and several okay apps, but all-in-all it's a reasonable deal.