tag:blogger.com,1999:blog-1085824937309992692023-06-20T21:41:49.190-07:00Out Of OfficeCaseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.comBlogger32125tag:blogger.com,1999:blog-108582493730999269.post-53090575076819990472009-06-17T11:51:00.000-07:002009-06-17T12:02:02.071-07:00FocusAnother Lucius Seneca quote:<br /><br /><span style="font-style:italic;">No one persuit can be successfully followed by a man who is preoccupied with many things</span><br /><br />What are the things that you are preoccupied with? How many things do you have on the todo list in your head? How many of them have you gotten done lately? If you're like me then you have a big list floating around your head where things drop on and off of the mental checklist and you never really get to most of the things on there. <span style="font-style:italic; font-weight:bold;">Write it down!</span> Use a text document on your computer, send yourself an email, start a google document, or even good ol' pen and paper. Just get it out of your head so you can focus on things one at a time without worrying that you're going to forget something.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-37185949613112352852009-06-16T11:36:00.001-07:002009-06-16T12:07:15.159-07:00Yesterday my boss forwarded a resume to myself and several of the people on my team. The candidate has a ton of experience doing projects similar to what we're doing and would likely be a good fit. Reading through the previous positions on his resume and then his education I realized that he's been working as a programmer as long as I've been alive (I'm 27). I find the thought that I might still be sending out resumes in 20 years is horribly depressing.<br /><br />I started reading through <span style="font-style:italic;">On The Shortness Of Life</span> an essay by <a href="http://en.wikipedia.org/wiki/Seneca_the_Younger">Lucius Seneca</a> last week here and there while waiting for things to build/install and when eating my lunch. Tim Ferris had a <a href="http://www.fourhourworkweek.com/blog/2009/04/24/on-the-shortness-of-life-an-introduction-to-seneca/">blog post</a> about it and that got me interested. Anyhow, It has me thinking a lot about my time and the fact that it's a limited commodity, the fact that I'm giving up much of the lives of my children for work, and priorities. Here are a few excerpts that I've found particularly insightful:<br /><br /><span style="font-style:italic;">So it is - the life we receive is not short, but we make it so, nor do we have any lack of it, but are wasteful of it . . . life is amply long for him who orders it properly.</span><br /><br /><span style="font-style:italic;">"The part of life we really live is small." For all the rest of existence is not life, but merely time.</span><br /><br /><span style="font-style:italic;">Are you not ashamed to reserve for yourself only the remnant of life, and to set apart for wisdom only that time which cannot be devoted to any business? How late it is to begin to live just when we must cease to live!</span><br /><br /><span style="font-style:italic;">your vices will swallow up any amount of time. The space you have ... escapes from you quickly; for you do not seize it ... but allow it to slip away as if it were something superfluous and that could be replaced.</span>Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-89754844006242698012009-06-16T11:23:00.000-07:002009-06-16T11:34:09.709-07:00Been a whileIt's been a while since I wrote anything and for that I apologize. A couple months ago I tool a job for a company called Advaiya in Bellvue WA. The commute is a little painful but that stability is rather nice. We'd gotten to the point where I needed to either get other clients or get a real job. Health insurance was killing us and we were pretty tight on funds in general. In hindsight I should have taken care of health insurance and switching out to an HSA but never did.<br /><br />So, I'm back in the office again. I'm not sure what the future of this blog is and I never posted much or developed any significant level of readership to the best of my knowledge (if you're reading this now don't think that statement means I don't care about you :) ). I might keep writing in it as starting a real job again makes me remember how much I dislike the 9 to 5 thing. The sort of rhythm you get into where you have to fill up 8 hours before you can go home is strange. Can't I get the same amount or even more done faster? If I do the same/more work faster/smarter should I be done and head home? These are things that I'm pondering.<br /><br />If you have any ideas for the future of this blog please comment.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-22500841712977177592009-01-28T12:40:00.000-08:002009-01-28T13:10:15.922-08:00IIS7 and url escapingFirst off, sorry I'm such a slacker. Posting to this blog hasn't been one of my top priorities. I have a lot of draft posts that I've started or dropped a few thoughts into and never returned to. I'll work on getting through those. Enough of that.<br /><br />I've been working on a community that's hosted on Community Server off and on for a while now. Recently my primary client upgraded the test environment server over to a new box with a new version of the OS, SQL Server, and IIS. This has caused some problems with some problems here and there but most of those were taken care of easily. One weird one was that the tagging system in Community Server wasn't working quite right anymore. Single token tags such as "foo" would work as expected however multi token tags "foo bar" were no longer working and I was getting a page not found error. After a lot of digging around I discovered the issue:<br /><br />IIS6 treats "+" and "%20" in a url the same however IIS7 does not. Community Server uses "+" to indicate spaces in their tag url<blockquote></blockquote>s. So for a single token tag you have something like:<br /><br />[url]/tags/foo/default.aspx<br /><br />and for a multiple you have:<br /><br />[url]/tags/foo+bar/default.aspx<br /><br />At the suggestion of a developer I know I tried replacing the "+" w/ "%20" and low and behold it worked fine. The solution to this issue is to allow double url escaping by adding the following to your web config inside of the System.WebServer element:<br /><br /><security><security><br /> <requestFiltering allowDoubleEscaping="true" /><br /></security><br /> <requestfiltering allowdoubleescaping="true"><br /></requestfiltering></security><br /><br />Blog Post on Breaking Changes on IIS7:<br /><a href="http://learn.iis.net/page.aspx/381/aspnet-20-breaking-changes-on-iis-70/">http://learn.iis.net/page.aspx/381/aspnet-20-breaking-changes-on-iis-70/</a><br /><br />Community Server documentation on this issue here:<br /><a href="http://docswiki.communityserver.com/wikis/cs20085docs/configuring-iis7-for-community-server.aspx">http://docswiki.communityserver.com/wikis/cs20085docs/configuring-iis7-for-community-server.aspx</a>Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-77355201482759576312008-04-11T17:15:00.000-07:002008-04-11T17:20:41.913-07:00Javascript onUnload and postbackSo I just ran into an interesting scenario. I have a custom control where I need an event to fire before postback but I don't want to have to add an OnClientClick event in every page that uses the control. In fiddling with the javascript onunload event I found that oddly enough the unload event fires <i>after postback</i> to my aspx page. The solution? Use onbeforeunload instead:<br /><code><br />window.onbeforeunload = unload;<br /><br />function unload() {<br /> alert("unload");<br /> }<br /></code>Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-10356121946831063612008-04-02T11:21:00.001-07:002008-04-02T11:32:29.424-07:00Asp Uploader Control WeirdnessIt's been a while since my last post and I apologize for that, I need to post more often because I tend to run across interesting things to post about. I'm just lazy.<br /><br />I ran into an issue the other day when working on a SharePoint site that had me confused for a while. For some reason when you access the Uploader.PostedFile.InputStream property twice (even when setting the Position in the file to zero manually upon setting up a new reference to it and wrapping things in a using statement) the second time you read it you’ll get an empty file. Which is fucked up. <br /><br />Anyhow, I fixed that by accessing the Uploader.PostedFile.InputStream property in one of the instances where I wanted to access the file but didn't actually need an input stream. I haven’t really been able to make sense out of why it works this way but not the other but whatever. Life goes on.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-58755487605064667042008-01-11T20:26:00.000-08:002008-01-11T20:38:54.421-08:00GDI and Ampersand RenderingYesterday I spent a while tracking down a bug in a library that I wrote a while back. One of the things that the library is used for is drawing text in fonts that aren't web safe to be used as headings and whatnot. So if I want the phrase "Out Of Office" drawn in whatever font I just created (this isn't actually a real use case) I can just upload the ttf file to my fonts directory on the server and use the control to generate an image dynamically that will fit the space. The tool even provides caching so after a string with a given set of params has been requested <i>N</i> times it caches it and will load the image from the cache upon future requests. But enough about that.<br /><br />The bug I tracked down yesterday was related to the ampersand character and the fact that for some reason when the string I wanted to draw contained the ampersand character then no text was being drawn. I wouldn't get any exceptions or anything I just wouldn't get any text. The result image was just the background color I'd requested the size that the text would require if it was in the image. Without the ampersand char it worked as expected.<br /><br />In GDI when you go to draw a string via <a href="http://msdn2.microsoft.com/en-us/library/system.drawing.graphics.drawstring(VS.71).aspx">Graphics.DrawString</a> you can optionally display hot keys (meaning underlining a specific key to specify that it's a shortcut visually). When I'm drawing a string I'm passing in a <a href="http://msdn2.microsoft.com/en-us/library/system.drawing.stringformat.aspx">StringFormat</a> object which contains some formatting information (horizontal alignment and such). One of the properties of StringFormat is HotkeyPrefix which is used to set the <a href="http://msdn2.microsoft.com/en-us/library/system.drawing.text.hotkeyprefix(VS.71).aspx">Hotkey </a> functionality for the string (Hide, Show, or None). Now you might think that simply setting it to None (which is the default btw) would result in no Hotkey formatting being considered when rendering the string. But you'd be wrong.<br /><br />After a great deal of trial and error I got the ampersand to render when I <b>replaced each ampersand with 2 ampersands (an escape of sorts) and then set HotkeyPrefix to Hide</b>. Why this worked I'm not sure and it's kind of counterintuitive but whatever. That's how I fixed it.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com1tag:blogger.com,1999:blog-108582493730999269.post-91514099040511153612007-12-17T01:42:00.000-08:002007-12-17T01:45:56.643-08:00Seattle Startup WeekendThe next Startup Weekend has been announced and it's in <a href="http://startupweekend.com/seattle-startup-weekend/">Seattle</a>. I've been somewhat involved in helping to get things going and am really excited to see how it turns out. The event will be Jan 25-27th. More details to follow.<br /><br />You can register for the event or read up on what startup weekend is at the <a href="http://startupweekend.com/seattle-startup-weekend/">Seattle Weekend Announcement</a>. It will likely fill up quickly.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-25745037585506024082007-12-15T17:11:00.000-08:002007-12-15T17:31:48.543-08:00You know the fun Restart Now/Restart Later Windows pop-up that shows up when you have updates that you need to install? The one where if you click later it will just pop up again in a few minutes? I'm term serv'ed into a server that I don't have administrator rights on and it popped up. Only since I don't have shutdown/restart rights the restart button is grayed out. Since I have no choice in the matter why does the freakin thing even show up?<br /><br />So I just drag the little window off to the edge of the screen where it will sit quietly and not bother anyone anymore.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-74883368492802489532007-12-13T23:59:00.000-08:002007-12-14T00:42:34.627-08:00Creating Something BeautifulI was catching up <a href="http://joelonsoftware.com/">Joel Spolsky's blog</a> earlier and he had a series of posts containing the transcription of a talk he gave at Yale (<a href="http://joelonsoftware.com/items/2007/12/03.html">part 1</a>, <a href="http://joelonsoftware.com/items/2007/12/04.html">part 2</a>, and <a href="http://joelonsoftware.com/items/2007/12/05.html">part 3</a>). The posts are long but I thought they were worth reading. In particular there were two things he touched on that I thought were interesting.<br /><br /><b>Testing</b><br />In <a href="http://joelonsoftware.com/items/2007/12/03.html">part 1</a> he talks about testing and the fact that there's no realistic way you could have automated tests cover everything. He argues that at the very core the only thing you can do is check to ensure that one program behaves like another or according to a set of tests. Those tests however can't possibly cover everything that needs testing.<br /><br />He gives an example of the move at Microsoft to more of an automated test process and the rumored laying off of testers who don't know how to code to bring in SDETs who can program those automated tests. He points out that those tests can't test a number of things that require someone actually look at the product such as whether thing were laid out in an orderly and logical fashion and whether the product has a feeling of continuity. <br /><br />You can test a lot of things through automated testing but there's always going to be a need for someone with a sharp eye to go through and make sure everything is ship shape.<br /><br /><b>In-House Programming</b><br />In <a href="http://joelonsoftware.com/items/2007/12/04.html">part 2</a> he writes about why an in-house programmer sucks. He gave three reasons and they are all very good but the one that really struck me was the second:<br /><br />"So, the number two reason product work is better than in-house work is that you get to make beautiful things."<br /><br />Numbers 1 and 3 are that you never get to do things the right way and that at a software company your business is software so there's more incentive for the company to treat developers like rock stars (and who doesn't want to be treated like a rock star now and again). <br /><br />Number 2 stood out to me because it struck a chord somewhere and reminded me why I started getting interested in programming. I wanted to create something cool and useful and beautiful. <br /><br />I played guitar for a long time and I didn't do it to pick up chicks (though I may have used it in that way a time or two), I did it because I wanted to create something. I wanted to write something that would touch someone or cause someone to open up their eyes to a new perspective or challenge an existing perspective. I wanted to create something beautiful. I used to sit and play for hours, now I only play around on the guitar here and there when my son (who is 18 months old on Saturday) points to it and either wants to watch me play and dance a bit here and there or wants to sit in the case after I've pulled the guitar out.<br /><br />Currently I'm working on various small (on a scale of all development undertakings) projects. Some of them are pretty cool (like the one I'm working on now that I'll post about once it launches) and some of them aren't as cool (like forms). Though I can still work towards creating flexible and elegant solutions. In the grand scheme of things they may not be groundbreaking or hugely significant but they're still opportunities for elegance.<br /><br />Someday I'd like to create something beautiful and significant. And I will.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-43144828622031402822007-12-13T23:32:00.000-08:002007-12-14T00:42:48.603-08:00I'm still so SO super busy. That said there's some sql stuff I wanted to post.<br /><br /><b>Copying One Table To Another</b><br />Want to copy all the data including the structure (with the exceptions of the constraints) to a new database?<br /><code><br />Insert Into <i>NewDatabaseName</i><br />Select * From <i>OldDatabaseName</i><br /></code><br />Want to just copy the structure without the rows?<br /><code><br />Insert Into <i>NewDatabaseName</i><br />Select * From <i>OldDatabaseName</i><br />Where 1 = 2<br /></code><br />What could be easier.<br /><br /><b>Unions</b><br />Unions are pretty cool. That said if you're using <i>text, ntext, or image</i> types you need to use a <i>Union All</i>. If you don't you'll get an ugly error like this:<br /><code><br />Server: Msg 8163, Level 16, State 4, Line 1<br />The text, ntext, or image data type cannot be selected as DISTINCT.<br /></code><br /><b>Stored Procedure Output Parameters</b><br />If you're running a stored procedure that returns a data set you'll need to call <a href="http://msdn2.microsoft.com/en-us/library/9kcbe65k.aspx">SqlCommand.ExecuteReader()</a>. If you also have an output parameter specified in the procedure you might be tempted to do something like this:<br /><code><br />sqlDataReader = command.ExecuteReader();<br /><br />string outputParam = command.Parameters["foo"].Value;<br /><br />while (reader.Read()) {<br /> //read your rows<br /> }<br /><br />reader.Close();<br />command.Connection.Close();<br /></code><br />The above code will compile fine but you'll get strange exceptions on the line where you're reading out the param value. If you investigate you'll find that even though <i>command.Parameters["foo"]</i> isn't null <i>command.Parameters["foo"].Value</i> is. That's because when you're using a sql reader you need to close the reader before you can read the output param(s):<br /><code><br />sqlDataReader = command.ExecuteReader();<br /><br />while (reader.Read()) {<br /> //read your rows<br /> }<br /><br />reader.Close();<br />string outputParam = command.Parameters["foo"].Value;<br />command.Connection.Close();<br /></code><br />Now you know. And knowing is half the battle.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-81767456208432928222007-11-16T13:36:00.000-08:002007-11-16T13:52:26.177-08:00I've been crazy busy lately. I'm still crazy busy but I've decided to make a post here. I'm going to start posting little snippets of code that I've found useful or problems that I've resolved that I want to keep the solution to around.<br /><br />Log story short I needed a TreeView to postback when the checkbox associated with an element changed. This search led me to <a href="http://forums.asp.net/p/643832/1160084.aspx">This Post</a>. The solution proposed there works great however there's one issue that took me a long time to hunt down. The last post on the page lists some script to spit out after you've created your object:<br /><code><br /><script type=\"text/javascript\"><br /> if (document.all) { <br /> document.getElementById(YOURIDHERE).onclick = foo; <br /> }<br /></script><br /></code><br />This code works great in IE but doesn't in Firefox. It took me a long time to figure out why but it's due to the document.all like. Firefox doesn't support document.all. If you see that somewhere and like supporting firefox users then don't use it. That's all for now.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-80246519623131512482007-10-22T23:26:00.000-07:002007-10-23T00:12:08.345-07:00On Prefix and Postfix Increment OperatorsFor those familiar with increment operators and their prefix and postfix usage skip down to just below the pseudo-code.<br /><br />When you have a number and you want to increment it while stepping through a collection or something you can use the increment operator (<i>"++"</i>). That will add one to whatever number you pair with the operator. When using increment operators there are prefix and postfix forms. The prefix form is when you put the operator before the variable containing the number and the postfix is afterwards (<i>++i</i> vs. <i>i++</i>). Functionally these the placement results in very different functionality, if you use the prefix form then the number is incremented before it is evaluated whereas if you use postfix then it is evaluated after it's value is used. In other words (this is really simplified pseudo-code):<br /><code><br />variable n = 0;<br />print n;<br />print n;<br /></code><br />Will print the number 00.<br /><code><br />variable n = 0;<br />print ++n;<br />print n;<br /></code><br />Will print 11.<br /><code><br />variable n = 0;<br />print n++;<br />print n;<br /></code><br />Will print 01. <br /><br /><i>Awesome, let's continue</i>.<br /><br />The issue I have with this is that I can only use one at a time. I just came across a scenario where I actually got kind of excited about a line of code I had just written (which doesn't happen very often). The scenario was that I had a string containing tokens I needed however each token I needed was surrounded on both sides by tokens that I don't need. So I had something like:<br /><br /><i>;junk;ValueICareAbout;junk;junk;ValueICareAbout;junk;</i><br /><br />This led me to writing the following lines of code:<br /><code><br />for (int i = 0; i < tokens.Length; i++) {<br /> string token = tokens[++i++];<br /> Trace("Found Token: " + token);<br />}</code><br /><br />Sadly the compiler informed me that what I had done is totally not allowed. Which made me sad. Because <i>++i++</i> looks awesome. And yes, I do realize that I'm a huge dork.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com1tag:blogger.com,1999:blog-108582493730999269.post-66407868088885847242007-10-16T11:42:00.000-07:002007-10-16T12:08:55.018-07:00Freelance FinancesWhile I'm waiting for a 175mb SDK to download I thought I'd update since it's been a while.<br /><br />Last month I brought in <i>about a third</i> of what I was bringing in at my former <i>real</i> job. This month is looking like it'll be a little more but it might not be by much. While I can have a month or two like this I don't know that I can have 3 months in a row like this. Savings can certainly help support us but that's not their intended usage. There are several things that I think I've learned or that have been reinforced by the current lack of extra funding:<br /><br /><b>Save In Times Of Plenty</b><br />I'm really good at spending money. <i>REALLY</i> good at it. It's really easy to look at your bank account balance and justify some purchase or another since you have the money when in reality you're not going to get a whole lot of use out of something. Having money saved away will help get through the sparse times.<br /><br /><b>Lower Your Standards</b><br />One thing I struggle with is pride. Especially when it comes to <i>the things I have</i>. This is especially true of the car that I drive. We have a Mini Cooper that we recently paid off. It's nice having it paid off (and certainly helps for months when I'm not bringing in a whole lot) but we're still paying more on insurance and it's expensive to maintain since it's more or less a BMW. My car has been a source of pride since I finished college and got a shiny new Subaru WRX.<br /><br />All that said <i>I don't need it</i>. I don't need to spend money on every shiny object that catches my eye.<br /><br /><b>Re-Evaluate Your Priorities</b><br />This whole freelancing thing didn't start out as a way to make huge amounts of money. It would be nice if it started making me huge amounts of money but that's not one of the primary goals. I need to try to remember the other <i>benefits of freelancing</i> and weigh those into decisions that I make about my employment. What're the other benefits? I have so SO much <i>more freedom</i> with my time. I'm <i>learning a whole lot in a variety of technologies</i>. <i>I'm my boss</i>, if I'm working on projects that I don't like or don't like working with a specific client I don't have to. <i>Overall I'm more in control of my time and how I spend it.</i><br /><br />My download is done, back to work.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-40132443215512576742007-09-27T13:29:00.000-07:002007-09-27T18:09:06.382-07:00Family-Work-Life BalanceThe Family & Parenting Reporter for the Seattle Post Intelligencer Paul Nyhan made an interesting post last night about Work-Family Balance: <a href="http://blog.seattlepi.nwsource.com/family/archives/121866.asp">Work-Family Balance is a Joke: Embrace the Chaos</a><br /><br />The post talks briefly about efforts towards new <a href="http://seattlepi.nwsource.com/local/333286_familyleave27.html">family leave law in Washington</a> and then moves on to an evaluation over whether a happy Work-Family Balance is actually realistic and attainable. He concludes that it isn't and that working parents need to roll with the punches. <br /><br />I'm not sure how I feel about the phrase "Work-Family balance." Typically when I hear the term Work-<i>Something</i> Balance it's "Work-<i>Life</i> Balance" that's being talked about. I've never heard anyone without kids refer to their "Work-<i>Family</i> Balance." Perhaps it's only once we have kids that family actually factors into the equation. <br /><br />I think that the phrase for everyone should be Family-Work-Life balance. Family comes first, then work (gotta pay the bills), and then you can squeeze in some time for yourself after you taken care of your family and your work is in order. Not that this is the arrangement of my priorities all the time but it's something to shoot for. Actually, the thing to shoot for is Family-Life-Work but that's really hard to do. Focus on your family and living your life and let work be an afterthough. Work to live vs. the other way around and all that.<br /><br />Finding time for yourself is definitely a challenge even as a single person with a full time job let alone as a parent. Pamela Slim (who maintains the <a href="http://www.escapefromcubiclenation.com/get_a_life_blog/">Escape From Cubicle Nation blog</a>) posted yesterday morning about <a href="http://www.escapefromcubiclenation.com/get_a_life_blog/2007/09/8-strategies-to.html">8 Strategies to get the most from painful or awkward life transitions</a>. A lot of the strategies she posted definitely apply to parenting and the attempt to maintain some sort of balance. In an effort to not copy the meat and potatoes of her post into mine I'll say you should go check out <a href="http://www.escapefromcubiclenation.com/get_a_life_blog/2007/09/8-strategies-to.html">her post</a>. I'll end this with a quote from that post that I really liked:<br /><br /><i>The interesting thing is that no matter what the ultimate benefit of a change, going from "what was" to "what will be" can be very unsettling.</i>Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com1tag:blogger.com,1999:blog-108582493730999269.post-80655525683211403962007-09-22T12:46:00.000-07:002007-09-27T13:18:14.251-07:00The Excel InteropI just finished up a project working on a win32 client application that is used to import data from an Excel spreadsheet into a database via a secure web service. Working with the interop was interesting and it was nice to get exposed to something new. I'll post more about web services later (as well as returning custom data types via web service methods, serializable Dictionary objects, and converting rtf to html) but I wanted to rant about the Excel Interop a bit.<br /><br /><b>Indexing</b><br />When I started working with the interop I went in and created an instance of Excel:<br /><code><br />Microsoft.Office.Interop.Excel.Application excelObj = new Microsoft.Office.Interop.Excel.Application();<br /></code><br /><br />This is all well and good. After that I set visible to false and went about starting to access some of the bits and pieces in my xls file. Oh, and because we're using C# and because <a href="http://msdn2.microsoft.com/en-us/library/microsoft.office.interop.excel.workbooks_methods(VS.80).aspx">Open isn't overloaded</a>:<br /><code><br />Microsoft.Office.Interop.Excel.Workbook workbook = excelObj.Workbooks.Open(<br /> filename,<br /> Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value,<br /> Missing.Value, Missing.Value, Missing.Value, Missing.Value, Missing.Value, <br /> Missing.Value, Missing.Value, Missing.Value, Missing.Value<br /> );<br /><br />Microsoft.Office.Interop.Excel.Sheets sheets = workbook.Worksheets;<br />Microsoft.Office.Interop.Excel.Worksheet worksheet = (Microsoft.Office.Interop.Excel.Worksheet)sheets.get_Item(0);<br /></code><br />Now, if you run this code you'll get an exception citing an invalid index:<br /><code><br />System.Runtime.InteropServices.COMException (0x8002000B): Invalid index<br /></code><br />If you're like me you'll immediately try starting your index off at 1 because I suppose it makes sense to start off your worksheets at 1. As much as this seems like VB and as much as I don't like VB I think I can live with it. So you change the sheet number to one and go on your merry way.<br /><br />Then you try to access some data in your first worksheet:<br /><code><br />string str = (string)((Microsoft.Office.Interop.Excel.Range)worksheet.Cells[0, 0]).Value2;<br /></code><br />Running this code gives you an exception and you want to assume it's because you started your indices off at 0 but it doesn't quite make sense because it gave you a different exception:<br /><code>System.Runtime.InteropServices.COMException (0x800A03EC): Exception from HRESULT<br /></code><br />Hopefully at this point you immediately try <code>Cells[1, 1]</code> and don't spend some time trying to figure out what you did to go from a meaningful exception that made sense to a generic COM Exception. If you try 1,1 you'll find that it works and all will be right in the world.<br /><br />What bothers me about this isn't the fact that I have to start the index off at 1 rather than 0. What bothers me is that when I tried to open a worksheet with an out of bounds index I got an exception telling me that it was an index issue. When I tried cells that were out of bounds I got a generic exception. The worksheet exception was actually helpful and immediately let me know what the problem was whereas the cell exception wasn't even though it was pretty much the same exact issue.<br /><br /><b>Killing Your Instance</b>:<br />I'm not even going to into detail on this as it's been beaten to death already. Killing off an instance of Excel is a pain though I don't think that's really the fault of the interop. You have COM to thank for that one. Essentially you have to make sure that for each Excel COM object you create you're calling <i>ReleaseComObject</i>:<br /><code><br />Marshal.ReleaseComObject(excelObj);<br /></code><br />And then calling the Garbage Collector:<br /><code><br />GC.GetTotalMemory(false);<br />GC.Collect();<br />GC.WaitForPendingFinalizers();<br />GC.Collect();<br />GC.GetTotalMemory(true);<br /></code><br />I'm not really one to talk in this instance though since my client app still has a bug where when multiple instances of the Excel application are created once I close them out all of the processes go away except for the first one I created. It's really bizarre. See the references section for some links.<br /><br /><b>Hyperlinks</b><br />This isn't so much a beef with the Excel Interop as it is with Excel in general. In Excel you can't have a link within a cell. You can have the entire cell be a link to some location but you can't have the text <i>"click HERE for pictures of my cat"</i> and have only the text <i>"HERE"</i> act as a hyperlink. This ended up saving me some time on the rtf to html conversion but is kind of lame in my opinion.<br /><br /><b>References:</b><br />Here are some of the pages that I found the most helpful when working through this:<br /> - <a href="http://msdn2.microsoft.com/en-us/library/syyd7czh(VS.80).aspx">MSDN: Excel Tasks</a><br /> - <a href="http://www.craigmurphy.com/blog/?p=82">Craig Murphy: Excel Interop - killing Excel.exe</a><br /> - <a href="http://support.microsoft.com/default.aspx?scid=kb;en-us;317109">MS Help and Support: Office application does not quit after automation from Visual Studio .NET client</a><br /><a href="http://msdn.microsoft.com/newsgroups/default.aspx?dg=microsoft.public.excel.programming&lang=en&cr=US">Excel Solutions Forum</a>Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com3tag:blogger.com,1999:blog-108582493730999269.post-33344559871151087882007-09-18T23:35:00.001-07:002007-09-27T13:24:33.312-07:00Catching UpI've found myself wanting to post fairly often lately. Typically it's about some technical aspect that's either irritating me or making me really happy. It's not very often that I'm working with something and I sit back and reflect on how much I love <i>n</i> technology because <i>n</i> technology makes my life easier or is just plain cool. I've gone through and made draft posts containing nothing more than a title and a brief description for some of them and at some point I may come back to them.<br /><br />I need software that automatically extracts a topic along with my feelings towards and knowledge of that topic from my mind with minimal effort on my part. It would then take the randomness floating around in my head and structure it in a rational way, write up a few paragraphs, and post it to my blog. That way when I say to myself "wow, this is really cool" or "holy hell this is such a pain to work with" I can just hit a button and a post automagically appears on this blog (or whichever blog I choose).Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-1347033795851498152007-09-18T23:19:00.000-07:002007-09-27T13:20:17.753-07:00Joel SpolskyI know some people don't like Joel Spolsky and I know some people do. I'm in the latter camp and I don't care what other people think. Sure some of the things he writes and posts about aren't of a whole lot of interest to me. But then he'll post things like <a href="http://www.joelonsoftware.com/items/2007/09/18.html">this</a> and it makes up for all the posts of his that I only skim or skip over.<br /><br />If you have time go read his most recent post (as of my posting this) here:<br /><a href="http://www.joelonsoftware.com/items/2007/09/18.html">Strategy Letter VI</a><br /><br />This article was particularly largely for the history of computing and software aspect. Being rather young in the grand scheme of things I don’t have the amount of experience and perspective that he has. Given that fact I appreciate hearing about things like the rise and fall of Lotus 1-2-3 and the changes in the business of writing software as a result of the progression of hardware. It’s even more interesting when patterns can be identified.<br /><br />I'm not sure what happened to Strategy Letters 1 - 5 but I'm sure they were at the very least somewhat interesting. I may have to go dig those up at some point.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com1tag:blogger.com,1999:blog-108582493730999269.post-16897013490164911512007-09-11T10:46:00.000-07:002007-09-27T13:25:59.395-07:00RestructuringI've decided to change things up a little bit. From now on I will be trying to post a lot more often and on a larger variety of topics. I can only post about the struggles and triumphs of working from home so much. This doesn't mean I'll be posting pictures of my cat (I don't own a cat but I could always post photos of the neighbor's cat) or what I had for dinner tonight. From this point forward there will be more variety which will likely include little technical snippets, some details regarding what I'm working on, and my take on living with a kidlet.<br /><br />Oh, and we're expecting kidlet #2. Good times.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-27836307915007743412007-08-21T04:37:00.000-07:002007-09-27T13:27:57.298-07:00Title Goes HereI've been neglecting this thing lately. Almost two weeks since my last post.<br /><br />I've fallen behind a bit as of late and as such am juggling multiple projects and running to catch up. This leads to me staying up late working after the family goes to bed (which I don't especially mind that much I just don't like worrying about not getting things done on time). Which then leads to me being rather exhausted most of the morning after our 14 month old gets us up (though huge thanks go out to my wife for letting me sleep in a little after the really late nights). I then become actually productive around 11am and the cycle continues.<br /><br />It's almost 5am and I tried to go to bed around 3 but wasn't quite able to shut off my brain. Around 3:30 I decided to get back on the computer and get some work done. A little while after that I decided that drinking brain function impairing beverages (beer) was a stellar idea and a sure-fire way to get to sleep sometime soon-ish. I'm on #3 and I predict that by the time I finish this one I'll be lubricated enough to head to bed and get some sleep.<br /><br />Casey's recipe for shutting your brain off when you're up way too late and can't sleep:<br />1 - Get beer #1 from fridge<br />2 - Continue to work.<br />3 - Get beer #2.<br />4 - Continue to work.<br />5 - Beer #3.<br />6 - Decide you're in no shape to work and post to your blog or go play <a href="http://www.wickedpissahgames.com/games/gravitypods/GravityPods.html">what may very well be the most addictive and frustrating game ever</a> or something.<br />7 - finish beer #3 and head to bed leaving empty bottles on desk in case anyone comes over and wonders what you do all day.<br /><br />For best results the above steps should be completed inside of around 30 minutes.<br /><br />On that note, I'm rounding the corner on 3 at which point I'm going to head to bed and try to sleep.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com1tag:blogger.com,1999:blog-108582493730999269.post-82849043050581634792007-08-08T22:15:00.000-07:002007-09-27T13:22:16.798-07:00Work vs HomeOne thing that's kind of hard about working from home is that you're never really at work and you're never really at home. I can go downstairs to my "office" but I'm still home. At the same time I can be hanging out with my family or watching a movie with them but work is only a flight of stairs away. I find myself getting distracted and feeling like I should really be working and visa versa.<br /><br />When I worked a <i>real</i> job I tended to not work from home very often most of the time. There would be periods of time where I would have something I needed to work on from home but in general most of the time I spent working was in the office. While I still had trouble leaving the stresses of work behind when I was at home it was much easier to differentiate that time as <i>not work time</i>.<br /><br />If I tried to keep set hours that might help somewhat but I'm not really a set hours sort of person. This morning I slept in and didn't get started until late morning (10 or 11-ish) and in the past I've tended to wake up before my family and head downstairs to work until they're up. Weekends are just times when I tend to work less but I still typically put some time in (sometimes a lot of time in). I don't even really keep a mental summary of how many hours I've been working anymore.<br /><br />In this case I have work I need to get done but it'd sure be nice to go sit and read stories with my wife and son (I can hear them reading <a href="http://www.amazon.com/Goodnight-Moon-Board-Margaret-Brown/dp/0694003611/ref=pd_bbs_2/102-6475219-2602558?ie=UTF8&s=books&qid=1186636998&sr=8-2">Goodnight Moon</a>) and then head to bed. The work isn't going to do itself though.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-15971543840349632632007-08-07T16:55:00.000-07:002007-09-27T13:25:41.659-07:00Home AgainOh man, I had a great weekend. The wedding I went to was quite a departure from the standard wedding one typically goes to and was much more of a weekend party with friends than anything else. It was a lot of fun but an exhausting weekend made worse by the exhausting trips down and back. Something about being in a car for an extended period of time, even if you aren't driving, is just plain tiring. I drove about 10 hours yesterday (SF to Washington) so that wasn't helping either. Today I feel like a bit of a zombie and am having a hell of a time actually getting any work done.<br /><br />It's continually surprising to me how much I miss my wife and son when I'm away from them for more than a day or so. This whole marriage and fatherhood (married last November '05 and our son was born June '06) thing is still kind of new to me and I'm often surprised when I realize something like this even if it's something that is expected or <i>the norm</i>.<br /><br />When I got home last night around 11pm my wife and son were still up (apparently he was just starting to go to sleep while they watched a movie) which was really nice. When they heard me come in they came down and met me and our son did his little happy full body shake thing. It's good to be home.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-612716851264957272007-08-03T04:02:00.000-07:002007-09-27T13:27:57.298-07:00Crunch Time UpdateWell, it's Friday morning and I'm waiting for my ride out of town to show up.<br />I finished the largest project of the three however it took longer than I had anticipated. The project itself is a library for the creation of images in a variety of formats with really flexible text rendering capabilities as well as some helper functions and whatnot. I think the time was worth it though as the extra time I put into it went a long way towards making it more usable and flexible. <br /><br />Because of that extra time the project took I haven't been able to focus on the other two as much as I'd wanted. I'm about halfway through the larger of the other projects and should be able to finish that Monday night or Tuesday. The good news is I managed to get the target date moved out to EOD Tuesday since both me and my "boss" are going to be on the same trip and he understands that we probably won't be back until afternoon/evening on Monday and even then won't be good for a whole lot. Though when I get home it’s definitely family time as I’m going on this trip without them.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-39625467954433576162007-07-29T01:05:00.000-07:002007-09-27T13:27:57.298-07:00Crunch TimeLast Wednesday I had three projects come in. The projects are all somewhat intertwined and all share a common target completion date (Aug 6th) and due date (Aug 10th). On top of that I'm going to be taking a road trip down to San Francisco for a friend's wedding from the 4th through the 6th. The 4th and the 6th are both pretty much write-off days since we'll be driving most of the day. That means I'm trying to have all three projects pretty much wrapped up and finalized by the time I leave Friday morning. <br /><br />I've made really good progress on the largest project and I don't anticipate having a problem completing at least two if not all three of them by the time I leave. That said I need to make sure I can stay motivated between now and then (unlike Friday when I got fairly little done; I blame the sunshine and the fact that it was Friday) and will be putting in some long hours. <br /><br />Fun times, I knew it wouldn't be easy but its worth it.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0tag:blogger.com,1999:blog-108582493730999269.post-84369816483075014672007-07-25T10:27:00.001-07:002007-09-27T13:19:02.157-07:00The Naked Truth: FollowupLast night's <a href="http://thenakedtruth.wetpaint.com/">The Naked Truth</a> event was fairly interesting. Most of the discussion consisted of discussion regarding the best way to get media attention for your startup. The panel consisted of:<br /> - <a href="http://blog.seattlepi.nwsource.com/venture/">John Cook</a>: <a href="http://seattlepi.nwsource.com/">Seattle Post Intelligencer</a><br /> - <a href="http://seattletimes.nwsource.com/news/business/links/bios.html#tduryee">Tricia Duryee</a>: <a href="http://seattletimes.nwsource.com/html/home/">Seattle Times</a><br /> - <a href="http://www.techcrunch.com/about-michael-arrington/">Michael Arrington</a>: <a href="http://www.techcrunch.com/">TechCrunch</a><br /> - <a href="http://www.fredvogelstein.com/">Fred Vogelstein</a>: <a href="http://www.wired.com/">Wired</a><br /> - Becky Buckman: <a href="http://online.wsj.com/public/us">Wall Street Journal</a><br /><br />It was an interesting discussion though one whose content I don't have a reason to apply currently.<br /><br />After the discussion there was a get together which basically meant hundreds of local entrepreneurs and other geeks drinking free beer, eating free bbq, and talking about whatever it is that they're into. I hung out with <a href="http://www.enteringstartup.com/">Hans Omli</a>, met John Li from <a href="http://www.menuism.com/">Menuism</a>, Brian Dorsey from <a href="http://www.noonhat.com/lunch/">Noonhat</a> (<a href="http://blog.noonhat.com/2007/06/29/five-minute-video-introducing-noonhat/">here's is a video</a> of Brian introducing the site concept at <a href="http://www.seattlebizjam.com/">SeattleBizJam</a>), and some folks whose names and affiliations I can't remember.Caseyhttp://www.blogger.com/profile/14925534089627749584noreply@blogger.com0