<?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>LuckyCatLabs</title>
	<atom:link href="http://blog.luckycatlabs.com/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.luckycatlabs.com</link>
	<description>Making code suck less</description>
	<lastBuildDate>Tue, 16 Mar 2010 01:37:56 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Release (Sort-of): RubySunrise Gem</title>
		<link>http://blog.luckycatlabs.com/2010/03/15/release-sort-of-rubysunrise-gem/</link>
		<comments>http://blog.luckycatlabs.com/2010/03/15/release-sort-of-rubysunrise-gem/#comments</comments>
		<pubDate>Tue, 16 Mar 2010 01:37:07 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[announcement]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[release]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.luckycatlabs.com/?p=67</guid>
		<description><![CDATA[As a follow-up to the Java sunrise/sunset calculator I released early last year, I&#8217;m releasing a ruby gem that does essentially the same thing.  Just in A LOT less code, but with the same attention to test goodness.
To install and use the RubySunrise gem just:
$ gem install RubySunrise
or download from RubyGems. 
The current version [...]]]></description>
			<content:encoded><![CDATA[<p>As a follow-up to the Java sunrise/sunset calculator I released early last year, I&#8217;m releasing a ruby gem that does essentially the same thing.  Just in A LOT less code, but with the same attention to test goodness.</p>
<p>To install and use the RubySunrise gem just:</p>
<blockquote><p>$ gem install RubySunrise</p></blockquote>
<p>or download from <a href="http://rubygems.org/gems/RubySunrise">RubyGems</a>. </p>
<p>The current version as of today is 0.2, which requires the <a href="http://tzinfo.rubyforge.org/">tzinfo</a> gem (link) to perform the timezone offset lookups.</p>
<p>If you want/need the lastest, just grab it from the github repo:</p>
<blockquote><p>
$ git clone git://github.com/mikereedell/sunrisesunset-ruby<br />
$ gem build RubySunrise
</p></blockquote>
<p>At this time the RubySunrise gem covers astronomical, nautical, civil, and official sunrise/sunset calculations for every location that experiences a sunrise and sunset every day (Sorry Alaska!).  I&#8217;m currently working on the strangeness that is causing my Alaskan test suite to fail with known-good data.</p>
<p>Example time:</p>
<pre name="code" class="ruby:nogutter:nocontrols">
require 'solareventcalculator'

date = Date.parse('2008-11-01')
calc = SolarEventCalculator.new(date, BigDecimal.new("39.9537"), BigDecimal.new("-75.7850"))

utcOfficialSunrise = calc.compute_utc_official_sunrise
localOfficialSunrise = calc.compute_official_sunrise('America/New_York')

puts "utcOfficialSunrise #{utcOfficialSunrise}"
puts "localOfficialSunrise #{localOfficialSunrise}"
</pre>
<p>Which yields:</p>
<pre>
utcOfficialSunrise 2008-11-01T11:33:00+00:00
localOfficialSunrise 2008-11-01T07:33:00-04:00
</pre>
<p>The source is available under the Apache License, Version 2.0:<br />
<a href="http://github.com/mikereedell/sunrisesunset-ruby">http://github.com/mikereedell/sunrisesunset-ruby</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.luckycatlabs.com/2010/03/15/release-sort-of-rubysunrise-gem/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Maven with Ruby Part II</title>
		<link>http://blog.luckycatlabs.com/2009/03/20/maven-with-ruby-part-ii/</link>
		<comments>http://blog.luckycatlabs.com/2009/03/20/maven-with-ruby-part-ii/#comments</comments>
		<pubDate>Sat, 21 Mar 2009 01:50:02 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[clearcase]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.luckycatlabs.com/?p=52</guid>
		<description><![CDATA[Want to add something to your projects Maven builds (like code coverage&#8230;) but don&#8217;t want to CTL-C/CTL-V your way to boredom?  Use the below script to lend a hand.  Substitute the XML in the SNIPPET variable to the artifact/plugin/dependency to be injected (leave the  tag in place) and use the command:

$>ruby mavenInjector.rb [...]]]></description>
			<content:encoded><![CDATA[<p>Want to add something to your projects Maven builds (like code coverage&#8230;) but don&#8217;t want to CTL-C/CTL-V your way to boredom?  Use the below script to lend a hand.  Substitute the XML in the SNIPPET variable to the artifact/plugin/dependency to be injected (leave the <inject> tag in place) and use the command:</p>
<pre name="code" class="ruby:nocontrols:nogutter">
$>ruby mavenInjector.rb /xpath/to/element
</pre>
<p>Here&#8217;s the code.  Check the <a href="http://github.com/mikereedell/scripts/tree/master">git repository</a> for the latest.</p>
<p>In the beginning of the &#8216;for&#8217; loop in the inject method I remove the read-only bit from the file.  This is for those of us afflicted with ClearCase and can be removed for those fortunate enough to use a sane SCM.</p>
<pre name="code" class="ruby:nocontrols:nogutter">
#/usr/bin/env ruby
require 'rexml/document.rb'
require 'fileutils.rb'

class MavenInjector

  def inject(path)
    if(path == nil)
      puts 'Must provide the root path of the node to inject under.'
      exit
    end

    poms = Dir[Dir.pwd() + "/**/pom.xml"]

    for pom in poms do
      if(!File.writable?(pom))
        FileUtils.chmod 0644, pom
      end

      pomXML = REXML::Document.new(File.new(pom))
      element = pomXML.get_elements(path)[0]

      if(element == nil)
        parentElement = pomXML.get_elements("/project/build")[0]
        element = REXML::Element.new("plugins", parentElement)
      end

      for plugin in getElementsToInject() do
        element.add_element(plugin)
      end

      formatter = REXML::Formatters::Default.new(4)
      formatter.write(pomXML, File.new(pom, "w+"))
    end
  end

  def getElementsToInject()
    elementXML = REXML::Document.new(SNIPPET)
    return elementXML.get_elements("/inject/plugin")
  end
end

SNIPPET = <<HEAD
<inject>
<plugin>
    <groupId>org.codehaus.mojo</groupId>
    <artifactId>cobertura-maven-plugin</artifactId>
    <configuration>
<formats>
<format>html</format>
        </formats>
    </configuration>
  </plugin>
</inject>
HEAD

MavenInjector.new.inject(ARGV[0])
</pre>
<p>Any questions/problems/enhancements are welcome in the comments.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.luckycatlabs.com/2009/03/20/maven-with-ruby-part-ii/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using Ruby To Help Maven</title>
		<link>http://blog.luckycatlabs.com/2009/03/13/using-ruby-to-help-maven/</link>
		<comments>http://blog.luckycatlabs.com/2009/03/13/using-ruby-to-help-maven/#comments</comments>
		<pubDate>Fri, 13 Mar 2009 11:52:14 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[maven]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.luckycatlabs.com/?p=45</guid>
		<description><![CDATA[Maven projects can become a wasteland of neglected, old dependencies: huge, unmanageable pom files  and a local repository that&#8217;s catalog of every Apache project in the past 10 years.  Who knows if your project still requires that old version of Xerces?
This script takes the name of a dependency and removes it from every [...]]]></description>
			<content:encoded><![CDATA[<p>Maven projects can become a wasteland of neglected, old dependencies: huge, unmanageable pom files  and a local repository that&#8217;s catalog of every Apache project in the past 10 years.  Who knows if your project still requires that old version of Xerces?</p>
<p>This script takes the name of a dependency and removes it from every pom.xml in any sub-directory from where it&#8217;s called, removing the dependency element for the given jar file from each one.  The script also saves the <dependency> tree in the file $artifactname.xml in case you need to put it back.</p>
<pre name="code" class="ruby:nocontrols:nogutter">
#/usr/bin/env ruby
require 'rexml/document.rb'

if(ARGV[0] == nil)
  puts 'Must provide the name of the artifact to remove.'
  exit
end

artifact = ARGV[0].chomp
poms = Dir[Dir.pwd() + "/**/pom.xml"]

for pom in poms do
  pomXML = REXML::Document.new(File.new(pom))
  element = pomXML.get_elements("//dependency[artifactId='" + artifact + "']")[0]

  if(element != nil)
    temp = File.new(artifact + ".xml", "w+")
    formatter = REXML::Formatters::Default.new()
    formatter.write(element, temp)
    puts "Removing the dependency: " + artifact + "\nfrom " + pom
    element.parent.delete(element)
    pomXML.write(File.new(pom, "w+"))
  else
    puts "No artifacts with the name:'" + artifact + "' were found."
  end
end
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.luckycatlabs.com/2009/03/13/using-ruby-to-help-maven/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Licensing Your Code the Ruby Way</title>
		<link>http://blog.luckycatlabs.com/2009/01/31/licensing-your-code-the-ruby-way/</link>
		<comments>http://blog.luckycatlabs.com/2009/01/31/licensing-your-code-the-ruby-way/#comments</comments>
		<pubDate>Sat, 31 Jan 2009 19:44:52 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.luckycatlabs.com/?p=31</guid>
		<description><![CDATA[Do you have an existing project you want to open-source?  Does the thought of manually adding the license comment block to EVERY. SINGLE. SOURCE. FILE. sound not-so-exciting?  Here&#8217;s some help, ruby style:

class Licenser

    def licenseFiles(dir)
          filenames = Dir[dir.chop + "**/*.java"]
	  [...]]]></description>
			<content:encoded><![CDATA[<p>Do you have an existing project you want to open-source?  Does the thought of manually adding the license comment block to EVERY. SINGLE. SOURCE. FILE. sound not-so-exciting?  Here&#8217;s some help, ruby style:</p>
<pre name="code" class="ruby:nocontrols:nogutter">
class Licenser

    def licenseFiles(dir)
          filenames = Dir[dir.chop + "**/*.java"]
	  for filename in filenames do
              contents = ''
              File.open(filename, 'r') { |file| contents = file.read }
              contents = HEADER + contents
              File.open(filename, 'w') { |file| file.write(contents) }
          end
    end
end

HEADER = &lt;&lt;HEAD
/*
 * Copyright 2008-2009 Mike Reedell / LuckyCatLabs.
 *
 * Licensed under the Apache License, Version 2.0 (the "License");
 * you may not use this file except in compliance with the License.
 * You may obtain a copy of the License at
 *
 *      http://www.apache.org/licenses/LICENSE-2.0
 *
 * Unless required by applicable law or agreed to in writing, software
 * distributed under the License is distributed on an "AS IS" BASIS,
 * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 * See the License for the specific language governing permissions and
 * limitations under the License.
 */

HEAD

	Licenser.new.licenseFiles(ARGV[0])
</pre>
<p>This script was inspired by the the <a href="http://svn.apache.org/viewvc/incubator/ode/trunk/tasks/check_license_headers.rb?revision=524802&#038;view=markup&#038;pathrev=524802">check_license_headers.rb</a> script in the Apache SVN repo.  Couldn&#8217;t get it to work on my setup, so I rewrote the parts I needed.</p>
<p>This can be found in the <a href="http://github.com/mikereedell/scripts/tree/master">LuckyCat Labs GitHub scripts project</a>.  Look for updates to handle more source types and to check for existing license headers.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.luckycatlabs.com/2009/01/31/licensing-your-code-the-ruby-way/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Release: Sunrise/Sunset Java Library</title>
		<link>http://blog.luckycatlabs.com/2009/01/27/release-sunrisesunset-java-library/</link>
		<comments>http://blog.luckycatlabs.com/2009/01/27/release-sunrisesunset-java-library/#comments</comments>
		<pubDate>Wed, 28 Jan 2009 03:21:54 +0000</pubDate>
		<dc:creator>mike</dc:creator>
				<category><![CDATA[announcement]]></category>
		<category><![CDATA[java]]></category>
		<category><![CDATA[open source]]></category>
		<category><![CDATA[release]]></category>

		<guid isPermaLink="false">http://blog.luckycatlabs.com/?p=3</guid>
		<description><![CDATA[New from LuckyCat Labs is a Java library that computes the sunrise / sunset using GPS coordinates and today&#8217;s date.  To use, simply download the tar or zip file from the GitHub page, or use git to pull the source:
$ git clone git://github.com/mikereedell/sunrisesunsetlib-java
Once you have the source, use the command:
$ ant all
To compile the source, [...]]]></description>
			<content:encoded><![CDATA[<p>New from LuckyCat Labs is a Java library that computes the sunrise / sunset using GPS coordinates and today&#8217;s date.  To use, simply download the tar or zip file from the <a title="GitHub Page" href="http://mikereedell.github.com/sunrisesunsetlib-java/">GitHub page</a>, or use git to pull the source:</p>
<pre>$ git clone git://github.com/mikereedell/sunrisesunsetlib-java</pre>
<p>Once you have the source, use the command:</p>
<pre>$ ant all</pre>
<p>To compile the source, build the bin, src, and test jars, execute the unit tests and generate the JavaDoc for the library.</p>
<p>This code snippet illustrates the main usage pattern:</p>
<pre name="code" class="java:nogutter:nocontrols">
// Location of sunrise/set, as latitude/longitude.
Location location = new Location("39.9937", "-75.7850");

// Create calculator object with the location and time zone identifier.
SunriseSunsetCalculator calculator = new SunriseSunsetCalculator(location, "America/New_York");

Calendar date = Calendar.getInstance();
String dawn = calculator.getCivilSunriseForDate(date);
String dusk = calculator.getCivilSunsetForDate(date);
</pre>
<p>The list of supported time zone identifiers is given by:</p>
<pre name="code" class="java:nogutter:nocontrols">
//Returns String[] of supported tz identifiers.
TimeZone.getAvailableIDs();
</pre>
<p>Any feedback? Comments? Features? Bugs?  Comment below or add to the <a href="http://github.com/mikereedell/sunrisesunsetlib-java/tree/master">project wiki</a>.</p>
<p>Released under the <a title="Apache License 2.0" href="http://www.apache.org/licenses/LICENSE-2.0" target="_self">Apache License 2.0.</a></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.luckycatlabs.com/2009/01/27/release-sunrisesunset-java-library/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
	</channel>
</rss>
