Sunday, July 10, 2011

ActionScript Regular Expression Tester/Visualizer

Here is an improved version of my older post. Given that I already had the index of each occurrence in my hand, why not visualize it ? I chose the RichText spark component to show the matches.

I wanted to make the font style to bold and change the color to red of each match. I first thought of looping through each occurrence and concatenating to produce the RichText. But it wasn't necessary at all. The replace function of string took in a RegEx and all was easy. The replace function not only took in RegEx but also had the functionality to include the matching string in the replacement string as a parameter. That's right! The parameter is $&. See the code below. Oh and I had to handle the new lines too.

var expression:RegExp = new RegExp(txtRegularExpression.text, "g");                        
                                                
var newLineExpression:RegExp = new RegExp("\\n", "g");
                        
var stringToShow:String = txtStringToMatch.text.replace(newLineExpression, "<br/>");
                        
stringToShow = stringToShow.replace(expression, "<b><font size='12' color='#FF0000'>$&</font></b>");
                        
richText.textFlow = TextConverter.importToFlow(stringToShow, TextConverter.TEXT_FIELD_HTML_FORMAT);

Saturday, July 9, 2011

ActionScript Regular Expression Tester

Here is a little tool I created using Adobe Flex to match a string against a regular expression. It tries to mimic the functionality of matches() function in .NET Regular Expression to return an array of matches. I have another idea to improve this, so I am back to work!

Here is matches function that I used. The application is after the code.

public static function getMatches(expression:RegExp, stringToMatch:String):Array
        {
            if (!expression.global)
            {
                throw new Error("expression.global is not true!");
            }
            
            var matches:Array = new Array();
            
            var allMatchesFound:Boolean = false;
            
            while (allMatchesFound == false)
            {
                var match:String = expression.exec(stringToMatch);
                
                if(match != null)
                {
                    matches.push(match);
                }
                else
                {
                    allMatchesFound = true;
                }
            }
            
            return matches;
        }



Friday, June 24, 2011

Commit using shortcut key in TortoiseSVN (Windows)

I always needed to automate committing in TortoiseSVN. Sure, it was not a very big deal to right click a folder/file and click commit but still how awesome would it be if I just use a shortcut key?

This led me to to this stackoverflow question which basically leads to this article. Cool! Just what I wanted!
Well, not quite. It does show that we should call TortoiseProc.exe with the required parameters, but acquiring the parameters (selected folder/file) in Windows Explorer is the tricky part. Not to mention, that it should happen when a shortcut key is pressed.

Well the whole process was surprisingly easy, thanks to QTTabBar. QTTabBar is one awesome piece of software which enables, tabbed browsing for Windows Explorer which is its major feature. Plus, it has a plethora of other goodies which makes Explorer down right lame.

Take a look at those lovely Tabs!

image

So the feature that we are going to use is "Applications".

Once QTTabBar is installed, right click on the bar, and select Options.

















From Options, go to the Applications tab.

Then from there, select the button to your top right (the one without the folder icon). Type a name "Commit"

From there, set the options as follows.

1. The path should be of course where you installed TortoiseSVN.
2. Leave the arguments as it is, unless you know what other arguments you need to pass in.
3. Assign a shortcut key and presto!

C:\Program Files\TortoiseSVN\bin\TortoiseProc.exe
/command:commit /path:%s%














Here is another shortcut I created for Update.

/command:update /path:%s%













This is just the beginning, you can do MUCH more than this using the article I specified earlier.

And the fun doesn't stop there... You can automate just about ANYTHING that accepts parameters, using shortcut keys now!

Happy Committing!

Saturday, May 21, 2011

Restore the IME in Windows 7

 

It wasn’t long time since I removed the IME (Language) bar in Windows 7 task bar just to conserve space. But now I want it back. I tried everything, right clicking on the task bar and I combed the properties but yet the efforts were fruitless and I was empty handed and mad! I removed it from the taskbar, let me get it back from the task bar! Not fair!

Enough rambling… The fix was pretty easy. Head to Control Panel and then to Region & Language, on to the 2nd tab which is Keyboards and Language

image

Then click “Change keyboards” button. Then to the 2nd tab of that, which what we finally wanted “Language Bar”. And there you go! Choose Docked in the taskbar, or floating on the desktop.

image

Sunday, March 20, 2011

Best Spell Checker for Skype (or any windows application)–Tiny Spell

 

If you are that person who wants pristine clean spellings all over what you type and might jump off a river and go crazy if you make the slightest spelling mistake, you are more or less like me. I use Skype at work and the lack of a built-in spell checker  is a real draw back for me. But look no more. I have found the perfect solution. Tiny Spell.

Stays out of your way until you commit the crime and beeps (optional, but default) to let you know that you did something wrong. It will show in a tiny tooltip, the incorrect word and all you have to do is press the down key to bring a list of possible corrections. (Down key is not enabled by default)

With a plethora of features, TinySpell really does save the day. Did I mention it is free? Well there is a Pro version but seriously it wouldn’t annoy you in anyway to buy the pro version (At least not yet) and the features in the non-pro version is more than enough!

These are the settings that I have set up. I was heartbroken that I cannot get the replacement list hot key to set up to Ctrl+Space. But it is a minor flaw given that at least I can turn a blind eye to.

 Capture

 

Well the features of Tiny Spell at a glance (I have included the ones that I like)

  • Show spellings error on-the fly!
  • Show the possible corrections with a press of a key.
  • Beep on spelling error (Could be annoying sometimes)
  • Ignore password fields
  • Use either a whitelist or a blacklist for defining applications to which spell checker should be enabled/disabled.
  • Custom Dictionaries (Default is American English)

image

  • Insert the replacement word or copy it to the clipboard.
  • Add your custom words to a dictionary!!! (Brilliant!)
  • Low on resources ( It was taking about 4MB )

TinySpell+ (Pro version) includes much much more.

  • Remembers the last error.
  • Instantly displays the best spelling suggestion (No need to press down) for quick replacement
  • Add auto-replacements to the dictionary
  • Import/Export your private dictionary
  • and a bit more enhanced checking for spelling errors such as ignore ALL CAPS and words with numb3rs.

 

So if you are interested in it, go for it!

TinySpell