Joben.Rara.blogs(".NET")

There are two ways to write error-free programs; only the third one works.
Visualizing RegEx

I'm a big fan of visualization. Seeing my del.icio.us feed for the day, I saw this RegEx visualizer built by Oliver Steele. It's not meant to be a regex workbench or validator (It does not recognize certain character ranges like [1-5] or qualifiers like {1,3}). Still, its educational and just reading "non deterministic finite-state automaton" brings back memories of Chomsky and grammars and hanging on to dear life to get a 3.0 :-)

I still have my book "Introduction to Automata Theory, Languages and Computation." As a wise professor used to say to us in class, "Reading (esp. difficult text) stretches the mind". I keep it mostly to intimidate and appear smarter ;-)

Posted: Jan 17 2008, 08:57 AM by velocity | with no comments
Filed under:
Software Estimation Tool - easy to use. requires little input. quick and definitive.

Forget Function Point Analysis. Tell Steve McConnell to stuff his book someplace dark.

This really works very well.

Software Estimation Tool

Ruby phone in question

I'm meeting John Lam sometime this month... (ok, me and about 100 others Applause). I'm attending his talk on Dynamic Programming Languages for the Web a.k.a IronRuby, IronPython on Silverlight. If you want to ask him a "phone in" question, let me know so I can make a list.

Posted: Jul 11 2007, 04:54 PM by velocity | with 4 comment(s)
Filed under: ,
A sample game using Silverlight

Tim Heuer blogs about the experience of Terralever, a .NET shop who currently produce interactive games based on Flash. They wanted to see if Silverlight can be used to build the type of interactive games they have been building. The end-result is Zero Gravity. They even made their character, Lt. Bennett, "social network aware" so that you can add him to your Facebook, MySpace, and even Twitter.

Read more about it here -> silverlight: who needs inertia, introducing lt. bennett

About the game. I got to level 8 (teleportorama). I'm not sure if I hate the music though.

Posted: Jun 27 2007, 07:48 AM by velocity | with no comments
Filed under:
Ruby on Rails envy ads

I don't know if you've seen these, its RoR vs. PHP/Java set into the famous "I'm a PC, I'm a Mac" ad format. I found about 4 of these. here, here, here

 

Bug Bash Comic

Funny but true. :-)

Recycling: Short Introduction to Regular Expression

I recently wrote a short article as an overview to why regular expressions should be in every developer's toolbox. I actually left the real discussion of regex to other experts so I used a lot of link-love. [:-)]

Seeing that Mike Malone posted an advanced regex article, I decided to put up that short intro here.

What are regular expressions and why should I (a.k.a. developer) care?

If you’re looking for a definition, try this http://en.wikipedia.org/wiki/Regular_expression .

However I think it’s better to show you rather than tell you what a regular expression is.

What if you wanted to search your code for all instances of btn_Ok, btn_Cancel, btn_Reset and change them into OkButton, CancelButton, ResetButton. Looking at the task, you’ll see that it’s a fairly simple pattern and you can do this with three runs of Find-and-Replace. But what if you had to change 10 of these? 100? Suppose there was a way to do this with just one run, would you like to know how?

The answer would be “Use a Regular Expression (during a Find and Replace)”.

Assuming that our favorite code editor was capable of using a standard regular expression, what would the “pattern matching language” look like.

(btn_)(\w*)

this will match all strings that have the pattern btn_Ok, btn_Cancel, etc. It uses groupings so it could use it during replace.

\2Button

this replaces the strings matching the pattern with the text after “btn_” and the word “Button”

Using vim, this would be :%s:\(btn_\)\(\w*\):\2Button:g

In Visual Studio, the syntax is a bit different. I’ll mention why later on.

{btn_}{:a*}

\2Button

Find-And-Replace Dialog

Regular expression only requires you know a few rules to get you started. Check out The absolute bare minimum every programmer should know about regular expressions as a starter.

Pattern matching is not only useful for find and replace, you can also use it to validate user input. Validate User Input with Regular Expressions (VB.NET)

The following links have sample regular expressions found in input validation scenarios like a valid email, a valid Telephone number, a valid URL, etc.

5 Regular Expressions Every Web Programmer Should Know, Regular Expressions that are good to know

Learn about regular expressions in .NET

MSDN Webcast: Using Regular Expressions (Part 2 of 2): Metacharacters (Level 200)

Regular Expression Language Elements in the .NET framework

.NET Developer's Guide to Regular Expression Examples

MSDN forum on Regular Expressions

Use regular expressions in Microsoft Word

