<?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>Seth Gholson</title>
	<atom:link href="http://www.sethgholson.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.sethgholson.com</link>
	<description></description>
	<lastBuildDate>Sat, 02 Jun 2012 00:00:00 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.2</generator>
<atom:link rel="hub" href="http://pubsubhubbub.appspot.com"/><atom:link rel="hub" href="http://superfeedr.com/hubbub"/>		<item>
		<title>NoClassDefFoundError After ADT Update</title>
		<link>http://www.sethgholson.com/2012/06/noclassdeffounderror-after-adt-update/</link>
		<comments>http://www.sethgholson.com/2012/06/noclassdeffounderror-after-adt-update/#comments</comments>
		<pubDate>Sat, 02 Jun 2012 00:00:00 +0000</pubDate>
		<dc:creator>Seth Gholson</dc:creator>
				<category><![CDATA[Android]]></category>
		<category><![CDATA[Development]]></category>
		<category><![CDATA[adt]]></category>
		<category><![CDATA[android]]></category>

		<guid isPermaLink="false">http://www.sethgholson.com/?p=1566</guid>
		<description><![CDATA[I’ve just returned to an Android project after a couple of months’ pause. After updating Eclipse and ADT, my project started throwing an exception: 06-12 21:45:26.154: ERROR/AndroidRuntime(3654): java.lang.NoClassDefFoundError: com.google.gson.gson This JAR file was clearly in my “lib” folder in the project and in my build path. After entirely too much fiddling about, cleaning, rebuilding, and [...]]]></description>
			<content:encoded><![CDATA[<p>I’ve just returned to an Android project after a couple of months’ pause. After updating Eclipse and ADT, my project started throwing an exception:</p>
<pre class="brush:java">06-12 21:45:26.154: ERROR/AndroidRuntime(3654): java.lang.NoClassDefFoundError: com.google.gson.gson</pre>
<p>This JAR file was clearly in my “lib” folder in the project and in my build path. After entirely too much fiddling about, cleaning, rebuilding, and googling, I discovered my problem. Apparently, ANT is now expecting these to be in the “libs” folder. After moving all of my third party JAR files from “lib” to “libs”, deleting “lib”, and restarting Eclipse, all is right the the world again!</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sethgholson.com/2012/06/noclassdeffounderror-after-adt-update/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Restart Forever.js After Reboot</title>
		<link>http://www.sethgholson.com/2012/04/restart-forever-js-after-reboot/</link>
		<comments>http://www.sethgholson.com/2012/04/restart-forever-js-after-reboot/#comments</comments>
		<pubDate>Wed, 25 Apr 2012 01:00:26 +0000</pubDate>
		<dc:creator>Seth Gholson</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[bash]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[node.js]]></category>

		<guid isPermaLink="false">http://www.sethgholson.com/?p=1555</guid>
		<description><![CDATA[I’m amid migrating from a Dreamhost shared server to a VPS. A benefit of this is the ability to have long running processes like node.js. I’m also migrating the back end for Menu Line George to Parse.com. My v1 process for recording the George calls was a kludge of scripts running on my home desktop [...]]]></description>
			<content:encoded><![CDATA[<p>I’m amid migrating from a Dreamhost shared server to a VPS. A benefit of this is the ability to have long running processes like node.js. I’m also migrating the back end for <a title="Praaaaaaaaaaaaaise the Looooooooooord it's Tuesday! Wait... Damn. It's Tuesday." href="http://itunes.apple.com/us/app/menu-line-george/id440761181" target="_blank">Menu Line George</a> to Parse.com. My v1 process for recording the George calls was a kludge of scripts running on my home desktop to call via Skype. This was more a proof-of-concept than a long term solution. Now I’ll be using <a href="http://www.twilio.com" target="_blank">Twilio</a> + <a title="I can't stand the taste of V8." href="http://www.nodejs.org" target="_blank">node.js</a> + <a title="Most ungooglable product name ever." href="http://www.parse.com" target="_blank">Parse</a> as my permanent solution, significantly reducing how much I’ll need to think about it on a daily basis.</p>
<p>The simplest way I’ve found to keep a node script running as a service is <a title="He got caved in, and he's been there ever since. Forever? Forever." href="https://github.com/nodejitsu/forever" target="_blank">forever.js</a>. If you’re new to node, I suggest checking it out. Otherwise, I’m sure you’ve heard of it.</p>
<p>I fired it up yesterday and it worked like a champ. That is, of course, until my VPS rebooted overnight for some reason and the call wasn’t made this morning. I found a handy little guide over at Hack Sparrow for creating a cron job to restart your node script with forever when the machine reboots.</p>
<p>First create a shell script like this one (I called mine <em>app-starter.sh</em>):</p>
<pre class="brush:plain">#!/bin/sh

if [ $(ps aux | grep $USER | grep node | grep -v grep | wc -l | tr -s "\n") -eq 0 ]
then
        export NODE_ENV=production
        export PATH=/usr/local/bin:$PATH
        forever start ~/example/app.js &gt; /dev/null
fi</pre>
<p>Then make the script executable:</p>
<pre class="brush:plain">chmod 700 ~/app-starter.sh</pre>
<p>Now make cron run the script when the system is rebooted. Add this to your crontab (via <em>crontab –e</em>):</p>
<pre class="brush:plain">@reboot ~/app-starter.sh &gt;&gt; cron.log 2&gt;&amp;1</pre>
<p>For the uninitiated like myself, use<em> CTRL+K,X</em> to save.</p>
<p>Thanks to Hack Sparrow for taking the time to share this.</p>
<p>via <a title="The night starts now" href="http://www.hacksparrow.com/make-forever-reboot-proof-with-cron.html" target="_blank">Hack Sparrow</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sethgholson.com/2012/04/restart-forever-js-after-reboot/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>XML Shredding In SQL Is A Recipe For Arthritis</title>
		<link>http://www.sethgholson.com/2012/04/xml-shredding-in-sql-is-a-recipe-for-arthritis/</link>
		<comments>http://www.sethgholson.com/2012/04/xml-shredding-in-sql-is-a-recipe-for-arthritis/#comments</comments>
		<pubDate>Fri, 06 Apr 2012 22:07:06 +0000</pubDate>
		<dc:creator>Seth Gholson</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.sethgholson.com/?p=1533</guid>
		<description><![CDATA[At work I&#8217;ve been spending a lot of time the past couple of weeks doing the same thing: serialize the records in a table as XML, pass it up to the client, then back down to another database to be deserialized and merged. It&#8217;s nothing fancy, but it&#8217;s certainly tedious. It&#8217;s generally been a pattern [...]]]></description>
			<content:encoded><![CDATA[<p>At work I&#8217;ve been spending a lot of time the past couple of weeks doing the same thing: serialize the records in a table as XML, pass it up to the client, then back down to another database to be deserialized and merged. It&#8217;s nothing fancy, but it&#8217;s certainly tedious. It&#8217;s generally been a pattern of:</p>
<p>Generate the XML: (easy)</p>
<pre class="brush:sql">SELECT
  Column1,
  Column2,
  Column3,
  Column4,
  Column5
FROM FooTable Foo
FOR XML AUTO, ROOT('Root')</pre>
<p>To create something like this:</p>
<pre class="brush:xml">&lt;Root&gt;
&lt;Foo Column1="Value1" Column2="Value2" Column3="Value3" Column4="Value4" Column5="Value5" /&gt;
&lt;/Root&gt;</pre>
<p>But having to type this out has been the arthritic step. For larger tables, this can take a while.</p>
<pre class="brush:sql">SELECT
	a.value('@Column1', 'varchar(20)') Column1,
	a.value('@Column2', 'varchar(20)') Column2,
	a.value('@Column3', 'varchar(20)') Column3,
	a.value('@Column4', 'varchar(20)') Column4,
	a.value('@Column5', 'varchar(20)') Column5
FROM
	@XmlValue.nodes('/Root/Foo') T(a)</pre>
<p>I know of nothing to automatically generate something like this, and yesterday I decided enough is enough (after coming to a table that was 65 columns wide). I wanted a way to quickly write the SELECT clause of something like this for me. Quick and easy was important, because if it were a chore to use I&#8217;d likely just write it out, grumbling the whole time.</p>
<p>The table definition is easy to generate via Management Studio. Right Click the window &gt; Script Table As &gt; Create To &gt; New Query Window and you get something like:</p>
<pre class="brush:sql">CREATE TABLE [dbo].[FooTable](
	[Column1] [varchar(20)] NULL,
	[Column2] [varchar(20)] NULL,
	[Column3] [varchar(20)] NULL,
	[Column4] [varchar(20)] NULL,
	[Column5] [varchar(20)] NULL,
//...[constraint and references]...</pre>
<p>I settled on using the clipboard as the medium so I don&#8217;t need to deal with saving a file or using a form for input. With this pinned to my taskbar, I just copy the table definition text to my clipboard and click the icon. Voila! The result is ready to be pasted. There&#8217;s nothing fancy here. Just convenience.</p>
<pre class="brush:csharp">using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Windows.Forms;

namespace MasterShredder
{
    class Program
    {
        [STAThread]
        static void Main(string[] args)
        {
            string contents = Clipboard.GetText();
            if (string.IsNullOrEmpty(contents))
            {
                Console.WriteLine("I'm expecting the column definition to be in your clipboard.");
                Console.WriteLine("Expected format:  [ColumnName] [ColumnType] [NULL or NOT NULL],");
                Console.Read();
            }
            else
            {

                string[] lines = contents.Split('\n');
                StringBuilder result = new StringBuilder();

                foreach (string line in lines)
                {
                	//Strip new line and tab characters.
                    string cleanLine = line.Replace(Environment.NewLine, "").Replace("\t", "");
                    string[] parts = cleanLine.Split(' ');
                    if (parts.Length &gt; 2)
                    {
                        string name = parts[0].Replace("[", "").Replace("]", "");
                        string type = parts[1].Replace("[", "").Replace("]", "");

                        // type definition was split. i.e. decimal(18, 6)
                        if(parts[2].EndsWith(")"))
                        {
                            type += parts[2];
                        }
                        string lineResult = String.Format(",a.value('@{0}', '{1}') {0}", name, type);
                        result.AppendLine(lineResult);
                        Console.WriteLine(lineResult);
                    }
                }

                if(!string.IsNullOrEmpty(result.ToString()))
                {
                    Clipboard.SetText(result.ToString());
                }
            }
        }
    }
}</pre>
<p>Oh, and if this is crappy, <a title="fork it and fix it on gist." href="https://gist.github.com/2323419" target="_blank">fork and fix it on gist</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sethgholson.com/2012/04/xml-shredding-in-sql-is-a-recipe-for-arthritis/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using simple_list_item_2 with an ArrayAdapter (Android)</title>
		<link>http://www.sethgholson.com/2012/01/using-simple_list_item_2-with-an-arrayadapter-android/</link>
		<comments>http://www.sethgholson.com/2012/01/using-simple_list_item_2-with-an-arrayadapter-android/#comments</comments>
		<pubDate>Fri, 13 Jan 2012 21:31:48 +0000</pubDate>
		<dc:creator>Seth Gholson</dc:creator>
				<category><![CDATA[Development]]></category>
		<category><![CDATA[android]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.sethgholson.com/2012/01/using-simple_list_item_2-with-an-arrayadapter-android/</guid>
		<description><![CDATA[Today I wanted to display static a ListView of properties and their values. It’s Friday, so I really wanted to do this with as little work as possible. Android’s free layout simple_list_item_2 sounded like what I wanted, but it wasn’t immediately clear how to handle this. There are a lot of lazy ways we can [...]]]></description>
			<content:encoded><![CDATA[<p>Today I wanted to display static a ListView of properties and their values. It’s Friday, so I really wanted to do this with as little work as possible. Android’s free layout simple_list_item_2 sounded like what I wanted, but it wasn’t immediately clear how to handle this. There are a lot of lazy ways we can list single values, but Googling around how to use simple_list_item_2 resulted in lots of questions with no real answer.</p>
<p>I found Mark Assad, who parsed the system layout files into <a href="http://sydney.edu.au/engineering/it/~massad/project-android.html" target="_blank">raw XML</a>. The led to the magic answer of <a href="http://developer.android.com/reference/android/widget/TwoLineListItem.html" target="_blank">TwoLineListItem</a> widget. Finding this widget allowed me to write a simple ArrayAdapter of key/value pairs.</p>
<pre class="brush:java">adapter = new ArrayAdapter(this,android.R.layout.simple_list_item_2,list){
        @Override
        public View getView(int position, View convertView, ViewGroup parent){
            TwoLineListItem row;
            if(convertView == null){
                LayoutInflater inflater = (LayoutInflater)getApplicationContext().getSystemService(Context.LAYOUT_INFLATER_SERVICE);
                row = (TwoLineListItem)inflater.inflate(android.R.layout.simple_list_item_2, null);
            }else{
                row = (TwoLineListItem)convertView;
            }
            BasicNameValuePair data = list.get(position);
            row.getText1().setText(data.getName());
            row.getText2().setText(data.getValue());

            return row;
        }
    };
listView.setAdapter(adapter);</pre>
<p>Hope this saves someone else some time, as I spent an embarrassing amount of time determined to use the simple_list_item_2 layout.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sethgholson.com/2012/01/using-simple_list_item_2-with-an-arrayadapter-android/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>A Bit Scatterbrained&#8230;</title>
		<link>http://www.sethgholson.com/2012/01/a-bit-scatterbrained/</link>
		<comments>http://www.sethgholson.com/2012/01/a-bit-scatterbrained/#comments</comments>
		<pubDate>Thu, 12 Jan 2012 20:19:06 +0000</pubDate>
		<dc:creator>Seth Gholson</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[Apple]]></category>
		<category><![CDATA[Family]]></category>
		<category><![CDATA[Humor]]></category>
		<category><![CDATA[iPhone]]></category>
		<category><![CDATA[SQL]]></category>

		<guid isPermaLink="false">http://www.sethgholson.com/2012/01/a-bit-scatterbrained/</guid>
		<description><![CDATA[Lately I find myself mixing my PascalCase with my camelCase, calling alloc init instead of new, using [ ] instead of (), and writing awfully verbose method names all over the place. I justify my errors with a glimpse at my average day here lately:]]></description>
			<content:encoded><![CDATA[<p>Lately I find myself mixing my PascalCase with my camelCase, calling alloc init instead of new, using [ ] instead of (), and writing awfully verbose method names all over the place. I justify my errors with a glimpse at my average day here lately:</p>
<p><a href="http://www.sethgholson.com/wp-content/uploads/2012/01/dailyFocus1.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="Not to scale. Some margin of error. I focus on my family all day. I promise!" border="0" alt="Not to scale. Some margin of error. I focus on my family all day. I promise!" src="http://www.sethgholson.com/wp-content/uploads/2012/01/dailyFocus_thumb1.png" width="623" height="212" /></a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sethgholson.com/2012/01/a-bit-scatterbrained/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>The Value of Documentation</title>
		<link>http://www.sethgholson.com/2011/10/the-value-of-documentation/</link>
		<comments>http://www.sethgholson.com/2011/10/the-value-of-documentation/#comments</comments>
		<pubDate>Wed, 12 Oct 2011 14:26:50 +0000</pubDate>
		<dc:creator>Seth Gholson</dc:creator>
				<category><![CDATA[Technology]]></category>
		<category><![CDATA[Titanium]]></category>
		<category><![CDATA[appcelerator]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[titanium]]></category>

		<guid isPermaLink="false">http://www.sethgholson.com/2011/10/the-value-of-documentation/</guid>
		<description><![CDATA[Having been reared as a developer in Microsoft’s cozy little .NET world, I didn’t really appreciate the value of quality documentation until I ventured out into the wild jungle. I’ve been using Appcelerator’s Titanium Mobile SDK for the past few months. It’s kind of become my Shere Khan here in the jungle. Theoretically, using Titanium [...]]]></description>
			<content:encoded><![CDATA[<p>Having been reared as a developer in Microsoft’s cozy little .NET world, I didn’t really appreciate the value of quality documentation until I ventured out into the wild jungle.</p>
<p>I’ve been using Appcelerator’s Titanium Mobile SDK for the past few months. It’s kind of become my <a title="Chris Benard is my Baloo" href="http://en.wikipedia.org/wiki/Shere_Khan" target="_blank">Shere Khan</a> here in the jungle. Theoretically, using Titanium Mobile is easier and faster than writing native code. This might be true if I didn’t waste so much time deciphering their documentation. </p>
<p>I made a button to toggle my table view’s editable status. The object had a property called editable, so that seemed to be what I wanted. After testing, however, all this did was toggle whether or not swipe-to-delete worked. What I really wanted was the little red minus sign to appear, and have the contents of each row shifted to the right to make room. After 30 minutes of trial and error, looking through <a href="http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.TableViewRow-object" target="_blank">TableViewRow</a> properties, and searching their <a title="Want to see only the results that have been answered? Screw you." href="http://developer.appcelerator.com/questions/newest" target="_blank">Q&amp;A</a> section (because Appcelerator has no official forums) I found that <a title="I&#39;m surprised it doesn&#39;t have two visibility properties: visible and viewing" href="http://developer.appcelerator.com/apidoc/mobile/latest/Titanium.UI.TableView-object" target="_blank">TableView</a> actually has two properties: editable and editing.</p>
<p>&#160;</p>
<p><a href="http://www.sethgholson.com/wp-content/uploads/2011/10/image1.png"><img style="border-bottom: 0px; border-left: 0px; display: inline; border-top: 0px; border-right: 0px" title="image" border="0" alt="image" src="http://www.sethgholson.com/wp-content/uploads/2011/10/image_thumb1.png" width="603" height="94" /></a> </p>
<p>&#160;</p>
<p>Even after discovering this other property, I still had to actually test each one to see what they did. Apparently, “editable” toggles the swipe-to-delete, whereas “editing” toggles the minus-button-on-the-left thing. The two are independent of each other. </p>
<p>Thanks for saving me time, web based application framework!</p>
<p>Signed,</p>
<p>Bitter in Bossier</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sethgholson.com/2011/10/the-value-of-documentation/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Enterprise Library Sometimes Chops XML into 2033 Characters</title>
		<link>http://www.sethgholson.com/2011/10/enterprise-library-sometimes-chops-xml-into-2033-characters/</link>
		<comments>http://www.sethgholson.com/2011/10/enterprise-library-sometimes-chops-xml-into-2033-characters/#comments</comments>
		<pubDate>Tue, 04 Oct 2011 20:37:57 +0000</pubDate>
		<dc:creator>Seth Gholson</dc:creator>
				<category><![CDATA[.NET]]></category>
		<category><![CDATA[SQL]]></category>
		<category><![CDATA[Enterprise Library]]></category>
		<category><![CDATA[XML]]></category>

		<guid isPermaLink="false">http://www.sethgholson.com/?p=1446</guid>
		<description><![CDATA[This morning I began what I thought would be an uneventful task in .NET: connect to one database, download as XML some rows from a table that have changed since a given time, then pass that XML to a stored procedure in another database so that the changes can be merged. Just two tables: one [...]]]></description>
			<content:encoded><![CDATA[<p>This morning I began what I thought would be an uneventful task in .NET: connect to one database, download as XML some rows from a table that have changed since a given time, then pass that XML to a stored procedure in another database so that the changes can be merged. Just two tables: one relatively small, the other just a 2-column relationship table for the first table. Here’s a contrived snippet to serve the same purpose:</p>
<p>The SQL:</p>
<pre class="brush:sql">
CREATE PROCEDURE dbo.GetXmlValue

AS

SELECT TOP 100
*
FROM sys.all_columns
FOR XML AUTO, ROOT('Root')
</pre>
<p>The Code:</p>
<pre class="brush:csharp">
Database db = GetDatabase();

DataSet set;

using (DbCommand cmd = db.GetStoredProcCommand("dbo.GetXmlValue"))
{
set = db.ExecuteDataSet(cmd);
}
</pre>
<p>In my application, it was this second table that tripped me a bit. The first only had a few changed rows, so the XML was only 500-1000 characters. The second table generated a much longer XML string – 3864 characters long. My initial plan was to return two tables, each 1 column and 1 row. When using <a href="http://msdn.microsoft.com/en-us/library/microsoft.practices.enterpriselibrary.data.database.executedataset(v=pandp.31).aspx" target="_blank">Database.ExecuteDataSet</a> to fetch the results, however, the second table yielded two rows. I backtracked, second guessed myself, and even grabbed a couple of guys in the hall to double check my code. No one could explain it. It seemed odd that this hasn’t come up before for someone here. I did a bit of Googling and only found a couple of results. This <a href="http://support.microsoft.com/kb/310378" target="_blank">Microsoft Knowledgebase Article</a> just says it’s “by design” and to use <a href="http://msdn.microsoft.com/en-us/library/system.data.sqlclient.sqlcommand.executexmlreader(v=vs.71).aspx" target="_blank">SQLCommand.ExecuteXmlReader</a>.</p>
<p>The next question that came up was “Well, what does it do if I return a long XML value among other values in the same row?” I tested this out and everything worked as expected. All of the XML was in a single column value as it should be.</p>
<p>I still can’t exactly explain it. <a href="http://msdn.microsoft.com/en-us/library/microsoft.practices.enterpriselibrary.data.database.executescalar(v=pandp.31).aspx" target="_blank">ExecuteScalar</a> has a character limit of 2033 characters. I suspect that because each table in my result set is just a single column value, something somewhere is relying on ExecuteScalar.</p>
<p>My solution? In my stored procedure I just stored each of my table results as an XML typed variable, then returned the two together in the same row.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sethgholson.com/2011/10/enterprise-library-sometimes-chops-xml-into-2033-characters/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GTIN 12 UPC Check Digit Calculation in SQL Server 2008</title>
		<link>http://www.sethgholson.com/2011/09/gtin-12-upc-check-digit-calculation-in-sql-server-2008/</link>
		<comments>http://www.sethgholson.com/2011/09/gtin-12-upc-check-digit-calculation-in-sql-server-2008/#comments</comments>
		<pubDate>Fri, 16 Sep 2011 20:22:49 +0000</pubDate>
		<dc:creator>Seth Gholson</dc:creator>
				<category><![CDATA[SQL]]></category>
		<category><![CDATA[Technology]]></category>
		<category><![CDATA[barcode]]></category>
		<category><![CDATA[check digit]]></category>
		<category><![CDATA[UPC]]></category>

		<guid isPermaLink="false">http://www.sethgholson.com/?p=1406</guid>
		<description><![CDATA[I recently needed to generate the check digit for a GTIN-12 UPC code in SQL. The calculation method for the check digit varies depending on what kind of barcode you’re implementing, so I popped on over to Google to get the necessary algorithm. Naturally, and regardless of simplicity, I checked for any available code snippets. [...]]]></description>
			<content:encoded><![CDATA[<p>I recently needed to generate the check digit for a <a href="http://en.wikipedia.org/wiki/Universal_Product_Code">GTIN-12 UPC code</a> in SQL. The calculation method for the check digit varies depending on what kind of barcode you’re implementing, so I popped on over to Google to get the necessary algorithm. Naturally, and regardless of simplicity, I checked for any available code snippets. The only I found weren’t GTIN-12, and were in C or C++. So for anyone looking to do it (or something similar) in T-SQL, here’s a scalar function to do just that.</p>
<pre class="brush:sql">CREATE FUNCTION dbo.CalculateBarcodeGTIN12CheckDigit(@input CHAR(11))
RETURNS INT
AS
BEGIN
DECLARE @evenDigitSum INT = 0
,@oddDigitSum INT = 0
,@i TINYINT = 0
,@result INT;

-- check if given Barcode is Numeric , if not return error status -1
IF(ISNUMERIC(@input) = 0
OR LEN(RTRIM(LTRIM(@input))) != 11)
RETURN -1

-- start the compute BarCode checksum algorithm
SET @i = 1
WHILE (@i &lt;= 11)
BEGIN
--Add odd and even digits separately;
IF((@i % 2) = 0)
SET @evenDigitSum += CONVERT(TINYINT, SUBSTRING(@input,@i,1))
ELSE
SET @oddDigitSum += CONVERT(TINYINT, SUBSTRING(@input,@i,1))
SET @i += 1
END

--As per: http://en.wikipedia.org/wiki/Universal_Product_Code
--Multiply odd sum by 3, add to even sum, and mod 10.
SET @result = ((@oddDigitSum * 3) + @evenDigitSum) % 10;
IF(@result = 0)
RETURN 0
ELSE
RETURN 10 - @result;

RETURN -1
END
GO</pre>
<p>Scalar functions are killer, but I’ll only ever be using it for a single record.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.sethgholson.com/2011/09/gtin-12-upc-check-digit-calculation-in-sql-server-2008/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Hatcher William</title>
		<link>http://www.sethgholson.com/2011/05/1403/</link>
		<comments>http://www.sethgholson.com/2011/05/1403/#comments</comments>
		<pubDate>Fri, 20 May 2011 15:41:44 +0000</pubDate>
		<dc:creator>Seth Gholson</dc:creator>
				<category><![CDATA[Family]]></category>

		<guid isPermaLink="false">http://www.sethgholson.com/2011/05/1403/</guid>
		<description><![CDATA[So. Awesome.]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.sethgholson.com/wp-content/uploads/2011/05/20110520-104025.jpg"><img src="http://www.sethgholson.com/wp-content/uploads/2011/05/20110520-104025.jpg" alt="20110520-104025.jpg" class="alignnone size-full" /></a></p>
<p>So. Awesome. <img src='http://www.sethgholson.com/wp-includes/images/smilies/icon_smile.gif' alt=':)' class='wp-smiley' /> </p>
]]></content:encoded>
			<wfw:commentRss>http://www.sethgholson.com/2011/05/1403/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Berlin &#8211; All Panoramas</title>
		<link>http://www.sethgholson.com/2010/12/berlin-all-panoramas/</link>
		<comments>http://www.sethgholson.com/2010/12/berlin-all-panoramas/#comments</comments>
		<pubDate>Sat, 25 Dec 2010 14:28:22 +0000</pubDate>
		<dc:creator>Seth Gholson</dc:creator>
				<category><![CDATA[Travel]]></category>

		<guid isPermaLink="false">http://www.sethgholson.com/2010/12/berlin-all-panoramas/</guid>
		<description><![CDATA[Because I didn’t want to include all of the panoramas I took in my main Berlin summary post, here is a list of nearly all of them for those that care: Apartment: http://www.occip.it/pyh2l87gj Park behind apartment: http://www.occip.it/pyh30sy9j http://www.occip.it/pyh80z5ij Nazi war crimes trial exhibit: http://www.occip.it/pyh405w8j http://www.occip.it/pyhsssgj Outside the Nazi war crimes courthouse: http://www.occip.it/pyh7em0j http://www.occip.it/pyh20eo5j Outside our [...]]]></description>
			<content:encoded><![CDATA[<p>Because I didn’t want to include <em>all<strong> </strong></em>of the panoramas I took in my <a href="http://www.sethgholson.com/2010/12/berlin/">main Berlin summary post</a>, here is a list of nearly all of them for those that care:</p>
<p><strong>Apartment:<br />
</strong><a href="http://www.occip.it/pyh2l87gj">http://www.occip.it/pyh2l87gj</a></p>
<p><strong>Park behind apartment:<br />
</strong><a href="http://www.occip.it/pyh30sy9j">http://www.occip.it/pyh30sy9j</a><br />
<a href="http://www.occip.it/pyh80z5ij">http://www.occip.it/pyh80z5ij</a></p>
<p><strong>Nazi war crimes trial exhibit:<br />
</strong><a href="http://www.occip.it/pyh405w8j">http://www.occip.it/pyh405w8j</a><br />
<a href="http://www.occip.it/pyhsssgj">http://www.occip.it/pyhsssgj</a></p>
<p><strong>Outside the Nazi war crimes courthouse:<br />
</strong><a href="http://www.occip.it/pyh7em0j">http://www.occip.it/pyh7em0j</a><br />
<a href="http://www.occip.it/pyh20eo5j">http://www.occip.it/pyh20eo5j</a></p>
<p><strong>Outside our Nuremburg hotel:<br />
</strong><a href="http://www.occip.it/pyh78bnj">http://www.occip.it/pyh78bnj</a></p>
<p><strong>Church in Nuremburg (half):<br />
</strong><a href="http://www.occip.it/pygy00nksj">http://www.occip.it/pygy00nksj</a></p>
<p><strong>Bridge in Nuremburg:<br />
</strong><a href="http://www.occip.it/pyh203r7j">http://www.occip.it/pyh203r7j</a><br />
<a href="http://www.occip.it/pyh40yluj">http://www.occip.it/pyh40yluj</a></p>
<p><strong>Medieval Dungeon:<br />
</strong><a href="http://www.occip.it/pyhsunvj">http://www.occip.it/pyhsunvj</a></p>
<p><strong>Christmas markets:<br />
</strong><a href="http://www.occip.it/pyhsec8j">http://www.occip.it/pyhsec8j</a><br />
<a href="http://www.occip.it/pyh30wfjj">http://www.occip.it/pyh30wfjj</a><br />
<a href="http://www.occip.it/pygy0t15j">http://www.occip.it/pygy0t15j</a><br />
<a href="http://www.occip.it/pyh30sfbj">http://www.occip.it/pyh30sfbj</a></p>
<p><strong>Random Subway Station:<br />
</strong><a href="http://www.occip.it/pygz0cvgj">http://www.occip.it/pygz0cvgj</a></p>
<p><strong>Main train station (Berlin Hauptbahnhof)<br />
</strong><a href="http://www.occip.it/pyhs0jsxj">http://www.occip.it/pyhs0jsxj</a></p>
<p><strong>Church:<br />
</strong><a href="http://www.occip.it/pyh30zyej">http://www.occip.it/pyh30zyej</a><br />
<a href="http://www.occip.it/pyh3006qxj">http://www.occip.it/pyh3006qxj</a><br />
Outside: <a href="http://www.occip.it/pygy0v67j">http://www.occip.it/pygy0v67j</a></p>
<p><strong>Crypt:<br />
</strong><a href="http://www.occip.it/pyh50u4zj">http://www.occip.it/pyh50u4zj</a></p>
<p><strong>Charlottenburg Palace:<br />
</strong><a href="http://www.occip.it/pyh69zfj">http://www.occip.it/pyh69zfj</a></p>
<p><strong>Holocaust Memorial:<br />
</strong><a href="http://www.occip.it/pyh80z4rj">http://www.occip.it/pyh80z4rj</a><br />
<a href="http://www.occip.it/pyh3066kj">http://www.occip.it/pyh3066kj</a><br />
<a href="http://www.occip.it/pyh7i82j">http://www.occip.it/pyh7i82j</a></p>
<p><strong>Brandenberg Gate:<br />
</strong><a href="http://www.occip.it/pyh30dfsj">http://www.occip.it/pyh30dfsj</a> &#8212; kind of messed up</p>
<p><strong>Tiergarten:<br />
</strong><a href="http://www.occip.it/pyhsvm2j">http://www.occip.it/pyhsvm2j</a><br />
<a href="http://www.occip.it/pygy0fraj">http://www.occip.it/pygy0fraj</a></p>
<p><strong>KaDeWe Restaraunt:<br />
</strong><a href="http://www.occip.it/pygz0ygrj">http://www.occip.it/pygz0ygrj</a></p>
<p><strong>Gedächtniskirche:<br />
</strong><a href="http://www.occip.it/pyh80f95j">http://www.occip.it/pyh80f95j</a></p>
]]></content:encoded>
			<wfw:commentRss>http://www.sethgholson.com/2010/12/berlin-all-panoramas/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic page generated in 0.957 seconds. -->
<!-- Cached page generated by WP-Super-Cache on 2013-05-19 05:33:15 -->
