Tuesday, March 11, 2008

Long ago I realized that I was not to be a prolific blogger, but would be the antithesis thereof; yet I still feel guilt over not doing it. Not for the sake of others, mind you, but because spouting my opinion/knowledge (or illusion thereof) is something I innately enjoy doing. Spouting my opinion here is less rewarding than doing so face-to-face - I like the immediate gratification it provides. Not to mention the fact that my opinions/knowledge are much better presented in the context of an active analog conversation than a seemingly-passive digital one. Yes, I know, I know, dialog does exist in our digital version of face-to-face reality, but it really isn't the same and I don't know that I have determined, for myself, if it is as valuable.

Anyway, I do hope to blog more if for nothing more than the opportunity to write, which is something I enjoy and need to work on.


posted on Tuesday, March 11, 2008 11:16:03 AM (Mountain Standard Time, UTC-07:00)  #    Comments [0] Trackback
 Thursday, November 01, 2007

I sure hope so! I noticed this quite some time ago when I first saw the syntax for anonymous types in C#. Being a lover of JavaScript, I quite like the ability to do things in C# in a manner consistent with the syntax I am used to using in JavaScript (my current favorite programming language, especially thanks to MochiKit). The syntax I refer to is partly alluded to in this post by Eilon Lipton (first time I have ever heard of Eilon), where he talks about substituting an anonymous type for a Dictionary<string, string>, using said Dictionary for setting attributes on HTML tags he is creating in C#. Sound familiar? I mentioned something similar in my post yesterday.

To illustrate the syntax I keep referring to, here is what I am used to doing in JavaScript, particularly with MochiKit - let's say I want to create a div element programmatically (and let's spit it out as HTML so we can better get the gist of things):

 toHTML(DIV({id:"myDiv", class:"myCssClass"}, P({ style:"font-weight:bold" }, "Hello World!")));

The HTML rendered looks like:

 <div class="myCssClass" id="myDiv"> <p style="font-weight: bold;">Hello World!</p> </div>

So, rather than declaring a the JavaScript function "DIV" or "P" (which create div and paragraph DOM elements, respectively) with every possible option as a parameter to said function (e.g. id, style, class, etc.), you simply pass in an anonymous object which contains values for the properties you care about setting. This is a fairly typical way of doing things in JavaScript, and despite the protests from the academic portion of my brain as well as other developers, I would love to be able to do the same in C#.

 

Technorati Tags: , , ,

posted on Thursday, November 01, 2007 11:38:15 AM (Mountain Standard Time, UTC-07:00)  #    Comments [0] Trackback
 Wednesday, October 31, 2007

Since learning about the SubSonic project last week, I have spent a bit of time reading up on it, watching screencasts about it, playing with it, and reading the blog of its creator, Rob Conery. In his post "How MVC, jQuery, and SubSonic Will Make You Smile," Rob talks about the use of .NET 3.5's extension methods, in particular extending a Dictionary<string, string> to return HTML for a drop down list (HTML select); here is what his version of the extension method looks like:

 

 1: public static string ToHtmlSelect(this Dictionary<string, string> listItems, string name,
object selectedValue, object attributes)
 2: {
 3:  // input formats
 4:  string selectFormat = "<select name='{0}' id='{0}' {1}>\r\n{2}\r\n </select>";
 5:  string optionFormat = "\t<option value='{0}' {1}>{2}</option>\r\n";
 6:  
 7:  // output
 8:  StringBuilder sb = new StringBuilder();
 9:  
 10:  foreach (string s in listItems.Keys)
 11:  {
 12:  string selectedFlag = "";
 13:  string text = listItems[s];
 14:  string value = s;
 15:  if (value.ToLower().Equals(selectedValue.ToString().ToLower()))
 16:  selectedFlag = "selected=true";
 17:  sb.AppendFormat(optionFormat, s.ToString(), selectedFlag, text);
 18:  }
 19:  string result = string.Format(selectFormat, name, attributes.ToAttributeList(), sb.ToString());
 20:  return result;
 21: }



 

