Pedro Assunção

Kinect-related injuries

Being able to play games without having a remote sounds awesome, but it’s not without its perils. To prove it, here’s a video of a Kinect session that went wrong. You can see this one and a few more on CrunchGear’s original article.

I’m pretty sure we are going to see a lot more of these popping up on youtube :)


Java Web Start (jnlp) simple example

Folder structure

One of my current projects requires me to deliver a Swing application via Java Web Start. This meant some research to figure out how that works. Since i’m a nice guy, here’s the result for everyone that needs it.

As you can see – in the folder structure image – there are some files that are required for the whole thing to work. Here’s a brief explanation about each of them (in my creation order ;) ):

  • src/org/Test.java : My source code. It’s just a simple main that creates a JFrame and displays it;
  • Manifest.txt : The manifest file used to create the jar file that gets served by Java Web Start;
  • faren.jar : My application’s jar. I’ll explain how to create it in a while;
  • faren.jnlp : The Java Web Start description file;
  • faren.html : The html file that contains the button to start the application.

The first thing we want to do is create the source file. In the case of my simple test, here are its contents (blank lines removed for brevity):

Test.java

package org;

import javax.swing.JFrame;
import java.awt.Dimension;

public class Test {
  public Test() {
    JFrame faren = new JFrame("Test");
    faren.setSize(new Dimension(300, 300));
    faren.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
    faren.setVisible(true);
  }
  public static void main(String[] args) {
    new Test();
  }
}

Moving on to the jar manifest file, it basically just says what the main class will be:

Manifest.txt

Main-Class: org.Test

Creating the jar is as simple as running the following command:

jar cfm faren.jar Manifest.txt org

It creates the faren.jar file, using the manifest file and the sources contained within the org folder. If – like me – you use Maven, you will have this for free using the app-assembler plugin, but for the test’s purposes i didn’t want to create a full maven project :)

Now we need to define a description file for the Java Web Start mechanism:

faren.jnlp

<?xml version="1.0" encoding="UTF-8"?>
<jnlp spec="1.0+" codebase="file:///Users/pedroassuncao/Desktop/jnlp_example">
  <information>
    <title>Dynamic Tree Demo</title>
    <vendor>Dynamic Team</vendor>
  </information>
  <resources>
    <!-- Application Resources -->
    <j2se version="1.6+" href="http://java.sun.com/products/autodl/j2se"/>
    <jar href="faren.jar" main="true" />
  </resources>
  <application-desc
    name="Dynamic Tree Demo Application"
    main-class="org.Test"
    width="300"
    height="300">
  </application-desc>
  <update check="background"/>
</jnlp>

