Grep like String Searches in Windows

Tuesday, 15 December 2009 21:18 by Jeff

Problem
What is the eqivalent of grep in Windows.

Solution
1) Windows XP onwards come with the DOS command FINDSTR

Example :
I want to search the Microsoft .NET Chart Controls Sample for a particular string and list only the filename.

FINDSTR /S /C:"This sample demonstrates Stacked Area" /m *.*

/S recursively searches sub-directories.
/C: sets the string you are searching for.
/M lists filename only.

For more help type FINDSTR -? in DOS

Output from the command :
C:\Inetpub\wwwroot\WebSamples>FINDSTR /S /C:"This sample demonstrates Stacked Area" /m *.*
ChartTypes\BarColumnCharts\Stacked\stackedchart.aspx

2) Another way to search is using Windows PowerShell. This example will search for the same string as the FINDSTR example and list only the filenames containing that string.

get-childitem ./* -include *.* -recurse -exclude msc_cntr*.txt |select-string -pattern "This sample demonstrates Stacked Area"-casesensitive | select-object Path

Rough guide what is happening here :
a) get-childitem ./* -include *.* -recurse -exclude msc_cntr*.txt - This will get the recursive search for all files from you current directory down. -exclude msc_cntr*.txt was used as I the file was open and locked at the time, add error output I did not require.
b) select-string -pattern "This sample demonstrates Stacked Area"-casesensitive - This is just case sensitive search on the string "This sample demonstrates Stacked Area".
c) select-object Path - This displays the filename and full file path, for the filename with no path use "select-object Filename".

Output from the command :
PS C:\Inetpub\wwwroot\WebSamples> get-childitem ./* -include *.* -recurse -exclude msc_cntr*.txt | select-string -pattern "This sample demonstrates Stacked Area" -casesensitive | select-object Path

Path
----
C:\Inetpub\wwwroot\WebSamples\ChartTypes\BarColumnCharts\Stacked\stackedchart.aspx

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   , , , ,
Categories:   Windows
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

A free VB.NET Image cropper and scaler

Thursday, 24 September 2009 08:08 by Nick

This is a neat little application (with source) that lets you load an image, crop it, resize the cropped lump, and save it as a JPEG. It uses System.Drawing.Image to crop and resize images in VB.Net.

I was looking around for something to do this, but either the examples didn't do what I wanted or cost money. If you need something to edit ecommerce photos that need to be a certain size and aspect, this is for you. 

Other features:

- Choose your crop area with mouse drag

- Choose your aspect ratio

- Shrinks or enlarges the cropped area to fit your exact output size needs.

- Did I mention it's free?

  Download imageCropper.rar and enjoy.

 

ImageCropper.rar (72.63 kb)

Currently rated 4.7 by 3 people

  • Currently 4.666667/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:  
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

LINQ SqlDateTime Overflow Error

Wednesday, 27 May 2009 05:46 by Jeff

Problem

Using the following tools Visual Web Developer Express 2008 and Sql Server Express 2008, when inserting a new row into my test User table I got the following error :

"SqlDateTime overflow. Must be between 1/1/1753 12:00:00 AM and 12/31/9999 11:59:59 PM"

My table definition has 2 columns 

Name:DateAdded  Type : datetime Allow Nulls : No Default Value : getdate()
Name:DateTimeStamp  Type : datetime Allow Nulls : No

 

Solution

My LINQ insert statement set

DateTimeStamp = DateandTime.Now

and assumed that SQL Server Express 2008 would handle the DateAdded column for me.

Looking at the debug I could see DateTimeStamp was set correctly and DateAdded was empty, still on the assumption that SQL Server Express was taking care of things for me.

What fixed this issue for me was going back to my .dbml diagram, selecting the definition of DateAdded and setting the Auto Generated Value property to True.

 

Currently rated 4.0 by 1 people

  • Currently 4/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   LINQ | Visual Studio Express 2008
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Thumbnailer and Lightbox Reminder

Wednesday, 8 April 2009 04:38 by Jeff

This is really posted to remind me how to use the Thumbnailer and LightBox extensions now that René Kuss's website has vanished :(

Add the commands in the src attribute and hit save after you have uploaded an image.

Example :

[thumb:height=150,link=lightbox]

<img src="/image.axd?picture=2009%2f4%2fzembian-error-google-chrome1.jpg[thumb:height=150,link=lightbox]" alt="" />

See the post here to see this in action.

Be the first to rate this post

  • Currently 0/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Categories:   BlogEngine.NET
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed

Updated Envision Theme with Webkit Fix

Wednesday, 8 April 2009 04:13 by Jeff

To use it unzip into your BlogEngine.Net themes directory and select the theme from the settings dropdown list

If you have problems with the theme then send me an email and I will try and help out.

Envision.1.0.zip (32.56 kb)

Tested with the following browsers on Windows XP Pro SP3 :

FireFox 3.0.8
Opera 9.64
Internet Explorer 8.0.6001.18702
Google Chrome 2.0.169.1
Apple Safari 4 Public Beta (528.16)

Currently rated 5.0 by 1 people

  • Currently 5/5 Stars.
  • 1
  • 2
  • 3
  • 4
  • 5
Tags:   ,
Categories:   BlogEngine.NET
Actions:   E-mail | Permalink | Comments (0) | Comment RSSRSS comment feed