Wijmo

I just found out about Wijmo. Wijmo is a javascript widget library that utilizes jQuery, jQuery UI and knockoutjs. Using jQuery UI allows the widgets to be themed easily with any of Wijmo’s premium themes, the canned jQuery UI themes, or rolling your own with theme roller.

Wijmo costs if you want to use it in a commercial application, but they do have an open source option that allows for use in GPLv3 projects.

OMGWTFIIS?!?!

scream and shout

I am working on some automation to allow a large zip file to be uploaded, extracted, parsed, etc. While working locally, things worked fine. Once I pushed to our dev server, it all fell apart.

The file is 30MB – I did not really think that was too large, but apparently there is a nice, hidden gem in IIS – an artificial limit of 30MB. It was driving me nuts because I could upload a bunch of other zip files, but not the one I needed to. That led me to think it had something to do with the size, and lo and behold that is it.

I found the magic google incantation to find a post on IIS7 file upload size limits. This post gives a great overview about the silliness that exists, and a nice site-level solution:

<system.webServer>
  <security>
    <requestFiltering>
      <requestLimits maxAllowedContentLength="524288000"/>
    </requestFiltering>
  </security>
</system.webServer>

A commenter outlines a solution using the IIS7 snap-in, but I am okay with the web.config method. For completeness, here are the steps:

  1. Open IIS7 snap-in
  2. Select the site to enable large file uploads
  3. Double click “Request Filtering” in the main window
  4. Right-click the dialog window and select “Edit Feature Settings”
  5. Modify the “Maximum allowed content length (bytes)

So, at least I got everything working, but I sure wasted a whole bunch of my time before I found this…

photo by: mdanys

EF and “dynamic” data

We use EF for our e-commerce website, and we have the need to get some data out in the form of reports. Ideally I’d like to be able to basically write up a report query and have the data come out on the other side. However, with EF it isn’t necessarily that simple.

I really don’t want to have to go through all the ceremony of creating models, mapping classes, services, etc. I’d like to keep it pretty simple with a service that can give me back the data I want, then I can use it in a Google Chart or a jQuery datatable or something on the client side. I want the server-side to be basic, and then I can focus on the client-side to give a rich report experience.

I did a quick search and came up with a couple of interesting options. The first is a way to dynamically query views. It sounds very interesting, but it looks like it isn’t quite what I am looking for. The post leaves things a little open-ended, but it looks like the views he is querying already have all the strongly-typed stuff needed and the code just performs dynamic queries against those static objects. I could be wrong though as there is not concrete example of how it is used, just the theory behind all the dynamic wackiness going on.

The next option looks a little more like what I am looking for – it returns a dynamic object using SqlQuery. The code in the post is a little verbose for my taste, but a commenter converted the code into an extension, and I like that idea a lot better. I put his code into a gist.

After looking into the options, I think that maybe the notion that I have to stick with EF is just holding me back. I am very familiar with Massive and have used it and enjoy using it. It is a single class file, and maybe it is just the thing I need to get this report data out of my database easily – which is the idea behind Massive!

Coalesce operator basic example

There was some null checks for trimming that were added in our codebase like this:

if (model.SearchEmail != null)
    model.SearchEmail = model.SearchEmail.Trim();

A tiny bit “easier”* alternative would be to use the coerce operator:

model.SearchEmail = (model.SearchEmail ?? String.Empty).Trim();

It is a little less typing and a single line. I think it is still pretty obvious what you are trying to do, so if you like it, use it.

If you don’t already know about coalesce, it is basically “if the value is null, use this other value”. So in the above, if model.SearchEmail is null, then use String.Empty. Then, trimming String.Empty would return null. But, if model.SearchEmail has a value, it gets trimmed and everything works as expected.

If you are interested in more examples/info, check out this StackOverflow Q&A.

* I say “easier” because it is my preference for terse yet understandable code. It may not be your preference, and that is cool

WebAPI – Y U NO DELETE?!!

37098508

Ok, silliness aside, WTF? At first I thought I was going insane. After wasting about 20 minutes thinking it was my fault, I realized it had to be something else. Well, it turns out that, by default, IIS Express doesn’t handle PUT and DELETE. So it isn’t a WebAPI thing, it is an IIS Express thing, but it isn’t immediately obvious what the problem is.

