| Subcribe via RSS

Display Single Post on Home Page in WordPress

December 11th, 2011 | Comments Off | Posted in PHP, WordPress

Most themes have some sort of post roll that lists out the most recent posts on the home page. In most cases this is the ideal way to get your readers up to date on your most recent information. Say you had a more traditional website that displays what your company is about on the home page and maybe your recent or most read blog posts are relegated to the sidebar. So how do we display just a single post in that home page body section? Pretty simply it turns out.

Just prior to the php while loop (look at the file located in Appearance > Editor > index.php) set the query_posts method equal to the id of your post. So you’d have something that looks like this.

Error when Opening VS.NET Project Moved to New Folder

September 8th, 2010 | Comments Off | Posted in visual studio

So from time to time, you need to move a Visual Studio project to a new folder to do some new fun things with it — upgrading code, replicating a project or just because. Well when you do this VS.NET doesn’t like you too much because all its references were pointing back to that original folder. In my case, I got hit with errors two fold. The first:

The local IIS URL http://[XXX] specified for Web Project [XXX] has not been configured. In order to open, the directory needs to be configured. Would you like to create a virtual directory now?

Sure Visual Studio. Knock yourself out. You Ok through only to get hit with:

Creation of the virtual directory [XXX] failed with the error: Could not find the server [XXX]. Creating a virtual directory is only supported on the local IIS server.

Couldn’t you have just saved me the extra error message and spit that out to begin with? So our culprit is the .csproj file. Open that up in text pad and scroll to the bottom. Within the WebProjectProperties XML block, there is a UseIIS node. Flip that from true to false. Save it out and you should be good to go.

Err Msg: ‘Could Not Load Type _Default’ & ‘Server Application Unavailable’

February 5th, 2010 | Comments Off | Posted in ASP.NET
I thought I’d lump these two together since they seem to be interrelated. So I’m doing development on a dev box I haven’t worked with in a while. I have a Visual Studio project that works like a champ on my box, but as soon as I load it up to the dev I get the error message ‘Could Not Load Type _Default.’ I was thinking it was a web.config issue so I tried to massage that for a while with no luck. I’d set up the application correctly in IIS so it shouldn’t have any issues accessing the dll in the local bin folder. What I hadn’t counted on was the two versions of the .NET Framework running on this box. This was a 2.0 app I’d developed and my current application was defaulting over to 1.1. Updated this under the application in IIS, and up it came. It didn’t stay up for long though as I surfed through my application and quickly hit a ‘Server Application Unavailable’ error. I threw this project into the 2.0 application pool and everything settled down.

Find All Cookie Values in a Given Application via ASP.Net and c#

January 14th, 2010 | Comments Off | Posted in ASP.NET, C#

Cookies can be especially maddening at times if you don’t know what values are being stored within them. The following simple script is written in csharp and ASP.Net and allows you to see all of the cookies currently hanging around under a given application. Pretty handy when trying to fish yourself out of a problem.

Error Message: Could not find file ‘c:\windows\system32\inetsrv\System.Xml.XmlDocument’.

January 13th, 2010 | Comments Off | Posted in XML

Someday I’ll free myself from the XML hell I seem to be mired in, but that day is not today. So I’ve got a fun new issue. The previous coder stored all the user entry values in session values without thinking about the fact that this won’t run correctly once it goes live in the web farm. So now I have to switch all those values over to be stored in the cookie and a few in the database that need to be secured. So in my haste to switch everything over, I ran across the error message “Could not find file ‘c:\windows\system32\inetsrv\System.Xml.XmlDocument’.” Huh? All I’ve done is try to store the Xml string into a XmlDocument object like so:

After pondering and tinkering with this for the better part of 30 minutes, it finally occured to me. The Load method of XmlDocument is used to access an Xml file on the server whereas the LoadXml method is used to load a previously defined Xml string. Popped that in, and it worked like a charm. Now what is my next error?

Google US Search Listings Versus Google Canada

January 5th, 2010 | Comments Off | Posted in SEO
I was reviewing my traffic logs this afternoon and I noticed a couple of my sites have risen up the ranks to number 3 on their key respective search term on Google — Canada? Hmmm…when I look at the main Google US site the websites in question are ranking 8 and 11. Not bad mind you, but why would Google Canada think so much more highly of these domains than its US counterpart when they are hosted in the US and there is nothing Canada specific about them (they are pretty generic and all country friendly actually)? Google’s search algorithm is the ultimate black box so who knows for sure, but I did run across this interesting article breaking down what could be influencing its decision at NVI Solutions. Check it out.

Navigating to a Sibling Node via XPath

January 4th, 2010 | Comments Off | Posted in XSL

So I’m in an XSLT stylesheet, and I’ve navigated my way down to the node level. Now I’m trying to traverse my way down to the next sibling node and get an attribute out of it. Something like the following:

Not the best XML structure in the world, but what do you do when you have inherited code? After a long time of searching and trying out about 20 different possible iterations, I found the best solution to be:

For a quick translation, we are currently at the question node from the XML sample above, looking to step down into the answer node to get the text value. The second XSLT code block’s select statement tells the routine to get the following sibling node ‘answer’ even more specifically the first answer node following the question node. From there, we just reference the text attribute within the node.

Subtracting Dates in C#

December 16th, 2009 | Comments Off | Posted in C#
I’ve got an exam application that has a fixed time limit and relays the clock winding down to the test taker via an AJAX call. So we know what time it is now (DateTime.Now), we know when we started the exam (set value in session) and we know the time limit of the exam (pulled from the database). How do we bring it all together? We have to figure out our finish time by running the AddMinutes method against our exam beginning DateTime value, adding our predefined number of minutes set in the time limit. Next, we simply subtract our begin time from our finish time, and that leaves us with a TimeSpan value. The only thing remaining is to do something with that TimeSpan value. It has a host of methods for conversion, but we are going to run the TotalMinutes method this go around to get us the countdown value. Maybe not as simple as VB’s datediff, but simple enough.

Get User Name for NT Authentication in C#

December 10th, 2009 | Comments Off | Posted in C#

Lots of systems sit behind an NT Authentication wall to keep the unwanted users out, but does it really do you any good if you don’t know which user made a given update to a system. Also this is good if you want to give a certain user administrative privledges, displaying certain functionality while hiding it from the rest of your users. The easiest way to get at that piece of information is to jump down into the System.Security.Principal.WindowsIdentity class and hit up the GetCurrent().Name method. Note this will pull back the user name preceeded by the domain they are logged onto so to ditch that you’ll just need to clean it up with a Regex statement (ex: Regex.Replace(sNTUser,”DOMAINNAME.”,”"))

Adding Project to Source Control in Visual Studio

December 8th, 2009 | Comments Off | Posted in visual studio
This is probably old hat to most here, but Source Control is still fairly new to me within the context of Visual Studio. Case in point, I was trying to take a local project I had developed on my box and integrate it into a solution already created on the Team Foundation Server. I checked the solution out then I was dead in the water. It seems the key is to right click on the name of your project in the Solution Explorer window then select ‘Add Solution to Source Control.’ Now all you need to do is check in your changes and you are set.