Browse by Tags

Tagged Content List
  • Blog Post: Regex based Lexer with F#

    This lexer allows you to define your regular expression based rules in a very declarative way using F# computation expressions. open Lexer let definitions = lexerDefinitions { do ! addNextlineDefinition " NEWLINE " @" (\n\r)|\n|\r " do ! addIgnoreDefinition " WS " @" \s " ...
  • Blog Post: I finally got fed up with Enum.Parse

    I don’t know why I didn’t do this long ago, but I am done writing this: var val = (SomeEnum)Enum.Parse( typeof (SomeEnum),”someString”); I have typed this too many times and it annoys me.  I wrote a small extension method on the string type to make this better: public static...
  • Blog Post: DRY and Unit Tests don’t mix well

    When reading source code, I sometimes come across unappealing code(sometimes even my own).  However, there is one kind of “bad code” I see quite frequently.  It is a set of unit tests which have had the DRY (Don't Repeat Yourself) principle unduly forced upon them.  DRY is the idea that...
  • Blog Post: A functional take on console program loop in F#

    Often when learning a new technology I start with a simple console application in which the program is run in a loop it continues to prompt you for more input until you give some command like quit or exit or whatever you choose: Enter input: someInput someOutput Enter input: otherInput someoutPut Enter...
  • Blog Post: Synchronizing Scrollbars using JQuery

    I just wrote this simple plugin for JQuery which lets you synchronize the scroll bars of any collection of elements.  This lets you move the scrollbar of one div it have the scrollbars’ of the rest of the divs move the same exact amount. Here is the code: 1: jQuery.fn.synchronizeScroll = function...
  • Blog Post: Prime Factorization using Unfold in Haskell

    I randomly yesterday started thinking about the unfoldr function in Haskell while working out at the gym (how nerdy is that, I am lifting iron but thinking of functional programming). Unfoldr take a single and an unfolding function and turns it into a list (the opposite of fold). At the gym I was thinking...
  • Blog Post: Code Assumptions

    My co-workers and I recently came across a piece of code which exposed some assumptions we had about the “correct” behavior of two functions; these assumptions turned out to be false.  The code dealt with determining if the IP of a  request coming into to a website matches a certain range of...
  • Blog Post: Snippet Designer 1.1 Released

    I just released Snippet Designer 1.1.  This is not a major release but just some bug fixes and often requested changes to make the snippet designer more useful.   Some of the most notable changes are: Languages Service are turned OFF by default now.  Since I was unable to figure out a...
  • Blog Post: Model Binder

    When working with a multi-tier application I often find myself converting from one of the tiers object models to my own similar (but often different) model.  I often write code that would set one by one each property from a web tier object to my object.  In order to make this easier I wrote...
  • Blog Post: Updated JQuery ResizeComplete method

    I made 2 slight changes and I think it works pretty well now. I now detect if the browser is Firefox and use the regular resize event since its resize behaves like a resizeComplete. I also modified the timeout a bit since I think 100 ms might be too small. Here is the updated version: 1: jQuery.fn.resizeComplete...
  • Blog Post: Rough draft of a new JQuery method

    I have run into issues recently with the browsers' implementation of the resize event on the window. Opera, Safari, IE and Firefox all have different behaviors when this event is fired. Firefox only fires it when you release the mouse. IE fires this event many many times while resizing. Safari will fire...
  • Blog Post: Parameterized State Transformer Monad in F#?

    I have have been playing around with F# and I decided to create a state monad. This worked out really well since I was able to leverage the F# computation expressions . I then decided to try to extend this and make it more general by creating a parameterized state transformer monad. This is a state monad...
  • Blog Post: SQL CE 3.5 with LINQ to SQL Revisited

    A few days ago I made a post about using SQL CE 3.5 with LINQ to SQL . I described a way to use connection pooling with SQL CE. A gracious blog reader (Mike Brown) pointed out a way I could make my solution much simpler by using the [ ThreadStatic ] attribute. I never heard of this attribute but it is...
  • Blog Post: SQL CE 3.5 with LINQ to SQL

    Using LINQ to SQL with SQL CE 3.5 can be a bit of a challenge. First off, the LINQ to SQL Visual Studio designer doesn't support SQL CE so you need to run sqlmetal from the command line to create the object model (or write it by hand). Once you get past this point then you can use LINQ to SQL the same...
  • Blog Post: CollectionView.DeferRefresh() : My new best friend

    Well, maybe not best friend but its a nice function.  When working with bound collections in WPF you often end up dealing with a CollectionView .  This is the MSDN documentation description of a CollectionView : You can think of a collection view as a layer on top of a binding source collection...
  • Blog Post: I started playing with F#...

    I decided to do some Project Euler problems using F#.  So here is my first one, Problem # 31.  Nothing in this solution really shows off anything special about F# but you have to start somewhere ;)   1: #light 2:   3: let rec combos amt (denoms: int list) = 4: if amt...
  • Blog Post: The two most important WPF Tools

    I have been working a lot with WPF and I found the following two FREE tools to be extremely helpful. The first is: XamlPadX - ( http://blogs.msdn.com/llobo/archive/2007/12/19/xamlpadx-v3-0.aspx ) This is an enhanced version of XamlPad which comes with the .NET SDK. This is a light weight tool...
  • Blog Post: Foreach is Duck Typed!

    I thought I know how the foreach construct worked under the covers. I figured the compiler would check if the type being iterated over implement IEnumerable or IEnumerator. And if so it will call MoveNext and Current to loop over the elements. But then I read this: http://blogs.msdn.com/kcwalina/archive...
  • Blog Post: Writing a Regular Expression parser in Haskell: Part 4

    With the previous two modules in place we are now set up to use a DFA to match against a string.  In my implementation I support either a greedy match or an short match.  In a full featured regular expression engine this ability to choose greedy or not would be per operator but for simplicity I have...
  • Blog Post: Writing a Regular Expression parser in Haskell: Part 3

    The third module in the simple regular expression parser is called: NFAtoDFA.  Which as you might have guessed, takes the NFA that resulted from the first module and converts it into a DFA.  The structure that the DFA uses is the same that the NFA uses since they are both finite state machines.   Converting...
  • Blog Post: ArgumentNullException vs ArgumentException

    Both ArgumentNullException and ArgumentException have a constructor which takes two strings. One is the name of the parameter (or argument) in question and the other is a string describing the exception. The funny/odd/interesting thing about them is that one has the opposite order of arguments. For ArgumentException...
  • Blog Post: Intro to LINQ to SQL Optimistic Concurrency

    After some investigation I feel I have a decent understanding on how LINQ to SQL concurrency works. LINQ to SQL uses optimistic concurrency which means that it never takes an exclusive lock on a table.  It caches the information you are working with and then (by default) when you submit changes verifies...
  • Blog Post: Breadth First Tree Traversal in Haskell

    As my interest in functional languages has grown, I have become increasingly interested in using them to implement algorithms which I can already write with imperative languages. For example, I was taught to implement (and I assume most other people as well) a breadth first traversal of a tree using...
  • Blog Post: Closures and Pass by Reference

    What do you think the following code will do? Compile time error Run time error Work fine 1: static void Main( string [] args) 2: { 3: int x = 10; 4: int y = 5; 5: Swap( ref x, ref y); 6: } 7: 8: 9: static void Swap( ref int x, ref int y) 10: { 11: int temp = x; 12: x = y; 13: y = temp; 14: Func<...
  • Blog Post: The J Language

    I have been experimenting with this programming language called J . J is a full featured programming language capable of doing anything your more conventional language do. What makes J different is how it approaches solving problems. All functions (called verbs in J) can be applied to any n-dimensional...
Page 1 of 2 (42 items) 12