tag:blogger.com,1999:blog-30482248485186626902024-03-21T00:58:39.634-07:00A blog from Chris Brownhttp://zirafon.org/Anonymoushttp://www.blogger.com/profile/16028805125450984162noreply@blogger.comBlogger4125tag:blogger.com,1999:blog-3048224848518662690.post-45740297518840414922015-03-14T14:20:00.001-07:002015-03-15T04:03:01.571-07:00Conflicts with Umbraco 7 install and ReSharper.Im currently working on a project that abstracts <a href="http://umbraco.com/">Umbraco</a> away from the customer facing UI AKA front end. We are effectively utilising Umbraco as a service rather than as a platform. Because as a CMS, its incredibly powerful and functional but these benefits come at a cost for the customers interacting with the front end. Typically its performance but there are a whole heap of issues that effect large sites that im not going to go into on this particular blog.<br />
<br />
This post is about Umbraco 7 installation. Its an obscure one so I thought I would mention it here to aid folk in the future.<br />
<br />
Basically when you install <a href="https://our.umbraco.org/documentation/installation/install-umbraco-with-nuget" target="_blank">Umbraco from NuGet</a> and you come across the following error.<br />
<br />
<br />
<pre style="background-color: #eeeeee; border: 1px dashed #999999; color: black; font-family: Andale Mono, Lucida Console, Monaco, fixed, monospace; font-size: 12px; line-height: 14px; overflow: auto; padding: 5px; width: 100%;"> <code style="color: black; word-wrap: normal;">
Install failed. Rolling back...
install-package : Expected "$(_PublishProfileSet)" to evaluate to a boolean instead of "", in condition "$(_PublishProfileSet) And '$(PublishProfileName)'
=='' And '$(WebPublishProfileFile)'==''". C:\Program Files (x86)\MSBuild\Microsoft\VisualStudio\v12.0\Web\Microsoft.Web.Publishing.targets
At line:1 char:1
+ install-package umbracocms
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : NotSpecified: (:) [Install-Package], InvalidProjectFileException
+ FullyQualifiedErrorId : NuGetCmdletUnhandledException,NuGet.PowerShell.Commands.InstallPackageCommand
</code>
</pre>
<br />
It's a known conflict error between Resharper and the install. Further details can be found <a href="https://youtrack.jetbrains.com/issue/RSRP-419513" target="_blank">here</a>. But in brief. <i style="background-color: yellow;">Disable Resharper and try again.</i><br />
<br />
Worked for me. I believe the issue is resolved in v9 of ReSharper but further comments would be appreciated.<br />
<br />
To disable/Suspend ReSharper<br />
<br />
Navigate to: Tools -> Options -> ReSharper -> Suspend Now<br />
<br />
<table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"><tbody>
<tr><td style="text-align: center;"><a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk5sRSKWeVEZmc5Nh5eTQa-pACEmpN031NQTwOISWTew8siaterrmtJnlqU5JxtG4K1n6URmBs4TZRQow4oTF41enTgMM3tivy9FDt2VPyHKNcftZ7fqAf-YnHLQ0d1uWbk8xfaRoPP53Y/s1600/resharper-suspend.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgk5sRSKWeVEZmc5Nh5eTQa-pACEmpN031NQTwOISWTew8siaterrmtJnlqU5JxtG4K1n6URmBs4TZRQow4oTF41enTgMM3tivy9FDt2VPyHKNcftZ7fqAf-YnHLQ0d1uWbk8xfaRoPP53Y/s1600/resharper-suspend.png" height="267" width="400" /></a></td></tr>
<tr><td class="tr-caption" style="text-align: center;">Suspend ReSharper</td></tr>
</tbody></table>
<br />
<br />Anonymoushttp://www.blogger.com/profile/16028805125450984162noreply@blogger.com0tag:blogger.com,1999:blog-3048224848518662690.post-5705640180297912082015-03-03T14:58:00.001-08:002015-03-03T15:38:42.596-08:00Intro into the OWIN specification and a Hello world example of Katana<h2>
Getting Started with OWIN and Katana</h2>
<div>
Firstly, lets start by trying to identify what the <a href="http://owin.org/" target="_blank">OWIN </a>specification is. The following text is taken from <a href="http://owin.org/">owin.org</a>.</div>
<blockquote class="tr_bq">
OWIN defines a standard interface between .NET web servers and web applications. The goal of the OWIN interface is to decouple server and application, encourage the development of simple modules for .NET web development</blockquote>
Or in other words; <b><a href="http://www.asp.net/aspnet/overview/owin-and-katana/an-overview-of-project-katana" target="_blank">Katana</a>, the Microsoft implementation of OWIN, is basically an answer to <a href="http://nodejs.org/" target="_blank">node.js</a> just like the ASP.NET MVC framework was the answer to <a href="http://rubyonrails.org/" target="_blank">Ruby on Rails</a>.</b><br />
<br />
This is evident when we compare the two hello world web server implementations;<br />
<br />
<h3>
1. Node Web server initiation</h3>
<script src="https://gist.github.com/chris-brown/23aaad30f8063c1af02b.js"></script>
<h3>
2. Katana self hosting web server</h3>
<script src="https://gist.github.com/chris-brown/598a0010b43dcc605544.js"></script>
Now this is evidently a high level comparison between the 2 but it suggests my point.<br />
<br />
<b><u>Katana</u></b>, is a collection of projects for supporting and implementing the OWIN specification. The value here is that it creates an abstraction between the web server and application. Meaning it completely decouples server dependencies away from our application. This then introduces the concept of, <i style="background-color: yellow;">use what we need and nothing more</i>.<br />
<br />
Significantly it includes OWIN support for System.Web and System.Net.HttpListener.<br />
<br />
This is an obvious benefit when you review a typical .NET application and notice the dependent reference <a href="https://msdn.microsoft.com/en-us/library/system.web%28v=vs.113%29.aspx" target="_blank">System.Web.dll</a>; which is over 2.5MB and includes over 10 years of retrofitted development.<br />
<br />
Where node uses <a href="https://www.npmjs.com/" target="_blank">Node Package Manager</a>, Microsoft uses <a href="http://www.nuget.org/" target="_blank">NuGet </a>to manage these modules.<br />
<br />
For this blog post, this is where the comparison stops between these two technologies. I dont want to dwel upon it, however for further readings checkout this <a href="http://www.salmanq.com/blog/net-and-node-js-performance-comparison/2013/03/" target="_blank">performance comparison article</a>; <i>NB. At the time of this blog publication the article was over a year old so the result will no doubt vary.</i><br />
<br />
MSFT's decision to open source their forthcoming ONE ASP.NET platform has meant the open source community has supported the Katana implementation well. Significant support that you can pull down today includes;<br />
<ul>
<li><a href="https://www.nuget.org/packages/Microsoft.AspNet.WebApi.Owin" target="_blank">Web API</a></li>
<li><a href="https://www.nuget.org/packages/Microsoft.AspNet.SignalR.Owin/" target="_blank">SignalR</a></li>
<li><a href="https://www.nuget.org/packages/Nancy.Owin/" target="_blank">Nancy</a></li>
</ul>
<div>
I've used a couple of these projects on a basic hello world application. Its a self hosted project running from a console app. But a follow up post will include a Linux host. This is available on GitHub for downloading, forking, or contributing.
<br/>
<br/>
<a href="https://github.com/chris-brown/katana-web-hello-world-demo" class="btn">View on GitHub</a>
<br />
<br />
<iframe src="https://ghbtns.com/github-btn.html?user=chris-brown&repo=katana-web-hello-world-demo&type=watch&count=true&size=large&v=2" frameborder="0" scrolling="0" width="160px" height="30px"></iframe>
<iframe src="https://ghbtns.com/github-btn.html?user=chris-brown&repo=katana-web-hello-world-demo&type=watch&count=true&size=large" frameborder="0" scrolling="0" width="170px" height="30px"></iframe>
<br />
<br/>
<iframe src="https://ghbtns.com/github-btn.html?user=chris-brown&repo=repo=katana-web-hello-world-demo&type=fork&count=true&size=large" frameborder="0" scrolling="0" width="158px" height="30px"></iframe>
<br/>
<br/>
Thanks for reading. As always I would really appreciate any comments.</div>Anonymoushttp://www.blogger.com/profile/16028805125450984162noreply@blogger.com0tag:blogger.com,1999:blog-3048224848518662690.post-60418084226004879882014-12-29T06:17:00.003-08:002015-01-16T04:51:38.952-08:00Concatenating multiple rows into one column in T-SQL<style type="text/css">
pre.code{
background: #f0f0f0; border: 1px dashed #CCCCCC; color: black; font-family: arial; font-size: 12px; height: auto; line-height: 20px; overflow: auto; padding: 5px 10px; text-align: left; width: 99%; margin:1em auto;
}
pre.code .code{color: black; word-wrap: normal;}
</style>
This post looks at how to deliminate many rows into one single column.<br />
<br />
I come across this issue quite often so I thought I would share my solution. For example it's quite a good solution for quick ad-hoc data extracts.<br />
<br />
There are many ways to do this but the most performant way is actually the simplest too.<br />
<br />
The most common approach which most people fall back to would be to iterate through the collection using a Cursor and format a string that way. For many reasons this is not a good idea, from memory to potential deadlock issues to name 2.<br />
<br />
For this demo im going to comma deliminate all my tables into a single column for me to then copy this value straight into my <a href="http://www.sublimetext.com/" target="_blank">favorite text editor</a> to then save as a CSV.<br />
<br />
My data looks like the following.
<br />
<pre class="code"><code>ProductReview
StoreEventPage
AuditLog
Author
TimeLine
TimeLineEvent
</code></pre>
<br />
Now using the <a href="https://gist.github.com/560464dd6ae980c8d41a.git">gist</a> below. I can combine the result set of these string values and concatinate them to one string variable.
<br />
<br />
<script src="https://gist.github.com/chris-brown/560464dd6ae980c8d41a.js"></script>
Now again this is commonly done but note the <a href="http://msdn.microsoft.com/en-us/library/ms190349.aspx"><i>COALESCE</i> expression</a>. This avoids having duplicated commas and removes null values. The COALESCE expression is a syntactic shortcut for the CASE expression, when the first argument is NULL, COALESCE returns NULL.
<br />
The end result is the following which we can now save as a csv.
<br />
<pre class="code"><code>ProductReview,StoreEventPage,AuditLog,Author,TimeLine,TimeLineEvent</code>
</pre>
<br />
Thanks for reading. Always appreciate hearing your thoughts and comments.
<br />
Checkout my <a href="http://www.zirafon.org/">website</a> for further info and contact details.Anonymoushttp://www.blogger.com/profile/16028805125450984162noreply@blogger.com2tag:blogger.com,1999:blog-3048224848518662690.post-76914423912436405562014-12-23T15:46:00.001-08:002014-12-29T06:26:30.808-08:00Setting up precompiled handlerbars.js templates and using grunt to compile them<h3>
What is Javascript Templating</h3>
<div>
Good place to start is to describe what exactly <a href="http://en.wikipedia.org/wiki/JavaScript_templating" target="_blank">JS Templating</a> is and what a good use-case could be. For me, I have data that I've retrieved client side and I need to transform it into repetitive markup then I use a templating library.</div>
<div>
<br /></div>
<div>
Now sure Angular and Knockout are pretty popular approaches for rich client side data-binding but in alot of cases they are too bloated and overkill for certain scenarios.</div>
<div>
<br /></div>
<div>
Say I have a legacy app that uses a heavy amount of JQuery (pretty common scenario for me!) and im tasked to render data from a REST API endpoint to the UI. I dont want to add a whole new client side dependency just to render the data. JS Templating, in particular <a href="http://handlebarsjs.com/precompilation.html" target="_blank">Handlebars precompiler</a>, is perfect for this scenario.</div>
<div>
<br /></div>
<div>
For more detailed comparisons between templating libraries and performance reviews, please refer to the links below.</div>
<div>
<ul>
<li><a href="http://viget.com/extend/benchmarking-javascript-templating-libraries">http://viget.com/extend/benchmarking-javascript-templating-libraries</a></li>
<li><a href="http://www.sorescode.com/2010/09/12/benchmarks.html">http://www.sorescode.com/2010/09/12/benchmarks.html</a></li>
</ul>
<div class="separator" style="clear: both; text-align: center;">
<a href="http://chart.apis.google.com/chart?chxl=1:|ms&chxp=1,50&chxr=0,0,1000&chxt=y,y&chbh=a,15&chs=500x300&cht=bvg&chco=FFCC33,FF9900,3072F3,224499&chds=0,1000,0,1000,0,1000,0,1000&chd=t:98|202.5|309.2|889.8&chdl=Simple+Handlebars|Simple+Mustache|Loop+Handlebars|Loop+Mustache&chtt=Handlebars.js+%26+Mustache.js+Benchmarks" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="http://chart.apis.google.com/chart?chxl=1:|ms&chxp=1,50&chxr=0,0,1000&chxt=y,y&chbh=a,15&chs=500x300&cht=bvg&chco=FFCC33,FF9900,3072F3,224499&chds=0,1000,0,1000,0,1000,0,1000&chd=t:98|202.5|309.2|889.8&chdl=Simple+Handlebars|Simple+Mustache|Loop+Handlebars|Loop+Mustache&chtt=Handlebars.js+%26+Mustache.js+Benchmarks" height="192" width="320" /></a></div>
<div>
<br /></div>
</div>
<div>
<br /></div>
<div>
Its not always that straight forward a decision but if you need close control of your markup then its a great approach. There are many alternative approaches, from utilising client side UI controls like <a href="http://www.telerik.com/kendo-ui" target="_blank">Kendo UI</a> or <a href="http://www.infragistics.com/products/jquery" target="_blank">Infragistics Web Controls</a> to previously mentioned <a href="https://docs.angularjs.org/guide/templates" target="_blank">Angular JS templates</a> or <a href="http://knockoutjs.com/examples/grid.html" target="_blank">Knockout data-binding</a>.</div>
<div>
<br /></div>
<div>
The UI controls are an opinionated out-of -the-box solution while Angular and Knockout require their sizable libraries.</div>
<div>
<br /></div>
<h4>
Getting Started</h4>
<div>
The source for this demo can be obtained <a href="https://github.com/chris-brown/handlebarsjs-grunt-setup" target="_blank">here</a>. I haven't created any grunt tasks, im just bringing it all together to offer a solution for this demo. </div>
<div>
<br /></div>
<div>
Using <a href="https://www.npmjs.com/search?q=handlebars" target="_blank">node package manage</a>r I install the following packages.</div>
<div>
<ul>
<li>grunt</li>
<li>grunt-handlebars-compilar</li>
<li>grunt-contrib-watch</li>
<li>handlebars</li>
</ul>
<div>
Please note im using v1.3.0 of the handlebars package.</div>
<div>
If you copy the following <b><a href="https://github.com/chris-brown/handlebarsjs-grunt-setup/blob/master/package.json" target="_blank">Package.json</a></b> into the root directory, then these packages can be added automatically by running the following command.</div>
</div>
<blockquote class="tr_bq">
npm install </blockquote>
The benefit of using precompiled handlebar templates is that we only now need to use the runtime library. Once minified this is only a 7kb file.<br />
Copy the file to your solution directory. The file should be located in the following location.<br />
<blockquote class="tr_bq">
\node_modules\handlebars\dist\handlebars.runtime.min.js</blockquote>
Im then going to create a directory for my templates to live and then create my first handlebar template file.<br />
<blockquote class="tr_bq">
mkdir templates</blockquote>
<blockquote class="tr_bq">
echo. 2>templates/demo-list.handlebars</blockquote>
The next step is to configure the grunt file. <a href="http://gruntjs.com/configuring-tasks" target="_blank">This </a>link will give you further details as to how and why we do this. Below configures the handlebars task with the compile target. I then associate this task to the watch task.<br />
<script src="https://gist.github.com/chris-brown/188ec32bd15ac8878a68.js"></script>
This will now run the handlebars task when a file defined in the watch file pattern is changed and saved.<br />
To test this, run the following command.<br />
<blockquote class="tr_bq">
grunt watch</blockquote>
And edit the contents of the template.<br />
<br />
This should then create <i>scripts/handlebars-templates.js</i> file.<br />
<br />
<h4>
Putting it all together</h4>
<div>
All thats left to do now is to fetch our arbitrary data and render the markup. To do this ive used githubs free api as you can see from the gist of my gist below.</div>
<br />
<script src="https://gist.github.com/chris-brown/8d815606f93a483a671d.js"></script>
<br />
<div>
Finally we add the JS references to our page and the container we want to render the markup inside and were done.</div>
<br />
<script src="https://gist.github.com/chris-brown/2f44e86c588240209ff6.js"></script>
All the code for this demo has been added to github so please feel free to pull it down <a href="https://github.com/chris-brown/handlebarsjs-grunt-setup" target="blank"><b>here</b></a>.<br />
Any queries please let me know and vist my website <a href="http://www.zirafon.org/">http://www.zirafon.org</a> for more contact details.
<br/><br/>
Thanks for reading. Always appreciate your thoughts and comments.
<br/>
Checkout my <a href="http://www.zirafon.org">website</a> for further info and contact details.Anonymoushttp://www.blogger.com/profile/16028805125450984162noreply@blogger.com0