Philip Hendry's Blog

July 20, 2011

Highlighting Selected Text automatically in Visual Studio

Filed under: Dev Tools, Tip, Visual Studio — philiphendry @ 1:40 pm

I’ve used Eclipse and always loved the way that any selected text is automatically discovered elsewhere in the current file and highlighted – this is also available in Notepad++.

Plugins to the rescue! There’s WordLight for Visual Studio 2008 and another called Highlight all occurrences of selected word.

June 1, 2011

Internet Explorer Developer Toolbar Formatting Javascript

Filed under: Dev Tools, Tip, Web — philiphendry @ 3:19 pm

I’ve seen screens like this all the time:

image

Jumbles of javascript spewd out by the ASP.NET AJAX and the like. However I’ve just noticed this very handy toolbar menu option:

image

Which produces formatted code like this:

image

I wish I had found that months and months ago!!

March 7, 2011

Mapping SkyDrive as a Network drive in windows

Filed under: Tip, Windows — philiphendry @ 9:06 pm

I didn’t realise you could do it until I found an article describing exactly how to do it and it works a treat! I’m thinking of using my SkyDrive account to backup photos off a NetGear ReadyNAS Duo storage device onto the cloud so they’re all doubly safe!!

November 19, 2010

Javascript Intellisense in Visual studio 2008

Filed under: Tip, Visual Studio — philiphendry @ 12:14 pm

I don’t know about you but I’m a big fan of intellisense and for a while I’ve been using a simple hack to get javascript intellisense working. For example, I’ve just added the following lines to the master page :

<%-- A simple hack to fool Visual Studio into giving us intellisence for javascript --%>
<%if(false) {%><script type="text/javascript" language="javascript" src="ClientResources/Javascript/uitools.js"></script><%}%>
<%if(false) {%><script type="text/javascript" language="javascript" src="ClientResources/Javascript/jquery-1.3.2-vsdoc.js"></script><%}%>
<%if(false) {%><script type="text/javascript" language="javascript" src="/../lib/jqueryplugins/jquery.rms.ajaxprogress.js"></script><%}%>
<%if(false) {%><script type="text/javascript" language="javascript" src="/../lib/jqueryplugins/jquery.rms.ajaxhistory.js"></script><%}%>

There are a few things to note :

  • The if (false) is the neat little hack that means this will never get rendered but Visual Studio will still parse and provide intellisense for the references.
  • I’m including the jQuery using the vsdoc version which means the intellisense as slightly more information in it. For example :

    image
  • To extend our own javascript files with vsdoc info see Scott Guthries blog – it’s just a case of formatting the javascript comments.
  • You can also use parents paths out of the web site and into the lib folder!
  • This will also work with style sheets which means the underlining of styles telling you they don’t exist goes away! Admittedly you have to pick either a default one or a customer stylesheet but that’s better than nothing!
<%if(false){%><link href="../styles/Styles.css" rel="Stylesheet" type="text/css" /><%} /* Weird trick to resolve css references in the page without affecting compiled output */%>

October 28, 2010

Don’t check in binaries files and ReSharper files into svn!!!

Filed under: Tip — philiphendry @ 9:07 am

Just added **.ReSharper** **\_ReSharper.** *\bin* *\obj* *.suo *.user to the TortoiseSvn global ignore pattern so I don’t go checking in resharper files or binary folders that aren’t needed – not that I ever did this before but it had always been a job I did by hand during the initial check-in of a project.

December 9, 2009

Adding a Windows Explorer Context Menu for the Web Development Server

Filed under: Tip, Windows, Windows 7 — philiphendry @ 4:17 pm

I wanted to be able to launch a single folder – the results of an ASP.NET WebForms build – in a Web Development Server without having to run up Visual Studio. The result looks like this :

image

And the solution… add the following to the registry :

Windows Registry Editor Version 5.00

[HKEY_CLASSES_ROOT\Directory\shell\webdev]
@="Launch in WebDev Server"

