go to:

Thursday, December 04, 2008

Native MDI Containers, Managed Child Forms, and Me...

So, at work we have this (ugly) native C++ MFC application that the Powers-That-Be insist needs a complex web-services riddled interface to our social-networking-meets-file-sharing new website.  Initially, said interface was to be in MFC native code action.  I said, "sheeeeeeeeeiiiiiiiiiiiiiiiittt".  But then the light came: why not do the interface in a .NET form and pass the form handle somehow to the native application to pull it into its window as a child window.  Any interaction between the two can be handled easily through messaging calls.  I immediately began to Google on it.  I found nothing that directly addressed this problem.  I concluded it was one of two things: either it was so easy, no one bothered documenting it, or so rarely done, no one bothered documenting it.  Either way, no one bothered documenting it...UNTIL NOW!!!

Basically my solution was to grab the parent window's class using a call to GetClassName, then send this as a command line parameter to the .NET exe via a ShellExecute call.  Once in the .NET client, I use two DllImport-ed calls: FindWindow and SetParent -- FindWindow to get the window handle from the class name I passed in as a parameter, and SetParent to, well, set the parent of my form.

The sample code is here.  Note, you'll need to change the hardcoded path in the NativeMaster C++ solution to the output of the ManagedChild project.  Hope it's helpful...


Submit this story to DotNetKicks

Monday, November 24, 2008

DIB, C#, and Me...

Ok, after pulling out my hair trying to generate thumbnails from device-independent bitmaps stored by a CArchive in an "old" MFC program, I finally got help here at the workplace on this.

I must say I could not find this easily with much Googling, ergo I'm gonna post this up here with comments for anyone else out there looking for the same thing.

Please suggest any updations to comments and / or code, if you see the need...

NOTE: This code has been updated. Look here for it.

// our BITMAPINFOHEADER struct, as per gdi
// use LayoutKind to make sure data is marshalled as we've laid it out
public uint biSize;
public int biWidth;
public int biHeight;
public ushort biPlanes;
public ushort biBitCount;
public uint biCompression;
public uint biSizeImage;
public int biXPelsPerMeter;
public int biYPelsPerMeter;
public uint biClrUsed;
public uint biClrImportant;
public void Init()
biSize = (uint)Marshal.SizeOf(this);

public static Bitmap BitmapFromDIB(MemoryStream dib)
// get byte array of device independent bitmap
byte[] dibBytes = dib.ToArray();

// get the handle for the byte array and "pin" that memory (i.e. prevent garbage collector from
// gobbling it up right away)...
GCHandle hdl = GCHandle.Alloc(dibBytes, GCHandleType.Pinned);

// marshal our data into a BITMAPINFOHEADER struct per Win32 definition of BITMAPINFOHEADER
BITMAPINFOHEADER dibHdr = (BITMAPINFOHEADER)Marshal.PtrToStructure(hdl.AddrOfPinnedObject(), typeof(BITMAPINFOHEADER));

// go ahead and release the "pin" from our handle on that memory

// If the target device does not have one plane, or we're working with a bitmap other than a
// non-compressed (BI_RGB) bitmap, we're not gonna work woith it
if (dibHdr.biPlanes != 1 || dibHdr.biCompression != 0)
return null;

// we need to know beforehand the pixel-depth of our bitmap
PixelFormat fmt = PixelFormat.Format24bppRgb;
switch (dibHdr.biBitCount)
case 32:
fmt = PixelFormat.Format32bppRgb;
case 24:
fmt = PixelFormat.Format24bppRgb;
case 16:
fmt = PixelFormat.Format16bppRgb555;
return null;

// prepare for our output bitmap
Bitmap bmp = new Bitmap(dibHdr.biWidth, dibHdr.biHeight, fmt);

// load our "empty" bitmap into memory and lock it for writing in the format we specified
BitmapData bd = bmp.LockBits(new Rectangle(0, 0, bmp.Width, bmp.Height), ImageLockMode.WriteOnly, fmt);

// marshal our device independent bitmap data over to our output bitmap
Marshal.Copy(dibBytes, Marshal.SizeOf(dibHdr), bd.Scan0, bd.Stride * bd.Height);

// we're done marshalling, so release our bitmapdata lock

// DIB data is upside-down for some reason, so flip it

// return our bitmap
return bmp;


Submit this story to DotNetKicks

Tuesday, November 11, 2008

C++, Web Services, TinyXML, and Me...


So my current employer wants our existing MFC application to interface with some web services exposed by our new website (sorry, need to stay hush-hush about it at the moment).  Now, while the MFC side of things is turning out to be a bitch, I threw together some classes to make life easier for me.  The source is here.

CppHttp.h is a simple class to do GET and POST requests through.  Currently, it does NOT do multi-part requests, but I promise to update this when I get to that.  To consume the responses, I'm using TinyXML.  I looked at some other libraries, including using the MsXml stuff, but they were WAY overboard what I needed.  I included a sample class that calls a stock market thing I found on  The Find method in there is particularly useful when getting, say, a DataTable back and wanting to go straight to the nodes.

