*.dannyg

an extension of dannyg

Observer pattern in Javascript

clock February 18, 2010 07:07 by author Danny Gershman

The observer pattern is extremely powerful in many cases where you want to have a Javascript class “listen” to another object.  The class or object attaches to a Subject and waits an update command and then notifies all Observers.    Another key concept here is the idea of inheritance in Javascript. 

I have a simple Javascript function that handles inheritance:

function inherits(base, extension)
{
    for (var property in base)
    {
        try
        {
            extension[property] = base[property];
        }
        catch(warning)
        {
        
        }
    }
}

 

Using this concept in mind I can now extend any additional functionalities of any Javascript class or object on the DOM.  Now let’s take a look at the Observer and Subject classes.

function Observer()
{
    this.Update = function(data)
    {
        alert(this.id + " Update() function has not been implemented");
    }
}
 
function Subject() {
    this.observers = new ArrayList();
}
 
Subject.prototype.Notify = function( context ) {
    var m_count = this.observers.Count();
            
    for( var i = 0; i < m_count; i++ )
        this.observers.GetAt(i).Update( context );
}
 
Subject.prototype.AddObserver = function( observer ) {
    if( !observer.Update )
        throw 'Wrong parameter';
 
    this.observers.Add( observer );
}
 
Subject.prototype.RemoveObserver = function( observer ) {
    if( !observer.Update )
        throw 'Wrong parameter';
   
    this.observers.RemoveAt(this.observers.IndexOf( observer, 0 ));
}

 

We can now go forward and actually implement the code on our HTML page.  Let say we have a series of form fields and we want to set that data equal to the value of another text box.  We could easily subscribe or unsubscribe to listen for updates.  We’ll then use a simple HTML button to send updates to the listening controls.

Our page looks like this in the browser

image

And now for the underlying HTML code.

<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
<html xmlns="http://www.w3.org/1999/xhtml">
<head>    
    <script type="text/javascript" src="http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js"></script>
    <script type="text/javascript" src="../Resources/Javascripts/library.js"></script>
    <title>Observer Pattern Example</title>
</head>
<body>
    <form>
        <br />textbox1: <input type="text" id="textbox1" />
        <br />button2: <input type="button" id="button2" />
        <br />notify data: <input type="text" id="textbox3" />
        <input type="button" id="button1" value="Notify" onclick="NotifyObservers(this)" />
    </form>
</body>
</html>
    <script type="text/javascript">
        $(function() {
            inherits(new Observer(), $("#textbox1")[0]);
            inherits(new Observer(), $("#button2")[0]);
            inherits(new Subject(), $("#button1")[0]);
 
            $("#button1")[0].AddObserver($("#textbox1")[0]);
            $("#button1")[0].AddObserver($("#button2")[0]);
 
            $("#textbox1")[0].Update = function(data) {
                this.value = data;
            }
 
            $("#button2")[0].Update = function(data) {
                this.value = data;
            }
        });
 
        function NotifyObservers(subject) {
            subject.Notify($("#textbox3")[0].value);
        }
    </script>

 

As you can see the DOM objects themselves inherit the respective Javascript class functions and properties.  I’m using jQuery to directly call the functions on the objects.  When I fill in some value on the textbox3 that data gets passed through the individual implementations of the Update() method on each object that had been attached to the Subject.

image

The attached objects have decided to update their own values, but in theory I can do anything with that data.  A very powerful design pattern.

This also uses an ArrayList a feature not included in Javascript.  The ArrayList class is seen below.

function ArrayList() {
    this.aList = []; //initialize with an empty array
}
        
ArrayList.prototype.Count = function() {
    return this.aList.length;
}
        
ArrayList.prototype.Add = function( object ) {
    return this.aList.push( object ); //Object are placed at the end of the array
}
 
ArrayList.prototype.GetAt = function( index ) //Index must be a number {
    if( index > -1 && index < this.aList.length )
        return this.aList[index];
    else
        return undefined; //Out of bound array, return undefined
}
        
