Saturday, May 12, 2012

Magnets, How They DO Work

Love bug season has descended unexpectedly early here in north central Florida.

Love bugs love lovin' at our expense.
 
Swarms of these annoying insects, male and female joined at the butt, fly adrift, ready albeit unwilling to let themselves be splattered at high speed against the finish of your car. Given time and accelerated by summer heat, their acidic gut chemistry can pit the paint and fill the delicate fins of your radiator with bug parts.



An easy, somewhat ghetto measure can be taken to protect the radiator and engine compartment from these annoying insects. All you need is some plastic screening material, a dead hard drive, and scissors.

I drive a minivan, so I don't much care about its finish, I'm more concerned about function than form. In my case, I just cut a swatch of plastic screening material large enough to cover the radiator openings in the front grille, then secured it at either top corner with a rare-earth magnet salvaged from a long-dead hard drive.



The few inches of overlap will allow the screen to stay draped over the grille openings while driving, as will the curve of the grille itself. A masochist might go so far as to have a wire mesh complete with some power running through it to act as a mobile bug zapper and decrease the bug population, but I lack the motivation and time to go that far, I'm content to just keep them out.

Now my engine can remain bug free, without compromising airflow the engine needs so that the radiator can dissipate heat on the road.


Friday, May 11, 2012

Inconsistent Line Ending Style

In trying to commit some changes to SVN using the TortoiseSVN client, I received an odd error for a single SQL database table script text file:

Inconsistent line ending style


On the TortoiseSVN forums someone suggested that this might have occurred because someone edited the file in multiple editors, and somewhere in the process happened to slip in a line feed particular to their editor which version 1.7.4 of our Apache Subversion server found disagreeable.

To work around this, I was able to open the file in Microsoft Word, then save the file as plain text, with Windows (Default) chosen for text encoding:



Why SVN server scrutinizes the line feeds is unclear to me, but thankfully whomever committed the offending change made it to just this one file out of hundreds in the repository.





Wednesday, April 11, 2012

Pick One Random Number from a Set of Numbers

A while back I posted a means to generate random numbers in SQL. I ran across a situation where I need to pick one number randomly from a set of numbers.

I found a decent solution here, but I didn't want to create a separate view and scalar function for this task.

Instead I create a table variable with a single integer column as the primary key. Next, I insert each of the values of the small set of numbers into the table variable. Finally, I perform a SELECT against the table variable with NEWID() specified in the ORDER BY clause, so that a randomly-chosen member of the set will be returned. 

        DECLARE @Code int

        DECLARE @Codes TABLE
        (
            Code int PRIMARY KEY
        )
       
        INSERT INTO @Codes (Code) VALUES (3)  
        INSERT INTO @Codes (Code) VALUES (6)
        INSERT INTO @Codes (Code) VALUES (9)
        INSERT INTO @Codes (Code) VALUES (12)

        IF @Code IS NULL
            SELECT TOP 1 @Code = Code FROM @Codes ORDER BY NEWID()

  
In my case this is to provide a stored procedure, which may or may not have a value provided for the @Code input parameter, be able to automatically pick a random value in case @Code is NULL. The table variable isn't necessary if the value being picked is among the primary key values of an existing table; a random selection can be obtained simply by doing a SELECT with NEWID().








Thursday, March 22, 2012

Disclaimer

All data and information provided on this site is for informational purposes only. 

DarthContinent.com makes no representations as to accuracy, completeness, currentness, suitability, or validity of any information on this site and will not be liable for any errors, omissions, or delays in this information or any losses, injuries, or damages arising from its display or use. All information is provided on an as-is basis.

There, now that the legal mumbo jumbo is out of the way, to put it more succinctly, read this at your own risk. I absolutely will not be responsible for any misuse of information contained wherein which happens to be detrimental to the well being of yourself, your Facebook friends, your in-laws, nor anyone else in the whole world, in perpetuity. 

Even the Jedi have no sway here! 

They, too, are bound by galactic law, despite their deep desire to eradicate the Sith. Indeed, were the Jedi to attempt to take this site down by Force, figuratively or literally, I would use the Sith powers at my disposal to squish their testicles or ovaries into raisin-like remnants of their former glory! Then would they know the TRUE power of the Force and the Dark side!

Well. Enough of that, let's party!