Welcome to my blog where I write about software
development, cycling, and other random nonsense. This is not
the only place I write, you can find more words I typed on the Buoyant Data blog, Scribd tech blog, and GitHub.
software development
It seems that I might be going to BarCamp Austin2 this next weekend. I'll be presenting on "the importance of webservices" or something about as exciting. I'm still working on my presentation (ick) and I'm going to try to incorporate as many useless buzzwords, pot-shots at George W. Bush, and cult movie references as possible. I'm not sure how it's going to be, at least 41% more exciting than my last BarCamp presentation on Cocoa hacking and why everybody should, but still 12% less turtle-neck than a Steve Jobs keynote. I'll be sure to post my slides and hopefully a video or audio of the presentation later, but we'll see if I can make a presentation worth posting first.
software development
I recently recommended to a client that a project they were looking to have done in Visual Basic should be done in C#, but I found that it wasn't as easy as I thought it would be to articulate *why* I was recommending that. The easy answer was because I'm a C programmer at heart and C# is what I'm into these days, but given that the bulk of my professional experience in the last 4-years has been in Visual Basic, and that both C# and current versions of VB are fairly interchangeable for someone familiar with both, that reasoning seemed a bit weak.
I came across this article on programming in Visual Basic and it really rings true to me. I don't enjoy programming in VB quite as much, but at the end of the day I'll look back and realize that it made almost no difference to me at all. I have the same embarrassment about programming in VB that the author talks about on occasion, and I have the same thing with Windows programming in general in comparison to C on Unix-like systems.
I also thought the wikipedia article comparing VB and C# had a pretty interesting section on the VB and C# programming cultures. I know that my first project in VB6 was terrible. I had a fairly strong C on Unix programming mindset and even though the concepts should have been the same it took me a long time to figure out how to adapt what I knew about programming "The Right Way" to that environment. I can't honestly say for certain that was the fault of VB, it may have been my unfamiliarity with doing graphical user interfaces, but to this day it still feels more natural to follow good programming practice in C#.
Speaking of that first VB program, I'm inclined to agree that, given enough time I will think my old code was crap when I look back ...
opinion
I'm shocked that anything as simple as a music download site offering popular music (not major label stuff, but still some high profile artists) in unprotected mp3 files could be done so poorly. Seriously, how crappy must that system be if they have to force a .wma extension onto the mp3s? If they have a non-ActiveX download setup what's the deal with Mac downloads? How hard is it to have a properly descriptive error message for Mac users?
I can't even come up with words to describe how poorly they've done this. Has nobody involved with this mess ever actually thought of testing the site?
opinion
I try to separate my political leanings from my work, especially when it comes to blogging, etc, but this is too much. The House passed non-binding resolution on Iraq which is the latest in the long list of completely neutered actions by our legislative branch.
It's not a question of "supporting the troops" or "protecting the children" or "stopping terrorism" if you don't have the spine to keep the executive branch in check (what a quaint idea) resign so we can find somebody who isn't an absolute coward. Regardless of which side you lean towards politically, any executive branch that's given carte blanche is dangerous.
mono
As some of you may have noticed, the Twitterbot seems to always fail to authenticate properly against twitter's basic HTTP authentication prompt when run from Mono 1.2.3 on Mac OS X. This was neither an error in twitter's webservice (I have been running my bots from a FreeBSD machine with Mono 1.1.13 for some time now) nor in the Twitterbot code itself, but rather a regression in the System.Net.Configuration namespace, I'll let "kangaroo" (the developer who found and fixed the bug) explain:
13:03 <@kangaroo> ok its falling in to DoPreAuth
13:04 <@kangaroo> Authorization auth = AuthenticationManager.PreAuthenticate (this, creds);
13:04 <@kangaroo> thats returning null
14:04 <@kangaroo> got a patch for you
14:04 < rtyler> to compile into mono or my app?
14:05 <@kangaroo> http://monoport.com/1821
14:05 <@kangaroo> mono
14:05 <@kangaroo> you need a new System.dll
The patch should make it into the next bug-fix release of Mono (1.2.3.2) and should allow you to once again run Twitterbot on Mac OS X, otherwise you might want to try another machine, or step back a few point releases if it's that critical to have you Twitterbot running.
opinion
DRM made news thanks to Steve Jobs' open letter. I don't really have anything to say that hasn't been said already, but I found an article today that sums it up pretty nicely.
Of course I don't use iTunes much anyway, I'd much rather buy-and-rip CDs. I guess I'm doing just what Bill Gates says.
miscellaneous
There's really not a decent explanation for this, other than Terminal.app went bonkers. I've seen this happen before to some extent if you have an NSWindow that has transparent background, but a partial background drawing like here is something completely new.
miscellaneous
You may have noticed recently (hopefully not) this site kicking back a simple, plain-text error: An internal server error occurred. Please try again later
The root of this issue was some scripts inside Drupal simply taking too long and timing out, which I believe, has been resolved by enabling e-accelerator in the site's .htaccess file. I'm hoping that has killed the errors, if it hasn't feel free to drop me a line at tyler@bleepsoft.com and let me know the site is broke again :)
Special thanks to Dave at GeekISP of course for being accommodating with my silly complaints.
cocoa
Ever since coming across the (draft) specification for NAT-PMP I've been almost in love with the absurdly simple NAT port mapping protocol. The unfortunate downside is that NAT-PMP isn't well supported except on Airport base stations, one of which I recently acquired, so as is customary when I welcome a new device into my apartment, I had to write some code for it. I hate to sound like a fan-boy, but like Bonjour, Stuart Cheshire's other baby, NAT-PMP is sickeningly simple. A series of straight-forward UDP packets is all that is needed for a local (inside the NAT) device to create a mapping on the NAT device itself.
To exhibit this functionality, I've created a sample application that uses a tiny little library I built to create and destroy mappings on the NAT-PMP enabled device. The application is called "PmpMyApp" and can be found on GitHub
The code contained in pmpmapper.c has three basic functions that perform the functionalities that NAT-PMP provides, and are aptly named as well:
struct sockaddr_in *pmp_get_public();
pmp_map_response_t *pmp_create_map(uint8_t type, uint16_t privateport, uint16_t publicport, uint32_t lifetime);
pmp_map_response_t *pmp_destroy_map(uint8_t type, uint16_t privateport);
The pmp_get_public() function returns a pointer to a sockaddr_in that contains the external IP address of the NAT device. The pmp_create_map() function does the heavy-lifting, in that it will create the actual mapping (and the deletion too, with a zero lifetime) and will tell the NAT device to persist the mapping for the number of seconds specified with the lifetime argument. The code is commented so it should be very easy to get a feel for how to use the pmpmapper functions, a good place to start is by examining how it's used in the PmpMyApp source. (Note: All of the PmpMyApp code is BSD licensed)
miscellaneous
I am not certain if forgetfulness is a side effect of working too much, or general stress, but I spent about a minute looking around for my keys before finding them still sitting in the lock on my front door.
In the attached video, I found that my mouse was in a perpetual state of scrolling down. Not a quick scroll either, a nice leisurely one, the kind you take on the beach, a nice leisurely scroll down in every window with a scrollbar in the entire operating system. Gak.
mono
I finally got around to testing FTGL# with Mono on Windows. Didn't require any modification, but there's one oddity ...
C:\Documents and Settings\stephen\My Documents\work\FTGLSharp\sample\bin\Debug>"FTGLSharp Demo.exe"
Opening Font File C:\Windows\Fonts\arial.ttf
Setting 24pt, 72dpi
Done font initialization
sap.ftgl.MainForm, Text: FTGL.OnActivated() called
sap.ftgl.demo.demoControl.forceRefresh()
sap.ftgl.demo.demoControl.OnPaint() called
sap.ftgl.MainForm, Text: FTGL.OnActivated() called
sap.ftgl.demo.demoControl.forceRefresh()
sap.ftgl.demo.demoControl.OnPaint() called
C:\Documents and Settings\stephen\My Documents\work\FTGLSharp\sample\bin\Debug>mono "FTGLSharp Demo.exe"
Opening Font File C:\Windows\Fonts\arial.ttf
Setting 24pt, 72dpi
Done font initialization
sap.ftgl.MainForm, Text: FTGL.OnActivated() called
sap.ftgl.demo.demoControl.forceRefresh()
sap.ftgl.MainForm, Text: FTGL.OnActivated() called
sap.ftgl.demo.demoControl.forceRefresh()
I don't know yet if it's Mono or Me (I'm usually missing some detail ...) but OnPaint() isn't happening when it should if I fill my control with another control
opinion
Time-Warner (again) had an outage this morning, and it has somehow left my Linksys WRT54G absolutely incapable of routing properly.
From the router administration page, I can ping public servers. From inside the network, I can ping ping local machines. I can properly resolve hostnames, I just can't ping anything on the public internet, from inside the network. My router has become absolutely dysfunctional as anything but a simple switch.
I'm only lamenting that I don't know of a taller building from which to hurl this miserable piece of shit from.
mono
While I have been know togripeabout WebServicesCore, there are however options now when developing service-oriented applications. Introducing, Dumbarton; Dumbarton is basically a ObjC-C# bridge that makes use of the Mono embedded API to allow you to utilize C# code from within your Cocoa application. Personally, I think writing SOAP consumption code in C# using Mono or .NET is far nicer than trying to write something using C/Objective-C via WebServicesCore, so this is my "favorite" option. The word favorite being in quotes as unfortunately Dumbarton is a bit complex to use and bundle for a smaller Cocoa application.
Dumbarton is however an option, so I wrote up a quick example that makes use of a currency exchange rate webservice via xmethods.com and essentially rehashes the proverbial "Currency Converter" sample project with an up to date exchange rate. I've pushed the project to GitHub in case you want to check out the whole project.
the nitty gritty
Mostly because I'm a lazy developer (who isn't?) I used the standard "wsdl" executable that you can find in .NET or Mono to generate the necessary stub class for providing the last intermediary layer between our desktop application. The method that's generated (synchronous) that we'll write our wrapper for is:
public System.Single getRate(string country1, string country2);
which will handle the actual webservice invocations which we'll write a small Dumbarton wrapper for. Interacting with SOAP webservices in .NET/Mono is quite simple however, so it'd be trivial to take an existing set of generated stubs and modify them, or simply write all the code from scratch.
The Dumbarton wrapper provides the neccessary "boot strapping" for a bridged object between Cocoa and Mono and also "acts" as the bridged object for the C# class. For example, our Dumbarton wrapper class is called CurrencyConverter which is a subclass of DBMonoObjectRepresentation, and in the wrapper method we call:
[self invokeMethod:"getRate" withNumArgs:2,str1,str2];
which will invoke the C# method getRate(string,string) and return a MonoObject pointer. The bridged methods will return a MonoObject pointer which you can either unbox with the DB_UNBOX_* macros provided in the DBBoxing.h file, or you can invoke methods on that object like CurrencyConverter does with:
(MonoString *)(DBMonoObjectInvoke(rateObj,"ToString",0,NULL))
in order to return a string, or another MonoObject pointer to use. Overall it's really simple to use once you have all the ducks in a row, such as llinking against the Mono.framework and the Dumbarton.framework properly, and you load them into the DBMonoEnvironment appropriately.
notes on CurrencyConverter
I bundled a Dumbarton.framework build that I had handy inside the Subversion repository, but I have linked this against the Mono 1.2.3-preview that I have installed on my machine, so I recommend you checkuot the latest Dumbarton from Subversion (svn co svn://svn.myrealbox.com/source/trunk/Dumbarton) and install the latest stable version of Mono (1.2.2). If you feel like trying out the preview, you can grab the Mono 1.2.3 preview installer to link your custom Dumbarton build against. Something to note however, is the Installation Path in the Dumbarton Xcode project is set to /Library/Frameworks currently, so if you want to link against it and bundle it inside your application bundle you'll need to update that to @executable_path/../Frameworks and then bundle it in the same fashion you would with Growl or Sparkle. You will also need to setup a copy files or a build script phase to handle your bundling of the DLLs inside the application bundle as well. Distributing an application that uses Mono and Dumbarton is a bit stickier, as you have to pick and choose which libraries to bundle, etc, check out this thread from the mono-osx list.
the springer final thought
Depending on your familiarity with developing with C# in either Mono or .NET, Dumbarton may be a great option for utilize existing .NET code for webservices, write cross-platform webservices code, or just avoid the pains of WebServicesCore; it can also be another frustrating stop on the avenue of SOAPy pains if you misunderstand how Dumbarton or C# works. It's currently on my ever lengthening todo list to start documenting far more of what you can do with Dumbarton, but hopefully the examples distributed with the source, along with CurrencyConverter provide a good starting point for those who feel crazy enough to try it out.
As a side note, I have 8.6444 pound in my wallet right now.
cocoa
Steve Scott of Late Night Cocoa asked me a couple weeks ago if I wanted to come on and talk about BuildFactory and continuous integration, and then that slowly morphed into talking about webservices and Dumbarton as he noticed I posted some WebServicesCore gripes. We got to chatting a bit about why Mac developers don't seem to "appreciate" webservices as much as those in the .NET world, etc and eventually got together to record Web Services with R. Tyler Ballance.
If you've not checked out Late Night Cocoa, I highly recommend it, it's already shaping up to be a good (technical) podcast about Mac development (the Core Data with Marcus Zarra interview was fantastic, a hard one to follow). If nothing else I hope most developers can use my interview to get a better feel for what's available in the growing webservices (2.0!) landscape. A more active discussion about the strengths and weaknesses in the Cocoa frameworks can do nothing but make the Mac development community stronger, check it out!
opinion
I came across this after reading a bit about the "bomb scare" in Boston today, and cannot come to any other conclusion than "we're retarded." In the picture in the article linked above, even I can clearly see that it's really not a bomb, it's hardly even a "device" but nonetheless, these "hoax packages caused alarm in Boston."
I fear that in this age of increased terror-McCarthyism and ridiculous (shallow) security measues, if I were to forget my backback under the table in an outdoor café, I would return later to retrieve it and be greeted by a bomb squad apprehensively approaching my backpack filled with nothing more explosive than a half-eaten roast beef sandwich.
To the staff of "Aqua Teen Hunger Force" it was nice knowing you, and I'm sorry but you're all about to be implicated in an eeeevil terrorist plot to bombard Boston with poor animation; regardless, I hear Cuba has wonderful weather this time of year.
cocoaTodd Ditchendorf is the man I have to thank now, not only for his fantastic SOAP Client, but now for "showing me the way" in terms of using CFNetwork to handle basic HTTP authentication with SOAP webservices in Cocoa. Performing the basic HTTP authentication is still an absolute pain in the ass, but it is possible nonetheless.
academia
Apparently, predictably, and late to the party, research publishers are getting nervous about the push for Open Access. Hopefully this is just an idea for a push from the publishers that will quickly be dropped, but from an article on nature.com (found via slashdot of course):
Public access equals government censorship
I hesitate to even quote that because it's so far off-base. There was more too, but since this is just an article on a potential future publicity campaign I don't really think a thorough response is warranted. If the publishers ever try pushing this BS on the research community I have no doubt the response will not be what the publishers hope.
These publishers have to realize that the entire reason they exist at all is because they have been the best way to make information available to as many people as possible. Publishing researchers want their work to be available and if traditional publishers can't continue to be a relevant way to make that happen then they simply don't have a viable business model. Personally I still think there's value in subscriptions to printed journals, and I'm sure people I work with feel the same.
mono
As I previously mentioned, I've written a small C# application called "Twitterbot" that grabs items from an RSS feed and retrofits them for twitter. After discussing it with some of the folks over at twitter, they have no problem with me open sourcing the litte bot, so I give you, the Twitterbot.
I also added a few fixes this morning after adding the hybridized twitter-thing:
Improved duplication checks
Refresh slow-downs between 12:00 and 6:00 am (exclusive)
Better error handling
A few comments :)
The Twitterbot can be downloaded from the subversion repository, details are located on the Twitterbot's page. The Twitterbot is BSD licensed and will run with both .NET and Mono. Enjoy!