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/2009

Java 1.6 on a 32-bit Core Duo Mac

I have a first generation Macbook Pro (Core Duo 2.0 GHz, 2.0G, etc) with Mac OS X 10.5.X. It's a really nice machine and has held up well for the past couple of years. It works beautifully.

Everything works well, except Apple doesn't support Java 1.6 on 32-bit Intel Macs, which applies to the Core Duo. My primary skillset, (other than UNIX/Linux), revolves around Java. I admit, I was about to sell my laptop and head to the Apple Store, when I found a few links that can ease the pain.

I found a link on Tomas Varaneckas', (Paranoid Engineering), blog about SoyLatte, a Java 6 release for Mac OS X based on a FreeBSD patchset.

I am going to assume you have basic UNIX command knowledge. I opened a Terminal, and changed to the JavaVM.framework/Versions directory.
cd /System/Library/Frameworks/JavaVM.framework/Versions/
I uncompressed and extracted the files from the intel 32-bit soylatte*tar.gz archive.
bunzip2 -c ~/Downloads/soylatte16-i386-1.0.3.tar.bz2 | sudo tar xvf -
I renamed 1.6/Home to 1.6/Home.bak and symlinked the soylatte directory to 1.6/Home.
sudo mv 1.6/Home 1.6/Home.bak
cd 1.6
sudo ln -s ../soylatte16-i386-1.0.3 Home
There is general information in the links above for how to use the SoyLatte JDK. I use IntelliJ Idea and Eclipse for Java development. I simply point the IDE configuration to the 1.6 directory to add the JDK.

8/25/2008

Pasting Unformatted Text in Word by default


As I was editing a document today, I was reminded by how much I despise the operation of <ctrl>-<v>, (paste), in Microsoft Word. Key shortcuts for paste (<ctrl>-<v>) will always paste Formatted Text. But 99% of the time, I want unformatted text. Even if I wanted formatted text, what are the odds I would want to use the same format in the new document as what is in the clipboard?

Unfortunately, the approach I ended up with involved adding a Macro and assigning <ctrl>-<shift>-<v> as the key shortcut.

1. The link below has more on adding a macro to Office. I added mine to the Normal.dot template, which might cover all documents, as it's the default template type.
http://www.gmayor.com/installing_macro.htm

2. The following link as the code for a macro to paste unformatted text from the clipboard.
http://en.allexperts.com/q/Microsoft-Word-1058/Pasting-unformatted-text-default.htm

3. Assign a key shortcut. I recommend <ctrl>-<shift>-<v>.
http://misterslimm.wordpress.com/2007/07/17/microsoft-word-paste-special-as-unformatted-text-keyboard-shortcut-2/

You should now be able to use <ctrl>-<shift>-<v> to paste unformatted text!