Pages

Friday, January 20, 2017

Make your Blogger blog more responsive by auto-magically adding the SRCSET attribute to your images!

viaMacchina uses Blogger for its blogging platform. Blogger has been around for a long time, and it continues to be one of the best blogging platforms available. Out of the box, you get a mobile view to your blog. But, to be clear, even though the view is geared towards mobile devices, it is not responsive. Because of this, we are developing a completely responsive template to replace the out of the box Blogger template and mobile view.

Sunday, March 13, 2016

Breaking All The Rules with WCF Full Circle


Recently while working on a project for a large government enterprise, I encountered a problem similar, nay, exactly the same as Scott Hanselman in his post "Breaking All The Rules with WCF." From the malformed WSDL to a custom WS-Security usernameToken without a password, I was dealing with the same issue.

Scott, as always, has done an incredible job highlighting the problem, and providing a solution, so I highly encourage you to read his post. I'm writing this post to cover the one thing he missed, creating a service that can be used to test this binding configuration against.

Thursday, December 17, 2015

Open Live Writer is finally here!

image

Just over a week ago Scott Hanselman dropped the news that an open source version of the popular Windows Live Writer blogging application has finally been released. The Windows Live Writer application has been a popular publishing platform for years, but has not been updated since 2012. Earlier this year Hanselman ignited the communities interest by tweeting that talks were under way to open source the app.

The wait is finally over. You can download it here:

http://openlivewriter.org/

The application is still “old” compared to 2015 standards… but now that it is open source, I’m confident the community is going to run with it. Just in the past week the authentication for the popular Blogger service has been updated to work with the OAuth 2.0 spec.

Happy Blogging!

Monday, December 7, 2015

Let’s Encrypt!

Just last week LetsEncrypt.org entered public beta. This is newsworthy because SSL and TLS security are becoming more and more important for web applications, and the developers that create them. I won’t go into the details of the importance of using SSL and other stronger forms of transport layer security (TLS). There's a plethora of information on the web, as well as my favorite training site, Pluralsight.com. But, it suffices to say, if you are creating a web app these days, you need to be using SSL.

Monday, July 6, 2015

Asynchronous Task Containers


A few years ago I posted about using Action delegates to create logical containers to encapsulate functionality. This technique is a good example of DRY programming, and it is very useful in scenarios where you are performing similar operations with different parameters such as calling a database or service.

Tuesday, February 17, 2015

iTextSharp hates your HTML5


When it comes to PDF generation in .Net there aren't many open source projects to choose from, so by default many people choose the most popular community driven project, iTextSharp. With a relatively easy learning curve and decent API, iTextSharp can address most simple scenarios for generating PDF's, and with a little more effort can render even more complex PDF's as well. iTextSharp has been essentially free using the LGPL license, but with the introduction of version 5, the AGPL license has clouded the waters a bit.

This post addresses a potential gotcha when using the iTextSharp XmlWorker to render HTML5 to PDF's.

Monday, October 27, 2014

An argument for using WebGrease instead of the ASP.Net Web OptimizationFramework


ASP.Net Web Optimization was introduced to ease the minification and bundling of JavaScript and CSS files within your project. It's available out of the box with any new project that uses the MVC 4 project templates. In your App_Start folder, there's a file called BundleConfig where you configure what files should be minified and bundled into one file. Minification and bundling are a good thing of course, because they reduce the number of requests the browser has to make in order to retrieve the resources it needs to render a page, and they reduce the size of those resources.

But, what if you have an MVC 3 or WebForms project? What do you do? There are plenty of tutorials out there that will walk you through adding the ASP.Net Web Optimization NuGet package to your project, and the steps that it will take to get your project configured. This post however takes a different approach. What if we don't use the ASP.Net Web Optimization package at all... what if we just use WebGrease instead?

Sunday, August 31, 2014

Installing Ghost on Ubuntu 14

I've been wanting to check out Ghost for a while now, and over the weekend I decided to give it a whirl. I fired up a new VM and installed the latest version of Ubuntu, downloaded the source from the Ghost.org site, and followed the simple installation procedure. And that's about as far as I got.

Unfortunately, something within the latest release of 'buntu is not configured correctly to just install and go. After some Googlin' I found Jinyu Liu's post about setting up Ghost, and he found the magic.

Run the following:
sudo update-alternatives --install /usr/bin/node node /usr/bin/nodejs 10
It will fix the Node symbolic link, which is apparently not correct.

After running that, everything installed just as described on the Ghost.org site, and I had a new blog up and running in minutes.

Monday, August 25, 2014

