Jason Mauss' Blog Cabin

Because someone's got to do the dirty work

Blog-Flair

Blogroll

Links

July 2004 - Posts

Finally - a *good* GMail client

A friend of mine that works at the California State Bar IM'd me today to tell me about a GMail client that a co-worker of his Johnvey Hwang has built. I downloaded and installed it, and lo and behold, it works great! I had tried a couple of different GMail clients before, but they all had little annoyances with them that lead me to uninstall and stop using them. So far though, no annoyances detected with this one. Good job Johnvey!

Get it here.

Bonus: On his site, Johnvey has some interesting details about how GMail is implemented. Web developers would be wise to read up and study this technique. Look below the download link.

Supressing the 'Save As...' dialog with Acrobat PDFWriter 5.0

I noticed over on Jason Bock's blog he had been writing a little bit about some PDF development he'd been doing - so I thought it might be appropriate for me to chime in with a little helpful info of my own involving PDF development.

The application I'm currently working on requires using some older technology (VB6/ActiveX/ASP 3.0/ADO). In addition, some of the output needs to be exported into PDF documents. One of the tools we're using (ActiveReports) has native support for exporting to PDF but, the other tool does not. So our solution (rather than buying a 3rd-party PDF component) was to just print the document to the Acrobat PDFWriter printer driver, thus giving us a PDF document.

The only problem is that this application is part of an automated service that processes these documents on a server and it can't require any user interaction. This is a problem because when you print to the Acrobat PDFWriter with Acrobat 5.0, before you can get a PDF file you get this:

Seeing as how I couldn't allow this, I needed a way to programmatically provide the name of the PDF file to the Acrobat PDFWriter printer driver before printing. While this isn't exactly the “Adobe API” way to do it - there is a simple registry hack that solves the problem and works quite smoothly.

 

Creating a String Value named PDFFileName under the registry key shown in the status bar above, the Acrobat PDFWriter printer driver will use that value (“C:\PDF6.pdf” in the image above) and print to the PDF file without asking for anything from the user. While I wouldn't exactly call this robust, it works. (Be careful though - after the Acrobat PDFWriter printer uses the value, it removes it entirely from the collection of values, so you have to add the value back before each printing). I'm simply using the Registry API (RegCreateKeyEx) from within VB6 to accomplish this.

For those of you developing with Adobe Acrobat Distiller (Version 6.0 of Adobe Acrobat) the “Adobe PDF” printer driver and Distiller have a much more robust and powerful API. The Acrobat PDFWriter printer driver is nowhere to be found as of version 6.0. It's all about Distiller for Adobe going forward.

The Complete Reference - JavaScript 2nd Edition - Review Part 1

A couple days ago I received my copy of this book from Osborne/McGraw-Hill. (X)HTML/CSS/JavaScript (a.k.a “DHTML“) isn't going away any time soon so I felt now was as good a time as any to start further educating myself on one of the most used languages of the web - JavaScript. I've previously read a couple of Thomas Powell's web development books and I really like his style of writing. It's clear and concise and he rarely leaves pertinent information uncovered. This book has been no exception so far. I've read through the first 4 chapters and it's already taught me a few things about JavaScript.

This book really targets a wide audience too. The first chapters discuss not only beginning JavaScript concepts, but beginning programming concepts. The nomenclature, topics like variable scope, weak types, data type conversion, event handlers, operators, expressions, etc. It even attempts (briefly) to give the reader a quick primer on objects and how to use them with JavaScript. I've not skimmed -- but quickly read -- these first chapters as there wasn't a whole lot to learn for me.

I'll follow up with a review of further chapters tomorrow on Functions, Objects, and Regular Expressions. A good read so far - albeit a little bit of a bible/tome-sized book.

 

Language Wars and Developer's Dirty Laundry

After reading Carl's thoughts on this page, and then LazyCoder's comments, it was Rory's post that finally provoked enough emotion in me to want to weigh in with my 2 cents. And Rory, don't worry man, I fell for the whole Nike Swoosh gimmick too - and I'm far too embarassed to mention how old I was before I came to the same realization you did.