ArrayList.prototype.Clear = function() {
    this.aList = [];
}
 
ArrayList.prototype.RemoveAt = function ( index ) // index must be a number {
    var m_count = this.aList.length;
            
    if ( m_count > 0 && index > -1 && index < this.aList.length ) 
    {
        switch( index )
        {
            case 0:
                this.aList.shift();
                break;
            case m_count - 1:
                this.aList.pop();
                break;
            default:
                var head   = this.aList.slice( 0, index );
                var tail   = this.aList.slice( index + 1 );
                this.aList = head.concat( tail );
                break;
        }
    }
}
 
ArrayList.prototype.Insert = function ( object, index ) {
    var m_count       = this.aList.length;
    var m_returnValue = -1;
                
    if ( index > -1 && index <= m_count ) 
    {
        switch(index)
        {
            case 0:
                this.aList.unshift(object);
                m_returnValue = 0;
                break;
            case m_count:
                this.aList.push(object);
                m_returnValue = m_count;
                break;
            default:
                var head      = this.aList.slice(0, index - 1);
                var tail      = this.aList.slice(index);
                this.aList    = this.aList.concat(tail.unshift(object));
                m_returnValue = index;
                break;
        }
    }
                
    return m_returnValue;
}
 
ArrayList.prototype.IndexOf = function( object, startIndex ) {
    var m_count       = this.aList.length;
    var m_returnValue = - 1;
                
    if ( startIndex > -1 && startIndex < m_count ) 
    {
        var i = startIndex;
                    
        while( i < m_count )
        {
            if ( this.aList[i] == object )
            {
                m_returnValue = i;
                break;
            }
                        
            i++;
        }
    }
                
    return m_returnValue;
}
        
        
ArrayList.prototype.LastIndexOf = function( object, startIndex ) {
    var m_count       = this.aList.length;
    var m_returnValue = - 1;
                
    if ( startIndex > -1 && startIndex < m_count ) 
    {
        var i = m_count - 1;
                    
        while( i >= startIndex )
        {
            if ( this.aList[i] == object )
            {
                m_returnValue = i;
                break;
            }
                        
            i--;
        }
    }
                
    return m_returnValue;
}

 

Enjoy!  Tweet me if you have any questions @dannygnj

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


JQuery & JSONP

clock February 8, 2010 18:58 by author Danny Gershman

http://jasonkelly.net/archive/2009/02/24/using-jquery-amp-jsonp-for-cross-domain-ajax-with-wcf-services.aspx

Technorati Tags: ,,,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


BlogEngine.NET custom captcha

clock December 24, 2009 12:36 by author Danny Gershman