SSRS Deployment Center

I recently worked on an enterprise project that involved deploying SSRS reports and data sources to different environments throughout the organization. SSRS reports have always lacked proper deployment tooling compared to other project types. The RS.EXE deployment tool from Microsoft makes it possible to create scripted deployments, but it's too complex for the average business user. And although it's possible to use it in conjunction with automated builds, it is not as easy as it should be. Because of this I created a set of GUI and command line tools called the SSRS Deployment Center that will hopefully ease future SSRS report deployments.


I've put the project onto CodePlex, so if your in need of a set of tools to make report deployments easier, check it out here:

https://ssrsdeploymentcenter.codeplex.com/

The CodePlex site has all of the information you need to download, configure and run the tools.


Monday, July 28, 2014

SSRS Nested Subreport Gotcha!

Recently I was working on a reporting solution for a client when I ran across an interesting problem. I was writing a report in SSRS using multiple nested subreports that would roll up into the report. This has been a fairly common approach that I've used in the past. The difference in this case was the number of nested subreports. Specifically I was using three levels of reports, all of which used some form of data binding. I ran into an issue where the "grand-child" report would not render.

It is easiest to explain the situation using images. There are three reports. A top level, "master" report that we will refer to as the Parent. Within the Parent report there is a sub report that we will refer to as the Child. And within the Child report there is a sub report that we will refer to as the GrandChild.

Monday, July 21, 2014

Reminder: If you develop WebForms, you should be doing this…

There are plenty of posts out there about using the aspnet_compiler.exe tool.

http://mikehadlow.blogspot.com/2008/05/compiling-aspx-templates-using.html
http://odetocode.com/blogs/scott/archive/2006/10/17/what-can-aspnet_compiler-exe-do-for-me.aspx

I’m not writing this to shed any new light on the subject. I'm writing this to remind developers that you should be using this tool… period.

Monday, April 28, 2014

Improving WebSql interaction using jQuery Deferred

I recently inherited a project that made heavy use of WebSql. Though it has been deprecated as a client side technology, this project was using it to create an offline web application that could be run on mobile devices. The immediate problem that I noticed with the project was that there was no consolidation of logic into a central JavaScript file. Each page included inline functions that essentially did the same thing, just using different queries. After profiling the site I realized that this "distribution" of logic also led to multiple instances of the web sql database being instantiated.... which, as you guessed, is a problem.

To address this issue I started by creating a wrapper for the Web SQL functions that would make it easier to work with the technology. The wrapper removes the work of instantiating the database object and managing the transaction, and it uses jQuery Deferred objects to make it easier to work with the results returned by the Web SQL calls.

Monday, February 24, 2014

A Multi-Term jQuery Mobile Listview Filter

If you've done any development with jQuery Mobile you've likely used the Listview Widget. It's a handy little component that makes rendering list data a breeze. Even better, it has a built in search filter that you can enable by simply decorating your list element with data-filter="true"



The default behavior of the Listview Widget's filter is to match on a single term. The moment you add an additional space into your search string, look out! But, if you need multi-term search behavior in your filter, it's easy to add.

Tuesday, February 4, 2014

Quick and Compliant Email Templates using Razor

Even in today's hyper connected world where you can Tweet someone's TV or Instagram your refrigerator, it seems like when it comes to business, Email is still king. If you need a simple, effective, and fast way to create a templated email in code, I suggest using Razor as your templating engine.

If you've done any MVC development since version 3, you've likely used the new Razor View Engine. Its concise and semantic, and it gets out of the way of your html. Best of all, it's not dependent on MVC, so you can re-purpose it in many different ways.

There are already a few existing projects that surround Razor templates. In this example I'm using the following project, but you can use whatever you prefer to get the job done:

https://github.com/volkovku/RazorTemplates

I like the RazorTemplates project because like Razor itself, the syntax in the RazorTemplates project is concise and semantic.

Monday, January 27, 2014

Generic Repositories Including Includes!

The real credit for this solution goes to Steve Moss. He posted this article last year:

http://www.appetere.com/Blogs/SteveM/May-2012/Passing-Include-statements-into-a-Repository

All that I've done is modified his work to fit in with the generic repository pattern that I often use.

http://www.viamacchina.com/2013/07/a-generic-repository-for-entity.html

One of the difficulties in using a repository to manage your data is that the repository itself can end up obscuring functionality from the underlying data provider. The pattern that I previously wrote about did just this. If you needed to Include relationships that were not originally established in your entity model, you had to create additional logic to retrieve that missing data.