[HKEY_CLASSES_ROOT\Directory\shell\webdev\command]
@="\"c:\\windows\\microsoft.net\\framework\\v2.0.50727\\WebDev.WebServer.exe\" /port:54321 /path:\"%V\""

I would like to change that so it uses %windir% instead of C:\Windows but I must have got the syntax wrong because Explorer wouldn’t recognise the command. I’d also like to add an option for .aspx files that launches the parent folder in WebDev then launches an explorer window for the selected aspx file.

One last thing… this isn’t launching the server with any elevated permissions. If that’s required then you’ll need a tool such as Wintellects Elevate command which can be downloaded with full C# source code.

September 29, 2009

Generating a list of numbers in T-SQL

Filed under: SQL Server, T-SQL, Tip — philiphendry @ 8:33 am

I wanted to create a list of numbers so I could cross join them to another set of data to generate some test data quickly. There are ways to generate numbers using a CTE (Common Table Expression) or if you’re in a real hurry you can make us of a fairly undocumented table called master..spt_values. Seeing as this table isn’t well documented don’t go using it for production code since it might change but for quick one-off tasks it seems fine.

The following SQL creates a list of numbers from 0 to 2047 :

select [number]
from master..spt_values
where type = 'P'

September 21, 2009

ASP.NET Page Life Cycle Diagram

Filed under: ASP.NET, Tip — philiphendry @ 7:42 pm

I saw this months ago and wondered where it had gone so when I came across it by chance whilst googling I thought I would save myself a link to it. Many thanks to Raymond Lewallen who credits Leon Andrianarivony!

image

Sproc Compile Locks

Filed under: MSDN Article Summary, SQL Server, Tip — philiphendry @ 7:28 pm

I came across an article on Microsofts support site which has raised a point which I’d never considered before. It basically says that if the user that executes a stored procedure is not the owner of the procedure then locks are acquired during the process to find a cached plan that may lead to blocking. It also states this could be avoided by fully qualifying the sproc name (e.g. dbo.mysproc) when calling it to avoid the extra lookups. This has been a problem for me in the past since the projects I’ve worked on had been setup with an account running as dbowner, however, if I was setting up a database from scratch I’d set up a specific user(s) for accessing the database and give it just the permissions it requires (sproc execute permissions for example.) I think, therefore, this would fall into these problem. However, I would also make use of the schema prefix (e.g. Sales.Order table) rather than leaving it as dbo and therefore avoid this problem altogether.

September 11, 2009

Conditional Aggregate Totals in SQL

Filed under: SQL Server, T-SQL, Tip — philiphendry @ 8:03 am

I’ve been working on a SQL Server Reporting Services report which had to display several counts on each row. Each row represented a project and each project could have several tasks that were either ordinary tasks or milestones and could also be escalated. The report need to show something like this :

Project Name Milestone Counts Task Count Escalated Task Count
1st Week 2nd Week 3rd Week >=4th Week Total 1st Week 2nd Week 3rd Week >=4th Week Total

As you can see a task initially has to break down into two major colours of milestone and ordinary task counts but then is broken down into counts in the 1st, 2nd, 3rd and greater than 4th week totals including the total itself.

Initially this seemed tricky when thinking in terms of using count() but there’s an incredibly simple technique that solves this but which isn’t immediately obvious. The Sum() aggregate function can contain an expression and in this example that expression could compare the task date against late week dates and return either a 1 or 0 :

select ProjectName,
   sum(case when IsMilestone = 1 
      and TaskDate < @LateDate 
      and Taskdate >@OneWeekLateDate               
      then 1 else 0 end) as Week1LateMilestoneCount
from Project
group by ProjectName

I’ve only included one example there but I think it’s enough to get the idea.

Older Posts »

Theme: Shocking Blue Green. Blog at WordPress.com.

Follow

Get every new post delivered to your Inbox.