<?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>blog.7thcross.com</title>
	<atom:link href="http://blog.7thcross.com/?feed=rss2" rel="self" type="application/rss+xml" />
	<link>http://blog.7thcross.com</link>
	<description>busy with web &#38; rails</description>
	<lastBuildDate>Mon, 26 Jan 2009 15:40:36 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.0.1</generator>
		<item>
		<title>Script to say Alpha, Bravo, Charlie, Delta&#8230;</title>
		<link>http://blog.7thcross.com/?p=34</link>
		<comments>http://blog.7thcross.com/?p=34#comments</comments>
		<pubDate>Mon, 26 Jan 2009 15:38:53 +0000</pubDate>
		<dc:creator>blj</dc:creator>
				<category><![CDATA[tools]]></category>
		<category><![CDATA[javascript]]></category>
		<category><![CDATA[prototype]]></category>

		<guid isPermaLink="false">http://blog.7thcross.com/?p=34</guid>
		<description><![CDATA[I just cannot remember the NATO phonetic alphabet especially when I had to spell out the software activation key to customers on phone. Anyway, to help me I have this script when on click would reveal the alphabets. The NATO phonetic alphabet javascript is available on github. Feel free to do whatever you want to [...]]]></description>
			<content:encoded><![CDATA[<p>I just cannot remember the <a href="http://en.wikipedia.org/wiki/NATO_phonetic_alphabet">NATO phonetic alphabet</a> especially when I had to spell out the software activation key to customers on phone. Anyway, to help me I have this script when on click would reveal the alphabets.</p>
<p>The <a href="http://github.com/blj/phonetic-alphabets/">NATO phonetic alphabet javascript</a> is available on github. Feel free to do whatever you want to do with it.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.7thcross.com/?feed=rss2&amp;p=34</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Using the older Rake (0.7.3)</title>
		<link>http://blog.7thcross.com/?p=30</link>
		<comments>http://blog.7thcross.com/?p=30#comments</comments>
		<pubDate>Fri, 02 Jan 2009 10:10:32 +0000</pubDate>
		<dc:creator>blj</dc:creator>
				<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[0.7.3]]></category>
		<category><![CDATA[0.8.3]]></category>
		<category><![CDATA[1.2.3]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[error]]></category>
		<category><![CDATA[rails]]></category>
		<category><![CDATA[rake]]></category>

		<guid isPermaLink="false">http://blog.7thcross.com/?p=30</guid>
		<description><![CDATA[You have updated rake to the newer version and only to find out that it does not work with older Rails tasks. Certainly the rake 0.8.3 is not compatible with the Rails 1.2.3. If you try rake db:migrate, it fails with error: undefined method `last' for {:prepare=&#62;:environment}:Hash. To invoke the older rake use rake _0.7.3_ [...]]]></description>
			<content:encoded><![CDATA[<p>You have updated rake to the newer version and only to find out that it does not work with older Rails tasks.</p>
<p>Certainly the rake 0.8.3 is not compatible with the Rails 1.2.3. If you try <code>rake db:migrate</code>, it fails with error: <code>undefined method `last' for {:prepare=&gt;:environment}:Hash</code>.</p>
<p>To invoke the older rake use <code>rake _0.7.3_ db:migrate</code>. Obviously rake version 0.7.3 must be installed.</p>
<h2>Older rake on remote</h2>
<p>To invoke older rake in the remote server on your capistrano task, such as <code>cap deploy:migrate</code>, set which rake to use in the deploy.rb using <code>set :rake, "rake _0.7.3_"</code>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.7thcross.com/?feed=rss2&amp;p=30</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Juggernaut Rails Rake Tasks &amp; Capistrano Tasks</title>
		<link>http://blog.7thcross.com/?p=29</link>
		<comments>http://blog.7thcross.com/?p=29#comments</comments>
		<pubDate>Wed, 03 Sep 2008 19:09:48 +0000</pubDate>
		<dc:creator>blj</dc:creator>
				<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[juggenaut]]></category>
		<category><![CDATA[manage]]></category>
		<category><![CDATA[process]]></category>
		<category><![CDATA[push server]]></category>
		<category><![CDATA[rake task]]></category>

		<guid isPermaLink="false">http://blog.7thcross.com/?p=29</guid>
		<description><![CDATA[Manage juggernaut push server process via rake using juggernaut rake tasks and juggernaut capistrano tasks.]]></description>
			<content:encoded><![CDATA[<p>Manage juggernaut push server process via rake using <a title="juggernaut rake tasks pastie" href="http://pastie.textmate.org/private/zjwumrzfvfbavx08fkns7a">juggernaut rake tasks</a> and <a href="http://pastie.textmate.org/private/03lrbkjx1m17cesrzpjhda">juggernaut capistrano tasks</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.7thcross.com/?feed=rss2&amp;p=29</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Rails NULL Encoding of MySQL Results</title>
		<link>http://blog.7thcross.com/?p=28</link>
		<comments>http://blog.7thcross.com/?p=28#comments</comments>
		<pubDate>Thu, 14 Aug 2008 11:32:52 +0000</pubDate>
		<dc:creator>blj</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[character set]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[latin1]]></category>
		<category><![CDATA[results]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://blog.7thcross.com/?p=28</guid>
		<description><![CDATA[If you are not careful, the encoding that you set in database.yml may bring some ill-effects. The encoding: utf8 causes ActiveRecord connection to execute set names = 'utf8' in the MySQL session. This tells MySQL server that the this particular session sends and want to receive everything in utf8 character set. Even the column stored [...]]]></description>
			<content:encoded><![CDATA[<p>If you are not careful, the encoding that you set in database.yml may bring some ill-effects. The <code>encoding: utf8</code> causes ActiveRecord connection to execute <code>set names = 'utf8'</code> in the MySQL session. This tells MySQL server that the this particular session sends and want to receive everything in utf8 character set. </p>
<p>Even the column stored in &#8216;latin1&#8242; is converted to &#8216;utf8&#8242;. This takes a considerable hit on the performance, I also have a suspicion that MySQL does not cache results when it is forced to do the conversion.</p>
<h3>How to avoid</h3>
<p>1. Store data in correct encoding as it needs. </p>
<p>2. By telling MySQL to not convert the results by initaliazing rails with&#8230;</p>
<pre>
ActiveRecord::Base.connection.execute('SET CHARACTER_SET_RESULTS = NULL')
</pre>
]]></content:encoded>
			<wfw:commentRss>http://blog.7thcross.com/?feed=rss2&amp;p=28</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>MySQL: Encoding issues &#8211; latin1 to utf8 &#8211; easy</title>
		<link>http://blog.7thcross.com/?p=27</link>
		<comments>http://blog.7thcross.com/?p=27#comments</comments>
		<pubDate>Wed, 13 Aug 2008 21:54:22 +0000</pubDate>
		<dc:creator>blj</dc:creator>
				<category><![CDATA[mysql]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[encoding]]></category>
		<category><![CDATA[latin1]]></category>
		<category><![CDATA[utf8]]></category>

		<guid isPermaLink="false">http://blog.7thcross.com/?p=27</guid>
		<description><![CDATA[There are many reasons why you should get the encoding right in the mysql columns. Unfortunately when you started it, the databases default encoding was in latin1 and now you want to convert to utf8 as per your needs. You can easily do it within the mysql. Lets do this using an example. For this [...]]]></description>
			<content:encoded><![CDATA[<p>There are many reasons why you should get the encoding right in the mysql columns. Unfortunately when you started it, the databases default encoding was  in latin1 and now you want to convert to utf8 as per your needs. You can easily do it within the mysql. </p>
<p>Lets do this using an example. For this purpose we have a table called <code>news</code>. This used to have default encoding as latin1, so the column <code>title varchar(255)</code> and <code>content text</code> were storing values in latin1. </p>
<p>To change the values from latin1 to utf8 for the two string columns:</p>
<p><strong>Step 1:</strong> set the original default encoding to the columns:</p>
<pre>alter table news
       modify title varchar(255) character set 'latin1',
       modify content text character set 'latin1';</pre>
<p><strong>Step 2:</strong> now change the column type to binary types:</p>
<pre>alter table news
       modify title varbinary(255),
       modify content varbinary(65536);</pre>
<p><strong>Step 3:</strong> now convert to utf8:</p>
<pre>alter table news
        modify title varchar(255) character set 'utf8',
        modify content text character set 'utf8';</pre>
<p>This is it, you should be all converted from latin1 to utf8. Also remember to pass the original attributes of the those columns again when using modify column.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.7thcross.com/?feed=rss2&amp;p=27</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Database Character Set Latin1 to UTF8</title>
		<link>http://blog.7thcross.com/?p=26</link>
		<comments>http://blog.7thcross.com/?p=26#comments</comments>
		<pubDate>Tue, 12 Aug 2008 14:18:51 +0000</pubDate>
		<dc:creator>blj</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.7thcross.com/?p=26</guid>
		<description><![CDATA[Update: This post has inaccuracies and should no longer be used as a guide, but you may find latin1 to utf8 useful. I was long struggling with the problem of migrating some data from a legacy DB to a Rails application. The original character set was in latin1 and the data were all messed up. [...]]]></description>
			<content:encoded><![CDATA[<p><ins datetime="2008-08-13T21:58:21+00:00">Update: This post has inaccuracies and should no longer be used as a guide, but you may find <strong><a href="http://blog.7thcross.com/?p=27">latin1 to utf8</a></strong> useful.</ins></p>
<p>I was long struggling with the problem of migrating some data from a legacy DB to a Rails application. The original character set was in latin1 and the data were all messed up. Further it does not copy exactly when I try to copy via rails to the new model. I finally have a solution that is uglier than the problem.</p>
<h2>Source latin1/non-utf database</h2>
<p>The source database should be dumped into a file with this&#8230;</p>
<pre>
mysqldump --default-character-set=latin1 --skip-set-charset -u<your username> -p<your password> dbname > source.sql
</pre>
<p>Next, replace latin1 in the dumped sql with utf8 using&#8230;</p>
<pre>
sed 's/latin1/utf8/g' dumpfile.sql > source_utf8.sql
</pre>
<p>Perhaps you can re-create the database again in a different computer, that way you do not lose the original source database or create another database using&#8230;</p>
<pre>
  CREATE DATABASE dbname_utf8 CHARACTER SET utf8 COLLATE utf8_general_ci;
</pre>
<p>Now dump the data into the new temporary database that we use to migrate from</p>
<pre>
  mysql -uUSER dbname_utf8 < source_utf8.sql
</pre>
<h3>Copying to the destination</h3>
<p>Now the madness, I call it madness because it only works if I precisely did it this way. I kind of understand the reason but not 100% sure.</p>
<p>As an example, in the source database dbname_utf8 you have a table that we will map to a model say OldNews and we have a News model for the rails app and we want to copy the data across. The steps that worked for me are...</p>
<ul>
<li>Create or alter the new table in the rails app, in this case it will be news with utf8 charset columns.</li>
<li>Set utf8 as encoding for source (dbname_utf8) and destination databases  in your config/database.yml</li>
<li>Do not use any Iconv stuff, it made a bigger mess of my data</li>
<li>Make a method that will help you to migrate the data across from OldNews to the News</li>
<li>Now alter the database.yml to whatever the original default encoding was for the new database or remove the utf8 encoding.</li>
</ul>
<p>Thats it, the above worked for me after a lots of trial and error. Hope it works for others in similar position.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.7thcross.com/?feed=rss2&amp;p=26</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>AppleScript Tools and the GUI</title>
		<link>http://blog.7thcross.com/?p=25</link>
		<comments>http://blog.7thcross.com/?p=25#comments</comments>
		<pubDate>Tue, 12 Aug 2008 06:39:37 +0000</pubDate>
		<dc:creator>blj</dc:creator>
				<category><![CDATA[tools]]></category>
		<category><![CDATA[applescript]]></category>

		<guid isPermaLink="false">http://blog.7thcross.com/?p=25</guid>
		<description><![CDATA[Some applications do not expose API (Dictionary?) and you have no choice than to script-mimic the GUI events. AppleScipt on its own reminds me of COBOL (exaggerated) and scripting GUI is not proving to be easy either. The UIElementInspector, an easy to use app proves to be handly. It gives the full hierarchy of an [...]]]></description>
			<content:encoded><![CDATA[<p>Some applications do not expose API (Dictionary?) and you have no choice than to script-mimic the GUI events. AppleScipt on its own reminds me of COBOL (exaggerated) and scripting GUI is not proving to be easy either. The <a href="http://www.apple.com/applescript/uiscripting/02.html">UIElementInspector</a>, an easy to use app proves to be handly. It gives the full hierarchy of an UI element. You would really appreciate it when your code seems fine but is unable to find the menu item that looks like &#8220;Export Image&#8230;&#8221;, people expect it to be an ellipsis but no they are three periods.</p>
<h3>AppleScript tools</h3>
<p>Anyway, I am a beginner of AppleScript and I found these tools quite useful:</p>
<ul>
<li><strong>Editor:</strong> AppleScript Editor sucks, <a href="http://macromates.com/">TextMate</a> wins.</li>
<li><strong>Dictionary:</strong> To view the exposed APIs <a href="http://appscript.sourceforge.net/tools.html">appscript tools&#8217; ASDictionary</a> comes handy, which does a decent job of listing all the Objects and Methods in HTML can also show them in Ruby, Python, AppleScript and ObjectiveC terminologies.</li>
<li><strong>Language Translator</strong> If you appreciated Ruby instead of AppleScript or Python or Objective C for that matter, using <a href="http://appscript.sourceforge.net/tools.html">ASTranslator</a> may help. Very handy when your google search returned snippets of AppleScript and you are scripting in Ruby.</li>
<li><strong>GUI Elements:</strong> Of course the above mentioned <a href="http://www.apple.com/applescript/uiscripting/02.html">UIElementInspector</a> when you have no idea what is the hierarchy of a particular element.</li>
</ul>
<p>Is there any other tool that I should know?</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.7thcross.com/?feed=rss2&amp;p=25</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Midnight publishing of objects &amp; MySQL Query Cache</title>
		<link>http://blog.7thcross.com/?p=24</link>
		<comments>http://blog.7thcross.com/?p=24#comments</comments>
		<pubDate>Wed, 06 Aug 2008 21:43:39 +0000</pubDate>
		<dc:creator>blj</dc:creator>
				<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[code optimise]]></category>

		<guid isPermaLink="false">http://blog.7thcross.com/?p=24</guid>
		<description><![CDATA[Usually we have to list objects that are published or expired on some day or time, for e.g. in a shop catalog, say you want to make a product available on a particular date and your conditions may look like the following in a Rails model: named_scope :available, lambda{ { :conditions=>["products.is_available = 1 and products.available_at]]></description>
			<content:encoded><![CDATA[<p>Usually we have to list objects that are published or expired on some day or time, for e.g. in a shop catalog, say you want to make a product available on a particular date and your conditions may look like the following in a Rails model:</p>
<pre>
  named_scope :available, lambda{
    {
      :conditions=>["products.is_available = 1 and products.available_at <= ?", Time.now.to_s(:db)]
    }
  }
</pre>
<p>MySQL has a facility to cache the results of queries and respond quickly when asked again. To make use of it, the query should be constant. In the above, the <code>Time.now</code> changing every second, you end up asking MySQL with different query every second. In reality, many listings can work without being too sensitive to time. You can publish at midnight without doing much harm. A simple change to <code>Date.today.at_midnight</code> or even the immediate hour can result in great performance of your queries: </p>
<pre>
  named_scope :available, lambda{
    {
      :conditions=>["products.is_available = 1 and products.available_at <= ?", Date.today.at_midnight.to_s(:db)]
    }
  }
</pre>
<ul>
<li>More on <a href="http://dev.mysql.com/tech-resources/articles/mysql-query-cache.html">MySQL Query Caching</a>.</li>
<li>Also worth taking a note of <a href="http://luckysneaks.com/blog/when-now-is-not-now">Time.zone</a></li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://blog.7thcross.com/?feed=rss2&amp;p=24</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>UTF8 BOM, Rails Views &amp; Phantom Space</title>
		<link>http://blog.7thcross.com/?p=22</link>
		<comments>http://blog.7thcross.com/?p=22#comments</comments>
		<pubDate>Sat, 02 Aug 2008 07:47:28 +0000</pubDate>
		<dc:creator>blj</dc:creator>
				<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[formatting problem]]></category>
		<category><![CDATA[rails views]]></category>
		<category><![CDATA[UTF-8 BOM]]></category>

		<guid isPermaLink="false">http://blog.7thcross.com/?p=22</guid>
		<description><![CDATA[Some how my XHTML was not formatting properly. Firefox, added phantom spacing around an element, which I was not able to recover with the CSS. I found rails was sending a weird character where it merges the template with the view yield. That turned out to be the UTF8 BOM which was added by my [...]]]></description>
			<content:encoded><![CDATA[<p>Some how my XHTML was not formatting properly. <em>Firefox</em>, added <strong>phantom spacing</strong> around an element, which I was not able to recover with the CSS. I found rails was sending a weird character where it merges the template with the view yield. That turned out to be the <a href="http://en.wikipedia.org/wiki/Byte_Order_Mark">UTF8 BOM</a> which  was added by my previous text editors to the view files. Textmate does not add this and it wont remove if the file already has one. The worse part is, rails renderer send this to the browser as it is, even if it is in the middle of the XHTML. </p>
<p>The quick fix is to remove the BOM, if your editor does not allow you to do so, a quick <a href="http://www.google.com/search?q=removing+UTF+8+BOM">google search on removing UTF8 BOM</a> can get you some <a href="http://rishida.net/blog/?p=102">script to remove BOM</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://blog.7thcross.com/?feed=rss2&amp;p=22</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Useful ActiveSupport::Dependencies</title>
		<link>http://blog.7thcross.com/?p=21</link>
		<comments>http://blog.7thcross.com/?p=21#comments</comments>
		<pubDate>Wed, 04 Jun 2008 12:21:37 +0000</pubDate>
		<dc:creator>blj</dc:creator>
				<category><![CDATA[rubyonrails]]></category>
		<category><![CDATA[tools]]></category>
		<category><![CDATA[active_support]]></category>
		<category><![CDATA[dependencies]]></category>
		<category><![CDATA[rails]]></category>

		<guid isPermaLink="false">http://blog.7thcross.com/?p=21</guid>
		<description><![CDATA[It is quite handy to use rails&#8217; auto-loading functionality on a non-rails ruby project. For e.g. if you want the classes in your lib folder to be auto-loaded, the following piece of code will help: require 'active_support' Dependencies.load_paths]]></description>
			<content:encoded><![CDATA[<p>It is quite handy to use rails&#8217; auto-loading functionality on a non-rails ruby project. For e.g. if you want the classes in your lib folder to be auto-loaded, the following piece of code will help:</p>
<pre>
require 'active_support'
Dependencies.load_paths << "#{File.join(File.dirname(__FILE__), 'lib')}"
</pre>
<p>Say you have a file lib/answer.rb which defines <code>class Answer; end;</code>. This will be required when you first use <code>Answer</code> constant in your code. </p>
]]></content:encoded>
			<wfw:commentRss>http://blog.7thcross.com/?feed=rss2&amp;p=21</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
