<?xml version="1.0" encoding="utf-8"?>
<feed xmlns="http://www.w3.org/2005/Atom">

  <title><![CDATA[Randika Rathugama]]></title>
  <link href="http://randika.github.com/atom.xml" rel="self"/>
  <link href="http://randika.github.com/"/>
  <updated>2012-05-12T11:46:02+01:00</updated>
  <id>http://randika.github.com/</id>
  <author>
    <name><![CDATA[Randika Rathugama]]></name>
    
  </author>
  <generator uri="http://octopress.org/">Octopress</generator>

  
  <entry>
    <title type="html"><![CDATA[How to deploy rails 3.1 app on heroku Cedar stack]]></title>
    <link href="http://randika.github.com/2011/11/09/how-to-deploy-rails-3-1-app-on-heroku-cedar-stack/"/>
    <updated>2011-11-09T03:36:50+00:00</updated>
    <id>http://randika.github.com/2011/11/09/how-to-deploy-rails-3-1-app-on-heroku-cedar-stack</id>
    <content type="html"><![CDATA[<script src="https://gist.github.com/1344834.js?file=deploy-notes-heroku.txt"></script>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Linux tips: Check whether the mongrel port 3000 is open]]></title>
    <link href="http://randika.github.com/2011/06/03/linux-tips-check-whether-the-mongrel-port-3000-is-open/"/>
    <updated>2011-06-03T19:39:41+01:00</updated>
    <id>http://randika.github.com/2011/06/03/linux-tips-check-whether-the-mongrel-port-3000-is-open</id>
    <content type="html"><![CDATA[<script src="https://gist.github.com/1006395.js?file=gistfile1.txt"></script>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Linux tips: How To Search Shell Command History]]></title>
    <link href="http://randika.github.com/2011/06/03/linux-tips-how-to-search-shell-command-history/"/>
    <updated>2011-06-03T19:16:25+01:00</updated>
    <id>http://randika.github.com/2011/06/03/linux-tips-how-to-search-shell-command-history</id>
    <content type="html"><![CDATA[<script src="https://gist.github.com/1006368.js?file=gistfile1.sh"></script>



]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[How to Install Ruby 1.9.2 and Rails 3.0 on Ubuntu]]></title>
    <link href="http://randika.github.com/2011/02/05/how-to-install-ruby-1-9-2-and-rails-3-0-on-ubuntu/"/>
    <updated>2011-02-05T01:36:40+00:00</updated>
    <id>http://randika.github.com/2011/02/05/how-to-install-ruby-1-9-2-and-rails-3-0-on-ubuntu</id>
    <content type="html"><![CDATA[<p>Most of the developers still use package managers to install ruby. This approach works, but most of the times it leads to dependency issues every now and then. Usually I don&#8217;t use package managers to install ruby, instead I use ruby version manager (RVM) by <a href="https://github.com/wayneeseguin/rvm" target="_blank">wayneeseguin</a></p>

<p>In this post I&#8217;m going to install ruby 1.9.2 on Ubuntu with the help of rvm.</p>

<p>Usually I use &#8220;aptitude&#8221; to install packages as It&#8217;s a better way to track the dependencies. If you don&#8217;t have it installed on your system, you can get it by executing these command on a shell prompt.</p>

<script src="https://gist.github.com/1325781.js?file=Installtion_notes_Ruby192_Ubuntu"></script>


<p>Great everything is ready for you now. Have fun with rails 3.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[How to unzip bz2 files]]></title>
    <link href="http://randika.github.com/2010/06/18/how-to-unzip-bz2-files/"/>
    <updated>2010-06-18T16:38:40+01:00</updated>
    <id>http://randika.github.com/2010/06/18/how-to-unzip-bz2-files</id>
    <content type="html"><![CDATA[<p>tar &#8211;use-compress-program bzip2 -xvf your-file-name.tar.bz2</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Fedora: Accidentally deleted Gnome desktop panels, how to restore?]]></title>
    <link href="http://randika.github.com/2010/06/15/fedora-accidentally-deleted-gnome-desktop-panels-how-to-restore/"/>
    <updated>2010-06-15T09:38:12+01:00</updated>
    <id>http://randika.github.com/2010/06/15/fedora-accidentally-deleted-gnome-desktop-panels-how-to-restore</id>
    <content type="html"><![CDATA[<p>I accidentally deleted the entire panels at the bottom and the top of the my fedora Gnome installation. Start menu, the clock, desktop switchers, workspaces and everything are gone now.</p>

<p>After googling for few minutes I found a fix for this. Here is what I did.</p>

<pre class="console">[randika@localhost ~]$ mkdir bak
[randika@localhost ~]$ mv -rf {.gnome*,.gconf*} bak/
</pre>


<p>As you can see I moved (I really don&#8217;t recommend deleting configuration files) all the gnome configuration files from my account to another directory named</p>

<pre>/home/randika/bak/</pre>


<p>then I restarted the OS. Done, now I have the default settings back on my screen.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Ruby on Rails: How to bypass Model validation]]></title>
    <link href="http://randika.github.com/2010/04/09/ruby-on-rails-how-to-bypass-model-validation/"/>
    <updated>2010-04-09T12:55:27+01:00</updated>
    <id>http://randika.github.com/2010/04/09/ruby-on-rails-how-to-bypass-model-validation</id>
    <content type="html"><![CDATA[<p>In my recent application I have these two models (User, BusinessAccount) with some data validation which works well with their respective controllers.</p>

<p>While keeping these models with their data validation as it is, I wanted to create another Controller (SignupController) which save both model data at once. But  I wanted to bypass the original model validation when saving the data from SignupController.</p>

<p>Here is what I did to achieve it with <a href="http://api.rubyonrails.org/classes/ActiveRecord/Validations.html#M002153" target="_blank"><strong>save_with_validation</strong>(perform_validation = false)</a> , hope this will help someone else who looking for the same.</p>

<script src="http://gist.github.com/361105.js?file=gistfile1.ru"></script>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[JavaScript: trim() Function]]></title>
    <link href="http://randika.github.com/2010/02/09/javascript-trim-function/"/>
    <updated>2010-02-09T09:42:19+00:00</updated>
    <id>http://randika.github.com/2010/02/09/javascript-trim-function</id>
    <content type="html"><![CDATA[<p>Where is the trim() function to remove leading and trailing whitespaces of strings? Actually Javascript String object doesn&#8217;t natively support it. But there is a workaround for this with regular expressions.</p>

<script src="http://gist.github.com/299049.js?file=gistfile1.js"></script>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Ruby on rails: how to install ruby 1.8.7 on windows]]></title>
    <link href="http://randika.github.com/2010/01/11/ruby-on-rails-how-to-install-ruby-1-8-7-on-windows/"/>
    <updated>2010-01-11T16:47:23+00:00</updated>
    <id>http://randika.github.com/2010/01/11/ruby-on-rails-how-to-install-ruby-1-8-7-on-windows</id>
    <content type="html"><![CDATA[<p>I couldn&#8217;t find the very famous ruby one-click-installer for ruby 1.8.7, after trying various ways I ended up with a solution for this. Here is what I did to get ruby 1.8.7 installed on windows.</p>

<p>First download the ruby 1.8.7 from this link: <a href="http://www.ruby-lang.org/en/downloads/">http://www.ruby-lang.org/en/downloads/</a> (I took Ruby 1.8.7-p72 Binary)</p>

<p>extract this to c:\ruby (or somewhere else you prefer but avoid using spaces on directories for your own safety)</p>

<p>Now update your <code>PATH</code> environment variable with appending <code>c:\ruby\bin</code> and verify the status of the installation by typing <code>ruby -v</code> in the command line prompt.</p>

<pre class="console">C:\Users\Randika&gt;ruby -v
ruby 1.8.7 (2008-08-11 patchlevel 72) [i386-mswin32]</pre>


<p>Ok now we need some dependencies  packages which doesn&#8217;t bundle with ruby 1.8.7</p>

<p>Download <strong>libiconv package</strong> from here
<a href="http://www.ruby-lang.org/en/downloads/">http://sourceforge.net/projects/gettext/files/</a>
find the libiconv-1.9.1.bin.woe32\bin\iconv.dll and place it inside <code>c:\ruby\bin&lt;/code></p>

<p>Download <strong>zlib package</strong> from here
<a href="http://www.zlib.net/zlib123-dll.zip ">http://www.zlib.net/zlib123-dll.zip</a>
extract it and find the zlib1.dll and place it inside  inside <code>c:\ruby\bin&lt;/code></p>

<p>OK, now we can install <strong>rubygems</strong>
Get it from here <a href="http://rubyforge.org/frs/?group_id=126">rubygems-1.3.5.zip</a> and extract to wherever you prefer. And then run <code>ruby setup.rb</code></p>

<pre class="console">D:\gems\rubygems-1.3.5&gt;ruby setup.rb</pre>


<p>by now gems should be ready to use with. Now you can update gems with</p>

<pre class="console">gem update --system</pre>


<p>finally install rails</p>

<pre class="console">D:\&gt;gem install rails
.....
...
D:\&gt;rails -v
Rails 2.3.5</pre>


<p><span style="color: #000000;"><strong>UPDATE: (20100422)</strong></span>
There is a Release Candidate (RC) of Ruby 1.8.7 (Ruby 1.8.7-p249 (RC2)) at http://rubyinstaller.org/download.htm
You can try that instead of what I have told in this post. Anyway I didn&#8217;t try it myself yet.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Most wanted ruby on rails code snippets, tips and tricks]]></title>
    <link href="http://randika.github.com/2009/11/30/most-wanted-ruby-on-rails-code-snippets-tips-and-tricks/"/>
    <updated>2009-11-30T10:44:53+00:00</updated>
    <id>http://randika.github.com/2009/11/30/most-wanted-ruby-on-rails-code-snippets-tips-and-tricks</id>
    <content type="html"><![CDATA[<p>REMOVED as outdated.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Cakephp Tips: Routing an Admin dashboard]]></title>
    <link href="http://randika.github.com/2009/09/09/cakephp-tips-routing-an-admin-dashboard/"/>
    <updated>2009-09-09T12:49:11+01:00</updated>
    <id>http://randika.github.com/2009/09/09/cakephp-tips-routing-an-admin-dashboard</id>
    <content type="html"><![CDATA[<p>I had some issues today with the admin routes of my XYZ :) cakephp app. I want the administrator to be able to type <strong>domainfoo.bar/admin</strong> and be directed to a log in. Then right after the authentication I want them to be redirected to admin_index of  the dashboards_controller (Admin&#8217;s Dashboard), So here is what I did for redirection.</p>

<pre lang="php" line="1">
$this->redirect(array('controller'=>'dashboards','action'=>'admin_index'));
</pre>


<p>But the problem is that I get the following error:</p>

<h2 style="margin: 0.3em 0px; padding: 0.8em 0px 0px; font-weight: normal; background-color: #ffffff; color: #ee3322; font-family: 'Gill Sans','lucida grande',helvetica,arial,sans-serif; font-size: 27px;">Private Method in DashboardsController</h2>


<p class="error" style="margin: 1em 0px; padding: 0.8em; background-color: #ee3322; color: #ffffff; font-family: Courier,monospace; font-size: 14px; line-height: 19px;"><strong style="margin: 0px; padding: 0px;">Error:<span class="Apple-converted-space"> </span></strong><em style="margin: 0px; padding: 0px; color: #000000; font-weight: normal; line-height: 19px;">DashboardsController::</em><em style="margin: 0px; padding: 0px; color: #000000; font-weight: normal; line-height: 19px;">admin_index()</em><span class="Apple-converted-space"> </span>cannot be accessed directly.</p>


<p class="notice" style="margin: 1em 0px; padding: 0.8em; background-color: #ffcc00; color: #000000; display: block; font-family: Courier,monospace; font-size: 14px; line-height: 19px;"><strong style="margin: 0px; padding: 0px;">Notice:<span class="Apple-converted-space"> </span></strong>If you want to customize this error message, create app\views\errors\private_action.ctp</p>


<p>The issue is when using,</p>

<pre lang="php" line="1">
$this->redirect(array('controller'=>'dashboards','action'=>'admin_index'));
</pre>


<p>it tries to access the admin_index() function directly which is private as the URL goes<strong> domainfoo.bar/dashbords/admin_index</strong></p>

<p>Instead we should set it as:</p>

<pre lang="php" line="1">
$this->redirect(array('controller'=>'dashboards','action'=>'index','admin'=>true));
</pre>


<p>or</p>

<pre lang="php" line="1">
$this->redirect(array('controller'=>'dashboards','action'=>'index','prefix'=>'admin'));
</pre>


<p>Hope this will help someone one day.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Reusable code blocks in CakePhp]]></title>
    <link href="http://randika.github.com/2009/07/16/reusable-code-blocks-in-cakephp/"/>
    <updated>2009-07-16T04:30:28+01:00</updated>
    <id>http://randika.github.com/2009/07/16/reusable-code-blocks-in-cakephp</id>
    <content type="html"><![CDATA[<p>Many web applications has code blocks such as header areas, footer areas, navigation menus that need to be repeated from page to page. In Cake These reusable parts are called Elements. This short tutorial demonstrates how to create and reuse code block in <a href="http://cakephp.org">cakephp</a>.</p>

<p>All you needs do first is, find the /app/views/elements/ directory from your cakephp web app and create a new file with the .ctp extension. oh if you are using .thtml as your views extension no matter you can use it.</p>

<p>For this example I&#8217;m creating footer block for my cake app. in /app/views/elements/footer.ctp
Then add the codes that requires for the footer in that page.</p>

<p>and from my other views, now i can call for this block as</p>

<pre lang="php">echo $this->element('footer');</pre>


<p>Yeah, It&#8217;s that simple. Also you can pass data to an element through the element&#8217;s second argument:</p>

<pre lang="php">echo $this->element('footer', array("var_foo"=>"bar"));</pre>


<p>On your element now you can get that variable, as this variable is available as members of the parameter array.</p>

<pre lang="php">echo $var_foo; //this will print "bar" as the output.</pre>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[Favorite Quotes]]></title>
    <link href="http://randika.github.com/2009/07/04/favorite-quotes/"/>
    <updated>2009-07-04T08:32:41+01:00</updated>
    <id>http://randika.github.com/2009/07/04/favorite-quotes</id>
    <content type="html"><![CDATA[<p>Here are few quotes that I like, and I&#8217;ll update this page constantly when I find more. anyway most of the quotes you find here are computer-related. please contribute to the list by providing your favorite quotes as well.</p>

<p><strong>“To have a great idea, have a lot of them.”</strong>
<em>-Thomas Alva Edison</em></p>

<p><strong>“The value of an idea lies in the using of it.”</strong>
<em>- Thomas Alva Edison</em></p>

<p><strong>
&#8220;What I hear I forget, what I see I remember, what I do I understand.&#8221;</strong>
<em>&#8211;<a title="Read more about Confucius at Wikipedia" href="http://en.wikipedia.org/wiki/Confucius" target="_blank">Confucius</a> (Chines <span class="mu">philosopher </span>551 BC – 479 BC)</em></p>

<p><strong>“There are 10 kinds of people in the world, those that understand binary and those that don&#8217;t.”</strong></p>

<p><strong>&#8220;Good judgement comes from experience; experience comes from bad judgement.&#8221;</strong></p>

<p><strong>“Some people want it to happen, some wish it would happen, others make it happen.”</strong>
<em>&#8211;Michael Jordan (American professional basketball player (NBA) born February 17, 1963)</em></p>

<p><strong>“There are two ways of constructing a software design.  One way is to make it so simple that there are obviously no deficiencies. And the other way is to make it so complicated that there are no obvious deficiencies.”</strong><em>
&#8211;C.A.R. Hoare</em></p>

<p><strong>“The function of good software is to make the complex appear to be simple.”</strong><em>
&#8211;Grady Booch</em></p>

<p><strong>“Any fool can use a computer.  Many do.”</strong>
<em>&#8211;Ted Nelson</em></p>

<p><span class="status-body"><strong></strong><span class="entry-content"><strong>&#8220;Live as if you were to die tomorrow. Learn as if you were to live forever.&#8221;</strong>
<em>&#8211; Mahatma Gandhi</em></span></span></p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[How to fix the error You don't have permission to access /phpMyAdmin on this server]]></title>
    <link href="http://randika.github.com/2009/05/17/how-to-fix-the-error-you-dont-have-permission-to-access-phpmyadmin-on-this-server/"/>
    <updated>2009-05-17T11:34:00+01:00</updated>
    <id>http://randika.github.com/2009/05/17/how-to-fix-the-error-you-dont-have-permission-to-access-phpmyadmin-on-this-server</id>
    <content type="html"><![CDATA[<p>After installing phpMyAdmin on fedora (FC10) with yum you may notice this error when trying to access it via a remote node.</p>

<p>Forbidden
You don&#8217;t have permission to access /phpMyAdmin on this server.</p>

<p>This may trigger due to the restrictions which assigned with the default config file. Open it with your favorite editor from the path below.</p>

<pre class="console">[root@megantereon /]# vi /etc/httpd/conf.d/phpMyAdmin.conf</pre>


<p>by default you can only access phpMyAdmin only over localhost. The rule is here.</p>

<pre class="console">Alias /phpMyAdmin /usr/share/phpMyAdmin
order deny,allow
deny from all allow from 127.0.0.1</pre>


<p>To allow access over remote web browsers, comment out the lines on the above config file as shown below.</p>

<pre class="console">Alias /phpMyAdmin /usr/share/phpMyAdmin
#order deny,allow
#deny from all allow from 127.0.0.1</pre>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[How to configure yum to get through a proxy]]></title>
    <link href="http://randika.github.com/2009/05/10/how-to-configure-yum-to-get-through-a-proxy/"/>
    <updated>2009-05-10T08:41:00+01:00</updated>
    <id>http://randika.github.com/2009/05/10/how-to-configure-yum-to-get-through-a-proxy</id>
    <content type="html"><![CDATA[<p>Today I had a new problem with one of a Fedora 8 server. The issue was with &#8220;yum&#8221;. When I try to install some apps with yum it didn&#8217;t work for me. Sorry I can&#8217;t really remember the error at this time. But It was something related to Yum repository is not accessible.</p>

<p>First I thought there is some issue with internet, but I was wrong. Internet was fine. The server&#8217;s internet connection was running with a proxy. So I realized there is still something to do with yum configuration.</p>

<p>So I had to google a bit to find out a solution or fix for get through the proxy server. here is what I did.</p>

<p>I just execute this command on a shell prompt and yum worked fine for me.
NOTE: my proxy server is 130.10.32.3 on port 9000. make sure to use your one instead :)</p>

<pre class="console">
export http_proxy=http://130.10.xxx.xxx:xxxx
export ftp_proxy=http://130.10.xxx.xxx:xxxx
</pre>


<p>Alternately you may add this line to /etc/yum.conf</p>

<pre class="console">
http_proxy=http://130.10.xxx.xxx:xxxx
ftp_proxy=http://130.10.xxx.xxx:xxxx
</pre>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[How to enable root login under Fedora 10 Gnome GUI login screen]]></title>
    <link href="http://randika.github.com/2009/04/17/how-to-enable-root-login-under-fedora-10-gnome-gui-login-screen/"/>
    <updated>2009-04-17T13:30:00+01:00</updated>
    <id>http://randika.github.com/2009/04/17/how-to-enable-root-login-under-fedora-10-gnome-gui-login-screen</id>
    <content type="html"><![CDATA[<p>By default on fedora 10 you can&#8217;t login as the root user from the Gnome login screen(GUI). I&#8217;m not exactly sure why it is disabled. anyway there we can enable it by doing some modification to  /etc/pam.d/gdm</p>

<p>to do so, just login as a normal user and type this command to become root user:</p>

<pre class="console">
# su -
</pre>


<p>provide the password for the root account and open the above mentioned file from your favourite editor:</p>

<pre class="console">
# gedit /etc/pam.d/gdm
</pre>


<p>or</p>

<pre class="console">
# vi /etc/pam.d/gdm
</pre>


<p>find this line and uncomment it.</p>

<pre class="console">
auth required pam_succeed_if.so user != root quiet
</pre>


<p>Save and close the file. Logout from the system. Now you should be able to login as root user from the login screen.</p>
]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[How to Change Default User Home Directory on Linux]]></title>
    <link href="http://randika.github.com/2009/04/17/how-to-change-default-user-home-directory-on-linux/"/>
    <updated>2009-04-17T09:46:00+01:00</updated>
    <id>http://randika.github.com/2009/04/17/how-to-change-default-user-home-directory-on-linux</id>
    <content type="html"><![CDATA[<p>By default user is added to /home directory. I just came up with a requirement of changing this to somewhere else. So here is the solution if you looking for the same.</p>

<p>Default values for account creation defined in /etc/default/useradd file under Linux distros.
Let&#8217;s open it up using a text editor. I&#8217;m using vi editor as always.</p>

<pre class="console">
# vi /etc/default/useradd
</pre>


<p>here is what i can see in my fedora box:</p>

<pre class="console">
# useradd defaults file
GROUP=100
HOME=/home
INACTIVE=-1
EXPIRE=
SHELL=/bin/bash
SKEL=/etc/skel
CREATE_MAIL_SPOOL=yes
</pre>


<p>as you can see the default home directory defined by HOME variable.  just replace it with your new path.</p>

<pre class="console">
HOME=/allusers/developers
</pre>

]]></content>
  </entry>
  
  <entry>
    <title type="html"><![CDATA[How to Install Glassfish on Linux]]></title>
    <link href="http://randika.github.com/2009/03/30/how-to-install-glassfish-on-linux/"/>
    <updated>2009-03-30T07:12:00+01:00</updated>
    <id>http://randika.github.com/2009/03/30/how-to-install-glassfish-on-linux</id>
    <content type="html"><![CDATA[<p>Before start the installation, verify the availability of java in your linux node.</p>

<pre class="console">$ java -version
java version "1.6.0_0"
IcedTea6 1.3.1 (6b12-Fedora-10) Runtime Environment (build 1.6.0_0-b12)
OpenJDK Client VM (build 1.6.0_0-b12, mixed mode)</pre>


<p><span style="font-size:85%;">Now you need the latest version of </span><a title="Download glassfish" href="https://glassfish.dev.java.net/downloads">Glassfish application server</a><span style="font-size:85%;">, I’m using Glassfish V2 for Linux for this installation.</span> I&#8217;m going to download this file to <span style="font-weight: bold;">/opt </span>dir.</p>

<pre class="console">$ lwp-download http://java.net/download/javaee5/v2ur2/promoted/Linux/glassfish-installer-v2ur2-b04-linux.jar</pre>


<p>once finished, execute</p>

<pre class="console">$ java -Xmx256m -jar glassfish-installer-v2ur2-b04-linux.jar</pre>


<p>Files will be decompressed in a directory named <span style="font-weight: bold;">/opt/glassfish</span></p>

<p>switch to glassfish dir and type</p>

<pre class="console">$ chmod +x -R lib/ant/bin
$ lib/ant/bin/ant -f setup.xml</pre>


<p>Ok, its almost done. Let&#8217;s start the server now.</p>

<pre class="console">$ bin/asadmin start-domain</pre>


<p>Now type http://localhost:8080 and see it&#8217;s working. you can reach to the admin console http://localhost:4848 here with default username/password. (admin/adminadmin)</p>

<p>hope this helps some one. <span style="font-family:monospace;">
</span></p>
]]></content>
  </entry>
  
</feed>

