Browsing the archives for the Software category.


HOWTO: Determine If A String Value Is A Full Path In PowerShell

Software

Quite often, you’ll have a string value and want to know if you are dealing with just a filename or a fully qualified path.  i.e.

web.config

vs.

c:\myproject\mysolution\myweb\web.config

If it’s just the filename, you’ll usually want to prepend some directory, such as $pwd or $myinvocation.mycommand.path, so that you end with a fully qualified path.

How, in PowerShell, do you easily determine which you’re dealing with?

I’m not going to tell you.  The reason is that you don’t need to.  PowerShell provides a neat little cmdlet called Resolve-Path which does path resolution for you:

[string]$partial = “web.config”

[string]$full = “c:\myproject\mysolution\myweb\web.config”

Resolve-Path $partial

Resolve-Path $full

Output:

Path
----
c:\myproject\mysolution\myweb\web.build


Path
----
c:\myproject\mysolution\myweb\web.build

No Comments

SQL Server’s LEN and DATALENGTH functions, compared

Software

Interesting little tidbit about the LEN() and DATALENGTH() functions in SQL Server.  Check this out:

select len(’foo’)
select datalength(’foo’)

———–
3

(1 row(s) affected)

———–
3

(1 row(s) affected)

 

select len(’ foo ‘)
select datalength(’ foo ‘)

———–
4

(1 row(s) affected)

———–
5

(1 row(s) affected)

What’s going on here?   According to the documentation for the LEN() function, it specifically removes trailing blanks.  Why?  Why only trailing blanks?  Zlatko Michailov suggests that

It must have appeared as a remedy for fixed-length character strings – char and nchar. Since those are always padded with blank spaces to fill up the entire slot, LEN()over values of those types would always return the size of the type, regardless of the value.

Anyway, don’t let this oddball behavior get you too.

2 Comments

How Many Joins Is Too Many? Answer: “If You Have To Ask…”

Software

I saw this when I was inspecting some MySQL server settings:

image

That setting for sql_max_join_size is great.  Let’s put some commas in to help us understand that number:

18,446,744,073,709,551,615

That’s 18 quintillion (and change).

That’s only a couple of orders of magnitude less than the number of stars in the universe.  That’s over twice the max size of a signed 64-bit integer, which is:

9,223,372,036,854,775,807

So my question is, who is joining that many tables?  And why?  Is it the Data Warehouse Project To End All Data Warehouse Projects?  Requirements:

  1. Take all the data in the known universe
  2. Cross-reference each piece of data against every other piece of data
  3. Start listing epiphanies

Hm.  It’s a mystery.

2 Comments

PowerShell 2.0 “More” command in the ISE

Software

Back in the good old days of the DOS command prompt, you frequently wanted to break up a large chunk of results into pages, that you could scroll through using the spacebar.

For example:

help | more

Would show one page of help information at a time.

Does PowerShell 2.0 support the “more” command? Well, it depends.  It depends on if you’re using the “standard” PowerShell.exe command prompt, or the PowerShell_ISE.exe (Integrated Scripting Environment).  The behavior is different depending on which tool you use.

I use the ISE quite a bit.  It’s not a perfect editor – far from it – but I like the ability to have files open and to be able to interactively run parts of scripts via the F8 “run selection” option.

However, in PowerShell ISE, all of the “more” business goes away.  PowerShell ISE doesn’t do a good job of interactively working with results.

So, for example, in PowerShell ISE, if you type:

mysql –? | more

… you won’t get any paging.  Everything will just spit out to the end.

PowerShell has a cmdlet called Out-Host with a –Paging parameter, which theoretically should give us something, but in my tests it just hangs the ISE IDE.  Even the example given in Get-Help Out-Host:

get-process | out-host –paging

Returns with the error:

image

out-lineoutput : The method or operation is not implemented.

So, moral: if you want to do interactive stuff with PowerShell, such as FTP, MySQL, or pipe to “more” to page results, use the standard PowerShell 2.0 command prompt, and stay away from the ISE. For now.

1 Comment

log4net Silent Failures Make Me Yell

Software

log4net is driving me crazy, and doing so in a souped-up Ferrari in 5th gear.  Admittedly, it’s a short distance from “where I am now” to “crazy”, but I don’t want some idiotic software program to push me over the line.

The latest travesty came yesterday, when I spent way too much time diagnosing why log4net wasn’t outputting anything to the log(s).  Not only that, but there were no Event Viewer entries.  So I tried dinking around with the usual culprits – verifying paths, permissions, triple-checking the log4net.config file entries against known-good examples, yadda yadda yadda.