What came to mind though, had little to do with how petty and trivial the language argument is. My thoughts kind of shifted up a level and I looked at it from a broader perspective. I thought to myself, “Why do developers let themselves get dragged down into these kinds of arguments? Arguments based on unfounded truths, name-calling and contempt for anything different than themselves?” If you were wondering what I meant by the title of this post, it should be clear by now. There still exists a percentage (anything greater than 0% is too high) of developers that like to air this dirty laundry any time, any place, for any reason. I'm not talking about Carl, Rory, or those that let people know how pointless the language wars are. I'm talking about the schleps that set back the progress made by other developers and corporations in attempting to put a rational, human face on software development. It seems that for every developer able to pass for a normal human being, you've got 2 or 3 of the “Steve Urkel-Ignorant Zealot-Slashdot Bigot-FUD Lovin' PHB” types. Just think “Lumberg“ from Office Space. I bet he'd love to tell you how VB.NET is a toy language and that Samir and Mr. Bolton got hired because they knew Assembler. I wonder how Initech's .NET migration is coming along.

Is it just this industry? I haven't done work in enough industries to know. Perhaps it has something to do with the type of people this industry appeals to. One thing is certain though; developer stereotypes are still just about as true now as they've ever been. Developers are introverted, socially inept nerds that hold non-technical people in contempt for not sharing their lust for open-source code and the latest gadgets. I'm not saying I'd like to see an industry full of metrosexuals (yes!! I finally got a legitimate use of that word in a blog post) but, it wouldn't hurt to see more developers turning a deaf ear to these religious language war debates. It's to the point now where lies have been perpetuated for long enough that it's becoming the accepted truth, and that aspect of it bothers me a lot more than what language someone prefers to code in.

Setting the System Default Printer with Visual Basic 6

I know this doesn't exactly qualify as “.NET” knowledge but, it's something I've had to battle with for a while so I thought I would post it in case anyone else finds it as helpful as I have.

How to set which printer is the system default printer

Now, setting a printer to be the system default printer in Visual Basic 6 is way more difficult than it needs to be. If perhaps the DeviceName property of the VB.Printer object wasn't read-only we could set the default printer by passing the name of a printer to that property. Or, in perhaps a more OO approach, It would be nice if there was a “VB.DefaultPrinter” object that we could set equal to a particular VB.Printer object. Something like this would do:

Dim p as VB.Printer
For Each p In VB.Printers
   If p.DeviceName = “ThePrinterIWantToBeTheDefault“ Then
      Set VB.DefaultPrinter = p
   End If
Next

I would at least feel better about writing code like that than having to monkey around with the Win.ini file. Sheesh.

UPDATE: Wow, I really feel stupid now. I spent the better part of an entire workday trying to figure out how to do this when I could have just referenced the Windows Script Host Object Model (/system32/wshom.ocx) and coded this:

Dim w As New WshNetwork
w.SetDefaultPrinter (”ThePrinterIWantToBeTheDefault”)
Set w = Nothing

wow, 3 lines. Much easier. Thank you WSH team.

Writing and coding - deadlines siphon out the fun

I was chatting with a friend on instant message tonight. We got to talking about how we enjoy coding and enjoy writing about technical things. He was telling me about how a couple of years ago he had sent some emails off to someone at APress after thinking of writing a book. The route the conversation took after that was interesting though. We both agreed that when writing articles or book chapters for a publisher, or even doing technical reviewing for books, pressures such as deadlines or word counts often seem to take the fun out of writing, whether it be code for software or text for an article or book.

When you're under a code-writing deadline it can sometimes make you rush the work you're doing, causing you to feel like the quality of what you produced isn't really representative of your abilities. You feel like you were forced into writing “half-ass“ code. The same can be said of article or book writing deadlines. Writing and coding for yourself however, without deadlines, brings so much of the fun and enthusiasm back into the work that I hesitate to call it 'work'.

When I write articles I usually like to read over what I wrote - often over a span of several days - to make sure it still sounds good to me as my way of editing myself before the real editor edits my work. Deadlines have cut that short many times. I guess that's what an editor is for but, I like to think that most editors find my writing easy to work with.

With the code I write, I often like to think of as many ways as I can to break it with bad input. I like to run unit tests on it. I like to refactor it in my head, thinking of ways to improve performance and security. Deadlines often eliminate the time I have for that also.

