Saturday, November 17, 2007

The New Apple Wireless Keyboard

Every time I buy an Apple product I'm greeted by this really nice product that's been designed first but the engineers have put in the extra effort making sure that design works.
One gets the feeling that at Apple its not about who caused the problem and who's wrong but rather how a problem can be fixed.
Why am I all praises about apple? I just bought the new wireless keyboard from Apple. As soon as it was out of its sleek packaging I was amazed by how neat it was. Clean lines, laptop style keys.
Its not a full keyboard. Its missing the numeric pad but I think i can live with that. I've bought this to go with the new HTPC that i'm building that'll be sitting below the flat screen TV and I don't want a keyboard that's big and needs wires. I can see most ladies smile at this point, maybe that's what women want "No Wires"...
I've tried the keyboard with my iMac (new 20" core 2 duo) running Mac OS X and Windows XP. I've tried it with my windows XP PC that's hidden somewhere out of sight (i'm writing this review on that) and it works really well with all those.
Update: Just tried it with my Nokia N80 and it works really well with it as well. If i use this i'm sure my SMS are going to become LMS's... The only problem I found was that i couldn't find a 'Menu' button on the keyboard.

There is a bit of delay at times but for the most part it works flawlessly without missing out anything.
The other problem I found was that its got no indication of if its switched on or not and i'm assuming that's because they want to conserve power (the caps lock does have a LED)
I've still not been able to connect it to my phone so i guess that's next and i'll try a little more tomorrow.
Overall a sexy keyboard just like the one that comes standard with the iMac's without the numeric keypad.
Also note that the keyboard won't work if you choose to pair it without a key.

Pros:
- Worked on all computers i've tried (Windows, Mac OS X)
- Sleek and very sexy
- Works from across my room without a hitch
- Bluetooth so no software required.

Cons:
- A little slow at times
- Price: cost me Rs.2500 but that was because i bought the iMac from the same guy too otherwise the price is Rs.4500/-
- No numeric keypad.

overall score: 4.5/5

Wednesday, August 22, 2007

java check file existance

here's a simple function that checks to see if a file exists

--------------------------------------------------
public boolean exists(String filename) {
File file = new File(filename);
return file.exists();
}

--------------------------------------------------

Friday, July 13, 2007

Sennheiser PX 100


I just bought those today. I know this blog was supposed to be about code but I have decided, i might add other tech stuff up here as well. So here's my review of the Sennheiser PX-100.

First of all, if you enjoy music and have been listening to it on your portable music player using the ear buds or phones that came with it, its time for a change. These headphones are the perfect replacement for the stock ones that come with the players today. Yes! that does include the iPod. At $50 in the US and Rs.3400 in India these phones are priced well for the headphones of their quality.
As you can probably make out in the picture they're open backed which means they're not going to do a lot in terms of blocking out outside sounds which can be a bit of a concern in India but they do make these super efficient. In spite of the small size these produce really good bass and the output isn't bad either. The open approach also means if you've got your music up loud (turn it down) others can hear it too...
Coming to how comfortable they are, well i'd give them a 5/10 on that. if you're using these for long hours (i've had them on all day) you've got to keep removing them unlike the pair of altec's i also own which i can wear all day without even feeling them. The fact that they fold away are really neat though i'm not a 100% convinced that its entirely a safe, they don't give the feel of being bullet proof if you know what i mean. talking about build quality the wires feel like they could snap too (and they're not replacable) but i'll update you on that. Having said that, these do come with a years warranty which might come in handy in case something happens.
Overall besides the build of these things I'd recomment them to anyone without a second thought.
PS: I'll update you in sometime about how these are doing :)
PS2: I've got a set of Grado's on the way, can't wait ;-)

update: i've been using these headphones for the last few days and i'm really impressed. the bass is nice and crisp, the detail in the sound is better then some of the more expensive cans i've heard.
I'm constantly scared i'm going to snap the wire.

Thursday, June 7, 2007

Google's Many Computers

Well, I know I was said i'll post only code here but here's some rather interesting news that I think is worth a mention. I'm a big fan of the google way... but what's amazing is that almost all of google.com is running off x86 processors. As you can imagine that'll require a vast number of computers which require lots of energy and space. Enter PeakStream the company that specializes in programming the graphics processor units or GPU's on our computers. If you've played any new game GTA or Need for speed or any such game you'll know that these processors have massive computing power these days.
How does all this fit into Google's plans? Well, cheap, multi-processor systems that use every bit of computing power available on the standard boxes available.
Maybe its just my mind, maybe google infact will do this, either way its a nice thought.

processor = gpu.getMorePower(); // hehe >:-)

Tuesday, May 15, 2007

Callbacks in Java

Unlike most other languages that provide function pointers in some form or other, Java doesn't. So the next question leading up is what's the workaround?
Ans. Event handlers or interfaces

Java or any other language that supports inheritance makes it possible to define something called an interface (abstract class with only pure virtual functions in c++).




Java
public interface Callback {
  public void fn();
}

C++
class callback {
public:
  virtual void fn() = 0;
}




so when we want to create a callback function we implement this interface, with the function 'fn' in this example being defined in the derived class. This function then becomes your callback.

Java

public class CallbackHandler implements Callback {
  public void fn() {
    // your implementation goes here
  }
}

public class SomeClass {
  public void foo() {
    EventGenerator event = new EventGenerator();
    // we're creating an instance of the callback
    Callback handler = new ClallbackHandler();

    /* register this class as the handler for the event. In other words
    * call function 'fn' when some event we're interested in happens
    */
    event.registerCallback ( handler );
  }
}

/* some class that needs to call our callback */
public class EventHandler {
  public void registerCallback( Callback callbackObj ) {
    this.callback = callbackObj;
  }

  ...

  public void bar() {
    // this will call the function we defined in our CallbackHandler class
    this.callback.fn();
  }
  private Callback callback = null;
}



The able code contains three classes. The first class is the CallbackHandler which will contain the code for the actual implementation of the callback. Note that it extends from the 'Callback' class.

The second class is where you actually want to the callback to be implemented. i.e. this is where the object of the CallbackHandler will be created.

Finally the third class is where the Callback will be called from. Note here that it doesn't know anything about 'CallbackHandler' except that its derived from the 'Callback' class. This makes it possible to have multiple "CallbackHandler's".

Note that the principal remainds the same and this can be done in any language. However C++ and C# provide a way to pass around the function pointer itself without the need to wrap it into a class.

hello world

Hi,

I'm starting this blog with the intention of posting some pieces of code i find interesting. I can assure you that all of it will be my own work and none if it might be reproduced in a commercial product non-open source product without my prior consent. GNU licence applies to it all.

Now that I'm done scaring myself, the name of this blog comes from the wand that Hermes (the messenger for the Greek gods) carried with him. The wand itself was was used by him to break the fight between two snakes that then wrapped themselves around it in peace for eternity. He was also knows to be a great helper to all the other gods loaning his flying sandals and invisible helmets to those in need.

to start of with

Java: HelloWorld.java


public class HelloWorld {
  public static void main ( String[] args ) {
    System.out.println ( "hello world" );
  }
}




Another thing, there will be code from a lot of different languages here.