Anyway, hope this is useful.  Let me know your thoughts.


Submit this story to DotNetKicks

Saturday, October 25, 2008

Dead Space, Metal Gear Solid 4, Ashley Todd, and Me...

Ok, first off, a Metal Gear Solid 4 update: I am increasing my rating from a 6 to a 6.5.

For those of you in the know, I am now off to deal with Rex. At any rate, even my wife was interested in the plot, although it wasn't like she could flip the channel, heh...

I am not sure how soon I will return to MGS4, however, as Deep Space just came, and my god is it great. The graphics, like MGS4 are stunning, it IS creepy, and I very much like how the storyline (albeit far, far "simpler" than MGS4) is unfolding through the gameplay and not through a million cut scenes.

Other than that, no coding or political updates, per se. One quick note on the Ashley Todd debacle: although we are extremely close to electing the first black President in our history -- an enormous leap since as late as the 50's, this is still obviously only window-dressing over our nation's subconscious. Miss Todd could have said anything, including that she simply can't remember what happened. Instead it was a large, viscous black man who attacked her.

Why is it never a Chinese man?

Submit this story to DotNetKicks

Tuesday, October 21, 2008

Metal Gear Solid 4 and Me...

Ok, I am not a hardcore gamer by any means. My wife got me a PS3 for Father's Day, as I got to see Grand Theft Auto on his and immediately spooged myself. GTA4 = 10 / 10. Period. Very fun. Etc.

To me, there is a common denominator between GTA4 and FarCry -- two (very?) different games: both follow a mantra of allow the gamer to go anywhere, do anything. Discovering those worlds and just playing around in them makes the product soooo much more enjoyable. A big reason why I'm giving MGS4 a 6 / 10...tops.

First and foremost, the TONS of cut scenes in MGS4 is driving me crazy. The game is so beautiful and very engrossing when you get to play (although not being able to jump, say over a very narrow hole in the floor, is annoying).

Second, I don't know what Tokyo Mushrooms the development team was eating when they made this, but the storyline was so very cool UNTIL Raiden comes in (if you've played it, you know what cut scene I'm talking about). Then it gets super-anime and quite frankly, super-gay. The game actually felt very mature, like it was a commentary on war (and it may still be), but is now cartoonish and rediculous.

I'll definitely re-post should my views on this game change, but for right now, I'm somewhat disappointed. A 6 out of 10.

I am looking forward to Dead Space, which should arrive any day now, as well as FarCry 2 (ooooh yeah!).

Your thoughts on MGS4?

Submit this story to DotNetKicks

Saturday, October 04, 2008

Java, Dice, Programming Languages and Me...

So, I decided to write another Applet, this time one that gives the "popularity" of a programming language based on the number of instances found from a generic search.

The source code is here.

Submit this story to DotNetKicks

Thursday, October 02, 2008

Politics, The Vice Presidential Debate, and Me...

Ok, first and foremost: Biden is winning, and won.  Not hugely, but hands down.  However, this post will focus more on Palin, and a new respect I found for her tonight.  My hat's off to that woman. 

First, she made me feel like I was watching my neighbor suddenly thrown onstage to debate a seasoned politician.  Her nervousness, although well-checked, was still evident.  There was this "hockey-mom", as has become so popular a euphemism for her, up there playing with the big boys.  Ugh.  The courage that must have took...

Furthermore, I don't think my toughest cram session for any test in college or otherwise was close to the splatter she must have been going through the last few weeks.  It seemed very obvious to me that most of what came out of her mouth was studied and remembered, and that it was only "known" well enough to most times be put in the right context.  But that knowledge wasn't hers, yet; it hadn't sunk in as understanding.  If it had, it would have come out much more fluidly.  Regardless, my god the amount of information she must have had to assimilate.

