2.12.2010

Java Puzzler: Initialization

What does the following print? (Update: Sub extends Super)

public class Super {
  static { System.out.println("super static"); }
  { System.out.println("super instance"); }
  Super() { System.out.println("super constructor"); }

  private static class Sub extends Super {
    static { System.out.println("sub static"); }
    { System.out.println("sub instance"); }
    Sub() { System.out.println("sub constructor"); }
  }

  public static void main(String[] args) {
    System.out.println("start");
    new Sub() {{System.out.println("anonymous instance"); }};
  }
}

9.15.2008

synergyc startup

i've been using synergy lately to share a keyboard and mouse between a linux box and my macbook. for whatever reason, synergy was crashing in daemon mode and i really hated keeping a terminal window open just to keep it running. so, with the help of lingon and launchd, i devised a nice solution that causes synergyc to launch in the background every time i login.

all you have to do is place the following snippet in ~/Library/LaunchAgents/net.sourceforge.synergy2.synergyc.plist:

<?xml version="1.0" encoding="UTF-8"?>
<!DOCTYPE plist PUBLIC "-//Apple//DTD PLIST 1.0//EN" "http://www.apple.com/DTDs/PropertyList-1.0.dtd">
<plist version="1.0">
<dict>
 <key>Label</key>
 <string>net.sourceforge.synergy2.synergyc</string>
 <key>ProgramArguments</key>
 <array>
  <string>/opt/local/bin/synergyc</string>
  <string>-f</string>
  <string>-n</string>
  <string>macbook</string>
  <string>SERVER_HOSTNAME</string>
 </array>
 <key>RunAtLoad</key>
 <true/>
</dict>
</plist>

Be sure to replace SERVER_HOSTNAME with the hostname of your server, modify the path to synergyc for your installation and delete or change the -n and the macbook to reflect your synergy configuration.

7.11.2008

i do not have a 3g iphone

i don't have an iphone, but i'm not really all that upset about it. i went down to the apple store on a whim this morning to see if the line looked doable, and it was long, but not that long. so, i waited for a bit.

what surprised me was that despite all the hype, despite all the preparation, the line was slow. it was really slow. in an hour and a half, the line moved twice. i was really disappointed in that. i would have thought that they'd be a bit more efficient than that.

anyway, i'm patient. i'll wait a few days until they get a little better at getting people through the stores.

update

apparently there's an activation issue that's causing things to be so slow. so, i can't blame the retail people anymore, but some software engineer in cupertino is fearing for his life (or at least his livelihood) right now...

7.08.2008

building protocol buffers with maven

i set up the maven build for protocol buffers and it looks like ted is not happy with my work. :-( seriously though, i wish he had a comments section so i could get a bit more detail about whether his gripe is with how protocol buffers are built or with maven itself. if he's unhappy with maven, +1 to that. (yes, i get annoyed with it too.) otherwise, i'd love to get some feedback on how to improve the build from both ted an everyone else.

no idea what i'm talking about? check out protobuf.

10.28.2007

glassfish ajp proxy

another post from the old blog that i didn't want to lose:

Jean-Francois Arcand wrote an excellent blog entry on getting an ajp proxy running with glassfish. the only problem was that it used mod_jk. now, that's great for httpd pre-2.2, but as of version 2.2 there is a much better way. mod_proxy_ajp allows you to proxy with ajp the same way you would with any other protocol. consequently, all of the worker.properties stuff can be replaced by apache configuration directives like:

<IfModule proxy_module>
<IfModule proxy_ajp_module>
  <Location /pebble>
    ProxyPass ajp://127.0.0.1:8009/pebble
  </Location>
</IfModule>
</IfModule>

comments

martyn
Hi
While configuring with the proxy_ajp this seems to forward all request to glassfish is there a way to configure it so it works like the mod_jk that you can specify file extentions that should be forwarded and let apache handle the html,jpegs,gif of the sort .
I have been going through the documentation but don't see any thing that does this. I would be greatfull for any pointers on this.
regards martyn.
me
hey, sorry for the very, very slow reply. you're right in that the example i gave forwards everything. and while i'm not expert on apache or proxies, i can say that mod_proxy is pretty versatile. i'm pretty sure that you could accomplish what you're trying to do with the ProxyMatch directive. another way to go might be to take a look at mod_cache. it would probably boost the performance of your static content in a more dynamic way. hope that helps.
anonymous
I think you also need a ProxyPassReverse, in case the glassfish side sends an HTTP redirect.

I'm not totally sure, but that is what I have read.  :-)

java with leopard

there seem to be a fair number of java developers using os x these days, so i thought that i'd quickly write down some thoughts about java on the new os.

java 1.6

the obvious question is: does leopard comes with java 1.6? at the moment, java -version gives me

java version "1.5.0_13" Java(TM) 2 Runtime Environment, Standard Edition (build 1.5.0_13-b05-237) Java HotSpot(TM) Client VM (build 1.5.0_13-119, mixed mode, sharing)

and ls /System/Library/Frameworks/JavaVM.framework/Versions/ gives me

1.3        1.4        1.4.2      1.5.0      Current 1.3.1      1.4.1      1.5        A          CurrentJDK

so, the obvious answer is no. honestly, this is a bit annoying. we know that there were some issues getting leopard out in time, but things seem to be dropping all over the place. it actually reminds me of vista a little bit... how sad. anyway, i still maintain hope that the missing pieces will show up in a software update pretty soon. otherwise...

so what's the upside? what's the reason that i'm not feeling dirty all over for owning a bit of AAPL (aside from the positive slope in that graph)?

spaces

while i spend my time at home with my macbook attached to a 20" cinema display, the rest of the time i'm confined to a mere 13". at any given time i'll have at least a browser, an ide, a text editor, a command prompt on my tiny little display and it gets a bit cluttered. until now i've been a cmd + tab, cmd + ` and cmd + her. (i really only ever used exposé to get to the desktop...) now, i think spaces may clean up my app switching. put the browser in the first space, the ide in the second and the command prompt in the third. now i can just ctrl + arrow between spaces and get right to where i want to be. since spaces aren't in a stack like the app switcher, i don't have to figure out how many cmd + tabs it'll take me to get to where i need to be.

obviously spaces wasn't just designed for developers, but i can't image who will get more use out of it. well, maybe people that want to hide the fact that they're playing launchball all day from their bosses... that's a different story.

i want mustang damnit.

10.17.2007

pie progress bar in safari 3

macosxtips pointed me to this neat little trick. if you want to get a nice little pie chart indicator for page loading instead of the default, just execute

defaults write com.apple.Safari DebugUsePieProgressIndicator -bool true

on the command line. in my opinion, it's a much nicer little indicator.