Friday, November 30, 2007

When is a class not a Class?

When it’s a structure, DOH!  I couldn’t figure out why my For Each loop wasn’t saving the value of my Reference objects.  Turns out they were Structures (treated like value objects) so they were copies, not references.  I discovered that with the help of Google Answers!

Troubleshooting the FCKing Editor

TestLink relies on FCK for rich-text editing.  Well the File Upload and Browser weren’t working – initially b/c then needed to be enabled, then I was getting a popup that said “XML Request Error : Internal Server Error (500)”.  I used the FCK Editor test page: editor/filemanager/browser/default/connectors/test.html  to determine the /userfiles/ directory needed to be created.  I ended up just putting it in the root to save time/trouble.

Administering SQL Express without Management Studio

Call me a glutton for punishment, but today I endeavored to create a database and user w/o the aid of SQL Management studio.  Why would you do something so ridiculous you ask?  First, my new shop is more of an Oracle group that tolerates MS, so I don’t have Management Studio installed yet.  Second, I think you learn more about a product when you start using it command-line.  No hand holding, point and click stuff here.  Just raw ascii and endless error messages.  Anyway, I got it working so here’s the script to create a database and a login for it:

 

create database TestLink

go

create login testlink with password = 'abc123', DEFAULT_DATABASE = testlink

go

use testlink

create user testlink with default_schema = dbo

go

sp_addrolemember 'db_owner', 'testlink'

go

 

Btw, if you’re SQL Express install is fresh then it is in Windows Authentication mode and needs to be changed to Mixed mode (restart SQLEXPRESS service required):

 

HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\Microsoft SQL Server\MSSQL.1\MSSQLServer

LoginMode = 2

Thursday, November 29, 2007

PHP + MSSQL working

I have learned much more than I wanted to about PHP trying to get TestLink working with MSSQL 2000 so here’s what I did:

 

  1. Downloaded ntwdblib.dll from webzila.com and overwrote the c:\PHP5 version and copied to SYSTEM32 (this seems to be a key to solution)
  2. Enabled the MSSQL extension (extension=php_mssql.dll )
  3. Restart IIS
  4. Visited PHP page with the info code in it: <? phpinfo(); ?> to verify the extension loaded.
  5. Ran test code that connected to a SQL server (I just Googled it).

 

 

Wednesday, November 28, 2007

Dynamically create a DataTable for Oracle Stored Procedures results

I recently had to write a report that flattened 20 joined tables to “dump” the contents for ad-hoc-i-ness; probably 100+ columns.  Well, I did not want to have to build a fixed DataTable (Table.Column.Add(“Col1”)…), as was the standard in our shop, so I wrote a routine to do it instead:

 

    Public Shared Function BuildDataTable(ByRef dr As OracleDataReader) As DataTable

        Dim table As New DataTable()

 

        Dim colName As String

 

        ' Create the table from the DataReader columns

        For i As Integer = 0 To dr.FieldCount - 2

            colName = dr.GetName(i)

            table.Columns.Add(colName)

        Next

 

        ' Populate the table

        While dr.Read

            Dim row As DataRow = table.NewRow()

 

            For i As Integer = 0 To dr.FieldCount - 2

                row.Item(i) = dr(i)

            Next

 

            table.Rows.Add(row)

        End While

 

        Return table

    End Function

Tuesday, November 27, 2007

Fermenting Update 1

As of Tuesday at 7am (30 hours), the fermenting has slowed to a very occasional bubble (1 in 30 seconds).  Once it stops I’ll wait 24 hours before bottling.  Unfortunately I discovered (actually read ALL the directions) that I put the Dry Hops in before I was supposed to.  Don’t know what effect that will have…only time will tell.

Monday, November 26, 2007

MySQL Backup & Restore

Just wanted to document how to backup and restore my shiny new MySQL database since I’ve got some real data in it.

 

Backup:

mysqldump -u sadmin -p pass21 Customers > custback.sql

 

Restore:

mysql -u sadmin -p pass21 Customers < custback.sql

Brewmeister C

Well, I jumped feet first into hobby-brewing.  After plunking down some bucks at the local homebrew store for their economy kit, I created a sweet smelling “amber” wort – beer jargon for boiled hops & sugars.  By the next day, the air-lock was bubbling, so I guess the yeast are alive and well in that plastic bucket (aka fermenter).  Only time will tell if I followed enough of the directions in enough detail to have a consumable beverage.

Thursday, November 15, 2007

PHP + MySQL

After find what looked to be a great QA utility, albeit written in PHP, I endeavored to install PHP and then MySQL, and then...the utility. After much wrestling with the PHP + MySQL config I was finally able to get it working with the help of this guy and another suggestion that you MUST reboot to have environment variables like PATH take effect...doh!


