Archive for the ‘code’ Category

I can be a C-numptie

Wednesday, November 22nd, 2006

This might not be earth-shatteringly new to those who have seen my code before, but I was a little surprised. 🙂

A C program that I wrote a little while ago (and has previously worked fine on Windows, Linux, Solaris and HP) failed horribly on AIX. A little digging showed that I had written:

char* thisIsSupposedToBeAString[256];

I guess that at the time I wrote it (presumably early in the morning, and caffeine-fuelled) I had a string (char thisIsSupposedToBeAString[256];) and wanted a pointer to it, so went back and stuck a * on it without thinking.

(more…)

Using Scheduled Tasks and batch files to do automatic backups

Friday, November 17th, 2006

As I’ve started storing all of my project work and GTD notes in my Wiki program, I thought it might be a good idea to take regular backups of the text files it uses for data. And being a geek, I thought I’d automate it. 🙂

@ECHO OFF
REM this makes the batch file less noisy - dont 
REM  output commands to screen

REM limit scope for environment variables created here REM to within this batch file only SETLOCAL
REM make a note of where the current directory is REM so we can go back there afterwards REM (useful when running this batch file manually) set DIR_TO_RESTORE=%CD%
REM run the 'date /t' command REM this outputs in the format: REM 19/11/2006 REM (probably different for people with non-UK regional REM settings)
REM Using for to look at bits of date individually... REM FOR /F ["options"] %variable IN ('command1') DO command REM options - REM tokens - identify which bits of the date output I want REM (3 tokens - day month year), REM delimiters - how they are separated ('/') REM (users with non-UK regional settings might REM need to change this - e.g. for '-') REM command - REM 1) date /t - show date without prompting to change it REM 2) set - set environment variables to store each token FOR /f "tokens=1-3 delims=/ " %%G IN ('date /t') DO ( REM set environment variables to store individual date values REM (assumes date/month/year - users with non-UK regional REM settings might want to switch date and month) set dd=%%G set mm=%%H set yy=%%I)
REM this gives us a numeric date - in the format yyyyMMdd REM which is useful in filenames for sorting set TODAY=%yy%%mm%%dd%
REM go to first directory containing something to backup REM tar it up, and move it to a backups directory cd "C:\\Documents And Settings\\Administrator\\My Documents\\bLADE My Documents\\" "C:\\cygwin\\bin\\tar.exe" -cvf %TODAY%_gtd.tar WM_Wiki_Pages move %TODAY%_gtd.tar "..\\My Personal\\WMWiki Backups\\."
REM repeat as required cd "C:\\Documents and Settings\\Administrator\\My Documents\\My Personal\\" "C:\\cygwin\\bin\\tar.exe" -cvf %TODAY%_ref.tar "My WM Wikis" move %TODAY%_ref.tar "..\\My Personal\\WMWiki Backups\\."
REM finished! go back to where we started cd %DIR_TO_RESTORE%
REM end scope for environment variables ENDLOCAL

(more…)

Using IContextMenu to extend Windows apps

Sunday, November 12th, 2006

I read a couple of weeks ago about Google acknowledging that they’d released too many products, and deciding to focus on developing features for existing products where possible in future. screenshotWith this in mind, this evening’s idea for Windows Mobile development is an extension to one of the core applications rather than a new application.

‘Email Triage’ is my extension to Pocket Outlook. Pocket Outlook comes with Tasks, Calendar and Messaging (for emails, SMS, and MMS). Despite the way the ‘Pocket Outlook’ sounds, these are more or less separate applications, which don’t interact other than sharing a common database to store information. As a user, the common name feels like mainly a branding thing. So I thought I’d try bringing them a bit closer together.

(more…)

I can actually finish stuff! (sort of)

Sunday, November 5th, 2006

My Thinkpad is full of random bits and pieces of unfinished code. Typically, I’ll have an idea for something, and do enough of it to convince myself that I’d be able to do it. Something like a coding magpie, I then get distracted by something else and never get round to going back and finishing it. Given that, I’m all the more impressed that I got round to finishing the Windows Mobile wiki-based notetaking app that I started last Sunday.

I know about a few little kinks in the code, and I’m sure there are many more. So maybe not completely finished, but it’s in a state where I can start using it, and have made it available to a few other people to use it as well.

(more…)

Using .NET WebBrowser to create a mobile wiki

Sunday, October 29th, 2006

Wrote another Windows Mobile app tonight – this time I even tried it out on my phone and not just the emulator!

The idea of this one is an alternative to the built-in Windows Mobile “Notes” application. Instead of single ‘post-it-style’ notes, the idea is to use a wiki approach – a personal wiki, entirely hosted on the PDA. (Partly because it is quicker to use local files, but mainly because I’m too skint to pay the mobile data fees to access an online wiki :-))

I prefer the wiki approach to note-taking – mainly for the quick and easy formatting and the hyperlinks between pages. I’ve used something similar before on Palm OS for a couple of years now – ‘NoteStudio‘ by DogMelon. This is a brilliant app, which I really miss since moving to Windows Mobile as my main PDA. (There has been some talk of a Windows Mobile for a while now, but this is looking a little like vaporware).

When I saw that the .NET compact framework included a web browser widget, I thought I’d see how hard it would be to knock together a wiki tool tonight.

(more…)

Hello (Windows Mobile) World!

Saturday, October 28th, 2006

Finally – a chance to play with my new Windows Mobile developer kit. I had my first go with it tonight, and so far, I’m pretty impressed.

The Windows Mobile 5 API exposes a lot of nice stuff to the developer – just looking through the overview page on MSDN.com showed me lots of stuff I want to have a go with. Like interacting with the phone, incoming calls, SMS messages – sent or received, using the phone’s internal camera, getting all sorts of system info like battery data, and loads more. So much to play with! The overview page also shows how easy it is to access the Pocket Outlook database, so I thought that this would be a good place to start.

(more…)

My Windows Mobile developer kit has arrived!

Wednesday, October 25th, 2006

Microsoft give away free developer resource kits for Windows Mobile. A two-disc DVD set, it comes with everything needed to write apps for Windows Mobile 5 – an IDE, SDK, the .NET Compact Framework, emulators for development and testing, API and documentation, and a bunch of educational resources like samples, walkthroughs and videos. I ordered it a little while ago, and it’s finally come.

I’m out tonight, so will have to wait before I can have a play. I’m looking forward to it, though – will have to try writing a small app for my phone tomorrow night.

What happens to Outlook add-ins when Outlook goes away?

Sunday, October 15th, 2006

I tried writing another Outlook extension tonight. This time, a desktop widget to display a dashboard-style at-a-glance view of how busy I am (based on my Microsoft Outlook task list).

screenshot of the app I wrote it to run in the background, and update itself once a minute. This raised an interesting question – what to do with the handle to Outlook.

Getting the handle to Outlook is probably the slowest bit of the app, so I don’t want to do this every minute. But caching a handle and reusing it ad-infinitum probably isn’t safe – what if Outlook is closed or restarted, (or… whatever happens when Windows hibernates?) while the widget app is running? Would the widget hold locks on the Outlook data file and cause a closing Outlook to hang? Or would the widget just fall over the next time it tried to use an invalid handle to the Outlook object model?

(more…)