Visualise regular expressions with “REGEXPER”

I have just been shown this is a really cool tool (thanks Pete). Enter a regular expression into the box at the top and it will generate a visual flow diagram of what the regular expression is doing. I think this the presentation is spot on. 

The site is at https://regexper.com/

Shown below, I picked a random regular expression from the regular expression library, http://regexlib.com/ and then pasted it into the tool to see what it looked like.

Regular expression shown as a flow visual

I can see the application of this too, for quickly orientating yourself around what a regular expression written a long time ago, the intent now lost, was doing or perhaps a new one like this that has been picked up from the internet.

I can see that the tool could also be useful for finding those silly mistakes when developing expressions and finding they don’t quite do what you expected, as it will provide another view on the problem.

 

 

 

Kill hung IIS windows FTP sessions

During some integration development some FTP sessions got created with keep alive on them, but how to remove them?

List active FTP sessions in IIS

Sounds simple, but was not so easy. The live sessions are listed in IIS under the ftp site in question. Select the site in IIS and then under FTP section, there should be a FTP Current Sessions. Double click will open a window with the current sessions in it.

FtpSessions

It is possible to disconnect the sessions by right clicking them, you can restart the whole ftp site and yet the sessions will keep bouncing back, if they were set to keep alive when created.

How do we kill an active session?

To kill them Google comes up with lots of solutions for Linux and recommends the download of many different tools to do the job. Personally I don’t like installing tools on my production server, so I dug deeper, there had to be a way to do this using commands, I found there is!

List the connections using netstat

To view the sessions, open command prompt and issue the command:

netstat

netstat –ao

This will list all the sessions, look for the sessions that are of concern, the originator IP address will give them away. At the far right will be the process id for those sessions (PID). Note this for the sessions that need to go.

In our example the process on my server was PID 1672.

Kill the session using taskkill

Now we need to kill the FTP PID in windows. Use this command to do that:

pidKill

taskkill /PID 1672 /F /T

Where the command switches are F= Force and T=Terminate and 1672 is the process ID on your server that you obtained earlier from the netstat command.

Check back in the FTP sessions window and the sessions should be gone forever.

I hope this was useful to you, do comment if it was!

Visual Studio menu font size stuck after presenter mode

Presenter mode in visual studio (accessed via the quick launch at top right), allows VS to switch into a larger font layout, ideal for LCD projector presentations.

Presenter Mode Visual Studio

Whilst I had this mode on I had a crash in visual studio and had messed with other settings One of these meant that when I switched presenter mode off, it was no longer taking the font size of the Visual Studio menus back down to normal. Although for a couple of days I lived with the large fonts, I finally looked at it today. Get yourself to the following Visual Studio

Tools>>Options>>Environment>>Fonts and Colors *US spelling

or type fonts into the quick launch, quick launch is really helpful for these kind of things…

Quick Launch - To Find Fonts and Colors

Now in the options window use the drop down to to select Environment, followed by clicking the “Use Defaults” button. When the overall window is “OKed”, then Visual Studio will return to normal, this same procedure can also be used to correct any of the other options in the drop down box.

Font Settings set Environment & click Use Defaults

After doing this, presenter mode on/off works again as expected.

More about presenter mode

.NET Power Tip 6: Presenting in Visual Studio (Presentation Mode & ToolBox Snippets)

6 Quick Tips for Presenting Code in Visual Studio

Why I find Microsoft One Note handy for blogging UI stuff

There are many instances where there are UI elements on screen that you wish to include in a blog post as text content as well as an image, usually for SEO reasons.

It can be laborious and error prone to retype from the image into the blog post, so I use One Note to do the OCR for me.

Here is an example of a menu in an application I want to talk about in a blog post. So I want to convert to text so use snipping tool to grab the text as an image:

Example menu with many items on it

Paste into One Note and Right click, select “copy as text”

Menu pasted into OneNote with context menu showing "copy text from picture"

Now paste the resulting text into the editor for the blog post.

NotePad application shown with text pasted into it

Easy eh?

This also is handy for quickly pulling the text from error dialogs where there is no cut & paste, quick snip of the message, copy text from OneNote and table names, object names etc are in your paste buffer ready to hit SQL server query window, in following example, the more info button didn’t hold the info I needed and to avoid typos it was easier and quicker to just use OneNote snipping tool into OneNote and copy as text back out of image.

image

Here is the Microsoft article that alerted me to this technique…

Extract text from pictures and file printouts by using OCR in OneNote