A little googling, a little reading, and I stumbled upon this post that explains how to update IIS Express (as well as IIS proper):

  1. Open the IIS Express config file (located at C:\Users\\Documents\IISExpress\config\applicationhost.config)
  2. Find the key “ExtensionlessUrl-Integrated-4.0”
  3. Add PUT and DELETE to the “verb”
<add name="ExtensionlessUrl-Integrated-4.0" 
     path="*." 
     verb="GET,HEAD,POST,DEBUG,PUT,DELETE" 
     type="System.Web.Handlers.TransferRequestHandler" 
     preCondition="integratedMode,runtimeVersionv4.0" />

CodeRush with Refactor! Pro

I am stoked! I was finally able to get a CodeRush with Refactor! Pro subscription. I cannot wait to get started with it.

I was a long time CodeRush Xpress user, and I have to say for a free tool, CodeRush Xpress is pretty awesome. I remember doing some pair-programming a while back with one of my co-workers and he saw me use a refactor. He stopped me and said, “how’d you do that?” I showed him CodeRush Xpress and he was off to download his own copy.

A couple months back I was finally able to make the jump to VS 2012 from VS 2010. As much as I enjoyed CodeRush Xpress, there were some stability issues that I had with VS 2010, and I think Xpress contributed to those issues. I am a bit of an “extension junkie”, so I am not sure if it was a combination, or maybe it was just some other plugin entirely. I could be giving Xpress a bum rap, so please try it out for yourself. It is free after all…

When I started my 2012 adventure, I decided to scale back the extensions, but I really did miss CodeRush Xpress, so I finally worked out purchasing a Pro license. DevExpress customer service is awesome. I had some questions and concerns, and they were totally responsive and willing to work with me. Special thanks to Vache – I really appreciate it.

But don’t just take my word for it. From devlinliles.com, who’s post helped sway me towards getting a Pro license even though he ultimately chose ReSharper over CodeRush:

I completely agree on the support side of things. CodeRush has this nailed. I tweeted some problems and got *positively* bombarded with answers and resources. The support they offer is second to (none) with tooling out there.

So, my next adventure begins. I cannot wait to get started. I am sure I’ll have plenty of follow-up posts to rave about all the great features of CodeRush!
🙂

SVG Patterns

SVG Patterns is a great site with many examples of using SVG patterns for backgrounds.

SVG patterns have the benefit of being scalable (they are vector graphics) while typically being smaller than bitmap graphics. They also are have more browser support than CSS3 gradients.

The site links to code samples for each pattern on Codepen so you can test them out, fork them and play with them, etc.

CSS3 Patterns

The idea behind SVG patterns was inspired by CSS3 Patterns, which is pretty cool.

Shortcodes in widgets

I just switched to this new theme, and I wanted to transfer over the customizations I made to the last theme. I was a WordPress n00b when I started the blog, and I did not initially use widgets. To transfer all my customizations over, I knew widgets would be the way to do it.

I have the Last.fm plugin, and I made mods to my sidebar.php file to include it before. All I needed to do this time was put the shortcode in a text widget, right? WRONG! I knew there had to be a way.

A quick google revealed this post on using shortcodes in widgets. It turns out it is super-simple, but does require editing the functions.php file. You simply add the following:

add_filter('widget_text', 'do_shortcode');

WCF Validation

The great thing about writing code is that you are almost assured that whatever you think would “be cool” someone out there in the world has written already. For example, I wanted to use DataAnnotations on my WCF model for validation. Silly me, I thought it would just work. I mean, it makes sense, right? Well, while it doesn’t work out of the box, it is something that makes sense, so someone wrote the code already!

I found this post over at DevTrends. It explains the logic behind using DataAnnotations for validation. My favorite part:

So a fantastic validation framework is available with .NET. All we need to do is integrate it into WCF.

Really, I am surprised this isn’t part of the framework, but whatever. Paul created a NuGet package, and that makes it so easy that it may as well be part of the framework. Thanks, Paul!
🙂