An interesting topic came up on one of the networks Joey and I were watching prior to the debate -- that the biggest thing Palin is defending tonight is her career.  It seemed (I'd only been half listening at the time, as my eardrum was punctured today [another story]), it seemed the commentators / pundits then were implying that, should she grossly fail, her career will be kaput.

I am convinced McCain and Palin are not what we want the next four years, but I would be incredibly disgusted were her career to truly suffer after tonight, as she pulled a monumental feat for a small town woman, recently turned Governor.  Same as I would were Obama not given the credit for going from relative obscurity as a community organizer in Chicago to the possible Presidency.  My post from August 20 implies my same sentiment: that whatever memes out there have infected us simple citizens with such animosity based on doublespeak and bullshit that we overlook our own gut instincts.

One more plus I have to hand to Palin: she's absolutely a tasty bitch who deserves a good spanking for being such a bad kitty...

I really can't say, though, if that's a qualification or not for Vice President.

Submit this story to DotNetKicks

Thursday, September 04, 2008

Flash RGB, C#, and Me...


So a co-worker of mine had to translate Flash RGB data into a Bitmap. He noted that finding that out was difficult, ergo, for your coding pleasure, here's a tasty little static function you can use just for that:

static Bitmap BmpOut(string rgb, int width, int height)
Bitmap bmp = null;
int bytes = (rgb.Length / (width * height));
bool IsArgb = (bytes == 8);
double dWidth = (double)width;
bmp = new Bitmap(width, height);
int counter = -1;
for (int i = 0; i < rgb.Length; i += bytes)
bmp.SetPixel(++counter % width, (int)Math.Floor((double)counter / dWidth),
Color.FromArgb(int.Parse(((!IsArgb) ? "FF" + rgb.Substring(i, 6) : rgb.Substring(i, 8)), System.Globalization.NumberStyles.HexNumber)));
catch { bmp = null; }
return bmp;


Submit this story to DotNetKicks

Wednesday, August 20, 2008

Politics, Lexicology, and Me...

I've decided to add a politically-nuanced(?) entry based on a tiny epiphany I just had. I will, in my lifetime, have seen the political re-meme-ing of one or two words.

I was thinking about why I am disgusted with people who now accuse others as "another liberal". I'm not sure exactly why I'm disgusted, as the image this pops into my mind is of some hairy, unshowered, pseudo-intellectual, hippy lesbian 20-something dancing around at a large college party with Grateful Dead playing in the background. But this is not what's implied when a (neo-)republican lay-pundit snarls at someone being "another liberal".

I then thought of Ann Coulter. She, in her undergraduate years at Cornell, was in the College of Arts and Sciences, basically getting a liberal arts education. I thought then that schools nowadays may need to have both a college of liberal arts and a college of conservative arts. I didn't care so much about what this would mean, if anything, because it was then I noticed the meaning of these words in my mind at that moment is not actually what their meaning really is.

The word conservative should connote something to the effect of "if it works, that's what we should do," whereas liberal would therefore imply "we haven't tried this; it may be better, so we should try it." Again, we might also say that conservative means to purposefully use a minimal amount of, say, salt, whereas we're liberal with salt if we shake on as much as we might want.

Looking at the Bush / Cheney's administration through these terms really makes them neither liberal nor conservative. Some argue that Clinton made the economy what it was when Bush Jr. took over, others say he inherited it from Bush Sr. Either way, our economy was working, and working well. A conservative, under the assumptions of the above connotations, would have continued the policies that was proven successful. Liberals would have wanted to expand on it, try new things with it, even alter it. Technically, then, our current administration is very liberal when it comes to our economy.

What's more baffling, though, is our military strategies post-9/11. Bin Laden initially denied responsibility for the attacks. A conservative (again under the above connotations) would have held back military action again Bin Laden and Al Qaeda until substantial proof (not just evidence) warranted retaliation against them. A liberal would be less burdened by proof. At this point, we again seem to be seeing a far more liberal administration than a conservative one. However, the real proof is in the pudding, and the pudding consisted of 15 of the 19 hijackers being Saudi Arabian. Ergo, both the liberal and the conservative would have directed attention more to that region than, say, Iraq. What term then fits this administration? Retarded? Pussy?

The final coup-de-gras comes with Bush's desire to lessen restrictions created by the Endangered Species Act. Aside from the mind-boggling reasoning behind trying to push this one out when your poll ratings are so low, this is an extraordinarily non-conservative stance. As a noun, this implies one who is discreet, cautious. I would bet money that a vast majority of Americans support the Endagered Species Act. This is unlike global warning and other environmentalist issues. This is about keeping rhinos and polar bears and eagles in existence, because they're cool. Ergo, not the policy change you want to try to make if you're cautious, and especially if you want to be discreet.Furthermore , as an adjective, conservative means "tending to conserve; preserve". Thus, Bush is a hardcore liberal.

This may seem to be a Bush / Cheney lambasting entry, but it isn't. I'll enjoy returning to this with a Obama or McCain administration to see which way they truly lean. I just want to remain true to the roots of my native language. I'm just a staunch conservative that way.

Submit this story to DotNetKicks

Tuesday, July 22, 2008

A Programming Job Interview Challenge #13 - Brackets, and Me...

Ok, I've been doing the programming quizzes here and have a solution...

In Perl:

$FILE = "expressions.txt";
open(FILE) or die("Could not open expressions file.");
foreach $OLINE (<FILE>)
if ($LINE =~ m/(^[\]}\)>])|([\[{\(<]$)/)
{ print "bad : $OLINE" }
while ($LINE =~ m/(\[\])|({})|(\(\))|(<>)/)
{ $LINE =~ s/(\[\])|({})|(\(\))|(<>)//g }
$strLen = length($LINE);
if ($strLen > 1)
{ print "bad : $OLINE" }
{ print "good : $OLINE" }

And a C# console app to generate the "sample" strings (i.e. the "expressions.txt" file used above):

using System;
using System.Collections.Generic;
using System.Text;

namespace ConsoleApplication1
class Program
static void Main(string[] args)
static void Creator()
Random r = new Random((DateTime.Now.DayOfYear + DateTime.Now.Millisecond) * (DateTime.Now.Second + DateTime.Now.Minute + 1));
string encs = "[{(<>)}]";

string sb = "";
for (int i = 0; i < 100; i++)
sb = "";
bool good = (r.Next(0, 100) > 50) ? true : false;
int strlen = r.Next(1, 21) * 2;
for (int j = 0; j < strlen; j++)
if (!good)
sb = String.Format("{0}{1}", sb, encs[r.Next(0, encs.Length)]);
int p = r.Next(0, encs.Length / 2);
int q = r.Next(0, 3);
if (q == 0)
sb = String.Format("{0}{1}{2}", encs[p], sb, encs[encs.Length - p - 1]);
else if (q == 1)
sb = String.Format("{0}{1}{2}", sb, encs[p], encs[encs.Length - p - 1]);
sb = String.Format("{0}{1}{2}", encs[p], encs[encs.Length - p - 1], sb);
//Console.WriteLine(String.Format("{0}: {1}", good, sb.ToString()));

I couldn't spend that much time on this, as I am at work. Ergo, I'm a little disappointed with the Perl, although it was my first Perl program ever!

I'm particularly curious about how I could have done some sort of recursive check. Please give any suggestions to the Perl script that would make it as close to a one-liner regex check.


Submit this story to DotNetKicks

Wednesday, July 09, 2008

Conway's Game of Life, Java, Smoking, and Me...

Ok, I've done it again. Another Conway's Game of Life, this time in Java:

The source code can be had here. It's called Gola (Game Of Life Applet).

So, I've quit smoking. I started July 6 at 11:27pm (my last cigarette). It is going much better this time.  This is my third time.  The first two times I quit for 2+ years each time.  I know this time is my final one.  Why?  I had a "moment" where I just didn't want them anymore.

That feeling stayed, even after I failed, so I set a quit date, got the patch, got lots of pretzel sticks, and made sure I didn't sit around and drink coffee in the morning.  This is the third day, and I had to stay home today.  I felt like I had the flu and slept until 1:00pm.  I've been a vegetable and sleeping on and off since.  It's 5:33pm now, and I'm finally getting a little energy back.  I wrote a little C# program for watching the "progress" of quitting.  I was going to include the health benefits stages as stages that would appear below the timer, but I slacked.  Here's the code and benefits list.

Submit this story to DotNetKicks

Thursday, July 03, 2008

Conway's Game of Life in Javascript, and Me...

Ok, I went and done it...

With my inability to purge my rotting brain of Conway's Game of Life, I have produced none-other than a super double-buffered javascript only Conway's Game of Life!

Hopefully I can sleep now. Below is it in all it's glory. You can get the javascript to run it here.

NOTE: ARRRRRRGGGGHHH!!! Ok, trying to get javascript to run in blogger, but it'll take a little work. Here's so you can see it works

ADDENDUM: In Blogspot, IE doesn't like this script so well, nor does Firefox. I've removed it from the page but you can still see it at the link above.

ADDENDUM REDUX: Well, IE does not like this script at all. Performance is lousy and display is f-ed up. Firefox runs it like a champ.

Submit this story to DotNetKicks

Sunday, June 22, 2008

Smoking and me...

Ok.  Woke up at 8:00am.  It took one hour to have every environmental variable twisted and re-interpreted into the phrase: You picked the wrong time to stop smoking.  At 9:06am, I rolled a cigarette and smoked it.

Even the Habitrol (like Nicroderm patches) manual...I would read happy phrases like "Congratulations!  Now that you've decided to quit smoking, you should pick a date within the next 2 - 3 weeks as your offical quit date."  Key word is within.  What my mind said:  2 - 3 weeks from now; I obviously did this wrong; I didn't prep enough; I'm not ready!; Oh fuck, where's my cigs?

I also have friends showing up the next two weekends, which equals drinking.  Probably not a good idea to stop until after they're gone.  Wife's addendum to this: well, if you buck up like a REAL MAN, and deal with it, and...

I stopped listening after that; smoke got in my eyes, which kinda hurt.

Submit this story to DotNetKicks

Saturday, June 21, 2008

Mazes, SDL, Smoking, and Me...

So, first and foremost, I will (hopefully) be posting daily for the next month.  I've decided to quit smoking.  I feel like ass all the time and have a 4-month old son for whom I've promised to quit.  I will, starting tomorrow, be using the patch, eating excessively, and curling up into a fetal position.  I will also, as a reminder to myself and a small benefit to mankind, provide an entry each day recounting my pain and suffering.  I've "quit" twice before for 2+ years.  If I can make it 30 days, I should be golden.

I have also been playing around with SDL the last week or so, and have re-written my MazeRunner screensaver to use SDL.  Based on my recent OCD on (GDI-based) screensavers, some initial Pros and Cons:


  • WAY WAY easy to use; much more so than DirectX or OpenGL
  • Fast and effective


  • Screensaver display settings "preview" seems next to impossible
  • SDL_Timer + SDL_Events for rendering = bad idea.  I had the timer send an event message for when to re-render the screen.  Quitting the saver would throw an error big time.  Seems that the saver was "in the process of rendering" when SDL_Quit was called and the saver was trying to free the surfaces.

I've also been having one hell of a time trying to figure out how to remove the "chunkiness" of the animation.  It's not flicker, but rather looks like a screen sync issue.

Although I'm not near to being fully pleased with the final product, and haven't taken the time to clean up my code, I've decided to throw the source (Visual Studio 2005) out here.  The screensaver and necessary dlls are here in a zip file.  I've also decided to throw the Yagol++ screensaver and GDI-based MazeRunner source out in zips.  They are here and here, respectively.

If anyone out there can take a look at the SDL MazeRunner code and provide any tips, changes, etc., I'd be thrilled.  I'd really like to know what I might be able to do to improve the "smoothness" of the animation.  I've only tried it out so far on my laptop here at home, so that may be a major reason, but I'd like it to look good on any system.

Submit this story to DotNetKicks

Friday, June 13, 2008

Screensavers, Mazes, and Me...

Ok, I'm on a major OCD track with screensavers.  I've written a stupid Maze Runner one, which you can download here.

I need to update this and the Yagol one for the Preview dialogs, plus potentially add some settings.  Currently, the preview for the Maze Runner looks like this:


Which doesn't really show the guy running through the maze.  Not sure when I'll get to this as I'm now focused on my next masterpiece!

I'll also throw the sourcecode up for Yagol and this soon, even though I get no love from my (limited) audience.


Submit this story to DotNetKicks

Thursday, May 29, 2008

Conway's Game of Life REDUX!, Screensavers, and Me...

NOTE as of 06.23.08
The source is now available through this page

I've become obsessed with this stupid Game of Life shite. All my other projects are on hold until I get this out of my system.

So far, I've gotten out a simple, plug-in based .NET version: Yagol.NET.

Now, for your pleasure, it's: The Yagol++ Screensaver!


I added "traces" of where a cell used to be live up to five generations earlier.

The saver can be downloaded here. Now, here's the catch: if you want a link to the source, I'll post it as a comment reply after I've received some comments from you all requesting it. I NEED ATTENTION!



Submit this story to DotNetKicks

Tuesday, May 20, 2008

Multimedia-based Code Commenting, and Me...

Ok, a former colleague of mine decided to create an extension to Visual Studio to allow audio commenting of code.

Go here to check it out.

Submit this story to DotNetKicks

Thursday, May 08, 2008

Buzzwords, Clones, and Me...

Ed had a post about the fluff around simple, common-sense truths from which I must I ask: What might have sparked this commentary?

He answer's this question in part in his own passage: that he seems to be dragged to seminars around buzzwords / buzz-phrases, ergo providing fodder to contemplate over, ergo his posting. On the other hand, it potentially leads to a mind-bending philosophical journey into the nature of clones.

I, like Ed, find those nuggets of "truth" (buried deep, deep within the massive stool-pile which is the self-help / buzzword seminar) both enjoyable as well as potentially helpful (when they happen to synchronize with some conundrum going on in my life at the time). That is, many times these seminars are laden with metaphors and example stories that can be useful. However, a cliche is still a cliche, and for a person not to recognize the cliche, and even go so far as to announce that, upon hearing the cliche for perhaps the thousandth time, they're still mind-boggled by its profundity and freshness, is the mark of that person being a clone.

Clones seem to have the inability to recognize that they are fully embracing known stereotypes. For example, watch any MTV Spring Break. Thousands and thousands of chiseled people, both mentally and physically, distinguishable only by hair color and swim-trunk color. In Oregon, a neighbor native to the region (or "hick", as the classification goes), who'd actually never left the region, had a heavy Southern accent. Probably the most indicative of a clone is a youthful Caucasoid donning oversized denim pants with a crotch-seam around the knees, an oversized T-shirt, and a baseball cap turned to the side. These interesting specimens have a peculiar gait and "anxious-stiffness" along the shoulder region that produces a unique presence combining "menace" and "jackass" together. Also, it seems to affect the speech patterns in such a way as to emulate retardation or at the least half-wittedness. But I digress...

Stereotypes, like cliches or plants, require frequent watering, or they will shrivel up and die. Like cliches, this requirement is met through the combination of its "empirical" reaffirmation, as well as its memetic proliferation to new hosts. Unlike cliches, however, stereotypes reaffirm themselves, whereas cliches are reaffirmed through external circumstance. With this axiom, we can postulate:

The buzzword-based seminar is the King's Feast for the buzzword-based clone. Without buzzword-based seminars, the stereotype alive in the host clone will begin to shrivel and die. The starvation of the clone's donned stereotype leads to increasing stereotype-reaffirmation.

Ed's commentary itself is therefore either the rejoicing of a potential host's confirmation that they are not a buzzword-based clone, or that the said host has allowed the buzzword-based stereotype to shrivel and die.

Fascinating, isn't it?


For examples of clones / wsuGangstas, see this or this (and any related) or this or this or this (excellent specimen photos; not sure about the blog, but...)

Submit this story to DotNetKicks

Friday, May 02, 2008

C++, Conway's Game of Life, and Me...

NOTE as of 5.03.08
Update to code. It actually works now. (what do you expect in 30 minutes)

NOTE as of 06.23.08
C++ source is now available through this page

NOTE as of 01.13.2009
ALL NEW C++ Game of Life screensaver, with PONG! Get it (and source) here!

Ok, just trying to get back into C/C++ for work and decided to quick write Conway's Game of Life. I have named it thusly YAGOL (Yet Another Game Of Life).

I so hate C/C++ Win32 programming after working in C#. Been working on it for a few days and nights and had enough. Whipped a YAGOL.NET out in like 30 minutes.

Here's my C# version of YAGOL (Yet Another Game Of Life). I'll be revising it every now and then. It's total shit as of this post, but...

Source included.

Hey, if you decide to make rules or changes, email them here.

Submit this story to DotNetKicks

Wednesday, April 30, 2008

Thick-Clients, Web Apps, and Me...

I have a question for any software developers / engineers / architects out there:

Everyone is going ga-ga for web applications, partly because AJAX has brought thick-client-like behavior to the web client, etc etc. But there is still something to the plain ol' think-client. Downloading an application and running it locally -- it just seems more tasty. A case can be made, too, that thick-client applications haven't fallen behind, and may even be taking a somewhat new form: the portable application. With portable applciations, no installation is necessary; just unzip and run. Data is stored relative to the application's execution path. And by carrying said application on, say, a USB stick, the data is persistent and the application can be run anywhere (so long as on the same operating system, which leads to another item of discussion).

So the question is:
Do you think thick-client applications are more "popular" than web apps with the general public? That is, may there possibly be a preference by the average user for a local application vs. a web application?

I'd have to say that there is, perhaps only subconsciously, but there is. So long have we all had to use applications "locally" that, even with fantastic Google applications, we find ways to integrate them into our existant local applications. I am writing this entry now using w.bloggar from my thumb drive, not via the web interface provided by Blogger. My wife uses Picasa frequently -- the downloaded application. Google offered a Microsoft Outlook calendar syncing tool, which, combined with forwarding GMail to a Hotmail account and using Office Outlook Connector, has provided me with a "virtual" Exchange service.

The next great revolution could come with a portable JVM written in Java (he he), which could then run applications from a thumb drive on any computer, no matter the OS.

Anyways, your thoughts all?

Submit this story to DotNetKicks

Saturday, March 22, 2008

High-speed Camera Footage, ILMerge, and Me...

First and foremost and are really cool.  High-speed camera footage of...well, you should watch it!

For some reason I went into vegetable-mode watching high-speed footage on YouTube of katanas cutting a bullet in half and a tomato and pretty much several dozen things a katana could cut in half.  I'm pretty sure I got those links from watching Pfaff's wing tsun demonstrations.  I have no idea...

Second, trying to the 3.1 Enterprise Library.  Here's the steps:

  • create Microsoft.Interop.Security.AzRoles.dll and copy into, say, c:\el31m
    • get from 2003 Svr., or install Server admin pack)
    • tlbimp that shiz with
      tlbimp azroles.dll /out:Microsoft.Interop.Security.AzRoles.dll /namespace:Microsoft.Interop.Security.AzRoles   

  • install / build entlib 3.1

  • copy all entlib 3.1 dlls ( and xmldocs? ) into, say, c:\el31m

  • copy ilmerge into, say, the c:\el31m directory

  • run this dos script in there

@echo off
set bigolline=
for /f %%a in ('dir /b Microsoft.Practices.*.dll') do call :process %%a
ilmerge /lib:c:\el31m /lib:"C:\Program Files\Microsoft Visual Studio 8\Common7\IDE" /lib:C:\WINDOWS\Microsoft.NET\Framework\v2.0.50727 /t:library /log:merge.log /xmldocs /out:EnterpriseLibrary31.dll %bigolline%
goto :eof
set bigolline=%1 %bigolline%

  • entlib sweetness...

Seems to work gravy, however I'll be posting on configuring the netTiers templates to utilize this single library.  Just doing this because I'm getting kind of tired of seeing 50 gazillion assemblies after building a project.

Submit this story to DotNetKicks

Saturday, March 01, 2008

Oh My God! How F-ing great! ...and Me

Ok, I think I found organizational bliss...

My mind doesn't think linearly like a lame project manager or MTV meathead.  Nor does it think arrogant-"artistically" like a West-Coast "artist" (i.e. bike messenger working at a burrito cart talking about his art he never produces) or small Italian thesbians (inside joke).

Ergo, the combination of ToDoList, GanttProject, and FreeMind.  I can't over-laud this combination.  It is true hot-action.

So far, the "integration" between the three looks to be:


Any comments on this, please share them.  Especially enhancements, etc.

On a side note, here's a picture set of me and me new son, Liam.  Liam Preston Duvall, born February 5, 2008 at 1:05am.  7 lbs. 10 oz.  19".  Complete stud.


Submit this story to DotNetKicks

Sunday, February 03, 2008

Superbowl XLII and Me

Ok, I don't have the NFL network, so I watched tonight's FANTASTIC, AMAZING, SPECTACULAR game on Fox.

Two big questions and disappointments:

  1. What the hell happened to the good Superbowl commercials?  The commercials tonight sucked (except for the eTrade baby)...
  2. Where the (beep) was the "final" Joe's Diner commercial?

Very annoying.  However, I can overlook that disappointment considering the outcome of the game.  Good job Giants!

To be a good sport, I think the Patriots do deserve a round of applause on an excellent 18-1 season...

Submit this story to DotNetKicks

Friday, January 04, 2008

SQL Server 2005 Database Truncations and Me

Hi kids...

Here's a hot action script for truncating all the tables in your SQL 2005 db for you.  Please post your comments, changes, etc. and I'll update this throughout:

select distinct
    t.table_schema + '.' + t.table_name as [table]
    , case when tc.constraint_type = 'FOREIGN KEY' then 1 else 2 end as [order]
into #master_tbl
from information_schema.tables t
inner join information_schema.table_constraints tc on
    tc.table_schema = t.table_schema and
    tc.table_name = t.table_name
where t.table_type = 'BASE TABLE'
and tc.constraint_type like '% KEY'
order by 2

alter table #master_tbl
add idx bigint identity(1,1)

select *
into #k
from #master_tbl

select *
into #rk
from #k

while ((select count(*) from #k) > 0)

    declare @table varchar(1024)
    declare @idx bigint

    select top 1
        @table = [table]
        , @idx = idx
    from #k

    exec ('alter table ' + @table + ' nocheck constraint all')

    delete from #k where idx = @idx


drop table #k

select *
into #t
from #master_tbl

while ((select count(*) from #t) > 0)

    declare @tidx bigint
    declare @ttable varchar(1024)

    select top 1
        @tidx = idx
        , @ttable = [table]
    from #t
    order by [order]

    begin try
        exec('truncate table ' + @ttable)
        print @ttable + ' purged'
    end try
    begin catch
        print @ttable + ' could not be purged.'
    end catch

    delete from #t where idx = @tidx


drop table #t

while ((select count(*) from #rk) > 0)

    declare @ktable varchar(1024)
    declare @kidx bigint

    select top 1
        @ktable = [table]
        , @kidx = idx
    from #rk

    exec ('alter table ' + @ktable + ' with check check constraint all')

    delete from #rk where idx = @kidx


drop table #rk

drop table #master_tbl


Submit this story to DotNetKicks

Wednesday, January 02, 2008

C#, the GAC, and Me


Been playing around with Reflection a bit.  I wanted to determine if any of an assembly's dependencies have been loaded from the GAC or not.  Here's the code snippet for you to play around with:

using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Text;
using System.Windows.Forms;
using System.Reflection;
using System.Runtime.InteropServices;
using System.Runtime.CompilerServices;

#region assembly info
// General Information about an assembly is controlled through the following
// set of attributes. Change these attribute values to modify the information
// associated with an assembly.
[assembly: AssemblyTitle("TestForm")]
[assembly: AssemblyDescription("")]
[assembly: AssemblyConfiguration("")]
[assembly: AssemblyCompany("Big Uncle Simon Co.")]
[assembly: AssemblyProduct("TestForm")]
[assembly: AssemblyCopyright("Copyright © Simon \"The Big Goose\" Duvall, Inc 2008")]
[assembly: AssemblyTrademark("")]
[assembly: AssemblyCulture("")]

// Setting ComVisible to false makes the types in this assembly not visible
// to COM components. If you need to access a type in this assembly from
// COM, set the ComVisible attribute to true on that type.
[assembly: ComVisible(false)]

// The following GUID is for the ID of the typelib if this project is exposed to COM
[assembly: Guid("dafca86f-596b-44f3-be6d-173464c82a32")]

// Version information for an assembly consists of the following four values:
// Major Version
// Minor Version
// Build Number
// Revision
[assembly: AssemblyVersion("")]
[assembly: AssemblyFileVersion("")]

namespace TestForm
static class Program
static void Main()
Application.Run(new Form1());
public class Form1 : Form
public Form1()

private void button1_Click(object sender, EventArgs e)
DataTable table = ReflectionClass.Class1.Do();

this.dataGridView1.DataSource = table;
foreach (DataGridViewColumn dgvc in this.dataGridView1.Columns)
dgvc.AutoSizeMode = DataGridViewAutoSizeColumnMode.AllCells;

#region Windows Form Designer generated code

private System.ComponentModel.IContainer components = null;

protected override void Dispose(bool disposing)
if (disposing && (components != null))

private void InitializeComponent()
this.panel1 = new System.Windows.Forms.Panel();
this.panel2 = new System.Windows.Forms.Panel();
this.button1 = new System.Windows.Forms.Button();
this.dataGridView1 = new System.Windows.Forms.DataGridView();
// panel1
this.panel1.Dock = System.Windows.Forms.DockStyle.Left;
this.panel1.Location = new System.Drawing.Point(0, 0);
this.panel1.Name = "panel1";
this.panel1.Size = new System.Drawing.Size(200, 492);
this.panel1.TabIndex = 0;
// panel2
this.panel2.Dock = System.Windows.Forms.DockStyle.Fill;
this.panel2.Location = new System.Drawing.Point(200, 0);
this.panel2.Name = "panel2";
this.panel2.Size = new System.Drawing.Size(674, 492);
this.panel2.TabIndex = 1;
// button1
this.button1.Location = new System.Drawing.Point(13, 13);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(172, 23);
this.button1.TabIndex = 0;
this.button1.Text = "Do It";
this.button1.UseVisualStyleBackColor = true;
this.button1.Click += new System.EventHandler(this.button1_Click);
// dataGridView1
this.dataGridView1.AllowUserToAddRows = false;
this.dataGridView1.AllowUserToDeleteRows = false;
this.dataGridView1.ColumnHeadersHeightSizeMode = System.Windows.Forms.DataGridViewColumnHeadersHeightSizeMode.AutoSize;
this.dataGridView1.Dock = System.Windows.Forms.DockStyle.Fill;
this.dataGridView1.Location = new System.Drawing.Point(0, 0);
this.dataGridView1.Name = "dataGridView1";
this.dataGridView1.ReadOnly = true;
this.dataGridView1.RowHeadersVisible = false;
this.dataGridView1.Size = new System.Drawing.Size(674, 492);
this.dataGridView1.TabIndex = 0;
// Form1
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(874, 492);
this.Name = "Form1";
this.Text = "Form1";


private System.Windows.Forms.Panel panel1;
private System.Windows.Forms.Button button1;
private System.Windows.Forms.Panel panel2;
private System.Windows.Forms.DataGridView dataGridView1;

namespace ReflectionClass
static public class Class1
const string version = "{0}.{1}.{2}.{3}.{4}.{5}";
// got the below from
// left it is spanish, because so so cooool....
static public DataTable PivotearTabla(DataTable source)
//Crear la tabla
DataTable dest = new DataTable();

// Primera columna del pivoteo

//Agregar las columnas (y sus nombres o cabeceras) a la nueva tabla
foreach (DataRow r in source.Rows)

//Agregar las filas vacias, con el nombre en la columna cero (0)
for (int i = 1; i < source.Columns.Count; i++)
DataRow fila = dest.NewRow();
fila[0] = source.Columns[i].ColumnName;

//agregar data
for (int fil = 0; fil < source.Rows.Count; fil++)
for (int col = 1; col < source.Columns.Count; col++)
dest.Rows[col - 1][fil + 1] = source.Rows[fil][col];

return dest;
static private DataTable GetTableSchema()
DataTable table = new DataTable();
table.Columns.Add("Name", typeof(String));
table.Columns.Add("Full Name", typeof(String));
table.Columns.Add("Version", typeof(String));
table.Columns.Add("GAC'd", typeof(Boolean));
table.Columns.Add("Img RT Ver.", typeof(String));
table.Columns.Add("GUID", typeof(String));
return table;
static public DataTable Do()
DataTable table = GetTableSchema();
AssemblyName[] _names = Assembly.GetEntryAssembly().GetReferencedAssemblies();
List<AssemblyName> names = new List<AssemblyName>(_names);
foreach (AssemblyName name in names)
Assembly a = Assembly.Load(name);
object[] os = a.GetCustomAttributes(false);
foreach (object o in os)
Type t = o.GetType();
FieldInfo[] fis = t.GetFields();
foreach(FieldInfo fi in fis)
string tmp = String.Format("{0}.{1}", t.Name, fi.Name);
if (!table.Columns.Contains(tmp))
table.Columns.Add(tmp, typeof(String));
PropertyInfo[] pis = t.GetProperties();
foreach (PropertyInfo pi in pis)
string tmp = String.Format("{0}.{1}", t.Name, pi.Name);
if (!table.Columns.Contains(tmp))
table.Columns.Add(tmp, typeof(String));

DataRow newrow = table.NewRow();
newrow["Name"] = name.Name;
newrow["Full Name"] = name.FullName;
newrow["Version"] = String.Format(version,
name.Version.Major, name.Version.MajorRevision, name.Version.Minor,
name.Version.MinorRevision, name.Version.Revision, name.Version.Build);
newrow["GAC'd"] = a.GlobalAssemblyCache;
newrow["Img RT Ver."] = a.ImageRuntimeVersion;

foreach (object o in os)
Type t = o.GetType();
FieldInfo[] fis = t.GetFields();
foreach (FieldInfo fi in fis)
string tmp = String.Format("{0}.{1}", t.Name, fi.Name);
newrow[tmp] = fi.GetValue(o).ToString();
PropertyInfo[] pis = t.GetProperties();
foreach (PropertyInfo pi in pis)
string tmp = String.Format("{0}.{1}", t.Name, pi.Name);
newrow[tmp] = pi.GetValue(o, null).ToString();


return PivotearTabla(table);

I'll be updating with a better formatter for the code here later on.


Submit this story to DotNetKicks

Tuesday, January 01, 2008

Blog Tag and Me, by P. Simon Duvall

( this post has been blanked out, due to stupidity...)


Submit this story to DotNetKicks