<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' 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'><id>tag:blogger.com,1999:blog-1507313692561905680</id><updated>2024-09-08T22:29:40.005-07:00</updated><category term="linux"/><category term="crap"/><category term="C"/><category term="NLP"/><category term="automata"/><category term="bash"/><category term="data structures"/><category term="formal languages"/><category term="java"/><category term="ssh"/><category term="systems programming"/><category term="EPDA"/><category term="cli"/><category term="content"/><category term="filesystems"/><category term="fragmentation"/><category term="git"/><category term="ioctl"/><category term="life"/><category term="ml-tree"/><category term="motivation"/><category term="scripting"/><category term="text manipulation"/><category term="Curvature"/><category term="Euclidean Geometry"/><category term="HPC"/><category term="LR parsing"/><category term="TAGs"/><category term="UI"/><category term="XTAG"/><category term="abstract"/><category term="alternatives"/><category term="android"/><category term="apps"/><category term="browsers"/><category term="chess"/><category term="cloud"/><category term="compression"/><category term="computer science"/><category term="configuration"/><category term="dynamic memory"/><category term="dynamic systems"/><category term="embedded"/><category term="emulators"/><category term="ext3"/><category term="fibmap"/><category term="game"/><category term="geodesic"/><category term="getopt"/><category term="git-rebase"/><category term="gnome-shell"/><category term="gnome3"/><category term="graphs"/><category term="gui"/><category term="introduction"/><category term="kernel"/><category term="logarithmic information theory"/><category term="login"/><category term="networkx"/><category term="ntfs"/><category term="numa"/><category term="patch"/><category term="perspective"/><category term="philosophy"/><category term="projects"/><category term="python"/><category term="rsync"/><category term="social networking"/><category term="supercomputers"/><category term="swt"/><category term="tensors"/><category term="tutorial"/><category term="uinput"/><category term="vim"/><category term="visualization"/><category term="web"/><category term="wine"/><title type='text'>Linux, Learning and life ...</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><link rel='next' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default?start-index=26&amp;max-results=25'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>51</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>25</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-861444644607804220</id><published>2023-12-10T22:08:00.000-08:00</published><updated>2023-12-10T22:09:47.898-08:00</updated><title type='text'>Automatically switching input sources on Dell Monitor (U3821DW) with inbuilt KVM switch</title><content type='html'>&lt;p&gt;My external monitor (Dell U3821DW) has a inbuilt &lt;a href=&quot;https://en.wikipedia.org/wiki/KVM_switch&quot;&gt;KVM switch&lt;/a&gt; that can be controlled either through the joystick controller on the monitor (reaching out to the monitor everytime you want to switch is a pain) or through the Dell Display and Peripherals Manager (DDPM). The latter is only available on MacOS or Windows.&lt;/p&gt;&lt;p&gt;My home setup has my work/personal MBP pro connected to the monitor via the USB-C hub (inbuilt) and my workstation running linux is connected via HDMI/USB-B. My keyboard and mouse are both connected via a USB-A hub that is connected to the monitor directly.&lt;/p&gt;&lt;p&gt;From MacOS I can use a hotkey setup via DDPM to switch to HDMI as the input source and the monitor automatically switches over the peripheral USB input to my workstation (the KVM part).&lt;/p&gt;&lt;p&gt;However from linux, I had to setup &lt;a href=&quot;https://www.ddcutil.com/&quot;&gt;ddcutil&lt;/a&gt; to be able to switch between the input sources (and back to my MBP).&lt;/p&gt;&lt;p&gt;ddcutil allows you to probe for the capabilities on each external monitor that is detected :&lt;/p&gt;&lt;blockquote&gt;&lt;span style=&quot;font-family: Inconsolata;&quot;&gt;&lt;b&gt;~ sudo ddcutil detect&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;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; &amp;nbsp;&lt;br /&gt;Display 1&lt;br /&gt;&amp;nbsp;&amp;nbsp; I2C bus:&amp;nbsp; /dev/i2c-3&lt;br /&gt;&amp;nbsp;&amp;nbsp; EDID synopsis:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Mfg id:&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; DEL&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Model:&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; DELL U3821DW&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Product code:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 41387&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Serial number:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 5J82073&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Binary serial number: 809060684 (0x3039494c)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Manufacture year:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2022,&amp;nbsp; Week: 42&lt;br /&gt;&amp;nbsp;&amp;nbsp; VCP version:&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 2.1&lt;br /&gt;~ sudo ddcutil capabilities | grep &quot;Input Source&quot; -A 5&lt;br /&gt;&amp;nbsp;&amp;nbsp; Feature: 60 (Input Source)&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; Values:&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 1b: Unrecognized value&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 0f: DisplayPort-1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 11: HDMI-1&lt;br /&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; 12: HDMI-2&lt;/b&gt;&lt;/span&gt;&lt;/blockquote&gt;&lt;p&gt;We don&#39;t see the USB-C input source here, my best guess was that &quot;Unrecognized value&quot; (0x1b) is the USB-C input as the output accounts for all the other video input sources. So to switch back to my MBP from linux, I would run :&lt;/p&gt;&lt;p style=&quot;margin-left: 40px; text-align: left;&quot;&gt;&lt;span style=&quot;font-family: Inconsolata;&quot;&gt;&lt;b&gt;~ sudo ddcutil setvcp 60 0x1b&lt;/b&gt;&lt;/span&gt;&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;NOTE: 60 here is the Virtual control panel (VCP) code for the &quot;Input source&quot; command set. Refer to the &lt;a href=&quot;https://en.wikipedia.org/wiki/Monitor_Control_Command_Set&quot;&gt;VESA Monitor Control Command Set&lt;/a&gt; for more information on VCP etc.&lt;/p&gt;&lt;p style=&quot;text-align: left;&quot;&gt;To automate this, I setup a script in my local $PATH that I can run from the terminal. You can also setup shortcuts in your favorite desktop linux environment to trigger this command.&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;&lt;p&gt;&lt;br /&gt;&lt;/p&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/861444644607804220/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2023/12/automatically-switching-input-sources.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/861444644607804220'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/861444644607804220'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2023/12/automatically-switching-input-sources.html' title='Automatically switching input sources on Dell Monitor (U3821DW) with inbuilt KVM switch'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-8327288054250818508</id><published>2019-08-03T01:55:00.001-07:00</published><updated>2019-08-03T01:55:54.776-07:00</updated><title type='text'>Bazel sandboxing and ccache</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;span style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;I was trying to build a random project cloned from github that uses bazel for the build system. While trying to build the source code, bazel aborted the build with the following error :&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;script src=&quot;https://gist.github.com/eerpini/24e2372ed996105f6f7c74f15bee68db.js&quot;&gt;&lt;/script&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;Turns out this is a known issue, Bazel runs builds in a sandbox (which is effectively a user namespace) and this sandbox does not have write access to the cache dir used by ccache. Unfortunately for me, Fedora defaults to use ccache.&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;The suggested fix is to whitelist the ccache cache directory, however the caveat is that the corresponding configuration option is not a valid startup option, it is only valid for the build action. So adding the following to ~/.bazelrc (creating one if it does not exist) should fix this error :&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;script src=&quot;https://gist.github.com/eerpini/94b5ba47172dde1f885bd337d669c8fe.js&quot;&gt;&lt;/script&gt;
&lt;span style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;span style=&quot;font-family: &amp;quot;trebuchet ms&amp;quot; , sans-serif;&quot;&gt;For the curious, you can see the cache directory that ccache uses by running &quot;ccache --print-config&quot; (~/.ccache is usually the default).&lt;/span&gt;
&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/8327288054250818508/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2019/08/bazel-sandboxing-and-ccache.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/8327288054250818508'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/8327288054250818508'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2019/08/bazel-sandboxing-and-ccache.html' title='Bazel sandboxing and ccache'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-7206710079994426246</id><published>2015-02-17T23:39:00.000-08:00</published><updated>2015-02-18T13:44:32.293-08:00</updated><title type='text'>Toggling the background in Vim</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I end up switching the background on my terminal a lot depending on where I am working and the ambient light conditions around. If you use vim, you know this can lead some text becoming almost invisible ( with the default colors only ? ) when you switch from a light background to a dark background or vice versa.&lt;br /&gt;
So, I ended up mapping a couple simple shortcuts for setting the vim background to dark or light :&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/eerpini/2841a24aba77e00bc893.js&quot;&gt;&lt;/script&gt;&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/7206710079994426246/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2015/02/toggling-background-in-vim.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/7206710079994426246'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/7206710079994426246'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2015/02/toggling-background-in-vim.html' title='Toggling the background in Vim'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-5814521263726109977</id><published>2014-10-21T00:33:00.000-07:00</published><updated>2014-10-21T00:34:19.955-07:00</updated><title type='text'>Extending QCOW2 virtual hd on Mac using VBoxManage</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
If you are on a linux box, you could just run qemu-img to resize the virtual hd file. But on Mac, at least I could not get qemu to build. So using the Virtualbox command line tool I did the following :&lt;br /&gt;
&lt;br /&gt;
VBoxManage clonehd original-hd-file.qcow vdi-copy-of-original-hd-file.vdi --format VDI&lt;br /&gt;
&lt;br /&gt;
VBoxManage modifyhd vdi-copy-of-original-hd-file.vdi --resize [ new size in MB]&lt;new in=&quot;&quot; mb=&quot;&quot; size=&quot;&quot;&gt;&lt;/new&gt;&lt;br /&gt;
&lt;br /&gt;
Virtual box does not have support for resizing QCOW files, so you have to convert it into either VDI, VMDK format before you can resize the file. If the file is not too big and you have ample space, this is a fairly quick solution. Also note that with modifyhd --resize you can only extend a file, you cannot shrink it.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/5814521263726109977/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2014/10/extending-qcow2-virtual-hd-on-mac-using.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/5814521263726109977'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/5814521263726109977'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2014/10/extending-qcow2-virtual-hd-on-mac-using.html' title='Extending QCOW2 virtual hd on Mac using VBoxManage'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-7386812857691164106</id><published>2014-10-15T23:22:00.000-07:00</published><updated>2014-10-15T23:22:05.958-07:00</updated><title type='text'>The Narrows Hike - A Memoir</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Very well written by Viswa about the Narrows day hike we did recently. One of the best groups I have hiked with.&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;Where the hearts meet and the girls eye diamonds,&lt;br /&gt;Not the typical gentlemen&#39;s clubs,&lt;br /&gt;But for him, PRASAD, a place to spade out some bucks,&lt;br /&gt;He&#39;s a gambler with lots of luck.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;Walked in with style, she dealt the cards out,&lt;br /&gt;Amazing ride, his sequence flushed out,&lt;br /&gt;He called it his hand, cashed in his demand,&lt;br /&gt;Ready to walk out, she can; but SRI KAN&#39;T.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;All for one, One for all,&lt;br /&gt;Consumed with chores, once and for all,&lt;br /&gt;He has you but mostly you have him,&lt;br /&gt;Trust you won&#39;t be lost, he&#39;s a MESH around U.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;As the ocean calls for drops&lt;br /&gt;Or the river Virgin may be,&lt;br /&gt;The joy ends up with the caller&lt;br /&gt;But the burden&#39;s borne by the KOLLI.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;Don&#39;t know much about knee pain,&lt;br /&gt;Don&#39;t care much about need to train,&lt;br /&gt;Can&#39;t help him watch sing along,&lt;br /&gt;That will make you see A RUN along.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;Hopping over the stones like a rabbit,&lt;br /&gt;Makes you wonder how he got into this habit,&lt;br /&gt;A cam and a camera in each hand,&lt;br /&gt;The lenses were blessed to be NAVEEN&#39;S friend.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;Just when you thought you got me,&lt;br /&gt;I tell mom nature, not a chance there be,&lt;br /&gt;Not for a moment, please think I&#39;d drop,&lt;br /&gt;Up like a bouncy BALL, GEE I pop.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;Slide to the left, right and front,&lt;br /&gt;Wait up to catch up, behind that were left,&lt;br /&gt;Point to the steps, so they step to the point,&lt;br /&gt;They do what you say, NAIDU what you do.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;You pin to his route, he figured it all out,&lt;br /&gt;Follow his steps and you will hardly step out,&lt;br /&gt;In the event you missed, his trek so swift,&lt;br /&gt;To help he will turn like an EERPINI bend.&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;Life&#39;s a journey, a longer one for some,&lt;br /&gt;Like a drop of a whiskey versus a bottle of rum,&lt;br /&gt;Moon may be bright, but it&#39;s the Sun with the light,&lt;br /&gt;Who knew otherwise until CHANDu was with us, right?&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #444444; font-family: inherit;&quot;&gt;Open the gates, you see them nine,&lt;br /&gt;Expend an hour or two, they were fine,&lt;br /&gt;The two streams met, then there were five,&lt;br /&gt;When the Sun has set, SATEESH helped survive!&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: #7f7f7f; font-family: Arial; font-size: x-small;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/7386812857691164106/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2014/10/the-narrows-hike-memoir.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/7386812857691164106'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/7386812857691164106'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2014/10/the-narrows-hike-memoir.html' title='The Narrows Hike - A Memoir'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-2914533003523629379</id><published>2014-10-12T22:50:00.001-07:00</published><updated>2016-02-20T08:57:39.028-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="abstract"/><category scheme="http://www.blogger.com/atom/ns#" term="life"/><category scheme="http://www.blogger.com/atom/ns#" term="perspective"/><title type='text'>Survival vs Existence.</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
&lt;b&gt;The Narrows Hike - at around ~10 Miles in&lt;/b&gt;&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;
&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQatpIE-Q6ZxfHzHvBNeJESSe9m4jLE258q92v13uZzYNEkUqnqn8hyphenhyphenVQAadJQWldQ3gqeI5rFMMaxfGPvSMWuhBXL4bGJ21l8yfMw05l3NyEWvset2x4rEiJhczShTk7ntawfDT38YbPA/s1600/P1000690.JPG&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;300&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQatpIE-Q6ZxfHzHvBNeJESSe9m4jLE258q92v13uZzYNEkUqnqn8hyphenhyphenVQAadJQWldQ3gqeI5rFMMaxfGPvSMWuhBXL4bGJ21l8yfMw05l3NyEWvset2x4rEiJhczShTk7ntawfDT38YbPA/s1600/P1000690.JPG&quot; width=&quot;400&quot; /&gt;&lt;/a&gt;&lt;/div&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;
The last shuttle leaves the Temple of Sinawawa in another five hours, at 1930 hrs. Tall canyons, millions of years of water and ice shaping up the stone, the process visible before your own eyes as water gushes down on the smooth and round stones. Your mind snapshots the beauty of the surroundings, but your body would rather get this over with. No one in sight, only the sound of water persistently eroding away the canyon walls. With every step, you slip, stumble, your brain corrects for the movements, and before you topple, you gain a tighter footing. The swollen knee cap from the earlier fall is feeling better being in knee deep cold water, yet it could totally do without working against the steady current. Will I survive another 10 miles without injuries, will I make it before sunset, will it matter if I don&#39;t ? I am hungry, I have not had any food so far. Though there is no lack of energy, I can feel my stomach caving in. The solitude and force of the nature around, strangely encouraging and replenishing. No tasks, no schedules. I am not waiting for someone to reply back, I am not thinking about dealing with the next shit storm. Just the plain primal goal of survival. Relieving.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;The Regular Sunday Night&lt;/b&gt;&lt;br /&gt;
I have to get to work tomorrow. Preferably early in the morning, so that I can retain that sleep and food schedule going for the rest of the week. Have a few tasks that have rolled over from friday and would possibly want to wrap them up before getting along with the day. Have to make sure I have breakfast in the morning. Sleeping now would be a good idea, but a better idea would be to turn away from the screen, read something for a while and then try to sleep. I had my flex armband turned off today, so I am probably going to figure in the bottom few on this week&#39;s leaderboards.&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;What ?&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
I rarely write about life, but when I do, it is pretty abstract. What I am comparing above are two self-centered memories. Questioning the flow of time around me and my buoyancy is the intent here, because it seems to be so very dependent on the layers of complexity you spin around yourself. The basic animal self never has to worry about anything more than the simple art of survival : food, sleep and sex.&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/2914533003523629379/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2014/10/the-art-of-zooming-in-and-out.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/2914533003523629379'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/2914533003523629379'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2014/10/the-art-of-zooming-in-and-out.html' title='Survival vs Existence.'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEiQatpIE-Q6ZxfHzHvBNeJESSe9m4jLE258q92v13uZzYNEkUqnqn8hyphenhyphenVQAadJQWldQ3gqeI5rFMMaxfGPvSMWuhBXL4bGJ21l8yfMw05l3NyEWvset2x4rEiJhczShTk7ntawfDT38YbPA/s72-c/P1000690.JPG" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-1014341499919719420</id><published>2013-01-29T13:38:00.001-08:00</published><updated>2013-01-30T11:09:56.697-08:00</updated><title type='text'>git me and git wholog - useful git aliases for viewing commits</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
When using git, it is a common requirement to be able to get a log of all the commits that you have done or some one else has done. I find the git --committer a little long to type in and use every time, with a little bash-foo you can have simple aliases like &quot;git me&quot; and &quot;git wholog &lt;someone&gt;&quot; to do the same. The changes for this would be :&amp;nbsp;&lt;/someone&gt;&lt;br /&gt;
&lt;br /&gt;
$HOME/bin/git&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;#!/bin/bash&lt;/span&gt;&lt;br /&gt;
&lt;br style=&quot;color: #0b5394;&quot; /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;if [ $# -gt 0 ]; then&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; if [ &quot;$1&quot; == &quot;me&quot; ]; then&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&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; exec git log --committer=&#39;Satish&#39;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; elif [ &quot;$1&quot; == &quot;wholog&quot; ]; then&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&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; if [ $# -lt 2 ]; then&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&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; echo &quot;usage: git wholog &lt;committer author=&quot;&quot; pattern=&quot;&quot;&gt;&quot;&lt;/committer&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&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; exit 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&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; fi&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&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; exec git log --committer=$2&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; else&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&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; exec git $@&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp;&amp;nbsp; fi&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: #0b5394;&quot;&gt;fi&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
$HOME/.bashrc&lt;br /&gt;
&lt;div style=&quot;color: #3d85c6;&quot;&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;color: #3d85c6;&quot;&gt;
alias git=&#39;~/bin/git`&lt;/div&gt;
&lt;br /&gt;
&lt;br /&gt;
Run &quot;source ~/.bashrc&quot; and you are all set to go.&lt;br /&gt;
&lt;br /&gt;
In retrospect, this could have been done much more neatly with &quot;&lt;span style=&quot;color: blue;&quot;&gt;git config --global alias.xxxx&lt;/span&gt;&quot;.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/1014341499919719420/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2013/01/git-me-and-git-wholog-useful-git.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/1014341499919719420'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/1014341499919719420'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2013/01/git-me-and-git-wholog-useful-git.html' title='git me and git wholog - useful git aliases for viewing commits'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-7651999890317010122</id><published>2012-10-16T00:51:00.001-07:00</published><updated>2012-10-16T00:51:23.199-07:00</updated><title type='text'>TCP/IP Over USB</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Setup&lt;br /&gt;
------&lt;br /&gt;
&lt;br /&gt;
Android phone, rooted.&lt;br /&gt;
Linux host.&lt;br /&gt;
USB 2.0 Compliant connection between the above two devices.&lt;br /&gt;
&lt;br /&gt;
Goal&lt;br /&gt;
-----&lt;br /&gt;
&lt;br /&gt;
A client browser program running on the android phone should be able to load the home page from the web server running on the Linux host.&lt;br /&gt;
&lt;br /&gt;
More information coming soon.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/7651999890317010122/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2012/10/tcpip-over-usb.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/7651999890317010122'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/7651999890317010122'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2012/10/tcpip-over-usb.html' title='TCP/IP Over USB'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-4053811069850438173</id><published>2012-05-09T21:01:00.000-07:00</published><updated>2015-02-18T13:43:46.723-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="login"/><category scheme="http://www.blogger.com/atom/ns#" term="systems programming"/><title type='text'>Session logging in Linux</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Most of you must be familiar with the &quot;who&quot; command on linux, it lists the users logged in currently on the machine and shows a lot more information related to where they are logged in from etc. There are a lot more options the command supports including the usual &quot;who am i&quot; and &quot;who mom likes&quot; versions.&lt;br /&gt;
Basically what &quot;who&quot; does is parse a couple of files which are used for session logging, this post aims to explain these files and the structure of the records in these files. Typically on linux systems two files are used for session logging :&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;/var/run/utmp&lt;/span&gt; : Stores user session related information, a record is appended at each login and then wiped out on logout.&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;/var/log/wtmp&lt;/span&gt; : Stores a trail of the login/logout information and other such logging information for the system. The same record which is pushed to utmp is pushed here on login and then the same record with the &quot;user&quot; field zeroed in is pushed on logout.&lt;br /&gt;
&lt;br /&gt;
The paths to the files can change and are available more generically as&lt;span style=&quot;color: blue;&quot;&gt; _PATH_UTMP&lt;/span&gt; and &lt;span style=&quot;color: blue;&quot;&gt;_PATH_WTMP&lt;/span&gt; defined in&lt;span style=&quot;color: blue;&quot;&gt; /usr/include/paths.h&lt;/span&gt;. Applications should use these definitions rather than hard coding the paths.&lt;br /&gt;
&lt;br /&gt;
Linux for compatibility provides both the utmp and utmpx API for dealing with these log files, the utmpx API is an extension(and a parallel API) of the utmp API and was created in System V Release 4. Linux however does not create parallel utmpx and wtmpx files, all the information is available in the above mentioned two files only.&lt;br /&gt;
&lt;br /&gt;
The records stored in each of the files is of the type &lt;span style=&quot;color: blue;&quot;&gt;&quot;struct utmpx&quot;&lt;/span&gt; defined in&lt;span style=&quot;color: blue;&quot;&gt; /usr/include/bits/utmpx.h&lt;/span&gt; as :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Courier New, Courier, monospace;&quot;&gt;&lt;script src=&quot;https://gist.github.com/eerpini/1b3a50a56fe8a36a0052.js&quot;&gt;&lt;/script&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: Courier New, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Note that to get some of the types for the fields in the structure it is important to declare&lt;span style=&quot;color: blue;&quot;&gt; _GNU_SOURCE&lt;/span&gt; in your program.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Each of the lines in &quot;utmp&quot; and &quot;wtmp&quot; files contains records of the above format. As I mentioned before Linux supports both the old utmp API and the utmpx API, if the utmp API is used then the records are read in as &quot;&lt;span style=&quot;color: blue;&quot;&gt;struct utmp&lt;/span&gt;&quot; which is defined in &lt;span style=&quot;color: blue;&quot;&gt;/usr/include/bits/utmp.h&lt;/span&gt;. The main difference between the two APIs is that the former has some re-entrant versions for functions which the latter(utmpx) does not. The various defined function calls are :&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
One field which requires some attention above is the type field. Records in the files can be of various types, &amp;nbsp;:&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
EMPTY - Invalid accounting information&lt;/div&gt;
&lt;div&gt;
RUN_LVL - Indicates a change in run-level during boot or shutdown (requires definition of _GNU_SOURCE)&lt;/div&gt;
&lt;div&gt;
BOOT_TIME - Contains the system boot time in ut_tv field.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
NEW_TIME - Contains the new time after a system clock change, recorded in the ut_tv field.&lt;/div&gt;
&lt;div&gt;
OLD_TIME - Contains the old time before a system clock change, similar to the NEW_TIME type record.&lt;/div&gt;
&lt;br /&gt;
INIT_PROCESS - Signifies a process which has been spawned by the INIT process.&lt;br /&gt;
LOGIN_PROCESS - Record for a process like &quot;login&quot;&lt;br /&gt;
USER_PROCESS - Signifies a user session process started by the login program.&lt;br /&gt;
DEAD_PROCESS - Identifies a process that has exited (occurs on logout)&lt;br /&gt;
&lt;br /&gt;
RUN_LVL and BOOT_TIME type records are written by &quot;init&quot; and these records are written to both the &quot;utmp&quot; file and the &quot;wtmp&quot; file.&lt;br /&gt;
&lt;br /&gt;
Using the utmpx API you can read and write entries to these files directly. The good thing is that you need not directly open/close these files, calling the function &quot;setutxent()&quot; opens the file or rewinds the file pointer if already open. Similarly when we are done reading/writing, we can close the file using &quot;endutxent()&quot;.&lt;br /&gt;
The functions available in the API to deal with the &quot;utmp&quot; file can be divided into three categories :&lt;br /&gt;
&lt;br /&gt;
1. Getting entire records &amp;nbsp;using the getutxent() function which returns the entire record starting from the current file pointer location.&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt; &amp;nbsp; &amp;nbsp;struct utmpx * getutxent(void);&lt;/span&gt;&lt;br /&gt;
2. Searching for records based on given parameters, the parameters are passed in a struct utmpx pointer.&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;struct utmpx * getutxid(const struct utmpx *ut);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;struct utmpx * getutxline(const struct utmpx *ut);&lt;/span&gt;&lt;br /&gt;
3. For putting a record to the file&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;struct utmpx * pututxline(const struct utmpx *ut);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Functions of the type getutx* return a pointer to the utmpx record read or NULL if EOF is reached. The returned pointer points to a static area and can be cached on certain systems, that is if the search parameters match the result in the pointer returned by a previous call, then the same contents might be returned again. It is a good idea to zero the static area pointed to by this pointer. Also the pututxline() function may internally call the getutx* set of functions, but this will not affect the contents of the static area that the getutx* set of functions return a pointer to. The pututxline() functions returns a pointer to the record passed as the argument &amp;nbsp;on success and NULL on failure.&lt;br /&gt;
By default all the getutx* functions work on the &quot;utmp&quot; file, we can change this (for example to the &quot;wtmp&quot; file) using the following function :&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;int utmpxname (const char *file);&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Note that this function does not open the file and thus will not report any errors pertaining to invalid paths, such errors will show up only on the consequent calls to the other getutx* functions or the setutxent() function.&lt;br /&gt;
Also since updates to the &quot;wtmp&quot; files are always just simple appends (remember that records are never removed from this file), this can be achieved using the following wrapper call which opens the file, writes the record and then closes it :&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white; color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;void updwtmpx (char *wtmpx_file, struct utmpx *ut);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Some systems might instead provide the &lt;span style=&quot;color: blue;&quot;&gt;updwtmp(char *, struct utmp *) &lt;/span&gt;or the &lt;span style=&quot;color: blue;&quot;&gt;logwtmp (const char *, const char *, const char *)&lt;/span&gt; functions for updating the wtmp file.&lt;br /&gt;
&lt;br /&gt;
There is another file on linux (and some unix implementations) which provides useful session information, this is &lt;span style=&quot;color: blue;&quot;&gt;&quot;/var/log/lastlog&quot;&lt;/span&gt; which contains logs of the logout time for users. The records in this file are of type &lt;span style=&quot;color: blue;&quot;&gt;&quot;struct lastlog&quot;&lt;/span&gt; &amp;nbsp;defined in &lt;span style=&quot;color: blue;&quot;&gt;/usr/include/bits/utmp.h&lt;/span&gt; (search for lastlog). This information is sometimes used to display the last time when you logged into a machine on login.&lt;br /&gt;
&lt;br /&gt;
Here is some sample code which reads the &quot;utmp&quot; file and lists the user name on each record. The code does not use the API calls but reads the records directly from the file, (this is not the preferred way of doing it though, the code is just a proof-of-concept).&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;span style=&quot;color: blue; font-family: Courier New, Courier, monospace;&quot;&gt;&lt;script src=&quot;https://gist.github.com/eerpini/55c0cd3bb62870b965a8.js&quot;&gt;&lt;/script&gt;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;
Apart from &quot;who&quot;, there are other commands like &quot;last&quot; which display information extracted from the utmp/wtmp files.&lt;br /&gt;
&lt;br /&gt;
All the above information (and more to come) is a result of the time I have spending with the &lt;a href=&quot;http://www.amazon.com/The-Linux-Programming-Interface-Handbook/dp/1593272200/ref=sr_1_1?ie=UTF8&amp;amp;qid=1336622012&amp;amp;sr=8-1&quot; target=&quot;_blank&quot;&gt;&quot;The Linux Programming Interface&quot;&lt;/a&gt;. Chapter 40 (Login Accounting) in the book provides quite a lot more details and sample code listings which use the utmpx API and do a lot more than the above sample code.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/4053811069850438173/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2012/05/session-logging-in-linux.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/4053811069850438173'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/4053811069850438173'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2012/05/session-logging-in-linux.html' title='Session logging in Linux'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-5209959357625070394</id><published>2012-04-28T23:50:00.000-07:00</published><updated>2015-02-18T13:54:23.818-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="numa"/><title type='text'>Memory at each node on a NUMA machine using libnuma (linux only)</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
For the past few days I have been occupied with trying to understand how NUMA works and what are related implications and challenges for system design. Linux supports more than a few memory location policies on a NUMA supported machine and a&amp;nbsp;corresponding&amp;nbsp;user space library to deal with these policies, migration of memory, thread location etc among other things. The library for most part seems to get information from the files in /proc/self and in /sys/devices/system/node. The latter location in the sys filesystem has a multitude of information pertaining to the memory on the system.&lt;br /&gt;
Here is a simple program I wrote toady which prints the memory located at each &quot;defined&quot; memory node on the NUMA system, this program uses the numa library libnuma. It is a rather trivial piece of code. My next task at hand (once I am done with the semester finals) would be to play around with my parallel implementation of QuickSort using pthreads and see if I can improve performance by manually playing with locality of memory and thread execution.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;script src=&quot;https://gist.github.com/eerpini/b724820e5c3b02bfcc77.js&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
I did hit upon one important piece of information which I did not know before, that my laptop (DELL E6410) is NUMA compatible but has a single memory node with all the 8 Gigs of memory. This might as well be the reason why the parallel QuickSort worked faster on my laptop than on some of the department machines with distributed memory banks and faster truly multithreaded cores.&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
EDIT :&lt;br /&gt;
&lt;br /&gt;
if you have the numactl package installed, you can also list numa related hardware information using the following command :&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;numactl --hardware&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
looking at the information you can tell that it is the same as what you would see under the various entries in the&amp;nbsp;/sys/devices/system/node directory.&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/5209959357625070394/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2012/04/memory-at-each-node-on-numa-machine.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/5209959357625070394'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/5209959357625070394'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2012/04/memory-at-each-node-on-numa-machine.html' title='Memory at each node on a NUMA machine using libnuma (linux only)'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-5960421067622666365</id><published>2012-04-24T12:30:00.003-07:00</published><updated>2012-04-29T00:06:01.175-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bash"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><title type='text'>Quick everyday scripting in bash</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
From my experience, mostly in grading courses and everyday tasks on my linux box, the most common requirements for scripting deal with iterating over a given set of entities and performing some task, or iterating over a given folder&#39;s contents and performing some task. Here are some sample cases and solutions to performing the same quickly. (I use bash so I am sure all the following work in bash).&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Case 1 :&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;b&gt;&lt;br /&gt;&lt;/b&gt;&lt;br /&gt;
You have a program X and you want to verify that it runs correctly (lets assume running correctly means the same as the program X exiting with success) over, say 100 iterations.&lt;br /&gt;
&lt;br /&gt;
Solution&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;for i in `seq 100`&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;do&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; ./X [ args for X]&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; if [ $? -ne 0 ]; then&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; echo &quot;X failed in iteration $i&quot;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; exit 1&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; fi&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;done&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The construct `...`&amp;nbsp;runs the command inside and is replaced by the output of that command. the &quot;basename&quot; command gives you the last literal in a path.&lt;br /&gt;
The special variable $? stores the exit code of the previous program that was run in the shell script, this is typically what you return at the end of the main() function in a C program. A return code of 0 stands for success.&lt;br /&gt;
Note that the above snippet will work assuming that you are in the directory which contains the file (program) X.&lt;br /&gt;
&lt;br /&gt;
&lt;b&gt;Case 2 :&amp;nbsp;&lt;/b&gt;&lt;br /&gt;
&lt;br /&gt;
A folder X has contents a, b, c, d, e, f, g , each of which is a folder. You want to create a file [parent_folder_name].txt in each of those folders.&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;for file in X/*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;do&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; touch $file/$(basename $file).txt&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;done&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
The construct $(...) runs the command inside and is replaced by the output of that command. the &quot;basename&quot; command gives you the last literal in a path. so&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ basename X/a&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;a&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;$ basename X/b&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;b&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
A slight modification to case 2, if X has both files and directories and you want to run the operation only for directories then you can modify the above snippet to check if the entry is a file/directory and act accordingly :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;for file in X/*&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;do&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; if [ -d $file ]; then&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; touch $file/$(basename $file).txt&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; fi&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;done&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Note that the above two snippets (for Case 2) will work assuming that your current working directory is the parent of directory X.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Case 3 :&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Execute a command via ssh on a set of remote machines, whose hostnames are in lexicographic order. For example the CS department here at purdue has the following set of machines :&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
sslab01-sslab21 and suppose I want to run the command &quot;who&quot; on each one of them.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;for i in `seq 21`&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;do&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; if [ $i -lt 10 ]; then&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; echo &quot;Running &#39;who&#39; on sslab0$i&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ssh sslab0$i &quot;who&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; else&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; echo &quot;Running &#39;who&#39; on sslab$i&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; ssh sslab$i &quot;who&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; fi&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;done&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
The if conditions in the above snippet are required because, by default the &quot;seq&quot; &amp;nbsp;does not output numbers of equal width, that is , it does not pad zeros at the beginning. However if you pass the &quot;-w&quot; option to seq, you can simplify the above snippet to :&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;for i in `seq -w 21`&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;do&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; echo &quot;Running &#39;who&#39; on sslab$i&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;&amp;nbsp; &amp;nbsp; ssh sslab$i &quot;who&quot;&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;background-color: white; color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;done&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;
The &quot;-w&quot; option ensures that `seq` prints its output in fixed width, padding the number with zeroes when ever necessary.&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I will edit the post and add more common scenarios as I come across new ones, but all the above snippets are short and once you get hold of things, you can actually type them in on the prompt whenever you want&amp;nbsp;rather than storing them in a script file and running that file.&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Adding Scripts to the PATH&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
However if you do want to run them as a script (from a file), it is a better option to do the following :&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
1. if &amp;nbsp;! [ -d ~/bin ]; then mkdir ~/bin; fi&lt;/div&gt;
&lt;div&gt;
2. touch ~/bin/script_I_run_often&lt;/div&gt;
&lt;div&gt;
3. Add the snippet to the script&lt;/div&gt;
&lt;div&gt;
4. chmod +x ~/bin/script_I_run_often&lt;/div&gt;
&lt;div&gt;
5. add &quot;export PATH=$PATH:~/bin&quot; to ~/.bashrc&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Now you can just run the script as :&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
$ script_I_run_often&lt;/div&gt;
&lt;div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;b&gt;Other Special Variables&lt;/b&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Some other special variables which are very useful in everyday scripting are :&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
$# : the number of arguments passed to the script, you can check this variable to see if your script got the correct number of arguments or not&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
$1, $2, $3 ... : are the arguments passed to the script&lt;/div&gt;
&lt;div&gt;
$$ : Pid of the current process&lt;/div&gt;
&lt;br /&gt;
NOTE : None of the information mentioned above is &quot;new&quot; or &quot;novel&quot;, the post is just meant to serve as a compilation of some quick bash tricks. I am sure many other such compilations exist on the internet.&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/5960421067622666365/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2012/04/tips-for-fast-everyday-scripting-in.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/5960421067622666365'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/5960421067622666365'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2012/04/tips-for-fast-everyday-scripting-in.html' title='Quick everyday scripting in bash'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-5813866776103402118</id><published>2012-04-17T21:55:00.000-07:00</published><updated>2012-04-17T21:55:48.679-07:00</updated><title type='text'>[Fixed] Blue Tint on Youtube videos (flash problem) on Centos 6.x</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
I have the adobe flash plugin from the adobe repository with the following version installed on my laptop running Centos &amp;nbsp;:&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;flash-plugin.x86_64 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;11.2.202.233-release &amp;nbsp; &amp;nbsp;@adobe-linux-x86_64&lt;/i&gt;&lt;br /&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
Since the last update, the videos on Youtube have mostly had a blue tint and less often a pale orange shade. After a couple of days of not trying to fix it (thanks to the hectic semester) I guessed this was a problem with flash or something to do with how flash uses the GPU, since those are the only two pieces of proprietary software on my laptop (and thus would be expected to be fixed rather slow for a problem so evident).&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
Finally, a little googling around showed this post on the Arch Linux forums :&amp;nbsp;&lt;a href=&quot;https://bbs.archlinux.org/viewtopic.php?pid=1084648&quot;&gt;https://bbs.archlinux.org/viewtopic.php?pid=1084648&lt;/a&gt;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
I just followed whatever was mentioned there, and the flash plugin looks far more stable now. Here are the steps I followed on my Centos 6.x machine :&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
1. Created the file /etc/adobe/mms.cfg and added the following contents :&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;#Hardware video decoding&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;EnableLinuxHWVideoDecode=1&lt;/span&gt;&lt;/div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;OverrideGPUValidation=true&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
2. Added the following line at the beginning of &amp;nbsp;/etc/X11/xinit/xinitrc-common&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;span style=&quot;color: blue; font-family: &#39;Courier New&#39;, Courier, monospace;&quot;&gt;export VDPAU_NVIDIA_NO_OVERLAY=1&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
You will need root permissions for both of the above, an alternative for the second step can be adding the same line to the user specific xinitrc file (~/.xinitrc). I logged out and logged in again after the changes, the blue tint is gone and the flash plugin itself is far more stable than before. As suggested in the thread on the arch linux forums, it might be a good idea to try a free alternative to the adobe flash player plugin if possible.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;div&gt;
PS :&amp;nbsp;&lt;/div&gt;
&lt;div&gt;
1. I run Centos 6.x on my Dell E6410, which has a NVIDIA NVS 3100M gpu.&lt;/div&gt;
&lt;div&gt;
2. It is just amazing the thread which showed up was on the arch linux forums, Arch Linux continues to amaze me.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/5813866776103402118/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2012/04/fixed-blue-tint-on-youtube-videos-flash.html#comment-form' title='5 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/5813866776103402118'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/5813866776103402118'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2012/04/fixed-blue-tint-on-youtube-videos-flash.html' title='[Fixed] Blue Tint on Youtube videos (flash problem) on Centos 6.x'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>5</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-7977729323814106437</id><published>2011-12-21T00:16:00.000-08:00</published><updated>2015-02-18T13:57:16.979-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="C"/><category scheme="http://www.blogger.com/atom/ns#" term="data structures"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="text manipulation"/><title type='text'>Converting a space delimited sentence into a sequence of null terminated strings</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
The title says it all, you are given a string which consists of words separated by spaces, here is a snippet of code for converting the same into a sequence of null terminated strings and then later printing them. Returning the indices in the original string where the words begin is the key here :&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
&lt;br /&gt;&lt;script src=&quot;https://gist.github.com/eerpini/f13b22e234ed0669b668.js&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;
Printing the strings is pretty trivial as :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;&lt;script src=&quot;https://gist.github.com/eerpini/057b4a765f8c8a04e64c.js&quot;&gt;&lt;/script&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
Quick code, picked up the hack from a certain shell command parsing code in Xinu.&lt;/div&gt;
&lt;div&gt;
&lt;br /&gt;&lt;/div&gt;
&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/7977729323814106437/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2011/12/converting-space-delimited-sentence.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/7977729323814106437'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/7977729323814106437'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2011/12/converting-space-delimited-sentence.html' title='Converting a space delimited sentence into a sequence of null terminated strings'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-7896063925511458031</id><published>2011-12-20T20:28:00.000-08:00</published><updated>2011-12-21T21:34:44.586-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="android"/><category scheme="http://www.blogger.com/atom/ns#" term="apps"/><category scheme="http://www.blogger.com/atom/ns#" term="gui"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><title type='text'>Intents and Activities in Android</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
The android UI is built around the concept of Activities. Each screen you see when you use an android app is an activity. And as usual, each activity has a layout that in programming methodology can only be accessed by the thread which set/created the layout. Android however has better method for creating activities and getting back information from them than purely language oriented methods (like global variables, shared objects etc). Android defines the notion of an intent, which can be used to give some information to an Activity and also get back information from an activity as an intent. The general code flow looks like the following :&lt;br /&gt;
&lt;br /&gt;
create an intent and start the activity :&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;&amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;final int result = 1;&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;Intent intent = new Intent(VoipChat.this, UserSettings.class);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;startActivityForResult(intent, result);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Add code in the event handler when an activity returns ( you need to check for the specific return code which is the same as result)&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;
&lt;/div&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp;public void onActivityResult(int requestCode, int resultCode, Intent data) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;if (resultCode == Activity.RESULT_OK &amp;amp;&amp;amp; requestCode == 1) {&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&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; //Do some work here&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp;}&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
In the activity class which is started, make sure you put the necessary data in a new intent before calling the finish() method. The code in UserSettings.java for example would look something like :&lt;br /&gt;
&lt;br /&gt;
&amp;nbsp; &amp;nbsp;&lt;span style=&quot;color: blue;&quot;&gt;Bundle bundle = new Bundle();&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;Log.d(&quot;USERSETTINGS&quot;, &quot;Returning : &quot;+userName.getText().toString());&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;bundle.putString(&quot;UserName&quot;, userName.getText().toString());&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;data.putExtras(bundle);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;this.setResult(RESULT_OK, data);&lt;/span&gt;&lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;   &lt;/span&gt;finish();&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
Accordingly the code inside the if block above would look something like :&lt;br /&gt;
&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;br /&gt;
&lt;span style=&quot;color: blue;&quot;&gt;&amp;nbsp; &amp;nbsp;String result = data.getExtras().getString(&quot;UserName&quot;);&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
note that data is the intent variable in the arguments for the onActivityResult() method.&lt;br /&gt;
&lt;br /&gt;
&lt;i&gt;NOTE : This blog post contains very specific information about the android sdk and included libraries. Unlike most of the other posts on this blog, it may not be of interest to the general readers.&lt;/i&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/7896063925511458031/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2011/12/intents-and-activities-in-android.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/7896063925511458031'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/7896063925511458031'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2011/12/intents-and-activities-in-android.html' title='Intents and Activities in Android'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-5757251542722818615</id><published>2011-12-06T14:01:00.001-08:00</published><updated>2011-12-22T17:10:58.354-08:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="text manipulation"/><category scheme="http://www.blogger.com/atom/ns#" term="vim"/><title type='text'>Disabling auto indentation for code pasting in vim</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
If you are a vim user and have automatic indentation enabled, then you have sure been through the trouble of trying to paste indented code and messing up the indentation completely. There is however a fix for this , you can temporarily disable code indentation when you are pasting text. Add the following to your vim configuration file (mostly ~/.vimrc) :&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;set pastetoggle=&amp;lt;key sequence&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
You can set whatever key sequence you want and if you do not have any other mapping for that key sequence, you just need to hit the key sequence and then &quot;i&quot; for insert and paste the text. Insert will generally show you the mode, for example if you have paste mode enabled, you will see&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;-- INSERT (paste) --&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;div&gt;
You can disable the paste mode using the same sequence as above. On my machine I have the sequence &amp;nbsp;set to &amp;lt;leader&amp;gt;&amp;lt;C-p&amp;gt;, (my leader key is bound to the default &quot;,&quot;)&lt;/div&gt;
&lt;div&gt;
&lt;div&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;set pastetoggle=&amp;lt;leader&amp;gt;&amp;lt;C-p&amp;gt;&lt;/span&gt;&lt;/div&gt;
&lt;/div&gt;
&lt;br /&gt;
&lt;div&gt;
So hitting, &quot;,&quot; and then Ctrl-p toggles the mode on vim on my machine.&lt;/div&gt;
&lt;br /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/5757251542722818615/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2011/12/disabling-auto-indentation-for-code.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/5757251542722818615'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/5757251542722818615'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2011/12/disabling-auto-indentation-for-code.html' title='Disabling auto indentation for code pasting in vim'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-7128427225353149489</id><published>2011-10-03T00:46:00.000-07:00</published><updated>2011-10-03T00:46:55.858-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="configuration"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="ssh"/><category scheme="http://www.blogger.com/atom/ns#" term="tutorial"/><title type='text'>Per host username configuration for ssh</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;
Using ssh to access many remote servers is a common scenario and more often the user names on these servers might be different from the one on the local machine and/or different among themselves. Ssh allows one to set the default username to use per host. You need to edit either the user specific configuration file (~/.ssh/config) or the system wide configuration file (/etc/ssh/ssh_config) and add the following :&lt;br /&gt;
&lt;br /&gt;
&lt;span style=&quot;background-color: white;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;1&lt;/span&gt;&lt;/span&gt; &amp;nbsp; &amp;nbsp;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt; Host &amp;lt;hostname&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;2 &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp;User &amp;lt;username&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;br /&gt;&lt;/span&gt;&lt;br /&gt;
You can add as many entries as you want like above and the next time you can just do&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;$ ssh &amp;lt;hostname&amp;gt;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
and ssh will try to log you in with the default username specified for that host in the configuration file.&lt;br /&gt;
More information on ssh can be found on the ssh man page (man ssh) and more information about the ssh configuration options can be found on the ssh_config man page(man ssh_config). (BTW, setting up passphrase-less ssh authentication is suggested if you connect to the remote servers very often and if security is not of high priority).&lt;/div&gt;
</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/7128427225353149489/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2011/10/per-host-username-configuration-for-ssh.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/7128427225353149489'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/7128427225353149489'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2011/10/per-host-username-configuration-for-ssh.html' title='Per host username configuration for ssh'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total><georss:featurename>West Lafayette, IN, USA</georss:featurename><georss:point>40.4258686 -86.9080655</georss:point><georss:box>40.3775186 -86.9870295 40.4742186 -86.829101500000007</georss:box></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-5461696054789159525</id><published>2011-08-21T23:34:00.000-07:00</published><updated>2011-08-21T23:34:25.637-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="crap"/><title type='text'>Letting it go ...</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;No system is efficient, there are memory leaks, there are application freezes, and some never work at all, you cannot keep a system up for ever, even the most resilient of servers have to be rebooted once in a while.&lt;br /&gt;
It so happens in life too, you need to let it go, to forget all the things that you have seen, heard and been through so far, this is not a foolish blog post with the constant onslaught of &#39;a&#39; someone&#39;s thoughts in the hindsight of the mind. It is rather a realization, once in a while, you need to let it go, discard all the burden that has come as part of the memories that so form the foundation of our (everyone&#39;s) existence. The multitude of neurons in the head will take a few days if not weeks to flush the changes through to the deepest reaches of the synapses, but you have to start it somewhere and let it go, start afresh. I feel that need now more than ever, but this of all things in the world is something you cannot verify, still you just have to go with the feeling that your heart asked your mind to let it go and the grey blob paid heed, you will however never know for sure that it did or not until another day when all the melancholy is triggered [again] by that one memory you have tried to let go time and over &amp;nbsp;!&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/5461696054789159525/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2011/08/letting-it-go.html#comment-form' title='2 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/5461696054789159525'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/5461696054789159525'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2011/08/letting-it-go.html' title='Letting it go ...'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>2</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-7708918043590243817</id><published>2011-07-27T03:41:00.000-07:00</published><updated>2011-07-27T03:41:32.164-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bash"/><category scheme="http://www.blogger.com/atom/ns#" term="emulators"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="scripting"/><category scheme="http://www.blogger.com/atom/ns#" term="wine"/><title type='text'>Converting paths on a linux filesystem to WINE relative paths</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;a href=&quot;http://www.winehq.org/&quot;&gt;Wine&lt;/a&gt; is a windows software emulator for Linux. Wine generally installs itself to &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;~/.wine &lt;/span&gt;and the C:\ Drive for the corresponding emulated windows environment is &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;~/.wine/drive_c/ &lt;/span&gt;. Wine sees the actually filesystem as mounted under a emulated &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Z:\&lt;/span&gt; drive, so for example &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;/mnt&lt;/span&gt; on the linux filesystem becomes &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Z:\mnt&lt;/span&gt;. To automatically run windows programs which require files from the linux filesystem, it is nifty if the linux filesystem path for a file can be converted to the emulated version starting with &lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Z:\&lt;/span&gt;&lt;/span&gt; , here is a small snippet of code which does that for the current working directory :&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;$ echo Z:`pwd` | sed &#39;s/\//\\/g&#39;&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
It gets the absolute path for the current working directory and converts all forward slashes (&#39;/&#39;) to backward slashes (&#39;\&#39;) and prepends the drive letter (Z:) to it. Now adapting the above snippet to get the wine path for a normal file is quite easy, and is left for those who are interested&lt;br /&gt;
&lt;br /&gt;
&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/7708918043590243817/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2011/07/converting-paths-on-linux-filesystem-to.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/7708918043590243817'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/7708918043590243817'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2011/07/converting-paths-on-linux-filesystem-to.html' title='Converting paths on a linux filesystem to WINE relative paths'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-2364221518173374269</id><published>2011-07-27T01:45:00.000-07:00</published><updated>2011-07-27T01:49:40.770-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="bash"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="scripting"/><category scheme="http://www.blogger.com/atom/ns#" term="ssh"/><title type='text'>Setting up password less authentication between two linux machines</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;Setting up password less authentication between two machines is a common requirement for many distributed software to work, some examples being hadoop, MPI etc ... however it is sometimes also handy if you are a system administrator and frequently login to a remote machine. Now the &lt;a href=&quot;http://linux.die.net/man/1/ssh-copy-id&quot;&gt;ssh-copy-id&lt;/a&gt; utility already exists to copy the ssh public key from the current machine to the remote machine. But if you have to copy the key from the remote machine to the local machine you have to first login to the remote machine, and then use ssh-copy-id (or some other method) from there. Here is a handy bash script to do the same.&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;#!/bin/bash&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;set -x&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if [ $# -eq 0 ]; then&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;echo &quot;Usage : setup_ssh &amp;lt;local_interface&amp;gt; &amp;lt;remote_ip&amp;gt; [&amp;lt;remote_user&amp;gt;]&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;echo &quot;Example : setup_ssh wlan0 192.168.0.10&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;exit 1&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;interface=$1&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;remote_ip=$2&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;my_ip=$(ifconfig $interface | grep &quot;inet addr&quot; | sed &#39;s/inet addr://g&#39; | awk &#39;{print $1}&#39;)&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if [ $? -ne 0 ]; then&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;echo &quot;Could not get the current machines ip&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;exit 1&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if [ $# -eq 3 ];then&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;user=$3&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;user=$USER&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if [ &quot;$user&quot; = &quot;root&quot; ]; then&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;remote_home=&quot;/root/.ssh&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;remote_home=&quot;/home/$user/.ssh&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;echo &quot;Checking for remote copy program ..&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;which scp&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if [ $? -eq 0 ]; then&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;remote_copy=&quot;scp&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;which rsync&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;if [ $? -eq 0 ]; then&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;remote_copy=&quot;rsync&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;else&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;echo &quot;Could not find a remote copy program, quitting !&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt;  &lt;/span&gt;exit 1&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;which ssh-copy-id&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if [ $? -ne 0 ]; then&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;echo &quot;Could not find ssh-copy-id &quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;exit 1&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if ! [ -f ~/.ssh/id_rsa.pub ]; then&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;echo &quot;Could not find the default public key : ~/.ssh/id_rsa.pub&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;exit 1&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;echo &quot;ssh-copy-id $user@$remote_ip&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;ssh-copy-id $user@$remote_ip&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;$remote_copy $user@$remote_ip:$remote_home/*.pub ./&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;cat *.pub &amp;gt;&amp;gt; ~/.ssh/authorized_keys&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;rm -rf *.pub&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;if [ $? -ne 0 ];then&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;echo &quot;Copying the public keys failed ... quitting &quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;exit 1&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;else&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;echo &quot;Successfull&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;exit 0&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
Note that the script only works in one of the following two formats :&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;$ ssh-setup interface remote_ip remote_user&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;div style=&quot;text-align: left;&quot;&gt;&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;or&lt;/div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;$ ssh-setup interface remote_ip&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
The remote ip need not only be an ip address, as you would have already understood from the script, it can also be a hostname or some handle which can be resolved to an ip address.&lt;br /&gt;
&lt;br /&gt;
A sample execution would look like &amp;nbsp;:&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;$ ssh-setup wlan0 192.168.0.21 root&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: #666666;&quot;&gt;Note : This script has only been tested on a linux machine (Fedora 14 ) and I do not assure you of its functionality, use at your own risk.&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&lt;br /&gt;
&lt;/span&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/2364221518173374269/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2011/07/setting-up-password-less-authentication.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/2364221518173374269'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/2364221518173374269'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2011/07/setting-up-password-less-authentication.html' title='Setting up password less authentication between two linux machines'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-3149141256502236775</id><published>2011-07-15T01:44:00.000-07:00</published><updated>2011-07-15T01:46:22.026-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="swt"/><title type='text'>Modifying SWT widgets from outside the event thread / Using a single display with SWT on linux</title><content type='html'>Like most GUI frameworks , SWT ( which itself is a wrapper over the native windowing system) has an event loop, more over it has other restrictions on the way the widgets/elements within the GUI can be modified. The main item of importance in a SWT based GUI is the display, created like :&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;Display display = new Display()&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
now, on linux (x64 at least to the extent I have tested), SWT does not support multiple displays. So you have to use one display entity to drive all your GUI components, this can especially get really troublesome if your GUI has multiple components and windows. Logically making the code modular (splitting the code for each window into may be different classes imposes its own issues) will result in problems.&lt;br /&gt;
This is because, SWT allows the GUI widgets to be accessed/modified only from the thread in which the display was created. If you try to access it from outside this thread, you will end up with a &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: red;&quot;&gt;SWTException : Invalid thread access. &amp;nbsp;&lt;/span&gt;Here are the possible fixes for this :&lt;br /&gt;
&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Declare the display as a static variable so that you have access to it based on the class name&lt;/li&gt;
&lt;li&gt;Now whenever you need to change something in the GUI, assume you have a function changeWidgetStyle( Params ) which changes the widget style, then you can call the function as :&amp;nbsp;&lt;/li&gt;
&lt;/ul&gt;&amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&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;lt;Class Name&amp;gt;.display.asyncExec(new Runnable(){&amp;nbsp;&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&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; &amp;nbsp; &amp;nbsp; public void run(){&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&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; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; &amp;nbsp; changeWidgetStyle( Params );&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&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; &amp;nbsp; &amp;nbsp; }&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;&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; });&lt;/span&gt;&lt;br /&gt;
&lt;br /&gt;
&lt;ul&gt;&lt;li&gt;Now the code inside the changeWidgetStyle function can access and modify any components of the GUI. I guess SWT imposes this restriction to make the event thread as responsive as possible.&lt;/li&gt;
&lt;li&gt;Use the display.syncExec() method with exactly the same syntax if you want to wait for the execution of the function to complete.&lt;/li&gt;
&lt;/ul&gt;&lt;div&gt;I will try to post a code example soon ( as I find some more time). !&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/3149141256502236775/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2011/07/modifying-swt-widgets-from-outside.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/3149141256502236775'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/3149141256502236775'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2011/07/modifying-swt-widgets-from-outside.html' title='Modifying SWT widgets from outside the event thread / Using a single display with SWT on linux'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-2894277697594329254</id><published>2011-07-15T01:26:00.000-07:00</published><updated>2011-07-15T01:27:43.009-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="alternatives"/><category scheme="http://www.blogger.com/atom/ns#" term="java"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><title type='text'>Configuring java using the alternatives system (on Fedora/Centos/Redhat)</title><content type='html'>On most red-hat based systems, alternative versions of the same software (from say different vendors) are managed using the &quot;alternatives&quot; system. Here is an example :&lt;br /&gt;
&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;$ which java | xargs file&lt;/span&gt;&lt;br /&gt;
&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;/usr/bin/java: symbolic link to `/etc/alternatives/java&#39;&lt;/span&gt;&lt;br /&gt;
&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;$ file /etc/alternatives/java&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;/etc/alternatives/java: symbolic link to `/usr/lib/jvm/jre-1.6.0-openjdk.x86_64/bin/java&#39;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;Here in this case we are looking at the java pointing to the one bundled by openjdk. Say if you have installed the Sun (or Oracle rather :|) JDK and if the path to that is /opt/java/bin , then you can add the sun version of java to the alternatives system using :&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;background-color: white;&quot;&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;$ alternatives --install /usr/bin/java java /opt/java/bin/java 100000&amp;nbsp;&lt;/span&gt;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;The last number there is a priority, set it high so that any priority based overrides are ineffective. Now by doing :&amp;nbsp;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;$ alternatives --config java&amp;nbsp;&lt;/span&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;you should be able to switch between the alternative versions of java !&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/2894277697594329254/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2011/07/configuring-java-using-alternatives.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/2894277697594329254'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/2894277697594329254'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2011/07/configuring-java-using-alternatives.html' title='Configuring java using the alternatives system (on Fedora/Centos/Redhat)'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-3675646772337371343</id><published>2011-07-13T18:46:00.000-07:00</published><updated>2011-07-15T01:30:21.266-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="kernel"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><title type='text'>The number of f**ks and sh**ts in the linux kernel source !</title><content type='html'>I was getting bored with my work and started trying to write out a fast parser in C which given a directory prints out the number of occurrences of fu*cks and sh**ts in files inside that directory. The program is &lt;a href=&quot;http://satisheerpini.net/summer-2011/code/count_f_words.c&quot;&gt;&lt;b&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue;&quot;&gt;here&lt;/span&gt;&lt;/b&gt;&lt;/a&gt;&amp;nbsp;. I ran this program on the current stable &lt;a href=&quot;http://www.kernel.org/&quot;&gt;linux kernel&lt;/a&gt; 2.6.29.3. Here are the interesting results ( I wrapped up the results from the C program to convert them to links to the source on the web using a simple python script, so that anyone interested can verify the count for themselves). It took the program a little more than 6 seconds (~ 6.3 secs) to complete parsing the entire kernel source.&lt;br /&gt;
&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/mmc/host/sdhci.c&lt;br /&gt;
Found a fuck in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/media/video/bt819.c&lt;br /&gt;
Found 9 shits in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/media/video/zoran/zr36050.c&lt;br /&gt;
Found 9 shits in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/media/video/zoran/zr36060.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/media/video/zoran/zr36016.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/scsi/qlogicpti.c&lt;br /&gt;
Found a fuck in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/scsi/qlogicpti.h&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/block/ub.c&lt;br /&gt;
Found a fuck in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/mtd/mtd_blkdevs.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/net/declance.c&lt;br /&gt;
Found 2 shits in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/net/niu.h&lt;br /&gt;
Found 2 fucks in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/net/sunhme.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/net/sunhme.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/net/wan/z85230.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/net/wireless/iwlegacy/iwl3945-base.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/net/sunlance.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/video/aty/radeon_pm.c&lt;br /&gt;
Found 2 shits in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/video/sis/sis_main.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/macintosh/adb.c&lt;br /&gt;
Found 2 shits in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/staging/slicoss/slicoss.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/ata/sata_via.c&lt;br /&gt;
Found a fuck in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=drivers/ide/cmd640.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=sound/oss/uart6850.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=sound/pci/cs46xx/dsp_spos_scb_lib.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=sound/pci/ac97/ac97_patch.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=Documentation/ManagementStyle&lt;br /&gt;
Found a fuck in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=Documentation/DocBook/kernel-locking.tmpl&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=Documentation/DocBook/kernel-hacking.tmpl&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=include/linux/fb.h&lt;br /&gt;
Found a fuck in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=lib/vsprintf.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=net/ipv4/tcp_input.c&lt;br /&gt;
Found a fuck in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=net/ipv4/netfilter/nf_nat_snmp_basic.c&lt;br /&gt;
Found a fuck in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=net/core/skbuff.c&lt;br /&gt;
Found a fuck in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=fs/notify/inotify/inotify_user.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=fs/jffs2/dir.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=fs/isofs/inode.c&lt;br /&gt;
Found 2 fucks in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=fs/xfs/xfs_btree.h&lt;br /&gt;
Found 24 fucks in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=arch/mips/pci/ops-bridge.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=arch/mips/kernel/genex.S&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=arch/mips/include/asm/mipsprom.h&lt;br /&gt;
Found a fuck in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=arch/mips/sgi-ip22/ip22-setup.c&lt;br /&gt;
Found a fuck in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=arch/m68k/include/asm/sun3ints.h&lt;br /&gt;
Found a fuck in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=arch/x86/kernel/cpu/cpufreq/powernow-k7.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=arch/x86/platform/visws/visws_quirks.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=arch/sparc/mm/ultra.S&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=arch/sparc/mm/srmmu.c&lt;br /&gt;
Found a fuck in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=arch/sparc/kernel/head_32.S&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=arch/sparc/kernel/traps_64.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=arch/sparc/kernel/pcic.c&lt;br /&gt;
Found a shit in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=arch/sparc/lib/checksum_32.S&lt;br /&gt;
Found a fuck in http://git.kernel.org/?p=linux/kernel/git/stable/linux-2.6.39.y.git;a=blob;f=arch/parisc/kernel/sys_parisc.c&lt;br /&gt;
Found 42 f words and 53 s words !&lt;br /&gt;
&lt;br /&gt;
Note : Don&#39;t go by the run time of the program, my machine has a i7 and is pretty fast !&lt;br /&gt;
&lt;br /&gt;
EDIT : Considering the attention this post has been getting, the words matched are : *fuck* and *shit~[a-z], the program is of course not case sensitive, and as is obvious , it is not a perfect matching program, it was just a half an hour worth coding experiment !</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/3675646772337371343/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2011/07/number-of-fks-and-sts-in-linux-kernel.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/3675646772337371343'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/3675646772337371343'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2011/07/number-of-fks-and-sts-in-linux-kernel.html' title='The number of f**ks and sh**ts in the linux kernel source !'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-4134387442461506565</id><published>2011-06-15T15:16:00.000-07:00</published><updated>2011-06-20T20:19:58.123-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="rsync"/><category scheme="http://www.blogger.com/atom/ns#" term="ssh"/><title type='text'>rcat - Concatenate to a remote file</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;I have recently had the need to do something like &quot;cat file1 &amp;gt;&amp;gt; file2&quot;, but where file2 sits on a remote machine. Most users can also think of the most common use case for this, when you have to concatenate your id_rsa.pub (public key) to the authorized_keys list on another machine. I came up with a small hack to do the same which uses rsync behind the scenes, here is how it looks :&lt;br /&gt;
&lt;br /&gt;
&lt;code&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;#!/bin/bash&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;#script to remotely concatenate files.&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;#args -&amp;gt; rcat file1 file2&amp;nbsp;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;#concatenates file1 to remote file file2&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;local_file=$1&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;username=`echo $2 | sed &#39;s/:/\t/g&#39; | awk &#39;{print $1}&#39; | sed &#39;s/@/\t/g&#39; | awk &#39;{print $1}&#39;`&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;remote_host=`echo $2 | sed &#39;s/:/\t/g&#39; | awk &#39;{print $1}&#39; | sed &#39;s/@/\t/g&#39; | awk &#39;{print $2}&#39;`&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;remote_file=`echo $2 | sed &#39;s/:/\t/g&#39; | awk &#39;{print $2}&#39;`&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;temp_folder=&quot;/tmp/$#/&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;file_name=`echo $local_file &amp;nbsp;| sed &#39;s/\// /g&#39; | awk &#39;{print $NF}&#39;`&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;if [ -d $local_file ] ;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;then&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;echo &quot;Cannot cat a directory&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;echo &quot;Qutting&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;&lt;span class=&quot;Apple-tab-span&quot; style=&quot;white-space: pre;&quot;&gt; &lt;/span&gt;exit&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;fi&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;rsync $local_file $username@$remote_host:$temp_folder/&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;ssh $username@$remote_host &quot;cat $temp_folder/$file_name &amp;gt;&amp;gt; $remote_file &amp;amp;&amp;amp; rm -rf $temp_folder/&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;echo &quot;done&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;code&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;color: blue; font-size: x-small;&quot;&gt;echo &quot;rcat $local_file $username@$remote_host:$remote_file&quot;&lt;/span&gt;&lt;/code&gt;&lt;br /&gt;
&lt;div&gt;&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;the bad thing about the script right now is that it will ask for authentication twice. But the good thing is that you need not manually sync the files and then concatenate them. The syntax for the remote file is similar to rsync, scp etc.&amp;nbsp;&lt;/div&gt;&lt;div&gt;rcat [local_file] [username]@[remote_host]:[remote_file]&lt;/div&gt;&lt;div&gt;&lt;br /&gt;
&lt;/div&gt;&lt;div&gt;[EDIT]&lt;br /&gt;
There is a utility &quot;ssh-copy-id&quot; to copy the public keys across systems.&lt;/div&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/4134387442461506565/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2011/06/rcat-concatenate-to-remote-file.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/4134387442461506565'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/4134387442461506565'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2011/06/rcat-concatenate-to-remote-file.html' title='rcat - Concatenate to a remote file'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-6155743090027633641</id><published>2011-06-03T16:19:00.000-07:00</published><updated>2011-06-03T16:55:10.845-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="git"/><category scheme="http://www.blogger.com/atom/ns#" term="gnome-shell"/><category scheme="http://www.blogger.com/atom/ns#" term="gnome3"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="UI"/><title type='text'>adding the Power Off option to the statusMenu in gnome-shell</title><content type='html'>&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;&lt;div dir=&quot;ltr&quot; style=&quot;text-align: left;&quot; trbidi=&quot;on&quot;&gt;The status menu, which is the dropdown menu to the right most corner on the top panel in gnome 3 contains the Suspend option. This is an alternating option, if you focus on the Suspend option and hit the &quot;Alt&quot; key, you will also see the &quot;Power Off&quot; option.&lt;br /&gt;
&lt;br /&gt;
But I wanted the &quot;Power Off&quot; option to be shown in all cases along with the Suspend option. Here is how I dissected the issue (for the facts, this is the first time I am even looking at gnome 3 code). &lt;br /&gt;
&lt;br /&gt;
1) Located the gnome-shell repository at &lt;a href=&quot;http://git.gnome.org/browse/gnome-shell/tree/&quot;&gt;http://git.gnome.org/browse/gnome-shell/tree/&lt;/a&gt;, searched for &quot;Suspend&quot; , and landed at the commit, &lt;a href=&quot;http://git.gnome.org/browse/gnome-shell/commit/?id=610c2b59872029bceb0279b24dc9637a85f54968&quot;&gt;http://git.gnome.org/browse/gnome-shell/commit/?id=610c2b59872029bceb0279b24dc9637a85f54968&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
2) Going through the above commit, figured out that the corresponding UI stuff is in &lt;a href=&quot;http://git.gnome.org/browse/gnome-shell/tree/js/ui/statusMenu.js&quot;&gt;http://git.gnome.org/browse/gnome-shell/tree/js/ui/statusMenu.js&lt;/a&gt;&lt;br /&gt;
&lt;br /&gt;
3) Cloned the gnome-shell repository. Edited the file gnome-shell/src/js/ui/statusMenu.js and made the following changes :&lt;br /&gt;
--&amp;gt; Made the Suspend option a non-alternating Menu item and display it only if we have suspend support.&lt;br /&gt;
--&amp;gt; Added the Power Off option as a new menu item and added a function which would be called when the option is activated. &lt;br /&gt;
&lt;br /&gt;
Voila , I now have the Power Off option as a separate option. Here are the before and after screenshots.&lt;br /&gt;
&lt;br /&gt;
&lt;div class=&quot;separator&quot; style=&quot;clear: both; text-align: center;&quot;&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7CxAmrl2FCOSgJMdb84Leo4jVnaubRLRxtNo3BfpKy8A_fnUkrNZE6LBK3er6J0p8862DgIf0eEJbyLQsddFPANLBXuGqBOgCiUsgkLOoSK6jWkRMqEiiKoal33_DhAV4Uk4KgxrHMX3z/s1600/upload1.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: left; float: left; margin-bottom: 1em; margin-right: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7CxAmrl2FCOSgJMdb84Leo4jVnaubRLRxtNo3BfpKy8A_fnUkrNZE6LBK3er6J0p8862DgIf0eEJbyLQsddFPANLBXuGqBOgCiUsgkLOoSK6jWkRMqEiiKoal33_DhAV4Uk4KgxrHMX3z/s320/upload1.png&quot; width=&quot;203&quot; /&gt;&lt;span class=&quot;Apple-style-span&quot; style=&quot;-webkit-text-decorations-in-effect: none; color: black;&quot;&gt;&lt;/span&gt;&lt;/a&gt;&lt;a href=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibwaYy4Qy6MyhDDBqBGfQBaG55J3JnUX5U0qXyx54up56_e4_XVJH4y1weFjltaIEfkefA7WN2bjxwGhZmP7q-VvOv5gzuwtj0NEhZwwa2xKQ8crcHJUf1uXFTJDJMIvUXj0U5uE8xq38G/s1600/upload2.png&quot; imageanchor=&quot;1&quot; style=&quot;clear: right; display: inline !important; margin-bottom: 1em; margin-left: 1em;&quot;&gt;&lt;img border=&quot;0&quot; height=&quot;320&quot; src=&quot;https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEibwaYy4Qy6MyhDDBqBGfQBaG55J3JnUX5U0qXyx54up56_e4_XVJH4y1weFjltaIEfkefA7WN2bjxwGhZmP7q-VvOv5gzuwtj0NEhZwwa2xKQ8crcHJUf1uXFTJDJMIvUXj0U5uE8xq38G/s320/upload2.png&quot; width=&quot;193&quot; /&gt;&lt;/a&gt;&lt;/div&gt;&lt;/div&gt;&lt;br /&gt;
The patch to the latest trunk of the gnome-shell repository which does this is &lt;a href=&quot;http://satisheerpini.net/misc/gnome-shell-add-poweroff-to-statusMenu.patch&quot;&gt;&lt;b&gt;here&lt;/b&gt;&lt;/a&gt;.&lt;br /&gt;
&lt;br /&gt;
For compiling the gnome-shell code once you have made the changes, follow the usual, &quot;configure&quot;, &quot;make&quot; steps and then run &quot;gnome-shell/src/gnome-shell --replace&quot; to use the newly compiled gnome-shell instead of your existing gnome-shell.&lt;br /&gt;
&lt;br /&gt;
This post is more aimed at providing a general flow for fixing issues, not really much in here.&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/6155743090027633641/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2011/06/adding-power-off-option-to-statusmenu.html#comment-form' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/6155743090027633641'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/6155743090027633641'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2011/06/adding-power-off-option-to-statusmenu.html' title='adding the Power Off option to the statusMenu in gnome-shell'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><media:thumbnail xmlns:media="http://search.yahoo.com/mrss/" url="https://blogger.googleusercontent.com/img/b/R29vZ2xl/AVvXsEj7CxAmrl2FCOSgJMdb84Leo4jVnaubRLRxtNo3BfpKy8A_fnUkrNZE6LBK3er6J0p8862DgIf0eEJbyLQsddFPANLBXuGqBOgCiUsgkLOoSK6jWkRMqEiiKoal33_DhAV4Uk4KgxrHMX3z/s72-c/upload1.png" height="72" width="72"/><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1507313692561905680.post-8948173663884605422</id><published>2011-06-03T01:52:00.000-07:00</published><updated>2011-06-03T01:55:39.960-07:00</updated><category scheme="http://www.blogger.com/atom/ns#" term="git"/><category scheme="http://www.blogger.com/atom/ns#" term="git-rebase"/><category scheme="http://www.blogger.com/atom/ns#" term="linux"/><category scheme="http://www.blogger.com/atom/ns#" term="patch"/><title type='text'>merging commits into a single patch with git-rebase</title><content type='html'>It is often the scenario that you have cloned a git repository and you have made some changes, now you cannot push to the repository and need to go through a reviewer, so you basically have to submit all your commits to the code as a single patch. Here is how :&lt;br /&gt;
&lt;br /&gt;
We are going to use the repository http://https://github.com/eerpini/git_demo all through the process as the remote repository. It only has a single file, README, and has just one commit with the default branch.&lt;br /&gt;
&lt;br /&gt;
1) Clone the repository : &lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
$ git clone git@github.com:eerpini/git_demo.git&lt;br /&gt;
&lt;/code&gt; &lt;br /&gt;
and then change into the directory git_demo.&lt;br /&gt;
&lt;br /&gt;
2) Add a new file :&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
$ touch new_file&lt;br /&gt;
$ echo &quot;Entering something into the new file&quot; &gt;&gt; new_file&lt;/code&gt;&lt;br /&gt;
&lt;br /&gt;
3) Since the new file is untracked, &quot;git status&quot; should show something like :&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
# On branch master&lt;br /&gt;
# Untracked files:&lt;br /&gt;
#   (use &quot;git add &lt;file&gt;...&quot; to include in what will be committed)&lt;br /&gt;
#&lt;br /&gt;
# new_file&lt;br /&gt;
nothing added to commit but untracked files present (use &quot;git add&quot; to track)&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
4) Add the file and commit :&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
$ git add new_file&lt;br /&gt;
$ git commit -a -m &quot;Adding a new file to the repository&quot;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
Note you can now get the change as a patch by doing &lt;code&gt;&quot;git format-patch -1 HEAD&quot;&lt;/code&gt;. But that is not our goal.&lt;br /&gt;
&lt;br /&gt;
5) Just like above lets commit some more changes(add another file for simplicity).&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
$ touch new_file_2&lt;br /&gt;
$ echo &quot;Entering something into the second new file&quot; &gt;&gt; new_file_2 &lt;br /&gt;
$ git add new_file_2 &lt;br /&gt;
$ git commit -a  -m &quot;Added the second file to the repository, this should be the second commit&quot;&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
6) Now we have two commits and &lt;code&gt;&quot;git status&quot;&lt;/code&gt; should show you this :&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
# On branch master&lt;br /&gt;
# Your branch is ahead of &#39;origin/master&#39; by 2 commits.&lt;br /&gt;
#&lt;br /&gt;
nothing to commit (working directory clean)&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
7)Now  if you want to submit all the changes you have made so far as a single patch, you need to first rebase the two commits into a single one. This is how you do it :&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
$ git rebase -i origin/master&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
This will show you the following text in your editor :&lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
pick d5d924c Adding a new file to the repository&lt;br /&gt;
pick c0883ac Added the second file to the repository, this should be the second commit&lt;br /&gt;
&lt;br /&gt;
# Rebase 879598c..c0883ac onto 879598c&lt;br /&gt;
#&lt;br /&gt;
# Commands:&lt;br /&gt;
#  p, pick = use commit&lt;br /&gt;
#  r, reword = use commit, but edit the commit message&lt;br /&gt;
#  e, edit = use commit, but stop for amending&lt;br /&gt;
#  s, squash = use commit, but meld into previous commit&lt;br /&gt;
#  f, fixup = like &quot;squash&quot;, but discard this commit&#39;s log message&lt;br /&gt;
#  x, exec = run command (the rest of the line) using shell&lt;br /&gt;
#&lt;br /&gt;
# If you remove a line here THAT COMMIT WILL BE LOST.&lt;br /&gt;
# However, if you remove everything, the rebase will be aborted.&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
Edit the  above text, basically changing the keywords from pick to something else. If you want only the commit message from one of them, change all the others to fixup or squash. I used squash  (edit as follows) : &lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
pick d5d924c Adding a new file to the repository&lt;br /&gt;
squash c0883ac Added the second file to the repository, this should be the second commit&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
Now you can see that both the commits have been combined into a single commit. You can check either using &lt;code&gt;&quot;git log&quot;&lt;/code&gt; or &lt;code&gt;&quot;git show HEAD&quot;&lt;/code&gt;. You can convert these changes into a single patch now using : &lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
$ git format-patch -1 HEAD&lt;br /&gt;
&lt;/code&gt;&lt;br /&gt;
In my case, this ended up being : &lt;br /&gt;
&lt;code&gt;&lt;br /&gt;
From 11d19a54021cccdf75e5f16d46eeff89c275be39 Mon Sep 17 00:00:00 2001&lt;br /&gt;
From: eerpini &lt;eerpini@gmail.com&gt;&lt;br /&gt;
Date: Fri, 3 Jun 2011 01:39:45 -0700&lt;br /&gt;
Subject: [PATCH] Adding a new file to the repository&lt;br /&gt;
&lt;br /&gt;
Added the second file to the repository, this should be the second commit&lt;br /&gt;
---&lt;br /&gt;
new_file   |    1 +&lt;br /&gt;
new_file_2 |    1 +&lt;br /&gt;
2 files changed, 2 insertions(+), 0 deletions(-)&lt;br /&gt;
create mode 100644 new_file&lt;br /&gt;
create mode 100644 new_file_2&lt;br /&gt;
&lt;br /&gt;
diff --git a/new_file b/new_file&lt;br /&gt;
new file mode 100644&lt;br /&gt;
index 0000000..e3c484b&lt;br /&gt;
--- /dev/null&lt;br /&gt;
+++ b/new_file&lt;br /&gt;
@@ -0,0 +1 @@&lt;br /&gt;
+Entering something into the new file&lt;br /&gt;
diff --git a/new_file_2 b/new_file_2&lt;br /&gt;
new file mode 100644&lt;br /&gt;
index 0000000..b4a1e8e&lt;br /&gt;
--- /dev/null&lt;br /&gt;
+++ b/new_file_2&lt;br /&gt;
@@ -0,0 +1 @@&lt;br /&gt;
+Entering something into the second new file&lt;br /&gt;
-- &lt;br /&gt;
1.7.5.2&lt;br /&gt;
&lt;/code&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.satisheerpini.net/feeds/8948173663884605422/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://blog.satisheerpini.net/2011/06/merging-commits-into-single-patch-with.html#comment-form' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/8948173663884605422'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1507313692561905680/posts/default/8948173663884605422'/><link rel='alternate' type='text/html' href='http://blog.satisheerpini.net/2011/06/merging-commits-into-single-patch-with.html' title='merging commits into a single patch with git-rebase'/><author><name>Satish</name><uri>http://www.blogger.com/profile/15880565251364737342</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='16' height='16' src='https://img1.blogblog.com/img/b16-rounded.gif'/></author><thr:total>1</thr:total></entry></feed>