He also mentions that (on line 19) there is another extension method that "hangs off the object class" which basically enumerates all of the properties of an object, creating a name/value pair attribute list. He doesn't give the code of that extension method, which he states "is ScottGu magic at work and something he shows in his MVC demos." I have yet to watch those demos myself, but the code is probably something akin to this:

 

 1: public static string ToAttributeList(this object attributes) 
 2: {
 3:  StringBuilder sb = new StringBuilder();
 4:  foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(attributes)) 
 5:  {
 6:  sb.AppendFormat("{0}='{1}' ", property.Name, property.GetValue(attributes).ToString());
 7:  }
 8:  return sb.ToString();
 9: }

 

This allows you to pass anonymous types, specifying what might normally be optional parameters, a la something I have been doing in JavaScript for a while using MochiKit (other JavaScript libs exploit the same literal JavaScript object notation in their function signatures). The idea is that you don't need to have a structured method signature that accepts all possible options - you can pass in what you want to specify as a part of an anonymous object. This will make more sense if you have spent any time doing this in JavaScript or want to wait a moment and read on.

Anyway, the whole reason I was even posting on this subject is because of a comment made on Rob's post by one Joe Chung, wherein he states:

"Seeing StringBuilder-generated HTML makes me sad for the future of ASP.NET. Object-oriented ASP spaghetti code is still spaghetti code."

He is referring to the string hacking done in the ToHtmlSelect extension method. I too don't care for it, and simply wanted to show a nicer way of doing this, which leverages objects we already have access to in ASP.NET which do that grunt work for us.

Here is my version of Rob's method (which I still have issues with, but for now we will let those go for the sake of staying on topic) - note, there are no literal strings for those that despise them:

 1: public static string ToHtmlSelect(this Dictionary<string, string> listItems, object selectedValue,
object attributes)
 2: {
 3:  DropDownList htmlSelect = new DropDownList();
 4:  htmlSelect.Attributes.AddAttributes(attributes);
 5:  foreach (string key in listItems.Keys)
 6:  {
 7:  ListItem item = new ListItem(listItems[key], key);
 8:  item.Selected = (key.ToLower().Equals(selectedValue.ToString().ToLower()));
 9:  htmlSelect.Items.Add(item);
 10:  }
 11:  return htmlSelect.ToHtml();
 12: }

 

Now, my version does not use the ToAttributeList() extension method hanging off of  object - mine uses something a bit different, but an extension method nonetheless (although a bit naive, it will suffice for our purposes):

 

 1: public static void AddAttributes(this System.Web.UI.AttributeCollection attributeCollection,
object attributes)
 2: {
 3:  foreach (PropertyDescriptor property in TypeDescriptor.GetProperties(attributes))
 4:  {
 5:  attributeCollection.Add(property.Name, property.GetValue(attributes).ToString());
 6:  }
 7: }

 

My extension method hangs instead off of System.Web.UI.AttributeCollection because my version of the ToHtmlSelect() method works with the System.Web.UI.DropDownList object, which uses that as the place to store its attributes.

The other key to mine is the following extension method which wraps a technique I have been using for over 2 years to create HTML (I didn't figure it out on my own, but can't remember where I saw this exactly - I think in the Google Group for the AjaxPro.NET component back when it was simply Ajax.NET):

 

 1: public static string ToHtml(this Control control)
 2: {
 3:  StringWriter sw = new StringWriter();
 4:  HtmlTextWriter htw = new HtmlTextWriter(sw);
 5:  control.RenderControl(htw);
 6:  return sw.ToString();
 7: }

 

Note - this can be used for all sorts of Control-derived ASP.NET HTML wrapper objects to get you some HTML without string hacking in your layers of code:

 

 1: Calendar c = new Calendar();
 2: string calendarHtml = c.ToHtml();

 

Notice Joe - no literal strings! That should make you happy (I know it makes me happy!).

Now, I love hacking JavaScript as much as the next guy (been doing it hardcore for the last 2.5 years even with ASP.NET because it is too much fun!), but hacking strings to create HTML is still not that fun. Even in JavaScript I don't do it if I don't have to, preferring to use functions that handle that for me (MochiKit has some simple DOM functions for handling HTML creation).

Anyway, hope this is of some use to someone out there!

 

Technorati Tags: , , , ,

