Wednesday, March 28, 2012

Macs, Remote Desktop and keyboards

I have a little project I'm developing in Java on top of my real job.

I usually do my development directly on my Windows machine, but I often connect through Remote Desktop from my Mac.

I have a French keyboard Mac, and the keyboard on the Windows machine is also French.

Of course, when you develop Java programs, the following keys are used extensively: {}[].

The problem is that the key combinations required on the Mac to produce these characters aren't sent correctly to the Windows PC through Remote Desktop. The quickest way to circumvent this problem is simply to copy and paste braces or brackets from existing code. Quite annoying.

I remember having searched for this problem before, and at that time I had not found anything.

Today I did : Ctrl + Alt.

It turns out that, for example, to type a { on my Mac, I have to type Alt-7, but when I'm in Remote Desktop, I need to use Ctrl-Alt-è.

Here are a couple of mappings that are useful :

To get a Type
{ Ctrl-Alt-è
} Ctrl-Alt-à
[ Ctrl-Alt-^
] Ctrl-Alt-ç

I imagine that for other languages, the key combinations would be different, but I'm convinced that you'll find them with Ctrl-Alt :-)

Sunday, January 8, 2012

OpenDNS, Dyndns, and DNS cache on Windows

I hope this helps someone in the future.

I've been using Dyndns.org for probably more than 10 years in order to be able to access my servers at home while I'm out of the house. Since most home routers have been supporting Dyndns for many years, this is a really simple setup.

In the last year or two, my kids have grown up and are now at the age where they use the internet on a daily basis, and so I've decided to use OpenDNS for my DNS needs, which has the added bonus of having url filters built in, so that I can minimally control what web sites my kids have access to.

I'm also a developer, and I have a machine set up at my buddy's house to host a web site. Since he has a dynamic IP also, I set up his own Dyndns account so that I can access the site from my home.

What I started experimenting was that when my buddy's ISP changed his IP, I couldn't access the site anymore using the Dyndns name.

As it turns out, OpenDNS' DNS tables are not updated right away when an IP address changes. After a bit of research, I found another service, DNS-O-MATIC, which allows you to tell OpenDNS that your IP has changed. So I set up an account there for my buddy, added dns-o-matic to his ddclient, and it worked fine.

Except for my Windows machines.

When my buddy's IP would change, ddclient on his machine would contact DNS-O-MATIC to request the OpenDNS IP change. At that point, if I was at home on a Linux machine and I tried to ping the Dyndns name, it would return the new address. However, on my Windows 7 machine, I'd still get the old address.

More Google.

It turns out that Windows has a DNS cache running by default. This cache, it seems, gets reset every 24 hours. If you disable that cache, then your system will query OpenDNS everytime you request a URL, but at least you'll get the latest one.

To enable/disable the cache, Start, Run..., and type "services.msc" and Enter. Then look for DNS Client, and disable/enable it.

With DNS cache enabled, you can also flush the current cache by typing the following in a command window : ipconfig /flushdns.

Finally, you can see the list of cached URLs by typing ipconfig /displaydns.

Friday, December 9, 2011

Reading a properties file, in an Axis2 web service, from the file system...

For those with some experience with Axis2 web services, you know that the axis2 application gets installed, as all Tomcat applications, in the <TOMCAT_ROOT>/webapps directory.

The axis2 app itself has a WEB-INF sub-directory, which itself contains these :

- classes
- conf
- lib
- modules
- services

I've been coding a few web services lately which use some java libraries (jars). I've found that the easiest way for the web services to get access to those libraries is to install all these jars in the WEB-INF/lib directory.

I then came to this requirement : one of the classes in one of the libraries needed to get its configuration information from a Properties file.

When I was coding within the Eclipse environment, that was easy enough, I just put the configuration file in my Eclipse project's root, and then used the following code :

String filename = "config.properties";
Properties props = new Properties();
props.load(new FileInputStream(filename));

Nothing new here, and it worked like a charm.

The problems started when I packaged that class into a library, and tried to use it from some web service installed in Axis2. The file couldn't be found anymore, or, more precisely, I had no idea where to put the file.

