Stranded on Midgard
Kevin’s view from down here
25
Aug

ASP and a Dynamic Slide Show Control

Posted in Code  by Kevin

This is a quick, simple (functional yet inelegant?) piece of IIS-friendly code for a user-driven slide show that I was asked to whip up.

A user wanted to post an mp3 along with some slides that the viewer could flip through along with listening to the audio.  In an effort to not have to revisit the code each time they had new slides to post I wrote a page (in classic ASP as the server supported it) that will monitor a folder for .JPG ’slides’ and build/manage the forward and back navigation of slides for you while enumerating your postion in the slides versus the total.  If the slides are in alphabetical order this just works and they can add/remove/edit slides all day with no changes needed to the slide code.  The forward and back buttons (not included) appear and disappear as appropriate.

Full code and comments after the jump. Read the rest of this entry »

Tags: , , , ,

30
Jul

Workday Message Board

Posted in Geek Parenting  by Kevin

I came across the Windows-based desktop tool extraordinaire ‘Samurize‘ the other day courtesy of my friends at Lifehacker and have been running with it ever since.

The app does a number of things, the one that really interested me was integrating the contents of a text file on your desktop and updating it as the file changed.  My usage started with first the ‘Hello World’ of desktop modding and adding a todo list, then evolved to writing a script that monitored a number of automated processes at work and created a text file for an embedded desktop dashboard.

I then turned my attention to how I could set up something with Dropbox and Samurize to synch between my daytime laptop and the one at home where the kids are constantly working.  Both being Windows machines made this easy as Samurize is currently Windows only.  Now I have 2 cross referenced files, synced over the net with Dropbox, that are edited on one machine and appear on the desktop of the other.  This makes it easy to post notes and messages, in a bulletin board style setup, to the kids during the day, allowing them to do the same.

Now we have a live bulletin board for swapping messages during the work day.  Shiny.

I have a few Dropbox invites left, shoot me an email if you want one of them.

Tags: ,

22
Apr

My New Browser Goes to 11 (-8) and Your Browser Sucks.

Posted in Humor, Uncategorized  by Kevin

Just 1 back button is for losers apparently.So I upgraded today from an earlier version of 3 to the new beta 5.  Biggest difference?  Not one, not two, but three sets of navigation buttons!  Yeah, behold the future of surfing UI you chumps.

So I checked and IE 7? One back button.  Opera v9.27?  One measly back button.  Safari 3.1?  Yep, only one.  Losers.  Once again the folks at the fox are blazing trails with usability.  Baby got back x 3.

Navigating backward has never been easier or more fun.  Thanks Firefox!  After being Rickrolled earlier tonight (thanks Grandma) I navigated back so fast that I pulled a muscle in my neck.  This is like my browser going to 11, only 8 less.

Upgrade today and I’ll see you somewhere back there, ’cause that’s where I’ll be.

Tags: , , , ,

17
Apr

Datagrid into Excel in VS 2008 - C#

Posted in Code  by Kevin

My old, standard code to do this in a previous version was throwing errors and required some research.  The working code included a workaround for what some are classifying as a bug (It looks though as if MSFT closed it as ‘by design’). Your mileage may vary.

To implement this you need to have a datagrid on your page already and link up the ‘ImageButton1′ element to your ‘Open this grid in Excel’ image or button.  You can then use the following pieces with little alterations.  Pay attention to part 4, you may have a decision to make there.

Part 1:
You use the old standard code to wire up the button to call the method:

{
	Response.Clear();
	Response.Buffer = true;
	Response.ContentType = "application/vnd.ms-excel";
	Response.Charset = "";
	this.EnableViewState = false;
	StringWriter sw = new StringWriter();
	HtmlTextWriter hw = new HtmlTextWriter(sw);
	this.ClearControls(YOUR_GRID_CONTROL_HERE);
	YOUR_GRID_CONTROL_HERE.RenderControl(hw);
	Response.Write(sw.ToString());
	Response.End();
}

Including the ClearControls method to strip controls out of your grid and leave their value instead.  This is called in the click handler. I clearly need to get a code plugin for Wordpress as my spacing was lost in translation here and it sucks to read…

private void ClearControls(Control control)
{
	for (int i = control.Controls.Count - 1; i >= 0; i--)
	{
		ClearControls(control.Controls[i]);
	}
	if (!(control is TableCell))
	{
		if (control.GetType().GetProperty("SelectedItem") != null)
		{
			LiteralControl literal = new LiteralControl();
			control.Parent.Controls.Add(literal);
			try
			{
				literal.Text =
				(string)control.GetType().GetProperty("SelectedItem").GetValue(control, null);
			}
			catch
			{
			}
			control.Parent.Controls.Remove(control);
		}
		else
			if (control.GetType().GetProperty("Text") != null)
			{
				LiteralControl literal = new LiteralControl();
				control.Parent.Controls.Add(literal);
				literal.Text =
				(string)control.GetType().GetProperty("Text").GetValue(control, null);
				control.Parent.Controls.Remove(control);
			}
	}
	return;
}