Add power to Word searches with regular expressions

Putting regular expressions to work in Word

Test your regular expressions with these online tools.

Regular Expression Tester (dotnetcoders.com)

Regex Tester (regexlib.com)

Or you can download Expresso, a tool “useful for learning how to use regular expressions and for developing and debugging regular expressions prior to incorporating them into C# or Visual Basic code.” It can even generate the proper C#, VB, and Managed C++ code for the regular expression you’re testing.

And Visual Studio does not play nice

The Visual Studio IDE and Regular Expressions details how Visual Studio supports regular expressions in its find-and-replace but uses a different “dialect” of regular expressions. (Bad VS, bad!). Michael Flanakin posts a collection of Regular Expressions for Visual Studio Code Analysis that uses Visual Studio’s particular syntax. Here’s a beginner’s guide to using  VS Find and Replace with regular expressions.

Setting Proxy settings in IE using PowerShell

Whenever I go to a client and need to plugin to their network, I would find myself typing in proxy settings to get internet access. In IE, that would be in Tools -> Internet Options -> Connections -> LAN Settings. When I'm back in the office and plugged in to my corporate network, these settings get overridden to valid values in my corp network. Given that I regularly visit my client, you can see how I have to do this dance every now and then.

So out with my PowerShell toolbox to hammer together my "set-proxysettings.ps1" script.

First, I had to find where IE stores these settings in the registry. I used regmon for that.

Once I had the registry settings, the rest was easy.

cd HKCU:\"Software\Microsoft\Windows\CurrentVersion\Internet Settings"

set-itemproperty . ProxyEnable 1
set-itemproperty . ProxyServer <proxy server:port>
set-itemproperty . ProxyOverride "<local>"

new-itemproperty . AutoConfigURL
set-itemproperty . AutoConfigURL <autoconfig url>

So whenever I'm at my client's site, I just run my powershell script to set my proxy settings.

For an excellent resource on learning PowerShell see Mastering PowerShell in your Lunch Break

Posted: Jun 23 2007, 12:34 PM by velocity | with no comments
Filed under:
DLR on Mono

Hey Cruizer, DLR is now on Mono. Smile

It’s now official. Thanks to Zoltan Varga’s recent check-in to SVN, Mono now successfully runs IronPython 2.0A1/DLR,


[mdavid@domU-12-31-37-00-03-10 Debug]$ mono -V
Mono JIT compiler version 1.2.4 (/trunk/ r77478)
Copyright (C) 2002-2007 Novell, Inc and Contributors. www.mono-project.com
        TLS:           __thread
        GC:            Included Boehm (with typed GC)
        SIGSEGV:       normal
        Architecture:  x86
        Disabled:      none
[mdavid@domU-12-31-37-00-03-10 Debug]$ mono ipy.exe IronPython console: IronPython 2.0A1 (2.0.10427.02) on .NET 2.0.50727.42 
Copyright (c) Microsoft Corporation. All rights reserved.
>>>
[Mono:DLR] Hello, Dynamic Language Runtime-enabled World!
 
Name game on SilverLight

Cruizer has a point, "SilverLight" really does sound like a play on "Flash". I never thought of it that way. I guess I'm losing my sense of fun. ~Groovy

Names aside, I think looking at SilverLight just from a "Flash" angle is missing the exciting stuff. I'm not too pumped up about having another "media player" or animation engine. (That is a topic for a different post) 

What I'm really excited about is its support for dynamic languages. To think that they could shrink the .NET runtime to around 4MB and still have it support a lot of useful namespaces is amazing.

Looking at the VB Team's blog on SilverLight support for "VBx", the runtime would support some generic collections (List & Dictionary) and even LINQ over objects while still including most of the "well-loved" VB functions. I think they have really done well in shipping out a well-factored .NET framework including "Microsoft.VisualBasic.dll"

I'm not a VB guy and I'm experiencing "DLR envy" as I code in C#. So I'm really looking forward to IronRuby. I've never really played with IronPython (What about Boo?). Nothing against VB/Python, it's just personal preference and a personal sense of "nice code".

Posted: May 17 2007, 04:09 AM by velocity | with 1 comment(s)
Filed under: ,
How Did We Come Up With Silverlight?

Read the different names they were considering before settling on Silverlight.

This is amusing. You can clearly see "geek" written all over with some smart ass ones. I seriously think MS needs a shot of "cool". Silverlight is ... well... just alright.

Link to Tim Sneath : How Did We Come Up With Silverlight?

Posted: May 16 2007, 12:49 PM by velocity | with 1 comment(s)
Filed under: ,
"Clean up sources before packing them" by SBC Packers

