My name is Edward Tanguay. I'm an American software and web developer living and working in Berlin, Germany.


2 days ago: Oh great, another "it depends" answer, isn't anything simple anymore? http://t.co/ypAZDhvX.
3 days ago: 24K sunday training: three cold 5Ks 24:14, 26:48, 29:13, 61 days to #parismarathon: http://t.co/pRWmrVui.
3 days ago: 5th grade humor: "your arithmetic is terrible, where did you learn math? / yale / yale? what's your name? / yim yonson".
5 days ago: News in slow french: nice way to keep your french up to par: audio, transcription, hover-vocabulary: http://t.co/ykqztLlM.
5 days ago: Newsinslowenglish: nice way to improve English: audio, transcription, hover-vocabulary #tesl #esl #efl: http://t.co/ehq08wQD.
5 days ago: Overheard at home: "I like my sister 23%".
5 days ago: This is the way I used to teach German pronunciation in college, fun memories: http://t.co/eRULGfun.
5 days ago: "excuse me, but, um, your location is leaking".
5 days ago: "our vision for photography in berlin is for it to be lively, progressive and active" #berlin #photography @just4you http://t.co/0I59GQeV.
5 days ago: Facebook will eventually find a way to stamp out privacy: "everyone famous to their friends & therefore public figures" http://t.co/p4V9RLSA.
5 days ago: .@nickhoward there's a global layer of educational incompetence surfacing everywhere where people want to teach instead of help people learn.
Base code to create a simple regex unit tester Here's some base code I use when I've written a regex and need to test it with positive and negative cases as I tweak it. ![]()
using System; using System.Collections.Generic; using System.Text.RegularExpressions; namespace Testreg2342 { public class Program { static void Main(string[] args) { bool unitTestPassed = true; List<string> goodEntries = new List<string> { "2008-12-22" }; List<string> badEntries = new List<string> { "2010-12-12X", "2010-12-32 12:00:00" }; foreach (var entry in goodEntries) { if (entry.IsValidDateFormat()) Console.WriteLine("ok: good entry correctly passed: " + entry); else { Console.WriteLine("**FAIL** GOOD ENTRY INCORRECTLY DID NOT PASS: " + entry); unitTestPassed = false; } } foreach (var entry in badEntries) { if (!entry.IsValidDateFormat()) Console.WriteLine("ok: bad entry corrcectly did not pass : " + entry); else { Console.WriteLine("**FAIL** BAD ENTRY INCORRECTLY PASSED: " + entry); unitTestPassed = false; } } Console.WriteLine(); if(unitTestPassed) Console.WriteLine("unit test passed"); else Console.WriteLine("UNIT TEST FAILED, CORRECT ALL ENTRIES MARKED **FAIL** ABOVE!"); Console.ReadLine(); } } public static class StringHelpers { public static bool IsValidDateFormat(this string purportedDateFormat) { return RegexHelpers.Matches(purportedDateFormat, @"^[0-9]{4}-(0[1-9]|1[0-2])-(0[1-9]|[1-2][0-9]|3[0-1])$"); } } public static class RegexHelpers { //use if you are expecting only one match, e.g. from "id = ???" public static string GetMatch(string text, string regex) { Match match = Regex.Match(text, regex); if (match.Success) { string theMatch = match.Groups[0].Value; return theMatch; } else { return null; } } public static bool Matches(string text, string regex) { if (GetMatch(text, regex) != null) return true; else return false; } } } |
Most Recently Added Items:
- How to call an unknown function on an unknown class with unknown parameters - php code example - added on Sunday, November 28, 2010
- How to setup JQuery intellisense in Microsoft Visual Web Developer 2010 Express - jquery howto - added on Sunday, November 14, 2010
- Simple menu site with jQuery AJAX - jquery code example - added on Sunday, November 14, 2010
- A PHP function which returns the most frequently occuring item - php code example - added on Friday, October 29, 2010
- How to create a singleton in PHP - php code example - added on Sunday, October 03, 2010
- Extension method to sort a generic collection of objects - c# code example - added on Tuesday, September 07, 2010
- A simple class that represents a matching quiz item - c# code example - added on Tuesday, September 07, 2010
- Extension method for checking regex in one line - c# code example - added on Thursday, September 02, 2010
- How to use a Dictionary<> with struct key to save a dynamic matrix of objects - c# code example - added on Sunday, August 22, 2010
- A simple jquery search machine for a web page - jquery code example - added on Sunday, August 22, 2010
- Wrapper class to simplify the creation of Excel files in C# 4.0 - wpf code example - added on Tuesday, July 20, 2010
- How to make clickable flashcards in plain javascript for your mobile phone - javascript code example - added on Wednesday, July 07, 2010
- Simple example of javascript which loads jquery locally - jquery code example - added on Wednesday, July 07, 2010
- How to stop regular expression greediness - c# code example - added on Tuesday, July 06, 2010
- How to use a generic dictionary to total enum values - c# code example - added on Friday, July 02, 2010
- Generic method to case-insensitively convert a string to any enum - c# code example - added on Friday, July 02, 2010
- How to create a TextBlock that has various font formatting in code behind - silverlight code example - added on Wednesday, June 30, 2010
- How to encode binary files to text files and back to binary again - c# code example - added on Wednesday, June 30, 2010
- How to use a custom parameter struct to pass any number of variables to constructors of similar classes. - c# code example - added on Saturday, June 26, 2010
- How to make a class that renders an interactive FrameworkElement and interacts with the View - silverlight code example - added on Tuesday, June 15, 2010
- How to set a nullable type to null in a ternary operator - c# code example - added on Tuesday, June 15, 2010
- How to override events in inherited classes - c# code example - added on Friday, June 11, 2010
- How to strip off e.g. "note:" and "firstName: " from the left of a string using regex - c# code example - added on Tuesday, June 01, 2010
- How to create and subscribe to custom events using EventHandler - c# code example - added on Wednesday, May 12, 2010
- Code base for asynchronously loading and caching dependent data in a Silverlight app - silverlight code example - added on Wednesday, May 05, 2010
- Function to trim the preceding and trailing blank lines off an array - php code example - added on Sunday, May 02, 2010
- How to load and display the contents of a text file with AJAX/Jquery - jquery code example - added on Sunday, May 02, 2010
- How to use fopen() to create a proxy site to read any website content into AJAX - php code example - added on Sunday, May 02, 2010
- Code base for loading and caching external data into a silverlight app - silverlight code example - added on Friday, April 30, 2010
- An UpdateSourceTrigger workaround for Silverlight - wpf code example - added on Sunday, April 18, 2010