Just to explain a little bit of what is going on in here (the important parts), what you want to make sure is that the codebase property is set correctly to the absolute path where the html file will be served from (in the case of a final deployment this will be something like http://myserver/jnlp/myapp, but in this case i’m serving without a web server, hence the file:/// part). You will also want to define a minimum version for the virtual machine of the client (the 1.6+ part) and eventually extend this information with the <shortcut> tag, that allows you to ask web start to create a desktop icon for your application on the clients’ computers. A full description of the structure of this file can be found here.

Finally, we need an html file that will show the java web start button. The following will suffice for now:

faren.html

<html>
  <head></head>
  <body>
    <script src="http://www.java.com/js/deployJava.js"></script>
    <script>
      // using JavaScript to get location of JNLP file relative to HTML page
      var dir = location.href.substring(0, location.href.lastIndexOf('/')+1);
      var url = dir + "faren.jnlp";
      deployJava.createWebStartLaunchButton(url, '1.6.0');
    </script>
    <noscript>
      <a href="faren.jnlp">Launch</a>
    </noscript>
  </body>
</html>

If the client’s browser supports javascript, this will use a special script from the java website that will ask to install the virtual machine if the client does not have it (or upgrade an existing one). If he doesn’t support javascript it will just show a link that will try to launch the java web start (depending a lot on whether the user’s file associations are correct (i.e. .jnlp files being assigned to the java executable).

Finally, with all this in place, point your browser to the place where you have the faren.html file and click the button; the application should launch.

By the way, does anyone know why my desktop shortcut is not being added on OSX? :)


Summing up Apple’s keynote

Apple had an event yesterday. And i saw that it was goooood. Seriously now, i was pleasantly surprised by – well – the surprises that were shown by Steve and co. Here’s a brief sum of coolness:

iLife 11

This update to the iLife family of products is one of the best ever, in my opinion.

iPhoto got yet more social features into it, like the ability to display your Facebook photo albums, as well as comments from your friends on those photos, and the fact that you can zoom to a particular part of the world map and, with one click, see the pictures inside that area. Other interesting features include a full screen mode, that takes away everything that is peripherical when organizing your pictures. They also introduced new slideshow templates and the books feature is very, very enhanced, showing a bookcase with all the photo book projects you have created and giving you complete control on the generation of the book.

iMovie also was added a lot of nice new features. The most notable include the long waited ability to edit audio directly in the timeline, like adjusting the sound level (even for just parts of a clip) and do fade ins and fade outs. Another great feature is the trailers part. It can now help you take your favorite footage and create movie-trailer-like movies, effortlessly. I can see myself using almost all these features in my podcast :D

GarageBand got some love as well: Between the ability to match the groove, or beat, of a track to another one, hence turning out-of-sync tracks into fully synced ones (which looks like magic), and a feature that reminds me of Guitar Hero called “How did i play”, GarageBand gets an incredible boost in terms of helpful features for artists and aspiring musicians.

No word on the rest of the products, but i can imagine some updates as well, though probably minor.

FaceTime for Mac

Yep, it’s here and fully available. You can now make video calls between iPhones and Macs (or macs and macs as well). Pretty awesome, though i wonder what will happen to iChat, and why wasn’t that integrated…

Mac AppStore

Will be available in 90 days time (yes, also for Snow Leopard) and will rock. These guys are going to make a ton of money on this thing. And for the end user, well, it means no longer manually installing updates for your favorite apps or using the (somehow) disparate software update mechanism in OSX.

MacBook Air

In one word: “Freakinawesome:)
No more spinning drives (yes, that means no optical drive as well: goodbye DVDs), which pretty much makes them lighter and smaller. 2 versions are available, one 13 inch and one 11 inch. The prices go from $999 to $1599, depending on the version and options you want.

OSX 10.7 Lion

They showed off some new features, though the most notable ones are:

  • A new dashboard: Where you can see all your installed apps from the Mac AppStore, like you do one your iPhone (yes, sliding panels and everything), and group them as well;
  • Full screen apps. Meaning, real fullscreen goodness for your applications. They basically want to make Lion a bridge between traditional OSX and the iOS, where every app is basically fullscreen;
  • Something called mission control, where you can see an overview of every app that is running on your Mac, be it fullscreen or windowed. Think Exposé, but better arranged.

What about you? What are your thoughts on Apple’s new features?


How does one change his domain name without losing hits?

I recently decided to drop one of the domain names that points to my blog. After (finally) getting the proper domain (pedroassuncao.com), i figured there was no sense anymore in keeping the old one (diffract.me).

Now here’s the problem: A lot of google links that bring a huge percentage of my traffic are pointing to the old one. That explains why – from last week to this one – i got a 90% traffic decrease in visits and page views. I definitely should have done something to prevent or at least minimize this “problem”, but i didn’t.

So my question is: What could i have done? Anyone out there has had this problem before? If so, what did you do to mitigate it?

UPDATE: Thanks for all the comments, that was really helpful. One in particular (by Ryan) explains a nice solution really in detail.


Google releases URL shortener and introduces new image format

Google is on a rampage. After opening up it’s short URL service to the general public, it now introduced a new image format (WebP) which they claim to achieve “an average 39% reduction in file size”. I wonder how long it will take for applications like Adobe Photoshop to include support for it.

As a bonus, in Google’s goo.gl (that’s the name of the URL shortening service), if you append .qr in any link you get the QR code for that link. This is especially useful for mobile devices to rapidly open links from their cameras. Try it out, here’s a link to my blog’s QR code. If you have a mobile device that can read QR codes it will open my main page in a browser. Very smart of them to allow this, as it will definitely be an advantage over other URL “shorteners”. Until they copy the feature, that is :)


Did a Russian scientist just invent an anti-aging pill?

He seems to be a very respected scientist in his field, with a lot of publications and a job at a very prestigious university. Even Gunter Blobel, a biochemist and Nobel laureate seems to respect him quite a bit. Is it just a couple of years until we are able to remain young and healthy – potentially – forever? Who never dreamed of living forever? I sure do!

Taken from here


Schiphol-Amsterdam : Airport security at its best