posted on Wednesday, October 31, 2007 12:38:37 PM (Mountain Standard Time, UTC-07:00)  #    Comments [11] Trackback
 Tuesday, October 30, 2007

This looks like a future cult classic:

 

 

 

Free the Pirates of the Great Salt Lake


posted on Tuesday, October 30, 2007 8:09:47 PM (Mountain Standard Time, UTC-07:00)  #    Comments [0] Trackback
 Friday, October 26, 2007

It's true - the Mormons are members of a cult! Most don't even realize it, and those that do want to deny it; it remains utterly undeniable regardless!

See for yourself - this website has the incontrovertible evidence.


posted on Friday, October 26, 2007 8:59:26 PM (Mountain Standard Time, UTC-07:00)  #    Comments [2] Trackback
 Sunday, July 22, 2007

Many months ago, I noticed Winder Dairy had some Habanero Pepper Jack cheese. I could hardly contain myself because I love Habanero-based anything (I especially love Habanero hot sauce; I put it on practically everything I eat) and I love Pepper Jack cheese to begin with, so it sounded like a dream come true.

It was disappointing to say the least. Not only was the cheese devoid of any noticeable heat, it had some horrid taste to it that was anything but Habanero. Regular Pepper Jack was better than this stuff by a long shot.

Fast forward a few months and I find myself in our local Costco loitering, as I often do, near the cold case in which they keep their cheeses, and I spy Rumiano's Habanero Pepper Jack. Just looking at this fine specimen, I could immediately tell that this was not the weak attempt at marrying the divine taste of Habanero pepper and the smooth creaminess of Jack cheese that was the 'cheese' Winder Dairy sold me earlier. So, I dropped the $7.00 it cost me for a couple pounds of the stuff and headed home.

I could barely wait to find out if this was everything I had hoped my first experience with a "Habanero Pepper Jack" would be, so the minute I was in the house I tore off the packaging. Immediately the smell of it hit me and I could tell it was the real deal (if you know what Habaneros smell and taste like, one whiff of this stuff would tell you the same). Capturing the taste of the Habanero while taming the heat is a tricky task, but Rumiano has done it perfectly. The cheese is hot, but not so hot that your tongue and throat blister (have you ever eaten a raw Red Savina Habanero?).

This stuff is great sliced thick on a garlic burger, shredded and used in a burrito, or, as I most often eat it, sliced and eaten with crackers. This cheese is hot enough that it makes the top of my head tingle once in a while. It is SO good. I am grateful that Costco carried it, otherwise I might never have made its acquaintance. If you are so lucky as to find it at Costco and like it, I would suggest buying all you can - who knows if and when Costco will quit carrying it, and they have it for half of what you would pay if you buy it from Rumiano's directly (and that is before shipping!).


posted on Sunday, July 22, 2007 5:00:46 PM (Mountain Standard Time, UTC-07:00)  #    Comments [0] Trackback
 Thursday, March 22, 2007


Here is the story from KSL's website.

Why are these people doing this? This group, calling themselves "Soulforce,"  "travels to religious universities which, they say, discriminate against homosexuals." Hmm. The word discriminate is too vague to know what they are really after, but if they are really saying "we don't like your school because you believe that homosexuality is somehow wrong as a lifestyle choice and we want you to accept it with open arms" then they are really smoking crack, to put it in a politically-correct way. :P

Hello? The LDS church does not accept homosexuality as a lifestyle choice, and that is that. Non-negotiable. This is a very fundamental thing we are talking about. I hate to do it, because it is so cliched, but it is so true: God created Adam and Eve, not Adam and Steve. Capiche?

Now, does that mean we hate those that call themselves homosexuals or that feel they suffer from so-called 'same-sex attraction' (SSA)? No. Years ago I was friends with and used to share an apartment with someone suffering from SSA and I didn't treat him poorly or think of him as a freak nor does God. However, when people openly engage in homosexual activity, the act is what is condemned. And that does not mean we are homophobic. Could it lead to homophobia? Sure. And that should be watched. However, the LDS church and the schools it owns are not going to bow to your pressure.

