Jun 30 2009

10 Useful, Often Overlooked HTML Tags.

Pop quiz: When would you use the <wbr> tag, and what does it do?

Yeah, I had no idea either. In fact, I had never even seen this tag before, but it’s a list of 10 Rare HTML Tags You Really Should Know from Nettuts+

I have to say that most of these I hadn’t heard of, but they are actually quite useful. Granted, I do most of my work in the .NET code behind and middle ware layers, but I do occasionally get to sling a bit of HTML, and I think I may start using some of these…

Oh, I almost forgot - the <wbr> tag allows you to specify a place where you think a line break might be useful, if needed.

Blog Traffic Exchange Related Posts Blog Traffic Exchange Related Websites
  • Home Network Security [/caption] Home Computer security 1. What is computer security? Computer security is the process of preventing and detecting unauthorized use of your computer. Prevention measures help you to stop unauthorized users (also known as "intruders") from accessing any part of your computer system. Detection helps you to determine whether or......
  • If you'd like to learn more about me, then read on, curious readers, read on! This was the week of the meme's. I was tagged by Weight Ladder to do a 6-word memoir. I had actually completed this meme in the past, but no worries. My "profound" words are still there for all to see. ;) JoLynn at The Fit Shack tagged me with a......
  • How To Choose The Right Keywords Density In Your Title Tag The text in that appears in the title tag is quite important for your search engines ranking. Having your keywords appear here is definitely something you can't afford to miss.Your TITLE tag should be between 50 - 85 characters in length. There is no need to put more than......
  • Take Back America Election Clock The Take Back America Election Clock (seen at right) is inspired by Ray Stevens' hit song We the People. "You vote Obamacare, we're gonna vote you outta there" goes the song. Who are they? To help all of us remember who voted for Obamacare the NIP has developed the Countdown......
  • Meta Tags - An Introduction A long, long time ago In a galaxy far, far awaymeta tags were the key component to search engine rankings. Okay, it was about 2 years ago, but thats a long time in the Internet galaxy. Although still relevant, the evil empireer, Darth Google, has led a movement by......
Jun 25 2009

Annoying “next message” behavior in Thunderbird, and how to stop it!

I love the Thunderbird email client. I use the portable version on my thumb drive, but one thing has always bugged the hell out of me when I use it: whenever I delete an email that I have opened in a popup window, Thunderbird automatically opens the next message. Most of the quasi-official entries on the forums state that this is the default behavior, and how 90% of email users use the app anyway, so there is no simple check box for disabling the “feature”.

I must be an odd duck then, because it is most certainly not how I use my email client. I distinctly remember disabling the annoying feature in older versions of Outlook Express. Well, I am the type who will not be denied. I go through great pains to get around such roadblocks - out of principle alone!

So I went digging and found many dead ends, and tips & tricks pages that proved to be unrelated. A lot of forums suggest things like adding the delete button to the toolbar, but that only works if you delete it from the main window. I want to read the email first, then delete it. Reading, closing (clicking the “X”) then deleting seems more tedious than necessary.

Then I found this handy add-on. Only one problem: it was for pre 2.0 versions of Thunderbird. The solution: How to hack the add-on to make it work in 2.0+.

Open the install.rdf file, and locate the MaxVersion key:

annoying-next-message-behavior-in-thunderbird_unselect-message-thunderbird-add-on-install_before

Then change the 1.6 to 2.1, like so:

annoying-next-message-behavior-in-thunderbird_unselect-message-thunderbird-add-on-install_after

and voila!

Sweet!

It’s worked great ever since, and I no longer curse Thunderbird. For automatically advancing to the next message, anyway. ;-)