There i was at gate D83 (or should i say 53?), waiting for my flight back to Portugal when something suddenly starts beeping. I turn to look and see a man washing the floor who had just stepped through an unused set of security gates that is laying around there (see picture).

If i’m not mistaken, these (probably older) gates used to have security checks done here, instead of at the main central place where this happens nowadays. I saw these a couple of times before, though i always assumed them to be deactivated. So when the cleaning man passed through it i couldn’t help but thinking the potential for experiments. I mean, anyone can potentially play around with it and “try out” which items go through undetected and which will be safely concealed. Call me paranoid, but i think it’s already bad that the general public is allowed to be near these things unsupervised, much less the damn things being turned on.


Google instant is pretty awesome

Google Instant results

In case you missed the Google event, they are rolling out a new feature called “Instant”. It basically shows you search results as you type the query in the search box.

Currently i could only have it working on Chrome at www.google.com (can’t be any other suffix, like co.uk, pt, etc.) but you definitely need to see it at work to appreciate it. It makes it much easier to find what you are looking for when you can change the results on the fly, if you are not happy with what you got :)


Everything is new all the time

It’s funny how the greatest revelations come to us in thee strangest places. I’m having dinner in a shopping mall and all of a sudden, while thinking about why humans get bored, it strikes me that we are the ones who make everything boring. It’s our brains, all the time!

Consider this: how many times have you closely looked at something as trivial as a chair? Look again at that same chair. And again, and again. How many screws does it have? How is the place where you sit your butt? Is it curvy, flat? What’s the color off the chair? How much does out weigh?

Do you catch my point? You can walk the same path a thousand times and you will always, and I mean always, be able to see something new. The problem is that our brains trick us not to.

And this is probably valid for social relationships. There is always something new to talk about. You just need to train your brain to think outside the box :)


Landing is every man for himself

I hurt a knee the last time I was out jumping, on a downwind landing. And it was all because of a combination of stupidity and lack of knowledge.

The first because I did something I shouldn’t: I trusted a fellow skydiver’s direction instead of the wind sleeve. Turns out his direction was perfect for his canopy’s rate of descent, which allowed him to make his final turn upwind.

The second cause for the crash was the lack of experience to deal with a downwind landing. Apparently one of the safest ways to do it is to land like a tandem: on your butt :)

Lessons learned and hopefully my knee will heal fast so I can jump again soon and put all this behind me.

Blue skies


Trying out the android app

So I come back from the road trip and what’s they’d first thing I do? Install the wordpress android app so I can blog anywhere, hehe. I kind of decided to use my blog as it was intended (as a web log), not necessarily as people see them these days (as places to write longer pieces of text that cannot be tweeted).

Peace


Going on a road trip

For the past few years i’ve been playing around with the idea of going on a road trip but was never able to get anyone else on board. After people start working it becomes very hard to organize common vacations amongst friends, so it just never happened. Last month i decided that i *have* to go on a road trip, even if i have to go alone. At some point the idea started slowly to become an “into the wild” kind of thing and it became clear that going solo will be a much richer experience. Not that i don’t like company, on the contrary, but i will have complete freedom to go wherever i feel like going :)

And so it is. This Saturday i’ll get some stuff in my car and take off, with only a rough idea of where i want to go. My plan is to visit the most isolated places in my beautiful country (Portugal) – something that i have been wanting to do for ages – and take a gazillion pictures to show off this awesome corner of Europe to anyone that wants to visit it.

Later i’ll post a list of things i’m taking with me (yep, there’s some thought to that, i’m not going Rambo on this one :) ), maybe it can help other fellow adventurers :)

Here’s the rough plan, (very) subject to change:


Isn’t music very similar?

One thing that both annoys and amazes me is the limited number of chord combinations in most songs. It’s extremely frequent to hear a musical composition and get that feeling that you heard it before. And we are probably right most of the times.

In the last AC/DC album there is a song entitled “Big Jack”. As soon as i heard it i immediately recalled another song by a very polemic Portuguese singer from the the 80s: António Variações (look up his songs, they were pretty innovative back then, actually).

I still trying to think why i am writing this but guess that i can’t help wondering, first, why aren’t there any more musical notes (i guess i should look that up) and, second, why most bands don’t explore more and keep falling to the same chord combinations all the time. The easy explanation is the amount of money that you can make with little work on a catchy pop song, but i feel sad if that’s the only one.