Here is where the old code (above) started throwing new errors.  The 2 following items may or may not be needed depending on your configuration.

I was getting an error about the grid not being in the form at that point which was bogus (as it was in the form) and found the following workaround for what some felt is a bug (http://connect.microsoft.com/VisualStudio/feedback/ViewFeedback.aspx?FeedbackID=118285). Regardless, placing this before the 2 methods above cleared the error.  I didn’t need to call it though a co-worker was calling it from the onlick event.  Regardless of if you call it directly or not, it contains no code.

public override void VerifyRenderingInServerForm(Control control)
{
	// Confirms that an HtmlForm control is rendered for the
	// specified ASP.NET server control at run time.
	// No code required here.
}

Now I was getting an error stating ‘RegisterForEventValidation can only be called during Render();’. What info I found stated that this seems to occur when there are column sorts present when doing this operation.

That leaves you with 2 options (that I know of) if you want the resorting to still be enabled (and I did):
ONE: Turn the eventValidation off, either for the page or whole app.  Effective, but not best practice for security so I opted for the slightly irritating, but just as effective, option 2.  My advice would be to leave eventValidation in place and go with option 2, but hey, I like freedom of choice too so here is how to disable it if you want:

To disable eventValidation:
For a single page - Put this in the @ Page

EnableEventValidation = "false"

For your whole app - Put this in the web.config

<pages enableEventValidation ="false" ></pages>

TWO: You can define a second gridview which looks exactly like the original, but with visible=”false”. Then when you hit the export button you make the hidden grid visible and get the result you are after, but with a little messier code.  The advantage here is that you can leave additional controls out of the 2nd grid and remove any styles so it renders better in Excel…

Tags: , , , ,

8
Apr

Buffy Between the Lines

Posted in Uncategorized  by Kevin

I’m going to be participating in the (standby for the adjectives) online, ‘radio-dramatized’, fan driven, Buffy the Vampire Slayer project known as ‘Buffy Between the Lines’.  Season 2 is just gearing up and I’ll be playing the mysterious character known as ‘Keith’ though I think that they are going to kill me off.  Because they can.

You can listen to season I and read about the project here: http://buffybetweenthelines.com

Also available via podcast.

I’m pretty psyched about participating and it came as no surprise that the part I got has no singing…

Tags:

25
Mar

Edward Hopper and Life

Posted in Commentary  by Kevin

Recently my wife and I went to the National Gallery of Art in DC and spent the day wandering and looking at the exhibits.  There were a number of fantastic pieces there, but is was a good, yet rather plain, painting that had the most impact on me.

An elderly man was standing in front of a wall on which was hung a single painting (Edward Hopper’s 1941 painting, Route 6, Eastham) that depicted a house and road in a rural setting that looked as if it had come from the 1940’s.  It is a fairly solitary painting with no figures, vehicles or action.  Just some houses and a road that disappears into the distance.

This man was standing, shoulders slumped, staring at the painting and that had a much greater impact on me than any of the art did.  The painting was simple and conveyed a clean, simple world of a rural mid-century home and the life that might have accompanied it.  I’m not old enough to see how life and the world has changed since that scene was commonplace and could not quite grasp the size of loss that his stance in front of the painting conveyed.

Remembering all the laughter, love, heartbreak and experiences that come in the less responsibility-ridden days of youth is already sentimental enough a loss.  Those days are gone and must now stand as they are.  I can scarcely imagine the weight my memories will carry when I reach my elder years and when my experiences to then loom as the only significant experiences I will have and not just ‘the earlier chapters of my life’.  How old will will any of us be when we come to the realization that we have already done the greatest things we will do?  I’m a positive guy, but a realist too.  Eventually age and the cultural limitations that come with it are going to flesh out that bell curve.

It is a nice piece or art but would have never sparked nearly as much in me without the look of loss on that old man’s face as he looked at it.

I suppose we spend our days trying to achieve enough so that when that day comes that we stand in front of the painting and are reminded that we’ve reached that turning point we can smile and walk away from the painting and our achievements without slumping our shoulders.  The clock is ticking, I need to get back to living.

Tags: , , ,

4
Mar

Song Charts

Posted in Commentary, Music  by Kevin

This started with my finding a brilliantly mocking graph that someone had made further poking fun at the Rick-rolling Rick Astley anthem ‘Never Gonna Give You Up’.  From there I was led down a rabbit hole to a group of people that are creating graphical representations of songs.  My first one follows, long live Sammy:

Most are far more inventive and wonderful, here are 2 that you should not miss:

And here is the one that started it:  Rick Astley

Tags: , , ,

1
Mar

Mass Effect

Posted in Commentary  by Kevin

I never got caught up in the hype of BioWare’s Mass Effect, partially because I never felt much passion for the precursor, Knights of the Old Republic.  Even after playing KotOR I thought it OK, but not anything more than that.  That being said I rented Mass Effect one weekend a few weeks ago along with some Wii game that stunk, so badly that I forget what it was.  The verdict on Mass Effect?

Awesome.

It is not of a genre that usually hooks me but the game sucked me right in and when I had to return the game I stopped and bought a copy.  I’d wake up at 5 AM to get some playing in before the family started stirring, I’d stay up much later than I should, I’d squeeze in 1.43 minutes while making toast, I absolutely loved it.  Here is why:

  • The story is a solid, engaging SF tale.
  • The visuals are excellent, I loved that my customized character was in all cut scenes.
  • The conversation/interaction model was fun, I could play as ‘me’
  • The combat system grew on me and though was never as challenging as a straight-FPS required me to play more strategically than I usually do (read charge in with shotgun blazing).
  • I got to hook up with a cute blue alien and I think she totally dug me.  I attribute this fixation to my years of loving Pa’u Zotoh Zhaan on Farscape, behold my penchant for blue ladies.

What I was not wild about:

  • All the driving over mountain ranges (c’mon, I don’t need to shoot crap every second, but c’mon, damn)
  • Not enough blue alien ladies
  • Light instructions, no in game help to speak of and having to hit the forums to get some tips on stuff I don’t expect to have to hit forums for

If you have a 360, try it out, it is on my very short list of favorite games ever.

Tags: , , , ,

8
Feb

New Firefly Novel (Fanfic) Available

Posted in Commentary  by Kevin

I make no effort to hide my passion for Joss Whedon’s Firefly series/universe and the subsequent file Serenity. I may have retired from the Week in Whedon Podcast but my love for the man’s literary works is as strong as ever. If you like exceptional writing, characters and some high adventure you are doing yourself a profound disservice to not have watched the Firefly series. You can get the whole series on DVD for pretty cheap, if you pay $30 for it you didn’t look hard enough. Watch Firefly before Serenity though as you’ll get more out of it.

OK, moving on to the point here. I’m not a huge purveyor of fanfic, I suppose that I have just read some bad stuff in the past and gotten a bad taste for it. Any monkey with a typewriter can write fanfic and the results I’ve read have often struck me as, well, written by a monkey. The new Firefly-verse set novel by Steven Brust is a far cry from the unholy spawn of monkeys and keyboards, and is worth a read.

It is 168 pages of Firefly loving fiction and though I am far from finished, as it is vying for my scant spare time along with George Martin’s “A Clash of Kings”, it seems a fine read to date with the voices of the characters that we enjoyed so much on the show/movie shining through in the book.

Download a copy here: http://dreamcafe.com/firefly.html

This has my seal of approval though I find myself oddly bothered by the umlaut in Zoe’s name. Keep it in Blue Öyster Cult, leave it out of Firefly…

Tags: , , , ,

5
Feb

Starting a Family Wiki

Posted in Geek Parenting  by Kevin

My long term memory is, well, OK at best. This is not a new development and the age of electronics has enabled me to store the information I want to remember and access it easily so this is not a debilitating personal shortcoming. I’ve embraced it, or at least compensated for it, reasonably as I accepted it and tools evolved.

Years ago my wife and I started recording (on paper) and placing in a box all of the memorable quotes that our children said so we would not forget them. Within a few days of a great quip we always seemed to have trouble remembering exactly what was said. So a decade later we had a treasure trove of hilarity scribbled on scraps of paper stating what someone said, when they said it and what the context was.

I was already using MediaWiki to store notes and pieces of code that I’d written over the years giving me an easy and convenient way to index and refer to that info when we decided to do the same for family info we did not want lost to faulty memories.

We have now been running a family wiki for over a year now and have piles of great information stored away for ourselves in later life or our children or grandchildren to refer to. The wiki format allows us to write a little bit about teachers (favorite and otherwise), crushes, art projects, first roller coasters, what people dressed as for Halloween, what we did on family vacations, favorite family recipes, poems written for school, who coached the basketball team in ‘06, great family practical jokes, those quotes and sayings that everyone has, and ten thousand other things that will be wonderful to flip through and remember in a few decades.

We’ve affectionately named ours the Clio Project in honor of the Greek Muse Clio, the Muse of memory. Now ‘to Clio’ something is a common verb. Well kind of common…

With some dedication the Clio Project is turning into a family treasure as increasingly more information is finding its way into an electronic format anyway and flowing into our data store. MediaWiki supports pictures, files, version control, categories, discussions (handy when my oldest disagrees with my assessment of any given item) in addition to passwording and overall site-access control.

So start early, having great moments documented from their beginning would be a great gift to give your child or grandchild one day. I wish the technology was around back when we started ‘The Box’ as much of the great details over those years have already faded or are fading rapidly now. I’ve found that if you take just 30 minutes a week to make an entry on some topic and it starts to accumulate pretty quickly.

I’ll end this post with a favorite entry from our wiki, from the category ‘Quotes’:

Kevin asked [son] if he wanted a hard-boiled egg for a snack:

[son]: No, I don’t like eggs (pauses) except when they are in cake.

6/17/2005 - [son] almost 5 years old.

Tags: , ,