ajani’s blog

 

Fun with constants in Java

The following code does not compile:

public class A {
public static void main(String[] args) {
int i = Integer.parseInt(args[0]);
switch (i) {
case X: System.out.println("ONE!"); break;
case Y: System.out.println("TWO!"); break;
default: System.out.println("ZERO!"); break;
}
}
public static final int X = B.getNumber("X");
public static final int Y = B.getNumber("Y");
}

class B {
public static int getNumber(String s) {
if (s.equals("X")) {
return 1;
}
else if (s.equals("Y")) {
return 2;
}
else {
return 0;
}
}
}

The compile error is:

A.java:5: constant expression required
case X: System.out.println("ONE!"); break;
^
A.java:6: constant expression required
case Y: System.out.println("TWO!"); break;
^
2 errors

I think I'll leave explaining why as an exercise for the reader. (Or for a future post. ;-)

Filed under  //   geek   java   programming  

Comments [0]

Potion Language

Potion is an object- and mixin-oriented (traits) language.

_why's been working on a new top secret project. Wish I had more time to play with all the neat languages out there. This one seems to have a lot of neat ideas.

Filed under  //   geek   languages   programming  

Comments [0]

Sprint and Verizon have more reliable 3G networks than AT&T

During March and April, we spent a day testing the major 3G services in 13 cities across the United States. Verizon's service showed a combination of speed and reliability, Sprint's results lent credence to its 'most dependable' claim, and AT&T's network showed fast upload speeds in most cities.

As an AT&T subscriber, I'm completely unsuprised that AT&T's network is less reliable than Sprint & Verizon. I would have been really curious to see how T-Mobile's network stacked up.

Comments [0]

Hot hot hot

Filed under  //   picture  

Comments [1]

Running up to Coit Tower

Since I didn't get any company for my lunch run today, I decided to mix things up and run to Coit Tower instead of the normal run along the Embarcadero to Fisherman's Wharf and back. I learned a few things from the endevour:

  • Telegraph hill is neither as tall nor as far away as it looks.
  • Stairs are infernal torture devices designed by Satan himself.

It ended up being a rather enjoyable run: I discovered a flower garden on the side of the hill, and the views were, of course, spectacular.

In case you're curious, I did upload the map.

I'm definitely going to have to explore more on lunch runs, it was really nice not to be doing the same old run again.

Filed under  //   running  

Comments [0]

Stadium to Stadium 10k 2009 Results

They've posted the official results. I came in 171st overall, 38th in my age group. More importantly, my overall time was 48:26.0, which is 7:48 per mile. That's about 6 minutes faster than my time last year. Ironically, even though I was faster this time, I came in 2 places lower in my age group.
 
Previously.

Filed under  //   race results   running  

Comments [0]

Stadium to Stadium 2009

Just finished another stadium to stadium 10k. I think I'm about 10 minutes faster than last year, and I have a much more amusing number.

     
Click here to download:
Stadium_to_Stadium_2009_tag_ru.zip (768 KB)

Filed under  //   running  

Comments [1]

Scribblenauts

The premise is simple: The player uses the touch-screen to help their character, Maxwell, acquire the star in each level by solving a series of puzzles. The twist is, in order to solve each puzzle the players use the notepad to write down objects that are used to reach the goal.

This game is all about experimentation, imagination and endless replay value. Think of any person, place or thing, write it down, and watch it come alive! Write Anything,
Solve Everything!

This sounds intriguing. It might just make me dig out my DS and attempt to actually spend some time playing a game. We'll see. I've been so bad at that gaming thing lately... But Scribblenauts sounds so... compelling.

Filed under  //   games  

Comments [0]

Opera creates another innovative browser feature

Opera has taken the wraps off a new service called Opera Unite, which allows users to transform their personal computer into a Web-connected media and information sharing service. Opera Unite is part of the latest beta version of the Opera 10 browser, and allows inventive Web developers to create just about any Web app they can imagine, and then enables users to host the app themselves.

Opera Unite basically turns your personal computer into an ad-hoc Web server. Various "services" can be loaded and activated via the browser, allowing your machine to share files with friends, stream MP3s, or even serve a full website. One service, Photo Sharing, lets you simply point to a folder full of photos on your own hard drive and serve them as an online photo gallery.

This sounds quite brilliant. I wonder how long until every web browser has a feature like this. I guess it's somewhat too bad that coming up with the cool new features before everyone else doesn't actually convert to market share.

Comments [0]

iotop

iotop is a console application for monitoring the I/O usage of processes on your system. It is especially handy for answering the question “Grrr, sloooowness, why is my disk churning so much?”

Where has this been all my life?

Filed under  //   geek   linux  

Comments [0]