Navigation

Search

Categories

On this page

Isn't Linux supposed to be free?
Utterly Destroy #regions
LoaderLock Was Detected
What Was That Format String Again You Know The One For The GUID Where You Only Output The Guid But With No Formatting
Making blank files of a certain size
Read the Syntax carefully
Array.FindAll Anonymous Delegate Syntax
Converting a DMG to ISO in Mac OSX
C# XML Documentation Bug for Visual Studio 2005

Archive

Blogroll

Disclaimer
The opinions expressed herein are my own personal opinions and do not represent my employer's view in anyway.

RSS 2.0 | Atom 1.0 | CDF

Send mail to the author(s) E-mail

Total Posts: 110
This Year: 11
This Month: 0
This Week: 0
Comments: 11

Sign In
Pick a theme:

 Thursday, September 11, 2008
Thursday, September 11, 2008 4:12:28 PM (Mountain Standard Time, UTC-07:00) ( )
I'm trying to install a RAID Card into a Linux file-server so we can amp up the storage.
Unfortunately it's running an older distro of Red Hat Enterprise Linux (3) uname -r = 2.4.21-47.0.1.EL in case anyone cares.

In order to do that, I need to compile a driver. Not so difficult. The hardware manufacturer created a really nice readme.txt file that I'm pretty sure I can follow.

- For Linux kernel 2.4 -
    
     You need a full kernel source tree to build the driver. If you are building
     a driver for the currently in-use kernel, the kernel source should match
     the version of the running kernel. In addition, you must obtain the config
     file for the running kernel:
No problem - lets go grab this from a RPM. Think again buddy -

"This system may not be updated until it is associated with a channel."

Wow - That's kind of a nasty cryptic message. What does it mean though?
https://rhn.redhat.com/rhn/help/release-notes/hosted/rhn-release-notes-2.8.0.jsp

Now when using up2date to register a system, customers will be presented with a message stating "This system may not be updated until it is associated with a channel" rather than an error. The system will be registered with RHN but will be unable to benefit from its service.
Let me spell that out for you dear reader. The myth of open source software isn't a myth. You can give away software for free. The bug fixes, and ongoing support... that will cost you.

I think I'm going to stick with an operating system that allows you to pay up front for the patches of your system for the supported lifetime.

 Friday, September 05, 2008
Friday, September 05, 2008 9:22:12 AM (Mountain Standard Time, UTC-07:00) ( )

I use C# on a daily basis to do most of my coding.

I really don't like #region directives. It's not just a love-hate thing. I really hate it. I have a compulsive need to eliminate them. It's extra fluff that really doesn't need to be in the in the code to make the code any more meaningful. It doesn't add any value to the executable bits.

Using Find/Replace always gets tedius. Why not just remove all instances of it throughout the solution in one action?

Imports System
Imports EnvDTE
Imports EnvDTE80
Imports EnvDTE90
Imports System.Diagnostics

Public Module CodeHelper

    Public Sub RemoveRegions()
        RemoveThisRegexFromSolution("\#region.+")
        RemoveThisRegexFromSolution("\#endregion")
    End Sub

    Public Sub RemoveThisRegexFromSolution(ByVal findRegex As String)

        DTE.Windows.Item(Constants.vsWindowKindFindReplace).Activate() 'Find and Replace
        DTE.Find.FindWhat = findRegex
        DTE.Find.ReplaceWith = ""
        DTE.Find.Target = vsFindTarget.vsFindTargetFiles
        DTE.Find.MatchCase = False
        DTE.Find.MatchWholeWord = False
        DTE.Find.MatchInHiddenText = True
        DTE.Find.PatternSyntax = vsFindPatternSyntax.vsFindPatternSyntaxRegExpr
        DTE.Find.SearchPath = "Entire Solution"
        DTE.Find.SearchSubfolders = True
        DTE.Find.KeepModifiedDocumentsOpen = False
        DTE.Find.FilesOfType = "*.*"
        DTE.Find.ResultsLocation = vsFindResultsLocation.vsFindResults1
        DTE.Find.Action = vsFindAction.vsFindActionReplaceAll

        DTE.Find.Execute() ' Do it

        DTE.Windows.Item(Constants.vsWindowKindFindReplace).Close() ' Close the box

    End Sub

End Module

 Friday, August 22, 2008
Friday, August 22, 2008 9:01:07 AM (Mountain Standard Time, UTC-07:00) ( )

I encountered this while debugging some Managed DirectX code.

1) Open Debug Menu and select Exceptions.
2) Selected Managed Debugging Assistants and find LoaderLock
3) Remove the selected value from the Thrown column

 Tuesday, April 22, 2008
Tuesday, April 22, 2008 9:03:45 AM (Mountain Standard Time, UTC-07:00) ( )

What was that format string again? You know, the one for the GUID where you only output the guid, but with no formatting?

using System;
public class GuidTest
{
    public static void Main()
    {
        string[] guidFormats = {"N", "D", "B", "P"};
        Guid g = new Guid();
        Array.ForEach(guidFormats, delegate(string t)
        {
            Console.WriteLine("{0}:{1}", t, g.ToString(t));
        });
        Console.ReadLine();
    }
}