As the Entity Framework has matured, the support for Including data from related entities has improved. Specifically, since EF 4.1, you can use strongly typed lambda's to specify relationships to eagerly load data. This, in combination with the existing string "Include", make working with entity relationships much more convenient.

To extend the original repository pattern to support dynamic includes, all that has to be done is to add an additional Select overload to the repository interface, and then make a quick change to the base class and the child classes that implement it.

1. Update the interface definition. The overloaded Select method that accepts an array of Expressions is the key.
public interface IRepository : IDisposable
{
    void Insert<E>(E entity) where E : class;

    void Update<E>(E entity) where E : class;

    void Delete<E>(E entity) where E : class;

    IQueryable<E> Select<E>() where E : class;

    IQueryable<E> Select<E>(params Expression<Func<E, object>>[] includeExpressions) where E : class;

    E Select<E>(object key) where E : class;
}

Thursday, October 24, 2013

Lights, Camera, Action Delegates!

I recently worked on a project that a number of other developers collaborated on. All of the contributors to the project are very smart people, and I was impressed by much of the work that they had done. But one thing caught my eye, and I want to write a post about it since there are folks out there that are not familiar with this technique.

The Func and Action delegates were introduced in .Net 3.5 and they have a variety of uses. One of the best uses that I have found for them is to separate procedural code from actual business logic. Specifically, I like to create methods that accept an action delegate to control database, Entity Framework, or Linq to Sql contexts, and WCF service operations.

In the project I was working on I repeatedly found classes in the data layer with code like this (in this example a connection object has already been created and passed into the class) :

IDbCommand dbCommand = connection.CreateCommand();
dbCommand.CommandText = "Command_Text";

try
{
    if (dbCommand.Connection.State == ConnectionState.Closed)
        dbCommand.Connection.Open();

    dbCommand.ExecuteNonQuery();
}
catch (Exception ex)
{
    Log.DefaultLog.WriteVerbose(ex.Message + Environment.NewLine + ex.StackTrace);
    throw ex;
}
finally
{
    if (dbCommand != null && dbCommand.Connection != null && dbCommand.Connection.State == ConnectionState.Open)
        dbCommand.Connection.Close();
}

Friday, August 16, 2013

SSIS and SharePoint List Sources with Lookup Fields

If you are not familiar with the Microsoft SQL Server Community Samples: Integration Services site, then I recommend that you check it out:

https://sqlsrvintegrationsrv.codeplex.com/

The site contains excellent SSIS samples and documentation on how to build solutions for everyday problems using SSIS. One of the most useful samples covers using a SharePoint list as a data source. A special SSIS Data Adapter project has been created and packaged so that you can run an installer and then use SharePoint lists in your SSIS package. The project can be found here:image

https://sqlsrvintegrationsrv.codeplex.com/releases/view/17652

After following the installation procedure you end up with a SharePoint List Source and SharePoint List Destination in your toolbox.
You can then use these sources and destinations in any Data Flow Task.
image

While using the SharePoint List sources today I ran into an issue using a lookup field. Essentially, my package was copying data from a SharePoint list into a local database table. The data exposed by the List Source included the internal SharePoint lookup value.image Essentially, it was including the field type and the separator (in this case ‘string;#’), which I did not want in my table.

There is an easy fix to remedy this situation though.

Thursday, August 8, 2013

SharePoint RenderingTemplate Gotcha!

Recently when working on a SharePoint 2010 project I let a minor mistake cause a great deal of frustration. I was creating a custom field that used a custom rendering template. I have done this before, but I guess on this day my mind was in WebForms land and I ended up with a solution that would deploy, but when I went to access my custom field, it would not render.

Here is a picture of my template… can you see the problem?

image

I had included the button OnClick call in the control markup. If you do this, your template will not render because it does not know how to wire up that event to it’s respective event handler. Take note of the Control declaration. Unlike normal ASP.Net User Controls, there is no reference to a Code Behind or Inherited Type… therefore… any events that need to be wired up will have to be done in your RenderingTemplateControl class file, and not in the markup!

I hope this helps!

Friday, August 2, 2013

The Changeling

Today’s society is moving faster than ever, and much like the rapidly evolving technology that we depend on, we ourselves are evolving faster and faster. Not physical evolution mind you, but mental evolution. Our minds are under enormous pressure to adapt, change, and evolve in order to keep pace with the ever-changing landscape that is modern life. Technology is driving this change, and those people who work with technology are most influenced by this “Hyper-evolution”.
The saying:
“it’s not what you know, but who you know”
…is still true in many ways, but the new world order requires a new saying:
“It’s not what you know, it’s what you can learn”