Thinking about this further, I came to a certain understanding about myself and the group of developers I consider myself a part of. No matter how much time we put in writing code or articles for work, we always like to have a side project going. Sometimes it's a website, maybe it's a project that we'll later release the source code for, or maybe it's just a blog that nobody reads (like yours truly). The reason we can't help but to do these things though is that we are in this for the long haul. To us, this is a career, not a job, nor a project, nor a contract. The side projects are our way of staying interested in and passionate about the technology. If it weren't for the side projects the stress and lack of fun at work might send us looking for another career path. We know in our hearts though, that coding and writing is what we were meant to do, so we don't let the lack of fun at work keep us from having our tech fun somewhere else. I think it's the same reason why pro athletes take up golf after they retire or go into sports broadcasting to remain part of the action. I think it's also the reason that so many of us like to go to TechEd, or the PDC, or DevDays, or TechFest, or the MVP Summit, or....you catch my drift. There are no deadlines to meet for attendees of these parties conferences other than showing up on time. It helps us renew the feelings we have about technology being fun.

Probably the biggest reason for this blog entry is because of the writing I've been doing for DevCampus lately (yeah I know you heard it coming, shut up.). The only deadlines I have right now are the ones I'm imposing on myself. So really, I don't have any. If I had to guess, I'd say I have about 20 articles that I'm writing currently, that are all in different stages of production. I get to bounce back and forth between articles, writing about whatever I feel like I'm in the mood for. Last night was performance tweaks for VSS, tonight was about licensing and installation of SQL Server 2000. Tomorrow night I'll probably finish up the article I'm writing on starting out as a computer programmer. Due to the lack of deadlines though, this is probably the most fun I've ever had writing technical content. If I don't like the way something sounds, I can spend a few days editing it or rewriting it until I'm satisfied.

If you don't have any side projects going, I'd encourage you to make one for yourself. I think you'll find it worth any amount of time you can donate to it. At least that's my experience. Your mileage may vary.

Managing Websites and Paging Content

I've given this subject a good amount of thought and still haven't come up with something I'm happy with so I'm putting the question out there for the public to chew on.

Background: For “Lessons” (articles) on the DevCampus site, there is a very good chance that the content will be lengthy. By “lengthy” I mean more than 10 printed pages -possibly more than 15 or even 20 printed pages. I'm going to do my best to break the content down into lessons that don't require an entire evening to get through but, some topics will take a lot of text and images to cover properly. So I was thinking about paging the content of the lessons, so that people could bookmark a URL that takes them to a specific page of the lesson and they can pick up where they had previously stopped reading.

Question: Without creating multiple records in the database table (a record per page), how do I page the content? I'd really like to be able to manage the content of a lesson as a whole while creating and editing it. I don't want to have to choose a certain page to edit or add multiple pages to an article while adding it to the database. This would be easiest for DevCampus editors that help me manage content on the site also. I don't want them to have to remember special rules for managing content.

As most of you reading this probably know, “Paging” of data traditionally relies upon setting a page size (a certain number of records) and then being able to access a page count property (which is usually just the record count divided by the page size). Also, the dataset/recordset can typically be filtered to the current page's records only so moving through the records is still really simple. How do I achieve paging though, without setting a page size, without having a page count, and without record filtering capabilities? I've resigned myself to thinking there is no way to do this short of creating my own custom solution.

My own solution (idea) consists of mimicking paging behavior but, in a way that is suited for a single record containing a lot of text. First, setting a page size that is a number of bytes (say, 75,000) and then using that number to get a page count by dividing the total number of bytes the article consists of by it. The only problem with this simplified solution is that it would likely cut words off randomly and not really allow me to set page breaks at a specific location in the content, which is important. I'd prefer the pages to break at the end of a section or paragraph in the lesson. I thought of putting special “page break” characters or symbols in the content but that would require an expensive parsing of the entire article looking for the page breaks and then keeping track of how many of the page breaks I've found when the page requested isn't the first page. This also seems like it would be a maintenance nightmare. If content is added or taken away from the lesson, there's a good chance the page break char/symbol location would need to be adjusted to give a proper page size.

So, has anyone out there dealth with this kind of issue before? If so, what'd you do? I'm interested in hearing.

Google Creating a Personalized Search?

I'm not really sure what the details surrounding this are, but I found it looking through my referral logs. Looks interesting. I'm going to spend some time playing with it later.

More Posts