tag:blogger.com,1999:blog-178981122024-03-07T02:16:11.676-05:00malayamaaruthamMalayamarutham is a mellifluous raaga in carnatic music which will make one soft at heart. In telugu, malaya maarutham is a cool evening breeze which invigorates mind, body & heart.
<br>
<br>
Feedback, suggestions, criticisms, typos, mistakes, errors etc., (no matter how small you think they are) on the articles of this blog are very welcome. They can be directed to kamaraju at gmail dot com.Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.comBlogger131125tag:blogger.com,1999:blog-17898112.post-58135984386175862812014-12-07T21:33:00.002-05:002014-12-07T21:33:28.523-05:00first birth day of Hamsini<div dir="ltr" style="text-align: left;" trbidi="on">
Today, my daughter, Hamsini, successfully completed her first trip around the Sun. Many many happy returns of the day, Kushi!<br />
<br />
It has been an
awesome year with great memories. She is growing up so fast, ever
curious and all smiles, busy learning new tricks, playing with her
friends and toys, watching ads in the TV, listening to rhymes, helping
mom in the kitchen (:-))<br />
<br />
I can never forget how she lights up when I come back from
work, how excited she is to go out, how she wants to play pick-a-boo
with her mom while I am holding her in my arms. Just the other day she started walking, decided that crawling is not really her game and is now running merrily around. <br />
<br />
Raising an infant is hard, especially
in the US, because it is just the two of us who have to take care of
everything. But thanks to the dear wife, I had all the fun while she did
all the hard work. So, thanks and congratulations, Prasanthi!</div>
Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com1tag:blogger.com,1999:blog-17898112.post-83511997153518934652014-06-08T17:07:00.000-04:002014-06-10T07:09:28.917-04:00Setting up Canon Pixma MX870 printer on Debian Jessie<div dir="ltr" style="text-align: left;" trbidi="on">
Here are the steps I followed to set up my printer (Canon Pixma MX870) on a machine running Debian Jessie.<br />
<br />
Setup details:<br />
My printer is connected wirelessly to the router which in turn is connected to the internet. The desktop machine running Debian Jessie is connected to the same router via ethernet cable.<br />
<br />
1) Find out the IP address of the printer.<br />
<br />
<span style="-webkit-text-stroke-width: 0px; background-color: white; color: #222222; display: inline !important; float: none; font-family: arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;">root@hogwarts:~# arp-scan --interface=eth1 --localnet<br />Interface: eth1, datalink type: EN10MB (Ethernet)<br />Starting arp-scan 1.8.1 with 256 hosts (http://www.nta-monitor.com/tools/arp-scan/)<br />192.168.0.1 20:e5:64:57:f1:12 (Unknown)<br />192.168.0.4 e8:99:c4:4c:d0:26 (Unknown)<br />192.168.0.8 00:1e:8f:97:25:3d CANON INC.<br /><br />3 packets received by filter, 0 packets dropped by kernel<br />Ending arp-scan 1.8.1: 256 hosts scanned in 1.380 seconds (185.51 hosts/sec). 3 responded</span><br />
<span style="-webkit-text-stroke-width: 0px; background-color: white; color: #222222; display: inline !important; float: none; font-family: arial, sans-serif; font-size: 13px; font-style: normal; font-variant: normal; font-weight: normal; letter-spacing: normal; line-height: normal; orphans: auto; text-align: start; text-indent: 0px; text-transform: none; white-space: normal; widows: auto; word-spacing: 0px;"><br /></span>
This shows that the printer's IP address is 192.168.0.8<br />
<br />
2) Install and start the cups service<br />
<pre>apt-get update
apt-get install cups
/etc/init.d/cups start</pre>
I have the following packages installed but it is possible that not all of them are necessary.
<br />
<pre>root@hogwarts:~# dpkg -l cups\* | grep ^ii
ii cups 1.7.1-12 amd64 Common UNIX Printing System(tm) - PPD/driver support, web interface
ii cups-bsd 1.7.1-12 amd64 Common UNIX Printing System(tm) - BSD commands
ii cups-client 1.7.1-12 amd64 Common UNIX Printing System(tm) - client programs (SysV)
ii cups-common 1.7.1-12 all Common UNIX Printing System(tm) - common files
ii cups-core-drivers 1.7.1-12 amd64 Common UNIX Printing System(tm) - PPD-less printing
ii cups-daemon 1.7.1-12 amd64 Common UNIX Printing System(tm) - daemon
ii cups-filters 1.0.50-1 amd64 OpenPrinting CUPS Filters - Main Package
ii cups-filters-core-drivers 1.0.50-1 amd64 OpenPrinting CUPS Filters - PPD-less printing
ii cups-pdf 2.6.1-9 amd64 PDF writer backend for CUPS
ii cups-pk-helper 0.2.5-2 amd64 PolicyKit helper to configure cups with fine-grained privileges
ii cups-ppdc 1.7.1-12 amd64 Common UNIX Printing System(tm) - PPD manipulation utilities
ii cups-server-common 1.7.1-12 all Common UNIX Printing System(tm) - server common files</pre>
3) Add the printer<br />
Add a user to the lpadmin group. For example, this is what I have
<br />
<pre>rajulocal@hogwarts:~$ id
uid=1000(rajulocal) gid=1000(rajulocal) groups=1000(rajulocal),24(cdrom),25(floppy),
29(audio),30(dip),44(video),46(plugdev),104(scanner),107(bluetooth),
109(netdev),122(lpadmin)</pre>
Go to http://localhost:631/ in your local browser.<br />
Click on "Adding Printers and Classes"<br />
Click on "Add Printer"
<br />
<pre>For some reason, "Find New Printers" did not detect the printer.
So I used "Add Printer" to add the printer manually.
</pre>
<pre>If prompted, provide the user login and password details of
the account which you added to the lpadmin group.</pre>
In "Other Network Printers" section, select "<span style="background-color: white; color: black; display: inline ! important; float: none; font-family: 'lucida grande',geneva,helvetica,arial,sans-serif; font-size: small; font-style: normal; font-variant: normal; letter-spacing: normal; line-height: normal; text-align: right; text-indent: 0px; text-transform: none; white-space: normal; word-spacing: 0px;"></span>LPD/LPR Host or Printer" and click continue<br />
In the connection field, enter
<br />
<pre>lpd://192.168.0.8/queue</pre>
and hit continue. Replace 192.168.0.8 with your printer's IP address.<br />
In the next screen, provide a Name, Description and Location for the printer and hit continue. I have
<br />
<pre>Name: CanonPixmaMX870
Description: Canon Pixma MX870 Color Printer with Duplexer, scanner, fax
Location: Home</pre>
In the next screen, choose
<br />
<pre>Make = Canon
hit continue
Model = Canon PIXMA MX870 - Cups+Gutenprint v5.2.9 (en)</pre>
click "Add Printer"<br />
In the next screen, I have set 2-Sided Printing = Long Edge (Standard) and left all other options as-is. Click "Set Default Options" when finished.<br />
<br />
4) Test the printer setup <br />
Print a test file using lpr.<br />
<pre>rajulocal@hogwarts:~/x$ lpr -P CanonPixmaMX870 santhi.txt
</pre>
Useful links:<br />
<ul style="text-align: left;">
<li>https://wiki.debian.org/SystemPrinting </li>
<li>http://www.usa.canon.com/cusa/support/consumer/printers_multifunction/pixma_mx_series/pixma_mx870#DriversAndSoftware</li>
<li>https://lists.debian.org/debian-user/2014/06/msg00318.html </li>
</ul>
</div>
Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-50341936613271331082014-04-25T08:17:00.000-04:002014-04-25T08:17:05.476-04:00digital copy for passport size photos in New York City<div dir="ltr" style="text-align: left;" trbidi="on">
You can get passport size photos (in both print and digital form) for US and Canadian visas at<strong class="street-address">
</strong><br />
<address itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress">
<strong class="street-address">
<span itemprop="streetAddress"> </span></strong></address>
<address itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress">
<strong class="street-address"><span itemprop="streetAddress">Duane Reade </span></strong></address>
<address itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress">
<strong class="street-address"><span itemprop="streetAddress">1251 Avenue Of The Americas</span><br /><span itemprop="addressLocality">New York</span>, <span itemprop="addressRegion">NY</span> <span itemprop="postalCode">10020</span></strong></address>
<address itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress">
<strong class="street-address"><span itemprop="postalCode"><span style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px; line-height: 16.1200008392334px;"><br /></span></span></strong></address>
<address itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress">
<strong class="street-address"><span itemprop="postalCode"><span style="background-color: white; color: #222222; font-family: arial, sans-serif; font-size: 13px; line-height: 16.1200008392334px;">Ph: (212) 391-1105</span></span></strong></address>
<address itemprop="address" itemscope="" itemtype="http://schema.org/PostalAddress">
<strong class="street-address"><span itemprop="postalCode"> </span>
</strong></address>
<strong class="street-address">
</strong>
<span class="cross-streets">
between 49th St & 50th St + 6th ave</span><br />
<span class="cross-streets">located underground near the subway train station</span><br />
<br />
<span class="cross-streets">They give both paper copies and digital copy. Service is great.</span><br />
<span class="cross-streets"><br /></span>
<span class="cross-streets">I was charged $29.91 (including tax) to get 2 prints of US passport photos + 2 prints of Canada passport photos + digital copy of the images written on a CD.</span><br />
</div>
Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-23302181552989132222014-03-17T09:48:00.001-04:002014-03-17T09:48:58.366-04:00book read by Anton Roth in NBC crisis show<div dir="ltr" style="text-align: left;" trbidi="on">
Yesterday (2014-03-16), I watched this show called crisis on NBC ( http://en.wikipedia.org/wiki/Crisis_(TV_series) ) . In that the kid who played Anton Roth reads a book titled "Passage to Perseid". Has anyone ever heard of this book? I searched in google, amazon but could not find it anywhere. Here is a screenshot of what I am talking about<br />
<br />
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjM-bVLNfXbki7PlOYjjVMjAg916KeEmh2BsNYvPWe5bStgNSJnKzNp9aUqD3gPcjmSqttVduLU59Ar19E97FNDV9FNA4GzHFznIx1I8sBjIvw4pZDZO5HzLEuCzLqjz9cJLQrYpA/s1600/passage_to_perseid.png" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEjM-bVLNfXbki7PlOYjjVMjAg916KeEmh2BsNYvPWe5bStgNSJnKzNp9aUqD3gPcjmSqttVduLU59Ar19E97FNDV9FNA4GzHFznIx1I8sBjIvw4pZDZO5HzLEuCzLqjz9cJLQrYpA/s1600/passage_to_perseid.png" height="348" width="640" /></a></div>
<br /></div>
Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-3429640124633795262014-01-14T00:26:00.000-05:002014-01-14T00:26:31.489-05:00perl one liner to print quotes around each line<div dir="ltr" style="text-align: left;" trbidi="on">
Consider the sample input file<br />
<pre class="verbatim" xml:space="preserve">rajulocal@hogwarts:~/x$ cat input.txt
1.1,k
2.2,ka
3.3,kam
4.4,kama
5.5,kamar
6.6,kamara
7.7,kamaraj
8.8,kamaraju</pre>
To put quotes around each line, use the following Perl one liner<br />
<pre class="verbatim" xml:space="preserve">rajulocal@hogwarts:~/x$ perl -lane '$sq="\047"; print "$sq$_$sq";' input.txt
'1.1,k'
'2.2,ka'
'3.3,kam'
'4.4,kama'
'5.5,kamar'
'6.6,kamara'
'7.7,kamaraj'
'8.8,kamaraju'</pre>
Here we are using octal code of single quote. To put quotes around just one column, use<br />
<pre class="verbatim" xml:space="preserve">rajulocal@hogwarts:~/x$ perl -F',' -lane '$sq="\047"; print "$F[0],$sq$F[1]$sq";' input.txt
1.1,'k'
2.2,'ka'
3.3,'kam'
4.4,'kama'
5.5,'kamar'
6.6,'kamara'
7.7,'kamaraj'
8.8,'kamaraju'
</pre>
<br />
Related posts: <a href="http://malayamaarutham.blogspot.com/2012/05/consider-input-file-cat-input.html">awk remove quotes in a column</a></div>
Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-47218276730314568142013-12-24T20:22:00.000-05:002013-12-24T20:22:33.395-05:00cvs equivalent of "svn status"<div dir="ltr" style="text-align: left;" trbidi="on">
<div dir="ltr" style="text-align: left;" trbidi="on">
<span id="docs-internal-guid-25436bfd-2739-fc73-df9a-35c411c414c2"></span><br />
<div dir="ltr" style="margin-bottom: 0pt; margin-top: 0pt;">
<span style="font-family: Arial;"><span style="font-size: 15px; line-height: 17px; white-space: pre-wrap;">To get output similar to "svn status" while using cvs as the version control system, run</span></span></div>
<div>
<pre>=> cvs -n -q update
U file1
U file2
M file3
M file4
? file5
? file6
</pre>
<span style="font-family: Arial; font-size: 15px; line-height: 17px; white-space: pre-wrap;">This will display files modified upstream, files modified locally, files not tracked by cvs. The output is compact and similar to the output of "svn status".</span><br />
<span style="font-family: Arial; font-size: 15px; line-height: 17px; white-space: pre-wrap;"><br /></span>
<span style="font-family: Arial; font-size: 15px; line-height: 17px; white-space: pre-wrap;">Create an alias for this in the shell rc file</span><br />
<pre>=> grep cvst ~/.cshrc
alias cvst 'cvs -n -q update'</pre>
<span style="font-family: Arial; font-size: 15px; line-height: 17px; white-space: pre-wrap;">Other Alternatives:</span></div>
</div>
<pre>#!/bin/sh
#------------------------------------------------------------------------------
# Approach 1
# Initial version from : http://www.freshblurbs.com/blog/2009/02/08/cvs-status-one-svn-bash-script.html
# Problem: this will not display files not part of cvs.
patterns=(
'?'
'Locally Added'
'Locally Modified'
'Needs Patch'
)
for i in "${patterns[@]}"
do
cvs -Q status -R . | grep -i "$i"
done
#------------------------------------------------------------------------------
#------------------------------------------------------------------------------
# Approach 2
# Initial version from : http://www.dzone.com/snippets/doing-something-equivalent-svn
# Problem: this will not display files not part of cvs.
cvs status 2>&1 | egrep "(^\? |Status: )" | grep -v Up-to-date
#------------------------------------------------------------------------------
</pre>
<pre></pre>
</div>
Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-25421898312512891492013-09-17T00:07:00.001-04:002013-09-17T00:26:36.206-04:00file sizes of scanned images<div dir="ltr" style="text-align: left;" trbidi="on">
When I scanned a passport (roughly 40 pages == 20 scanned images) in color with 600 dpi, the file size produced by Canon Pixma MX870 is 58 Mb. The same document when scanned using Xerox WorkCentre 7765 with same settings (color, 600 dpi) produces a file size of 2.3 Mb. In terms of speed, Pixma was like a grandma while the WorkCentre is very fast.<br />
<br />
Up until now, I never fully appreciated the power of an industrial workhorse that costs around $34000 as opposed to a good personal inkjet printer ($130 on Amazon). Wow!</div>
Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-76491242212716409482013-07-09T07:58:00.000-04:002013-07-09T07:58:07.238-04:00setenv does not work from script<div dir="ltr" style="text-align: left;" trbidi="on">
<div style="text-align: left;">
<span id="docs-internal-guid-48ff2149-c264-d8e0-62cd-1e0d63d97b7b" style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">This post explains how to export a variable from a shell script to a tcsh parent shell.</span><br />
<span id="docs-internal-guid-48ff2149-c264-d8e0-62cd-1e0d63d97b7b" style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"> </span><br />
<span id="docs-internal-guid-48ff2149-c264-d8e0-62cd-1e0d63d97b7b" style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">consider the following script</span></div>
<blockquote class="tr_bq">
<div style="text-align: left;">
<span id="docs-internal-guid-48ff2149-c264-d8e0-62cd-1e0d63d97b7b" style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">hogwarts:~/x> cat setup_var.sh <br />#! /bin/tcsh -f<br /><br />setenv a RAJU<br />echo $a<br /> </span></div>
</blockquote>
<div style="text-align: left;">
<span id="docs-internal-guid-48ff2149-c264-d8e0-62cd-1e0d63d97b7b" style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">The executable bit is set on the script</span></div>
<blockquote class="tr_bq">
<div style="text-align: left;">
<span id="docs-internal-guid-48ff2149-c264-d8e0-62cd-1e0d63d97b7b" style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">hogwarts:~/x> chmod +x setup_var.sh <br />hogwarts:~/x> ls -al setup_var.sh <br />-rwxr-xr-x 1 rajulocal rajulocal 39 Jul 9 03:40 setup_var.sh</span><span id="docs-internal-guid-48ff2149-c264-d8e0-62cd-1e0d63d97b7b" style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;"> </span></div>
</blockquote>
<div style="text-align: left;">
<span id="docs-internal-guid-48ff2149-c264-d8e0-62cd-1e0d63d97b7b" style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">I am using the tcsh shell</span></div>
<blockquote class="tr_bq">
<div style="text-align: left;">
<span id="docs-internal-guid-48ff2149-c264-d8e0-62cd-1e0d63d97b7b" style="background-color: transparent; color: black; font-family: Arial; font-size: 15px; font-style: normal; font-variant: normal; font-weight: normal; text-decoration: none; vertical-align: baseline;">hogwarts:~/x> echo $0<br />
tcsh<br />
</span></div>
</blockquote>
<div style="text-align: left;">
When executed, it shows that the variable "a" is getting the correct value</div>
<blockquote class="tr_bq">
<div style="text-align: left;">
hogwarts:~/x> ./setup_var.sh <br />
RAJU</div>
</blockquote>
<div style="text-align: left;">
However, the variable is not exported to the parent shell even though setenv is used in the script.</div>
<blockquote class="tr_bq">
<div style="text-align: left;">
hogwarts:~/x> echo $a<br />
a: Undefined variable.</div>
</blockquote>
<div style="text-align: left;">
The solution is to "source the script" instead of "dot executing".</div>
<blockquote class="tr_bq">
<div style="text-align: left;">
hogwarts:~/x> source setup_var.sh <br />
RAJU<br />
hogwarts:~/x> echo $a<br />
RAJU</div>
</blockquote>
<div style="text-align: left;">
Voila! Now the variable "a" is exported to the parent shell.<br />
<br />
Happy shell script hacking...</div>
</div>
Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-61461932283218539372013-06-06T00:22:00.001-04:002013-06-07T13:06:40.315-04:00shell add multiple lines EOF<div dir="ltr" style="text-align: left;" trbidi="on">
To create a file with multiple lines from a shell script you can use the following recipe<br />
<blockquote class="tr_bq" style="text-align: left;">
rajulocal@hogwarts:~/work/tcsh$ cat add_multiple_lines_to_file.sh <br />
#! /bin/tcsh -fx<br />
<br />
mkdir -p ~/x<br />
cat << EOF > ~/x/junk1<br />
k<br />
am<br />
ara<br />
ju<br />
EOF</blockquote>
Run this script using<br />
<blockquote class="tr_bq">
rajulocal@hogwarts:~/work/tcsh$ ./add_multiple_lines_to_file.sh <br />
mkdir -p /home/rajulocal/x<br />
cat</blockquote>
The output will be stored in ~/x/junk1 <br />
<blockquote class="tr_bq">
rajulocal@hogwarts:~/work/tcsh$ cat ~/x/junk1 <br />
k<br />
am<br />
ara<br />
ju</blockquote>
For further information<br />
<ol style="text-align: left;">
<li> read the section on "Here-documents" in http://docstore.mik.ua/orelly/unix/ksh/ch07_01.htm</li>
<li>http://en.wikipedia.org/wiki/Here_document</li>
<li>search for "here document" in google</li>
</ol>
</div>
Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-27743255039083081422013-02-28T23:56:00.000-05:002014-09-21T16:49:39.470-04:00generate random numbers with a given correlation in matlab<div dir="ltr" style="text-align: left;" trbidi="on">
Q. How to generate random numbers with a pre specified correlation in Matlab?<br />
<br />
Ans. Use mvnrnd() function.This function takes mean (vector of 1xk), covariance (matrix of k x k), number of points (n). The output is an nxk matrix which corresponds to the multivariate normal distribution with the specified mean, covariance.<br />
<pre class="verbatim" xml:space="preserve">>> n=1000; mu=[-2,2]; sigma=[1 0.5; 0.5 1]; X = mvnrnd(mu, sigma, n);
>> size(X)
ans =
1000 2
>> mean(X)
ans =
-2.0350 2.0157
>> cov(X)
ans =
0.9950 0.4898
0.4898 0.9894
>> plot(X(:,1), X(:,2), '.')
>> grid
</pre>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCpULacAe_IvU8yfyxFDCQ70jcaGEu5wZEPnePiQMvQVBOLx9tGTv4RQa6jV0sqS3_rWb-naF7VzIpyDh0SK1jWCFg61ZHb9peUUgpKW34AdeufEcEg9f-VHzYAANednDR4ucyeA/s1600/mvnrnd_example.jpg" imageanchor="1" style="margin-left: 1em; margin-right: 1em;"><img border="0" src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEhCpULacAe_IvU8yfyxFDCQ70jcaGEu5wZEPnePiQMvQVBOLx9tGTv4RQa6jV0sqS3_rWb-naF7VzIpyDh0SK1jWCFg61ZHb9peUUgpKW34AdeufEcEg9f-VHzYAANednDR4ucyeA/s320/mvnrnd_example.jpg" height="240" width="320" /></a></div>
<br />
The problem is underspecified if only the correlation matrix is known. In this case, set the mean to a zero vector, covariance to the given correlation matrix.<br />
<br />
Tested in MATLAB 7.14.0.739 (R2012a), Octave 3.6.2</div>
Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com2tag:blogger.com,1999:blog-17898112.post-22115997155668430352013-02-21T13:00:00.000-05:002013-02-21T13:00:24.590-05:00append a number to a string in matlab<div dir="ltr" style="text-align: left;" trbidi="on">
Problem: Given a prefix say 'foo', generate a cell array of strings in Matlab such that each string has a number appended to it.<br />
<br />
Ans:<br />
<pre class="verbatim" xml:space="preserve">>> n=5; cas = cellstr([repmat('foo', n, 1), num2str([1:n]')])
cas =
'foo1'
'foo2'
'foo3'
'foo4'
'foo5'
</pre>
Spaces are automatically appended when the appended numbers have wider range.
<br />
<pre class="verbatim" xml:space="preserve">>> n=10; cas = cellstr([repmat('foo', n, 1), num2str([1:n]')])
cas =
'foo 1'
'foo 2'
'foo 3'
'foo 4'
'foo 5'
'foo 6'
'foo 7'
'foo 8'
'foo 9'
'foo10'
</pre>
Adding another string at the top of the array is easy
<br />
<pre class="verbatim" xml:space="preserve">>> n=10; cas = [{'raju'}; cellstr([repmat('foo', n, 1), num2str([1:n]')])]
cas =
'raju'
'foo 1'
'foo 2'
'foo 3'
'foo 4'
'foo 5'
'foo 6'
'foo 7'
'foo 8'
'foo 9'
'foo10'
</pre>
which can also be done by
<br />
<pre class="verbatim" xml:space="preserve">>> n=10; cas = cellstr([repmat('foo', n, 1), num2str([1:n]')]); cas2 = [{'raju'}; cas]
cas2 =
'raju'
'foo 1'
'foo 2'
'foo 3'
'foo 4'
'foo 5'
'foo 6'
'foo 7'
'foo 8'
'foo 9'
'foo10'
</pre>
</div>
Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-80250471392704950612012-10-11T01:40:00.001-04:002012-10-11T01:44:18.349-04:00do a grep on a column<div dir="ltr" style="text-align: left;" trbidi="on">
Consider the following data<br />
<blockquote class="tr_bq">
</blockquote>
<blockquote class="tr_bq">
$ cat data.txt <br />
1,fruit,apple red,spherical<br />
2,fruit,apple green,spherical<br />
3,vegetable,peppers green,irregular<br />
4,vegetable,peppers yellow,irregular<br />
5,vegetable,peppers red,irregular<br />
6,vegetable,broccoli,irregular and green<br />
7,plant,green spinach,leaves<br />
8,plant,very green spinach,leaves<br />
9,plant,verygreenspinach,leaves<br />
10,seed,green pea,spherical<br />
11,unknown,green,undefined</blockquote>
The problem is to filter the lines where the third field ends in the word green. So the output should be<br />
<blockquote class="tr_bq">
2,fruit,apple green,spherical<br />
3,vegetable,peppers green,irregular</blockquote>
Short answer:- use awk with regular expression support<br />
<blockquote class="tr_bq">
$ awk -F"," '{if ($3 ~ /\sgreen$/) print $0}' data.txt <br />
2,fruit,apple green,spherical<br />
3,vegetable,peppers green,irregular </blockquote>
Long answer:-<br />
Naive use of grep gives a lot of false positives.<br />
<blockquote class="tr_bq">
$ grep green data.txt <br />
2,fruit,apple green,spherical<br />
3,vegetable,peppers green,irregular<br />
6,vegetable,broccoli,irregular and green<br />
7,plant,green spinach,leaves<br />
8,plant,very green spinach,leaves<br />
9,plant,verygreenspinach,leaves<br />
10,seed,green pea,spherical<br />
11,unknown,green,undefined</blockquote>
line6 should not be printed as the word green appears in the 4th column (and not the 3rd).<br />
<br />
lines 7,8,10 has the word green in the 3rd field. But they should not be printed since green does not appear at the end.<br />
<br />
line9 - the letters green are present in the third field but is not preceded by a space, so should not be printed.<br />
<br />
line 11 is most likely a data error. The third field has the word green but is not associated with any fruit, vegetable, plant etc.,<br />
<br />
<br />
Further, to print all the spherical objects, one can use<br />
<blockquote class="tr_bq">
$ awk -F"," '{if ($4=="spherical") print $0}' data.txt <br />
1,fruit,apple red,spherical<br />
2,fruit,apple green,spherical<br />
10,seed,green pea,spherical </blockquote>
Here a full match on the 4th field is performed. However, this trick cannot be extended to the present problem as only partially matches on the third field are desired.<br />
<br />
How the solution works:-<br />
<blockquote class="tr_bq">
$ awk -F"," '{if ($3 ~ /\sgreen$/) print $0}' data.txt </blockquote>
~ tests for a match<br />
/ ... / delimiters of the regular expression<br />
\s test for space<br />
$ test for end of field<br />
<br />
Tested on Debian Wheezy using<br />
<blockquote class="tr_bq">
$ awk --version<br />
GNU Awk 4.0.1<br />
Copyright (C) 1989, 1991-2012 Free Software Foundation.</blockquote>
</div>
Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-92130525249542078782012-08-23T23:08:00.000-04:002012-08-23T23:08:14.847-04:00kill all the open figures in matlab<div dir="ltr" style="text-align: left;" trbidi="on">
The following function can be used to kill all the open figures in Matlab<br />
<br />
<blockquote class="tr_bq">
function kill_figures<br /> % close all open figures<br /> delete(findall(0,'Type','figure'));<br />end</blockquote>
<div>
This function comes in handy when doing parametric studies. Say, there is a big chunk of code that generates 10 figures per run. In order to study the effect of a parameter for say 5 cases, we end up generating 50 (=5x10) plots. Once the study is done, this function comes in handy to kill all those figure windows.</div>
<div>
<br /></div>
<div>
Related tips:</div>
<div>
<div>
<br /></div>
<div>
To get the handles of all the figures, do</div>
<blockquote class="tr_bq">
figHandles = findall(0, 'Type', 'figure');</blockquote>
</div>
<div>
<br /></div>
<div>
<br /></div>
</div>
Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com1tag:blogger.com,1999:blog-17898112.post-79251618153077810682012-06-24T22:05:00.000-04:002012-06-25T15:45:43.089-04:00specify rsync location<div dir="ltr" style="text-align: left;" trbidi="on">
If rsync fails with the following error,<pre class="verbatim" xml:space="preserve">$ /usr/bin/rsync -prltvzD user@machine.com:~/file.csv . -n
rsync: Command not found.
rsync: connection unexpectedly closed (0 bytes received so far) [Receiver]
rsync error: error in rsync protocol data stream (code 12) at io.c(601) [Receiver=3.0.7]
</pre>
the problem could be due to the non-standard location of rsync on the remote machine. For example, in this case, rsync was installed at /usr/local/bin/rsync on the remote machine. This location can be specified by using the "rsync-path" option. The following command succeeds.<pre class="verbatim" xml:space="preserve">$ /usr/bin/rsync -prltvzD --rsync-path=/usr/local/bin/rsync user@machine.com:~/file.csv . -n
receiving file list ... done
sent 20 bytes received 58 bytes 3.47 bytes/sec
total size is 11473183 speedup is 147092.09 (DRY RUN)
</pre>
</div>Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-44279162458503228332012-06-10T19:28:00.001-04:002012-06-11T11:02:42.691-04:00eBay should make the winning bid stick for at least an hour<div dir="ltr" style="text-align: left;" trbidi="on">
Dear eBay[1],<br />
<br />
In the current bidding process, the auction ends at a particular time which gives unnecessary importance to it. This can be evidenced by a lot of inactivity at the beginning and a frenzy of activity at the very end.<br />
<br />
Eliminating this "auction-ending-time arbitrage" (AETA from now on) is very simple and easy. Just make each "winning bid" stick for at least an hour. If necessary, extend the "auction ending time" further.<br />
<br />
You can be even more creative by providing this chance only to the previous "winning bidders". I will let your strategy team work out the finer details. But the underlying idea is very simple. You need to provide a better way for others to re-participate in the auction.<br />
<br />
If you think I can be of further assistance, ping me kamaraju at gmail dot com.<br />
<br />
<br />
Why is this such a big deal?<br />
<br />
To be honest, the current system sucks. It is very easy to be outbid at the very last minute by a tiny amount. There is not enough time left to reenter the bidding process when it happens. This can be very frustrating for the current winning bidder especially if he/she is leading the race for the last couple of days/hours. These winning bidders deserve a second chance to rebid and reparticipate in the auction.<br />
<br />
This is not a big issue for items with a lot of bidders (high liquidity). But for items with a very few bidders (illiquid, niche items), the suggested improvement provides a good price discovery mechanism. <br />
<br />
When you have a good price discovery platform, the sellers will be more inclined to use eBay resulting in more revenue. So it is a win-win for both eBay and its customers.<br />
<br />
References:<br />
<ol style="text-align: left;">
<li>www.ebay.com</li>
</ol>
PS:- I have arbitrarily chosen the "sticky period" as one hour. But in reality, it can be any reasonable choice.<br />
<br />
PPS:- If any one else agrees with me, go to http://pages.ebay.com/help/account/suggestions.html , click on the "Buying and searching" link, fill the form and make this suggestion to eBay.</div>Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com2tag:blogger.com,1999:blog-17898112.post-45182961052635986952012-05-25T20:35:00.001-04:002012-05-26T16:07:21.604-04:00iceweasel amazon prime flash error<div dir="ltr" style="text-align: left;" trbidi="on">
When trying to watch a video on Amazon Prime, I got the following error
<br />
<pre class="verbatim" xml:space="preserve">Sorry we were unable to stream this video. This is
likely because your flash player needs to be updated.
</pre>
<div class="separator" style="clear: both; text-align: center;">
<a href="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgw1xu2FbwL_qVT20uoFO2pdsp9dhf4JymWXdDBIZl8gih9SYCxWNpYoZEYoeOP1rcW2lUcO8AptkegAKP8VLNLCRe2DNDNhWQNtLP9st41tu51xiaYLVthBnZeKyHAgE3VLog2iA/s1600/amazon_prime_flash.png" imageanchor="1"><img src="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEgw1xu2FbwL_qVT20uoFO2pdsp9dhf4JymWXdDBIZl8gih9SYCxWNpYoZEYoeOP1rcW2lUcO8AptkegAKP8VLNLCRe2DNDNhWQNtLP9st41tu51xiaYLVthBnZeKyHAgE3VLog2iA/s400/amazon_prime_flash.png" /></a></div>
To fix the error, install the following packages
<br />
<pre class="verbatim" xml:space="preserve">$dpkg -l \*flash\* \*iceweasel\* \*hal\* | grep ^ii
ii flashplugin-nonfree 1:2.8.3 Adobe Flash Player - browser plugin
ii flashplugin-nonfree-extrasound 0.0.svn2431-3 Adobe Flash Player platform support library for Esound and OSS
ii hal 0.5.14-8 Hardware Abstraction Layer
ii hal-info 20091130-1 Hardware Abstraction Layer - fdi files
ii iceweasel 10.0.4esr-2 Web browser based on Firefox
ii iceweasel-torbutton 1.4.5.1-1 transitional dummy package
ii libhal-storage1 0.5.14-8 Hardware Abstraction Layer - shared library for storage devices
ii libhal1 0.5.14-8 Hardware Abstraction Layer - shared library
ii libkephal4 4:4.4.5-9 API for easier handling of multihead systems
ii libkephal4abi1 4:4.7.4-2 API for easier handling of multihead systems
</pre>
Note:- Some of the packages might be unnecessary. But they are sufficient.<br />
<br />
Make sure that the hal daemon is working.
<br />
<pre class="verbatim" xml:space="preserve">$ps aux | grep hald
116 5715 0.0 0.4 17108 4584 ? Ssl 20:15 0:00 /usr/sbin/hald
root 5716 0.0 0.1 13980 1588 ? Sl 20:15 0:00 hald-runner
root 5751 0.0 0.1 5864 1508 ? S 20:15 0:00 hald-addon-input: Listening on /dev/input/event0 /dev/input/event2 /dev/input/event1 /dev/input/event6 /dev/input/event5 /dev/input/event3 /dev/input/event4 /dev/input/event10
root 5755 0.0 0.1 5860 1244 ? S 20:15 0:00 /usr/lib/hal/hald-addon-rfkill-killswitch
root 5759 0.0 0.1 5856 1240 ? S 20:15 0:00 /usr/lib/hal/hald-addon-generic-backlight
116 5777 0.0 0.1 3816 1176 ? S 20:15 0:00 hald-addon-acpi: listening on acpid socket /var/run/acpid.socket
root 5778 0.0 0.1 5864 1508 ? S 20:15 0:00 hald-addon-storage: polling /dev/sr0 (every 2 sec)
1000 5826 0.0 0.0 4048 764 pts/2 S+ 20:25 0:00 grep hald
</pre>
<br />
Update the flashplugin
<br />
<pre class="verbatim" xml:space="preserve">$sudo update-flashplugin-nonfree --install --verbose</pre>
<br />
Close iceweasel window. Remove the ~/.adobe , ~/.macromedia directories
<br />
<pre class="verbatim" xml:space="preserve">mv ~/.adobe ~/.adobe_old_deleteafter
mv ~/.macromedia ~/.macromedia_old_deleteafter
</pre>
<br />
Restart iceweasel. The video (and audio) should be working now.
</div>Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-70073663249998694892012-05-23T09:17:00.000-04:002012-05-23T09:25:24.584-04:00awk remove quotes in a column<div dir="ltr" style="text-align: left;" trbidi="on">
Consider the input file<br />
<pre class="verbatim" xml:space="preserve">$cat input.txt
"k",1.1
"ka",2.2
"kam",3.3
"kama",4.4
"kamar",5.5
"kamara",6.6
"kamaraj",7.7
"kamaraju",8.8
</pre>
Convert this to
<br />
<pre class="verbatim" xml:space="preserve">$cat output.txt
k|1.1
ka|2.2
kam|3.3
kama|4.4
kamar|5.5
kamara|6.6
kamaraj|7.7
kamaraju|8.8
</pre>
i.e. remove the quotes in the first column, change the delimiter to '|'.<br />
<br />
This can be achieved in awk by defining both '"' and ',' as delimiters.<br />
<pre class="verbatim" xml:space="preserve">$cat cmd.sh
cat input.txt | awk -F "[\",]" -v OFS="|" '{print $2,$4}'
</pre>
Execute the above script as
<br />
<pre class="verbatim" xml:space="preserve">$./cmd.sh > output.txt
</pre>
Tested on Debian Wheezy using GNU awk 4.0.1 version.
<br />
<br />
keywords: awk remove quotes from string, get rid of quotes, replace the delimiter character</div>Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-73992907907159235772012-04-08T13:45:00.005-04:002012-04-14T22:39:11.113-04:00who writes LinuxThis is a great article my friend <a href="http://sasikanth.com/default.htm">Sasikanth</a> shared with me on facebook: <a href="http://go.linuxfoundation.org/who-writes-linux-2012">who-writes-linux-2012</a> . It provides statistics on who actually develops the Linux kernel, the rate of development, companies supporting the developers and lot of other interesting tidbits.<br /><br /><span jsid="text" class="commentBody">It is good to see that most developers are getting paid for doing what they love. Makes it a more sustainable model.<br /><br />The quote "As the Linux kernel grows, the rate of change is growing with it." just sums it up. This IMHO, is very hard to achieve with a conventional business model.</span><span></span><div class="commentActions fsm fwn fcg"><a class="uiLinkSubtle" href="https://www.facebook.com/sasikanth.m/posts/10100479315100495?comment_id=5718145"><abbr title="Sunday, April 8, 2012 at 1:44pm" utime="1333907084" class="timestamp livetimestamp"><br /></abbr></a></div>Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-83811247181581628022012-04-01T19:01:00.002-04:002012-04-01T19:10:33.876-04:00take a screenshot on windows 7To take a snapshot (screenshot) of a window do alt+PRINT and then ctrl-v.<br /><br />If you do just PRINT, you will get a screenshot of the whole screen.<br /><br />To take the snapshot as a jpg picture<br /><ul><li>start the paint program Start -> run -> mspaint<br /></li><li>"Select the window of interest" -> alt+PRINT -> go to mspaint window -> use ctrl-v to paste -> save as .jpg.<br /></li></ul>Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-84070147870667896412012-03-11T18:55:00.004-04:002012-03-11T19:23:43.270-04:00matlab to excelQ) what is the excel equivalent of matlab's ismember function<br />A) vlookup<br /><br />The syntax is vlookup(lookup_value, table_array, col_index_num, [range_look_up])<br /><br />It can be used to check if a value exists in a column, compare two columns etc.,<br /><br />The col_index_num starts from 1.<br />I usually give the 4th argument as false, so I can get an exact match. See help in excel for more details.<br /><br />ISNA() - similar to matlab's isnan function, is another function that comes in handy with vlookup. It tells whether a number is #N/A or not.Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-49373111737107960582012-02-27T00:44:00.003-05:002012-02-27T00:51:09.630-05:00computable document formatIf you've got 20 minutes to spare, this is a great presentation to watch <a href="http://www.wolfram.com/broadcast/screencasts/announcing_cdf/">http://www.wolfram.com/broadcast/screencasts/announcing_cdf/</a> . Here Conrad Wolfram explains about a new file format that he calls "computable document format". IMHO, it is an excellent idea. One that could change the way we think about e-documents like pdf files, presentations, research publications etc.,Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-78485114501024598192012-02-06T17:06:00.007-05:002012-02-06T23:58:39.577-05:00cygwin mintty vim output is not to a terminalInside the cygwin terminal if you do<br /><pre class="verbatim" xml:space="preserve"><br />$ uname -r<br />1.7.10(0.259/5/3)<br /><br />$ mintty.exe<br /></pre><br />The mintty terminal pops up. However, if you run vim in the mintty terminal, there are warnings such as<br /><pre class="verbatim" xml:space="preserve"><br />$ vim junk1.txt<br />Vim: Warning: Output is not to a terminal<br />Vim: Warning: Input is not from a terminal<br /></pre><br />To get rid of these warnings, start mintty with "mintty.exe -". The .exe is optional. It is the '-' that is more important.<br /><br />Why bother with the mintty terminal in the first place? Because it has a lot more functionality than the default cygwin terminal. For eg., the mintty terminal can be resized, maximized, minimized in both the directions; copy pasting text from/to the terminal is a breeze.Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com1tag:blogger.com,1999:blog-17898112.post-3219097582362844222011-12-25T22:50:00.006-05:002011-12-25T23:07:08.678-05:00verizon router dhcp getting a fixed IP addressI am currently using Verizon DSL to connect to the internet. So, I have<br /><br />laptop -> router -> internet<br /><br />A minor irritation with this set up is that the router can potentially assign different IP addresses whenever I do a reboot or something akin to /etc/init.d/networking restart. For example today it can be 192.168.1.58, tomorrow it could be 192.168.1.68 etc.,<br /><br />I currently have<br /><pre class="verbatim" xml:space="preserve"><br />$ifconfig <br />eth0 Link encap:Ethernet HWaddr 00:15:c5:19:9c:1a <br /> UP BROADCAST MULTICAST MTU:1500 Metric:1<br /> RX packets:0 errors:0 dropped:0 overruns:0 frame:0<br /> TX packets:0 errors:0 dropped:0 overruns:0 carrier:0<br /> collisions:0 txqueuelen:1000 <br /> RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)<br /> Interrupt:17 <br /><br />lo Link encap:Local Loopback <br /> inet addr:127.0.0.1 Mask:255.0.0.0<br /> inet6 addr: ::1/128 Scope:Host<br /> UP LOOPBACK RUNNING MTU:16436 Metric:1<br /> RX packets:6790 errors:0 dropped:0 overruns:0 frame:0<br /> TX packets:6790 errors:0 dropped:0 overruns:0 carrier:0<br /> collisions:0 txqueuelen:0 <br /> RX bytes:773105 (754.9 KiB) TX bytes:773105 (754.9 KiB)<br /><br />wlan0 Link encap:Ethernet HWaddr 00:13:02:9e:cc:1b <br /> inet addr:192.168.1.21 Bcast:192.168.1.255 Mask:255.255.255.0<br /> inet6 addr: fe80::213:2ff:fe9e:cc1b/64 Scope:Link<br /> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1<br /> RX packets:7486622 errors:0 dropped:0 overruns:0 frame:0<br /> TX packets:4833561 errors:0 dropped:0 overruns:0 carrier:0<br /> collisions:0 txqueuelen:1000 <br /> RX bytes:2650697959 (2.4 GiB) TX bytes:608573891 (580.3 MiB)<br /></pre><br />To have the same IP address, say 192.168.1.78, every time the computer is booted<br /><br />1) Add the following lines to /etc/dhcp/dhclient.conf<br /><pre class="verbatim" xml:space="preserve"><br />alias {<br /> interface "wlan0";<br /> fixed-address 192.168.1.78;<br /> option subnet-mask 255.255.255.255;<br />}<br /></pre><br />2) restart the network<br /><pre class="verbatim" xml:space="preserve"><br />sudo /etc/init.d/networking restart<br /></pre><br />Now you should see<br /><pre class="verbatim" xml:space="preserve"><br />$ifconfig <br />eth0 Link encap:Ethernet HWaddr 00:15:c5:19:9c:1a <br /> UP BROADCAST MULTICAST MTU:1500 Metric:1<br /> RX packets:0 errors:0 dropped:0 overruns:0 frame:0<br /> TX packets:0 errors:0 dropped:0 overruns:0 carrier:0<br /> collisions:0 txqueuelen:1000 <br /> RX bytes:0 (0.0 B) TX bytes:0 (0.0 B)<br /> Interrupt:17 <br /><br />lo Link encap:Local Loopback <br /> inet addr:127.0.0.1 Mask:255.0.0.0<br /> inet6 addr: ::1/128 Scope:Host<br /> UP LOOPBACK RUNNING MTU:16436 Metric:1<br /> RX packets:6790 errors:0 dropped:0 overruns:0 frame:0<br /> TX packets:6790 errors:0 dropped:0 overruns:0 carrier:0<br /> collisions:0 txqueuelen:0 <br /> RX bytes:773105 (754.9 KiB) TX bytes:773105 (754.9 KiB)<br /><br />wlan0 Link encap:Ethernet HWaddr 00:13:02:9e:cc:1b <br /> inet addr:192.168.1.21 Bcast:192.168.1.255 Mask:255.255.255.0<br /> inet6 addr: fe80::213:2ff:fe9e:cc1b/64 Scope:Link<br /> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1<br /> RX packets:7486678 errors:0 dropped:0 overruns:0 frame:0<br /> TX packets:4833604 errors:0 dropped:0 overruns:0 carrier:0<br /> collisions:0 txqueuelen:1000 <br /> RX bytes:2650705479 (2.4 GiB) TX bytes:608589238 (580.3 MiB)<br /><br />wlan0:0 Link encap:Ethernet HWaddr 00:13:02:9e:cc:1b <br /> inet addr:192.168.1.78 Bcast:0.0.0.0 Mask:255.255.255.255<br /> UP BROADCAST RUNNING MULTICAST MTU:1500 Metric:1<br /></pre>Note the new wlan:0 interface which is always assigned to 192.168.1.78.Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-32474362906665134732011-08-07T14:05:00.005-04:002012-02-07T16:37:15.822-05:00extract historical versions of a file tracked by gitSay, I have a file test.txt being tracked by git.<pre class="verbatim" space="preserve">$git log test.txt<br />commit 809ebdbd3c44b9310a7a0f67d61897d5d8f9b6d2<br />Author: rajulocal <rajulocal@kusumanchi.mae.cornell.edu><br />Date: Sun Aug 7 14:11:31 2011 -0400<br /><br /> version 15<br /><br />commit aec45562ad09257ce85eaf00f5a4fa6912e9e51e<br />Author: rajulocal <rajulocal@kusumanchi.mae.cornell.edu><br />Date: Sun Aug 7 14:11:21 2011 -0400<br /><br /> version 14<br /><br />commit 7fb63da179a2026ba92a8875ff7d3da881ef5854<br />Author: rajulocal <rajulocal@kusumanchi.mae.cornell.edu><br />Date: Sun Aug 7 14:11:11 2011 -0400<br /><br /> version 13<br /><br />commit 9b3ca5d3d7497e44c012f5ccd5daced2dd90ec12<br />Author: rajulocal <rajulocal@kusumanchi.mae.cornell.edu><br />Date: Sun Aug 7 14:10:51 2011 -0400<br /><br /> version 12<br /><br />commit d0b5471fa2abce0057cce1d61240e78c09406c04<br />Author: rajulocal <rajulocal@kusumanchi.mae.cornell.edu><br />Date: Sun Aug 7 14:10:40 2011 -0400<br /><br /> version 11<br /><br />commit e3af4e1a85b4ff07c31c8dcda47eb41c3f3c830b<br />Author: rajulocal <rajulocal@kusumanchi.mae.cornell.edu><br />Date: Sun Aug 7 14:10:26 2011 -0400<br /><br /> version 10<br /><br />commit be762c0ee45ec6046fa960cace9acae513b80137<br />Author: rajulocal <rajulocal@kusumanchi.mae.cornell.edu><br />Date: Sun Aug 7 14:10:18 2011 -0400<br /><br /> version 9<br /><br />commit 03ad798434559300cff26f6a238d7b0f05ad53d2<br />Author: rajulocal <rajulocal@kusumanchi.mae.cornell.edu><br />Date: Sun Aug 7 14:09:59 2011 -0400<br /><br /> version 8<br /><br />commit 94c50cce3b24e572133eeaedc5bfe00aad568aec<br />Author: rajulocal <rajulocal@kusumanchi.mae.cornell.edu><br />Date: Sun Aug 7 14:09:52 2011 -0400<br /><br /> version 7<br /><br />commit ab63e2bc7b258f702cc8c516c1f16bafc754cf27<br />Author: rajulocal <rajulocal@kusumanchi.mae.cornell.edu><br />Date: Sun Aug 7 14:09:44 2011 -0400<br /><br /> version 6<br /><br />commit 16c896d19e00267b63537596485074488cd20a85<br />Author: rajulocal <rajulocal@kusumanchi.mae.cornell.edu><br />Date: Sun Aug 7 14:09:37 2011 -0400<br /><br /> version 5<br /><br />commit 6937331a12209121ba24d111e1ca5128a3c1e836<br />Author: rajulocal <rajulocal@kusumanchi.mae.cornell.edu><br />Date: Sun Aug 7 14:09:21 2011 -0400<br /><br /> version 4<br /><br />commit 7ec1c7f98a152f6b760ff1561a3b805cc5e374e9<br />Author: rajulocal <rajulocal@kusumanchi.mae.cornell.edu><br />Date: Sun Aug 7 14:09:13 2011 -0400<br /><br /> version 3<br /><br />commit 5b3788ad1bdef15c1895a6efefcdd1ea96c840e9<br />Author: rajulocal <rajulocal@kusumanchi.mae.cornell.edu><br />Date: Sun Aug 7 14:09:01 2011 -0400<br /><br /> version 2<br /><br />commit 1306cba057d6cac06ffd39b9234ce72967dc44f8<br />Author: rajulocal <rajulocal@kusumanchi.mae.cornell.edu><br />Date: Sun Aug 7 14:08:35 2011 -0400<br /><br /> version 1<br /></pre><br /><br />In order to extract the latest 12 versions of test.txt and store each into a different file, I do<br /><pre class="verbatim" space="preserve">$xtract_hist_git 12 test.txt<br />$ls m??_test.txt <br />m00_test.txt m02_test.txt m04_test.txt m06_test.txt m08_test.txt m10_test.txt m12_test.txt<br />m01_test.txt m03_test.txt m05_test.txt m07_test.txt m09_test.txt m11_test.txt<br /></pre><br />m00_test.txt is the latest copy of test.txt, m01_test.txt is the latest but one copy, m02_test.txt is the latest but two copy etc.,<br /><br />xtract_hist_git is this little script<br /><pre class="verbatim" space="preserve">$cat ~/bin/xtract_hist_git <br />#! /bin/sh<br />#<br /># Author : Kamaraju S. Kusumanchi<br /># Email : kamaraju at gmail dot com<br /># File : ~/bin/xtract_hist_git<br /># Date (last modified) : Sun Aug 7 14:28:14 EDT 2011<br /><br />revs=$1<br />file=$2<br /><br />for i in `seq -w 0 $revs`<br />do<br /> git checkout master~$i $file<br /> mv $file m${i}_$file<br />done<br />git checkout master $file<br /></pre>Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0tag:blogger.com,1999:blog-17898112.post-50475583089507385202011-06-14T08:51:00.004-04:002011-06-14T08:58:25.219-04:00get all the odd lines in a filesed can be used to get all the odd or even lines in a file. Consider, for example,<pre class="verbatim" xml:space="preserve"><br />$cat linenums.txt<br /> line 1<br /> line 2<br /> line 3<br /> line 4<br /> line 5<br /> line 6<br /> line 7<br /> line 8<br /> line 9<br /> line 10<br /></pre><br />To print all the odd lines<pre class="verbatim" xml:space="preserve"><br />$sed -n '1~2p' linenums.txt <br /> line 1<br /> line 3<br /> line 5<br /> line 7<br /> line 9<br /></pre><pre class="verbatim" xml:space="preserve"><br />$sed -n '2~2p' linenums.txt<br /> line 2<br /> line 4<br /> line 6<br /> line 8<br /> line 10<br /></pre>Kamaraju Kusumanchihttp://www.blogger.com/profile/12855319594088570802noreply@blogger.com0