One of the biggest flaws with my blog was that there was no CAPTCHA  ("Completely Automated Public Turing test to tell Computers and Humans Apart.)  Wikipedia article here.

I was getting comment spammed.  This I hope will reduce if not eliminate BOTS from putting false comments into my blog.  BOTS do this to increase their ranking on search engines in order to get more hits to their sites, when a keyword is entered.

Upon looking at the code for BlogEngine.NET, I did notice that there looked like there was some DEV in the area of the CAPTCHA, but it wasn’t fully implemented.

There is still one minor security flaw in my CAPTCHA design.  Once it’s fixed I will reveal what it was and how I fixed it.  In the meantime, I’ve gone ahead and deleted all fake comments and uploaded the new code.

If you try to comment on my blog now, you’ll see a little picture with some number on it.  The picture is of one of my cats “Sneakers”.  If the number is typed incorrectly, you won’t be able to post the comment.  Some of the messaging needs fixing as well.  This is definitely a good feeling project for me.

image

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Building a custom ORDER BY clause from a WHERE IN clause

clock December 8, 2009 06:40 by author Danny Gershman

I ran across a pretty interesting requirement.  Be able to sort something off a CSV list of items.  In this case we have a comma separated string we are using for an IN clause

declare @employeeids varchar(50)

set @employeeids = ‘4213,5321,4124’

declare @orderbyClause nvarchar(MAX)
select @orderbyClause = COALESCE(@orderbyClause, '') + ' when employee_id = ' + convert(varchar, number) + ' then ' + convert(varchar, roworder) from
dbo.iter$ordered_intlist_to_tbl(@employeeids)
select ‘ORDER BY CASE ' + @orderbyClause + ' END'
   

We are also using a custom table valued function which turns a CSV into a table and maintains the order using a roworder.

/****** Object:  UserDefinedFunction [dbo].[iter$simple_intlist_to_tbl]    Script Date: 12/08/2009 12:16:51 ******/
SET ANSI_NULLS ON
GO

SET QUOTED_IDENTIFIER ON
GO

CREATE FUNCTION [dbo].[iter$ordered_intlist_to_tbl] (@list nvarchar(MAX))
   RETURNS @tbl TABLE (number int NOT NULL, roworder int NOT NULL) AS
BEGIN
   DECLARE @pos        int,
           @nextpos    int,
           @valuelen   int,
           @rowcounter int

   SELECT @pos = 0, @nextpos = 1, @rowcounter = 1

   WHILE @nextpos > 0
   BEGIN
      SELECT @nextpos = charindex(',', @list, @pos + 1)
      SELECT @valuelen = CASE WHEN @nextpos > 0
                              THEN @nextpos
                              ELSE len(@list) + 1
                         END - @pos - 1
      INSERT @tbl (number, roworder)
         VALUES (convert(int, substring(@list, @pos + 1, @valuelen)), @rowcounter)
      SELECT @pos = @nextpos
      SELECT @rowcounter = @rowcounter + 1
   END
  RETURN
END
GO

Technorati Tags: ,,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Get SQL Table Sizes

clock December 7, 2009 05:43 by author Danny Gershman

Very powerful script for determine table sizesm the original blogger http://www.mitchelsellers.com/blogs/articletype/articleview/articleid/121/determing-sql-server-table-size.aspx

DECLARE @TableName VARCHAR(100)    --For storing values in the cursor

--Cursor to get the name of all user tables from the sysobjects listing
DECLARE tableCursor CURSOR
FOR
select [name]
from dbo.sysobjects
where  OBJECTPROPERTY(id, N'IsUserTable') = 1
FOR READ ONLY

--A procedure level temp table to store the results
CREATE TABLE #TempTable
(
    tableName varchar(100),
    numberofRows varchar(100),
    reservedSize varchar(50),
    dataSize varchar(50),
    indexSize varchar(50),
    unusedSize varchar(50)
)

--Open the cursor
OPEN tableCursor

--Get the first table name from the cursor
FETCH NEXT FROM tableCursor INTO @TableName

--Loop until the cursor was not able to fetch
WHILE (@@Fetch_Status >= 0)
BEGIN
    --Dump the results of the sp_spaceused query to the temp table
    INSERT  #TempTable
        EXEC sp_spaceused @TableName

    --Get the next table name
    FETCH NEXT FROM tableCursor INTO @TableName
END

--Get rid of the cursor
CLOSE tableCursor
DEALLOCATE tableCursor

--Select all records so we can use the reults
SELECT *
FROM #TempTable

--Final cleanup!
DROP TABLE #TempTable

Technorati Tags: ,,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Use COALESCE to create a CSV

clock December 3, 2009 12:47 by author Danny Gershman

This has proved time and again to be a useful method of creating a datafeed.

DECLARE @EmployeeList varchar(100)

SELECT @EmployeeList = COALESCE(@EmployeeList + ', ', '') + 
   CAST(Emp_UniqueID AS varchar(5))
FROM SalesCallsEmployees
WHERE SalCal_UniqueID = 1

SELECT @EmployeeList
Technorati Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Debug VBScript in EditPlus

clock December 3, 2009 11:35 by author Danny Gershman

See the below screenshot for configuring.

image

Technorati Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Determine ASP.NET root page

clock December 3, 2009 06:55 by author Danny Gershman

Sometimes when an ASP.NET page loads up from the root of a directory, the page name is not revealed via HTTP headers.  If it’s a webforms application, simply scroll down the Postback form section. (id=”aspnetForm”)

Look at the action attribute.  See the sample below.

<form name="aspnetForm" method="post" action="Home.aspx" id="aspnetForm">
Technorati Tags: ,,,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Find column in SQL

clock October 1, 2009 06:47 by author Danny Gershman

SELECT name FROM sysobjects WHERE id IN ( SELECT id FROM syscolumns WHERE name = ‘Column Name’)

Technorati Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Poison Cookies

clock September 18, 2009 03:55 by author Danny Gershman

I thought I coined the term, but it exists already

http://www.testingreflections.com/node/view/3701

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Finding PID for IIS Application Pool

clock September 9, 2009 05:48 by author Danny Gershman

This is pretty simple.

Create a batch file, call it app-pool-pid.bat for instance.

Edit it and add the following lines into the file:

@echo off

cscript.exe c:\windows\system32\iisapp.vbs

pause

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Warning label

clock September 3, 2009 19:01 by author Danny Gershman

warninglabel

Generate your own: http://www.warninglabelgenerator.com/

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Combining Database IDs

clock August 25, 2009 12:31 by author Danny Gershman

There was a interesting requirement recently that came up.  It was to basically modify and existing BIT field and ALTER it to be an INT field.  Essentially it was to really push the limits of an INT field. 

Traditionally in a relational database, you have a one-to-one mapping of PK-to-FK (primary key to foreign key).  The goal here is to combine values that representative of the object in that database row.  In this case we are talking about permissions.

So first we need to create the table that will generate the IDs.  We need a seed which will be used as a basis of our ID.  We want to use binary values, it will be a power of two (2) for the primary key ID.

CREATE TABLE [Permissions]
(
     [Seed] [smallint] IDENTITY(-1, 1) NOT NULL,
     [Id] AS (power((2),[Seed])) PERSISTED NOT NULL,
     [PermissionName] [varchar](255) NOT NULL,
CONSTRAINT [PK_ID] PRIMARY KEY CLUSTERED ([Id] ASC),
UNIQUE NONCLUSTERED ([Seed] ASC)
)

Now that we have a table that can generate these IDs, we need to populate.  Below is a sample script that will insert some values into the table.

INSERT INTO [Permissions] (PermissionName) VALUES ('None')
INSERT INTO [Permissions] (PermissionName) VALUES ('Read')
INSERT INTO [Permissions] (PermissionName) VALUES ('Write')
INSERT INTO [Permissions] (PermissionName) VALUES ('Execute')

Let’s run a SELECT * and see what happened.

image

As you can see we have some nice values to work with.  I’ll show you what I mean.  Traditionally you would do some kind of join and then determine the value.  In this case, we are going to leverage the power of the bitwise operators built into SQL Server.  I’m going to write a stored procedure that sets my permissions.  Let say that I have a user table and in that table I have a field INT called PermissionId.  I can set my PermissionID using the stored proc or in a simple UPDATE statement.

UPDATE Users SET PermissionId = 3 WHERE [UserId] = 1

What I have basically said is for userid = 1, give them Read and Write permissions.  Let’s validate that. using bitwise operators.  We will exclude 0, because None will be included every time.

DECLARE @Permissions varchar(MAX)
DECLARE @PermissionId int 
 
SET @PermissionId = 3
 
SELECT @Permissions = COALESCE(@Permissions + '/', '') + PermissionName
FROM Permissions
WHERE Id = Id & @PermissionId
AND Id <> 0
 
PRINT @Permissions

 

This returns ‘Read/Write’.  Let try the same for 5.  It returns ‘Read/Execute’.  How about for 7. Yup, just what I thought, ‘Read/Write/Execute’.

Technorati Tags: ,,,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Enabling ASP Errors on Vista/Windows 7 (IIS7-7.5)

clock August 13, 2009 09:27 by author Danny Gershman

Pretty tricky, the title says it all

cscript %systemdrive%\inetpub\adminiscripts\adsutil.vbs set w3svc/AspScriptErrorSentToBrowser true      (to allow error message send to client)

On a x64 OS (I run Windows 7 RC x64)

cscript C:\Windows\winsxs\amd64_microsoft-windows-iis-legacyscripts_31bf3856ad364e35_6.1.7100.0_none_4b5800ce84aa413c\adsutil.vbs set w3svc/AspScriptErrorSentToBrowser true

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Check-In/Out Sharepoint with Office Quickly

clock August 5, 2009 12:15 by author Danny Gershman

I feel like I should explain this really cool idea that I had.  Basically to quickly check-in and check-out documents in Sharepoint.  I’ll show you with MSword.  First thing to do is fire up Word.  You’ll notice that in the upper left hand corner near the Office Menu, a quick menu bar.  See below.

image

Drop down the arrow to right of the bar and you’ll see an option to add “More Commands”.  From this new window that pops up, go to the drop down “Choose command from” and select “All Commands”.

image

From here find Check-In and Check-Out and add them.  (I’m adding version history too!).  You can even add keyboard shortcuts from here too.  Once you’ve completed, click OK.  You’ll see your quick access bar updated.

image

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Run ASP.NET Development Server without Visual Studio

clock August 5, 2009 07:11 by author Danny Gershman

Ever want to run ASP.NET development server without having to fire up Visual Studio Debugger.

You can create your own scripts or commands by being able to access this.

%WINDOWS PATH%\Microsoft.NET\Framework\v2.0.50727\WebDev.WebServer.exe

Here is the command line options as shown without setting any parameters.  Enjoy!

image

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Search for text in SQL database procs/functions

clock July 23, 2009 07:04 by author Danny Gershman

declare @searchString varchar(100)
Set @searchString = '%word_to_find%'
SELECT Distinct SO.Name
FROM sysobjects SO (NOLOCK)
INNER JOIN syscomments SC (NOLOCK)
on SO.Id = SC.ID
AND SC.Text LIKE @searchString
ORDER BY SO.Name

Technorati Tags: ,,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Step/Debug through VBScript

clock July 20, 2009 12:09 by author Danny Gershman

http://baodad.posterous.com/step-through-vbscript-debugging

Technorati Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


VBScript Array

clock July 20, 2009 11:02 by author Danny Gershman

Pretty neat script I wrote that allowing preserving an array by cloning it.

Function AddToArray(ArrayToClone, ValueToAdd)
Dim a, tempArray
    On Error Resume Next
    ReDim tempArray(UBound(ArrayToClone) + 1)
    If Err.Number = 0 Then
        For a = LBound(ArrayToClone) To UBound(ArrayToClone)
            tempArray(a) = ArrayToClone(a)       
        Next
    ElseIf Err.Number = 13 Then       
        Err.Clear
        ReDim tempArray(0)
    Else
        WScript.Echo Err.Number
    End If
    tempArray(UBound(tempArray)) = ValueToAdd       
    AddToArray = tempArray
End Function

Technorati Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Sharepoint Solution Installer

clock July 20, 2009 08:23 by author Danny Gershman

 

http://www.codeplex.com/sharepointinstaller

Technorati Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Quickly Install WSP

clock July 20, 2009 08:18 by author Danny Gershman

stsadm -o addsolution -filename helpdesk.wsp

stsadm -o deploysolution -name helpdesk.wsp -allowgacdeployment -immediate

stsadm -o execadmsvcjobs

Technorati Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Self Signing SSL into IIS

clock June 29, 2009 06:49 by author Danny Gershman

I’ve done this a million times, I just found it useful to publish it for easy reference

C:\Program Files\IIS Resources\SelfSSL>selfssl /T /N:CN=www.tempuri.org /K:1
024 /V:5000 /S:232294796 /P:443

/T: is to make it trusted

/N: is the common name

/K: is bit length

/V: is days of validity

/S: it the Site ID, you can get this from the log prepend (see below)

/P: is port

To get the site ID, open IIS, and check the log settings.

image

 

Technorati Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Getting Crystal Reports XI Release 2 to install

clock May 27, 2009 04:31 by author Danny Gershman

 

I was facing some issues getting Crystal Reports XI Release 2 to install.   The installer was complaining that .NET 1.0 or 1.1 should be installed.   This was kind of a confusing message, since .NET 1.0 and 1.1 were both installed on the box.

The workaround is to uninstall all versions of .NET except 1.0 and 1.1 temporarily.  In my case I had to uninstall .NET 2.0, 3.0, and 3.5 to get this to work.  Once it was completed installing, I reinstalled all the uninstalled versions of .NET.

Technorati Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Email Resources

clock May 26, 2009 15:11 by author Danny Gershman

 

Email Reputation Search

Blacklist Lookup

Smart Network Data Service

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Hotmail Sending Woes

clock May 20, 2009 06:45 by author Danny Gershman

Here are some great articles on the subject

http://www.webforefront.com/archives/2007/11/getting_through.html

http://windowslivehelp.com/community/p/46833/194297.aspx

http://www.iis-aid.com/articles/iis_aid_news/are_hotmail_cutting_their_own_throat?page=4

2rbdj4ibc9

Technorati Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


URL Rewrites in WCF

clock May 12, 2009 10:31 by author Danny Gershman

I had posted an entry to StackOverflow earlier today.  But I was able to resolve before I got an answer.  When handling URL rewrites in WCF, it’s important to include the trailing forward slash in the URL.  You can this in my example below.

 

public class FormatModule : IHttpModule
{    
#region IHttpModule Members    
 
     public void Dispose()    
     {       
          throw new NotImplementedException();   
     }   
    
     public void Init(HttpApplication application)    
     {        
          application.BeginRequest += new EventHandler(application_BeginRequest);   
     }    
 
     void application_BeginRequest(object sender, EventArgs e)   
     {       
          HttpContext context = HttpContext.Current;       
          if (context.Request.RawUrl.Contains(".pox"))             
               context.RewritePath("~/Lab1Service.svc?format=pox", false);        
          else if (context.Request.RawUrl.Contains(".json"))             
               context.RewritePath("~/Lab1Service.svc?format=json", false);   
      }    
#endregion
}
 
What I needed to do was to include the trailing slash as seen below.

 

context.RewritePath("~/Lab1Service.svc/?format=pox", false);
Technorati Tags: ,,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Login to IMAP Server with puTTY

clock May 11, 2009 06:36 by author Danny Gershman

Create a connection to an IMAP server using the hostname and port 143

? login username password

To see a list of all the mailboxes on the server we use the list command. The arguments "" "*" simply get all the mailboxes including sub folders.

? list "" "*"
 
Technorati Tags: ,,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Remote Desktop Keyboard Shortcuts

clock May 7, 2009 12:52 by author Danny Gershman

image

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Finding CPU Utilization on SQL Server

clock May 7, 2009 03:59 by author Danny Gershman

Run this query to see if there is an increasing amount on a particular SPID

select spid, cpu, physical_io from sysprocesses order by cpu desc

Technorati Tags: ,,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Hotmail/Live Email Sending Problems

clock May 5, 2009 16:13 by author Danny Gershman

I’ve spent the last day or two trying to resolve why email was not being sent from specific SMTP Server to Hotmail. 

By signing up for Smart Network Data Services, you can very easily see where you pain point is.

Check it out https://postmaster.live.com/snds

Very helpful stuff!

image

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Finding duplicates with SQL

clock April 21, 2009 09:37 by author Danny Gershman

This is probably one of the most useful pages I’ve ever used on the Internet

http://www.petefreitag.com/item/169.cfm

Technorati Tags:

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


VSWebCache

clock March 30, 2009 12:58 by author Danny Gershman

When you open a Visual Studio .NET 2003 web project, you need to have your IIS virtual directory match what is in your SLN file as well as your .webinfo file.  That IIS virtual directory needs to also map to the actual directory your project file is in.

Whenever you attempt to open a web project (csproj / vbproj) in VS2003, it will attempt to read from the VSWebCache reference first.  This can cause your development environment to break, if you happen to have moved files around since the last time you opened your project. 

Browse to the VSCache location for your user and clear out the appropriate folder to reset this.  The location is set in VS under Tools –> Options –> Projects –> Web Settings.  See screenshot below.

image

Technorati Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


URL Rewriting Problems

clock March 28, 2009 13:04 by author Danny Gershman

This is from a blog post that Scott Guthrie wrote on URL Rewriting (original post here: http://weblogs.asp.net/scottgu/archive/2007/02/26/tip-trick-url-rewriting-with-asp-net.aspx)

Handling CSS and Image Reference Correctly

One gotcha that people sometime run into when using Url Rewriting for the very first time is that they find that their image and CSS stylesheet references sometimes seem to stop working.  This is because they have relative references to these files within their HTML pages - and when you start to re-write URLs within an application you need to be aware that the browser will often be requesting files in different logical hierarchy levels than what is really stored on the server.

For example, if our /products.aspx page above had a relative reference to "logo.jpg" in the .aspx page, but was requested via the /products/books.aspx url, then the browser will send a request for /products/logo.jpg instead of /logo.jpg when it renders the page.  To reference this file correctly, make sure you root qualify CSS and Image references ("/style.css" instead of "style.css").  For ASP.NET controls, you can also use the ~ syntax to reference files from the root of the application (for example: <asp:image imageurl="~/images/logo.jpg" runat="server"/>

Technorati Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


ReadyBoost

clock March 25, 2009 16:50 by author Danny Gershman

http://www.vistarip.com/e107_plugins/faq/faq.php?0.cat.4.7

Technorati Tags: ,

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


ReBind ASPX.VB/CS (Codebehind) to ASPX

clock March 23, 2009 16:57 by author Danny Gershman

Something has happened to a solution file that I’m working with and the codebehind has been unbinded from it’s ASPX page.  Use the following technique to rebind in VS2003

image

Right-click an ASPX page and select “View Code” (You can highlight multiple ASPX pages, by using Ctrl+Click)

image

The code will now be rebinded, as see below.

image

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


How to determine if an assembly was compiled as debug

clock March 10, 2009 17:51 by author Danny Gershman

First thing to do is get Red Gate’s .NET Reflector.  Drop the assembly and run the disassemble.  You should see in the Assembly Metadata metadata that says

Debuggable("True, True")

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Creating Custom Workflows

clock November 19, 2008 13:08 by author Danny Gershman

In order to achieve the list behavior I wanted, I had to create a custom workflow.  The problem was I wanted to have a task list feed into a calendar.  I wanted this because I still wanted to keep the Outlook connectivity.  By using Sharepoint Designer, I was able to create a simple workflow.  I added a two new fields on the task list.  One was a Yes/No field that acts as a trigger.  Once this value is set I'm then adding a new item into the calendar.  I use a variable to combined the Title and the other custom field into Event Title on the Calendar.  It works great!

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


Web Application Stress Tool

clock November 18, 2008 08:00 by author Danny Gershman
I ran into some issues with the web application stress tool on Vista x64.  I need to download the dll msvcp50.dll from the DLLfiles on web.  Then I copied it to the following locations.
C:\Windows\System32
C:\Windows\SysWow64
Then I ran the setup.exe and it installed successfully.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5


About dannyg

dannyg has been writing software for the last 12+ years and worked with various languages and programs.  He specializes business process automation, versatile solutions and R&D.

 


Sign in