Blog Traffic Exchange Related Posts Blog Traffic Exchange Related Websites
  • Beginner's Woodworking Tips And Tricks Woodworking is one of the most fun crafts around. You master it, and it can be the most rewarding. In this article, I'm going to share with you some woodworking tips and tricks I've accumulated over the years to help a newbie woodworker the common glitches and minor frustrations most......
  • Weight Loss Tips and Tricks When it comes to losing weight, you probably know the drill. Burn more calories than you consume, eat healthy, and be healthy and the results will happen. Most diets and weight loss plans do not have much substance which is why dieting in general is far from healthy for you.......
  • Solaris Tips and Tricks Find a list of Tips and Tricks here.A nice trick to list the process which has opened a particular port is : #!/bin/ksh## 7-30-2003# find from a port the pid that started the port#line='-------------------------------------------------------------------------'pids=`/usr/bin/ps -ef | sed 1d | awk '{print $2}'`# Prompt users or use 1st cmdline argumentif [......
  • What Fish Don’t Want You to Know By Frank P. Baron The practice of fishing has been around for millennia, but we as humans still don’t have it down pat. There are thousands of books out there on techniques, can’t miss hints and basic fishing principles. However, if you read only one book about fishing, this one should be highly considered.......
  • Weight Loss Tips and Blogs Needed I need some help. Any one with any weight loss tips and blogs that can help me shed some extra weight and adjust to my new lifestyle are encouraged to share them. I am looking for tips and tricks that will assist me in losing some extra fat, gain more......
Jun 23 2009

How to fake a TreeNodeCollection subclass in .NET

If you’ve ever had reason to try to extend the standard Microsoft web TreeView control, you will have no doubt noticed that MS was quite unkind to you and sealed (or declared NotInheritable for you VB.NET types) the System.Web.UI.WebControls.TreeNodeCollection class.

The problem arises when you want to overload the default behavior that is implemented by the TreeNodeCollection class. For example, when a node was added to my TreeView class (via the TreeView.Nodes.add method), I needed to be able to analyze it for the ultimate purpose of my subclass.

However, this was not possible because the TreeNodeCollection class is sealed, so I wasn’t able to inherit from it and overload the add method behavior as I should have been able to do.

There are always possibilities.

Anyone who knows me knows I don’t give up easily (if ever), and I eventually plowed through many false starts but hit upon a solution.

I decided to wrap the underlying TreeNodeCollection class with my own, and overload the Nodes property on the TreeView class, and the ChildNodes property on the TreeNode class.

The Wrapper.

Here’s what the wrapper looks like:
[vb language=".net"]

Public Class MyTreeNodeCollection

Private mtvwChildNodes As System.Web.UI.WebControls.TreeNodeCollection
Private mMyTreeViewOwner As IMyNodeContainer

Public Sub New(ByVal Owner As IMyNodeContainer, _
ByVal TreeViewChildren As System.Web.UI.WebControls.TreeNodeCollection)
mtvwChildNodes = TreeViewChildren
mMyTreeViewOwner = Owner
End Sub

Public Sub Add(ByVal child As MyTreeNode)
mtvwChildNodes.Add(CType(child, System.Web.UI.WebControls.TreeNode))
mMyTreeViewOwner.RegisterNodeForLookup(child)
End Sub
End Class
[/vb]

As you can see, the constructor takes the real, underlying TreeNodeCollection to pass all node to prior to being “registered” (analyzed). It also takes something that implements the IMyNodeContainer interface.

The IMyNodeContainer interface.

I had to implement this because I wanted to be able to use this wrapper class for both TreeView and TreeNode objects, but the signature of their properties is different - TreeView.Nodes and TreeNode.ChildNodes, respectively. So I opted for the interface to keep things clean.

Here’s what the interface looks like:

[vb language=".net"]
Public Interface IMyNodeContainer

Sub RegisterNodeForLookup(ByVal node As MyTreeNode)
ReadOnly Property Nodes() As MyTreeNodeCollection

End Interface
[/vb]

Wrapping things up.

This is where the magic happens.

To put the wrapper (MyTreeNodeCollection) in place, I overload the collection getting properties in the base class - TreeView.Nodes and TreeNode.ChildNodes, respectively, like so:

[vb language=".net"]
Public Overloads ReadOnly Property Nodes() As MyTreeNodeCollection Implements IMyNodeContainer.Nodes
Get
Return mNodeCollection
End Get
End Property
[/vb]

So, for those of you playing along at home, when the developer calls .Nodes on an instance of MyTreeView class, an instance of MyTreeNodeCollection is returned and the resulting add method in performed on the underlying TreeNodeCollection, thusly:

[vb language=".net"]
Public Sub Add(ByVal child As MyTreeNode)
mtvwChildNodes.Add(CType(child, System.Web.UI.WebControls.TreeNode))
mMyTreeViewOwner.RegisterNodeForLookup(child)
End Sub
[/vb]