N:00000000000000000000000000000000
D:00000000-0000-0000-0000-000000000000
B:{00000000-0000-0000-0000-000000000000}
P:(00000000-0000-0000-0000-000000000000)

That's right. Now I remember.

 Monday, April 21, 2008
Monday, April 21, 2008 9:36:55 AM (Mountain Standard Time, UTC-07:00) ( )

Sometimes you just need a file with nothing particular in it so you can test a web-page with a <input type="file"/>

Rather than write a snippet of code, or use a utility, you can use the operating system to do this.

On WindowsXP, you can use FSUTIL to do this.

FSUTIL FILE CREATENEWFILE <path> <sizeInBytes>

FSUTIL FILE CREATENEWFILE C:\20mbfile.txt 20971520

 Friday, April 04, 2008
Friday, April 04, 2008 10:46:55 AM (Mountain Standard Time, UTC-07:00) ( )

It's every so important to read the syntax carefully in computer science. Missing the specifics will get you every time.

Compare these two statements.

DECLARE @sql VARCHAR(8000)
SET @sql = 'SELECT CustomerID FROM Customers'
EXEC @sql

to this

DECLARE @sql VARCHAR(8000)
SET @sql = 'SELECT CustomerID FROM Customers'
EXEC(@sql)

I'm sure you've caught it by now. It's the parenthesis.

Syntax

Execute a stored procedure:

[ [ EXEC [ UTE ] ]
    {
        [ @return_status = ]
            { procedure_name [ ;number ] | @procedure_name_var
    }
    [ [ @parameter = ] { value | @variable [ OUTPUT ] | [ DEFAULT ] ]
        [ ,...n ]
[ WITH RECOMPILE ]

Execute a character string:

EXEC [ UTE ] ( { @string_variable | [ N ] 'tsql_string' } [ + ...n ] )

It's even in bold in the documentation. One would think it might jump out and grab my attention. However sadly, it did not.

Friday, April 04, 2008 8:40:06 AM (Mountain Standard Time, UTC-07:00) ( )

I could not find this easily on the web, so I hope this saves someone a search.

Take the following under consideration

string root = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

// We're interested in details, so we'll work with DirectoryInfo instead of Directory and strings
DirectoryInfo rootDirectory = new DirectoryInfo(root);
DirectoryInfo[] subDirectories = rootDirectory.GetDirectories("*", SearchOption.AllDirectories);

DirectoryInfo[] hiddenDirectories =
Array.FindAll<DirectoryInfo>(subDirectories,
delegate(DirectoryInfo d)
{
return (d.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden;
});

It's wasn't immediately obvious to me how the syntax for Array.FindAll<T> worked. I hope this clears up any confusion in the future.

As a side note. C# 3.0 is the cats meow. This is not 100% equivalent to the above. I think we can all agree we're getting closer to expressing programmers intent.

string start = Environment.GetFolderPath(Environment.SpecialFolder.MyDocuments);

DirectoryInfo root = new DirectoryInfo(start);

var subDirectories = root.GetDirectories("*", SearchOption.AllDirectories).AsQueryable();

var hidden = subDirectories.Where(d => (d.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden);

alternatively in comprehension syntax...

var hidden2 = from d in subDirectories where (d.Attributes & FileAttributes.Hidden) == FileAttributes.Hidden select d;

 Thursday, March 20, 2008
Thursday, March 20, 2008 8:46:46 AM (Mountain Standard Time, UTC-07:00) ( )

Using the Disk Utility application on OSX, it's easy to get an image of a CD as a file on the hard drive.
The unortunate thing is that the image file is going to be a DMG by default.

I wanted to convert this to an ISO, so I could burn the file to media later with software that understood this format.

Conversion is fairly painless. Drop to your console, and use the following.

hdiutil convert /path/to/filename.dmg -format UDTO -o /path/to/savefile.iso

 Friday, March 14, 2008
Friday, March 14, 2008 3:55:39 PM (Mountain Standard Time, UTC-07:00) ( )

I have a love-hate relationship with Visual Studio. I spend most of my computing-work-day in this program, and I really hate when I have to fix the 'quirks' that it gets me with.

Today's bug happened when I was trying to document the use of a custom error page by documenting the section of the web.config that was necessary in the XML comments for the class definition.

I was met with resistance, and finally a crash from visual studio for my efforts. No worries. A quick search, and I'm back in business.

Thanks to the blogosphere, namely this fine guy http://blogs.msdn.com/djpark/archive/2007/11/29/public-hotfix-vs-2005-sp1-unresponsive-when-typing-in-an-xml-doc-comment.aspx, I'm a happy camper.

FIX: Visual Studio 2005 stops responding when you type "<" or ">" in the " <![CDATA[]]>" tag if you enable XML documentation for a project http://support.microsoft.com/kb/940201/en-us

It's nice when there's a patch for things, before you need them. I could say it would be nice if you didn't need them at all, but lets face it. I write worse code than the VS folks.

Thanks for the patch guys, keep rocking the code.