Geeks With Blogs



Lance Robinson

Create Your Badge

Lance Robinson is a software engineer in Durham, Chapel Hill, Raleigh, and surrounding areas. More about Lance.


Lance's TextBox » About Me » My Resume »Twitter Programming
ADO.NET Entity Framework – Code First Development Pattern
Here’s a quick start introduction to the ADO.NET Entity Framework Code First Development Pattern. For a more complete (but still intro) walkthrough, check out ScottGu’s blog. At the time of this writing, you’ll need the EF 4.1 Release Candidate. After EF 4.1 is released you’ll no doubt be able to find it on the ADO.NET team blog. 1. Create a new empty ASP.NET MVC2 Web Application, add a reference to System.Data.Entity. If using the EF4.1 RC - add a reference to the EntityFramework dll that comes ......

Posted On Thursday, April 14, 2011 3:42 AM

Visual Studio 2010 Find and Replace With Regular Expressions
Here is a quick notes about using regular expressions in the VS2010 Find Replace dialog. 1. To create a backreference, use curly braces (“{“ and “}” ) instead of regular parentheses. 2. To use the captured backreference, use \1\2 etc, where \1 is the first captured value, \2 is the second captured value, etc. Example: I want to find*: info.setFieldValue(param1, param2); and replace it with: SetFieldValue(info, param1, param2); To do this, I can use the following find/replace values: Find what: {[a-zA-Z0-9]+}.setFieldValu... ......

Posted On Thursday, March 10, 2011 5:07 PM

Creating Team Foundation Work Items With PowerShell
Here is the simple function I added to my powershell profile: function create-tfstask ($desc) { tfpt workitem /new $workItemType /collection:$serverUrl /fields:"Title=$($desc);Ass... To=$assignee;AreaId=$areaId... } To find the AreaId and IterationId for your project/versions, just look at a bug you know is setup correctly: PS C:\> tfpt query /collection:http://3bs001vs... /wiql:"select AreaId,IterationId from workitems where ID = 879" Next I hooked this into ......

Posted On Wednesday, January 26, 2011 10:58 AM

How do I rollback a TFS check-in?
I can never remember how to rollback a check-in, and there all kinds of mess in search results about this (change between different versions of TFS etc), so I thought I’d just put this here so I won’t forget anymore. :) Thanks to @manningj, TFS genius. Just drop to the command line and use tf.exe. Example: tf rollback /changeset:12345 For more on the tf.exe commands: tf help Technorati Tags: Visual Studio,Team Foundation,Rollback ......

Posted On Tuesday, December 21, 2010 11:24 AM