I don't know why, but the agenda of homosexual groups really gets on my nerves and I guess that is why I blog about it particularly. Used to be that all they wanted was tolerance. Then they wanted acceptance and validation for their lifestyle. Now they will not tolerate the beliefs of those that once tolerated them. How nice - that is right in line with something Elder Neal A. Maxwell once said:

"Today, in place of some traditionally shared values is a demanding conformity pushed, ironically, by those who eventually will not tolerate those who once tolerated them."


posted on Thursday, March 22, 2007 3:39:17 PM (Mountain Standard Time, UTC-07:00)  #    Comments [4] Trackback
 Tuesday, March 13, 2007

 

Just one of the many stories about this.

Good for Gen. Peter Pace! Why should he apologize? He is just as entitled to his beliefs as the very homosexuals that he offended in his statement. Right? Or did that change?

I know people are probably just upset because he represents a branch of the military and can't say those things as official policy statements, but the man is completely entitled to believe what he believes. Homosexuals do so, why can't this man? It's about time someone stood up for their beliefs and let the chips fall where they may. I am not celebrating his opinion, per se, simply the idea that one can say what they believe and not be strung up for it.

Representative Marty Meehan of Massachusetts recently assumed "Chairmanship of the Armed Services Subcommittee on Oversight and Investigations" and said about Mr. Pace's comments, "General Pace's statements aren't in line with either the majority of the public or the military."

So, the man should align his opions with popular opinion? I like dark chocolate and think it is better than milk chocolate - that is against popular opinion, yet I don't plan on changing my opinion. Mr. Meehan also said that General Pace "needs to recognize that support for overturning (the policy) is strong and growing" and that the armed forces are "turning away good troops to enforce a costly policy of discrimination."

Maybe he does recognize these things; it doesn't mean it will change his personal opinion about homosexuality being immoral, and I don't think it should.

"...if the time comes that the voice of the people doth choose iniquity, then is the time that the judgments of God will come upon you; yea, then is the time he will visit you with great destruction even as he has hitherto visited this land." - Mosiah 29:27


posted on Tuesday, March 13, 2007 9:39:15 AM (Mountain Standard Time, UTC-07:00)  #    Comments [2] Trackback
 Friday, March 02, 2007


