<?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>dot.Using &#187; ideas</title>
	<atom:link href="http://blog.kesor.net/category/ideas/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.kesor.net</link>
	<description>Making technology about computers, and computers about usability.</description>
	<lastBuildDate>Tue, 30 Aug 2011 00:30:09 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.3.1</generator>
		<item>
		<title>Testing messy bash scripts</title>
		<link>http://blog.kesor.net/2007/12/22/22/</link>
		<comments>http://blog.kesor.net/2007/12/22/22/#comments</comments>
		<pubDate>Sat, 22 Dec 2007 00:01:20 +0000</pubDate>
		<dc:creator>kesor</dc:creator>
				<category><![CDATA[bash]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[refactoring]]></category>

		<guid isPermaLink="false">http://blog.kesor.net/2007/12/22/22/</guid>
		<description><![CDATA[Read this book too! I am reading the book “Refactoring” by Martin Fowler, and just reek with ideas about improving software, as well as solving problems I head-banged during my “software” development career. On my last job, there was this huge messy heap of bash scripts that were “The Installation” of their main software product. [...]]]></description>
			<content:encoded><![CDATA[<div style="text-align:justify">
<div style="float:right;margin-left:2em">Read this book too!<br/><iframe src="http://rcm.amazon.com/e/cm?t=kesornet-20&#038;o=1&#038;p=8&#038;l=as1&#038;asins=0201485672&#038;fc1=000000&#038;IS2=1&#038;lt1=_blank&#038;lc1=0000FF&#038;bc1=000000&#038;bg1=FFFFFF&#038;f=ifr&#038;npa=1" style="width:120px;height:240px;" scrolling="no" marginwidth="0" marginheight="0" frameborder="0"></iframe></div>
<p>I am reading the book “Refactoring” by Martin Fowler, and just reek with ideas about improving software, as well as solving problems I head-banged during my “software” development career.</p>
<p>On my last job, there was this huge messy heap of bash scripts that were “The Installation” of their main software product. It was a remarkable amount of bad smelling bash code, however it somehow managed to work. My work, at the time, was from-scratch-rewrites of this or that functionality and then somehow plugging it into the existing framework (damn, i call it a framework now).</p>
<p><span id="more-22"></span></p>
<p>It could have been just amazing if I could take the existing <u><a href="http://steve-yegge.blogspot.com/2007/12/codes-worst-enemy.html"><strike>pile of dirt</strike></a></u> <strike>dung</strike> bash scripts &#8211; and refactor it into something that is readable, sort of.</p>
<p>Today, while I was riding the bus, reading “Refactoring” pg.110, it struck me. It’s actually can be extremely easy to <b>test bash scripts!</b> All it takes is a collection of all the familiar commands, like “cat”, “rm”, etc … and one sneaky PATH environment variable. These commands would be fakes, stubs &#8211; they all just print their name and parameters into a log file. In fact, there is just one actual script and the rest are links to that single one.</p>
<p>That log file can be compared before and after a refactoring. It takes less time to output names and parameters to a file than to execute the actual commands. So while running the actual script might take hours, with the stubs it should run in less time, much less. Finally, by comparing your pre and post refactoring log files, you get a really nice test-suite that can help you refactor. I might even call it replacing unreadable code with readable one without breaking much of anything.</p>
<p>In the particular case of the scripts that I’ve mentioned earlier, I guess that the most used refactoring to improve readability would be <i>Inline Method</i>. Whoever wrote the original scripts was very fond of <i>wrappers</i> for commands like &#8220;ln&#8221;. Even though commands like “ln” don’t really need a wrapper. The wrapper with at least two echo commands and a very long name is quite redundant and adds unnecessary complexity.</p>
<p>There are several problems with this simplistic approach though. One of the problems might be that the script is using full path in names (like /bin/ln), instead of relying on the PATH environment variable. Such things can be relatively easily taken care of until the testing solution is perfect. (I guess). One of the things to try, for example, is running bash in restricted mode, if I remember what that is correctly.</p>
<p>I’ll try that on some new messy scripts that I got on my new job!</p>
<p>YEY!
</p></div>
<p>PS: Google docs rocks! (even publish-to-blog kinda works) </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kesor.net/2007/12/22/22/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Invite the world to GMail</title>
		<link>http://blog.kesor.net/2007/09/01/invite-the-world-to-gmail/</link>
		<comments>http://blog.kesor.net/2007/09/01/invite-the-world-to-gmail/#comments</comments>
		<pubDate>Sat, 01 Sep 2007 18:28:20 +0000</pubDate>
		<dc:creator>kesor</dc:creator>
				<category><![CDATA[google]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[usability]]></category>

		<guid isPermaLink="false">http://blog.kesor.net/2007/09/01/invite-the-world-to-gmail/</guid>
		<description><![CDATA[The other day I noticed that I have this &#8220;Invite a friend&#8221; on my GMail. I didn&#8217;t use that thing for more than a year, so I took the chance of this re-discovery to get rid of it. Within several minutes I sent 98 invitations to an imaginary friend whose mail bounced at some noreply@somewhere&#8230; [...]]]></description>
			<content:encoded><![CDATA[<p>The other day I noticed that I have this &#8220;Invite a friend&#8221; on my GMail. I didn&#8217;t use that thing for more than a year, so I took the chance of this re-discovery to get rid of it. Within several minutes I sent 98 invitations to an imaginary friend whose mail bounced at some noreply@somewhere&#8230; address. And it worked &#8211; I got rid of that little blue box that serves no purpose on my GMail page!</p>
<p>Imagine my surprise when today I find that box at the same place, with 50 new invitations to give away.</p>
<p>No, really &#8211; I don&#8217;t have any friends who don&#8217;t have a GMail account. I don&#8217;t want to use this &#8220;feature&#8221;, ever. And it does not contribute a thing to my GMail experience &#8211; get rid of it Google! Put some AdSense there or something.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kesor.net/2007/09/01/invite-the-world-to-gmail/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>HAML Caching CGI</title>
		<link>http://blog.kesor.net/2007/07/30/haml-caching-cgi/</link>
		<comments>http://blog.kesor.net/2007/07/30/haml-caching-cgi/#comments</comments>
		<pubDate>Mon, 30 Jul 2007 08:38:23 +0000</pubDate>
		<dc:creator>kesor</dc:creator>
				<category><![CDATA[apache]]></category>
		<category><![CDATA[development]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[ruby]]></category>

		<guid isPermaLink="false">http://blog.kesor.net/2007/07/30/haml-caching-cgi/</guid>
		<description><![CDATA[Mike Zillion asked about how to make HAML a processor (of haml files) for Apache on the HAML Group on Google. That inspired me to write a proper wrapper with caching that will Hamlize templates into HTML and cache those for speedy access on subsequent requests. This is what I came up with: #!/bin/env ruby [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://www.mikezillion.com">Mike Zillion</a> asked about how to make HAML a processor (of haml files) for Apache on the <a href="http://groups.google.com/group/haml/t/b2fd4dbc5f76cd61">HAML Group</a> on Google. That inspired me to write a proper wrapper with caching that will Hamlize templates into HTML and cache those for speedy access on subsequent requests.</p>
<p>This is what I came up with:<br />
<span id="more-9"></span></p>
<pre lang="ruby">
#!/bin/env ruby

exit if ARGV[0].nil?
exit unless File.exists?(ARGV[0])

CACHE_DIR_NAME='cache'

haml_file = ARGV[0]
haml_time = File.stat(haml_file).mtime

html_file = CACHE_DIR_NAME + '/' + haml_file.sub(/aml$/,'tml')
if File.exists?(html_file)
  html_time = File.stat(html_file).mtime

  if html_time > haml_time
    output = File.read(html_file)
  end
end

if output.nil?
  require 'rubygems'
  require 'haml'
  template = File.read(haml_file)
  haml_engine = Haml::Engine.new(template)
  output = haml_engine.to_html()

  # cache the output
  Dir.mkdir(CACHE_DIR_NAME) unless File.directory?(CACHE_DIR_NAME)
  html_file_io = File.open(html_file,"w")
  html_file_io.print(output)
  File.utime(Time.now, haml_time, html_file)
end

# unbuffer output
$stdout.sync = true

require 'cgi'
ENV['SERVER_SOFTWARE'] ||= 'not set'
cgi = CGI.new('html3')
print cgi.header(
        'type'     => 'text/html',
        'charset'  => 'UTF-8',
        'length'   => output.length,
        'server'   => ENV['SERVER_SOFTWARE'],
        'expires'  => Time.now + 10*3600*24, # 10 days
        'Pragma'   => 'no-cache',
        'Last-Modified' => haml_time,
        'Cache-Control' => 'no-cache'
)
print output
</pre>
<p>And as Mike suggested, adding a couple lines to your Apache configuration makes all the difference:</p>
<pre line="1">
  AddType text/haml .haml
  AddHandler haml-file .haml
  Action haml-file /dev/bin/haml_cache_cgi.rb
  Action text/haml /dev/bin/haml_cache_cgi.rb
</pre>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kesor.net/2007/07/30/haml-caching-cgi/feed/</wfw:commentRss>
		<slash:comments>4</slash:comments>
		</item>
		<item>
		<title>Writing helpers with Haml and rSpec</title>
		<link>http://blog.kesor.net/2007/07/22/writing-helpers-with-haml-and-rspec/</link>
		<comments>http://blog.kesor.net/2007/07/22/writing-helpers-with-haml-and-rspec/#comments</comments>
		<pubDate>Sun, 22 Jul 2007 19:02:46 +0000</pubDate>
		<dc:creator>kesor</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[haml]]></category>
		<category><![CDATA[ideas]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rspec]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[specifications]]></category>

		<guid isPermaLink="false">http://blog.kesor.net/2007/07/22/writing-helpers-with-haml-and-rspec/</guid>
		<description><![CDATA[Recently Wolfman posted a description about Rails helpers written with Haml::Helpers#open and rSpec. I want it to be more DRY than it is, since the whole application is using rSpec and Haml, all helpers should have the same before(:each) So basically &#8211; what I did was : [source:ruby] Spec::Runner.configure do &#124;config&#124; config.with_options :behaviour_type => :helpers [...]]]></description>
			<content:encoded><![CDATA[<p>Recently <a href="http://blog.wolfman.com/articles/2007/07/14/using-rspec-to-test-haml-helpers">Wolfman</a> posted a description about <a target="_blank" title="Ruby on Rails" href="http://www.rubyonrails.com">Rails</a> helpers written with <a target="_blank" title="HAML" href="http://haml.hamptoncatlin.com">Haml</a>::<a target="_blank" title="HAML::Helpers RDoc" href="http://haml.hamptoncatlin.com/docs/rdoc/classes/Haml/Helpers.html">Helpers#open</a> and <a target="_blank" title="rSpec" href="http://rspec.rubyforge.org">rSpec</a>.</p>
<p>I want it to be more DRY than it is, since the whole application is using rSpec and Haml, all helpers should have the same <code>before(:each)</code></p>
<p>So basically &#8211; what I did was :</p>
<p><span id="more-8"></span><br />
[source:ruby]<br />
Spec::Runner.configure do |config|<br />
  config.with_options :behaviour_type => :helpers do |config|<br />
    config.include Haml::Helpers<br />
    config.include ActionView::Helpers<br />
    config.prepend_before :all do<br />
      @haml_is_haml = true<br />
      @haml_stack = [Haml::Buffer.new]<br />
    end<br />
  end<br />
end<br />
[/source]</p>
<p>Except it will not work, for various reasons.</p>
<p>Hope to solve all the quirks sometime soon. I know this will cost me some sleep.</p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kesor.net/2007/07/22/writing-helpers-with-haml-and-rspec/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>The Ultimate Development GUI</title>
		<link>http://blog.kesor.net/2006/05/19/the-ultimate-development-gui/</link>
		<comments>http://blog.kesor.net/2006/05/19/the-ultimate-development-gui/#comments</comments>
		<pubDate>Fri, 19 May 2006 14:15:06 +0000</pubDate>
		<dc:creator>kesor</dc:creator>
				<category><![CDATA[development]]></category>
		<category><![CDATA[gui]]></category>
		<category><![CDATA[ideas]]></category>

		<guid isPermaLink="false">http://blog.kesor.net/2006/05/19/the-ultimate-development-gui/</guid>
		<description><![CDATA[For the last several days I have been trying to find the perfect tool for development of the many projects I have. My basic requirement was a good editor (TextMate would be a dream, but I don&#8217;t own a Mac yet), and a good integration with the filesystem &#8211; either remote, or in version control. [...]]]></description>
			<content:encoded><![CDATA[<p>For the last several days I have been trying to find the perfect tool for development of the many projects I have. My basic requirement was a good editor (TextMate would be a dream, but I don&#8217;t own a Mac yet), and a good integration with the filesystem &#8211; either remote, or in version control.</p>
<p>After some tweaks and manipulations &#8211; I have came to use Scintilla + Explorer + TortoiseSVN + WebDAV (windows integrated). Overall this is almost perfect, except one small thing, organizing the different windows on the screen &#8212; and those huge window titles I hate so much. It would be really perfect if the titles were minimal (text height, no more), and the layout would be saved.</p>
<p>This is when it hit me &#8212; why not create a program that will do the layout only?</p>
<p>A really small application &#8211; preferably multiplatform, which will run windows inside it with layout separation for resizing, and with tabs for each window &#8212; for more than one program maybe. So basically you&#8217;ll have what all development studios have &#8212; eclipse for example, but instead of a file explorer you would run Windows Explorer, and instead of a version control plugin you would have TortoiseSVN, and instead of WebDAV integration you would also have the explorer. And instead of the text editor window you will have scintilla, or notepad, or whatever . . . and these layouts will be saveable and configurable to include multiple colums or rows, and tabs for each window.</p>
<p>GTK or QT would probably be the best ways to do this and stay multiplatform at the same time.</p>
<p>Ideas are coming at a rate much higher than project completition&#8230;.</p>
<p><strong>Update:</strong> There are several utilities which do something like this, Acer&#8217;s GridVista is one of them for example. Good, but not good enough.</p>
<p></p>
]]></content:encoded>
			<wfw:commentRss>http://blog.kesor.net/2006/05/19/the-ultimate-development-gui/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>

<!-- Dynamic Page Served (once) in 0.450 seconds -->