Finally I realized that my build process was not pulling over .asax files to the deploy directory.  You might remember .asax as the file in ASP.NET projects that is tied to with the Global application code-behind class.  My build process (MSBuild-based, very cool, customizations up the yang) has a whitelist of acceptable file extensions to pull over, and .asax was missing.

So I added it.  And the goddamned log4net system started spitting out log messages.  FUCK!

<flame><on>

OK, first of all, if you’re so goddamned powerful, Mr. log4net, why do you whimper and shy away in the presence of a client app that is sending log messages to a logger / repository that doesn’t exist or isn’t configured?  I mean, are you Clark Kent or Superman?

Second: who designs an app to give NO FEEDBACK – zero, zilch, nada, nil – when a message sent to a NAMED SINK can’t be delivered?  In my case, I’m looking for a logger called “Com.Foo.Bar” and it didn’t even exist.  At least throw me a warning in the Event Viewer.  But no, you like to play the strong silent type, wrecking my productivity and causing my face to turn all different shades of purple and making me think Very Bad Thoughts like “I’ll just take this here laptop and play Ultimate Frisbee with it.”

Third: this is probably a .NET thing, but why isn’t my Global class pulled in to the project when I compile?  Why do I need the actual .asax file?  All my code is in the code-behind .cs file.  It’s almost like if Global.asax doesn’t exist, the Application_Start never gets fired.  Weird.

</on></flame>

So, bottom line for the others out there: make sure that you pull across your .asax file, if you’re using the Application_Start() method to configure your log4net system.

No Comments

Non-Relational Database Discussion at Seattle Tech Startups March Meeting

Community, Entrepreneurship, Networking, Software

Tonight’s e-mail brought a reminder from Gaurav about the Seattle Tech Startups meeting next Wednesday, March 10th, at the Douglas Forum at the Executive Education Center at the UW Business School.

Michael Miller from Cloundant (YC S08) will be on hand to discuss CouchDB and their commercial offering. We’ll also have Eric Peters from Frugal Mechanic (Founders Co-op) to talk about Cassandra. We’re going to have one more speaker and would ideally like it to be someone who can discuss MongoDB. The sponsor behind MongoDB, 10Gen, is helping us find a speaker in Seattle in time for the meeting, but if you know someone who could fit the bill, please drop us a note.

The topic is relevant, timely, and should be of interest to a lot of geeky Seattleites.  I’ve played around in the last year with non-relational cloud offerings from Microsoft and Amazon and also had a geek crush for a long time on Google’s BigTable technology.  While I’m not convinced of the universal applicability of non-relational databases, I think that they definitely have a place in the massively-scalable technology environment.  And the tooling and support infrastructure has grown leaps and bounds in the last year or two, to the point where working with them is no longer a huge pain.

Hope to see you there!

1 Comment

SPTD problem with Daemon Tools

Software

I’ve been doing a ton of Vista updates in preparation for my any-day-now move to Windows 7, and one of the updates hosed my Daemon Tools Lite installation.  I kept seeing this error:

“This program requires at least Windows 2000 with SPTD 1.60 or higher.  Kernel debugger must be deactivated.”

image

I had no idea what SPTD was, but this site tells me that SPTD is a sort of hardware abstraction layer.  OK, fine.  I have no idea what version (if any) of SPTD I have installed; supposedly you can find out from the Daemon Tools program, but it won’t launch.

So, I downloaded SPTD 1.62 directly from duplexsecure.com.  Upon running the downloaded installer, I see this:

image

Did I inadvertently download the 64-bit version?  No, I don’t think so…the file name indicates that I’ve got the x86 version.  Hm.

So, after Googling for a bit (did I mention I’m the world’s best Googler?) I found this forum post on the Daemon Tools support site that describes my exact problem.  I follow the second method and download the Windows Server 2003 Resource Kit, then run the command INSTSRV SPTD REMOVE:

image

I note in passing that this command removes the registry key HKLM/SYSTEM/CurrentControlSet/Services/SPTD/.

Then reboot, followed by a reinstall of the Daemon Tools Lite 4.35.5 install (supposedly containing SPTD 1.62).  During the install, I see that SPTD 1.62 is indeed installed:

image