You can see why I had to use the IMyNodeContainer interface here. The RegisterNodeForLookup performs the functionality I was originally trying to subclass the TreeNodeCollection for.

Blog Traffic Exchange Related Posts
Jun 18 2009

Window.scrollTo Fails Under OVERFLOW-Y: auto Style.

I was trying to subclass a Web Treeview control for my own evil purposes and ran into a sticky problem - scrollTo not working! Just for background, my evil purpose was to replace the Infragistics ultra web tree control, since we only use about 5% of the functionality, but pay the full price of upgrades and page size for the other 95%.

anyway, all was going well, until I tried to implement the ScrollTo functionality.

My first pass looked something like this:

[javascript]
<Script Type="text/javascript">
<!–
var ele = document.getElementById(nodeID);
window.scrollTo(ele.parentElement.offsetParent.offsetLeft ,ele.parentElement.offsetParent.offsetTop);
//–>
</Script>
[/javascript]

Now this worked great in my sample text page, but when I dropped it into the main application page, it didn’t do a damn thing. What gives?

Well, I traced the problem down to a style tag on the wrapping div tag:

[css]
OVERFLOW-Y: auto;
[/css]

It seems that the auto setting disallowed my scrolling to a specific x,y coordinate when that coordinate was outside the visible space.

That really stunk because I didn’t have the ability to modify the existing container page, beyond replacing the Infragistics control tag.

Luckily, I found a workaround:

[javascript]
<Script Type="text/javascript">
<!–
var ele = document.getElementById(nodeID);
ele.scrollIntoView();
//–>
</Script>
[/javascript]

Not only does this work within the CSS overflow directive, but it’s also a bit more elegant since I no longer have to worry about all that parent offset nonsense. :)

Blog Traffic Exchange Related Posts Blog Traffic Exchange Related Websites
  • Role of On Page Optimization in SEO What's Search Engine Optimization? Search Engine Optimization is the method of enhancing the visibility of a web site on search engine listings. It refers to an inventory of promoting tools required to arrange a web site in order to extend its rankings in the context of the result of pages......
  • Optimizing Title Tags For Success Properly optimizing the title tag (or more appropriately, the HTML title element) of a web page can yield big benefits from a search engine optimization (SEO) perspective. The following document explains why titles are so important and provides useful tips on how to optimize a title tag.Title tags are......
  • Optimizing Title Tags For Success Properly optimizing the title tag (or more appropriately, the HTML title element) of a web page can yield big benefits from a search engine optimization (SEO) perspective. The following document explains why titles are so important and provides useful tips on how to optimize a title tag.Title tags are......
  • How To Avoid The 3 Biggest Title Tag Mistakes With Search Engines Your title tag is the most important 3 to 12 words on your Web page. It accounts for up to 80% of your rankings on search engines.Here's why:Search Engines look for "searched for" words first in title tags.The title tag is one of the main places search engines look......
  • Website Optimization For Newbies - 3 Important Tips For Keyword Placement in Your Website Website optimization requires placing your main keywords in specific places on your web pages. After you have performed a keyword search and chosen the specific keywords that you want the search engines to recognize, you should place one or more of these keywords on each web page. But don't......
Jun 16 2009

IE7 WebControl TreeView line gap in quirks mode.

I’ve been writing a subclass of the MS Webcontrol.TreeView control for one of our Web Applications at work. I figured this would be a fairly easy task, since I only needed to extended it with a few properties. It turns out that I was caught on a nit-picky annoyance in the TreeView control itself.

The TreeView control renders verticals lines with gaps.

Here’s a screen cap of the problem.

ie7-webcontrol-treeview-line-gap-in-quirks-mode_treeview-line-break

As you can see, the TreeView control renders the vertical line with a gap, or break (looks like a dashed line!). It didn’t matter how I loaded the data - dynamic/runtime/design time - I get the same gap no matter what!

I was able to see that it was not a problem in IE 6 or less, but what good is that? Well, it turns out that it was a bit of a clue because starting with version 5, IE didn’t render things correctly per the CSS boxing specification. This was fixed in IE 7, but to provide backwards compatibility, Microsoft carried this busted form of rendering forward in IE 6 as QuirksMode. The line gap problem only occurs in strict mode (default for IE 7 and 8, as well as firefox). I could make the line gap go away by forcing the browser into QuirksMode (by adding a comment, ex:

< ! - - QUIRK! - - >

to the very top of the HTML file), but I was writing a web control and would not always have the luxury of controlling my container.