PowerShell – Recycle All IIS App Pools
With a little help from Shay Levy’s post on Stack Overflow and the MSDN documentation, I added this handy function to my profile to automatically recycle all IIS app pools. function Recycle-AppPools { param( [string] $server = "3bhs001", [int] $mode = 1, # ManagedPipelineModes: 0 = integrated, 1 = classic ) $iis = [adsi]"IIS://$server/W3SVC/... $iis.psbase.children | %{ $pool = [adsi]($_.psbase.path); if ($pool.AppPoolState -eq 2 -and $pool.ManagedPipelineMode -eq $mode) { # AppPoolStates: ......

Posted On Thursday, December 16, 2010 3:59 PM

Setting a Master Page Dynamically
To set an ASPNET master page dynamically, use the Page_PreInit function and set the Page.MasterPageFile property. For example: protected void Page_PreInit(object sender, EventArgs e) { this.Page.MasterPageFile = "~/MasterPages/" + mymaster + ".Master"; } In the above example, mymaster should be set by whatever your requirements dictate – read from DB/CMS/whatever. The page (aspx) itself shouldn’t have any other reference to the master page (ie, no “MasterPageFile attribute in the page directive), ......

Posted On Tuesday, August 17, 2010 3:04 PM

PowerShell TruncateAtWhitespace Function
Here’s a TruncateAtWhitespace function that takes an incoming parameter value and an incoming max length, and returns a substring broken at a whitespace position. This way if you have “Lance has a blog” and you need to truncate it to 8 characters or less, you get “Lance” instead of “Lance ha”. function TruncateAtWhitespace{ param( [string]$value, [int]$maxlength=200 ) $maxlength-=3; #allow for "..." suffix if ($value.Length -le $maxlength) { return ($value + "..."); } $closestwhitespaceindex = [int]$value.Substring(0, ......

Posted On Monday, August 16, 2010 3:30 PM

Amazon SimpleDB Developer Tools
According to a recent Amazon survey, “Developer Tools” were the most requested improvement for SimpleDB. /n software’s Amazon Integrator fits the bill for developers building in .NET, ASP.NET, .NETCF, Java, JSP, C++, C++ Builder, Delphi, VB6 (ActiveX), and even classic ASP. You can download a free trial version, which includes demos and API documentation for the SimpleDB component as well as the included AWS, EC2, S3, and SQS components. Technorati Tags: Amazon, AWS, SimpleDB ......

Posted On Tuesday, February 3, 2009 9:46 AM

TwitterMinder and Flickr->Twitter scripts
If you’re an RSSBus user who is using my Google Calendar –> Twitter or Flickr –> Twitter services, you might notice a minor change to both. I changed Twitterminder so that tweets resulting from Google Calendar entries are prepended with “GCal: “. I did the same thing with the Flickr->Twitter script, it will now prepend “Flickr: “. Related: How to call these services from your own applications. Related: How I converted TwitterMinder into Flickr->Twitter by changing 4 lines of code ......

Posted On Thursday, August 28, 2008 1:58 PM

CSharp TruncateAtWhitespace Function
Here’s a TruncateAtWhitespace function that takes an incoming parameter value and an incoming max length, and returns a substring broken at a whitespace position. This way if you have “Lance has a blog” and you need to truncate it to 8 characters or less, you get “Lance” instead of “Lance ha”. /// <summary> /// Truncate at the end of a word /// </summary> /// <param name="value">The original string</param> /// <param name="maxlength">The maximum length of string to return</param> ......

Posted On Monday, August 16, 2010 3:28 PM

Listing SPQuery FieldNameRefs
It took me a while to figure out how to get a list of all the available fields for a particular type of list in SharePoint (for performing custom queries in SPQuery). I was looking for a published list of these fields, which as far as I know does not exist. Instead, you just use the GetList method of the Lists SOAP service. Here’s an example SOAP request: <?xml version="1.0" encoding="utf-8"?> <SOAP-ENV:Envelope xmlns:SOAP-ENV="http://sche... SOAP-ENV:encodingStyle="htt... ......

Posted On Monday, December 7, 2009 4:24 AM

How to embed Excel in a .NET WinForms App
Download and install owc11. Run AxImp on OWC11.dll, which will have been installed in the microsoft shared\web components directory (ie C:\Program Files\Common Files\microsoft shared\Web Components\11\). AxImp.exe can be found in the Windows SDK (ie, C:\Program Files\Microsoft SDKs\Windows\v6.0A\Bin\AxIm... In Visual Studio project, drag OWC11.dll to a toolbox tab and drop the Excel component on form. Voila. When it comes deployment time, you’ll need the AxInterop.OWC11.dll. Some sample code: ......

Posted On Thursday, September 17, 2009 9:19 AM

quickly add zip and credit card functionality to applications
James Shaw mentioned how easy it was to add zip and credit card functionality (using nsoftware components) to a recent website he helped build recently. Technorati : ibiz, ibiz e-payment, ipworks, ipworks zip ......

Posted On Friday, December 15, 2006 4:01 PM

Four New Developer Toolkit Releases from /n software
Last week /n software announced new versions of three different toolkits, and a brand new SharePoint Integrator product. From NEW: /n software UPS Integrator V2 Released! Includes easy access to the most popular UPS mail capabilities including shipping, tracking, address verification, rate calculation, and much more. NEW: /n software SharePoint Integrator Released! Enables developers to build applications that integrate with Microsoft SharePoint Server, including components for working ......

Posted On Wednesday, July 15, 2009 1:53 AM

Pass by Reference Parameters in PowerShell
A long time ago Jeffrey Snover briefly mentioned the PowerShell [REF] parameter attribute, but otherwise there isn’t much mention around about how to use it. It seems simple enough, but I kept getting this error from PowerShell: “Reference type is expected in argument.” This post by MOW cleared things up for me – I needed to wrap my [REF] parameters in parens in the function call, like so: Find-NewMessages $valvar1 ([REF]$refvar1) ([REF]$refvar2) For those looking to see how pass by reference params ......

Posted On Wednesday, January 14, 2009 5:06 PM

New nsoftware Releases for SharePoint, BizTalk, SSIS
Today /n software announced new versions of three more toolkits today: SharePoint Extensions V3 BizTalk Adapters V3 SSIS Tasks V3 I have been involved in building these products, so if you have any questions feel free to let me know. Technorati Tags: BizTalk, SharePoint, SSIS ......

Posted On Friday, January 9, 2009 3:38 PM

Amazon EC2 developer component
/n software’s new Amazon Integrator toolkit is now available (it was just released today!) for software developers: Amazon Integrator V3 with EC2 & SimpleDB Now Shipping! Integrate popular Amazon Web Services, including S3, SQS, SimpleDB, AWS, and EC2 with your applications. All Editions Now Shipping: .NET, Java, C++, ActiveX, Delphi, & C++ Builder! Technorati Tags: Amazon, AWS, nsoftware ......

Posted On Friday, January 9, 2009 3:25 PM

93x faster .NET Image Loading

I was looking around for how to load images faster than the .NET System.Drawing.Image class and found this awesome finding from Omar Shahine.  The .NET 1.1 SP1 update included a new signature for System.Drawing.Image.FromStream that takes a boolean “validateImageData”.  If you set this to true, the loading time is *much* faster.  Does anybody know what validation is actually performed when this parameter is true?

Posted On Friday, September 19, 2008 4:29 PM

Troubleshooting FTP connections with PowerShell
I find that helping people troubleshoot FTP connectivity issues is much easier if they have PowerShell installed. I can just have them run the NetCmdlets ftp cmdlets with the –debug switch, which displays a trail of information about the communication over the wire. In this way you can see every command send to the server and every response coming back from the server, including what ports a server is attempting to use for ftp data connections. Very often ftp transfer connectivity errors are the ......

Posted On Thursday, May 21, 2009 1:22 PM

PowerShell function to determine if running on 64 bit machine
Easy a pie: function is64bit() { if ([IntPtr].Size -eq 4) { return $false } else { return $true }} Explanation: the size of an IntPtr will be 4 bytes on a 32 bit machine and 8 bytes on a 64 bit machine. I came across the tip somewhere (blog, usenet??) but I couldn't find it again - so I thought I'd share it here for anybody else who is looking for it. Technorati Tags: PowerShell ......

Posted On Friday, February 20, 2009 10:21 AM

Copyright © Lance Robinson | Powered by: | Join free