When the install finishes, I’m prompted to reboot, which I do.  The shutdown hangs, which I’ve noticed occurs consistently after I install Daemon Tools Lite on Vista.  I hard-boot and when the system comes back up , Daemon Tools starts up in the background, which I can tell by this:

image

Finally!  A good Daemon Tools reinstall.  Hope this helps others of you running into the same problem.

6 Comments

Odd LINQ to SQL problem

Software

Is LINQ overspecifying my datetime values?  Check this out:

declare @p0 datetime
select @p0='2010-02-13 08:09:22.2270000'
Msg 241, Level 16, State 1, Line 4
Conversion failed when converting date and/or time from character string.

Compare to:

declare @p0 datetime
select @p0='2010-02-13 08:09:22'
Command(s) completed successfully.

The first set of datetime varchar strings is what is generated by my LINQ to SQL code.  But SQL Server barfs on it.  Hm.

2 Comments

WTIA Industry Achievement Awards March 4 2010

Business, Community, Entrepreneurship, Software, Startups

Hot from my inbox —

The 15th annual Washington Technology Industry Association Industry Achievement Awards will be held March 4th, 2010 at Showbox SODO.  Organizer Katie Douglas writes that it will be a “casual affair” and there will be lounges that feature some of the tech behind the lifestyle characteristics (such as coffee, wine, and chocolate) that makes Washington such a great place to live.

I involuntarily laughed at the tagline/theme: “Washington Breeds Innovation”.  I’ve been doing a lot of connotative / denotative linguistic research as part of my work on Crowdify, and that phrase brings to mind the State of Washington furiously copulating with a passive, bespectacled, softly moaning Innovation.  I don’t know, maybe it’s a guy thing.  Maybe it’s just me.

Curious who the finalists in the various categories are?  I was too.  I’m most interested in the “Breakthrough Startup of the Year” category, in which Gist is nominated.  As I’ve written elsewhere in these pages, my hindbrain has a sort of unhealthy obsession with the algorithms behind Gist’s service and they all seem to be great people to boot.

I’ve seen the VholdR tech in person, and to my mind, it’s neat, but not as neat as Gist.  Plus they get demerits for funky spelling.  The Google correctly points you to their site if you type “vholder” in the search box, but still….

I don’t know a thing about DreamBox Learning, which is funny considering how many projects I’ve done in the online education space over the years.

I’m rooting for Gist in this category.

Register here: http://www.washingtontechnology.org/IAA

See you there?

No Comments

Agile Open Northwest Conference Recap

Community, Software

Having just spent most of part of the last couple days at the 2010 Agile Open Northwest Conference in Seattle, I can say for sure that (a) our team does Agile in a very mature way and (b) there are some smart, smart motherfuckers out there.  Yes, I dropped the F-bomb in polite conversation, but whenever I go to a tech conference or any sort of event where bright people can shine, I’m constantly pleasantly surprised at how brilliant some people are.

When I was young, I thought I was the smartest.  And, in the little pond I swam in, I probably had a good shot at the title.  When I went to college, that attitude got dented, but not discarded; when I went to Microsoft, it got dented a little more; but it hasn’t been until I’ve gotten into my 30’s that I think I can accurately rank my intelligence in relation to others.  And the data is trending downward. ;)    I think part of it is that I don’t really care that much anymore.  Also, I now define myself a lot of different ways; there’s a lot more diversity in the components of my self-perception.

I’d name names and tell you who I thought fit in that brilliant category at #AONW but if you’re at all an observer of the Agile community you probably already know who they are.

So, you’re thinking, how was the conference?  I was only able to attend half the sessions, due to work scheduling commitments, but the sessions I attended – save for one – were enlightening and contained nuggets of wisdom and/or practice that I can take with me to my projects.  I personally presented two sessions, one last night and one this morning, and although the attendance was underwhelming, the discussions were really informative and thought-provoking.

The organization at this year’s #AONW seemed to be a little more on the ball than last year’s event held in Portland.  Not sure if that’s due to the local organizers, the maturing of the conference, or what.

The Seattle Center was a good choice for a venue; it’s centrally located, and the Northwest Rooms are all easy to find and self-contained enough that we didn’t have to wander around too much.

I’ve already put notes up from my sessions and tomorrow I’ll put up notes from the sessions that I attended but did not personally host.

n.b. I’m sort of amazed I didn’t blog about my experience last year at the 2009 AONW in Portland.  It was in many was one of the seminal events of 2009 for me, for a lot of reasons.

1 Comment
« Older Posts
Newer Posts »