New looks!

I’ve just updated the website’s looks! 😀 I’m trying to update this site and the new header and background is the first step in that direction. I also wrote the first version of a dedicated page for my real time ray tracer project “Rateracer”, see the link at the header, and improved the sidebar.

I’m hoping this site will slowly become up to date in the following weeks as I make up for lost time. xD

Posting events in OS X with CGEventPost

Haaai!

I realize nobody reads this blog but I’m hoping someone finds this when searching the web. xD

I’m having problems when posting my own mouse left and middle clicks using CGEventPost under Mac OS X Lion. My left click events don’t properly switch between windows and my middle click events don’t properly open new tabs.

I’ve posted a more detailed stack overflow question but have yet to receive any answers. 😦

stack overflow link: http://stackoverflow.com/questions/9106275/cgeventpost-click-events-not-taking-proper-effect

Here’s to hoping someone reads this. 😛 😀

New Ocarina arrived! :D

I got my new ocarina today! Around 9 the postman rang the door and I flew out of the bed and signed for the little package. 😀 The ocarina is quite small and fits in the palm of my hand. It came in small paper box decorated with the Focalink graphics. In the box the ocarina was inside a protective glove and there were also a paper with fingering charts.

The ocarina is beatiful! 😀 Black awesomeness. 🙂

New ocarina on the way! :D

Haaaai!

I haven’t blogged in a loong time. But no matter, I guess no one reads this anyway. xD

Anyway, I ordered a new ocarina last Sunday. It’s the Focalink AC-A in matte black. It was sent from Taiwan on the 9th but the tracking system is refusing to tell me anything more than that thus far. 😦 I’m going crazy, I want my oc! 😛

Update: It just reached Sweden! xD I might get it tomorrow! 😀 😀

Focalink 12 hole Alto C type A

HttpURLConnection getInputStream FileNotFoundException

Hello Android/Java coders!

So I recently got some weird errors when doing http requests in my Android game Hamster Climb. I was trying to get the input stream from a HttpURLConnection but kept getting a FileNotFoundException even tho the URL worked perfectly in my desktop browser. Here’s an example, without error catching stuff, of how the code could look like:

String user = getUser();
String url = "http://somesite.com/page?user=" + user;
URL u = new URL(url);

HttpURLConnection c = (HttpURLConnection) u.openConnection();
c.setDoInput(true);
c.setDoOutput(true);
c.connect();

InputStream is = c.getInputStream();

The problem was that at the last line the call to getInputStream generated a FileNotFoundException. I printed the URL that was used and tried it in the browser. Worked prefectly.

I managed to solve it tho. The problem was that even tho creating a URL object with the built url string works, the url might be broken. For example, if user is “Some guy” the url will contain a space which is not valid. Browsers solve this by automatically replacing the space with %20 which is what my browser did.

To solve this in code you use the URLEncoder class’ static method encode. This method takes a string and encodes it to a string that is ok to put in a URL. So replacing

String url = "http://somesite.com/page?user=" + user;

with

String url = "http://somesite.com/page?user="
+ URLEncoder.encode(user, "UTF-8");

solves the problem when user contains illegal URL characters.

Hope this helps someone out there getting weird errors. 🙂

Hamster Climb site updates

Both here on this blog and over at the Hamster Climb site I’ve updated the information and screenshots of the game. The info now matches the currently released version and the new screenshots show more screens of the game. 🙂

Hamster Climb’s New Home

Hamster Climb now has it’s own web site! 😀 I have made pages for reporting problems with the game and for submitting suggestions.

Link


I am a student of Engineering Physics at Uppsala University and am currently working on my master's thesis. On this website I mostly write about my own programming projects.