web 2.0

Getting Started With The Arduino

As an engineer, I constantly feel the need to learn new things in order to keep the "saw sharp". Since I write code for a living, I often feel dissatisfied by the notion that everything I create is "virtual". The only way to interact with the things that I create are with a keyboard and mouse. The thought of this often makes me wonder if I would have been happier in a profession where I built things with my hands. People tend to appreciate things more that they can hold and physically interact with. So naturally, this led me to the idea of "How can I make software take on a more physical presence?". Of course I immediately thought of robotics, so I typed the term "robotics" into Google and I discovered the term "Physical Computing". According to Wikipedia, the definition of physical computing is: Physical computing, in the broadest sense, means building interactive physical systems by the use of software and hardware that can sense and respond to the analog world. While this definitio... [More]

Tags:

Arduino | Tech

Adding Export Capabilities to the Razor WebGrid

When MVC first came out I really missed having a native grid control. Now a few years later, we have grid support again! In case, you didn’t know the Razor WebGrid was included in the System.Web.Helpers assembly which shipped with ASP.NET MVC 3. Over the years, I have sampled a variety of grid controls such as jqGrid, the Infragistics grid control and the MvcContrib grid. Each grid control has its benefits and disadvantages but I think the new WebGrid offers a clean API which makes development tasks simple. Here is a screenshot of what the grid looks like: To display a grid on a razor view page, you basically create a new grid object, assign some properties and then call the GetHtml helper method. Here is an example: @{ var grid = new WebGrid(canPage: true, canSort: true, rowsPerPage: Model.PagingInfo.PageSize, ajaxUpdateContainerId: "grid"); grid.Bind(Model.Data, rowCount: Model.PagingInfo.TotalItems, autoSortAndPage: false); } @grid.GetHtml( column... [More]

Tags:

ASPNet | MVC | Tech

Building MVC Select Lists The Easy Way

It is common to have a view model that contains a list of select list items ( IEnumerable ). However, I get a little annoyed when I see a select list item getting initialized like this: Widgets = db.Widgets.FindAll().Select(x => new SelectListItem() { Text = x.Name, Value = x.Value }); Although this is legal syntax its just a little bit too ugly for my liking. In an effort to make life simpler I came up with the following helper class: public static class SelectListFactory { public static IEnumerable<SelectListItem> BuildList<T>(IEnumerable<T> items, Func<T, SelectListItem> func) { return items.Select(func); } public static IEnumerable<SelectListItem> BuildList<T>( IEnumerable<T> items, Func<T, string> text, Func<T, string> value = null, Func<T, Boolean> selected = null) { return items.Select(x => new SelectListItem{ ... [More]

Tags: ,

ASPNet | MVC | Tech

MVC–Showing a setup screen on the first run

Recently, I participated in a project where I helped to build a website in Orchard. One of the things that I admire (and there are many) about Orchard is the setup screen that appears the first time you run the site. It’s a nice touch and really makes the site easy to configure. No need to tweak a web.config, create a database or read a 20 page setup guide on how to get started. You just fill out the form and the site is ready… Of course, I wanted to build something similar for my open source project WeBlog. First, I tried to reverse engineer the orchard code. However, orchard uses a lot of dynamic types and things are heavily abstracted so it was hard to re-use their code for my purposes. Next, I tried to Google for a solution but the only thing I could find was this stack overflow post. My first thought was to create a base controller class and override the OnActionExecuting method. In that method I could force a redirect if the site was not configured yet. However, I ... [More]

Dapper.Net - A Micro ORM that puts you back in control

Its fun to reminisce about how database access has evolved over the years. In the early days I used to write parameterized SQL statements directly in my code. Eventually that evolved into using stored procedures. Mainly because by using a stored procedure I could change the way data was gathered without recompiling my source code. Eventually, I abandoned stored procedures altogether when LINQ to SQL was released. Finally, if we fast forward to the current day, my preferred method of accessing data is with EF code first. EF Code first is great because I can spend even less time managing my database and more time solving business problems. With the level of abstraction getting higher and higher it makes you wonder if perhaps the next generation of developers will not even write T-SQL anymore. They will probably laugh at us old timers when we talk about stored procs and T-SQL.  Wait! Back up a minute! Just because we have abstracted ourselves from the database doesn’t mean t... [More]

Tags:

dotNet | SQL | Tech