<?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>The eflow blog &#187; script</title>
	<atom:link href="http://blog.eflow.org/archives/tag/script/feed" rel="self" type="application/rss+xml" />
	<link>http://blog.eflow.org</link>
	<description>Insert some amazingly witty tagline here</description>
	<lastBuildDate>Fri, 09 Dec 2011 18:59:40 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.3</generator>
		<item>
		<title>Script to Find Unused Message Keys in Message.properties Files</title>
		<link>http://blog.eflow.org/archives/325</link>
		<comments>http://blog.eflow.org/archives/325#comments</comments>
		<pubDate>Thu, 06 Jan 2011 19:55:44 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[babble]]></category>
		<category><![CDATA[openmrs]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[messages]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[spring]]></category>

		<guid isPermaLink="false">http://blog.eflow.org/?p=325</guid>
		<description><![CDATA[Over time the messages in our Spring message.properties files grow stale. When a developer updates/changes code he/she doesn&#8217;t necessarily go to the messages.properties and remove all the keys that they removed from code. This has not detrimental effect on code, it just means that when translating into a new language the translator is potentially more [...]]]></description>
			<content:encoded><![CDATA[<p>Over time the messages in our Spring message.properties files grow stale.  When a developer updates/changes code he/she doesn&#8217;t necessarily go to the messages.properties and remove all the keys that they removed from code.  This has not detrimental effect on code, it just means that when translating into a new language the translator is potentially more work than they need to.</p>
<p>I wrote this quick shell script to loop over the file and do a recursive grep for that key.  The key is considered &#8220;used&#8221; if it exists in the current directory with quotes around it (single or double).  This WILL NOT find keys if they are only used programmatically. (e.g. VAR + &#8220;.started&#8221;)</p>
<blockquote><p>
#!/bin/sh</p>
<p># Loops over all the keys in the given messages.properties file<br />
# and looks in the current directory for the string in quotes.<br />
# Results are printed to stdout<br />
#<br />
# use: (from the &#8220;web&#8221; dir in openmrs)<br />
# sh ./findunusedmessages.sh WEB-INF/messages.properties</p>
<p>propfile=$1<br />
props=`awk -F= &#8216;{print $1}&#8217; $propfile`<br />
count=0<br />
total=0</p>
<p>echo &#8220;These property keys were not found in the code base:&#8221;<br />
for prop in $props<br />
do<br />
 #echo &#8220;Looking for property: $prop&#8221;<br />
 if [ ! -z "$prop" ];<br />
 then<br />
   total=`expr $total + 1`<br />
   output=`grep &#8211;exclude-dir=&#8221;.svn&#8221; -re &#8220;[\'\"]$prop[\'\"]&#8221; *`<br />
   if [ -z "$output" ];<br />
   then<br />
     echo &#8220;$prop&#8221;<br />
     count=`expr $count + 1`<br />
   fi<br />
 fi<br />
done</p>
<p>echo &#8220;done! Found $count possibly uneeded message keys in $propfile (out of $total total keys)&#8221;
</p></blockquote>
<p>Download the file here: <a href='http://blog.eflow.org/wp-content/uploads/2011/01/findunusedmessages.sh'>findunusedmessages.sh</a><br />
<br/><br />
<br/></p>
 <img src="http://blog.eflow.org/wp-content/plugins/feed-statistics.php?view=1&post_id=325" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.eflow.org/archives/325/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Updating UUID Column in the Large Obs Table</title>
		<link>http://blog.eflow.org/archives/276</link>
		<comments>http://blog.eflow.org/archives/276#comments</comments>
		<pubDate>Thu, 07 Jan 2010 15:43:04 +0000</pubDate>
		<dc:creator>Ben</dc:creator>
				<category><![CDATA[openmrs]]></category>
		<category><![CDATA[mysql]]></category>
		<category><![CDATA[script]]></category>
		<category><![CDATA[sql]]></category>
		<category><![CDATA[uuid]]></category>

		<guid isPermaLink="false">http://blog.eflow.org/?p=276</guid>
		<description><![CDATA[We have well over 50 million rows in our obs table. Using the simple &#8220;update obs set uuid = uuid() where uuid is null&#8221; would bomb out with a &#8220;The total number of locks exceeds the lock table size&#8221; error. I ran this for a few hours to get through all rows. (Note that it [...]]]></description>
			<content:encoded><![CDATA[<p>We have well over 50 million rows in our obs table.  Using the simple &#8220;update obs set uuid = uuid() where uuid is null&#8221; would bomb out with a &#8220;The total number of locks exceeds the lock table size&#8221; error.</p>
<p>I ran this for a few hours to get through all rows.  (Note that it overwrites any uuids that are currently there)</p>
<p>Copy this into a sql script and run it with &#8220;source&#8221; in mysql at command line.</p>
<blockquote><p>
drop procedure update_uuids;<br />
delimiter //<br />
create procedure update_uuids() begin<br />
set @max = (select max(obs_id) from obs);<br />
set @x = 1;<br />
repeat<br />
set @y = @x + 100000;<br />
update obs set uuid = uuid() where obs_id >=@x and obs_id <@y;<br />
set @x = @y;<br />
until @x > @max<br />
end repeat;<br />
end<br />
//<br />
delimiter ;<br />
call update_uuids();
</p></blockquote>
 <img src="http://blog.eflow.org/wp-content/plugins/feed-statistics.php?view=1&post_id=276" width="1" height="1" style="display: none;" />]]></content:encoded>
			<wfw:commentRss>http://blog.eflow.org/archives/276/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
	</channel>
</rss>

