<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/atom10full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><feed xmlns="http://www.w3.org/2005/Atom" xmlns:openSearch="http://a9.com/-/spec/opensearch/1.1/" xmlns:blogger="http://schemas.google.com/blogger/2008" xmlns:georss="http://www.georss.org/georss" xmlns:gd="http://schemas.google.com/g/2005" xmlns:thr="http://purl.org/syndication/thread/1.0" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" gd:etag="W/&quot;A0ADSHY5fCp7ImA9WhFSFEs.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657</id><updated>2013-06-17T17:19:39.824+05:30</updated><category term="libreoffice" /><category term="Kaspersky" /><category term="web" /><category term="gentoo" /><category term="malware" /><category term="word" /><category term="ants" /><category term="broadcom" /><category term="sed" /><category term="mainframe" /><category term="chrome" /><category term="corby" /><category term="medical" /><category term="dell" /><category term="css" /><category term="powershell" /><category term="git" /><category term="valgrind" /><category term="globus" /><category term="smartmontools" /><category term="grep" /><category term="rails" /><category term="spam" /><category term="HR" /><category term="hg" /><category term="bsnl" /><category term="fossil" /><category term="aws" /><category term="facebook" /><category term="visualization" /><category term="choice" /><category term="hardware innovation" /><category term="JCL" /><category term="64-bit" /><category term="java" /><category term="mysql" /><category term="ntfs" /><category term="WPA" /><category term="arch" /><category term="Thunderbird" /><category term="security" /><category term="Memristor" /><category term="IPL" /><category term="CAPTCHA" /><category term="utf-8" /><category term="Commandos Strike Force" /><category term="journalctl" /><category term="hal" /><category term="django" /><category term="gridftp" /><category term="bash" /><category term="ext2" /><category term="WEP" /><category term="Firefox" /><category term="pkgbuild" /><category term="filesystem" /><category term="desktop" /><category term="dns" /><category term="software" /><category term="rubymine" /><category term="pip2" /><category term="Virus.win32.autorun.abt" /><category term="Walter Lewin" /><category term="heroku" /><category term="boto" /><category term="udev" /><category term="xpressmusic" /><category term="journalism" /><category term="vista" /><category term="jetbrains" /><category term="Enlightenment" /><category term="google" /><category term="MC3100" /><category term="ruby" /><category term="bitdefender" /><category term="activerecord" /><category term="proxy" /><category term="cryptography" /><category term="Microsoft" /><category term="HIV" /><category term="Times of India" /><category term="cache" /><category term="Counter Strike" /><category term="cricket" /><category term="apple" /><category term="perl" /><category term="OLED" /><category term="skype" /><category term="fedora" /><category term="systemd" /><category term="openoffice" /><category term="gnome" /><category term="nokia" /><category term="python" /><category term="Mozilla" /><category term="Panda antivirus" /><category term="script" /><category term="windows" /><category term="irc" /><category term="image" /><category term="Intuition" /><category term="troubleshoot" /><category term="csv" /><category term="olx.in" /><category term="wlan" /><category term="India" /><category term="screenshots" /><category term="humantiy" /><category term="linux" /><category term="computer science" /><category term="hibernate" /><category term="KDE" /><category term="ertf" /><category term="emacs" /><category term="init" /><category term="boot" /><category term="opensuse" /><category term="octave" /><category term="poppler" /><category term="politics" /><category term="micromax" /><category term="syslog" /><category term="ssh" /><category term="games" /><category term="Motorola" /><category term="font" /><category term="rtf" /><category term="Microsoft Surface" /><category term="book" /><category term="samsung" /><category term="gprs" /><category term="ascii" /><category term="pleasure" /><category term="blogger" /><category term="SEO" /><category term="bottom up" /><category term="wireless" /><category term="z/OS" /><category term="w32.Autorun.FM.worm" /><category term="kernel" /><category term="chromium" /><category term="IE" /><category term="iptables" /><category term="freenode" /><category term="gmail" /><category term="ftp" /><category term="Yahoo Messenger" /><title>A Window</title><subtitle type="html">Here I write about various events I was involved in and ideas that inspired me. Recently, it is more of a linux blog because I have been doing a lot of work on it. However, off and on I write on various other things that my mind just can't let go easily.</subtitle><link rel="http://schemas.google.com/g/2005#feed" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/posts/default" /><link rel="alternate" type="text/html" href="http://intosimple.blogspot.com/" /><link rel="next" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default?start-index=26&amp;max-results=25&amp;redirect=false&amp;v=2" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><generator version="7.00" uri="http://www.blogger.com">Blogger</generator><openSearch:totalResults>182</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/atom+xml" href="http://feeds.feedburner.com/DigDeeperIntoSimplicity" /><feedburner:info uri="digdeeperintosimplicity" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><entry gd:etag="W/&quot;DE4BRXc6fCp7ImA9WhBaGUk.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-8390325869425265931</id><published>2013-05-31T02:18:00.001+05:30</published><updated>2013-05-31T02:19:14.914+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-31T02:19:14.914+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="Intuition" /><title>[Rails:] false.present? being false is not intuitive (to me at least)</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
In Rails I often use the &lt;code&gt;present?&lt;/code&gt; method to check whether a key-value pair is present is an input hash. The code would be something like the following.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;def trial_method(params)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; o = Model.where(:id =&amp;gt; params[:id].to_i).first&lt;br /&gt;
&amp;nbsp; &amp;nbsp; o.field = params[:field_key] if params[:field_key].present?&lt;br /&gt;
&amp;nbsp; &amp;nbsp; o.save!&lt;br /&gt;
end&lt;/code&gt;
&lt;br /&gt;
This works fine when field is most cases. However, when the field is a &lt;code&gt;boolean&lt;/code&gt; field, there is a subtle with this code.&lt;br /&gt;
&lt;br /&gt;
When &lt;code&gt;params[:field_key]&lt;/code&gt; is true, the code works fine; but whenever it is &lt;code&gt;false&lt;/code&gt;, the code fails. The intent is to see if the key-value pair is present and if present the value should be assigned to the field. Now, the value can be both &lt;code&gt;true&lt;/code&gt; and &lt;code&gt;false&lt;/code&gt; and both of those should be assigned to field. However, when the value is &lt;code&gt;false&lt;/code&gt;, the &lt;code&gt;present?&lt;/code&gt; function returns false and the field is not set any more. So the field value stays &lt;code&gt;true&lt;/code&gt; and with the above code can not be flipped to &lt;code&gt;false&lt;/code&gt;. The correction is of course simple.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;o.field = params[:field_key] unless params[:field_key].nil?&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
This behaviour did not seem intuitive to me. So, I looked up documentation and source for &lt;a href="http://api.rubyonrails.org/classes/Object.html#method-i-present-3F" rel="nofollow"&gt;&lt;code&gt;present?&lt;/code&gt;&lt;/a&gt;. The definition of &lt;code&gt;present?&lt;/code&gt; is quite simple.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;def present?&lt;br /&gt;
&amp;nbsp; !blank?&lt;br /&gt;
end&lt;/code&gt;
&lt;br /&gt;
Clearly all it does is to negate the result of &lt;code&gt;blank?&lt;/code&gt;. So, I looked up the definition for that too.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;def blank?&lt;br /&gt;
&amp;nbsp; respond_to?(:empty?) ? empty? : !self&lt;br /&gt;
end&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
When I tested &lt;code&gt;false.respond_to?(:empty?)&lt;/code&gt;, it returned &lt;code&gt;false&lt;/code&gt;. So, it is clearly executing the &lt;code&gt;!self&lt;/code&gt; part, which translates to &lt;code&gt;false.blank?&lt;/code&gt; being &lt;code&gt;true&lt;/code&gt; and therefore &lt;code&gt;false.present?&lt;/code&gt; being &lt;code&gt;false&lt;/code&gt;.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/cm3lG4FSfLA" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/8390325869425265931/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=8390325869425265931" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/8390325869425265931?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/8390325869425265931?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/cm3lG4FSfLA/rails-falsepresent-being-false-is-not.html" title="[Rails:] false.present? being false is not intuitive (to me at least)" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/05/rails-falsepresent-being-false-is-not.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CEcEQ3szfCp7ImA9WhBaGU8.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-2410405329232789069</id><published>2013-05-30T19:23:00.000+05:30</published><updated>2013-05-30T19:23:22.584+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-30T19:23:22.584+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="csv" /><category scheme="http://www.blogger.com/atom/ns#" term="libreoffice" /><title>LibreOffice is not showing CSV files properly</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
I get to deal with comma-separated(.csv) and tab-separated(.tsv) files from time to time and I have seen LibreOffice showing gibberish when I try to view the files.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-YKISQeusuFE/UadZZ9e6UmI/AAAAAAAAAUw/hXQBZY5jtB4/s1600/libre1.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="306" src="http://1.bp.blogspot.com/-YKISQeusuFE/UadZZ9e6UmI/AAAAAAAAAUw/hXQBZY5jtB4/s400/libre1.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
The fix is actually very simple. I just had to set the encoding correctly.&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://3.bp.blogspot.com/-SarLOJpHPCc/UadZms14uwI/AAAAAAAAAU4/OSKdW-c_DE0/s1600/libre2.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="305" src="http://3.bp.blogspot.com/-SarLOJpHPCc/UadZms14uwI/AAAAAAAAAU4/OSKdW-c_DE0/s400/libre2.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/yLchWeWFLUk" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/2410405329232789069/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=2410405329232789069" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/2410405329232789069?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/2410405329232789069?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/yLchWeWFLUk/libreoffice-is-not-showing-csv-files.html" title="LibreOffice is not showing CSV files properly" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-YKISQeusuFE/UadZZ9e6UmI/AAAAAAAAAUw/hXQBZY5jtB4/s72-c/libre1.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/05/libreoffice-is-not-showing-csv-files.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0INRHkyfSp7ImA9WhBaFUQ.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-269321533107212484</id><published>2013-05-27T01:49:00.000+05:30</published><updated>2013-05-27T01:49:55.795+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-27T01:49:55.795+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="mainframe" /><category scheme="http://www.blogger.com/atom/ns#" term="z/OS" /><category scheme="http://www.blogger.com/atom/ns#" term="JCL" /><title>Separating data processor implementation and data processing logic</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
After about a year, yesterday I was looking some Mainframe source code. I was looking at some JCL to be precise. Looking at the familiar &lt;a href="http://publib.boulder.ibm.com/infocenter/zos/basics/index.jsp?topic=/com.ibm.zos.zdatamgmt/zsysprogc_utilities_IDCAMS.htm" rel="nofollow"&gt;IDCAMS&lt;/a&gt; and &lt;a href="http://publib.boulder.ibm.com/infocenter/zos/v1r11/index.jsp?topic=/com.ibm.zos.r11.idai200/repro.htm" rel="nofollow"&gt;REPRO&lt;/a&gt; procedures, I could get a sense of what the code was doing. Then I saw a sorting routine which used the program &lt;a href="http://publib.boulder.ibm.com/infocenter/zos/v1r11/index.jsp?topic=/com.ibm.zos.r11.icea100/ice1ca40162.htm" rel="nofollow"&gt;ICETOOL&lt;/a&gt;. I could figure out the input and output streams defined but I could not find the parameters for sorting. Finally, I figured they were getting passed through &lt;a href="http://publib.boulder.ibm.com/infocenter/zos/v1r11/index.jsp?topic=/com.ibm.zos.r11.icea100/icesam.htm" rel="nofollow"&gt;TOOLIN&lt;/a&gt;&amp;nbsp;interface. Interestingly, the sorting parameters were kept in a separate file. This was nice programming: separating the rules from the implementation so that when the input changes, the changes to the rules can be made in that file only and the rest of the program works fine without any changes.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/KKXh0z0YRLQ" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/269321533107212484/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=269321533107212484" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/269321533107212484?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/269321533107212484?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/KKXh0z0YRLQ/separating-data-processor.html" title="Separating data processor implementation and data processing logic" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/05/separating-data-processor.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0AERX86eCp7ImA9WhBaE00.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-8467326418992854236</id><published>2013-05-23T17:18:00.000+05:30</published><updated>2013-05-23T17:18:24.110+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-23T17:18:24.110+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="aws" /><title>Search in AWS console</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
When I managed a small number of servers, looking up a server in AWS console was rather easy. However, as the number of servers grew, I started thinking of having a filter/search option. Fortunately AWS provides a nice search feature in the console.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://1.bp.blogspot.com/-qKQONs58rUc/UZ4BNzg8yBI/AAAAAAAAAUY/trHBPTZbv2Y/s1600/aws.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-qKQONs58rUc/UZ4BNzg8yBI/AAAAAAAAAUY/trHBPTZbv2Y/s1600/aws.png" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;Initial view when my instances were showing and there was no filter text.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;
&lt;table align="center" cellpadding="0" cellspacing="0" class="tr-caption-container" style="margin-left: auto; margin-right: auto; text-align: center;"&gt;&lt;tbody&gt;
&lt;tr&gt;&lt;td style="text-align: center;"&gt;&lt;a href="http://2.bp.blogspot.com/-I3kt2aqK-rg/UZ4BN9tJeAI/AAAAAAAAAUc/ckJ2HSfDfyo/s1600/aws1.png" imageanchor="1" style="margin-left: auto; margin-right: auto;"&gt;&lt;img border="0" height="106" src="http://2.bp.blogspot.com/-I3kt2aqK-rg/UZ4BN9tJeAI/AAAAAAAAAUc/ckJ2HSfDfyo/s400/aws1.png" width="400" /&gt;&lt;/a&gt;&lt;/td&gt;&lt;/tr&gt;
&lt;tr&gt;&lt;td class="tr-caption" style="text-align: center;"&gt;After I added incorrect filter text, no matching instances were found.&lt;/td&gt;&lt;/tr&gt;
&lt;/tbody&gt;&lt;/table&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/5VsT2uR6Yuc" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/8467326418992854236/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=8467326418992854236" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/8467326418992854236?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/8467326418992854236?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/5VsT2uR6Yuc/search-in-aws-console.html" title="Search in AWS console" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-qKQONs58rUc/UZ4BNzg8yBI/AAAAAAAAAUY/trHBPTZbv2Y/s72-c/aws.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/05/search-in-aws-console.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak8GQHYzeyp7ImA9WhBaE00.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-1979012508961639951</id><published>2013-05-23T12:12:00.001+05:30</published><updated>2013-05-23T17:03:41.883+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-23T17:03:41.883+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="KDE" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="bash" /><title>Directory size listing</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
A lot of times when freeing up disk space [Well yes in today's world also people like me need to do it.], instead of opening my file manager and finding the size of the folders by checking the properties section in the right-click drop-down, I wanted to look at a list view where I can sort by folder size. Now, &lt;a href="http://kde.org/" rel="nofollow"&gt;KDE&lt;/a&gt;'s Dolphin file manager shows number of items within a folder but not the size and I anyways prefer the command line so I wanted a command line tool that lists size of directories. The amount of space left on the partitions can be easily found by the following command:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;df -h&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
I also found a command for directory size.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;du&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
However, its default behaviour is to show the size of files recursively. So, I do not get the size of the folders in the directory I am interested in. Instead, I get the size of files within those folders and recursively so forth. I needed to set the depth of search into the folders. I found a parameter with a similar name. The following command works just as I need.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;du --max-depth=1 -h&lt;/code&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/iiJ3oZF3xZY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/1979012508961639951/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=1979012508961639951" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/1979012508961639951?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/1979012508961639951?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/iiJ3oZF3xZY/directory-size.html" title="Directory size listing" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/05/directory-size.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkIAQ3Y_cCp7ImA9WhBbEk8.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-2222846355041096342</id><published>2013-05-11T02:45:00.004+05:30</published><updated>2013-05-11T02:45:42.848+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-11T02:45:42.848+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="facebook" /><title>Inconsistent facebook</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://1.bp.blogspot.com/-MFOEbEyxMPU/UY1jZPHrd3I/AAAAAAAAAUA/YswoxQExBfc/s1600/fb.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" src="http://1.bp.blogspot.com/-MFOEbEyxMPU/UY1jZPHrd3I/AAAAAAAAAUA/YswoxQExBfc/s1600/fb.png" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/jWI-We9Wtks" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/2222846355041096342/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=2222846355041096342" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/2222846355041096342?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/2222846355041096342?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/jWI-We9Wtks/inconsistent-facebook.html" title="Inconsistent facebook" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://1.bp.blogspot.com/-MFOEbEyxMPU/UY1jZPHrd3I/AAAAAAAAAUA/YswoxQExBfc/s72-c/fb.png" height="72" width="72" /><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/05/inconsistent-facebook.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0ACQn0zeyp7ImA9WhBbEUs.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-7297323218226436140</id><published>2013-05-09T19:55:00.002+05:30</published><updated>2013-05-10T11:32:43.383+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-10T11:32:43.383+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="powershell" /><category scheme="http://www.blogger.com/atom/ns#" term="windows" /><title>Operating on each file in a directory in Windows Powershell</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Recently, when I had to do some tasks on a Windows machine, I thought of trying out the Powershell. I had to process every file in a directory. In linux, I could easily do it on the command line so I tried to find out similar way for Windows. It turned out to be fairly simple actually.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;$files=get-childitem .&lt;br /&gt;
foreach ($file in $files) { echo $file.fullname &amp;nbsp;}&lt;/code&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/UUpxWvMu3E0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/7297323218226436140/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=7297323218226436140" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/7297323218226436140?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/7297323218226436140?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/UUpxWvMu3E0/operating-on-each-file-in-directory-in.html" title="Operating on each file in a directory in Windows Powershell" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/05/operating-on-each-file-in-directory-in.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CkMAQX0ycCp7ImA9WhBbEk8.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-6731407857317364154</id><published>2013-05-08T01:02:00.000+05:30</published><updated>2013-05-11T02:44:00.398+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-05-11T02:44:00.398+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="India" /><category scheme="http://www.blogger.com/atom/ns#" term="humantiy" /><category scheme="http://www.blogger.com/atom/ns#" term="olx.in" /><category scheme="http://www.blogger.com/atom/ns#" term="medical" /><title>Sad state of medical profession</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div style="text-align: justify;"&gt;
Today when a friend told me about an ad at &lt;a href="http://www.olx.in/"&gt;olx.in&lt;/a&gt; about &lt;a href="http://www.olx.in/nf/search/medical%2Bseats" rel="nofollow"&gt;medical seats being sold&lt;/a&gt; (for those unaware of the concept, it means paying and getting into medical colleges irrespective of one's qualifications and intellectual merit), I was appalled. I knew that such things do happen. However, these deals were always secretly done. Openly selling seats in colleges is equivalent to committing theft in broad daylight and proudly announcing that it is the thief's right to do so. I believe it is blasphemy against humanity. It is a pity that people consider religious blasphemy very seriously but blasphemy against humanity is so simply ignored.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
There is a propagation of crime going on here. These colleges bribe their way out of accreditation process or make a temporary show of fulfilling the requirements of the accreditation. Very rarely some are &lt;a href="http://articles.timesofindia.indiatimes.com/2013-04-15/news/38555338_1_engineering-colleges-technical-institutions-moorthy-selvakumaran"&gt;caught&lt;/a&gt;. Obviously the quality of education in such institutes is not up to the mark. The grave question then is whether we can trust diagnoses done by doctors passing our from such institutes that offer seats for sale. This actually is a more serious concern than global warming because incorrect diagnoses will cause undeserved deaths; but sadly no politician talks of it in his/her agenda.&lt;br /&gt;
&lt;br /&gt;
&lt;div class="separator" style="clear: both; text-align: center;"&gt;
&lt;a href="http://2.bp.blogspot.com/--Q2x6lBL01g/UYlX7Rx4pVI/AAAAAAAAATs/eUygCpsRF-c/s1600/olx.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"&gt;&lt;img border="0" height="385" src="http://2.bp.blogspot.com/--Q2x6lBL01g/UYlX7Rx4pVI/AAAAAAAAATs/eUygCpsRF-c/s400/olx.png" width="400" /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/3CB-Sj8DNvg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/6731407857317364154/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=6731407857317364154" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/6731407857317364154?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/6731407857317364154?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/3CB-Sj8DNvg/sad-state-of-medical-profession.html" title="Sad state of medical profession" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="http://2.bp.blogspot.com/--Q2x6lBL01g/UYlX7Rx4pVI/AAAAAAAAATs/eUygCpsRF-c/s72-c/olx.png" height="72" width="72" /><thr:total>1</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/05/sad-state-of-medical-profession.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0EFQn0yfyp7ImA9WhBWGUk.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-554906859259301839</id><published>2013-04-14T18:50:00.001+05:30</published><updated>2013-04-14T18:50:13.397+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-04-14T18:50:13.397+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="pip2" /><category scheme="http://www.blogger.com/atom/ns#" term="grep" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>Uninstalling python packages</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Continuing my &lt;a href="http://intosimple.blogspot.com/2013/04/uninstalling-all-gems.html" rel="nofollow" target="_blank"&gt;system cleanup&lt;/a&gt;, I decided to get rid of all unnecessary python packages.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;pip2 list | awk -F ' ' '{print $1}' | grep -vE "django-paypal|boto|mercurial|MySQL-python|nltk" | xargs pip2 uninstall -y&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
The &lt;code&gt;-y&lt;/code&gt; flag indicates confirmation of uninstallation.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/6UU3LXQs78I" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/554906859259301839/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=554906859259301839" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/554906859259301839?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/554906859259301839?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/6UU3LXQs78I/uninstalling-python-packages.html" title="Uninstalling python packages" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/04/uninstalling-python-packages.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkIHSHg6eip7ImA9WhBWGUk.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-4464478420683087430</id><published>2013-04-10T22:18:00.002+05:30</published><updated>2013-04-14T18:32:19.612+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-04-14T18:32:19.612+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="grep" /><title>Uninstalling all gems</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Some time back I was trying out jruby. I had installed multiple gems for it. Today, while cleaning up my system I was trying to get rid of it because it does not have much use to me. However, uninstalling the gems one by one is a pain. So, I wrote the following line to uninstall all gems.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;jruby -S gem list | awk -F ' ' '{print $1}' | xargs jruby -S gem uninstall&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
P.S. : To understand how to construct such one liners please look at my &lt;a href="http://intosimple.blogspot.com/2013/01/kill-all-zombie-processes-of-process.html" rel="nofollow" target="_blank"&gt;previous post&lt;/a&gt;.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/QZz_sHqiQ9k" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/4464478420683087430/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=4464478420683087430" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/4464478420683087430?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/4464478420683087430?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/QZz_sHqiQ9k/uninstalling-all-gems.html" title="Uninstalling all gems" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/04/uninstalling-all-gems.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DUEDQXYzcCp7ImA9WhBQGEQ.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-3237749295102066454</id><published>2013-03-22T01:55:00.000+05:30</published><updated>2013-03-22T01:57:50.888+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-22T01:57:50.888+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><title>Call by reference in Ruby</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
In Ruby, some objects are passed by value and some by reference. In case, we want to pass by reference some object which by default gets passed by value, we can just use the id value of the object in Ruby's memory, i.e. the object space. The id can be obtained as follows.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;some_object = "some intialization"&lt;br /&gt;
some_object.object_id&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Here is how pass by reference would work using object id values.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;def caller&lt;br /&gt;
&amp;nbsp; &amp;nbsp; blah = "blahblueblah"&lt;br /&gt;
&amp;nbsp; &amp;nbsp; callee(blah.object_id)&lt;br /&gt;
end&lt;br /&gt;
&lt;br /&gt;
def callee(object_id)&lt;br /&gt;
&amp;nbsp; &amp;nbsp; puts ObjectSpace._id2ref(doc.object_id)&lt;br /&gt;
end&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Such use should be highly improbable and might even turn out to be bad practice; but sometimes we just want to do things for the heck of it.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/Qed2mfOPd1w" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/3237749295102066454/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=3237749295102066454" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/3237749295102066454?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/3237749295102066454?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/Qed2mfOPd1w/call-by-reference-in-ruby.html" title="Call by reference in Ruby" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/03/call-by-reference-in-ruby.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0MNQn0zeip7ImA9WhBQFko.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-9085040607085445272</id><published>2013-03-19T13:21:00.000+05:30</published><updated>2013-03-19T13:21:33.382+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-19T13:21:33.382+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="mysql" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="activerecord" /><category scheme="http://www.blogger.com/atom/ns#" term="cache" /><title>Bypassing ActiveRecord cache</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;code&gt;ActiveRecord&lt;/code&gt; is the default object relational model of the Rails web framework. It obviously follows the &lt;a href="http://en.wikipedia.org/wiki/Active_record_pattern" rel="nofollow" target="_blank"&gt;active record&lt;/a&gt; architectural pattern. Now, &lt;code&gt;ActiveRecord&lt;/code&gt; maintains it own query cache which is different from the query cache of the underlying database server. This query cache is a rather simplistic one.&lt;br /&gt;
&lt;br /&gt;
The issue that brought the requirement of query cache bypassing into picture was as follows.&lt;br /&gt;
&lt;br /&gt;
1. a call to first object of the model to check if any records existed (Model.first)&lt;br /&gt;
2. raw SQL query to truncate the table&lt;br /&gt;
3. a call again to first object of the model to check if any records existed (Model.first)&lt;br /&gt;
&lt;br /&gt;
Now, #1 and #3 obviously generated same SQL query. So, &lt;code&gt;ActiveRecord&lt;/code&gt; served #3 from its cache.&lt;br /&gt;
&lt;br /&gt;
We found multiple approaches of bypassing the &lt;code&gt;ActiveRecord&lt;/code&gt; cache.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Approach 1&lt;/b&gt;&lt;br /&gt;
Clear the entire &lt;code&gt;ActiveRecord&lt;/code&gt; cache. In Rails 2 this can be done using&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;ActiveRecord::Base.query_cache.clear_query_cache&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
In Rails 3, the same can be achieved using the following line.&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp;&lt;code&gt;ActiveRecord::Base.connection.clear_query_cache&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
This approach however would clear the entire &lt;code&gt;ActiveRecord&lt;/code&gt; cache which in production environment means increasing load on database server which is already the bottleneck. Plus, this approach is like using a jack hammer where a finger-tap would work.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Approach 2&lt;/b&gt;&lt;br /&gt;
This approach exploits the simplicity of the &lt;code&gt;ActiveRecord&lt;/code&gt; cache. It forms the query in such a manner that the query string is very likely to be different from previous queries.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;r = call random number generator&lt;br /&gt;
where_clause = "r = r"&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Appending the above where clause to #1 and #3, we obtained queries that are very likely to be different from previous ones at least within the life time of the cache. This approach is obviously not elegant.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Approach 3&lt;/b&gt;&lt;br /&gt;
In this approach, we went with raw SQL queries not only for #2 but also for #1 and #3. &lt;code&gt;ActiveRecord&lt;/code&gt; does not seem to cache raw SQL queries. So we could replace the call to the 'first' method of the model with something similar to the following.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;sql = "select * from table_name limit 1"&lt;br /&gt;
ActiveRecord::Base.connection.execute sql&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Although we can get the job done by this approach, it is bad practice to execute raw SQL.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Approach 4&lt;/b&gt;&lt;br /&gt;
Finally, we found a way of doing it through Rails. We need to explicitly tell Rails not to serve our queries from its cache for #1 and #3. This can be done as follows.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;Model.uncached do&lt;br /&gt;
&amp;nbsp; &amp;nbsp; Model.first&lt;br /&gt;
end&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
As this method does the job using the Rails framework, the abstraction all provided by ActiveRecord remains unbroken.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/SQFFJi61sFY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/9085040607085445272/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=9085040607085445272" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/9085040607085445272?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/9085040607085445272?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/SQFFJi61sFY/bypassing-activerecord-cache.html" title="Bypassing ActiveRecord cache" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/03/bypassing-activerecord-cache.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0MNRXk4eyp7ImA9WhBQEks.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-8570313152617434567</id><published>2013-03-14T19:28:00.000+05:30</published><updated>2013-03-14T19:28:14.733+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-14T19:28:14.733+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="rubymine" /><category scheme="http://www.blogger.com/atom/ns#" term="java" /><category scheme="http://www.blogger.com/atom/ns#" term="jetbrains" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><title>Memory snapshot in Jetbrains RubyMine on linux</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
I use &lt;a href="http://www.jetbrains.com/ruby/" rel="nofollow" target="_blank"&gt;RubyMine&lt;/a&gt; on linux for Ruby on Rails development. Of late, it had been hanging up frequently. I reported this to &lt;a href="http://www.jetbrains.com/" target="_blank"&gt;Jetbrains&lt;/a&gt;. They got back to me asking me to provide more details so that the concerned developer can try and find more details about the issue. On a side note, their customer support was so fast in responding, I was amazed. Also, the guy responding back was pretty technical himself.&lt;br /&gt;
&lt;br /&gt;
Getting back to the topic, they had asked me to provide a memory snapshot. The process of generating a memory snapshot is described &lt;a href="http://devnet.jetbrains.com/docs/DOC-1144" target="_blank"&gt;here&lt;/a&gt;. However, that process requires users to download YourKit Java Profiler, which apart from being a large download, comes with a 15-day license. To me it did not make sense. So, I got back to them about it and it turns out on linux, you don't really need it. The linux version of RubyMine, comes with the profiler libraries bundled.&lt;br /&gt;
&lt;br /&gt;
&lt;!--StartFragment--&gt;&lt;code&gt;$RUBYMINE_HOME/bin/libyjpagent-linux.so&lt;/code&gt;&lt;!--EndFragment--&gt;&lt;br /&gt;
&lt;code&gt;$RUBYMINE_HOME/bin/libyjpagent-linux64.so&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
To enable its usage all you need to do is, edit the following script and set&amp;nbsp;&lt;code&gt;IS_EAP&lt;/code&gt; to "&lt;code&gt;true&lt;/code&gt;".&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;$RUBYMINE_HOME/bin/rubymine.sh&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Restarting RubyMine after that change, will show the memory and CPU snapshot icons. It is also advised to provide thread dumps, as described &lt;a href="http://devnet.jetbrains.com/docs/DOC-260" target="_blank"&gt;here&lt;/a&gt;, along with the memory snapshot.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/MNgDhPGIbDg" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/8570313152617434567/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=8570313152617434567" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/8570313152617434567?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/8570313152617434567?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/MNgDhPGIbDg/memory-snapshot-in-jetbrains-rubymine.html" title="Memory snapshot in Jetbrains RubyMine on linux" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/03/memory-snapshot-in-jetbrains-rubymine.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DU4BRno6eyp7ImA9WhBRFk0.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-6221351568373643247</id><published>2013-03-07T03:42:00.001+05:30</published><updated>2013-03-07T03:42:37.413+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-03-07T03:42:37.413+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="systemd" /><category scheme="http://www.blogger.com/atom/ns#" term="arch" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="irc" /><category scheme="http://www.blogger.com/atom/ns#" term="journalctl" /><title>Extracting logs out of journalctl</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;a href="http://www.freedesktop.org/software/systemd/man/journalctl.html" target="_blank"&gt;Journalctl&lt;/a&gt; gives us nice consolidated logs. However, on a number of&amp;nbsp;occasions,&amp;nbsp;we need to extract parts of the logs. There are multiple ways of doing it. To filter by process, you can use PID numbers as shown below.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;journalctl _PID=&amp;lt;pid number&amp;gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
To obtain PID number when you have the process name [or part of the process name], use the following:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;ps aux | grep -i &amp;lt;process name&amp;gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
The manual page only refers to it in examples. A commonly used slicing option is to see logs of current boot only. This can be done as follows.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;journalctl -b&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Another option is to look at logs of a particular unit only. This can be done in the following way.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;journalctl -u &amp;lt;unit name&amp;gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
The unit name could be some daemon name like '&lt;code&gt;mysqld&lt;/code&gt;'. Unfortunately, this does not work with '&lt;code&gt;kernel&lt;/code&gt;' as a unit. It can be combined with the &lt;code&gt;-b&lt;/code&gt; option though. However, I find myself dealing with messages from various units. So, I scan through all messages and find the messages I need. To filter them out, I can use time stamps in the messages using the following format.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;journalctl --since='2013-03-06 22:58:34' --until='2013-03-06 23:00:34'&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
The beginning time stamp works fine; but the ending time stamp does not work. I talked about it at #systemd IRC channel. It is fixed and will be released soon.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/8UtZfl0cOes" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/6221351568373643247/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=6221351568373643247" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/6221351568373643247?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/6221351568373643247?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/8UtZfl0cOes/journalctl-logs.html" title="Extracting logs out of journalctl" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/03/journalctl-logs.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DEAMQHk8fCp7ImA9WhBSFUs.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-6332893021466641577</id><published>2013-02-23T02:29:00.003+05:30</published><updated>2013-02-23T02:29:41.774+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-02-23T02:29:41.774+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="arch" /><category scheme="http://www.blogger.com/atom/ns#" term="ftp" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="fedora" /><category scheme="http://www.blogger.com/atom/ns#" term="aws" /><title>Setting up an FTP server on AWS</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Recently for testing some code, I had to host an FTP server. I tried doing it on my local first. It was easy. I just had to follow the &lt;a href="https://wiki.archlinux.org/index.php/Very_Secure_FTP_Daemon" target="_blank"&gt;Arch wiki&lt;/a&gt; for &lt;a href="https://security.appspot.com/vsftpd.html" target="_blank"&gt;vsftpd&lt;/a&gt;. File transfers in both directions were working so I thought I can try it on an Amazon instance too.&lt;br /&gt;
&lt;br /&gt;
My local machine ran Arch linux on while the Amazon instance ran Fedora 8. After looking up the details of the package manager for Fedora and some help from a &lt;a href="http://narenonit.blogspot.in/" rel="nofollow" target="_blank"&gt;friend&lt;/a&gt;, I installed vsftpd on it, applied the same config and started the FTP service. When we started testing it, we could operate successfully from command line but not from the code. From the command line, we were using active mode of operation while the code was using the passive mode, so we looked into the config to check settings related to passive mode of operation. It turned out that the passive mode is enabled by default. However, going through the various options we found an option called &lt;code&gt;pasv_address&lt;/code&gt;. From prior experience I know that AWS machines have a private LAN IP and a separate public IP. Now, the OS on the cloud instance is not aware of what public IP it is serving. So, we suspected that in its response it must be asking the client to connect on the private LAN IP which would obviously fail. So we just set the&amp;nbsp;&lt;span style="font-family: monospace;"&gt;pasv_address&amp;nbsp;&lt;/span&gt;option to the public IP of the instance and passive mode started working fine. We could successfully connect to it and get file transfers done. So, we decided to use it for testing our code. However, when we tested it, we saw that our application was trying to post files but it was failing every time. The error we were getting each time said '&lt;code&gt;500: Invalid Port command&lt;/code&gt;'.&lt;br /&gt;
&lt;br /&gt;
The FTP protocol really goes funky with ports. It uses separate ports for control and data. The behaviour of data ports is dependent upon the mode of operation. In active mode, the client initiates the data connection and therefore the port selection is done by the client, while in passive mode, the server initiates the data connection and therefore the port selection is done by the server. We were using the passive mode of operation and the server was hitting the client at a port that later turned out to be blocked. To debug the situation, we tried connecting to the FTP server from the command line utility '&lt;code&gt;ftp&lt;/code&gt;' using the following command.&lt;br /&gt;
&lt;br /&gt;
ftp &lt;code&gt;ip address of FTP server&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
To turn on the passive mode and debug mode, we can use the commands '&lt;code&gt;passive&lt;/code&gt;' and '&lt;code&gt;debug&lt;/code&gt;' respectively. However, they only set the options on the client without actually sending any control data to the server. To test the FTP service, try some command that sends some control data. We went with an 'ls'. The following FTP commands were executed in sequence.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;PASV&lt;br /&gt;
LIST&lt;/code&gt;
&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;&lt;/code&gt;
The &lt;code&gt;PASV&lt;/code&gt; commands [1] outputs a line, like the following, indicating the port the data transfer will happen.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;Entering Passive Mode (1,2,3,4,224,186)&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
The port has to be calculated from the last two numbers using the following &lt;a href="http://support.microsoft.com/kb/281193" target="_blank"&gt;formula&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;n1 x 256 + n2&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
In the above instance, it is 224 x 256 + 186 = 57530. Once we knew that the issue was the port that the FTP server was trying to communicate to the application machine on was blocked, we decided to configure the FTP server to connect on some port within the open port range. This can be done setting the&amp;nbsp;&lt;span style="background-color: white; color: #333333; line-height: 24px;"&gt;&lt;code&gt;pasv_min_port&lt;/code&gt; and&amp;nbsp;&lt;/span&gt;&lt;span style="background-color: white; color: #333333; line-height: 24px;"&gt;&lt;code&gt;pasv_max_port&lt;/code&gt; options correctly in vsftpd.conf. Once we got the server connect to the client on proper ports, the transfers worked fine.&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
[1] A &lt;a href="http://www.networksorcery.com/enp/protocol/ftp.htm" target="_blank"&gt;reference&lt;/a&gt; of FTP commands.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/4VvDhjSvUa8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/6332893021466641577/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=6332893021466641577" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/6332893021466641577?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/6332893021466641577?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/4VvDhjSvUa8/setting-up-ftp-server-on-aws.html" title="Setting up an FTP server on AWS" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/02/setting-up-ftp-server-on-aws.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D04GQH46fip7ImA9WhBSFEU.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-3585118582158552023</id><published>2013-02-22T04:02:00.000+05:30</published><updated>2013-02-22T04:02:01.016+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-02-22T04:02:01.016+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="systemd" /><category scheme="http://www.blogger.com/atom/ns#" term="ftp" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="syslog" /><title>Getting to know the Syslog protocol</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Recently I was looking into FTP issues, when I learnt some details about &lt;a href="http://en.wikipedia.org/wiki/Syslog" target="_blank"&gt;Syslog&lt;/a&gt;. I was using &lt;a href="https://security.appspot.com/vsftpd.html" target="_blank"&gt;vsftpd&lt;/a&gt; for hosting an FTP service. I had enabled logging but I was not seeing anything in &lt;a href="http://www.freedesktop.org/software/systemd/man/journalctl.html" target="_blank"&gt;journalctl&lt;/a&gt; output. The reason for that turned out to be a configuration flaw. I had not turned on the option for vsftpd to use syslog. Once I turned the option on, proper log files were created.&lt;br /&gt;
&lt;br /&gt;
I do not have &lt;a href="http://en.wikipedia.org/wiki/Syslog-ng" target="_blank"&gt;Syslog-ng&lt;/a&gt; or any other syslog package installed. I had uninstalled it when I switched to &lt;a href="http://www.freedesktop.org/wiki/Software/systemd" target="_blank"&gt;systemd&lt;/a&gt;. So, I had not enabled that option in vsftpd. However, as it turns out when I turn that option on vsftpd uses the syslog protocol for logging. Systemd listens for messages sent using that protocol and creates appropriate logs.&lt;br /&gt;
&lt;br /&gt;
This is a great way of unifying all logging. Individual packages do not have to bother about logging. They just act as clients of the protocol and the listener will take care of maintaining the logs. There are instances of similar architecture being followed for logging in other domains too.&lt;br /&gt;
&lt;br /&gt;
As it turns out, there are&amp;nbsp;standardized&amp;nbsp;versions of the syslog protocol:&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;a href="http://tools.ietf.org/html/rfc5424" target="_blank"&gt;Syslog protocol&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://tools.ietf.org/html/rfc3164" target="_blank"&gt;BSD Syslog protocol&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;br /&gt;
The version used commonly is the BSD one even the former is more advanced. Now syslog is being replaced by systemd's journal because it capitalizes over syslog. It provides efficient transfer of binary data and supports JSON. Maintaining logs is much easier.&lt;br /&gt;
&lt;br /&gt;
It was interesting to know that even though syslog packages are becoming obsolete, the syslog protocol is still the logging standard. It is actually a nice example of robust architecture surviving over the years.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/MiKR5g2yRKs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/3585118582158552023/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=3585118582158552023" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/3585118582158552023?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/3585118582158552023?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/MiKR5g2yRKs/getting-to-know-syslog-protocol.html" title="Getting to know the Syslog protocol" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/02/getting-to-know-syslog-protocol.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D08ARHw9fSp7ImA9WhBWGUk.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-1282118351152533344</id><published>2013-01-08T21:19:00.002+05:30</published><updated>2013-04-14T18:54:05.265+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2013-04-14T18:54:05.265+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="grep" /><title>Kill all zombie processes of a process</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Time and again I have found phpmyadmin not working because there are a lot of zombies of httpd. I do not know yet why these many instances of the daemon show up and why they turn into unresponsive zombie processes. Usually when this happens, I just kill all the zombies and spawn a new daemon and I carry on with my work. I used to kill all the zombies one at a time. However, today I figured out that I can do it with a single line.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;ps aux | grep http | awk -F " " '{print $2}' | xargs kill -9&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
[If the working is clear to you, do read further and let me know if I can improve it or if I am interpreting anything incorrectly although things are somehow working.]&lt;br /&gt;
&lt;br /&gt;
The one-liner above is easy to understand once we have understand the pieces. So, I am listing that below.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li&gt;&lt;span style="font-family: monospace;"&gt;ps aux&lt;/span&gt;&amp;nbsp;lists all running processes&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: monospace;"&gt;grep http&lt;/span&gt;&amp;nbsp;finds the lines containing the string 'http'&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: monospace;"&gt;awk -F " " '{print $2}'&amp;nbsp;&lt;/span&gt;splits each input line by delimiter specified with -F flag, space in this case and prints the second token thus obtained&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: monospace;"&gt;kill -9&amp;nbsp;&lt;/span&gt;send &lt;a href="http://www.gnu.org/software/libc/manual/html_node/Termination-Signals.html" target="_blank"&gt;SIGKILL&lt;/a&gt; signal to the processes whose ids are specified as arguments&lt;/li&gt;
&lt;li&gt;&lt;span style="font-family: monospace;"&gt;xargs&lt;/span&gt;&amp;nbsp;takes output of previous command and makes it input for the next&lt;/li&gt;
&lt;/ul&gt;
&lt;div&gt;
You should probably have a look at the man pages for more details on the commands.&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/gSArA7tFZFE" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/1282118351152533344/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=1282118351152533344" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/1282118351152533344?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/1282118351152533344?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/gSArA7tFZFE/kill-all-zombie-processes-of-process.html" title="Kill all zombie processes of a process" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2013/01/kill-all-zombie-processes-of-process.html</feedburner:origLink></entry><entry gd:etag="W/&quot;Ak8MR3oyfCp7ImA9WhNVFk0.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-7991237546090511860</id><published>2012-12-26T03:00:00.001+05:30</published><updated>2012-12-27T17:18:06.494+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-27T17:18:06.494+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="java" /><category scheme="http://www.blogger.com/atom/ns#" term="django" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="software" /><category scheme="http://www.blogger.com/atom/ns#" term="python" /><title>Rails is re-inventing the wheel</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div style="text-align: justify;"&gt;
In recent years, there has been a surge in web applications. To support the growing market, frameworks have developed around scripting languages for developing web applications fast. Of those &lt;a href="http://rubyonrails.org/" target="_blank"&gt;Ruby on Rails&lt;/a&gt; seems to be the most mature. &lt;a href="https://www.djangoproject.com/" target="_blank"&gt;Django&lt;/a&gt;, the most advanced Python framework for web applications is yet to come at par with it.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
Be it Django or Ruby on Rails, both follow a model-view-controller architecture to web applications. Now, many web applications using these frameworks follow 'skinny controllers, fat models'. As a result the models become home to a lot of business logic. Models are intended to serve only as an abstraction to the database. They are meant to be 'models of data'. Also, when the application grows huge, we run into issues of scalability and we resort to techniques like &lt;a href="http://en.wikipedia.org/wiki/Shard_(database_architecture)" rel="nofollow" target="_blank"&gt;sharding&lt;/a&gt;. Now, there are of course multiple ways of sharding and you need to decide what suits you better. Here, I list a few ways for Rails applications.&lt;/div&gt;
&lt;ul style="text-align: left;"&gt;
&lt;li style="text-align: justify;"&gt;&lt;a href="https://github.com/mperham/data_fabric" target="_blank"&gt;data_fabric&lt;/a&gt;&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;&lt;a href="http://stjhimy.com/posts/19-gem-review-octopus-database-sharding-for-activerecord" target="_blank"&gt;octopus&lt;/a&gt;&lt;/li&gt;
&lt;li style="text-align: justify;"&gt;&lt;a href="http://spockproxy.sourceforge.net/" target="_blank"&gt;Spock proxy&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="text-align: justify;"&gt;
Now, sometimes the sharding logic also creeps into the models. Obviously objects of model classes do not have a single purpose any more. Over time, the model classes obviously become too complicated. It becomes difficult to maintain and debug. The Rails community is becoming increasingly aware of these issues. There are multiple ways in which developers are trying to move business logic away from models. Here I list of couple of those ways.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;/div&gt;
&lt;ul&gt;
&lt;li&gt;&lt;a href="http://grantammons.me/architecture/2012/12/22/where-the-logic-hides/" target="_blank"&gt;use cases&lt;/a&gt;&lt;/li&gt;
&lt;li&gt;&lt;a href="http://blog.waxman.me/extending-your-models-in-rails-3" target="_blank"&gt;concerns&lt;/a&gt;&lt;/li&gt;
&lt;/ul&gt;
&lt;div style="text-align: justify;"&gt;
Looking at the overall scenario reminds me of building N-tier applications using Java Enterprise Edition. The sharding logic and details of data fetching can be a tier below models and the business logic can be a tier above it. ' seems to me developers using web frameworks like Django and Rails are just re-inventing the wheel. Also, Java has optimized garbage collection which can be tuned to various needs. In Ruby garbage collection seems to be a big &lt;a href="http://patshaughnessy.net/2012/3/23/why-you-should-be-excited-about-garbage-collection-in-ruby-2-0" target="_blank"&gt;issue&lt;/a&gt;, though good work in the area is coming in the next version.&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style="text-align: justify;"&gt;
So much in the name of innovation, eh? In case my ideas seem to waver from reality do point me in the right direction.&lt;br /&gt;
&lt;br /&gt;
Update: You can follow the discussion on &lt;a href="http://news.ycombinator.com/item?id=4967175" rel="nofollow" target="_blank"&gt;Hacker News&lt;/a&gt; on the topic.&lt;/div&gt;
&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/-yFplNpVtKs" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/7991237546090511860/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=7991237546090511860" title="1 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/7991237546090511860?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/7991237546090511860?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/-yFplNpVtKs/rails-in-re-inventing-wheel.html" title="Rails is re-inventing the wheel" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>1</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2012/12/rails-in-re-inventing-wheel.html</feedburner:origLink></entry><entry gd:etag="W/&quot;AkMCQX4-eyp7ImA9WhNVE0g.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-8274271668818853766</id><published>2012-12-24T19:44:00.001+05:30</published><updated>2012-12-24T19:44:20.053+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-24T19:44:20.053+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="ruby" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><title>Rails time formats</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
During programming, I do tend to forget the various &lt;a href="http://www.wetware.co.nz/2009/07/rails-date-formats-strftime/" target="_blank"&gt;time formats&lt;/a&gt; available in Rails. Also, there are so many options available that a simple typo like capitalizing (or not) changes meaning. It is best that this part be always tested properly.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/QxTCBbRmIP0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/8274271668818853766/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=8274271668818853766" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/8274271668818853766?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/8274271668818853766?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/QxTCBbRmIP0/rails-time-formats.html" title="Rails time formats" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2012/12/rails-time-formats.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0ACSX05fip7ImA9WhNWF0s.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-8720944921395533388</id><published>2012-12-16T02:22:00.000+05:30</published><updated>2012-12-17T23:06:08.326+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-17T23:06:08.326+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="KDE" /><category scheme="http://www.blogger.com/atom/ns#" term="arch" /><category scheme="http://www.blogger.com/atom/ns#" term="dell" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="apple" /><title>Apple Magic Mouse with Dell Latitude E6520</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Recently, I found some free time at office and my colleague's Apple magic mouse was lying on my table. It sure is a cool device. So, I thought why not connect it to linux and see how it works. So, I turned on the bluetooth daemon on my system with the following command.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;systemctl start bluetooth&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
I use &lt;a href="http://userbase.kde.org/Bluedevil" target="_blank"&gt;Bluedevil&lt;/a&gt;. So, I clicked on the tray icon and ran a scan for bluetooth devices in range. The pairing key required is 0000. Initially the mouse pointer movement was too fast and scroll was too slow. So, I changed the configuration using &lt;a href="http://blog.matws.net/post/2010/10/16/Correct-magic-mouse-scrolling-on-Linux" target="_blank"&gt;this blog&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
It is cool, indeed. However, I found it difficult for regular use because I am not used to it and it is a touch mouse unlike other mice. When I am moving the mouse, I have to make sure my index finger is not touching the surface, else there is unwanted scrolling.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/krOxU2IVUK0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/8720944921395533388/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=8720944921395533388" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/8720944921395533388?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/8720944921395533388?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/krOxU2IVUK0/apple-magic-mouse-with-dell-latitude.html" title="Apple Magic Mouse with Dell Latitude E6520" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2012/12/apple-magic-mouse-with-dell-latitude.html</feedburner:origLink></entry><entry gd:etag="W/&quot;CUYDQ3Y8eCp7ImA9WhNWFkw.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-4936574867033401051</id><published>2012-12-14T00:11:00.000+05:30</published><updated>2012-12-16T04:42:52.870+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-12-16T04:42:52.870+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="pleasure" /><title>Enjoying writing</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Recently while waiting for a flight at Mumbai domestic airport, I decided to write down my thoughts. Of late, I have been writing on some keyboard mostly but this time I was writing with a pen and I actually enjoyed doing it. So, I write &amp;nbsp;about writing only. This is what I wrote:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;Is it possible to write with this pen?&lt;br /&gt;
Well not completely impossible. Also I realize the benefit of writing with a thick pen. With a thick pen, you tend to write each letter well while with a thin pen, you write a letter away [especially the letters towards the end of word]. [It] Reminds me of a friend who recently advised me to try a thick pen and I have to admit I am really loving this experience. At school, I hated writing with a thick pen because it slowed me down. However, now that its not my writing speed by my writing that I care about, I think I will use this thick pen more often.&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Compared typing on a keyboard, while penning down the flow of thoughts was better. I liked it and decided to do it more often.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/-kRxx1h4stU" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/4936574867033401051/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=4936574867033401051" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/4936574867033401051?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/4936574867033401051?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/-kRxx1h4stU/enjoying-writing.html" title="Enjoying writing" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2012/12/enjoying-writing.html</feedburner:origLink></entry><entry gd:etag="W/&quot;DkMBQXY_eCp7ImA9WhNQEEw.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-2898804478934389713</id><published>2012-11-16T02:50:00.001+05:30</published><updated>2012-11-16T02:50:50.840+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-16T02:50:50.840+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="utf-8" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="rails" /><category scheme="http://www.blogger.com/atom/ns#" term="ascii" /><title>UTF-8 encoded Rails Console in linux</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Although, initially while working on Rails project, we do not pay much attention to the character encoding, soon it bites us bad. When we try to play with a string containing Unicode characters in an ASCII encoded Rails console, it complains about it and we are stuck.&lt;br /&gt;
&lt;br /&gt;
It is quite easy to get a UTF-8 encoded Rails console. All we need to do is properly set the LANG environment variable of the terminal first.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;export LANG=en_US.UTF-8&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Rails picks up this variable and sets its encoding. So, when we fire up Rails console now and enter the following command, it shows that we have UTF-8 encoded console.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;puts __ENCODING__&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Now,&amp;nbsp;we can easily play with UTF-8 strings.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/Zg1eDRS3BtY" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/2898804478934389713/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=2898804478934389713" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/2898804478934389713?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/2898804478934389713?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/Zg1eDRS3BtY/utf-8-encoded-rails-console-in-linux.html" title="UTF-8 encoded Rails Console in linux" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2012/11/utf-8-encoded-rails-console-in-linux.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0cGRnc7eyp7ImA9WhNSGUU.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-4022225352285747367</id><published>2012-11-04T04:53:00.000+05:30</published><updated>2012-11-04T04:53:47.903+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-11-04T04:53:47.903+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="dns" /><category scheme="http://www.blogger.com/atom/ns#" term="skype" /><category scheme="http://www.blogger.com/atom/ns#" term="linux" /><category scheme="http://www.blogger.com/atom/ns#" term="Microsoft" /><title>Skype uses its own DNS</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Skype is a really interesting software. Its text chat UI is mature and audio and video chat facility are very nice. Skype has this interesting ability of working &lt;a href="http://unix.stackexchange.com/questions/21840/skype-connects-to-the-internet-but-all-my-web-browsers-cant-on-fedora-15" rel="nofollow" target="_blank"&gt;independent of the DNS configuration of your system&lt;/a&gt;. Even when the DNS server your system is configured for, gets &lt;a href="http://intosimple.blogspot.com/2010/09/bsnl-dns-server-poisoned.html" target="_blank"&gt;poisoned&lt;/a&gt;, Skype does not get affected.&lt;br /&gt;
&lt;br /&gt;
In fact, I leverage this ability of Skype to detect network issues due to DNS service being down. On such an occasion, when the browsers were not working but Skype was, I pointed my DNS configuration to Google's DNS servers (listed below) and the browsers worked fine.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;8.8.8.8&lt;br /&gt;
8.8.4.4&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
To take a deeper look, I tracked the connections Skype was making. I used the following to do that.&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;netstat -taucp | grep skype&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Initially it was sending out packets from port&amp;nbsp;51395 of my localhost. After I logged in, I find the following connections:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="overflow: auto; white-space: nowrap;"&gt;
&lt;code&gt;tcp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 *:42520 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LISTEN &amp;nbsp; &amp;nbsp; &amp;nbsp;19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
tcp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 H:47078 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;111.221.77.159:40016 &amp;nbsp; &amp;nbsp;SYN_SENT &amp;nbsp; &amp;nbsp;19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
udp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 *:42520 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
udp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 localhost:51395 *:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19207/skype&lt;br /&gt;
&lt;/code&gt;&lt;/div&gt;
&lt;br /&gt;
H about is the hostname of my system and the IP&amp;nbsp;111.221.77.159 is owned by Microsoft, Microsoft Singapore to be specific. Interesting sequence of connections, when I lookup a contact and open the corresponding chat window.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="overflow: auto; white-space: nowrap;"&gt;
&lt;code&gt;tcp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 *:42520 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LISTEN &amp;nbsp; &amp;nbsp; &amp;nbsp;19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
tcp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp;516 H:46808 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;193.95.154.39:33033 &amp;nbsp; &amp;nbsp; ESTABLISHED 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
tcp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 H:47078 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;111.221.77.159:40016 &amp;nbsp; &amp;nbsp;ESTABLISHED 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
udp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 *:33626 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
udp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 *:41980 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
udp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 *:42520 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
udp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 localhost:51395 *:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
udp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 H:32897 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19207/skype&lt;br /&gt;
&lt;/code&gt;&lt;/div&gt;
&lt;br /&gt;
The IP&amp;nbsp;193.95.154.39 maps to Skype Technologies. After sending a line of text on &amp;nbsp;the chat window, the following connections were made.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="overflow: auto; white-space: nowrap;"&gt;
&lt;code&gt;tcp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 *:42520 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LISTEN &amp;nbsp; &amp;nbsp; &amp;nbsp;19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
tcp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 H:46808 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;193.95.154.39:33033 &amp;nbsp; &amp;nbsp; ESTABLISHED 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
tcp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 H:47078 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;111.221.77.159:40016 &amp;nbsp; &amp;nbsp;ESTABLISHED 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
tcp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp;236 H:44172 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;157.56.123.82:https &amp;nbsp; &amp;nbsp; ESTABLISHED 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
tcp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;1 H:45020 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;91.190.216.9:www-http &amp;nbsp; SYN_SENT &amp;nbsp; &amp;nbsp;19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
tcp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; 75 H:48246 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;78.141.179.14:12350 &amp;nbsp; &amp;nbsp; ESTABLISHED 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
udp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 *:33626 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
udp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 *:42520 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
udp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 localhost:51395 *:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
udp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 H:32897 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;*:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19207/skype&lt;br /&gt;
&lt;/code&gt;&lt;/div&gt;
&lt;br /&gt;
The IPs&amp;nbsp;157.56.123.82,&amp;nbsp;91.190.216.9,&amp;nbsp;78.141.179.14 map to Microsoft Corp Redmond, Skype and&amp;nbsp;Entreprise des Postes et Telecommunications respectively. After that, when I was not doing any more activity on Skype, the following network activity was seen.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;div style="overflow: auto; white-space: nowrap;"&gt;
&lt;code&gt;tcp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 *:42520 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; LISTEN &amp;nbsp; &amp;nbsp; &amp;nbsp;19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
tcp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 H:47078 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;111.221.77.159:40016 &amp;nbsp; &amp;nbsp;ESTABLISHED 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
tcp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 H:47362 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;db3msgr6011307.ga:https ESTABLISHED 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
tcp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 H:48246 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;78.141.179.14:12350 &amp;nbsp; &amp;nbsp; ESTABLISHED 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
udp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 *:42520 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; *:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19207/skype &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
udp &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;0 &amp;nbsp; &amp;nbsp; &amp;nbsp;0 localhost.localdo:51395 *:* &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; 19207/skype&lt;br /&gt;
&lt;/code&gt;&lt;/div&gt;
&lt;br /&gt;
db3msgr6011307.ga does not have any DNS entries. Suggestions for digging further are welcome.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/jBkJ2mPjDa8" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/4022225352285747367/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=4022225352285747367" title="2 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/4022225352285747367?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/4022225352285747367?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/jBkJ2mPjDa8/skype-uses-its-own-dns.html" title="Skype uses its own DNS" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>2</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2012/11/skype-uses-its-own-dns.html</feedburner:origLink></entry><entry gd:etag="W/&quot;A0QBSXc-fip7ImA9WhJaFEs.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-4984515528363024474</id><published>2012-10-06T02:05:00.001+05:30</published><updated>2012-10-06T02:05:58.956+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-10-06T02:05:58.956+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="emacs" /><category scheme="http://www.blogger.com/atom/ns#" term="sed" /><title>Formatting column entries for IN query</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
Extracting entries of a column in a spreadsheet and using them in an IN query is not a rare scenario [at least for me] at work. Now, copying and pasting the entries in a comma separated and sometimes quote-enclosed format is tedious and when there are 100 entries, doing that by hand is unacceptable for me. On top of that when each entry has to be modified a bit before passing in the IN query, then the whole process becomes drudgery. Today, when faced with such a situation, I used emacs and sed to save myself a lot of time and boredom.&lt;br /&gt;
&lt;br /&gt;
Let us consider that the spreadsheet has a column that has the following entries:&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;12345-1&lt;br /&gt;
23456-2&lt;br /&gt;
34567-1&lt;br /&gt;
45678-1&lt;br /&gt;
56789-1&lt;/code&gt;
&lt;br /&gt;
Now, lets consider that I have to strip the first suffix, enclose the values in quotes and pass them in the IN query. So, I copy the column and paste in a text file and run the following commands on the file.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;sed -i 's/-1//' ./myfile.txt&lt;/code&gt;&lt;br /&gt;
&lt;div&gt;
&lt;div&gt;
&lt;code&gt;sed -i 's/-2//' ./myfile.txt&lt;/code&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now the file had the following contents.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;code&gt;12345&lt;br /&gt;
23456&lt;br /&gt;
34567&lt;br /&gt;
45678&lt;br /&gt;
56789&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now, I opened the file in emacs and ran a &lt;a href="http://emacswiki.org/emacs/KeyboardMacros" target="_blank"&gt;keyboard macro&lt;/a&gt; to get the following string.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;code&gt;'12345', '23456', '34567', '45678', '56789',&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now, I could easily use it in my query. Now, the macro I used was simple. I started recording the macro using &lt;code&gt;`C-x ('&lt;/code&gt;. The macro consisted of the following keys in sequence [try it yourself to be clear]:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;code&gt;'&lt;/code&gt; -&amp;gt; &lt;code&gt;End&lt;/code&gt; -&amp;gt; &lt;code&gt;'&lt;/code&gt; -&amp;gt; &lt;code&gt;,&lt;/code&gt; -&amp;gt; &lt;code&gt;Delete&lt;/code&gt; -&amp;gt; &lt;code&gt;Space&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I ended recording the macro using&amp;nbsp;&lt;code&gt;`C-x )'&lt;/code&gt;. Now, I had one line edited so I let emacs run the macro 4 times using the following command:&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;code&gt;C-u 4 C-x e&lt;/code&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
I got the inspiration for using macros in the following video.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;iframe allowfullscreen="allowfullscreen" frameborder="0" height="315" src="https://www.youtube-nocookie.com/embed/dE2haYu0co8" width="560"&gt;&lt;/iframe&gt;&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/pk3e7YAaWu0" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/4984515528363024474/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=4984515528363024474" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/4984515528363024474?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/4984515528363024474?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/pk3e7YAaWu0/formatting-column-entries-for-in-query.html" title="Formatting column entries for IN query" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2012/10/formatting-column-entries-for-in-query.html</feedburner:origLink></entry><entry gd:etag="W/&quot;D0EERXozeSp7ImA9WhJUFEU.&quot;"><id>tag:blogger.com,1999:blog-1600341619162257657.post-7762500122029513332</id><published>2012-09-13T03:02:00.000+05:30</published><updated>2012-09-13T03:03:24.481+05:30</updated><app:edited xmlns:app="http://www.w3.org/2007/app">2012-09-13T03:03:24.481+05:30</app:edited><category scheme="http://www.blogger.com/atom/ns#" term="rubymine" /><category scheme="http://www.blogger.com/atom/ns#" term="java" /><category scheme="http://www.blogger.com/atom/ns#" term="64-bit" /><title>JVM crash: an eye opener</title><content type="html">&lt;div dir="ltr" style="text-align: left;" trbidi="on"&gt;
I had done some programming but I guess I had not hit many walls. In C, my programs had segfaulted; but every time that happened I knew that my program broke; but there was never a notion of the programming environment breaking down. I, of course, know that when one is coding specifically to break the environment, it is not impossible; but I am talking about cases when the break is not intended. I could never imagine the shell, in which I am running a program for connecting to some website and getting some data, breaking down in between the running of the program.&lt;br /&gt;
&lt;br /&gt;
However, recently I was using Rubymine to test some XML parsers I had written and suddenly it crashed. Initially, I thought may be Rubymine crashed, so I went back to shell where I had started it. To my utter surprise, it was the JVM that had crashed. That is when it hit me that programming environments can also crash. I have reported the &lt;a href="http://bugs.sun.com/bugdatabase/view_bug.do?bug_id=7195011" target="_blank"&gt;bug&lt;/a&gt;; but there is not much done from Oracle's side about it.&lt;br /&gt;
&lt;br /&gt;
Well, I do not expect much from them either; but the lesson I learnt is valuable: it is not only the program; but also the program's environment that can crash. Its not that I did not know it but it is not something I regularly expected. From now on, I will though. It did change the way I looked at errors. I guess this is what counts as experience.&lt;/div&gt;
&lt;div class="blogger-post-footer"&gt;I would like to hear your suggestions and feedback.&lt;/div&gt;&lt;img src="http://feeds.feedburner.com/~r/DigDeeperIntoSimplicity/~4/19SmrqA6b6E" height="1" width="1"/&gt;</content><link rel="replies" type="application/atom+xml" href="http://intosimple.blogspot.com/feeds/7762500122029513332/comments/default" title="Post Comments" /><link rel="replies" type="text/html" href="http://www.blogger.com/comment.g?blogID=1600341619162257657&amp;postID=7762500122029513332" title="0 Comments" /><link rel="edit" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/7762500122029513332?v=2" /><link rel="self" type="application/atom+xml" href="http://www.blogger.com/feeds/1600341619162257657/posts/default/7762500122029513332?v=2" /><link rel="alternate" type="text/html" href="http://feedproxy.google.com/~r/DigDeeperIntoSimplicity/~3/19SmrqA6b6E/jvm-crash-eye-opener.html" title="JVM crash: an eye opener" /><author><name>Phoenix</name><uri>http://www.blogger.com/profile/18150624810921348256</uri><email>noreply@blogger.com</email><gd:image rel="http://schemas.google.com/g/2005#thumbnail" width="32" height="18" src="http://2.bp.blogspot.com/_jmVxCj-35E8/TFcpNZ_zWBI/AAAAAAAAAPU/5kdqb7ZpDcQ/S220/vlcsnap-2010-07-31-21h58m13s76.png" /></author><thr:total>0</thr:total><feedburner:origLink>http://intosimple.blogspot.com/2012/09/jvm-crash-eye-opener.html</feedburner:origLink></entry></feed>