I needed to find a long term solution to this problem.

Next, I looked at the HTML source of the rendered page, and saw this:

[html]
<table cellpadding="0" cellspacing="0" style="border-width:0;">
<tr>
<td>
<div style="width:20px;height:1px">
<img src="/TreeviewControlTest/WebResource.axd?d=OYmDnVppVECKIpxOWC8o8Y7DO6QwB2J3EY4s4RR8zAU1&amp;t=633765128008804061" alt="">
</div>
</td>
<td>
<img src="/TreeviewControlTest/WebResource.axd?d=OYmDnVppVECKIpxOWC8o8UGy0bLoCc8gOB1oQm6Pzj81&amp;t=633765128008804061" alt="">
</td>
<td class="TreeView1_WebTree_1" style="white-space:nowrap;">
<a class="TreeView1_WebTree_0" href="javascript:__doPostBack(’TreeView1$WebTree’,'Root//Tree’)" onclick="TreeView_SelectNode(TreeView1_WebTree_Data, this,’TreeView1_WebTreet6′);" id="TreeView1_WebTreet6" name="TreeView1_WebTreet6">Tree</a>
</td>
</tr>
</table>
[/html]

Each node is rendered as a table, with the vertical line and expand/collapse icons being in their own table cell and wrapped in a div. The problem was the style applied to the outer div - style=”width:20px;height:1px“.

That 1px height was causing the vertical line image to be compressed, but where did it come from?

Reflecting on System.Web.UI.WebControls.TreeNode

I spent almost an hour delving into the various (and copious!) style properties for the tree and its nodes, looking for where this height setting was generating from. I couldn’t find it! I eventually opened the System.Web.UI.WebControls.dll in Reflector to see what the render code for the node was doing:

ie7-webcontrol-treeview-line-gap-in-quirks-mode_treeview-reflector

Well, once I saw that the code was hard-wired to render this CSS style, I was done. Or was I?

!important

Well, it wasn’t going to be as easy as setting the style in the code behind, but I could override the style in my own class.

The trick is to define, and apply the following CSS class:

[css]
<style type="text/css">
.MyTreeView TD Div
{
height: 20px!important;
}
</style>
[/css]

The !important CSS directive overrides the style applied in the System.Web.UI.WebControls.TreeNode render method.

ie7-webcontrol-treeview-line-gap-in-quirks-mode_treeview-no-line-break

Again, just as with the QuirksMode comment above, I was able to add the CSS style to the page and voila - problem solved. But this still wasn’t good enough. I needed this to work out of the box for any consumers of my control.

The ultimate answer was to override the RenderBeginTag of the TreeView control, and render this style before the control itself:

[vb language=".net"]

Public Overrides Sub RenderBeginTag(ByVal writer As System.Web.UI.HtmlTextWriter)
‘/////////////////////////////////////////////////////////////////////////////////////////
‘/// This is a total hack to get around some Microsoft BS which hardwires
‘/// a style attribute on the node div to set the height = 1px!
‘///
‘/// This renders a css override to force the div to the proper height
‘/////////
Me.CssClass = String.Concat(Me.CssClass, " MyTreeView")
writer.WriteBeginTag(HtmlTextWriterTag.Style.ToString)
writer.WriteAttribute(HtmlTextWriterAttribute.Type.ToString, "text/css")
writer.WriteLine(HtmlTextWriter.TagRightChar)
writer.Write(".MyTreeView TD Div ")
writer.WriteLine("{ height: 20px!important; }")
writer.WriteEndTag(HtmlTextWriterTag.Style.ToString)
writer.WriteLine()
‘//////////////////////////////////////////////////

‘/// Render the Standard Begin Tag
MyBase.RenderBeginTag(writer)
End Sub
[/vb]

