Tuesday, October 2, 2007

NowhereLand Filming in LoDo


Just outside my office at 1860 Blake Street, the film crew for the upcoming Eddie Murphy movie, "NeverLand", a prop Mercades was being configured with camera equipment.

A full article about the filming of NowhereLand can be found online:

http://www.denverpost.com/search/ci_7033903

Friday, September 28, 2007

Populating a Password Textbox at Runtime

Having an with a password property (TextMode="Password"), you cannot simply set the textbox's .Text attribute at runtime to populate the control with a value. Rather, you have to do the following:


this.txtPassword.Attributes["value"] = {whatever value from variable or DB}

Many thanks to:
http://aspadvice.com/blogs/joteke/archive/2005/02/03/_4000_ASP.NET-Forums_3A00_-How-to-set-text-to-a-Password-TextBox_3F00_.aspx

Wednesday, September 12, 2007

Converting Enum instance to string for evaluation

I came across a situation where I needed to get a Querystring value and evaluate it against a Enum used for display modes.

// Display Mode Enum
public enum Mode
{
View,
Add,
Edit
}

// Evalutate Querystring
object oDisplayMode = Request.QueryString["mode"];
if (oDisplayMode != null)
{
displayMode = (Mode)Enum.Parse(typeof(Mode), oDisplayMode.ToString(), true);

// Put into ViewState for next postback
ViewState["DisplayMode"] = displayMode;
}

Monday, September 10, 2007

Get names of all columns for a table in SQL Server

SELECT name
FROM syscolumns
WHERE [id] = OBJECT_ID('table_name')

Monday, August 27, 2007

Soda Pop Relics

I was headed to REI after work, but managed to miss my exit so I had to go north on I-25. The 58th Ave. Southbound exit was closed due to a semi roll-over (would have been an intersting picture).

In any case, I had to detour back toward Downtown via Washington St. Around 5oth Ave. I came across an old restaurant/bar having a double-sided Pepsi/Dr. Pepper sign. There are not too many of these around now, so I decided to capture the sign.




Enjoy a cold one!

Wednesday, August 8, 2007

Enabling XSLT scripting in .NET

By default, a .NET XslCompiledTransform does not allow for script execution within an XSL document due to security restrictions. As a result, it is necessary to enable scripting as follows:

transform = new XslCompiledTransform();
settings = new XsltSettings();
stream = new MemoryStream();
settings.EnableScript = true;
transform.Load(transformFilePath, settings, null);
transform.Transform(inputXml, null, stream);


Detailed Article:
http://msdn2.microsoft.com/en-us/library/wk7yxab1.aspx

SQL Server Search and Replace

