<?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>eXpand yOur cReativity &#187; Bhushan G Ahire</title>
	<atom:link href="http://blog.bhushangahire.net/author/admin/feed/" rel="self" type="application/rss+xml" />
	<link>http://blog.bhushangahire.net</link>
	<description>by Bhushan G Ahire</description>
	<lastBuildDate>Mon, 26 Jul 2010 10:25:25 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.8.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>Is your Netbeans running slower? Try this trick.</title>
		<link>http://blog.bhushangahire.net/2010/07/26/is-your-netbeans-running-slower-try-this-trick/</link>
		<comments>http://blog.bhushangahire.net/2010/07/26/is-your-netbeans-running-slower-try-this-trick/#comments</comments>
		<pubDate>Mon, 26 Jul 2010 10:25:25 +0000</pubDate>
		<dc:creator>Bhushan G Ahire</dc:creator>
				<category><![CDATA[General]]></category>
		<category><![CDATA[GC]]></category>
		<category><![CDATA[memory]]></category>
		<category><![CDATA[netbeans]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=223</guid>
		<description><![CDATA[
I use NetBeans 6 all the time on my laptop and have learned how to configure it
to run more effectively for me.
NetBeans, like any Java application needs room to work, and the default memory settings
for Java and NetBeans are usually not what I consider ideal.
Of course how would they know what is ideal, you need [...]]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F07%2F26%2Fis-your-netbeans-running-slower-try-this-trick%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<p>I use NetBeans 6 all the time on my laptop and have learned how to configure it<br />
to run more effectively for me.<br />
NetBeans, like any Java application needs room to work, and the default memory settings<br />
for Java and NetBeans are usually not what I consider ideal.<br />
Of course how would they know what is ideal, you need to tell it.<br />
Granted my solution may not be ideal for others, but it&#8217;s worth playing with.<br />
I&#8217;m using jdk6 update 17.<br />
And even this should work for NetBeans 6, this should work on any platform.</p>
<pre class="brush: ruby;">
on MAC/Linux/Windows netbeans/6.0/etc/netbeans.conf
netbeans_default_options=&quot;-J-Xms256m -J-Xmx512m -J-XX:PermSize=32m -J-XX:MaxPermSize=160m
-J-Xverify:none -J-Dapple.laf.useScreenMenuBar=true -J-XX:+UseConcMarkSweepGC
-J-XX:+CMSClassUnloadingEnabled -J-XX:+CMSPermGenSweepingEnabled&quot;
</pre>
<p>Any change to this file will require a reboot.</p>
<p>Also, turn on the View-&gt;Toolbars-&gt;Memory to keep track of the NetBeans memory usage, clicking<br />
on it will force a GC, and you can get a feeling for how much memory your NetBeans<br />
session needs, making adjustments to the maximums above.<br />
And my recommendation is that the maximum (-J-Xmx) setting should never be more than<br />
the RAM on the machine minus 512m, or system memory thrashing may occur.</p>
<p>Additional information can be found at<br />
<a href="http://www.netbeans.org/kb/faqs/performance.html#FaqGCPauses">the NetBeans FAQ on GC pauses</a><br />
and<br />
<a href="http://wiki.netbeans.org/FaqNetbeansConf">the NetBeans FAQ on configuration</a>.</p>
<p>The above settings make a world of difference in the way NetBeans performs for me.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2010/07/26/is-your-netbeans-running-slower-try-this-trick/&amp;title=Is+your+Netbeans+running+slower%3F+Try+this+trick." rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2010/07/26/is-your-netbeans-running-slower-try-this-trick/&amp;title=Is+your+Netbeans+running+slower%3F+Try+this+trick." rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2010/07/26/is-your-netbeans-running-slower-try-this-trick/&amp;title=Is+your+Netbeans+running+slower%3F+Try+this+trick." rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2010/07/26/is-your-netbeans-running-slower-try-this-trick/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2010/07/26/is-your-netbeans-running-slower-try-this-trick/&amp;t=Is+your+Netbeans+running+slower%3F+Try+this+trick." rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Is+your+Netbeans+running+slower%3F+Try+this+trick.+-+http://blog.bhushangahire.net/2010/07/26/is-your-netbeans-running-slower-try-this-trick/+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2010/07/26/is-your-netbeans-running-slower-try-this-trick/&amp;title=Is+your+Netbeans+running+slower%3F+Try+this+trick.&amp;summary=I%20use%20NetBeans%206%20all%20the%20time%20on%20my%20laptop%20and%20have%20learned%20how%20to%20configure%20it%0D%0Ato%20run%20more%20effectively%20for%20me.%0D%0ANetBeans%2C%20like%20any%20Java%20application%20needs%20room%20to%20work%2C%20and%20the%20default%20memory%20settings%0D%0Afor%20Java%20and%20NetBeans%20are%20usually%20not%20what%20I%20consider%20ideal.%0D%0AOf%20course%20how%20would%20they%20know%20what%20&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F07%2F26%2Fis-your-netbeans-running-slower-try-this-trick%2F&amp;t=Is+your+Netbeans+running+slower%3F+Try+this+trick." rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2010/07/26/is-your-netbeans-running-slower-try-this-trick/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Run acts_as_solr in JRuby in background mode</title>
		<link>http://blog.bhushangahire.net/2010/07/12/run-acts_as_solr-in-jruby-in-background-mode/</link>
		<comments>http://blog.bhushangahire.net/2010/07/12/run-acts_as_solr-in-jruby-in-background-mode/#comments</comments>
		<pubDate>Mon, 12 Jul 2010 12:43:07 +0000</pubDate>
		<dc:creator>Bhushan G Ahire</dc:creator>
				<category><![CDATA[JRuby]]></category>
		<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[background]]></category>
		<category><![CDATA[fork]]></category>
		<category><![CDATA[solr]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=217</guid>
		<description><![CDATA[<p class="ArticleSummary">When you try and run rake solr:start or rake solr:stop it uses Kernel.fork to spawn of a child process. However in JRuby this is disabled by default due to concurrency issues. And this prevents your solr rake tasks from running under a JRuby environment...</p>

<div class="extended">
<h3>The Problem</h3>
When you try and run rake solr:start or rake solr:stop it uses Kernel.fork to spawn of a child process.
However in JRuby this is disabled by default due to concurrency issues. There is an option to enabling fork (jruby -J-Djruby.fork.enabled=true)
within JRuby but it is experimental and as the warning says, "WARNING: fork is highly unlikely to be safe or stable on the JVM." as it can cause all sorts of weird and wonderful side-effects.
<h3>The Solution</h3>
The solution therefore is to simply alter the solr:start and solr:stop tasks to use Kernel.exec instead.
To do this find the solr rake tasks usually in {RAILS_ROOT}/vendor/acts_as_solr/lib/tasks/solr.rake. In the start task all that is required is to comment out the start of the fork block. so you only have the exec method call,
This will not start the solr process in the background. To do so you just have to add <strong>"&#38;"</strong> at the end of the exec command, which causes the jar file to run in background mode.
]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F07%2F12%2Frun-acts_as_solr-in-jruby-in-background-mode%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<p class="ArticleSummary">When you try and run rake solr:start or rake solr:stop it uses Kernel.fork to spawn of a child process. However in JRuby this is disabled by default due to concurrency issues. And this prevents your solr rake tasks from running under a JRuby environment&#8230;</p>
<div class="extended">
<h3>The Problem</h3>
<p>When you try and run rake solr:start or rake solr:stop it uses Kernel.fork to spawn of a child process.<br />
However in JRuby this is disabled by default due to concurrency issues. There is an option to enabling fork (jruby -J-Djruby.fork.enabled=true)<br />
within JRuby but it is experimental and as the warning says, &#8220;WARNING: fork is highly unlikely to be safe or stable on the JVM.&#8221; as it can cause all sorts of weird and wonderful side-effects.</p>
<h3>The Solution</h3>
<p>The solution therefore is to simply alter the solr:start and solr:stop tasks to use Kernel.exec instead.<br />
To do this find the solr rake tasks usually in {RAILS_ROOT}/vendor/acts_as_solr/lib/tasks/solr.rake. In the start task all that is required is to comment out the start of the fork block. so you only have the exec method call,<br />
This will not start the solr process in the background. To do so you just have to add <strong>&#8220;&amp;&#8221;</strong> at the end of the exec command, which causes the jar file to run in background mode.</p>
<pre class="brush: ruby;">
task :start do
      require &quot;#{File.dirname(__FILE__)}/../../config/solr_environment.rb&quot;
      begin
        n = Net::HTTP.new('127.0.0.1', SOLR_PORT)
        n.request_head('/').value

      rescue Net::HTTPServerException #responding
        puts &quot;Port #{SOLR_PORT} in use&quot; and return

      rescue Errno::ECONNREFUSED #not responding
        Dir.chdir(SOLR_PATH) do
            exec &quot;java #{SOLR_JVM_OPTIONS}
-Dsolr.data.dir=#{SOLR_DATA_PATH} -Djetty.logs=#{SOLR_LOGS_PATH}
-Djetty.port=#{SOLR_PORT} -jar start.jar &amp;&quot;
          sleep(5)
          File.open(&quot;#{SOLR_PIDS_PATH}/#{ENV['RAILS_ENV']}_pid&quot;, &quot;w&quot;){ |f| f &amp;lt;&amp;lt; pid}
          puts &quot;#{ENV['RAILS_ENV']} Solr started successfully on #{SOLR_PORT}, pid: #{pid}.&quot;
        end
      end
    end
</pre>
<p>and in the end task just comment out the begining of the fork block so you are left with</p>
<pre class="brush: ruby;">
  task :stop do
    require &quot;#{File.dirname(__FILE__)}/../../config/solr_environment.rb&quot;
      file_path = &quot;#{SOLR_PIDS_PATH}/#{ENV['RAILS_ENV']}_pid&quot;
      if File.exists?(file_path)
        File.open(file_path, &quot;r&quot;) do |f|
          pid = f.readline
          Process.kill('TERM', pid.to_i)
        end
        File.unlink(file_path)
        Rake::Task[&quot;solr:destroy_index&quot;].invoke if ENV['RAILS_ENV'] == 'test'
        puts &quot;Solr shutdown successfully.&quot;
      else
        puts &quot;PID file not found at #{file_path}. Either Solr is not running or no PID file was written.&quot;
      end
  end
</pre>
<p>you should now be able to run your solr rake tasks under jruby with out any problems..</p>
</div>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2010/07/12/run-acts_as_solr-in-jruby-in-background-mode/&amp;title=Run+acts_as_solr+in+JRuby+in+background+mode" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2010/07/12/run-acts_as_solr-in-jruby-in-background-mode/&amp;title=Run+acts_as_solr+in+JRuby+in+background+mode" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2010/07/12/run-acts_as_solr-in-jruby-in-background-mode/&amp;title=Run+acts_as_solr+in+JRuby+in+background+mode" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2010/07/12/run-acts_as_solr-in-jruby-in-background-mode/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2010/07/12/run-acts_as_solr-in-jruby-in-background-mode/&amp;t=Run+acts_as_solr+in+JRuby+in+background+mode" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Run+acts_as_solr+in+JRuby+in+background+mode+-+http://blog.bhushangahire.net/2010/07/12/run-acts_as_solr-in-jruby-in-background-mode/+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2010/07/12/run-acts_as_solr-in-jruby-in-background-mode/&amp;title=Run+acts_as_solr+in+JRuby+in+background+mode&amp;summary=When%20you%20try%20and%20run%20rake%20solr%3Astart%20or%20rake%20solr%3Astop%20it%20uses%20Kernel.fork%20to%20spawn%20of%20a%20child%20process.%20However%20in%20JRuby%20this%20is%20disabled%20by%20default%20due%20to%20concurrency%20issues.%20And%20this%20prevents%20your%20solr%20rake%20tasks%20from%20running%20under%20a%20JRuby%20environment...%0D%0A%0D%0A%0D%0AThe%20Problem%0D%0AWhen%20you%20try%20and%20run%20rake&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F07%2F12%2Frun-acts_as_solr-in-jruby-in-background-mode%2F&amp;t=Run+acts_as_solr+in+JRuby+in+background+mode" rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2010/07/12/run-acts_as_solr-in-jruby-in-background-mode/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Ruby Mixin Tutorial</title>
		<link>http://blog.bhushangahire.net/2010/06/03/ruby-mixin-tutorial/</link>
		<comments>http://blog.bhushangahire.net/2010/06/03/ruby-mixin-tutorial/#comments</comments>
		<pubDate>Thu, 03 Jun 2010 05:08:28 +0000</pubDate>
		<dc:creator>Bhushan G Ahire</dc:creator>
				<category><![CDATA[ruby]]></category>
		<category><![CDATA[mixin]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=195</guid>
		<description><![CDATA[
In Java you just have classes (both abstract and concrete) and interfaces.  The Ruby language provides classes, modules, and a mix of both.  In this post I want to dive into mixins in Ruby.
In the Ruby language a mixin is a class that is mixed with a module.  In other words the [...]]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F06%2F03%2Fruby-mixin-tutorial%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<p>In Java you just have classes (both abstract and concrete) and interfaces.  The Ruby language provides classes, modules, and a mix of both.  In this post I want to dive into mixins in Ruby.</p>
<p>In the Ruby language a mixin is a class that is mixed with a module.  In other words the implementation of the class and module are joined, intertwined, combined, etc.  A mixin is a different mechanism to the extend construct used to add concrete implementation to a class.  With a mixin you can extend from a module instead of a class.  Before we get started with the mixin examples let me first explain what a module is.</p>
<p>I think of a module as a degenerate abstract class.  A module can’t be instantiated and no class can directly extend it but a module can fully implement methods.  A class can leverage the implementation of a module by including the module’s methods.  A module can define methods that can be shared in different and seperate classes either at the class or instance level.</p>
<p>Let me define a module, albeit a trivial one, that would convert a numeric integer value to English.</p>
<pre class="brush: ruby;">
# Convert a integer value to English.
module Stringify
  # Requires an instance variable @value
  def stringify
    if @value == 1
      &amp;amp;quot;One&amp;amp;quot;
    elsif @value == 2
      &amp;amp;quot;Two&amp;amp;quot;
    elsif @value == 3
      &amp;amp;quot;Three&amp;amp;quot;
    end
  end
end
</pre>
<p>Note that the Stringify module makes use of a @value instance variable.  The class that will be mixed with this module needs to define and set a @value instance variable since the Stringify module uses it but does not define it.  In addition to instance variables a module could invoke methods defined not in the module itself but in the class that it will be mixed with.</p>
<p>Now let me construct a self contained module that is not dependent on the implementation of any class that it can be mixed with.</p>
<pre class="brush: ruby;">
# A Math module akin to Java Math class.
module Math
  # Could be called as a class, static, method
  def add(val_one, val_two)
    BigInteger.new(val_one + val_two)
  end
end
</pre>
<p>The methods in the Math module are intended to be invoked like class methods, also known as static methods.  The add method in the Math module accepts two integer values and returns an instance of BigInteger.  Let me now define the mixin BigInteger class.</p>
<pre class="brush: plain;">
# Base Number class
class Number
  def intValue
    @value
  end
end

# BigInteger extends Number
class BigInteger &lt; Number

  # Add instance methods from Stringify
  include Stringify

  # Add class methods from Math
  extend Math

  # Add a constructor with one parameter
  def initialize(value)
    @value = value
  end
end
</pre>
<p>I loosely modeled the BigInteger and Number classes after the Java versions.  The BigInteger class defines one constructor and directly inherits one method from the Number base class.  To mix in the methods implemented in the Stringify and Math modules with the BigInteger class you will note the usage of the include and extend methods, respectively.</p>
<pre class="brush: plain;">
# Create a new object
bigint1 = BigInteger.new(10)
# Call a method inherited from the base class
puts bigint1.intValue   # --&gt; 10
</pre>
<p>The extend method will mix a module’s methods at the class level.  The method defined in the Math module can be used as a class/static method.</p>
<pre class="brush: plain;">
# Call class method extended from Math
bigint2 = BigInteger.add(-2, 4)
puts bigint2.intValue   # --&gt; 2
</pre>
<p>The include method will mix a module’s methods at the instance level, meaning that the methods will become instance methods.  The method defined in the Stringify module can be used as an instance method.</p>
<pre class="brush: plain;">
# Call a method included from Stringify
puts bigint2.stringify   # --&gt; 'Two'
</pre>
<p>There is another use of the extend method.  You can enhance an object instance by mixing it with a module at run time!  This is a powerful  feature.  Let me create a module that will be used to extend an object, changing it’s responsibilities at runtime.</p>
<pre class="brush: plain;">
# Format a numeric value as a currency
module CurrencyFormatter
  def format
    &quot;$#{@value}&quot;
  end
end
</pre>
<p>To mix an object instance with a module you can do the following:</p>
<pre class="brush: plain;">
# Add the module methods to
# this object instance, only!
bigint2.extend CurrencyFormatter
puts bigint2.format   # --&gt; '$2'
</pre>
<p>Calling the extend method on an an instance will only extend that one object, objects of the same class will not be extended with the new functionality.</p>
<pre class="brush: plain;">
puts bigint1.format   # will generate an error
</pre>
<p>Modules that will be mixed with a class via the include or extend method could define something like a contructor or initializer method to the module.  The module initializer method will be invoked at the time the module is mixed with a class.  When a class extends a module the module’s self.extended method will be invoked:</p>
<pre class="brush: plain;">
module Math
  def self.extended(base)
    # Initialize module.
  end
end
</pre>
<p>The self prefix indicates that the method is a static module level method.  The base parameter in the static extended method will be either an instance object or class object of the class that extended the module depending whether you extend a object or class, respectively.</p>
<p>When a class includes a module the module’s self.included method will be invoked.</p>
<pre class="brush: plain;">
module Stringify
  def self.included(base)
    # Initialize module.
  end
end
</pre>
<p>The base parameter will be a class object for the class that includes the module.</p>
<p>It is important to note that inside the included and extended initializer methods you can include and extend other modules, here is an example of that:</p>
<pre class="brush: plain;">
module Stringify
  def self.included(base)
    base.extend SomeOtherModule
  end
end
</pre>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2010/06/03/ruby-mixin-tutorial/&amp;title=Ruby+Mixin+Tutorial" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2010/06/03/ruby-mixin-tutorial/&amp;title=Ruby+Mixin+Tutorial" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2010/06/03/ruby-mixin-tutorial/&amp;title=Ruby+Mixin+Tutorial" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2010/06/03/ruby-mixin-tutorial/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2010/06/03/ruby-mixin-tutorial/&amp;t=Ruby+Mixin+Tutorial" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Ruby+Mixin+Tutorial+-+http://blog.bhushangahire.net/2010/06/03/ruby-mixin-tutorial/+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2010/06/03/ruby-mixin-tutorial/&amp;title=Ruby+Mixin+Tutorial&amp;summary=In%20Java%20you%20just%20have%20classes%20%28both%20abstract%20and%20concrete%29%20and%20interfaces.%20%20The%20Ruby%20language%20provides%20classes%2C%20modules%2C%20and%20a%20mix%20of%20both.%20%20In%20this%20post%20I%20want%20to%20dive%20into%20mixins%20in%20Ruby.%0D%0A%0D%0AIn%20the%20Ruby%20language%20a%20mixin%20is%20a%20class%20that%20is%20mixed%20with%20a%20module.%20%20In%20other%20words%20the%20implementation%20of%20&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F06%2F03%2Fruby-mixin-tutorial%2F&amp;t=Ruby+Mixin+Tutorial" rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2010/06/03/ruby-mixin-tutorial/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Center Page Horizontal &amp; Vertical with plane CSS &amp; HTML</title>
		<link>http://blog.bhushangahire.net/2010/05/31/center-page-horizontal-vertical-with-plane-css-html/</link>
		<comments>http://blog.bhushangahire.net/2010/05/31/center-page-horizontal-vertical-with-plane-css-html/#comments</comments>
		<pubDate>Mon, 31 May 2010 08:41:35 +0000</pubDate>
		<dc:creator>Bhushan G Ahire</dc:creator>
				<category><![CDATA[Uncategorized]]></category>
		<category><![CDATA[center align]]></category>
		<category><![CDATA[css]]></category>
		<category><![CDATA[HTML]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=193</guid>
		<description><![CDATA[
Vertical centering has always been awkward with css as vertical-align only refers to inline elements within a single line and not to block level elements. However vertical align does apply to table-cells also so we can use this to our advantage in browsers that support display:table such as mozilla and opera.
We can also cater for [...]]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F05%2F31%2Fcenter-page-horizontal-vertical-with-plane-css-html%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<p class="intro2">Vertical centering has always been awkward with css as vertical-align only refers to inline elements within a single line and not to block level elements. However vertical align does apply to table-cells also so we can use this to our advantage in browsers that support display:table such as mozilla and opera.</p>
<p>We can also cater for all IE (IE5 &#8211; IE7) via conditional comments and supply them with their own vertical centering routine.</p>
<p>Firstly I&#8217;ll describe what&#8217;s needed for mozilla. Here&#8217;s the main css code:</p>
<p><strong>Code:</strong></p>
<div class="code">* {margin:0;padding:0}<br />
/* mac hide \*/<br />
html,body{height:100%;width:100%;}<br />
/* end hide */<br />
body {<br />
background-color: #cccccc;<br />
text-align:center;<br />
min-height:468px;/* for good browsers*/<br />
min-width:552px;/* for good browsers*/<br />
}<br />
#outer{<br />
height:100%;<br />
width:100%;<br />
display:table;<br />
vertical-align:middle;<br />
}<br />
#container {<br />
text-align: center;<br />
position:relative;<br />
vertical-align:middle;<br />
display:table-cell;<br />
height: 468px;<br />
}<br />
#inner {<br />
width: 552px;<br />
background:red;<br />
height: 468px;<br />
text-align: center;<br />
margin-left:auto;<br />
margin-right:auto;<br />
border:1px solid #000;<br />
}</div>
<p>The html would look like this:</p>
<p><strong>Html:</strong></p>
<div class="code">&lt;body&gt;<br />
&lt;div id=&#8221;outer&#8221;&gt;<br />
&lt;div id=&#8221;container&#8221;&gt;<br />
&lt;div id=&#8221;inner&#8221;&gt;<br />
&lt;h1&gt;Centered Vertical and Horizontal&lt;/h1&gt;<br />
&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;/div&gt;<br />
&lt;/body&gt;</div>
<p>Most of the above should be familiar to you but the bit we are interested in is the display:table in #outer. This tells the browser to display this element with the same characteristics of a table which allows us to then use vertical-align:middle. We then nest an inner #container that is set to display:table-cell and this table-cell will then 				be vertically aligned to the parent as would a table cell.</p>
<p>The inner #inner element is then horizontally centered using margin:auto and that completes the solution for mozilla and Opera. It&#8217;s a shame that we need the extra wrappers but this is the safest way to do this. Unlike other vertical centering methods (where you position the element 50% from the top and then drag it back up with a negative top 				margin equal to half the elements height) the method I describe will always stay in the viewport and will not slide off the top or the side of the screen which is a bad failing of other methods used.</p>
<p>To bring IE into the game we need to do something else because it doesn&#8217;t understand display:table. Luckily we can draw on a behaviour that is consistent from ie5 &#8211; ie7 and simply involves positioning the outer element 50% from the top using relative positioning and the dragging the inner element back up with a negative 50% relative top position. 				In other browsers this would bring the element back to the same position but IE drags the inner element back only half its height therefore perfectly centering the element.</p>
<p><strong>Code:</strong></p>
<div class="code">&lt;!&#8211;[if lt IE 8]&gt;<br />
&lt;style type=&#8221;text/css&#8221;&gt;<br />
#container{top:50%}<br />
#inner{top:-50%;position:relative;}<br />
&lt;/style&gt;<br />
&lt;![endif]&#8211;&gt;</div>
<p>We also need to add overflow:hidden to the outer for IE7 otherwise we get a vertical scrollbar where its not needed.</p>
<div class="code">&lt;!&#8211;[if IE 7]&gt;<br />
&lt;style type=&#8221;text/css&#8221;&gt;<br />
#outer{<br />
position:relative;<br />
overflow:hidden;<br />
}<br />
&lt;/style&gt;<br />
&lt;![endif]&#8211;&gt;</div>
<p>Nothing else needs to be changed as IE7 and under doesn&#8217;t understand display:table and just ignores it. The html stays the same and the only extra css is the 2 lines above. It couldn&#8217;t really be much simpler.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2010/05/31/center-page-horizontal-vertical-with-plane-css-html/&amp;title=Center+Page+Horizontal+%26+Vertical+with+plane+CSS+%26+HTML" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2010/05/31/center-page-horizontal-vertical-with-plane-css-html/&amp;title=Center+Page+Horizontal+%26+Vertical+with+plane+CSS+%26+HTML" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2010/05/31/center-page-horizontal-vertical-with-plane-css-html/&amp;title=Center+Page+Horizontal+%26+Vertical+with+plane+CSS+%26+HTML" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2010/05/31/center-page-horizontal-vertical-with-plane-css-html/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2010/05/31/center-page-horizontal-vertical-with-plane-css-html/&amp;t=Center+Page+Horizontal+%26+Vertical+with+plane+CSS+%26+HTML" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Center+Page+Horizontal+%26+Vertical+with+plane+CSS+%26+HTML+-+http://blog.bhushangahire.net/2010/05/31/center-page-horizontal-vertical-with-plane-css-html/+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2010/05/31/center-page-horizontal-vertical-with-plane-css-html/&amp;title=Center+Page+Horizontal+%26+Vertical+with+plane+CSS+%26+HTML&amp;summary=Vertical%20centering%20has%20always%20been%20awkward%20with%20css%20as%20vertical-align%20only%20refers%20to%20inline%20elements%20within%20a%20single%20line%20and%20not%20to%20block%20level%20elements.%20However%20vertical%20align%20does%20apply%20to%20table-cells%20also%20so%20we%20can%20use%20this%20to%20our%20advantage%20in%20browsers%20that%20support%20display%3Atable%20such%20as%20mozilla%20&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F05%2F31%2Fcenter-page-horizontal-vertical-with-plane-css-html%2F&amp;t=Center+Page+Horizontal+%26+Vertical+with+plane+CSS+%26+HTML" rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2010/05/31/center-page-horizontal-vertical-with-plane-css-html/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>10 Essential Plugins For Your Wordpress Portfolio</title>
		<link>http://blog.bhushangahire.net/2010/05/19/10-essential-plugins-for-your-wordpress-portfolio/</link>
		<comments>http://blog.bhushangahire.net/2010/05/19/10-essential-plugins-for-your-wordpress-portfolio/#comments</comments>
		<pubDate>Wed, 19 May 2010 05:12:50 +0000</pubDate>
		<dc:creator>Bhushan G Ahire</dc:creator>
				<category><![CDATA[Uncategorized]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=184</guid>
		<description><![CDATA[
One of the best things about Wordpress is the thousands of plugins available for free. No matter how you want to customise your site, there’s probably a plugin to do it. From turning it into an ecommerce store to automatically pulling in content, the possibilities are endless.
When it comes to portfolio sites, you don’t really [...]]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F05%2F19%2F10-essential-plugins-for-your-wordpress-portfolio%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<p>One of the best things about Wordpress is the thousands of plugins available for free. No matter how you want to customise your site, there’s probably a plugin to do it. From turning it into an ecommerce store to automatically pulling in content, the possibilities are endless.</p>
<p>When it comes to portfolio sites, you don’t really need a lot of bells and whistles. Your portfolio is all about your work and presenting it in the best possible way, so which Wordpress plugins are the best to achieve this? Which will help your <a href="http://www.frogsthemes.com/wordpress-portfolio-themes/">Wordpress portfolio</a> really perform?</p>
<h2>Tweet This</h2>
<p>Chances are you have a Twitter account, so what better way to show off your work than to put it in front of your followers? The <a onclick="javascript:pageTracker._trackPageview('/outbound/article/wordpress.org');" rel="external nofollow" href="http://wordpress.org/extend/plugins/tweet-this/" target="blank">Tweet This plugin</a> installs a cool button on all of your posts and pages, allowing people to Tweet a link to your work. It can also be set up to Tweet new posts so you don’t have to sign up to a service like <a onclick="javascript:pageTracker._trackPageview('/outbound/article/twitterfeed.com');" rel="external nofollow" href="http://twitterfeed.com/" target="blank">Twitterfeed</a>.</p>
<p>Our favourite thing about this plugin is that it lets you shortern URLs using a service of your choice. If you’ve got your own URL shortener this is very nifty indeed.</p>
<h2>Sociable</h2>
<p>Fantastic for generating traffic spikes, <a onclick="javascript:pageTracker._trackPageview('/outbound/article/wordpress.org');" rel="external nofollow" href="http://wordpress.org/extend/plugins/sociable/" target="blank">Sociable</a> lets you add social bookmarking links on your posts, pages and RSS feeds. Good art, design or photography is social networking gold, so this is definitely a plugin you want to install.</p>
<h2>Xavins Review Ratings</h2>
<p>It might be a bit old-school, but star ratings are great for visitor interaction. Our favourite plugin for this is <a onclick="javascript:pageTracker._trackPageview('/outbound/article/wordpress.org');" rel="external nofollow" href="http://wordpress.org/extend/plugins/xavins-review-ratings/" target="blank">Xavin’s Review Ratings</a>. It’s entirely customisable from the number of stars to the size of the fractions to the design of the stars themselves. Intended mainly for review websites, we think it’s cool to let people review your work, so give this a try on your portfolio.</p>
<h2>NextGen Gallery</h2>
<p>Probably the most comprehensive image gallery plugin for Wordpress, <a onclick="javascript:pageTracker._trackPageview('/outbound/article/wordpress.org');" rel="external nofollow" href="http://wordpress.org/extend/plugins/nextgen-gallery/" target="blank">NextGen Gallery</a> provides a huge set of options for displaying your images. From adding custom templates and multiple CSS stylesheets, to using watermarks and slideshows, it’s the only plugin you need for an instant, professional-looking gallery.</p>
<h2>FlippingBook</h2>
<p>Some people love them and some people hate them, but page-flip sites stand out from the crowd. If you want your portfolio in picture-book format, <a onclick="javascript:pageTracker._trackPageview('/outbound/article/pageflipgallery.com');" rel="external nofollow" href="http://pageflipgallery.com/" target="blank">FlippingBook</a> is the plugin for you. It lets you easily create an interactive Flash album complete with pages that, well, flip!</p>
<h2>Smush.it</h2>
<p>This neat little plugin is a FrogsThemes favourite, optimising your images in a ‘lossless’ way. As any web designer knows, saving bytes is a good thing. Your portfolio loads faster and there’s less stress on your bandwidth. <a onclick="javascript:pageTracker._trackPageview('/outbound/article/wordpress.org');" rel="external nofollow" href="http://wordpress.org/extend/plugins/wp-smushit/" target="blank">Smush.it</a> makes it easy for everyone to optimise their image file sizes – once installed, it optimises new images automagically!</p>
<h2>Wordpress Super Cache</h2>
<p>This plugin also cuts down on your page load time by generating a static HTML file to serve to most of your users. It’s a lot quicker than serving normal Wordpress php scripts and a really useful talent for image-heavy sites like your portfolio. If your work is popular on social media sites, <a onclick="javascript:pageTracker._trackPageview('/outbound/article/wordpress.org');" rel="external nofollow" href="http://wordpress.org/extend/plugins/wp-super-cache/" target="blank">Wordpress Super Cache</a> can help your site handle the resulting heavy traffic. Neat huh?</p>
<h2>Audio Player 2.0</h2>
<p>Want to add audio to your portfolio? Look no further than <a onclick="javascript:pageTracker._trackPageview('/outbound/article/wordpress.org');" rel="external nofollow" href="http://wordpress.org/extend/plugins/audio-player/" target="blank">Audio Player 2.0</a>. From autostart to autoloop, it has everything you need to make your portfolio literally speak to your visitors. The top advantage for portfolio sites? You can customise the colour scheme to blend in with your design.</p>
<h2>Wordpress Backup</h2>
<p>Now you’ve installed all these plugins and your portfolio is ace, it’s time to make it safe and secure. Currently, the best plugin that backs up your Wordpress portfolio is simply called <a onclick="javascript:pageTracker._trackPageview('/outbound/article/wordpress.org');" rel="external nofollow" href="http://wordpress.org/extend/plugins/wordpress-backup/" target="blank">Wordpress Backup</a>. It performs regular backups of your upload directory (i.e. images), your theme and your plugin directory. This takes care of a lot of your content, but unfortunately leaves out your database.</p>
<p>For that we recommend a newcomer – <a onclick="javascript:pageTracker._trackPageview('/outbound/article/www.backup-technology.com');" rel="external nofollow" href="http://www.backup-technology.com/online-backup-for-wordpress/" target="blank">Online Backup for Wordpress</a>. This plugin comes with 50MiB of free space in a real life datacentre – your blog posts have never been so secure! We’ve been assured that in the coming months this plugin will backup images, plugins and other file-level items, so watch this space for an update.</p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2010/05/19/10-essential-plugins-for-your-wordpress-portfolio/&amp;title=10+Essential+Plugins+For+Your+Wordpress+Portfolio" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2010/05/19/10-essential-plugins-for-your-wordpress-portfolio/&amp;title=10+Essential+Plugins+For+Your+Wordpress+Portfolio" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2010/05/19/10-essential-plugins-for-your-wordpress-portfolio/&amp;title=10+Essential+Plugins+For+Your+Wordpress+Portfolio" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2010/05/19/10-essential-plugins-for-your-wordpress-portfolio/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2010/05/19/10-essential-plugins-for-your-wordpress-portfolio/&amp;t=10+Essential+Plugins+For+Your+Wordpress+Portfolio" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=10+Essential+Plugins+For+Your+Wordpress+Portfolio+-+http://blog.bhushangahire.net/2010/05/19/10-essential-plugins-for-your-wordpress-portfolio/+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2010/05/19/10-essential-plugins-for-your-wordpress-portfolio/&amp;title=10+Essential+Plugins+For+Your+Wordpress+Portfolio&amp;summary=One%20of%20the%20best%20things%20about%20Wordpress%20is%20the%20thousands%20of%20plugins%20available%20for%20free.%20No%20matter%20how%20you%20want%20to%20customise%20your%20site%2C%20there%E2%80%99s%20probably%20a%20plugin%20to%20do%20it.%20From%20turning%20it%20into%20an%20ecommerce%20store%20to%20automatically%20pulling%20in%20content%2C%20the%20possibilities%20are%20endless.%0D%0A%0D%0AWhen%20it%20comes%20to%20&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F05%2F19%2F10-essential-plugins-for-your-wordpress-portfolio%2F&amp;t=10+Essential+Plugins+For+Your+Wordpress+Portfolio" rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2010/05/19/10-essential-plugins-for-your-wordpress-portfolio/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>How Do I Enable remote access to PostgreSQL database server?</title>
		<link>http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/</link>
		<comments>http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/#comments</comments>
		<pubDate>Tue, 11 May 2010 12:11:22 +0000</pubDate>
		<dc:creator>Bhushan G Ahire</dc:creator>
				<category><![CDATA[Amazon EC2]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[postgres]]></category>
		<category><![CDATA[remote]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=177</guid>
		<description><![CDATA[



By default, PostgreSQL database server remote access disabled for security reasons. However, some time you need to provide the remote access to database server from home computer or from web server.
Step # 1: Login over ssh if server is outside your IDC
Login over ssh to remote PostgreSQL  database server:
$ ssh user@remote.pgsql.server.com
Step # 2: Enable [...]]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F05%2F11%2Fhow-do-i-enable-remote-access-to-postgresql-database-server%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<div class="format_text entry-content">
<div style="float: right; margin-top: 0px; margin-left: 5px;"><a title="See all Postgresql related tips/articles" href="http://www.cyberciti.biz/tips/category/postgresql/"><br />
<img src="http://figs.cyberciti.biz/3rdparty/pgsql-logo.png" border="0" alt="" /></a></div>
<p>By default, PostgreSQL database server remote access disabled for security reasons. However, some time you need to provide the remote access to database server from home computer or from web server.</p>
<h2>Step # 1: Login over ssh if server is outside your IDC</h2>
<p>Login over ssh to remote PostgreSQL  database server:</p>
<p><code>$ ssh user@remote.pgsql.server.com</code></p>
<h2>Step # 2: Enable client authentication</h2>
<p>Once connected, you need edit the PostgreSQL configuration file, edit the PostgreSQL configuration file <strong>/var/lib/pgsql/data/pg_hba.conf</strong> (or <strong>/etc/postgresql/8.2/main/pg_hba.conf</strong> for latest 8.2 version) using a text editor such as vi.</p>
<p>Login as postgres user using su / sudo command, enter:</p>
<p><code>$ su - postgres</code></p>
<p>Edit the file:</p>
<p><code>$ vi /var/lib/pgsql/data/pg_hba.conf</code></p>
<p>OR</p>
<p><code>$ vi /etc/postgresql/8.2/main/pg_hba.conf</code></p>
<p>Append the following configuration lines to give access to 10.10.29.0/24 network:</p>
<p><code>host all all 10.10.29.0/24 trust</code></p>
<p>Save and close the file.  Make sure you replace 10.10.29.0/24 with  actual network IP address range of the clients system in your own network.</p>
<h2>Step # 2: Enable networking for PostgreSQL</h2>
<p>You need to enable TCP / IP networking. Use either step #3 or #3a as per your PostgreSQL database server version.</p>
<h2>Step # 3: Allow TCP/IP socket</h2>
<p>If you are using <strong>PostgreSQL version 8.x or newer</strong> use the following instructions or skip to <a href="#3a">Step # 3a</a> for older version (7.x or older).</p>
<p>You need to open PostgreSQL configuration file /var/lib/pgsql/data/postgresql.conf or /etc/postgresql/8.2/main/postgresql.conf.</p>
<p><code># vi /etc/postgresql/8.2/main/postgresql.conf</code></p>
<p>OR</p>
<p><code># vi /var/lib/pgsql/data/postgresql.conf </code></p>
<p>Find configuration line that read as follows:</p>
<p><code>listen_addresses='localhost'</code></p>
<p>Next set IP address(es) to listen on; you can use comma-separated list of addresses; defaults to &#8216;localhost&#8217;, and &#8216;*&#8217; is all ip address:</p>
<p><code>listen_addresses='*'</code></p>
<p>Or just bind to 202.54.1.2 and 202.54.1.3 IP address</p>
<p><code>listen_addresses='202.54.1.2 202.54.1.3'</code></p>
<p>Save and close the file. Skip to <a href="#4">step # 4</a>.</p>
<h3>Step #3a &#8211; Information for old version 7.x  or older</h3>
<p>Following configuration only required for <strong>PostgreSQL version 7.x or older</strong>. Open config file, enter:</p>
<p><code># vi /var/lib/pgsql/data/postgresql.conf </code></p>
<p>Bind and open TCP/IP port by setting tcpip_socket to true.  Set / modify tcpip_socket to true:</p>
<p><code>tcpip_socket = true</code></p>
<p>Save and close the file.</p>
<h2>Step # 4: Restart PostgreSQL Server</h2>
<p>Type the following command:</p>
<p><code># /etc/init.d/postgresql restart</code></p>
<h2>Step # 5: Iptables firewall rules</h2>
<p>Make sure iptables is not blocking communication, <a href="http://www.cyberciti.biz/tips/howto-iptables-postgresql-open-port.html">open port 5432</a> (append rules to your iptables scripts or file <a href="http://www.cyberciti.biz/faq/howto-block-ipaddress-of-spammers-with-firewall/">/etc/sysconfig/iptables</a>):</p>
<pre>iptables -A INPUT -p tcp -s 0/0 --sport 1024:65535 -d 20.04.23.22  --dport 5432 -m state --state NEW,ESTABLISHED -j ACCEPT
iptables -A OUTPUT -p tcp -s 20.04.23.22 --sport 5432 -d 0/0 --dport 1024:65535 -m state --state ESTABLISHED -j ACCEPT</pre>
<p>Restart firewall:</p>
<p><code># /etc/init.d/iptables restart</code></p>
<h2>Step # 6: Test your setup</h2>
<p>Use psql command from client system. Connect to remote server using IP address 20.04.23.22 and login using postgres username and testdatabase database, enter:</p>
<p><code>$ psql -h 20.04.23.22 -U postgres -d testdatabase</code></p>
</div>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/&amp;title=How+Do+I+Enable+remote+access+to+PostgreSQL+database+server%3F" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/&amp;title=How+Do+I+Enable+remote+access+to+PostgreSQL+database+server%3F" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/&amp;title=How+Do+I+Enable+remote+access+to+PostgreSQL+database+server%3F" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/&amp;t=How+Do+I+Enable+remote+access+to+PostgreSQL+database+server%3F" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=How+Do+I+Enable+remote+access+to+PostgreSQL+database+server%3F+-+http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/&amp;title=How+Do+I+Enable+remote+access+to+PostgreSQL+database+server%3F&amp;summary=%0D%0A%0D%0A%0D%0ABy%20default%2C%20PostgreSQL%20database%20server%20remote%20access%20disabled%20for%20security%20reasons.%20However%2C%20some%20time%20you%20need%20to%20provide%20the%20remote%20access%20to%20database%20server%20from%20home%20computer%20or%20from%20web%20server.%0D%0AStep%20%23%201%3A%20Login%20over%20ssh%20if%20server%20is%20outside%20your%20IDC%0D%0ALogin%20over%20ssh%20to%20remote%20PostgreSQL%20%20d&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F05%2F11%2Fhow-do-i-enable-remote-access-to-postgresql-database-server%2F&amp;t=How+Do+I+Enable+remote+access+to+PostgreSQL+database+server%3F" rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2010/05/11/how-do-i-enable-remote-access-to-postgresql-database-server/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Setup Capistrano to deploy Rails application on Amazon EC2 with Git</title>
		<link>http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/</link>
		<comments>http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/#comments</comments>
		<pubDate>Wed, 17 Feb 2010 06:22:49 +0000</pubDate>
		<dc:creator>Bhushan G Ahire</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[Security]]></category>
		<category><![CDATA[Subversion]]></category>
		<category><![CDATA[capistrano]]></category>
		<category><![CDATA[git]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[ec2]]></category>
		<category><![CDATA[server]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=155</guid>
		<description><![CDATA[
1: Create a new Rails app &#8211; we&#8217;ll call is &#8216;deploytest&#8217;
$ rails deploytest
$ cd deploytest
2: Create a local Git repository for it
$ git init
$ git add *
$ git commit -a -m 'initial commit'
$ git status
3: Create a couple of Capistrano files
$ capify .
4: Edit config/deploy.rb
# The name of your app
set :application, "deploytest"
# The directory on [...]]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F02%2F17%2Fsetup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<div class="post-body entry-content">1: Create a new Rails app &#8211; we&#8217;ll call is &#8216;deploytest&#8217;</p>
<pre class="prettyprint"><span class="pln">$ rails deploytest
$ cd deploytest</span></pre>
<p>2: Create a local Git repository for it</p>
<pre class="prettyprint"><span class="pln">$ git init
$ git add </span><span class="pun">*</span><span class="pln">
$ git commit </span><span class="pun">-</span><span class="pln">a </span><span class="pun">-</span><span class="pln">m </span><span class="str">'initial commit'</span><span class="pln">
$ git status</span></pre>
<p>3: Create a couple of Capistrano files</p>
<pre class="prettyprint"><span class="pln">$ capify </span><span class="pun">.</span></pre>
<p>4: Edit config/deploy.rb</p>
<pre class="prettyprint"><span class="com"># The name of your app</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">application</span><span class="pun">,</span><span class="pln"> </span><span class="str">"deploytest"</span><span class="pln">
</span><span class="com"># The directory on the EC2 node that will be deployed to</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">deploy_to</span><span class="pun">,</span><span class="pln"> </span><span class="str">"/var/www/apps/#{application}"</span><span class="pln">
</span><span class="com"># The type of Source Code Management system you are using</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">scm</span><span class="pun">,</span><span class="pln"> </span><span class="pun">:</span><span class="pln">git
</span><span class="com"># The location of the LOCAL repository relative to the current app</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">repository</span><span class="pun">,</span><span class="pln">  </span><span class="str">"."</span><span class="pln">
</span><span class="com"># The way in which files will be transferred from repository to remote host</span><span class="pln">
</span><span class="com"># If you were using a hosted github repository this would be slightly different</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">deploy_via</span><span class="pun">,</span><span class="pln"> </span><span class="pun">:</span><span class="pln">copy

</span><span class="com"># The address of the remote host on EC2 (the Public DNS address)</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">location</span><span class="pun">,</span><span class="pln"> </span><span class="str">"ec2-xxx-xxx-xxx-xxx.compute-1.amazonaws.com"</span><span class="pln">
</span><span class="com"># setup some Capistrano roles</span><span class="pln">
role </span><span class="pun">:</span><span class="pln">app</span><span class="pun">,</span><span class="pln"> location
role </span><span class="pun">:</span><span class="pln">web</span><span class="pun">,</span><span class="pln"> location
role </span><span class="pun">:</span><span class="pln">db</span><span class="pun">,</span><span class="pln">  location</span><span class="pun">,</span><span class="pln"> </span><span class="pun">:</span><span class="pln">primary </span><span class="pun">=&gt;</span><span class="pln"> </span><span class="kwd">true</span><span class="pln">

</span><span class="com"># Set up SSH so it can connect to the EC2 node - assumes your SSH key is in ~/.ssh/id_rsa</span><span class="pln">
</span><span class="kwd">set</span><span class="pln"> </span><span class="pun">:</span><span class="pln">user</span><span class="pun">,</span><span class="pln"> </span><span class="str">"root"</span><span class="pln">
ssh_options</span><span class="pun">[:</span><span class="pln">keys</span><span class="pun">]</span><span class="pln"> </span><span class="pun">=</span><span class="pln"> </span><span class="pun">[</span><span class="typ">File</span><span class="pun">.</span><span class="pln">join</span><span class="pun">(</span><span class="pln">ENV</span><span class="pun">[</span><span class="str">"HOME"</span><span class="pun">],</span><span class="pln"> </span><span class="str">".ssh"</span><span class="pun">,</span><span class="pln"> </span><span class="str">"id_rsa"</span><span class="pun">)]</span><span class="pln">
</span></pre>
<p>The only account on a default EC2 instance is root. You probably want to create a second user that is responsible for your application.</p>
<p>5: Copy your SSH public key to your EC2 node</p>
<pre class="prettyprint"><span class="pln">$ scp </span><span class="pun">-</span><span class="pln">i </span><span class="pun">~</span><span class="str">/my-ec2-keypair ~/</span><span class="pun">.</span><span class="pln">ssh</span><span class="pun">/</span><span class="pln">id_rsa</span><span class="pun">.</span><span class="pln">pub root@ec2</span><span class="pun">-</span><span class="lit">xxx</span><span class="pun">-</span><span class="lit">xxx</span><span class="pun">-</span><span class="lit">xxx</span><span class="pun">-xxx</span><span class="lit">.compute</span><span class="pun">-</span><span class="lit">1.amazonaws</span><span class="pun">.</span><span class="pln">com</span><span class="pun">:</span><span class="str">/root/</span><span class="pun">.</span><span class="pln">ssh</span><span class="pun">/</span><span class="pln">authorized_keys2</span></pre>
<p>NOTE the filename authorized_keys2 &#8211; not authorized_keys!!</p>
<p>6: Setup the EC2 node for Capistrano deployment.<br />
From your LOCAL machine, not the EC2 node:</p>
<pre class="prettyprint"><span class="pln">$ cap deploy</span><span class="pun">:</span><span class="pln">setup</span></pre>
<p>7: Finally, deploy your application</p>
<pre class="prettyprint"><span class="pln">$ cap deploy</span></pre>
<p>You will see lots of output and with this dummy application some of those will report errors/warnings. Don&#8217;t worry about that for now.</p>
<p>8: Check that the Deployment was successful<br />
Connect to the EC2 node with SSH the regular way, cd to the app directory and check that everything is there. If that is all working then you are ready to deploy a real application and add custom tasks for managing the database, restarting the server etc.</p>
<p>Bear in mind that Capistrano add new &#8216;releases&#8217; of your software in separate directories and symlinks the &#8216;current&#8217; directory to the latest. So the root of your deployed application is the &#8216;current&#8217; subdirectory.</p>
<p>Hope this will help you setting up your ec2 instance with capistrano.</p></div>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/&amp;title=Setup+Capistrano+to+deploy+Rails+application+on+Amazon+EC2+with+Git" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/&amp;title=Setup+Capistrano+to+deploy+Rails+application+on+Amazon+EC2+with+Git" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/&amp;title=Setup+Capistrano+to+deploy+Rails+application+on+Amazon+EC2+with+Git" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/&amp;t=Setup+Capistrano+to+deploy+Rails+application+on+Amazon+EC2+with+Git" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Setup+Capistrano+to+deploy+Rails+application+on+Amazon+EC2+with+Git+-+http://tr.im/SU8k+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/&amp;title=Setup+Capistrano+to+deploy+Rails+application+on+Amazon+EC2+with+Git&amp;summary=1%3A%20Create%20a%20new%20Rails%20app%20-%20we%27ll%20call%20is%20%27deploytest%27%0D%0A%24%20rails%20deploytest%0D%0A%24%20cd%20deploytest%0D%0A2%3A%20Create%20a%20local%20Git%20repository%20for%20it%0D%0A%24%20git%20init%0D%0A%24%20git%20add%20%2A%0D%0A%24%20git%20commit%20-a%20-m%20%27initial%20commit%27%0D%0A%24%20git%20status%0D%0A3%3A%20Create%20a%20couple%20of%20Capistrano%20files%0D%0A%24%20capify%20.%0D%0A4%3A%20Edit%20config%2Fdeploy.rb%0D%0A%23%20The%20name%20o&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F02%2F17%2Fsetup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git%2F&amp;t=Setup+Capistrano+to+deploy+Rails+application+on+Amazon+EC2+with+Git" rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2010/02/17/setup-capistrano-to-deploy-rails-application-on-amazon-ec2-with-git/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Installing PostgreSQL on Snow Leopard 10.6</title>
		<link>http://blog.bhushangahire.net/2010/02/15/installing-postgresql-on-snow-leopard-10-6/</link>
		<comments>http://blog.bhushangahire.net/2010/02/15/installing-postgresql-on-snow-leopard-10-6/#comments</comments>
		<pubDate>Mon, 15 Feb 2010 08:41:59 +0000</pubDate>
		<dc:creator>Bhushan G Ahire</dc:creator>
				<category><![CDATA[MAC Tiger]]></category>
		<category><![CDATA[mac]]></category>
		<category><![CDATA[port]]></category>
		<category><![CDATA[postgres]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/?p=152</guid>
		<description><![CDATA[

Installing PostgreSQL 8.3
First, you’ll need to install Xcode if you haven’t already. This is available on the Snow Leopard DVD in the Optional Installs directory.
Second, if you aren’t already using it, download Mac Ports for Snow Leopard and install it. Mac Ports has come a long way in the last few years and will make [...]]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F02%2F15%2Finstalling-postgresql-on-snow-leopard-10-6%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<div class="entry">
<h2>Installing PostgreSQL 8.3</h2>
<p>First, you’ll need to install Xcode if you haven’t already. This is available on the Snow Leopard DVD in the Optional Installs directory.</p>
<p>Second, if you aren’t already using it, download <a href="http://distfiles.macports.org/MacPorts/MacPorts-1.8.0-10.6-SnowLeopard.dmg">Mac Ports for Snow Leopard</a> and install it. Mac Ports has come a long way in the last few years and will make your life much easier.</p>
<p>Once those are installed, run the following command:<br />
<code>sudo port install postgresql83 postgresql83-server</code></p>
<h2>Setup Your First Database</h2>
<p>At the very end of the install it tells you how to setup your first database:</p>
<p><code>sudo mkdir -p /opt/local/var/db/postgresql83/defaultdb</code><br />
<code>sudo chown postgres:postgres /opt/local/var/db/postgresql83/defaultdb</code><br />
<code>sudo su postgres -c '/opt/local/lib/postgresql83/bin/initdb -D /opt/local/var/db/postgresql83/defaultdb'</code></p>
<p>You’ll also want to setup Postgres to auto-run as a server on start up.</p>
<p><code>sudo launchctl load -w /Library/LaunchDaemons/org.macports.postgresql83-server.plist</code></p>
<p>If you want to start it right now, you can either reboot or do the following:</p>
<p><code>sudo su postgres -c '/opt/local/lib/postgresql83/bin/postgres -D /opt/local/var/db/postgresql83/defaultdb'</code></p>
<h2>Make psql Available from the Command Line</h2>
<p>The executable files for PostgreSQL get shoved into a non-standard place (just like MySQL), so you’ll need to edit the default profile.</p>
<p><code>sudo vi /etc/profile</code></p>
<p>You can also do this using <code>sudo mate /etc/profile</code> if you aren’t comfortable in VI.</p>
<p>The <code>PATH=</code> line needs to be changed to include the PostgreSQL bin directory.</p>
<p>Mine was <code>PATH="/opt/local/bin:$PATH"</code> and is now:</p>
<p><code>PATH="/opt/local/bin:/opt/local/sbin:/opt/local/lib/postgresql83/bin:$PATH"</code></p>
<p>If you open a new terminal window you can now type <code>psql</code> and it will find it.</p>
<h2>Create a New User and Database</h2>
<p>By default, PostgreSQL creates a <em>postgres</em> user for you. However, it’s not good practice to use the default and it’s a pain in the ass. Let’s just create a new database user to make it easier.</p>
<p><code>createuser --superuser macusername -U postgres</code></p>
<p>You need to change <code>macusername</code> to your mac username. This will make your life ALOT easier. Trust me here.</p>
<p>Next, create your database:</p>
<p><code>createdb my_database</code></p>
<h2>Installing the PostgreSQL Ruby Gem</h2>
<p>Unlike the MySQL driver, we don’t need to pass the ARCHFLAGS variable as 64 bit. PostgreSQL comes with both 32 and 64-bit versions. Yeah!</p>
<p><code>sudo gem install postgres-pr</code></p>
<p>Per Tom’s comment below, we should be using the native driver for better performance.</p>
<p><code>sudo env ARCHFLAGS="-arch x86_64" gem install pg</code></p>
<h2>Configuring your Rails Application</h2>
<p>Inside your Ruby on Rails application, open up config/database.yml and change your development adapter to be similar to the following:</p>
<p><code>development:<br />
  adapter: postgresql<br />
  database: defaultdb<br />
  username: defaultdb<br />
</code></p>
<p>You can change <code>defaultdb</code> to the name you need for your application.</p>
</p></div>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2010/02/15/installing-postgresql-on-snow-leopard-10-6/&amp;title=Installing+PostgreSQL+on+Snow+Leopard+10.6" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2010/02/15/installing-postgresql-on-snow-leopard-10-6/&amp;title=Installing+PostgreSQL+on+Snow+Leopard+10.6" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2010/02/15/installing-postgresql-on-snow-leopard-10-6/&amp;title=Installing+PostgreSQL+on+Snow+Leopard+10.6" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2010/02/15/installing-postgresql-on-snow-leopard-10-6/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2010/02/15/installing-postgresql-on-snow-leopard-10-6/&amp;t=Installing+PostgreSQL+on+Snow+Leopard+10.6" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Installing+PostgreSQL+on+Snow+Leopard+10.6+-+http://tr.im/SU8l+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2010/02/15/installing-postgresql-on-snow-leopard-10-6/&amp;title=Installing+PostgreSQL+on+Snow+Leopard+10.6&amp;summary=%0D%0AInstalling%20PostgreSQL%208.3%0D%0AFirst%2C%20you%E2%80%99ll%20need%20to%20install%20Xcode%20if%20you%20haven%E2%80%99t%20already.%20This%20is%20available%20on%20the%20Snow%20Leopard%20DVD%20in%20the%20Optional%20Installs%20directory.%0D%0ASecond%2C%20if%20you%20aren%E2%80%99t%20already%20using%20it%2C%20download%20Mac%20Ports%20for%20Snow%20Leopard%20and%20install%20it.%20Mac%20Ports%20has%20come%20a%20long%20way%20in%20t&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F02%2F15%2Finstalling-postgresql-on-snow-leopard-10-6%2F&amp;t=Installing+PostgreSQL+on+Snow+Leopard+10.6" rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2010/02/15/installing-postgresql-on-snow-leopard-10-6/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Send SMS from Ruby On Rails application using web service, SOAP API</title>
		<link>http://blog.bhushangahire.net/2010/01/15/send-sms-from-ruby-on-rails-application-using-web-service-soap-api/</link>
		<comments>http://blog.bhushangahire.net/2010/01/15/send-sms-from-ruby-on-rails-application-using-web-service-soap-api/#comments</comments>
		<pubDate>Fri, 15 Jan 2010 11:09:19 +0000</pubDate>
		<dc:creator>Bhushan G Ahire</dc:creator>
				<category><![CDATA[Rails]]></category>
		<category><![CDATA[ruby]]></category>
		<category><![CDATA[mailserve]]></category>
		<category><![CDATA[sms]]></category>
		<category><![CDATA[soap]]></category>

		<guid isPermaLink="false">http://blog.bhushangahire.net/2010/01/15/send-sms-from-ruby-on-rails-application-using-web-service-soap-api/</guid>
		<description><![CDATA[
SOAP4R is a Ruby library for accessing Web Services via SOAP. Recently I had a chance to explore SOAP4R. Here&#8217;s how to get started with it.

Installation
Although Ruby 1.8.x comes with SOAP4R in its standard library, it is an old, buggy version. I highly recommend using the latest gem (1.5.8 as of the this update). It [...]]]></description>
			<content:encoded><![CDATA[<div class="fblike_button" style="margin: 10px 0;"><iframe src="http://www.facebook.com/plugins/like.php?href=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F01%2F15%2Fsend-sms-from-ruby-on-rails-application-using-web-service-soap-api%2F&amp;layout=standard&amp;show_faces=false&amp;width=450&amp;action=recommend&amp;colorscheme=light" scrolling="no" frameborder="0" allowTransparency="true" style="border:none; overflow:hidden; width:450px; height:25px"></iframe></div>
<p class="entry">SOAP4R is a Ruby library for accessing Web Services via SOAP. Recently I had a chance to explore SOAP4R. Here&#8217;s how to get started with it.</p>
<p class="entry"><span id="more-3"></span></p>
<h3 class="entry">Installation</h3>
<p class="entry">Although Ruby 1.8.x comes with SOAP4R in its standard library, it is an old, buggy version. I <strong>highly</strong> recommend using the latest gem (1.5.8 as of the this update). It has one dependency, httpclient.</p>
<p class="entry"><code>gem install soap4r --include-dependencies</code></p>
<h3 class="entry">Service</h3>
<p class="entry">There are many services available to send SMS but I prefer to use,</p>
<h4 class="entry">MailServe-SMS</h4>
<p class="entry"><a href="http://qlc.in/ms/overview.htm" target="_blank">MailServe-SMS</a>, text messaging service, is everything you need for fast, no-frills, no-fuss text messaging. A quick and easy way to send SMS.</p>
<p class="entry">Let’s explore these further.</p>
<h3 class="entry">Method 1: Read the WSDL at run-time</h3>
<p class="entry">&#160;</p>
<div class="entry">
<pre class="ruby"><span style="font-weight: bold; color: rgb(204,0,102)">require</span> <span style="color: rgb(153,102,0)">&quot;soap/wsdlDriver&quot;</span>
wsdl = <span style="color: rgb(153,102,0)">&quot;http://sms.qlc.co.in/smsapi.wsdl&quot;</span>
driver = <span style="font-weight: bold; color: rgb(102,102,255)">SOAP::WSDLDriverFactory</span>.<span style="color: rgb(153,0,204)">new</span><span style="font-weight: bold; color: rgb(0,102,0)">(</span>wsdl<span style="font-weight: bold; color: rgb(0,102,0)">)</span>.<span style="color: rgb(153,0,204)">create_rpc_drive</span></pre>
</div>
<p class="entry">&#160;</p>
<p class="entry">A single call to a driver factory reads the WSDL file, and creates a driver class for you to use, complete with the methods defined by the service. What if your service requires authentication? The driver inherits methods from httpclient, so you can specify its options as you would for httpclient:</p>
<p class="entry">Once driver is get initialised you need to call SMS sending API i.e. <b>SendSMSRequest</b>.</p>
<div class="entry">
<pre class="ruby">driver.<span style="color: rgb(153,0,204)">SendSMSRequest</span><span style="font-weight: bold; color: rgb(0,102,0)">(</span><span style="color: rgb(153,102,0)">&quot;username&quot;, <span style="color: rgb(153,102,0)">&quot;password&quot;</span>, <span style="color: rgb(153,102,0)">&quot;sender_no&quot;</span>, <span style="color: rgb(153,102,0)">&quot;from_no&quot;</span>, <span style="color: rgb(153,102,0)">&quot;message&quot;</span></span><span style="font-weight: bold; color: rgb(0,102,0)">)</span></pre>
</div>
<p class="entry">&#160;</p>
<p class="entry">Once This will return you response <strong>200 SMS sent successfully </strong>on success else if the information submitted was wrong then <strong>500 Information submitted was incomplete</strong>.</p>
<p class="entry">&#160;</p>
<h3 class="entry">Method 2: Generate classes from WSDL</h3>
<p class="entry">SOAP4R installs a command-line utility called &#8216;wsdl2ruby&#8217; which can generate a client or server.</p>
<p class="entry"><strong>Coming soon…..</strong></p>


<!-- Begin SexyBookmarks Menu Code -->
<div class="sexy-bookmarks sexy-bookmarks-expand sexy-bookmarks-center">
<ul class="socials">
		<li class="sexy-delicious">
			<a href="http://del.icio.us/post?url=http://blog.bhushangahire.net/2010/01/15/send-sms-from-ruby-on-rails-application-using-web-service-soap-api/&amp;title=Send+SMS+from+Ruby+On+Rails+application+using+web+service%2C+SOAP+API" rel="nofollow" title="Share this on del.icio.us">Share this on del.icio.us</a>
		</li>
		<li class="sexy-digg">
			<a href="http://digg.com/submit?phase=2&amp;url=http://blog.bhushangahire.net/2010/01/15/send-sms-from-ruby-on-rails-application-using-web-service-soap-api/&amp;title=Send+SMS+from+Ruby+On+Rails+application+using+web+service%2C+SOAP+API" rel="nofollow" title="Digg this!">Digg this!</a>
		</li>
		<li class="sexy-stumbleupon">
			<a href="http://www.stumbleupon.com/submit?url=http://blog.bhushangahire.net/2010/01/15/send-sms-from-ruby-on-rails-application-using-web-service-soap-api/&amp;title=Send+SMS+from+Ruby+On+Rails+application+using+web+service%2C+SOAP+API" rel="nofollow" title="Stumble upon something good? Share it on StumbleUpon">Stumble upon something good? Share it on StumbleUpon</a>
		</li>
		<li class="sexy-technorati">
			<a href="http://technorati.com/faves?add=http://blog.bhushangahire.net/2010/01/15/send-sms-from-ruby-on-rails-application-using-web-service-soap-api/" rel="nofollow" title="Share this on Technorati">Share this on Technorati</a>
		</li>
		<li class="sexy-facebook">
			<a href="http://www.facebook.com/share.php?v=4&amp;src=bm&amp;u=http://blog.bhushangahire.net/2010/01/15/send-sms-from-ruby-on-rails-application-using-web-service-soap-api/&amp;t=Send+SMS+from+Ruby+On+Rails+application+using+web+service%2C+SOAP+API" rel="nofollow" title="Share this on Facebook">Share this on Facebook</a>
		</li>
		<li class="sexy-twitter">
			<a href="http://twitter.com/home?status=Send+SMS+from+Ruby+On+Rails+application+using+web+service%2C+SOAP+API+-+http://tr.im/SU8m+(via+@bhushangahire)" rel="nofollow" title="Tweet This!">Tweet This!</a>
		</li>
		<li class="sexy-linkedin">
			<a href="http://www.linkedin.com/shareArticle?mini=true&amp;url=http://blog.bhushangahire.net/2010/01/15/send-sms-from-ruby-on-rails-application-using-web-service-soap-api/&amp;title=Send+SMS+from+Ruby+On+Rails+application+using+web+service%2C+SOAP+API&amp;summary=SOAP4R%20is%20a%20Ruby%20library%20for%20accessing%20Web%20Services%20via%20SOAP.%20Recently%20I%20had%20a%20chance%20to%20explore%20SOAP4R.%20Here%27s%20how%20to%20get%20started%20with%20it.%20%20%20%20Installation%20%20Although%20Ruby%201.8.x%20comes%20with%20SOAP4R%20in%20its%20standard%20library%2C%20it%20is%20an%20old%2C%20buggy%20version.%20I%20highly%20recommend%20using%20the%20latest%20gem%20%281.5.8%20as%20o&amp;source=eXpand yOur cReativity" rel="nofollow" title="Share this on Linkedin">Share this on Linkedin</a>
		</li>
		<li class="sexy-tumblr">
			<a href="http://www.tumblr.com/share?v=3&amp;u=http%3A%2F%2Fblog.bhushangahire.net%2F2010%2F01%2F15%2Fsend-sms-from-ruby-on-rails-application-using-web-service-soap-api%2F&amp;t=Send+SMS+from+Ruby+On+Rails+application+using+web+service%2C+SOAP+API" rel="nofollow" title="Share this on Tumblr">Share this on Tumblr</a>
		</li>
</ul>
<div style="clear:both;"></div>
</div>
<!-- End SexyBookmarks Menu Code -->

<div style='clear:both'></div>]]></content:encoded>
			<wfw:commentRss>http://blog.bhushangahire.net/2010/01/15/send-sms-from-ruby-on-rails-application-using-web-service-soap-api/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
