Tag Archives: Dynamic

F#: Creating your own mocks using Object Expressions… Wow

This just in from the “Wow, I can’t believe how easy this is” update desk: You can roll your own mocks “dynamically”, even when mocking an interface. No, this isn’t too good to be true. No that weird tingling isn’t from your bullsh@# meter going off. (But you really should get that tingling checked by [...]

Leave a comment Continue Reading →

F#: Duck typing with generic constraints and why you will be speechless

So I’ve been working on a validation design that basically allows validation methods to be added to a list and then run. A small part of it: member x.Validate(valueToCheck:’a) = methodList |> Seq.map (fun (methodToRun) -> methodToRun(valueToCheck)) |> Seq.reduce (fun(outer) inner -> outer.MergeResults(inner)) What this is saying is take a list of methods, run them [...]

Leave a comment Continue Reading →

jQuery Validator: Build Rules and Messages Dynamically

Ok so here’s your typical code for the jQuery Validator: jQuery(ELEMENT_FORM).validate({ errorLabelContainer: ELEMENT_ERROR_DIV, wrapper: ‘div’, rules: { textboxEmailAddress: { required: true, email: true } }, messages: { textboxEmailAddress: { required: ERROR_EMAIL_ADDRESS_REQUIRED } }, …. As you can see, the elements like “textboxEmailAddress” are hard coded in there which means if that name changes in the [...]

Leave a comment Continue Reading →

Simple Property Merge for Python Objects

Not sure if this is useful to other people, but then again if I cared that would make me human. So here’s a quick way to merge two objects in python: def mergeObjectProperties(objectToMergeFrom, objectToMergeTo): “”" Used to copy properties from one object to another if there isn’t a naming conflict; “”" for property in objectToMergeFrom.__dict__: [...]

Leave a comment Continue Reading →

ASP.Net MVC: Upload Image to Database and Show Image “Dynamically” Using a View

Oddly enough this came about from me wanting to do this, figuring it out, and then deciding not to bother with it. So there’s a possibility this will happen to you too. Well that’s not completely true. The first half where I was uploading and showing from a database, but showing an image through a [...]

17 Comments Continue Reading →