This is a stored procedure I found online (http://vyaskn.tripod.com/sql_server_search_and_replace.htm) that seaches and replaces a string within all columns of a given database.


CREATE PROC SearchAndReplace

(

@SearchStr nvarchar(100),

@ReplaceStr nvarchar(100)

)

AS

BEGIN



-- Copyright © 2002 Narayana Vyas Kondreddi. All rights reserved.

-- Purpose: To search all columns of all tables for a given search string and replace it with another string

-- Written by: Narayana Vyas Kondreddi

-- Site: http://vyaskn.tripod.com

-- Tested on: SQL Server 7.0 and SQL Server 2000

-- Date modified: 2nd November 2002 13:50 GMT



SET NOCOUNT ON



DECLARE @TableName nvarchar(256), @ColumnName nvarchar(128), @SearchStr2 nvarchar(110), @SQL nvarchar(4000), @RCTR int

SET @TableName = ''

SET @SearchStr2 = QUOTENAME('%' + @SearchStr + '%','''')

SET @RCTR = 0



WHILE @TableName IS NOT NULL

BEGIN

SET @ColumnName = ''

SET @TableName =

(

SELECT MIN(QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME))

FROM INFORMATION_SCHEMA.TABLES

WHERE TABLE_TYPE = 'BASE TABLE'

AND QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME) > @TableName

AND OBJECTPROPERTY(

OBJECT_ID(

QUOTENAME(TABLE_SCHEMA) + '.' + QUOTENAME(TABLE_NAME)

), 'IsMSShipped'

) = 0

)



WHILE (@TableName IS NOT NULL) AND (@ColumnName IS NOT NULL)

BEGIN

SET @ColumnName =

(

SELECT MIN(QUOTENAME(COLUMN_NAME))

FROM INFORMATION_SCHEMA.COLUMNS

WHERE TABLE_SCHEMA = PARSENAME(@TableName, 2)

AND TABLE_NAME = PARSENAME(@TableName, 1)

AND DATA_TYPE IN ('char', 'varchar', 'nchar', 'nvarchar')

AND QUOTENAME(COLUMN_NAME) > @ColumnName

)



IF @ColumnName IS NOT NULL

BEGIN

SET @SQL= 'UPDATE ' + @TableName +

' SET ' + @ColumnName

+ ' = REPLACE(' + @ColumnName + ', '

+ QUOTENAME(@SearchStr, '''') + ', ' + QUOTENAME(@ReplaceStr, '''') +

') WHERE ' + @ColumnName + ' LIKE ' + @SearchStr2

EXEC (@SQL)

SET @RCTR = @RCTR + @@ROWCOUNT

END

END

END



SELECT 'Replaced ' + CAST(@RCTR AS varchar) + ' occurence(s)' AS 'Outcome'

END

Monday, July 16, 2007

Assigning and accessing multiple values for DataKeyNames on a GridView

Multiple DB column values can be assigned to the DataKeyNames attribute of a GridView, and accessed in the code-behind as follows:

aspx markup:
asp:GridView ID="gv1" runat="server"
DataSourceID="ods1"
DataKeyNames="pk_parent_id, fk_child_id"
OnRowDataBound="gv1_RowDataBound"

code-behind:

protected void gv1_RowDataBound(object sender, GridViewRowEventArgs e)
{
int childId = (int)(gv1.DataKeys[e.Row.DataItemIndex].Values["fk_child_id"]);
}


protected void btn1_Click(object sender, EventArgs e)
{
foreach (GridViewRow row in gv1.Rows)
{
int childId = (int)(gv1.DataKeys[row.RowIndex].Values["fk_child_id"]);
}
}

Wednesday, July 11, 2007

Getting back a DOUBLE when dividing two integer values

C# returns back a 0 to a double when dividing two integer values. Therefore, we have to cast as follows:

double dblResult = (double)(intValue1) / (double)(intValue2));

Monday, July 2, 2007

Centering a pop-up window in Javascript

I come across this a lot, but always seem to forget some little detail... so I'm putting it here as a reference:

function wopen(url, name, w, h)
{
// Fudge factors for window decoration space.
// In my tests these work well on all platforms & browsers.
w += 32;
h += 96;
wleft = (screen.width - w) / 2;
wtop = (screen.height - h) / 2;
// IE5 and other old browsers might allow a window that is
// partially offscreen or wider than the screen. Fix that.
// (Newer browsers fix this for us, but let's be thorough.)
if (wleft < 0) {
w = screen.width;
wleft = 0;
}
if (wtop < 0) {
h = screen.height;
wtop = 0;
}
var win = window.open(url,
name,
'width=' + w + ', height=' + h + ', ' +
'left=' + wleft + ', top=' + wtop + ', ' +
'location=no, menubar=no, ' +
'status=no, toolbar=no, scrollbars=no, resizable=no');
// Just in case width and height are ignored
win.resizeTo(w, h);
// Just in case left and top are ignored
win.moveTo(wleft, wtop);
win.focus();
}

Tuesday, June 26, 2007

Design time databinding to a control within an ItemTemplate

This is a kind of a hack, but comes in handy for certain situations such as assigning a data value to a control (i.e. ASP:HiddenField 'Value' attribute) contained within an ItemTemplate when binding in the code-behind is not feasible.

Value='<%# Eval("data_column_name") %>'

Tuesday, June 19, 2007

Setting ReportServerCredentials for ReportViewer

Here is a solution for a situation in which an instance of a ReportViewer control was on a different server and domain than the SQL 2005 Report Server. It also allows for limiting security to only a specific directory on the Report Server.

1) On the Report Server machine, create a local user account and assign the necessary permissions to interact with Reporting Services

2) In the Report Manager on the reporting server machine, assign the above account to a role of System User. Next, navigate to the directory containing the reports, to to the Properties tab, select Security and create a New Role Assignment using the account created in step #1.

3) Implement a public class that implements IReportServerCredentials as follows:

using System;
using System.Net;
using System.Security.Principal;
using System.Text;

using Microsoft.Reporting.WebForms;

namespace Common
{
public class ReportServerCredentials : IReportServerCredentials
{
private string reportServerUserName;
private string reportServerPassword;
private string reportServerDomain;

public ReportServerCredentials(string userName, string password, string domain)
{
reportServerUserName = userName;
reportServerPassword = password;
reportServerDomain = domain;
}

public WindowsIdentity ImpersonationUser
{
get
{
// Use default identity.
return null;
}
}

public ICredentials NetworkCredentials
{
get
{
// Use default identity.
return new NetworkCredential(reportServerUserName, reportServerPassword, reportServerDomain);
}
}

public void New(string userName, string password, string domain)
{
reportServerUserName = userName;
reportServerPassword = password;
reportServerDomain = domain;
}

public bool GetFormsCredentials(out Cookie authCookie, out string user, out string password, out string authority)
{
// Do not use forms credentials to authenticate.
authCookie = null;
user = null;
password = null;
authority = null;

return false;
}
}
}


4) In the code hosting the ReportViewerControl, assign the account credentials created in step #1 to the ReportServerCredentials property using the above class. It is recommended that the credentials string values be placed in a .config file with a public accessor class. For now, actual string values will be passsed for the illustration of this example:

ReportViewer1.ServerReport.ReportServerCredentials = new ReportServerCredentials("MaerskReports", "lCt!25!", "");

Monday, June 18, 2007

Converting a String value to a URI object instance

I came across a situation in .NET where I needed to programatically set the 'ReportServerUrl' property for a ReportViewer object in my C# code-behind. This was mostly due to the fact the application can be deployed on several different servers of which the I placed the URL to the Report Server in web.config.

So, I thought that I could simply implement:
ReportViewer1.ServerReport.ReportServerUrl =
http://servername/reportserver;

NOT!

I learned that ReportServerUrl needed to be assigned to a System.Uri object. So, I came up with the following function to convert a given string to a Uri object:

public Uri NavigateTo(string location)
{
return new Uri(location);
}


So, now all I need to do is:

1) Put URL into web.config
<add key="reportserver_url" value="http://localhost/reportserver"/>


2) Write a public interface to the configuration string

public static string GetReportServerUrl()
{
return AppConfig.ReportServerUrl;
}


3) Assign property in code-behind
ReportViewer1.ServerReport.ReportServerUrl = NavigateTo(AppConfig.GetReportServerUrl());

Thursday, June 14, 2007

Part 2 - Implementing PARSENAME to make use of the date range

Nuances about PARSENAME
* Evaluates from Right to Left
* Works with only a period as a delimiter


Code:
-- Note: @Week should be a stored proc input param
Declare @Week varchar(30)
Set @Week = '04/29/2007 to 05/05/2007'

Declare @NewDateRange varchar(30)
Declare @WeekBegin varchar(30)
Declare @WeekEnd varchar(30)


Set @NewDateRange = REPLACE(@Week, ' to ', '.')
Set @WeekBegin = PARSENAME(@NewDateRange, 2)
Set @WeekEnd = PARSENAME(@NewDateRange, 1)


SELECT @WeekBegin as BeginDate
SELECT @WeekEnd as EndDate


/* Results:
BeginDate = 04/29/2007
EndDate = 05/05/2007


Sources:
http://www.sqlteam.com/article/using-the-parsename-function-to-split-delimited-data
http://msdn2.microsoft.com/en-us/library/ms186862(SQL.90).aspx

SQL to create a list of weeks - Handy for reporting

Declare @StartDate DateTime
Declare @EndDate DateTime

Set @StartDate = '04/29/2007'
--Date of the sunday to show in the combo box.
Set @EndDate = '06/01/2008'; --Date used to as the stop point for the combo box. Does NOT get shown

With DateList( WeekCommencing ) as (
SELECT @StartDate WeekCommencing

UNION All

SELECT DateAdd( w, 7, WeekCommencing )

FROM DateList

WHERE DateAdd( w, 7, WeekCommencing ) < @EndDate ) SELECT Convert( VarChar(10), WeekCommencing, 101 ) + ' to ' + Convert( VarChar(10), DateAdd( d, 6, WeekCommencing ), 101 ) Week FROM DateList dl WHERE WeekCommencing <= GetDate()

Tuesday, June 12, 2007

FormatDate Function

I need a reminder of the parameters specifying which portions to display of a datetime value. Here is what I found on MSDN:

1 = Display a date and/or time. If there is a date part, display it as a short date. If there is a time part, display it as a long time. If present, both parts are displayed.

2 = Display a date using the long date format specified in your computer's regional settings.

3 = Display a date using the short date format specified in your computer's regional settings.

4 = Display a time using the 24-hour format (hh:mm).

http://msdn2.microsoft.com/en-us/library/8aebkz6s.aspx

Monday, May 28, 2007

Cancun Trip - Boca Del Puma Excursion

I went on a 1/2 excursion to Boca Del Puma where we did a variety of activities including: walking tour of flora & fauna, bike ride to Mayan village and swimming in an underground limestone cave.

Click below to enjoy the show!


Sunday, March 18, 2007

Nothing Left To Lose


... come on and we'll sing, like we were free
push the pedal down watch the world around fly by us
come on and we'll try, one last time
I'm off of the floor
one more time to find you...



I had the pleasure of going to the Ogden tonight to treat my senses to the music of Mat Kearny. I recently discovered his music listening to my favorite radio station KBCO.

What I find unique about Mat's music is how he seamlessly intertwines spoken word into his music and singing. I feel he does it so elegantly compared to other musicians using a similar technique... Sorry G. Love!

To sum up a great show, Mat is a very mature musician who kept the rhythm and energy flowing throughout the entire show. I see him going very far in the years to come.

As I mentioned in an earlier post, "Nothing Left to Lose" is on my hit list of songs to play on my new guitar using these tabs I found online.

Tuesday, February 20, 2007

Guitar Songs to Learn

Over the past several weeks, I've been listening to my iPod in "shuffle" mode and picking out songs I'd like to learn to play on my guitar using the "My Top Rated" feature (*****). I feel very inspired today and my iPod is doing a great shuffle job (I swear, there must some artificial intelligence with it), so I've decided to translate this from "My Top Rated" to a real list:
  • Fire and Rain - James Taylor
  • Desire - U2
  • Runaround - Blues Traveler
  • Yellow - Coldplay
  • Time of Your Life - Greenday
  • Rodeo Clowns - Jack Johnson/Ben Harper
  • No Such Thing - Johh Mayer
  • Nothing Left to Lose - Mat Kearney
  • Best of My Love - The Eagles
  • Dust in the Wind - Kansas
  • You Can't Always Get What You Want - Rolling Stones
  • America - Simon & Garfunkel
  • Rocky Mountain High - John Denver
  • What I'm Fighting For - Matisyahu
  • World Of Peace/Shalom Rav - RebbeSoul
  • Laugh Like I Could Learn to Love - Gus
  • My Stupid Mouth - Johh Mayer
  • More Than a Feeling - Boston
  • Put Your Records On - Corrine Baile Rae
  • Cruel to Be Kind - Nick Lowe
  • Karma Police - Radiohead
  • Margaritaville - Jimmy Buffett
  • No Rain - Blind Melon
  • For What It's Worth - Dusty Springfield
  • Under the Milky Way - The Church
  • Shiver - Coldplay
  • Last Worthless Evening - Don Henley
  • Crazy Little Think Called Love - Queen
  • Singing In My Sleep - Semisonic
  • Pinball Wizard - The Who
  • Beer For My Horses - Willie Nelson
  • I Had a King - Joni Mitchell
  • Mr. Jones - Counting Crowes
  • Lay Me Down - Crosby and Nash
  • Every Rose Has a Thorn - Poison
  • Drive - Incubus

I plan on getting most of these tabs online through Ultimate-Guitar.Com and 911Tabs.Com

Thursday, February 15, 2007

Disemboweled Doggie


When I got home in the wee hours of the morning from my Valentine's night out with some friends, Crockett got jealous and managed to quickly disembowel his little yellow stuffed doggie friend. Shame on your Crockett... He was your cute little "Mini-Me" daddy bought you right after you were adopted! :(

I think for now, I'll stich-up little yellow doggie before I present Crockett with a new one. Call it my version of a gastro bypass!

Tuesday, February 13, 2007

Clogged Drain :-(


Thank goodness I have a shop vac!

The Police are Coming!

Upon waking to KBCO this morning, I learned it's no longer a rumor about the Police getting back together and touring. They'll be at the Pepsi Center on June 9th. Tickets are between $50 and $275.

I think I'm going to make this happen. I've always wanted to them growing up, but couldn't do so for whatever reasons. Below is the offical news relesae from their site:

www.sting.com/news/news.php?uid=4772

Friday, February 9, 2007

First Neighborhood Shabbat

Tonight starts my first Shabbat in the neighborhood. I'll be headed over to DAT with a neighbor for Kabbalat Shabbat. Tomorrow, I'm walking over to Kohelet for morning services and meeting-up there with a friend.

I'm finally happy to not have to drive for several miles!

Tomorrow night, I'm headed over to Temple Emanuel for their fundraiser, "An Evening to Build Your Life On." It's a back-to-Shwayder Camp event that should bring back some awesome memories... songs... s'mores... Maybe an old camp girlfriend?

Wednesday, February 7, 2007

Walking in Memphis

Last night, I went with a friend to hear Marc Cohn at the Boulder Theater. If you're not familiar with Marc Cohn, he's a singer/songwriter most famous for his storytelling song "Walking in Memphis." Marc had the misfortune of being hit in the head by a stray bullet last year in Downtown Denver. Thankfully, he did not sustain any major injuries, but he does have a scar that he said is "pretty cool."

Okay, about the show... Marc started off saying this was his first gig in a long time, and that he may "suck." After playing his first couple songs, he asked the audience for requests and started playing based on that. Pretty cool! All I can say is that Marc did NOT suck, and he moved a packed house with his powerful voice and work on the piano. He played several songs from his new album that will be coming out "soon", that he joked about people downloading for free.

The highlight of the show was when he played Walking in Memphis. During the verse, "Are you a Christian Child...", the house lights went up and Marc signaled the audience to singing with "Ma'am I am tonight!" All I can say is WOW! I've never seen an artist interact so intimately with an audience.

Marc prefaced the song True Companion asking who got married to it, or plans to get married to it. He told a story about how a venue requested that he bring couples on stage who proposed that evening with this song. His response was that doing so would make him a rabbi! "I'm already a cantor," he said!

Marc did talk quite a bit about the shooting last year, and said he has no ill feelings towards the people of Colorado. He said it could have happened anywhere. It was obvious from these comments and his music that he has a strong and friendly connection to Colorado.

www.marccohn.net

Thank you Marc!

Tuesday, February 6, 2007

Door Knobs That DON'T Suck


The moment I moved into my house, I was blinded by the sight of those sucky gold door knobs all over the house. Okay, call me a snob, but come on... These door knobs belong back in the 1970's!

Instead of continuing to kvetch (one of my friend's already told me to knock it off), I went online today to purchase some modern and "finished" looking doorknobs. Since my house is on the compact side, I went with egg-shaped knobs in a satin nickel finish, specifically the "Laurel" series by Kwikset. I think they look great and are relatively affordable (sorry Baldwin).