Still can't get testlink working though...

Wednesday, November 14, 2007

Good find: HttpContext.Current.Items

Thanks to Mike Duncan for a good tip and lots of laughs:

 

Generally, HttpContext.Current.Items doesn’t get all that much hot blog press, but let me tell you, I’m here to change all that. For those out of the know, System.Web.HttpContext.Current.Items is a sweet key-value pair collection you can use to pass objects around up and through all components that participate in a single HTTP request.

Array.ForEach (also works for )

Thanks to the .Net Tip of the Day for this little gem:

 

    Sub HandleClick()

        Dim myFam As String() = {"Chris", "Sue", "Matthew", "Annie", "Samuel"}

        txtResult.Text = ""

        Array.ForEach(myFam, AddressOf AddSeperator)

    End Sub

 

    Sub AddSeperator(ByVal name As String)

        txtResult.Text += name & "|"

    End Sub

MVC .net?

The release of the MVC framework may be worth watching:
 

One of the things that many people have asked for over the years with ASP.NET is built-in support for developing web applications using a model-view-controller (MVC) based architecture.

Last weekend at the Alt.NET conference in Austin I gave the first public demonstration of a new ASP.NET MVC framework that my team has been working on.  You can watch a video of my presentation about it on Scott Hanselman's blog here.

We'll be releasing a public preview of this ASP.NET MVC Framework a little later this year.  We'll then ship it as a fully supported ASP.NET feature in the first half of next year.

MaintainScrollPositionOnPostback is cool (and easy)

New to me is the

MaintainScrollPositionOnPostback="true"

setting for the Page control.  It's a little "jerky", but it gets the job done.  It pays to troll the 4Guys site from time to time.  They really know their stuff!

Tuesday, November 13, 2007

GridView DataItem and Sorting NameValueCollections

I wanted to reuse the data that I was pulling for my Gridview (rather than make a separate call to the DB) so I put this code in the RowDataBound event to collect all the distinct server names:
 
Dim testServerList As New NameValueCollection
Dim name, value As String
If e.Row.RowType = DataControlRowType.DataRow Then
    name = CType(e.Row.DataItem, DataRowView).Row.Item("TestServerName").ToString()
    value = CType(e.Row.DataItem, DataRowView).Row.Item("TestServerId").ToString()
    If Not name.Equals(String.Empty) AndAlso testServerList(name) = Nothing Then
        testServerList.Add(name, value)
    End If
And then I wanted to sort the data:
 
Dim sortedKeys() As String
sortedKeys = testServerList.AllKeys
Array.Sort(sortedKeys)

Monday, November 12, 2007

Ntelos 8K

What a cold day.  The start was about 38F which is pretty cold for a cotton T and running shorts.  My hands didn't warm up until mile 2.  For some reason I had it in my mind that an 8k is only 4.6-4.7 miles which ended up being a good thing since I started picking up the pace at about 3.5 miles since I thought I only had about 1 miles left.  Here are my split times for future reference:
37:55 HR: 173avg 197max
Mile 1 - 7:36 158avg
Mile 2 - 7:49 174avg
Mile 3 - 7:53 175avg
Mile 4 - 7:34 177avg
Mile 5 - 7:01 180avg

Friday, November 9, 2007

How (NOT) to winterize an irrigation system


Note: you should not follow my advice. This is how a computer programmer winterizes a system and is clearly what not to do!
Do not:
  1. attach a compressor without understanding how your pressure regulator works (mine is loosen = less pressure ?!?!?) if you're asking what's a pressure regulator just stop now
  2. open the city water valve with your compressor attached!
  3. assemble cast iron fittings without lots of teflon tape
  4. walk back and forth to the timer control
  5. expect things to go as planned
I should have known I was in for trouble when things went relatively smoothly at Home Depot. I purchased two cast iron adapters to take my 1.25" PVC fitting to 3/8" compressor fitting - after we found the "real" plumbing associate.

I assembled my "adapter" and when connecting it to the system the pressure instantly shot up to 80psi - the danger zone for PVC. You don't want to be above 60psi - city water pressure. Anyway, I figured lets see what happens to that zone I don't use that much...it turned on and worked like normal. The big zone never did lift the sprinklers, so I'm a little worried it didn't get blown out enough. Hopefully we'll be okay here - south of the mason/dixon.

My valves have little manual override tabs that I discovered after walking back and forth a bunch of times to the control in the garage. Next time I'd use them! Make sure you use lots of teflon tape, since the iron didn't seem to seal well with the PVC.