Blog Traffic Exchange Related Posts Blog Traffic Exchange Related Websites
  • Create your web page with NetBeans - Part 3 In this part we will look into PHP basics PHP is a widely used open source, general-purpose scripting language. It was originally designed for use in Web site development.  PHP proved so useful and popular, it rapidly grew to become the full-featured language that it is today, acquiring the name......
  • Engaging Pointers For Creating Excellent Website Development Titles And Headlines If you look at people when they are browsing magazines in the store, when they find one they are interested in, they usually only look for specific articles and put it back if they don't find what they want. They look for headlines and titles that catch their eye. This......
  • Musical Instruments: Drums for Sale The unique thing about drums when it comes to making music is that there are so many different elements that change the sound you create when you play them. The size, shape and composition of the drum will all alter the sound that it creates. Whether you beat on the......
  • Visual Quickstart Guide - HTML, XHTML & CSS 6th Edition I recently bought the book Visual Quickstart Guide - HTML, XHTML & CSS 6th Edition to refresh my knowledge on Web creation and to serve as a handy reference for me. I know that there are a lot of free XHTML + CSS tutorials online but nothing beats a......
  • Web Marketing Business Solutions For Small Business | Online Marketing Consultant Web MarketingLooking for ways to give your business a marketing boost? If so, do you own an on-line presence as part of your promotions formula? The World Wide Web is now the first selection for individuals researching products and services they are thinking buying.The web has now assumed dominance the......
Jun 11 2009

How to find what’s running under SVCHost.exe

My PC was behaving sluggishly the other day. I tried to be patient, but had to fire up the task manager when I could bear it no longer. That’s when I noticed great gobs of my swap file allocated to “SVCHOST.EXE”:

whats-running-under-svchost_exe_tasklist-ss

The problem is, SVCHOST is a catch all windows service container. Meaning, many windows services run under the same instance of SVCHOST. How was I going to figure out which services might be the culprit?

Enter the tasklist command.

Tasklist displays info about running tasks, including SVCHOST.

Simply running tasklist at the command prompt displays a laundry list of all running processes. This wasn’t going to do it, so I ran it with the “/?” switch to try and find how to narrow the info…

/SVC Displays services hosted in each process.
/FI filter Displays a set of tasks that match a given criteria specified by the filter.

Looks good so far, now I need to know what filter to apply:

Filters:
    Filter Name     Valid Operators           Valid Value(s)
    -----------     ---------------           --------------------------
    IMAGENAME       eq, ne                    Image name

OK, this gives us:

“C:\>tasklist /svc /FI “IMAGENAME EQ SCVHOST.EXE”

But it seems the filter is case sensitive, because when I run that command, I get this:

INFO: No tasks are running which match the specified criteria.

So, switching to lower case gives me what I want:

“C:\>tasklist /svc /FI “IMAGENAME EQ svchost.exe”

Image Name     PID        Services
=========== =====  =======================
svchost.exe     744        DcomLaunch
svchost.exe     844        RpcSs
svchost.exe     888        AeLookupSvc, AppMgmt,
                                    AudioSrv, BITS, Browser,
                                    CryptSvc, dmserver,
                                    EventSystem,lanmanserver,
                                    lanmanworkstation, Netman,
                                    Nla, RasMan, Schedule,
                                    seclogon, SENS,ShellHWDetection,
                                    Themes, winmgmt, wuauserv
svchost.exe     928         Dhcp, Dnscache
svchost.exe     976         LmHosts, W32Time
svchost.exe     1772       Net Driver HPZ12
svchost.exe     1816       Pml Driver HPZ12
svchost.exe     2424       TermService
svchost.exe     3312       TapiSrv
svchost.exe     2688       W3SVC

From there, it’s just a matter of shutting down or restarting each of the services listed under the process id 888 ( I got this from taskmanager).