Note that I didn't want to put the file within the AAR archive : I wanted the file to be outside the web service's archive because I wanted to configure the application from a text file that could be easily changed with a text editor directly on the target server. I wanted to avoid having to rebuild the archive everytime I wanted to install somewhere where I needed different properties.

It turns out that all that's needed is this :

- put your properties file in the WEB-INF/classes directory or your Axis2 installation, or to be more precise, in <TOMCAT_ROOT>/webapps/axis2/WEB-INF/classes
- in your code, use this.getClass().getResourceAsStream(), like this :

String filename = "config.properties";
Properties props = new Properties();
InputStream isr = this.getClass().getResourceAsStream("/"+filename);
if (isr != null){
  InputStreamReader isrProperties = new InputStreamReader(isr);
  props.load(isrProperties); 
}

Did you notice the "/" in front of the filename on the third line ?

This means look in the root of the classpath. And the root of the classpath, in an Axis2 web service environment, is <TOMCAT_ROOT>/webapps/axis2/WEB-INF/classes.

Hope this helps.

Monday, August 15, 2011

Getting a Canadian iPhone to work with an AT&T GoPhone SIM card, Conclusion

Back from vacation in Virginia Beach, and I thought I'd let all know that the AT&T SIM card I put in my Canadian iPhone 3G has worked flawlessly for the complete duration of my trip.

I had read on different sites that AT&T might deactivate the SIM, supposedly because they could detect that my phone was canadian, but no such thing happened.

So, I definitely recommend using the GoPhone SIM card in the iPhone 3G. As for the iPhone 4, it doesn't work as far as I can tell.

Friday, August 5, 2011

Getting a Canadian iPhone to work with an AT&T GoPhone SIM card, Part 5

Well, I'm now on highway 87 driving down to VA beach, and although coverage is spotty at best, I can now confirm that the GoPhone SIM card works in my jailbroken and unlocked iPhone 3G.

Thursday, August 4, 2011

Getting a Canadian iPhone to work with an AT&T GoPhone SIM card, Part 4

Yesterday, I tried to get my old iPhone 3G to work with the GoPhone SIM.

The challenge was to jailbreak the phone, as it's not compatible with jailbreakme.com. After a few trials and errors, I finally succeeded jailbreaking it with redsn0w, although it seems that since I was on iOS 4.2.1, there's now no way to bring it back to "factory settings" as far as the baseband is concerned : I'm stuck with the iPad baseband (6.xx), which is required for the unlocking to work. I of course then unlocked the phone with ultrasn0w.

Had I known that I was going to use my 3G phone instead of my new iPhone 4, I wouldn't have cut the SIM into a MicroSIM. But the damage was done, and so I had to come up with a quick fix for that. I just took an old satellite access card and cut a regular SIM out of it, and then cut the inside of that so that I could fit my GoPhone MicroSIM in it, and voilà, I had my MicroSIM-to-SIM adapter.

I then proceeded to insert them in my iPhone 3G, and the result is encouraging : no "SIM failure" message, just the phone working normally, but showing "Network unavailable" in the top-left.

We'll know tomorrow, when I'm in an AT&T tower range, whether the setup works or not.

Wednesday, August 3, 2011

Getting a Canadian iPhone to work with an AT&T GoPhone SIM card, Part 3

Quick update : I drove down to the US border last night to try the GoPhone SIM card in my iPhone 4 within range of an AT&T tower.

Turns out I'm getting the same behavior as I did at home in Montreal : I either get the "SIM failure" message, or if I put the phone in airplane mode and reboot, I then get one network bar and no connection to the AT&T network.

After further research this morning, I have found that the baseband used by my iPhone, 04.10.01, can not be unlocked by ultrasnow. I'm at version 4.3.3 of iOS by the way.

I'm looking right now at other avenues, namely :

- trying to install a custom iOS (with different baseband) onto my phone, I don't know if that's at all possible
- trying the SIM in my old iPhone 3G (I don't remember which iOS version / baseband it was on).