Thursday, November 8, 2007

Good thing I've got 2GB and a Duo

 

Flip-Flop - GIMP for President

After wrestling with Expression Design to do a simple screen capture + crop (and w/ the $$$ factor mentioned earlier) I went looking for something better - that's free.  Meet, GIMP. aka "The Free PhotoShop".  So far (read: 10 minutes) I haven't found anything that I don't like.
 

Great DIV hide JavaScript code

 My thanks to Lobo235 for his code that helped me with the collapsible fieldset:

<fieldset>
<legend onclick="toggleLayer( 'divComponentInfo', 'expandImg' )" onmouseover="this.style.cursor='hand'">
<img alt="expand" id="expandImg" src="images/expand_plus.gif" style="vertical-align:middle;padding-right:5px;" />Component information</legend>
<div id="divComponentInfo" style="display:none">

function toggleLayer( whichLayer )
{
var elem, vis;
if( document.getElementById ) // this is the way the standards work
elem = document.getElementById( whichLayer );
else if( document.all ) // this is the way old msie versions work
elem = document.all[whichLayer];
else if( document.layers ) // this is the way nn4 works
elem = document.layers[whichLayer];
vis = elem.style;
// if the style.display value is blank we try to figure it out here
if(vis.display==''&&elem.offsetWidth!=undefined&&elem.offsetHeight!=undefined)
vis.display = (elem.offsetWidth!=0&&elem.offsetHeight!=0)?'block':'none';
vis.display = (vis.display==''||vis.display=='block')?'none':'block';
}

Phil Factor is hilarious

It's got to be the funniest tech-blog...gets a laugh every time.
 

Heater fix - blown fuse

If you're blower fan is running and won't turn off, you just may have blown the fuse inside the control panel - that's what the "heater guy" had to fix.  Note to self: turn power to heater off before replacing the thermostat.  It would help if the breaker box were labeled correctly...disposal and heater were cross labeled!

Expression Design

I needed to create some icons and I don't have PhotoShop installed so I thought I would check out Expression Design.  I am pleased to report that they have faithfully copied Adobe's interface and hotkeys and in some ways improved on the tool.  I particularly like the scrollable properties window (much need at laptop resolution - 800px high).  Unfortunately MS Marketing apparently decided to make it painful to get Design b/c you either buy the entire Studio retail or have Team Suite MSDN ($10k).  That will probably keep most developers I know from using/switching...

Wednesday, November 7, 2007

Testing results of REF CURSOR in PL/SQL and Toad

I'm new to .Net development with Oracle procedures and today I just discovered the PL/SQL to call a procedure that returns a REF CURSOR and print the output in Toad. 
 
Many thanks to Littlefoot for the answer to making this work in Toad:
In such a case, check that DBMS Output is enabled (turn red button to a green one) and, possibly, set "Frequency of polling" to a minumum value (2 sec) - otherwise, you'll have to wait (default) 5 seconds for anything to appear.
 
DECLARE
  CUR1  AMR_PACK.PROJECT_CUR;
   C1    NUMBER;
   C2    VARCHAR2(10);
   C3    VARCHAR2(100);
   C4    VARCHAR2(20);
   T1    VARCHAR2(100);
   T2    NUMBER;
   P1    VARCHAR2(100);
   P2    NUMBER;
BEGIN
  DBMS_OUTPUT.ENABLE(1000000);
 
  EXTRACT_APPS_SUPPORTED('',OUT_CURSOR => CUR1);
 
  LOOP
    FETCH CUR1 INTO C1,
    C2,
    C3,
    C4,
    T1,
    T2,
    P1,
    P2;
   
    EXIT WHEN CUR1%NOTFOUND;
   
    DBMS_OUTPUT.PUT_LINE('base_id: ' || C1);
  END LOOP;
 
  CLOSE CUR1;
END;
 

Useful tools

A tip of the hat to a couple of the free tools that use often:

Crazy day

Boy was yesterday a tough one!  Kids throwing up, code blowing up, interpersonal issues, and to top it off…I broke my mother's heater trying to install a new thermostat (blower motor would not stop running).  Today is looking much better by comparison!

WPF experiences

Like many, I've been experimenting with SilverLight and that led me to look more into WPF. Installing the CTP seemed dicey, but it was the only way to get Visual Studio to create WPF projects. Even then, following the NetFx3 lab was tricky and frustrating. Perhaps Visual Studio 2008 will make things easier.

Rockford Lhotka said it right:
From early on, my consistent feedback to Microsoft has been that the technology is a failure if developers have to learn XAML to use WPF. By that measure, the current release of WPF is not doing well.