…and I intend to finish sometime (where sometime is > now && < end of time)
It’s been a while since I last paid this blog any attention. Since my last post I’ve changed job, country and had a haircut.
I’ve started toying with iOS applications and came across the EXC_BAD_ACCESS error fairly early on. Googling around tells me this is a fairly common error with all manner of causes, many of which stem from a misunderstanding of the memory management required when working is obj-c on iOS devices.
I’ll start by saying that I am a novice obj-c developer and have been spoilt for many years with modern languages that include garbage collection as standard. I understand pointers and reference and scalar variables but this knowledge has never been more pertinent than now.
I was initialising an NSDictionary as in the code snippet below. Content and username are NSString objects and type is an NSInteger, and there exactly is my error.
NSDictionary *post = [NSDictionary dictionaryWithObjectsAndKeys: content, @"content", username, @"user", type, @"type", nil];
NSDictionary stores objects (id types, or pointers to an object) with another object as the key, in this example all my keys are NSString objects. The error with my code is that type is NSInteger which is a scalar type. When attempting to store the NSInteger it is being interpreted as a pointer and therefore likely to point at an invalid memory location.
So that’s my understanding of the problem, what’s the solution?
Quite simple really, instead of storing a scalar type we need to store a pointer to an object, iOS provides the class NSNumber to solve the problem. So taking this into account the above code becomes:
NSDictionary *post = [NSDictionary dictionaryWithObjectsAndKeys: content, @"content", username, @"user", [NSNumber numberWithInt:type], @"type", nil];
and our EXC_BAD_ACCESS error goes away. I can tell my experience with objc and iOS is going to be a challenging but fun one!
This post is an update to a previous post regarding project hamster.
Since installing the missing project hamster to my gnome 2.24 upgrade I have used it daily at work to track the time spent on each of the many projects I will participate in on any given day and it has been absolutely marvelous at helping me fill out my timesheets accurately.
In addition to the amount of time I spend on a project and the name of the project, both of which are tracked superbly in 2.23, I also have to enter a description of what I was doing for each period of time logged. It is at this point that I found project hamster lacking. Until now!
I’m not sure if it was in version 2.24 or 2.25 of hamster that the description field was added but it’s a very welcome addition.
When you update an activity in 2.25 you now have a description text area to store exactly that, a description! The even better way of inputting a description is with the single activity text box by splitting the activity and the description with a comma. i.e. “activity_name, here is what I did during this activity”
Additionally the single activity box can also be used to set the category of the activity by adding an @ symbol. i.e. “activity_name@Work, here is what I did during this activity” nifty eh?
So now that I’ve teased you with what the new version does here is a description of how to upgrade from source, it’s fairly straightforward especially if you’re familiar with building applications from source already.
1. In a terminal enter the following command which will install all the necessary dependencies for building hamster (the line below will cover wrap onto 3 lines though it should be entered in the terminal as a single line)
sudo apt-get install gnome-common python-pysqlite2 python-gtk2 python-gtk2-dev python-gobject python-gobject-dev libgconf2-dev python-gnome2-dev x11proto-scrnsaver-dev libxss-dev
2. Grab yourself a copy of the source from http://ftp.gnome.org/pub/GNOME/sources/hamster-applet/2.25/hamster-applet-2.25.3.tar.gz
3. Extract the source file to a folder, assuming you downloaded the source to your home directory you could extract it with the following commands
cd ~ tar -zxvf hamster-applet-2.25.3.tar.gz
4. Now the commands to actually build the plugin, again assuming you extracted the source in the line above to a folder named hamster-applet-2.25.3 in your home folder
cd ~/hamster-applet-2.25.3 ./configure make sudo make install
5. And that’s it, should be rather painless, unless something goes horribly wrong (in which case leave a comment and I’ll see what I can do to help) All that’s left is to remove hamster from your panel and then add it again from the Add to panel dialog. Check that you’re running version 2.25.3 by right-clicking on the hamster applet and selecting About.
As always I hope that helps someone, comments are always appreciated.
Here is an update to a previous post regarding how to get gedit to recognise Smarty template *.tpl files. I’ve found that gedit prefers to use the mime type to decide what type of file it is and therefore what syntax highlighting to apply.
After a little investigation I found that most of my .tpl files were being identified as text/plain in Nautilus (found by right-clicking on the file and selecting properties, on the basic tab the type field will tell you the mime type nautilus is seeing it as)
My new solution to this problem is to convince nautilus (and gedit) that the *.tpl files are in fact HTML files and therefore syntax highlight them in the same way, and here’s how to do it:
cd /usr/share/mime/packages sudo cp freedesktop.org.xml freedesktop.org.xml.backup
sudo gedit /usr/share/mime/packages/freedesktop.org.xml
<glob pattern="*.php"/> <glob pattern="*.php3"/> <glob pattern="*.php4"/>
sudo update-mime-database /usr/share/mime
The only drawback with this option (and I consider it a rather minor inconvenience) is that double clicking your tpl files will try and open them in Firefox by default now, you can change this to open in gedit by default but then all your .html and .htm files will open in gedit by default too.
You choose which you prefer, I personally have no problem leaving them to open in Firefox by default since I rarely double click tpl files in nautilus, I usually use the file browser plugin in gedit.
Thanks to a suggestion by Sudhanshu I’ve edited the post to add the tpl entry to the php section of the freedesktop.org.xml file instead of the html section. The benefit of this is that you can now double click tpl files and have them open in the same application as php files (usually gedit) while html files will still open in your browser.
As always comments are appreciated on whether this was helpful or if you’ve found a better way.
Another post concerning my upgrade experience with Ubuntu 8.10 this time with regards to VPN connections. I keep meaning to take the time to write a more comprehensive piece about the upgrade as a whole but for now I’ll keep posting little snippets of minor annoyances and how I solved them.
This problem appeared when I attempted to connect to a VPN for the first time since the upgrade. Firstly all of my saved VPN connections were gone, slightly annoying but understandable since the network manager has undertaken a major overhaul in this version. So I create a new VPN connection to a Windows 2003 Small Business Server I manage, I entered the host, username, password and domain and left everything else as default. I try to connect to the new connection and almost immediately an error message pops-up (certainly quicker than my machine could even resolve the hostname)
The precise error was “The vpn connection xxx failed because there were no valid VPN secrets” (not quite the precise error message since the connection wasn’t called xxx, having a VPN connection named xxx would conjure up unsavoury, NSFW thoughts…)
I won’t go into the whys and hows because I honestly haven’t had the time to find out but the answer for me was to go back and edit the VPN connection and remove the password. Next time I connected to the VPN I was prompted for the password and everything was back to normal and I can continue with my task of reading someone elses email mwah hahaha!
This is just a quick post concerning my upgrade to Ubuntu 8.10 Intrepid Ibex, there will be more to come later.
One of the new features I was most anticipating in this upgrade was the time tracking applet included with the upgrade to Gnome 2.24. I have to fill in daily time sheets at work and trying to keep track of what I work on in any one day has become a real hassle, I was hoping this applet would make completing these time sheets a lot easier so imagine my dismay when after performing the upgrade to 8.10 and opening the add to panel dialog I found no such applet!
Long story short and without explaination because I don’t know why it wasn’t there but I was able to add the time tracking applet by running the following in a terminal
sudo apt-get install hamster-applet
after installing hamster the time tracking applet was in my add to panel dialog and I am indeed looking forward to using it (apparently it took me 8 minutes to write this post!)
Anyone that has read my blog before will know that I recently switched to Ubuntu as my primary OS however what I haven’t mentioned is that I also have a Windows XP virtual machine running for the sole purpose of running Outlook for my work email.
When I set up the virtual machine I was a bit too tight on the amount of space I gave to the primary hard disk image and have very quickly go to the point where Windows is complaining of a lack of space on drive C:
Firstly I moved the swap file to another virtual hard disk which solved the problem for a time but not for long. So I did some searching for files that were taking up space and found my Outlook offline cache file (outlook.ost) was fairly sizable so I wanted to move that too to the other virtual hard disk I’d set up, moving a file should be a straightforward task right? not if Microsoft has anything to do with it. Here are the steps you’ll need to follow in order to move your outlook.ost file.
Your outlook.ost file is now being used from it’s new location. Only 15 steps to move one file, and some of those steps I’ve doubled up on to be kind!
I understand that this has been improved in 2007 but I haven’t got a copy of that on hand to verify.
As always, I appreciate your comments. Let me know if this did or didn’t help you.
Another post regarding my recent switch to Ubuntu as my primary OS, this one concerns the VNC client/viewer bundled. I’ve been having problems with Remote Desktop Viewer which is the bundled and preferred VNC client in a default installation of Ubuntu 8.04, I’ve had random freezes and disconnects with a logout/login of my machine sometimes resolving the issue temporarily.
The alternative is to use the Terminal Server Client application to connect to a VNC server, should just be a case of selecting VNC in the protocol dropdown right? nope, it’s greyed out*sigh*
To enable the VNC option in the Terminal Server Client dropdown you need to install the xtightvncviewer package either in Synaptic or with
sudo apt-get install xtightvncviewer
I fired up the Terminal Server Client, selected the VNC protocol, set the display to full screen and connected to my server.
Job done? not quite. I’m now prompted by my server with a “press ctrl-alt-del to logon” message. That’s where I had some problems, pressing ctrl-alt-del caused Ubuntu to ask me how I want to shut down. I needed some way of sending a ctrl-alt-del to the remote machine but I couldn’t see any obvious way of doing it. Queue the next problem, I’d selected full screen and that’s what I got, completely full screen, I couldn’t even switch to an alternative workspace since the VNC viewer remained on top.
I really didn’t want to restart my machine just because I couldn’t get rid of one window so I started randomly hitting buttons whereupon I found that F8 was rather useful! Pressing F8 with the VNC viewer focussed brings up a small menu with a number of options one of which was to toggle full screen and another was to send ctrl-alt-del to the remote machine, hooray!
I’ve found this VNC viewer to be a bit quicker at screen refreshes (though it does more of them) and more stable than the bundled viewer in Ubuntu, feel free to leave a comment to the contrary or suggesting another alternative that you may use.
I’ve been battling with the YouTube API for the last 2 days now and found the single line of code that has been preventing me from generating a form upload token.
I was following the example code at http://code.google.com/apis/youtube/developers_guide_php.html#UploadingVideos and kept receiving “Expected response code 200, got 400″ when calling the getFormUploadToken function. HTTP error code 400 is a bad request which wasn’t really much help.
Eventually I found the problem and I will own up straight away that it was basically my fault, I’d made what I considered to be a slight change to the example code, I changed
$mediaGroup->category = array( $yt->newMediaCategory()->setText('Autos')->setScheme ('http://gdata.youtube.com/schemas/2007/categories.cat'), $yt->newMediaCategory()->setText('mydevelopertag')->setScheme ('http://gdata.youtube.com/schemas/2007/developertags.cat'), $yt->newMediaCategory()->setText('anotherdevelopertag')->setScheme ('http://gdata.youtube.com/schemas/2007/developertags.cat') );
to the following
$mediaGroup->category = $yt->newMediaCategory()->setText('Autos')->setScheme ('http://gdata.youtube.com/schemas/2007/categories.cat');
because I wasn’t interested in multiple categories, just something simple. My mistake was not in removing the two developer tags but removing the array(). This took me almost an entire day to realise and resulted in a “You have to be kidding” comment from me once fixed. *Sigh* oh well, not going to get that time back but at least I learned not to mess with example code.
Update: I have posted an alternative way to do the same thing this post describes, the alternative way should be more reliable. See it here http://www.c3b.co.uk/2008/12/16/alternative-method-for-opening-smarty-templates-with-html-syntax-highlighting-in-gedit/
I’ve started using gedit as my code editor after a couple of niggles with bluefish and wanted my smarty templates (*.tpl) to use the same syntax highlighting as HTML. Not wanting to have to manually select the language each time I open a .tpl file I went searching for a way to add them to the definition of what an html file is. I was getting frustrated with all the references to a syntax highlighting tab in the preferences dialog that just didn’t exist! Even the help file in gedit 2.22.1 still mentions the syntax highlighting tab but I can assure you it’s not there.
The solution I came up with was to manually edit the HTML language definition file for gtksourceview which is what gedit uses to define the syntax highlighting. To achieve this you must change the following line in the /usr/share/gtksourceview-2.0/language-specs/html.lang file:
Or download my version here (html.lang) of the file and run the following command:
Backup existing file
cd /usr/share/gtksourceview-2.0/language-specs sudo cp html.lang html.lang_bkup
Then move the downloaded version of the file into place (this assumes you download the file and extracted it to your home directory)
sudo mv ~/html.lang /usr/share/gtksourceview-2.0/language-specs/html.lang
Restart gedit and when you next open a .tpl file it will be highlighted in the same way as an HTML file.