<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	xmlns:content="http://purl.org/rss/1.0/modules/content/"
	xmlns:wfw="http://wellformedweb.org/CommentAPI/"
	xmlns:dc="http://purl.org/dc/elements/1.1/"
	xmlns:atom="http://www.w3.org/2005/Atom"
	xmlns:sy="http://purl.org/rss/1.0/modules/syndication/"
	xmlns:slash="http://purl.org/rss/1.0/modules/slash/"
	>

<channel>
	<title>DataChomp</title>
	<atom:link href="http://datachomp.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://datachomp.com</link>
	<description>Chomping at the bits</description>
	<lastBuildDate>Thu, 03 May 2012 19:03:47 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>CI with MVC4 and Linux? No Problem</title>
		<link>http://datachomp.com/archives/ci-with-mvc4-and-linux-no-problem/</link>
		<comments>http://datachomp.com/archives/ci-with-mvc4-and-linux-no-problem/#comments</comments>
		<pubDate>Thu, 03 May 2012 05:13:59 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[AppDev]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[Tools]]></category>

		<guid isPermaLink="false">http://datachomp.com/?p=621</guid>
		<description><![CDATA[There are a lot of tools out there that we can use to automate our awesomeness. One of those easy/free/fun tools is a continuous integration (CI) server. Since we are building in Windows and deploying to Linux, we can go ahead and upgrade a CI server from 'important' to essential. There are various products out [...]]]></description>
			<content:encoded><![CDATA[<p>There are a lot of tools out there that we can use to automate our awesomeness. One of those easy/free/fun tools is a continuous integration (CI) server. Since we are building in Windows and deploying to Linux, we can go ahead and upgrade a CI server from 'important' to essential. There are various products out there that can accomplish this; I'm going with what I know and that is <a href="http://www.jetbrains.com/teamcity/" title="TeamCity" target="_blank">TeamCity</a> from JetBrains.</p>
<p>On our Ubuntu box, after we finish the easy as candy install, we're going to want to install Mono. Check out <a href="http://datachomp.com/archives/running-asp-net-mvc4-on-ubuntu-12-04/" title="Install Mono on Ubuntu" target="_blank">this previous post</a> on how to do that and set it up in your /etc/environment.</p>
<p>Now that Mono is rocking, lets hop over to our CI install. At the time of this post, the latest version of TeamCity is 7.0.2a. Looking at the code below, we're going to install Java, pull down the latest version of the TeamCity linux tar, decompress it, switch directories and fire it up :<br />
<code><br />
sudo apt-get install openjdk-7-jre<br />
wget - http://download.jetbrains.com/teamcity/TeamCity-7.0.2a.tar.gz<br />
tar xfz TeamCity-7.0.2a.tar.gz<br />
cd Teamcity<br />
sudo ./bin/runAll.bat start<br />
</code></p>
<p>Pretty easy right? Lets check out our web interface:<a href="http://files.datachomp.com/AppDev/mono/teamcitywelcome.png" target="_blank"><img src="http://files.datachomp.com/AppDev/mono/teamcitywelcome.png" alt="TeamcityWelcome" width="200" height="200" target="_blank" /></a></p>
<p>Yay! Everything works! You're also at a ubiquitous web interface which will likely give the Softie in you some solace. There are tons of resources online for setting up your project in TeamCity to check it out, build it, run tests, deploy, yada yada yada. If you are just getting started, I highly recommend <a href="http://www.troyhunt.com/2010/11/you-deploying-it-wrong-teamcity.html" title="Troy Hunt Deployments" target="_blank">Troy Hunt's post.</a> You can also install Ruby on this server and have a wonderfully awesome auto-deployment method via <a href="https://github.com/capistrano/capistrano/wiki/Documentation-v2.x" title="Capistrano" target="_blank">Capistrano</a>. If you are interested in deploying with Capistrano, let me know I'll try to barf out a quick post on it. This is a pretty short and to the point post, if it needs more content with regards to project checkouts and stuff, let me know and I can barf that out as well.</p>
]]></content:encoded>
			<wfw:commentRss>http://datachomp.com/archives/ci-with-mvc4-and-linux-no-problem/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Running ASP.NET MVC4 on Ubuntu 12.04</title>
		<link>http://datachomp.com/archives/running-asp-net-mvc4-on-ubuntu-12-04/</link>
		<comments>http://datachomp.com/archives/running-asp-net-mvc4-on-ubuntu-12-04/#comments</comments>
		<pubDate>Wed, 25 Apr 2012 04:11:07 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[AppDev]]></category>
		<category><![CDATA[Linux]]></category>
		<category><![CDATA[MVC]]></category>
		<category><![CDATA[OS]]></category>

		<guid isPermaLink="false">http://datachomp.com/?p=551</guid>
		<description><![CDATA[The single most question I get regarding our Hello Postgres series over Tekpub is "How are you running your app on Linux?" As much as I enjoy sending volleys of fragmented explanations over emails to people, I decided it might be in everyone's best interest if I just blog it out. Technology moves fast... like [...]]]></description>
			<content:encoded><![CDATA[<p>The single most question I get regarding our <a href="http://tekpub.com/productions/pg" title="Hello Postgres" target="_blank">Hello Postgres</a> series over Tekpub is "How are you running your app on Linux?" As much as I enjoy sending volleys of fragmented explanations over emails to people, I decided it might be in everyone's best interest if I just blog it out. Technology moves fast... like super fast. So instead of showing you how to deploy an old and busted MVC3 app to a "has been" Ubuntu 11.10, we're going to be going with MVC4 and <a href="https://wiki.ubuntu.com/PrecisePangolin/TechnicalOverview/Beta2" title="Ubuntu 12.04 beta 2" target="_blank">Ubuntu 12.04</a>. We're so bleeding edge you can call us cutters!</p>
<p>I'm not going to show you how to set up and install your Ubuntu Server, as there is a ton of internet out there that can handle that for you and the installer itself is pretty hard to mess up. What I will cover is what to do after that last reboot where it is  just you and Bash, together... at last.</p>
<p>SSH into your fancy new Ubuntu box with <a href="http://www.chiark.greenend.org.uk/~sgtatham/putty/" title="Putty" target="_blank">Putty</a> and Run this:<br />
<code>sudo apt-get update && sudo apt-get -y install git-core curl python-software-properties</code></p>
<p>This is going to let us add the ppa(think of this as a package location) to install a current nginx:<br />
<code>sudo add-apt-repository ppa:nginx/stable<br />
sudo apt-get update && sudo apt-get -y install nginx</code></p>
<p>Yes! We can now git things, we can curl things, and we can nginx things! Rawwrr!!! Let's kick some other processes to the curb... like that skank MySQL and that wet blanket Apache:<br />
<code>sudo update-rc.d mysql remove &&<br />
sudo update-rc.d apache2 remove && mkdir mycoolapp</code></p>
<p>Now for the fun part, let's get Mono up and running. We really want the latest version of Mono, and like Nuget, not all packages in Ubuntu stay current. The fix for this in the mono world is to just grab <a href="http://www.integratedwebsystems.com/2012/04/install-mono-2-11/" title="Nathan Bridgewater" target="_blank">this dudes</a> install script and go have a drink because it takes a bit to finish:<br />
<code>mkdir mono-2.11<br />
cd mono-2.11<br />
wget --no-check-certificate https://github.com/nathanb/iws-snippets/raw/master/mono-install-scripts/ubuntu/install_mono-2.11.sh<br />
chmod 755 install_mono-2.11.sh<br />
./install_mono-2.11.sh<br />
</code></p>
<p>Now to check that we have the current version, we just run the following:<br />
<code>/opt/mono-2.11/bin/mono -V</code></p>
<p>Cool! We're current, but what we really need is to just be able to run "mono -V" anywhere we want. We can do that by modifying our /etc/environment file:<br />
<code>sudo nano /etc/environment<br />
#then insert ":/opt/mono-2.11/bin"  at the end of that path string. Log out, log in for it to take effect.</code></p>
<p>I don't now about you, but all this sys-admin crap is putting me to sleep and I want to code. Back on our Widows/Dev box, we're going to new up an empty MVC4 project (up to you to figure out how to get MVC4 going on your box, I used Web Platform Installer). After the project is new'ed up:</p>
<ul>
<li>Add a controller</li>
<li>Add a view based on that controller</li>
<li>Hit F5 and make sure it works</li>
<li>Remove the EntityFramework.dll because we love our data and don't want to give our app a low self esteem</li>
<li>Once removed, hit F5 again</li>
</ul>
<p>If everything is still running, then do a file system deploy to a local folder of your choice. Go check out what was just deployed, specifically the '/bin' folder. We want to remove the Web.Infrastructure.dll because Mono already has this built into its GAC. High Five Mono! With that out of the way, we are going to copy that deployment over to the 'mycoolapp' folder on our Linux server using <a href="http://winscp.net/eng/index.php" title="Winscp" target="_blank">WinsCP</a>. While I don't have a WordPress plugin to read your mind, I hear you thinking "Rob, surely there are better ways to do this." and you are right. However, this post is long enough and that topic will likely go into its own post.</p>
<p>SSH back into your linux box, and 'cd mycoolapp'. "cd" into your "mycoolapp" directory, type in 'ls' to see the contents and make sure your app made it over. Once we see it, we can do a cassini like run of it by typeing out xsp4 and hitting enter. Try and hit your box on the port 8080 (xsp4 should tell you what it is running on) and see if you can see your app:</p>
<p><img src="http://files.datachomp.com/AppDev/mono/monoapp.png"></p>
<p>Yay! Our code works and we're so open source now that we can wear tight jeans at Starbucks and put Bon Iver on our ipod... just like those <a href="http://wekeroad.com/" title="Lead Rails Wanker" target="_blank">Rails wankers</a>! As for nginx and running our site as a Mono service, we can just use some of the nice documentation over at the Mono site:</p>
<p>Nginx config:<br />
<a href="http://www.mono-project.com/FastCGI_Nginx" title="FastCGI_Nginx" target="_blank">http://www.mono-project.com/FastCGI_Nginx</a></p>
<p>Mono as a service:<br />
<a href="http://yojimbo87.github.com/2010/03/14/mono-startup-script.html" title="Monoserve" target="_blank">http://yojimbo87.github.com/2010/03/14/mono-startup-script.html</a></p>
]]></content:encoded>
			<wfw:commentRss>http://datachomp.com/archives/running-asp-net-mvc4-on-ubuntu-12-04/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>TSQL Tuesday #28 &#8211; Jack of all Trades, Master of One</title>
		<link>http://datachomp.com/archives/tsql-tuesday-28-jack-of-all-trades-master-of-one/</link>
		<comments>http://datachomp.com/archives/tsql-tuesday-28-jack-of-all-trades-master-of-one/#comments</comments>
		<pubDate>Tue, 13 Mar 2012 13:55:03 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://datachomp.com/?p=554</guid>
		<description><![CDATA[If you want the back story on what this topic is all about - http://sqlblog.com/blogs/argenis_fernandez/archive/2012/03/05/t-sql-tuesday-028-jack-of-all-trades-master-of-none.aspx]]></description>
			<content:encoded><![CDATA[<p>If you want the back story on what this topic is all about - <a href="http://sqlblog.com/blogs/argenis_fernandez/archive/2012/03/05/t-sql-tuesday-028-jack-of-all-trades-master-of-none.aspx">http://sqlblog.com/blogs/argenis_fernandez/archive/2012/03/05/t-sql-tuesday-028-jack-of-all-trades-master-of-none.aspx</a>  <-- ha webforms</p>
<p>Argenis went on some blabfest about how life got better for him after he started to really focus on SQL Server. He's a SQL Server certified Master, is incredibly helpful and one of the reasons I don't over commit myself to specific mastery. "But Rob, how can you say that? MCM's are reveled by everyone!!!" It's true. I take nothing away from a MCM and it is one of the few certs that are actually respected. But it's also not for me. Most of my shining moments as a DBA have nothing to do with a mastery of say quirky transaction scope of full text indexes or being the Chuck Norris of international merge replication scenarios and everything to do with knowing how things work on the whole. The more I know on the whole, especially with concepts, the better a DBA I am. When I'm getting Win-Auth errors, I don't need to be a Kerberos God ("When someone asks if you're a Kerberos God, you say YES!") to start to troubleshoot, but I need to know enough to ask the right questions. Being a jack of all trades typically lets me know when I'm in over my head and need to call in an expert - like my good friend Google or Argenis... which brings me to my next point:</p>
<p>As someone with an insatiable appetite for pizza...err learning, technology simply moves too fast and brings me too much joy to try to really master a facet of a single product. That is not a global rule, that is my personal choice and more importantly a personal defense mechanism from burnout. That is another thing that is fun about technology. There are usually many correct paths to success and interweaving those paths can build some really incredible software... which brings me to my final point:</p>
<p>As someone with no shortage of ego (I am a DBA afterall!) if you want to go down the path of being a jack of all trades, you better be friends with Masters and put your ego to the side and ask for help. There are few things more dangerous than not asking for help when you need it. We all write code that doesn't work the first time, we all have asked silly questions before, and we (as individuals) don't know everything.</p>
]]></content:encoded>
			<wfw:commentRss>http://datachomp.com/archives/tsql-tuesday-28-jack-of-all-trades-master-of-one/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>I&#8217;m leaving SQL Server for Postgres</title>
		<link>http://datachomp.com/archives/im-leaving-sql-server-for-postgres/</link>
		<comments>http://datachomp.com/archives/im-leaving-sql-server-for-postgres/#comments</comments>
		<pubDate>Thu, 08 Mar 2012 00:05:25 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[Postgres]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://datachomp.com/?p=526</guid>
		<description><![CDATA[Ok, well I'm not leaving SQL Server professionally (or financially!) but another relational database platform has clearly captured my heart. That platform is Postgres! Through a combination of relentless potshots at MySQL and emotional bribes where I feign interest in Rails, I was able to trick Rob Conery and the Tekpub team into not only [...]]]></description>
			<content:encoded><![CDATA[<p>Ok, well I'm not leaving SQL Server professionally (or financially!) but another relational database platform has clearly captured my heart. That platform is <a href="http://www.postgresql.org/">Postgres</a>! Through a combination of relentless potshots at MySQL and emotional bribes where I feign interest in Rails, I was able to trick <a href="http://wekeroad.com/2012/03/08/something-borrowed-something-new/">Rob Conery</a> and the Tekpub team into not only moving Tekpub to Postgres but also let me record a <a href="http://tekpub.com/productions/pg">Postgres series</a> with them. In this series, we share the data love on a platform that is open, fast and incredibly flexible. The ease at which Postgres addresses many of the day to day issues I deal with as a SQL Server DBA is mouthwatering to say the least. Luckily for you, it isn't just about me or DBAs which is why the head App Dev(il) himself <a href="http://wekeroad.com/2012/03/08/something-borrowed-something-new/">Rob C</a> came along for the ride! He is quick to ask questions and to put in his tidbits and raise issues that would relate to you, the developer. That's right friends, it isn't just a series that shakes the hand of Postgres, we walk up and give it a big sloppy kiss. So check it out and have fun watching "The Robs" bring you a double felony of database knowledge.</p>
<p><a href="http://tekpub.com/productions/pg">Hello Postgres</a><br/><br />
<iframe width="640" height="360" src="http://www.youtube.com/embed/Rl_-lKxSBm4?feature=player_embedded" frameborder="0" allowfullscreen></iframe></p>
<p>Show notes and scripts will be put up on GitHub when I get back in town.</p>
]]></content:encoded>
			<wfw:commentRss>http://datachomp.com/archives/im-leaving-sql-server-for-postgres/feed/</wfw:commentRss>
		<slash:comments>8</slash:comments>
		</item>
		<item>
		<title>Hey App, quit wasting my time sorting your data</title>
		<link>http://datachomp.com/archives/hey-app-quit-wasting-my-time-sorting-your-data/</link>
		<comments>http://datachomp.com/archives/hey-app-quit-wasting-my-time-sorting-your-data/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 22:42:22 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Databases]]></category>

		<guid isPermaLink="false">http://datachomp.com/?p=496</guid>
		<description><![CDATA[An issue I run into quite a bit is unnecessary sorting in the database. I'm not talking about the sort of 'Get last 5' type of sorting where you need to sort to get a valid result set. I'm talking about the 'Hey Database! I want some data...and I'll probably throw some business logic in [...]]]></description>
			<content:encoded><![CDATA[<p>An issue I run into quite a bit is unnecessary sorting in the database. I'm not talking about the sort of 'Get last 5' type of sorting where you need to sort to get a valid result set. I'm talking about the '<em>Hey Database! I want some data...and I'll probably throw some business logic in you... and while I'm here, how about we throw the presentation layer in as well and you sort the results for our UI!</em>'</p>
<p><strong>Nut Kicking:</strong><br />
In the same way that AppDevs outnumber DBAs, infrastructure wise there are typically way more web/caching servers than there are database servers. This is mostly due to the fact that like a decent DBA, a decent database server is expensive.  <del datetime="2012-01-29T19:26:23+00:00">AppDevs</del>Webservers in general are cheaper, have less memory and don't need to be as awesome as a <del datetime="2012-01-29T19:26:23+00:00">DBA</del>database server.</p>
<p><strong>Code Please:</strong><br />
Lets take a look at some execution plans/cost so you can view 'ORDER BY' the same way I do.<br />
Below is a simple example of selecting some badges by userid, and then display them alphabetically for the user to view :<br />
<code>SELECT  Name<br />
FROM dbo.Badges<br />
WHERE userid = 91254;</p>
<p>SELECT Name<br />
FROM dbo.Badges<br />
WHERE userid = 91254<br />
ORDER BY name DESC;</code><br />
And this is the execution plan it creates:<br />
<a href="http://files.datachomp.com/AppDev/orderby/orderbyexecutionplan.png" target="_blank"><img src="http://files.datachomp.com/AppDev/orderby/orderbyexecutionplan.png" alt="execplan" /></a></p>
<p>On the bottom, do you see the glyph that is "Sort Cost: 15%"? As well as a difference of almost 10% in general between the two queries? Removing those "sort"(har har har) of thing adds up...like a lot.</p>
<p><strong>Just Fix It</strong><br />
In C#, you have these things you can use called Ordered Enumerables and they are really easy to use... take a look:</p>
<pre class="csharp"><span style="color: #0600FF;">public</span> IOrderedEnumerable&lt;dynamic&gt; GetBadgeByUserId<span style="color: #000000;">&#40;</span><span style="color: #FF0000;">int</span> badgeid<span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	var table = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Badges<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
	var badges = table.<span style="color: #0000FF;">query</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;SELECT  Name FROM dbo.Badges WHERE userid = @0&quot;</span>, args: badgeid<span style="color: #000000;">&#41;</span>;
	<span style="color: #0600FF;">return</span> badges.<span style="color: #0000FF;">OrderBy</span><span style="color: #000000;">&#40;</span>x=&gt;x.<span style="color: #0000FF;">Name</span><span style="color: #000000;">&#41;</span>;
	<span style="color: #008080; font-style: italic;">//return badges.OrderByDescending(x =&gt; x.Name);</span>
<span style="color: #000000;">&#125;</span></pre>
<p>That wasn't too hard was it?  In the above example, it is making a call to the DB (using <a href="https://github.com/robconery/massive" target="_blank">Massive</a>) and sucking the results into 'badges'. That is where it breaks off its relationship with the database, and sorts the results in 'badges' and returns them to whatever was calling it.</p>
<p><strong>Does this make us happy?</strong><br />
I'm happy because you're not putting extra load on the DB. You're happy because you have some sorted data and can close a help ticket... everyone wins right?</p>
<p><strong>But But But, our servers are busy too!</strong><br />
Ahhh, but perhaps you're one of those clever AppDevs who says that if the DB is getting over worked, then the webservers are too! Since I don't have the webserver metrics, I can't really object to that. But what I can say is: "<em>Yo, that's cool. Since you are a programmer.... program up some javascript to sort the results in the UI. Then, the webservers and the db can both go listen to dub step or whatever servers like to do in their spare time.</em>"</p>
<p>There are a ton of ways to do this:<br />
<a href="http://lmgtfy.com/?q=sort+a+table+with+jquery" target="_blank">http://lmgtfy.com/?q=sort+a+table+with+jquery</a></p>
<p>Doing it on the front end also works great if you are stuck using some particular DALs or ORMs that take a bulimic approach to data retrieval IE - Eating everything in site and then barfing it out to the app.</p>
]]></content:encoded>
			<wfw:commentRss>http://datachomp.com/archives/hey-app-quit-wasting-my-time-sorting-your-data/feed/</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
		<item>
		<title>GIT and Red Gate SQL Source Control</title>
		<link>http://datachomp.com/archives/git-and-red-gate-sql-source-control/</link>
		<comments>http://datachomp.com/archives/git-and-red-gate-sql-source-control/#comments</comments>
		<pubDate>Sun, 29 Jan 2012 03:19:12 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://datachomp.com/?p=469</guid>
		<description><![CDATA[I am a huge fan of Red Gate SQL Source Control because it makes source controlling/deploying your database easier. I am aware of the MS Database Projects abomination application and the short version on that is that I have deemed them unworthy for my use. There are lots of tutorials and examples of using RG [...]]]></description>
			<content:encoded><![CDATA[<p>I am a huge fan of <a href="http://www.red-gate.com/products/sql-development/sql-source-control/" target="_blank">Red Gate SQL Source Control</a> because it makes source controlling/deploying your database easier. I am aware of the MS Database Projects <del datetime="2012-01-29T01:05:56+00:00">abomination</del> application and the short version on that is that I have deemed them unworthy for my use. There are lots of tutorials and examples of using RG SSC with centralized version control systems like <a href="http://subversion.tigris.org/" target="_blank">Subversion</a> or <a href="http://en.wikipedia.org/wiki/Nelson_Muntz" target="_blank">TFS</a> and it does work wonderfully with them.  Recently, my workplace decided to ditch TFS and move to a more modern distributed version control named <a href="http://git-scm.com/" target="_blank">Git</a>. Like most disruptions to your workflow, there are a few growing pains. This post is going to cover installing Git on Widows, hooking it up to <a href="https://github.com/" target="_blank">github.com</a> and showing some basic actions as we change our database.</p>
<p><strong>Install Git:</strong><br />
  Download the <a href="http://code.google.com/p/msysgit/downloads/list?can=3" target="_blank">full installer for Git</a> and install it.<br />
While you are mindlessly clicking 'next' make sure you integrate with CMD. This is critical for RG SSC and just a convenient thing to do in general. The important part will look like this:<br />
<a href="http://files.datachomp.com/SQLServer/rgssc/1install_cmd.png" target="_blank"><img src="http://files.datachomp.com/SQLServer/rgssc/1install_cmd.png" alt="sourcecontrolcmd" width=100 height=100 /></a></p>
<p><strong>Aside:</strong> I'm a converted fan of <a href="https://github.com/dahlbyk/posh-git" target="_blank">posh-git</a>. Using things like the Git GUI or Tortoise GIT will be incredibly tempting, and perhaps for initial familiarization, it might be a good idea to use those to visualize some concepts. That being said, it is really in your best interest to move towards the CLI and posh-git is very helpful in that regard. It isn't nearly as bad as you think once you get going.</p>
<p><strong>Repo Hosting</strong><br />
Once you have Git installed, you will want to hook up to some hosting. An incredibly popular and easy to use one is <a href="https://github.com/" target="_blank">Github.com</a> but there are <a href="http://git-scm.com/tools" target="_blank" class="broken_link" rel="nofollow">plenty of others</a>.</p>
<p><strong>Repo Man</strong><br />
In Github, you will want to create your repository and <a href="http://help.github.com/win-set-up-git/ " target="_blank">assign your SSH keys</a>. This process can be a bit more than you are used to at first, but GitHub as great at giving you some hand holding instructions: <a href="http://help.github.com/" target="_blank">http://help.github.com/</a><br />
Once the repo is initialized, I like to create a folder for the App and a folder for the database like so:<br />
<a href="http://files.datachomp.com/SQLServer/rgssc/2folder_layout.png" title="folder layout" target="_blank"><img src="http://files.datachomp.com/SQLServer/rgssc/2folder_layout.png" alt="folder layout" width=100 height=100 /></a><br />
You don't have to do it like that, but again, that is the way I currently like to do it.</p>
<p><strong>Lets hook up the DB!</strong><br />
Why use the Adventure Works database? Since it is a bit of a marketing database used to show both neat and inane features, we're hooking it up just to make sure all types of various objects work just fine with RG SQL Source Control.<br />
From there, go to SSMS and link up the DB to your local repository:<br />
<a href="http://files.datachomp.com/SQLServer/rgssc/4hookupssc.png" title="repo linko" target="_blank"><img src="http://files.datachomp.com/SQLServer/rgssc/4hookupssc.png" alt="repo linko" width=100 height=100 /></a> <a href="http://files.datachomp.com/SQLServer/rgssc/5configureforgit.png" title="repo linko" target="_blank"><img src="http://files.datachomp.com/SQLServer/rgssc/5configureforgit.png" alt="repo linko" width=100 height=100 /></a></p>
<p><strong>Command Line Interface ... or whatever</strong><br />
Back in powershell (or whatever client you are using) create a new branch for updating our proc.  <code>git branch dbobjects</code><br />
Note: We don't have to create a new branch. We could very easily just keep doing this in the 'master' branch. I find that creating of the branches to be a good habit and a handy organizational tool. Branching is one of those features that really shines in Git so lets put it to use.<br />
Go into that branch: <code>git checkout dbobjects</code><br />
<a href="http://files.datachomp.com/SQLServer/rgssc/6createbranch.png" title="branchard" target="_blank"><img src="http://files.datachomp.com/SQLServer/rgssc/6createbranch.png" alt="branchard" width=100 height=100 /></a></p>
<p>Now, we go back to SSMS and commit our changes:<br />
<a href="http://files.datachomp.com/SQLServer/rgssc/7addobjects.png" title="no hands!" target="_blank"><img src="http://files.datachomp.com/SQLServer/rgssc/7addobjects.png" alt="no hands!" width=100 height=100 /></a></p>
<p>Cool! Our "dbobjects" branch has been committed locally, now we just need to merge it into our master branch!</p>
<p>From there, go back to master: <code>git checkout master</code><br />
and then merge into master our dbobjects branch:  <code>git merge master dbobjects</code><br />
After we have merged,  we can delete the branch we were working in by running:<br />
<code>git branch -d dbobjects</code><br />
and the process will end up looking like this:<br />
<a href="http://files.datachomp.com/SQLServer/rgssc/9gotomasterandmerge.png" title="master merge" target="_blank"><img src="http://files.datachomp.com/SQLServer/rgssc/9gotomasterandmerge.png" alt="master merge" width=100 height=100 /></a></p>
<p>If you look on Github, you will see that nothing has changed there.  Why is that?   That is because all the work we have done has been locally. This is the essence and the speed of a distributed control system. We can commit, fix, break all we want without getting everyone else mad.  However, at some point, we will need to send our changes off so that others on the team can use (laugh) at them.  We do this by "push"ing to the origin: <code>git push -u origin master</code><br />
<a href="http://files.datachomp.com/SQLServer/rgssc/10pushtoorigin.png" title="origin" target="_blank"><img src="http://files.datachomp.com/SQLServer/rgssc/10pushtoorigin.png" alt="origin" width=100 height=100 /></a></p>
<p>Now, if we look at Github, we see our changes in the main repository, and if we go to check it out again:<br />
<a href="http://files.datachomp.com/SQLServer/rgssc/11alldoneyay.png" title="yay" target="_blank"><img src="http://files.datachomp.com/SQLServer/rgssc/11alldoneyay.png" alt="yay" width=100 height=100 /></a></p>
<p>We can see them there for people pulling down changes. You've done it. Now you too can participate in the source control fun with the AppDevs and make nerdworthy comments about rebasing, merging and pushing master.</p>
]]></content:encoded>
			<wfw:commentRss>http://datachomp.com/archives/git-and-red-gate-sql-source-control/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Oklahoma City JavaScript Group</title>
		<link>http://datachomp.com/archives/oklahoma-city-javascript-group/</link>
		<comments>http://datachomp.com/archives/oklahoma-city-javascript-group/#comments</comments>
		<pubDate>Thu, 19 Jan 2012 02:30:19 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[AppDev]]></category>

		<guid isPermaLink="false">http://datachomp.com/?p=457</guid>
		<description><![CDATA[A new user group is starting in Oklahoma City and it is one I find completely fascinating... a Javascript group! With the monumental surge in popularity of Javascript over the past year or so, this type of group is a can't miss. Who should attend you might ask? All of us in the tech field [...]]]></description>
			<content:encoded><![CDATA[<p>A <a href="http://okcjs.com/">new user group is starting in Oklahoma City</a> and it is one I find<br />
completely fascinating... a Javascript group! With the monumental surge in popularity of Javascript over the past year or so, this type of group is a can't miss.</p>
<p>Who should attend you might ask? <strong>All of us</strong> in the tech field because it is pretty much everywhere now. Even a database douche bag like myself is attending because I have finally accepted that Javascript is inescapable. Javascript is all over the web, going to be all over the desktop with Windows 8, appearing in the mobile markets, and starting to take over the back end with rad technologies like <a href="http://nodejs.org/" target="_blank">NodeJS</a>.</p>
<p>I'm a complete noob with Javascript and I feel completely comfortable coming to this group  because with as fast as this technology is moving, we're all noobs and need to learn from each other. This group will not waste your time because</p>
<p> <strong>Learning is cumulative.</strong></p>
<p> As a speed freak, my primary interest lies in <a href="http://nodejs.org/" target="_blank">NodeJS</a>, but I know for a fact that I will learn something to help me with Node from <a href="http://www.vancelucas.com/" target="_blank">Vance</a> talking about BDD testing with a testing framework called <a href="http://pivotal.github.com/jasmine/" target="_blank">Jasmine</a>. That is just how it works. He gives, I take, and down the road I give back. Even if you don't know or care a thing about Javascript, it can be a good networking opportunity with some of the people in our community that have a true passion for tech and are trying to push tech boundaries. If that doesn't interest you, you can <a href="http://i.imgur.com/0cFLk.gif" alt="Lurker" target="_blank">lurk in the back and watch me </a>ask stupid questions as I try and get the info to the highly firewall'ed learning center that is my brain... or just show up for a free lunch. You have options.</p>
<p>If you don't go or don't plan to go...no worries. I'll still love you (as a friend), but in our very fluid industry, dropping an hour a month of your time on something like this is an incredibly way to not go stagnant.</p>
<p>The first meeting is <strong>January 24th from 11:30-12:30</strong> at the <a href="http://okccoco.com/">OKC CoCo</a>. Come say hi and most importantly.... help me learn this stuff!</p>
<p>For more information, hit up <a href="http://okcjs.com/" title="http://okcjs.com/">http://okcjs.com/</a></p>
]]></content:encoded>
			<wfw:commentRss>http://datachomp.com/archives/oklahoma-city-javascript-group/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Simple-Talk &#8211; SQL Test write up</title>
		<link>http://datachomp.com/archives/simple-talk-sql-test-write-up/</link>
		<comments>http://datachomp.com/archives/simple-talk-sql-test-write-up/#comments</comments>
		<pubDate>Fri, 16 Dec 2011 15:19:50 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[Databases]]></category>
		<category><![CDATA[SQL Server]]></category>

		<guid isPermaLink="false">http://datachomp.com/?p=451</guid>
		<description><![CDATA[I had the pleasure of being able to write up a delightfully ephemeral piece on SQL Test for Simple-Talk. This is a fun little tool and I'm anxious to see just how much David and his team can improve it. http://www.simple-talk.com/sql/sql-tools/sql-test-seeing-red-change-to-green/ In other news, being published on Simple-Talk is also another thing Troy Hunt won't [...]]]></description>
			<content:encoded><![CDATA[<p>I had the pleasure of being able to write up a delightfully ephemeral piece on SQL Test for Simple-Talk. This is a fun little tool and I'm anxious to see just how much David and his team can improve it.</p>
<p><a href="http://www.simple-talk.com/sql/sql-tools/sql-test-seeing-red-change-to-green/" title="http://www.simple-talk.com/sql/sql-tools/sql-test-seeing-red-change-to-green/">http://www.simple-talk.com/sql/sql-tools/sql-test-seeing-red-change-to-green/</a></p>
<p>In other news, being published on Simple-Talk is also another thing <a href="http://troyhunt.com/" title="Troy Hunt">Troy Hunt</a> won't be able to 1-Up me with.</p>
]]></content:encoded>
			<wfw:commentRss>http://datachomp.com/archives/simple-talk-sql-test-write-up/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Getting started with Postgres and MVC3</title>
		<link>http://datachomp.com/archives/getting-started-with-postgres-and-mvc3/</link>
		<comments>http://datachomp.com/archives/getting-started-with-postgres-and-mvc3/#comments</comments>
		<pubDate>Sun, 20 Nov 2011 19:28:10 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[MVC]]></category>
		<category><![CDATA[Postgres]]></category>

		<guid isPermaLink="false">http://datachomp.com/?p=424</guid>
		<description><![CDATA["<a href="http://www.postgresql.org/">Postgres</a>? WTF man, you're a SQL Server DBA!"  It's true, I am a SQL Server DBA but even I have to admit that the Postgres team is doing some wildy exciting stuff.  With that in mind, lets take a quick look at just how quickly we can replace SQL Server with a free/open full bore Enterprise database system like <a href="http://www.postgresql.org/">Postgres</a>.]]></description>
			<content:encoded><![CDATA[<p>"<em><strong><a href="http://www.postgresql.org/">Postgres</a>? WTF man, you're a SQL Server DBA!</strong></em>"  It's true, I am a SQL Server DBA but even I have to admit that the Postgres team is doing some <a href="http://www.postgresql.org/about/featurematrix">wildy exciting stuff</a>. With that in mind, lets take a quick look at just how quickly we can replace SQL Server with a free/open full bore Enterprise database system like <a href="http://www.postgresql.org/">Postgres</a>.</p>
<p>One of the first things you will notice is Postgres is way easier to install than SQL Server. The SQL Server install is born from a truck stop romance between TFS and Sharepoint that someone found in a garbage bag in a dumpster and burned to a DVD. Postgres takes a different angle and opts for a 'less is more' type of approach. One of the big things you will want to pay attention to is the password you give the default 'postgres' account. Think of him as the SA account in SQL Server as he too wields a mighty big stick.</p>
<p>Once we finish the installer, lets open up pgAdmin III (henceforth known as pgAdmin). If you are accustomed to SSMS with SQL Server and always wished it went on a diet... then you might like pgAdmin. Be warned though, pgAdmin isn't SSMS on a diet... it is like SSMS with Anorexia. Once pgAdmin is opened and you are connected, then drill down to 'databases' and do a 'new database' and use the GUI to make your fancy new demo database, or just run the raw sql:</p>
<pre class="sql">&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">DATABASE</span> <span style="color: #ff0000;">&quot;Demo&quot;</span>
  <span style="color: #993333; font-weight: bold;">WITH</span> ENCODING=<span style="color: #ff0000;">'UTF8'</span>
       OWNER=postgres
       CONNECTION <span style="color: #993333; font-weight: bold;">LIMIT</span>=<span style="color: #cc66cc;">-1</span>;
&nbsp;</pre>
<p>Next, lets hop in that database and throw up some tables/data:</p>
<pre class="sql">&nbsp;
<span style="color: #993333; font-weight: bold;">CREATE</span> <span style="color: #993333; font-weight: bold;">TABLE</span> <span style="color: #ff0000;">&quot;Colors&quot;</span>
<span style="color: #66cc66;">&#40;</span>
	colorid serial <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,
	colorname character varying<span style="color: #66cc66;">&#40;</span><span style="color: #cc66cc;">50</span><span style="color: #66cc66;">&#41;</span> <span style="color: #993333; font-weight: bold;">NOT</span> <span style="color: #993333; font-weight: bold;">NULL</span>,
	constraint pk_colorid <span style="color: #993333; font-weight: bold;">PRIMARY</span> <span style="color: #993333; font-weight: bold;">KEY</span> <span style="color: #66cc66;">&#40;</span>colorid<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">WITH</span> <span style="color: #66cc66;">&#40;</span>OIDS=false<span style="color: #66cc66;">&#41;</span>;
&nbsp;
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">&quot;Colors&quot;</span> <span style="color: #66cc66;">&#40;</span>colorname<span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'red'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">INSERT</span> <span style="color: #993333; font-weight: bold;">INTO</span> <span style="color: #ff0000;">&quot;Colors&quot;</span> <span style="color: #66cc66;">&#40;</span>colorname<span style="color: #66cc66;">&#41;</span>
<span style="color: #993333; font-weight: bold;">VALUES</span> <span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">'blue'</span><span style="color: #66cc66;">&#41;</span>;
<span style="color: #993333; font-weight: bold;">SELECT</span> * <span style="color: #993333; font-weight: bold;">FROM</span> <span style="color: #ff0000;">&quot;Colors&quot;</span>;
&nbsp;</pre>
<p>So why the quotes around the table names you might be asking... well, SQL Server has a bit of Honey Badger approach to what case you assign names and Postgres treats it like a pretty big deal. Luckily, overcoming it isn't a big deal, we just double quote it. Now, if you don't have years of tsql or <a href="http://en.wikipedia.org/wiki/CamelCase">camelcasing</a> drilled into your brain, you can easy just do everything in lower case and not fight the double quote dragon.<br />
What else sticks out there... oh Data Types! You will have to adjust to some variance in data types, but in a good way. Postgres has a lavish assortment of data types for you to fall in love with and one of which is using 'serial' instead of the whole IDENTITY(1,1)  you might be used to in SQL Server. There are also some really cool things called Sequences in Postgres which are blazing fast and give you the value of the ID before you insert it. DBAs like them because it can get you AppDevs away from fatty GUID primary keys.</p>
<p>Fire up a new MVC3 app and hop into the Nuget console. From there, we're going to add our <a href="http://www.nuget.org/List/Packages/Npgsql">Postgre provider</a> with "<strong>Install-Package Npgsql</strong>". Now that we have our vital provider assemblies, lets go mess around in the web.config.</p>
<pre class="csharp">&nbsp;
&lt;configuration&gt;
	&lt;system.<span style="color: #0000FF;">data</span>&gt;
		&lt;DbProviderFactories&gt;
			&lt;add name=<span style="color: #808080;">&quot;Npgsql Data Provider&quot;</span>
        invariant=<span style="color: #808080;">&quot;Npgsql&quot;</span>
        support=<span style="color: #808080;">&quot;FF&quot;</span>
        description=<span style="color: #808080;">&quot;.Net Framework Data Provider for Postgresql Server&quot;</span>
        type=<span style="color: #808080;">&quot;Npgsql.NpgsqlFactory, Npgsql, Version=2.0.11.0, Culture=neutral, PublicKeyToken=5d8b90d52f46fda7&quot;</span> /&gt;
		&lt;/DbProviderFactories&gt;
	&lt;/<span style="color: #000000;">system</span>.<span style="color: #0000FF;">data</span>&gt;
&nbsp;
	&lt;connectionStrings&gt;
		&lt;add name=<span style="color: #808080;">&quot;pg&quot;</span> connectionString=<span style="color: #808080;">&quot;Server=127.0.0.1;Port=5432;Database=Demo;User Id=postgres;Password=dontusethisaccount;CommandTimeout=20;&quot;</span> providerName=<span style="color: #808080;">&quot;Npgsql&quot;</span> /&gt;
	&lt;/connectionStrings&gt;
&nbsp;</pre>
<p>Yeah! We have our provider factory rocking and our connection string. Yes, I am using the postgres account in this demo and yes that is wrong/stupid, but I'm having so much fun playing with the Postgres engine that I decided to take a shortcut there for this entry.</p>
<p>So our color app is pretty quick and dirty. In keeping with that spirit, I'm going to use <a href="https://github.com/robconery/massive">Massive</a> as my ORM of choice. It already has a <a href="https://github.com/robconery/massive/blob/master/Massive.PostgreSQL.cs">Postgres version</a> ready to go. <a href="https://github.com/toptensoftware/petapoco">PetaPoco</a> has some very nice Postgres options in it, but Massive is very quick/easy and the Expandos makes all the strong-typers uncomfortable and I love a good code-trolling.</p>
<p>In the Model folder of our app, I create a new class file called Massive and I copy/paste the <a href="https://github.com/robconery/massive/blob/master/Massive.PostgreSQL.cs">Postgres version</a> into it, and I also created a new class file called "Colors" that I pasted the following in:</p>
<pre class="csharp">&nbsp;
	<span style="color: #0600FF;">public</span> <span style="color: #FF0000;">class</span> Color : DynamicModel
	<span style="color: #000000;">&#123;</span>
		<span style="color: #0600FF;">public</span> Color<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span> : <span style="color: #0600FF;">base</span><span style="color: #000000;">&#40;</span><span style="color: #808080;">&quot;pg&quot;</span>, <span style="color: #808080;">&quot;Colors&quot;</span>, <span style="color: #808080;">&quot;colorid&quot;</span><span style="color: #000000;">&#41;</span> <span style="color: #000000;">&#123;</span> <span style="color: #000000;">&#125;</span>
&nbsp;
	<span style="color: #000000;">&#125;</span>
&nbsp;</pre>
<p>All wired up!  In the home controller, we'll throw some code to play with our table in:</p>
<pre class="csharp">&nbsp;
var table = <a href="http://www.google.com/search?q=new+msdn.microsoft.com"><span style="color: #008000;">new</span></a> Color<span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
var colors = table.<span style="color: #0000FF;">All</span><span style="color: #000000;">&#40;</span><span style="color: #000000;">&#41;</span>;
ViewBag.<span style="color: #0000FF;">colors</span> = colors;
&nbsp;</pre>
<p>And then in our view:</p>
<pre class="csharp">&nbsp;
@<span style="color: #0600FF;">foreach</span> <span style="color: #000000;">&#40;</span>var color <span style="color: #0600FF;">in</span> ViewBag.<span style="color: #0000FF;">colors</span><span style="color: #000000;">&#41;</span>
<span style="color: #000000;">&#123;</span>
	 @: @color.<span style="color: #0000FF;">colorid</span> @color.<span style="color: #0000FF;">colorname</span>
<span style="color: #000000;">&#125;</span>
&nbsp;</pre>
<p>F5 and what do we get? BOOM!!! "Error 42P01: relation "colors" does not exist"<br />
So remember when I started our Colors table with a capital C? This is where it can come back to bite you... and also one of the reasons I absolutely love Micro-ORMs. Fast, malleable, and so easy a DBA can use it. Let's hop into Massive and throw some quotes around our table access:</p>
<pre class="csharp">&nbsp;
<span style="color: #FF0000;">string</span> sql = limit &gt; <span style="color: #FF0000;">0</span> ? <span style="color: #808080;">&quot;SELECT TOP &quot;</span> + limit + <span style="color: #808080;">&quot; {0} FROM <span style="color: #008080; font-weight: bold;">\&quot;</span>{1}<span style="color: #008080; font-weight: bold;">\&quot;</span> &quot;</span> : <span style="color: #808080;">&quot;SELECT {0} FROM <span style="color: #008080; font-weight: bold;">\&quot;</span>{1}<span style="color: #008080; font-weight: bold;">\&quot;</span> &quot;</span>;
&nbsp;</pre>
<p>and Viola!  It works!  In pretty much the time it takes to install SQL Server, we're already rocking our stunning and highly valuable colors app!</p>
]]></content:encoded>
			<wfw:commentRss>http://datachomp.com/archives/getting-started-with-postgres-and-mvc3/feed/</wfw:commentRss>
		<slash:comments>5</slash:comments>
		</item>
		<item>
		<title>Rock out with your Procmon out</title>
		<link>http://datachomp.com/archives/rock-out-with-your-procmon-out/</link>
		<comments>http://datachomp.com/archives/rock-out-with-your-procmon-out/#comments</comments>
		<pubDate>Tue, 26 Jul 2011 23:59:40 +0000</pubDate>
		<dc:creator>Rob</dc:creator>
				<category><![CDATA[AppDev]]></category>
		<category><![CDATA[OS]]></category>
		<category><![CDATA[Tools]]></category>
		<category><![CDATA[Windows]]></category>

		<guid isPermaLink="false">http://datachomp.com/?p=350</guid>
		<description><![CDATA[If you are not a fan of Sysinternals tools then you clearly do not have your geek merit badge. While I have always kept a local copy in the past, there is now a cool and easy way to get to Sysinternals and it is via Start + run + \\live.sysinternals.com\tools If you are already [...]]]></description>
			<content:encoded><![CDATA[<p>If you are not a fan of Sysinternals tools then you clearly do not have your geek merit badge.  While I have always kept a local copy in the past, there is now a cool and easy way to get to Sysinternals and it is via<br />
Start + run +  \\live.sysinternals.com\tools</p>
<p>If you are already a gigantic nerd like me and have various login scripts that run, it is way easy to simply map that share by throwing the following into your login scripts:</p>
<p>net use s: \\live.sysinternals.com\tools</p>
]]></content:encoded>
			<wfw:commentRss>http://datachomp.com/archives/rock-out-with-your-procmon-out/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 1.416 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2012-05-19 06:30:09 -->