Blog Traffic Exchange Related Posts Blog Traffic Exchange Related Websites
  • Top 10 - SEO Do's & Don'ts SEO Do's Create a Useful, Content-Rich Website Properly Optimize Your Website Pages Have Relevant Websites Link to Your Website Analyze and Understand Your Website Statistics Revise Optimization Based on Feedback Create a Long-Term Content Strategy or Plan Do Learn Patience, Search Engine Success Takes Time Understand What Will and Will......
  • Maintenance for your Swimming Pool On a humid and hot day in August, there is nothing that feels quite as good as a dip in your pool. If your pool is looking a little bit more like a pond than a place for swimming, then nobody is going to be happy. Here are some tips......
  • SVCHOST.exe - What is it and why are there so many of them? I get asked this a lot.  When you run Task Manager in XP and look at the process list, you see tons of svchost.exe processes running.  You can't kill them (you don't really want to) and there's no obvious reason that there are so many of them. What are they? ......
  • The Movers Will Help You To Relocate The relocation has always been a hard chaotic task which would be worse if you do not have enough time for it. The tedious work of packing your precious goods and making sure that they are carefully moved would become a head pain for everyone. In addition, if you should......
  • Tennis Scoring A game of tennis starts with the service and ends when a player has scored 4 points, as long as they are also 2 points ahead of their opponent. Games are generally part of a set, which is a series of games played until one player has reached six wins,......
Jun 09 2009

Arraylist and generics don’t mix with IEnumerable(Of T).GetEnumerator.

The other day I was writing an in-house tool to assist in some upgrades we were performing on client installations. This tool was supposed to perform its operations on a batch of items, and display the results upon completion.

Since processing this batch of items was a lengthy endeavor, I wanted the failure to process one of the items to simply be recorded and allow the processing of the others to continue. Part of the processing of each item was a call to multiple web services, so I would need a way to handle the collection of errors along the way and make them available for their eventual display.

I had what I thought was a clever idea: a private Arraylist of exceptions that occurred during processing.

[vbnet]
Public Class BatchExceptions
Implements ICollection(Of System.Exception)

Private mExceptionlist As ArrayList
.
.
.
End Class
[/vbnet]

That way, I could simply iterate over the list and perform the standard exception handling, like so:

[vbnet]
Dim exc As Exception
For Each exc In BatchExceptions
HandleError(exc)
Next
[/vbnet]

Of course, in order to make use of the “For Each” construct, I had to implement the GetEnumerator of the ICollection interface.

[vbnet]
Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of System.Exception) _
Implements System.Collections.Generic.IEnumerable(Of System.Exception).GetEnumerator
Return (mExceptionlist.GetEnumerator)
End Function
[/vbnet]

Cool. Only one problem:

arraylist-and-generics-dont-mix-when-enumerating-generics_generics-enumerator

That was OK though, because I was using generics after all. The compiler was being helpful and reminding me that I had to specify ‘IEnumerator(Of Exception)’:

arraylist-and-generics-dont-mix-when-enumerating-generics_generics-enumerator2

[vbnet]
Public Function GetEnumerator() As System.Collections.Generic.IEnumerator(Of System.Exception) _
Implements System.Collections.Generic.IEnumerable(Of System.Exception).GetEnumerator
Return (DirectCast(mExceptionlist.GetEnumerator, IEnumerator(Of Exception)))
End Function
[/vbnet]

Everything compiled fine, but at run-time I got the following RTE:

