Reviewing a MyFreeview|HD DVR
Posted by Nick in Hardware, The Wonderful Internet, Wellington on November 15, 2009
After Mauricio (the Geekzone BDFL) asked me to review the JCMatthew DVR-320T I wasn’t sure what to expect. Now I can honestly say that I am happy to do this. I will try to be as impartial as possible and provide the readers with a no-nonsense review. My tone will be as non-technical as possible and I will strive to explain the slang as clearly as I can.
So I’ve started this reviewing journey that you can follow here. I will not be cc-ing my review to this blog but I will be taking questions via this post if there are any.
So feel free to drop me a line if you feel like it.
Cheers…
Solved: Mac OS X (Snow Leopard) and SVN (1.6.2)
Posted by Nick in Tutorial, Uncategorized on November 6, 2009
Today I spent a few hours trying to figure out why Eclipse was unable to connect to my locally running Subversion server. I was annoyed especially because Xcode and Terminal were not having any issues.
Some background information.
- SVN is running as a daemon locally. It gets started by:
svnserve -d –listen-host localhost -r /Library/Subversion/Repository
- trying to checkout stuff using the command below via Terminal works fine
svn co svn://localhost/Project1/trunk WorkingDirName
- trying to browse the svn repository from within Eclipse 3.5 Galileo using either Subclipse or Subversive always ends up with:
svn: connection refused by the server
I tried many things but none of them helped. I googled but failed to find something relevant. Just before giving up I thought I would check what ports were open on my machine, maybe there was some conflict. There was no conflict but…
netstat -anp TCP | grep LISTEN
returned this:
tcp6 0 0 ::1.3690 *.* LISTEN
That’s when it dawned on me: the svnserve was binding an IPV6 address and Eclipse could not handle that!
Solution:
ps -ef | grep svnserve
kill -9 (where proc_id is the process id of your svnserve, the second number on the line)
svnserve -d –listen-host 127.0.0.1 -r /Library/Subversion/Repository/ (or wherever you’ve placed your Repository)
Done! Now svnserve is bound to an IPV4 and Eclipse can play nice too.
Cheers…
p.s. please let me know if this worked with other Mac OS / SVN versions too
Mac OS and Java Me SDK 3.0
Sun have released not too long ago a Java ME SDK 3.0 that finally brings an official Wireless Toolkit Emulator to the Mac platform.
I have been dealing with SUN software for a while now and I was not expecting this to be a smooth ride. Those who’d dealt with the WTK on Windows/Linux platform are well aware of the limitations of these emulators. What I was not prepared for was to get so much clutter that would just not work more than a couple of times.
First impression: this wtk looks like the most polished emulator ever released by Sun.
Sadly, after using the thing for a few days I discovered that the old habits had not changed:
- there is no menu entry to run an existing jad/jar pair. You have to right click on an emulator instance and then run it…
- you cannot set-up a project starting from a jad/jar pair. There used to be an option to do this back in wtk 2.2…
- after running a couple of apps the whole thing crashes an burns
- when closing down the wtk a process is left lingering. Run this in a terminal: ps aux | grep device-manager.app
- switching the verbose mode when launching the emulator kills the whole thing dead!
- they bundled ant 1.7.1 with the distro although ant is built in Mac OS
- Permgen errors are thrown if you try to launch the app too often. LOL
Here’s what happened when I created a new project and tried to run it:
*** Error ***
Failed to connect to device 0!
Reason:
Emulator 0 terminated while waiting for it to register!
The same thing happens with Emulator 1 and 2 and 3 and 4 and 5 and 6 and … you get the picture.
Googling did return lots of forum posts, but hardly any answers…
So after wasting more than 2 hours on this issue I did the unthinkable: rebooted my mac! To my surprise the miracle happened during the reboot: I was finally able to run the project again.
Needless to say I am very disappointed but not surprised by the quality of this, early access, Java ME SDK.
Cheers…
Updating the UISearchBar programmatically
Posted by Nick in Objective C, Tutorial, iPhone on October 16, 2009
Today I had to update WelliBUS’s search bar programmatically because I needed to use the street picked up via GPS as my street name.
Until this point implementing the search bar seemed easy:
- adopt a couple of protocols: UISearchDisplayDelegate and UISearchBarDelegate
- implement a few callback methods (from the delegates listed above)
- (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchString:(NSString *)searchString; - (BOOL)searchDisplayController:(UISearchDisplayController *)controller shouldReloadTableForSearchScope:(NSInteger)searchOption; - (void)searchDisplayControllerDidBeginSearch:(UISearchDisplayController *)controller; - (void)searchDisplayControllerDidEndSearch:(UISearchDisplayController *)controller;
- and implement my own filtering function
- (void)filterContentForSearchText:(NSString*)searchText scope:(NSString*)scope;
The problem I had on my hands was how to programmatically update the text in the UISearchBar and force the UISearchDisplayDelegate to call the appropriate callback methods.
Turns out it was simpler than expected (despite not being able to find a solution by googling). All that was needed was:
[self.searchDisplayController.searchBar becomeFirstResponder]; self.searchDisplayController.searchBar.text = returnString;
Cheers…
JSON Framework — Potential Null Dereference
Posted by Nick in Uncategorized on October 5, 2009
If you are using json-framework as your preferred iPhone / Cocoa Touch JSON framework then you might find that the SBJSON.m is not necessarily perfect.
Don’t get me wrong, it is an awesome utility and it has saved me heaps of time but when analyzing the code (with XCode 3.2) I got lots (36 or so) of Potential null dereference warnings.
The reason for it is that when this the error is built in lines like this:
*error = err(EUNSUPPORTED, @"JSON object key must be string");
The error object is not checked for NULL.
According to Apple’s documentation one can call a method that takes a error:(NSError**)error parameter with either of these:
NULL
NSError *error = nil;
So if the argument is NULL you can’t really assign something to it.
To fix the XCode warnings (and your code) just do this test before the call to create a new error object.
if (error != NULL) *error = err(EUNSUPPORTED, @"JSON object key must be string");
Cheers…
Urban Airship – Push Notifications
Posted by Nick in Objective C, REST, iPhone on October 4, 2009
Today I have finally added Push Notifications to Parcel Trackr.
I decided not to waste time and I went for Urban Airship. I registered, uploaded my push certificate, downloaded the sample and integrated the two systems.
Not everything went smoothly though because when I first ran the application I got a
Failed to register with error: Error Domain=NSCocoaErrorDomain Code=3000 UserInfo=0×120610 “no valid ‘aps-environment’ entitlement string found for application”
I thought my provisioning profile did not include the right entitlement… so I re-downloaded it and tried again. Turns out I was using the wrong provisioning profile.
So if you want to avoid my mistake just make sure that after you’ve configured push services in the iPhone Dev Center you download the updated provisioning profile and then you install it via XCode.
Other things worth checking include: the product name in your build configuration matches the app id and of course, the ultimate solution, clean all targets before building!
Cheers…
WelliBUS is out
Posted by Nick in Mobile, The Wonderful Internet, Wellington, iPhone on September 21, 2009
Overview
On Thursday 17th of September Apple approved WelliBUS. Now the people in Wellington, NZ have a new option when it comes to finding out when their bus comes:
- use www.metlink.org.nz
- txtBUS 287 (20c / msg)
- 0800 801 700 (free)
- WelliBUS (free, needs an active internet connection)
A quick look at txtBUS will show you what a neat service it is. Type the stop number (optionally the service number and time), send yr msg to BUS (287) and there you go. But what happens when you don’t know that stop number? Or what if you forget the txt syntax? You can browse the metlink website or you can call their 0800 number. Alas neither option is convenient. This is where WelliBUS excels!
With WelliBUS you can do everything that you can do with txtBUS but you can also find out the bus stop number by searching by a street name or by simply tapping a GPS button that will do the hard work for you. Then you’ll be returned a list of nearby stops. Just tap one and you’re done! WelliBUS let’s you filter by date or service number just as you’d expect it to.
Launch
WelliBUS has been out there for only a few days now and I have to say I am impressed by the feedback I’ve received. Thank you everyone.
I don’t know if it is because it’s free or because Wellingtonians love their iPhones or because they use public transportation a lot.
I know many of you are asking about real time bus information, it’s coming but you have to be patient, from what I’ve heard you won’t have to wait much longer… At this point treat this as a rumor.
I hear a few of you have found some issues, please post them here as comments and I will prioritize them and tackle them as soon as I can. I know there is a typo and I know that if you filter by buses using 00 prefixes the app fails to filter. So if you search for service 008 please use just 8 instead.
If you want a copy, the app is here WelliBUS
Rest assured the app will stay free, ad-free, bloatware free. But if you like it I encourage you to download one of my paid apps from here: tmro apps.
Cheers…
p.s. My close friends know the funny story of how this application was conceived, but this is neither the place nor the time to share that story…
p.p.s. please leave your comments and feature requests as comments below.
Jersey and Websphere 6.1
If you landed on this page it probably means that you’ve attempted to deploy a Jersey RESTful web service in IBM’s Websphere app server.
First of all: what were you thinking?!?
Secondly: it probably wasn’t your decision and you just need to make it work and move on. That was our case anyway…
So rather than bore you to death with how we ended up debugging the JVM and discovering that a java.lang.TypeNotPresentException is thrown when calling class.isAnnotationPresent from within the cores (com.ibm.oti.reflect.AnnotationHelper.getAnnotation) of the IBM J9 JVM rather than a plain true / false, I will just give you a bullet list of the things that need to happen to keep Websphere happy.
- Get your versions right! Jersey 1.0.3 and Websphere AS 6.1.0.25 (including 6.1.0.25 Fix Pack for Web Services) (Getting here is a blog post in itself and I will not do it here)
- Make sure that the enterprise app that contains your Jersey resources uses “Classes loaded with parent class loader first” and “Single class loader for application” (That is in your application’s “Class loading and update detection” section.)
- In your web xml configure the Jersey servlet to search for resources using ClassNames rather than packages. Basically make sure your web.xml looks similar to what I have below.
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 | <servlet> <servlet-name>Jersey Web Application</servlet-name> <servlet-class>com.sun.jersey.spi.container.servlet.ServletContainer</servlet-class> <init-param> <param-name>com.sun.jersey.config.property.resourceConfigClass</param-name> <param-value>com.sun.jersey.api.core.ClassNamesResourceConfig</param-value> </init-param> <init-param> <param-name>com.sun.jersey.config.property.classnames</param-name> <param-value> net.tmro.MyRESTfulResource </param-value> </init-param> <load-on-startup>10</load-on-startup> </servlet> <servlet-mapping> <servlet-name>Jersey Web Application</servlet-name> <url-pattern>/json/*</url-pattern> </servlet-mapping> |
- Okay, some clarification: the reason ClassNamesResourceConfig is used rather than PackagesResourceConfig is that when the packages are browsed for the actual @Path annotated classes an actual jar browsing is done which throws and swallows a nasty SecurityException… I invite you (more like dare you) to try using ClasspathResourceConfig and let me know if it works.
Now go ahead and give this a try… don’t forget to let me know if it worked or failed for you… Good luck!
Cheers….
iPhone how to: center and horizontal align the contents of a UITextField
Posted by Nick in Objective C, iPhone on August 7, 2009
It’s as simple as:
1 2 | theTextField.contentVerticalAlignment = UIControlContentVerticalAlignmentCenter; theTextField.textAlignment = UITextAlignmentCenter; |
Basically this will ensure that no matter how tall your text field is the actual text will be centered both vertically and horizontally.
Cheers…
iPhone build error
Posted by Nick in Objective C, Tutorial, iPhone on July 18, 2009
I had to deal with the same problem twice in the past 2 days so I decided to put together this little post explaining what one needs to do when they see an error message like this:
error: syntax error before ‘AT_NAME’ token error: syntax error before ‘}’ token fatal error: method definition not in @implementation context

Build error message
Basically, what happens here is that the target for my iPhone application is using the wrong C/C++ Compiler version.
Here’s the fix:
Step 1 double click the target (or right click Get Info) and change the Compiler version to GCC 4.0
Compiler Version changed to 4.0
Step 2 add 2 new build setting conditions (one for the simulator and one for the device)

Build Setting Conditions
Step 3 Set the values to GCC 4.2

Final settings
Hit the magic Cmd + B and you should now have a project that builds (or at least no longer complains about the syntax error above.
Cheers…

Recent Comments