Just released this today - it yet needs a bit of work; the only major part not completed are the methods that provide metadata for stored procedures (mainly because I don't need this feature at the moment, so it was the lowest on my list of priorities), which I am planning on finishing within the next two weeks.

You can download it at www.sapientdevelopment.com.


posted on Friday, March 02, 2007 5:09:47 PM (Mountain Standard Time, UTC-07:00)  #    Comments [0] Trackback
 Tuesday, February 27, 2007

 

The company I work for is hiring -  whether you are a project manager, senior-level Java developer, Microsoft application developer or a web design/usability expert, Software Technology Group has something for you.

I have worked for STG for over 2 years now and can tell you that, without a doubt, working for STG has been one of the highlights of my career.


posted on Tuesday, February 27, 2007 9:28:28 AM (Mountain Standard Time, UTC-07:00)  #    Comments [0] Trackback
 Sunday, February 04, 2007

Jose Luis de Jesus Miranda not only claims to be Christ, but that he is the Anti-Christ also. De Jesus claims that, in 1973, Jesus Christ visited and 'integrated' with him.

"In 1998, de Jesus avowed that he was the reincarnation of the Apostle Paul. Two years ago at Growing in Grace's world convention in Venezuela, he declared himself Christ. And just last week, he called himself the Antichrist and revealed a "666" tattooed on his forearm. His explanation: that, as the second coming of Christ, he rejects the continued worship of Jesus of Nazareth."

You have to admit, that is good stuff. From the same story, it is reported that de Jesus preaches that sin no longer exists, and that the devil doesn't exist and that people are predestined to be saved. Wow, that just sounds so wonderful - but I am confused by something: if sin doesn't exist any longer, why aren't we all saved? I mean, if we are no longering sinning, what is preventing us from being saved then? Also, members of his church are expected to pay tithing - but what if they don't? I mean, if people are predestined to be saved, what is the point of paying tithing? I just don't get it. Anyone want to explain these things to me?

If you are going to create your own church, you would do well to make sure the doctrine you teach is at least a bit more consistent than this, right? Obvious to anyone that knows even an iota of the teachings found in the Bible, there are many problems with the claims of this charlatan. If you read the story, you will notice it makes mention of "three burly guys in dark suits with Secret Service-style earpieces" - why does the supposed Lord of the Universe need body guards?


posted on Sunday, February 04, 2007 11:28:28 AM (Mountain Standard Time, UTC-07:00)  #    Comments [1] Trackback
 Sunday, November 12, 2006

I just thought I would make a statement fraught with gross generalization akin to the one Elton John made...

Hey Elton - just because someone fails to live the religion they claim allegiance to doesn't mean that the religion itself is bad, regardless of it being 'organized' or not; people will be people, and unfortunately, we all make mistakes.

Now, I am sure what you really want to condemn is the fact that many 'religions' (read: Judeo-Christian type religions) have teachings that run contrary to your 'lifestyle' choice - but that isn't open for debate, unless by sophistry you wish to rationalize away said teachings as being mere suggestions or incorrect translations or whatever is currently in vogue among the innumerable philosphies of men.

By the way, as an artist I think you are pretty good and 'Philadelphia Freedom' is one of my faves; see, no hatred coming from this member of an organized religion.


posted on Sunday, November 12, 2006 12:48:27 PM (Mountain Standard Time, UTC-07:00)  #    Comments [3] Trackback
 Sunday, October 29, 2006


For the last client I worked for, we extensively modified a MochiKit port of a well-known 'Lightbox' implementation so that it would utilize IFrames - the users of the application loved it because they were used to primitive JavaScript alert and confirm boxes, and since a modal dialog was still the appropriate thing to do, it worked well.

A short time later, I found ThickBox - seems to be a much better implementation of this now-common technique, and I thought it might prove useful to have a MochiKit version of it in case I decide I want to use it (it is built on jQuery, which I don't personally use or care for, notwithstanding the library having a few useful constructs that I would like to see ported over to MochiKit).

In porting this script, I tried not to 'improve' it at all; i.e. I left nearly everything as-is with regards to naming conventions, use of certain constructs that I would like to improve, etc. and leave it up to you, if you choose to download it, to make any changes you see fit. Of course, any bugs you find would be great to know about, as well as ideas for enhancements, etc. and I will probably update this when I get time, because I would like to do things much differently (maybe I am smoking crack, but this whole idea of connecting to things based on the value of the 'class' attribute of a tag just seems stupid to me...).

My port of ThickBox isn't perfect and I did it as quickly as I could because I wanted to get it into the hands of those smarter than I - that means you. There are places in the code that are inconsistent and I will be working on that, but for now it does the job and should be a good starting point for those that find this useful.

Download ThickBox for MochiKit.


posted on Sunday, October 29, 2006 11:02:53 AM (Mountain Standard Time, UTC-07:00)  #    Comments [2] Trackback
 Saturday, February 28, 2004
Be smart about buying books

posted on Saturday, February 28, 2004 5:14:28 AM (Mountain Standard Time, UTC-07:00)  #    Comments [2] Trackback
 Wednesday, January 28, 2004
Funny vi comic

posted on Wednesday, January 28, 2004 3:39:51 AM (Mountain Standard Time, UTC-07:00)  #    Comments [0] Trackback
 Sunday, August 10, 2003

Okay, my intent for starting this blog are many, but primarily, it will serve as a place for me to record, for my posterity, things I learn with regard to technology, as well as my thoughts on the same, and just about anything else I deem fit (rather ambiguous, but I like it that way!). For example, I must say that I need to own a Mullet Wig, because mullets are such an integral part of American heritage. If you were alive during the ‘80s, there is a good chance you had a mullet. I had one, though it was small and short-lived, owing to the fact that it made my neck sweat. When I told the barber to cut it off, he seemed astonished – “Are you sure?!” Was this barber trying to give fashion advice, trying to save me from making a regrettable mistake? Possibly. I have never regretted it, and I hope he can look back and remember me as one who could see the demise of the coolness of mullets before most others, and that I was a pioneer in that sense. Yes – I cut off my mullet when they were still “in.”


posted on Sunday, August 10, 2003 4:35:14 PM (Mountain Standard Time, UTC-07:00)  #    Comments [2] Trackback