Unable to cast object of type ‘ArrayListEnumeratorSimple’ to type ‘System.Collections.Generic.IEnumerator`1[System.Exception]‘.

arraylist-and-generics-dont-mix-when-enumerating-generics_generics-enumerator-rte

This was frustrating. It seemed like the compiler failed to warn me of this incompatibility, and simply kicked the can on down the road to the run-time to deal with.

Solution:

Well, I did a little poking around and finally ended up replacing my Arraylist with a list like so:

[vbnet]
private mExceptionlist as System.Collections.Generic.list
[/vbnet]

Well, that did the trick but I can’t say it was as intuitive as it would seem. It makes sense, in hindsight, but why did I have to get some cryptic RTE? Why couldn’t the compiler have picked up on my use of an ArrayList and say, “Hey dummy - use a generic list!”? Still, I have a new trick to toss in my bag for the time I want to implement an enumerator on an Arraylist!

Blog Traffic Exchange Related Posts Blog Traffic Exchange Related Websites
  • Opening my mind to money Tread pointed out something that's going on over at Millionaire Mommy Next Door. MMND said: "For the next 30 days, I'll open my mind to receive increasingly more money. On day one, I'll decide how I'd like to spend $100. On day two, I'll double that amount to $200. Day......
  • How Would You Like To Develop Into A Part Time Professional Internet Marketer? A problem that most Net marketers face is that they're focussed on it half time while holding onto a full time regular job. This is alright and usually necessary in the first stages. If you want to become an professional Internet marketer, but, you may want to manage your time......
  • MonaVie and Inc. Magazine's 500 A lot of MonaVie distributors seem to tout the fact that Inc. magazine named MonaVie it's #1 choice in Food and Beverage and 18th overall. A few things should be noted about this list: It's a list of privately held companies - You won't see Coca-Cola, Pepsi, ConAgra foods or......
  • Explaining the ‘Mental’ Side of Weight-Loss This is a guest article written by Dr. Michael A. Snyder, MD, FACS, creator of FullBar. The major barrier to weight loss is accepting the need to change your diet, behaviors, AND relationship with food. These changes require a commitment. And, all of us know that commitments are very difficult!!......
  • Telesis on Processing From a webpage that doesn't 'exist' anymore... Telesis Telesis is the purposeful use of natural and social forces. It is planned progress. Magickal activism. Power does not reside in church or state, but in the manipulation of words, images, and symbols. The power of reality engineering. In the past, church......
Jun 04 2009

How to Delete Empty Folders - FREE!

While performing a disk cleanup recently, I had cause to locate and delete any empty folders under a root folder. I knew there had to be a batch file command to accomplish this, but I couldn’t for the life of me remember what it was!

Enter Google.

five minutes of some keyword searching with surgical precision and piecing together commands yielded my solution.

DIR /AD/B/S | SORT > FOLDERLIST.BAT

How It Works.

The Dir command is the familiar directory list command that comes standard with all versions of Windows since 95. The magic is in the switches:

/A Displays files with specified attributes.
When applied to the “D” attribute, it returns directories
/B Uses bare format (no heading information or summary).
/S Displays files in specified directory and all subdirectories.

SORT is an often overlooked command for, you guessed it, sorting. Here, the results of the Dir command are piped (”|”) into the SORT command as input. The result of the SORT command is then redirected from the command prompt to a file called FOLDERLIST.BAT.

Kick it up a notch.

Now that you’ve created this list, say you want to automate the deletion of each entry in the list. This is where pumping the output to a “.bat” file comes in. Open the bat file in textpad, or notepad, or your text editor

For example:

Typing:
DIR /AD/B/S | SORT > FOLDERLIST.BAT

in my C:\Program Files\Microsoft Visual Studio 8\VC folder yields the following results:

empty-file-results

Next, open the file in a text editor, word, or open office and replace the beginning of each line with the RD command followed by a space and a single quote. Like so:

empty-file-replace

This should give you the following:

empty-file-first-replace

Notice how each line now begins with “RD “” This is the old DOS Remove Directory command. Don’t worry, it only removes empty directories. But you still need to add an ending quote to each line. This is where Word or Open Office is handy. You can do another search and replace, but this time search for “^p” (new paragraph) and replace with ““^p” (end quote and new paragraph).

Save the file, and you’re all done except the double clicking.

Blog Traffic Exchange Related Posts Blog Traffic Exchange Related Websites
  • Wordpress Backup Wordpress Backup is an essential plugin for all Wordpress blog administrators by the Blog Traffic Exchange. It performs regular backups of your upload (images) current theme, and plugin directories. Backup files are available for download and optionally emailed to a specified email. Don't get caught without a recent backup of......
  • Solaris one liners http://www.unixguide.net/sun/sunoneliners.shtml Unix/Solaris: One-Liners Source: http://www.kevlo.com/~ebs/unix_commands.txt Listed here are a bunch of unix commands. --> change file date stamp touch –t 199906042020 filename --> move partitions ufsdump 0f - /dev/rdsk/c0t0s0s0 | (cd /home; ufsrestore xv -) --> lay down file system with 1% minfree and inode density newfs –m1 –i81920 /dev/rdsk/c0t0d0s0......
  • Anti Aging Makeup Tricks and Tips pt 1 There are all kinds of makeup tricks and tips out there, but choosing the right ones for your own personal needs is something that you need to figure out. Here are some unique makeup tricks and tips that are anti-aging in nature. What I meant to say is that there......
  • Anti Aging Makeup Tricks and Tips pt 2 There are makeup tricks and tips that you can apply to melt away the years and start feeling and looking young and beautiful again. Here are some of my favorite makeup tricks and tips for just that purpose. Rosy Lip Hues Rosy lip hue is perfect because it gives you......
  • Useless use of cat awards Here you will find some useless use of cat command in linux. Really interesting and quite informative. Useless Use of Cat Award If you've been reading comp.unix.shell or any of the related groups (comp.unix.questions inter alia) for any amount of time, this should be a familiar topic. I made this......
Jun 02 2009

Microsoft FxCop doesn’t like Microsoft generated code!

The other day I thought it might be nice to “do the right thing” and give my code a run against Microsoft’s FxCop.

I ran it right out of the box - I didn’t bother making my own rules or changing the defaults. I was bored. Anyway, here’s one of the results that actually made be chuckle once I read it carefully:

Warning, Certainty 90, for DoNotInitializeUnnecessarily
{

Target : #.ctor() (IntrospectionTargetMember)
Location : <735>> (String)
Resolution : “‘MyDocument.New()’ initializes field ‘MyDocument.disposedValue’
of type ‘Boolean’ to false. Remove this initialization
because it will be done automatically by the runtime.”

Help : (String)
Category : Microsoft.Performance (String)
CheckId : CA1805 (String)
RuleFile : Performance Rules (String)
Info : “Do not make initializations that have already been
done by the runtime.”
Created : 3/6/2009 6:58:21 PM (DateTime)
LastSeen : 3/6/2009 8:36:25 PM (DateTime)
Status : Active (MessageStatus)
Fix Category : NonBreaking (FixCategories)

}

The reason for the chuckle was that the code which triggered this violation of the rule was written by the Microsoft IDE! My role in this infraction was really quite simple: I typed “Implements IDisposable” and hit Enter. The IDE was “nice” enough to plugin the rest for me:

[vb language=".net"]

‘ To detect redundant calls
Private disposedValue As Boolean = False

‘ IDisposable
Protected Overridable Sub Dispose(ByVal disposing As Boolean)
If Not Me.disposedValue Then
If disposing Then
Array.Clear(mDocumentContent, 0, mDocumentContent.Length)
End If
End If
Me.disposedValue = True
End Sub
[/vb]

It’s bad enough that the IDE writes code for me without prompting, but maybe the FxCop team should talk to the IDE team to avoid such embarrassing nuisances (I had dozens of similar warnings to weed through) in the future.

According to the Code Analysis Team, this is the new default for FxCop 1.36.

Here’s how to avoid it:

Using an FxCop project:

  1. Open your FxCop project in FxCop
  2. Choose Project -> Options -> Spelling & Analysis
  3. Check Suppress analysis results against generated code
  4. Click OK

OR, if you prefer the command-line:

  1. Pass the /ignoregeneratedcode switch, for example:

FxCopCmd.exe /file:MyAssembly.dll /out:AnalysisResults.xml /ignoregeneratedcode

Blog Traffic Exchange Related Posts Blog Traffic Exchange Related Websites
  • Generate PDF from HTML with C# in ASP.NET PDF Duo .Net is a converting component for use in ASP.NET (VB, C# etc.) and enables toconvert HTML to PDF. The main class HtmlToPdf provides several methods and properties to enable multi-purpose customization of the resulting PDF. Main functions allow to convert HTML represented as a File, Page from Url......
  • Development and remote installation of Java service for the Android Devices Written by: Igor Darkov, Software Developer of Device Team, Apriorit Inc. In this article I’ve described: How to develop simple Java service for the Android Devices; How to communicate with a service from the other processes and a remote PC; How to install and start the service remotely from the......
  • Establishing Remodel Cost: Home Remodeling Critical First Step Nothing ruins a fantastic remodel more quickly than exceeding the project budget.  Why is this phenomenon so common in residential remodeling?  Simple:  Many homeowners struggle to establish a detailed budget at the appropriate time in the course of the project. Why is establishing remodel cost one of your most important......
  • The Complete Home Improvement Perspective There are lots of people these days that consider themselves good handy people.  These people are fond of bragging about their complete home improvement skills and all of the projects they have managed to put together.  If you are listening to some of these people, you may just be tempted......
  • Learn Java Easily With an IDE An IDE (Integrated Development Environment) is used in software industry in order to help programmers to reduce the time it takes to write code. There are many Java IDE's available that are used professionally and is a great tool for Java programmers. But IDE's are not there to help only......