I recently did a walkthrough of the Web Service Software Factory for a group of developers. They are considering its use for their Web Services development. I used the accompanying Hands-On-Lab for the exercise and made some minor modifications to make it "fit" their current environment.

After the walkthrough, I needed to send them a copy of the HOL including the changes I made. That should be easy enough, right? Compress and Send. First, I need to delete all the \bin and \obj directories to keep the compressed file's size to a minimum. Problem is, there are about 10 exercises and each of the solution folder is about 3 levels deep in each exercise folder. I'm lazy so I need to find an easier way. I could have used "Clean Sources" but that would mean running away from a good challenge of doing the same thing using PowerShell [:-)].

Here's my PowerShell script for deleting the \bin and \obj directories under all those solution folders.

The canonical version

get-childitem * -recurse | where-object { $_.PSIsContainer -eq $true } | where-object { $_.Name -eq "bin" -or $_.
Name -eq "obj" } | foreach-object { remove-item -path $_.FullName -recurse -whatif }

This should read like this: "Get everything in this directory and its sub-directories. Select Items which are containers (a.k.a. directories). Select folders whose names are "bin" or "obj". For each folder, delete the folder and all the files/folders that it contains.

The "readable" version (using aliases)

dir * -recurse | where { $_.PSIsContainer -eq $true } | where { $_.Name -eq "bin" -or $_.Name -eq
"obj" } | foreach { remove-item -path $_.FullName -recurse -whatif }

BTW, remove the -whatif in the end if you actually want the command to execute. Keeping the -whatif in allows you to "see" what would happen without actually executing the command.

Groove to Snap's I've got the Power [;-)] Man, I'm really showing my age.

Posted: May 15 2007, 05:43 PM by velocity | with 3 comment(s)
Filed under:
PowerShell Links Roundup

Link #1

Scott Hanselman writes about a Reflector add-in that outputs PowerShell Code

The one I've been messing with for the last few weeks is the PowerShell Language Add-in. Reflector can "decompile" (not the correct word) the IL within an assembly and show you the "intent" of that IL in any number of languages like C#, VB, Delphi, etc. Daniel "kzu" Cazzulino has created a PowerShell Language Add-in that, for the most part, shows you what the code would look like in PowerShell.

Reflector Addins and PowerShell Language Support for Reflector

Link #2

Editing PowerShell scripts - Syntax files for PowerShell

Jon Galloway has PowerShell Language Definitions for Notepad++

Peter Provost gives us Windows PowerShell Syntax File for vim

Posted: May 15 2007, 04:36 PM by velocity | with no comments
Filed under:
Silverlight surfing

Pardon the silver surfer tagline, I just watched the FF trailer, and as Johnny would say "That is so cool".

Over the last week, there have been a flurry of activities in the blogspace surrounding Microsoft's announcement on MIX. John Lam tries to come up with a way to organize all the different things being said about Silverlight and what it means to all developers.

Some highlights are:

- IronRuby is coming.

- VBx anyone?

- DLR and Iron Python/Ruby are being released under the Microsoft Permissive License (a.k.a Open Source). So Mono can just pick it up and use it without the need to re-implement anything under Mono.

All in all, I think this brings about more options/choices for developers on any side of the fence. 

Link to John Lam on Software

 

del.icio.us tags: , ,
Posted: May 07 2007, 04:10 AM by velocity | with no comments
Filed under: , , ,
CLR meets DLR...the future is dynamic.

Jim Hugunin of IronPython fame announced at the MIX conference the DLR (Dynamic Language Runtime). While IronPython demonstrates how good the support for dynamic languages are today in the CLR, the

"new Dynamic Language Runtime (DLR) adds a small set of key features to the CLR to make it dramatically better.  It adds to the platform a set of services designed explicitly for the needs of dynamic languages.  These include a shared dynamic type system, standard hosting model and support to make it easy to generate fast dynamic code." 

"these features enable all of the dynamic languages which use the DLR to freely share code with other dynamic languages as well as with the existing powerful static languages on the platform such as VB.NET and C#."

The first four languages include Python, Ruby (sweet Smile), JavaScript, & Visual Basic. Silverlight will include support for these languages so for browser based applications, you will now have the chance to use your favorite language (like Ruby) in client side programming. Silverlight 1.1 Alpha already supports Python. See this "Getting Started" guide.

Would you like to see the bits? It's part of the IronPython package which you can download from codeplex.

Link to Jim Hugunin's Thinking Dynamic

More Posts Next page »