<?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>7deeds &#187; algorithms</title>
	<atom:link href="http://blog.7deeds.com/tag/algorithms/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.7deeds.com</link>
	<description>Petros Amiridis - A humble programmer's seven noteworthy actions for the community</description>
	<lastBuildDate>Mon, 31 May 2010 12:09:10 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.1</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>PAbarcode gem</title>
		<link>http://blog.7deeds.com/2009/12/30/pabarcode-gem/</link>
		<comments>http://blog.7deeds.com/2009/12/30/pabarcode-gem/#comments</comments>
		<pubDate>Wed, 30 Dec 2009 09:07:51 +0000</pubDate>
		<dc:creator>Petros</dc:creator>
				<category><![CDATA[2-deed]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[gems]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.7deeds.com/?p=395</guid>
		<description><![CDATA[In a previous post I mentioned that I started maintaining a set of helper Ruby classes for working with barcodes. I have changed the structure of the project to make it a gem and I have published it on GemCutter.

First you need to install the gem:

sudo gem install pabarcode

then the example in the previous post [...]]]></description>
			<content:encoded><![CDATA[<p>In a <a href="http://blog.7deeds.com/2009/12/23/ruby-barcodes/">previous post</a> I mentioned that I started maintaining a set of helper Ruby classes for working with barcodes. I have changed the structure of the <a href="http://github.com/amiridis/pabarcode">project</a> to make it a gem and I have <a href="http://gemcutter.org/gems/pabarcode">published it on GemCutter</a>.</p>
<p><span id="more-395"></span></p>
<p>First you need to install the gem:</p>
<pre class="brush: bash;">
sudo gem install pabarcode
</pre>
<p>then the example in the previous post needs to change so as it uses the gem instead of the plain Ruby file:</p>
<pre class="brush: ruby;">
require &quot;rubygems&quot;
require &quot;pabarcode&quot;

include PAbarcode

file = File.open(&quot;apog.txt&quot;)

file.each do |line|
  bc = line.slice(0..11)
  bc13 = Barcode.new(bc).get_ean_13
  puts bc13 + line.slice(12..line.length)
end

file.close
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.7deeds.com/2009/12/30/pabarcode-gem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby helper classes for barcodes</title>
		<link>http://blog.7deeds.com/2009/12/23/ruby-barcodes/</link>
		<comments>http://blog.7deeds.com/2009/12/23/ruby-barcodes/#comments</comments>
		<pubDate>Wed, 23 Dec 2009 14:06:32 +0000</pubDate>
		<dc:creator>Petros</dc:creator>
				<category><![CDATA[2-deed]]></category>
		<category><![CDATA[algorithms]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[utilities]]></category>

		<guid isPermaLink="false">http://blog.7deeds.com/?p=385</guid>
		<description><![CDATA[In my day job, I work a lot with barcodes. We develop Windows Mobile software for devices with barcode readers. From time to time, I need to do file manipulation chores. That is: colleagues give me text files that contain barcodes and ask me to transform these.

Yesterday, a colleague of mine asked me to take [...]]]></description>
			<content:encoded><![CDATA[<p>In my day job, I work a lot with barcodes. We develop Windows Mobile software for devices with barcode readers. From time to time, I need to do file manipulation chores. That is: colleagues give me text files that contain barcodes and ask me to transform these.</p>
<p><span id="more-385"></span></p>
<p>Yesterday, a colleague of mine asked me to take as input a file with 12 characters long barcodes and add a check digit assuming the barcodes are EAN13. I decided to do it and also start maintaining a set of barcode helper classes written in Ruby. I haven&#8217;t created a gem yet, cause the functionality is &#8230; lets say limited <img src='http://blog.7deeds.com/wp-includes/images/smilies/icon_smile.gif' alt=':-)' class='wp-smiley' /> , but I plan to do so later.</p>
<p>You can go to</p>
<p><a href="http://github.com/amiridis/rbarcode">http://github.com/amiridis/rbarcode</a> </p>
<p>and just download the barcode.rb file.</p>
<p>Here is how I used the barcode.rb file in order to transform the file:</p>
<pre class="brush: ruby;">
require &quot;barcode&quot;

file = File.open(&quot;apog.txt&quot;)

file.each do |line|
  bc = line.slice(0..11)
  bc13 = Barcode.new(bc).get_ean_13
  puts bc13 + line.slice(12..line.length)
end

file.close
</pre>
<p>The file had the following format:</p>
<pre class="brush: plain;">
520532435284;1;09
520532435285;1;09
520532463580;1;09
</pre>
<p>and for the three lines above it produces:</p>
<pre class="brush: plain;">
5205324352841;1;09
5205324352858;1;09
5205324635807;1;09
</pre>
<p><strong>Update</strong>: I have changed this project to a gem. You can read about it in my <a href="http://blog.7deeds.com/2009/12/30/pabarcode-gem/">PAbarcode gem</a> post.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.7deeds.com/2009/12/23/ruby-barcodes/feed/</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
	</channel>
</rss>
