<?xml version="1.0" encoding="UTF-8"?>
<?xml-stylesheet type="text/xsl" media="screen" href="/~d/styles/rss2full.xsl"?><?xml-stylesheet type="text/css" media="screen" href="http://feeds.feedburner.com/~d/styles/itemcontent.css"?><rss xmlns:content="http://purl.org/rss/1.0/modules/content/" xmlns:wfw="http://wellformedweb.org/CommentAPI/" xmlns:dc="http://purl.org/dc/elements/1.1/" xmlns:atom="http://www.w3.org/2005/Atom" xmlns:sy="http://purl.org/rss/1.0/modules/syndication/" xmlns:slash="http://purl.org/rss/1.0/modules/slash/" xmlns:feedburner="http://rssnamespace.org/feedburner/ext/1.0" version="2.0">

<channel>
	<title>commandliners</title>
	
	<link>http://commandliners.com</link>
	<description># killall -9 X</description>
	<lastBuildDate>Fri, 03 Sep 2010 22:46:39 +0000</lastBuildDate>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=abc</generator>
		<atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="self" type="application/rss+xml" href="http://feeds.feedburner.com/commandliners" /><feedburner:info uri="commandliners" /><atom10:link xmlns:atom10="http://www.w3.org/2005/Atom" rel="hub" href="http://pubsubhubbub.appspot.com/" /><item>
		<title>Vim. Key mapping</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/s-kd6dNUsY4/</link>
		<comments>http://commandliners.com/2010/09/vim-key-mapping/#comments</comments>
		<pubDate>Fri, 03 Sep 2010 22:46:39 +0000</pubDate>
		<dc:creator>n0str0m0</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[mapping]]></category>
		<category><![CDATA[vim]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=1958</guid>
		<description><![CDATA[Maps are a way to create an association between a set of key strokes and a set of actions. They are really powerful. However, in this post, I will not explain them in the deepest detail. If you need further information, you will need a good Vim manual. As it happens with abbreviations, maps can [...]]]></description>
			<content:encoded><![CDATA[<p>Maps are a way to create an association between a set of key strokes and a set of actions. They are really powerful. However, in this post, I will not explain them in the deepest detail. If you need further information, you will need a good Vim manual. As it happens with <a href="http://commandliners.com/2010/07/vim-saving-keystrokes-abbreviations/">abbreviations</a>, maps can be used regardless of the mode you are in Vim or they can be restricted to a certain operation mode. They work the same way in every mode. Type <code>:help :map</code> to know which map commands work in which mode.</p>
<p>First off,</p>
<pre><code>:map
...
...
&lt;Esc&gt;OM       &lt;CR&gt;
&lt;Esc&gt;Ol       ,
&lt;Esc&gt;Ok       +
&lt;Esc&gt;Om       -
&lt;Esc&gt;Oj       *
&lt;Esc&gt;Oo       :
&lt;F2&gt;          :sp ~/TODO&lt;CR&gt;Go* &lt;Esc&gt;&lt;Up&gt;&lt;Right&gt;&lt;CR&gt;
&lt;xHome&gt;       &lt;Home&gt;
&lt;xEnd&gt;        &lt;End&gt;
&lt;S-xF4&gt;       &lt;S-F4&gt;
&lt;S-xF3&gt;       &lt;S-F3&gt;
&lt;S-xF2&gt;       &lt;S-F2&gt;
&lt;S-xF1&gt;       &lt;S-F1&gt;
&lt;xF4&gt;         &lt;F4&gt;
&lt;xF3&gt;         &lt;F3&gt;
</code></pre>
<p>shows a list of available maps</p>
<p>Let us start with a small example:</p>
<pre><code>:map &lt;F2&gt; :r!ls ~/&lt;CR&gt;</code></pre>
<p>As you can see, maps are created very much like abbreviations.<br />
When you type F2, Vim executes the associated sequence for that key. It is important to use &lt;CR&gt; when you are using <code>:commands</code>. Otherwise, you will have to type <code>ENTER</code> yourself. The map above reads the content of the <code>ls ~/</code> command, i.e. it lists the <code>$HOME</code> directory.
<p>When you work with maps, you are not limited to commands. You can tell Vim to &#8220;simulate&#8221; certain keystrokes. For example, you might want to execute something like &#8220;After this, I would like to move the cursor to the left&#8221;. This can be done with the &#8220;&lt;&gt;&#8221; notation (<code>:help &lt;&gt;</code> for more information). The following map illustrates this concept:</p>
<pre><code>:map &lt;F2&gt; ifor(;;) {&lt;CR&gt;}&lt;Up&gt;&lt;Right&gt;&lt;Right&gt;&lt;Right&gt;</code></pre>
<p>Now, when pressing F2, the following text is inserted (the underscore represents the position of the cursor):</p>
<pre><code>for(_;;) {
}
</code></pre>
<p>Notice you are still in insert mode. We could have achieved something similar with the following map:</p>
<pre><code>:map &lt;F2&gt; ifor(;;) {&lt;CR&gt;}&lt;ESC&gt;kf;i</code></pre>
<p>I personally prefer the latter. In my opinion, working in command mode is cleaner.
<p>The following map is quite useful:</p>
<pre><code>:map &lt;F4&gt; I#include &lt;&lt;ESC&gt;A&gt;</code></pre>
<p>Let us analyze what that sequence does. First, it goes into command mode and places the cursor at the beginning of the line in insert mode. Then, it inserts the &#8220;#include &lt;&#8221; string. Finally, it adds &#8220;&gt;&#8221; at the end of the line.</p>
<p>Assuming you have a text like the following:</p>
<pre><code>stdio.h</code></pre>
<p>Placing the cursor on that line (at any column) and pressing F4 rewrites the line as follows:</p>
<pre><code>#include &lt;stdio.h&gt;</code></pre>
<p>Maps can deal with buffers, windows, tabs (from Vim 7 onwards) and such. Here is a small example. Suppose you have a <i>TODO</i> file in your <code>$HOME</code> directory. From time to time, while you are working, you want to add a new entry. Sounds reasonable, right?. Imagine we have a <i>TODO</i> file that looks like this:</p>
<pre><code>* Stuff
* Things
</code></pre>
<p>We could easily open the file and make it ready to write a new entry with a simple map:</p>
<pre><code>:map &lt;F2&gt; :sp ~/TODO&lt;CR&gt;Go* &lt;Esc&gt;a</code></pre>
<p>Let us explain what is going on here: We split the window horizontally, editing the TODO file at the same time (<code>:sp ~/TODO</code>). Then the cursor is placed at the end of the file. We open a new empty line and write a &#8220;* &#8221; (<i>Go* </i>). Finally, we leave the cursor in insert mode. This way we just have to type the thing we want to remember and then we can <code>:close</code> the top window.
<p>Another simple example:</p>
<pre><code>:map &lt;F6&gt; :w %.bakcup</code></pre>
<p>This saves the current buffer with the same name plus the &#8220;.backup&#8221; extension. The <em>%</em> is a special variable which contains the name of the current file.
<p>Finally, if you want to <i>delete</i> a map because it is no longer useful, you can <code>:unmap</code> it.
<p><u>Conclusion</u><br />
Maps are a very powerful tool. You can do almost anything you may need, no matter how complex it is. There are a lot of interesting macros on the Internet. I recommend you to search the web!</p>
<p><u>VIM SHEET (VIII)</u></p>
<ul>
<li><b>map</b> Map a key to a set of commands / List available maps
<li><b>unmap</b> Unmap key
</ul>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/s-kd6dNUsY4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2010/09/vim-key-mapping/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://commandliners.com/2010/09/vim-key-mapping/</feedburner:origLink></item>
		<item>
		<title>The Sibyl</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/7ezcNH1ctyM/</link>
		<comments>http://commandliners.com/2010/08/the-sibyl/#comments</comments>
		<pubDate>Wed, 04 Aug 2010 16:26:22 +0000</pubDate>
		<dc:creator>rafacas</dc:creator>
				<category><![CDATA[security]]></category>
		<category><![CDATA[bifferboard]]></category>
		<category><![CDATA[crypt]]></category>
		<category><![CDATA[OAEP]]></category>
		<category><![CDATA[RSA]]></category>
		<category><![CDATA[sha1]]></category>
		<category><![CDATA[shadow]]></category>
		<category><![CDATA[sibyl]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=1979</guid>
		<description><![CDATA[The Sibyl is a project invented and implemented by Pedro (pfortuny) and me (rafacas). Although I have to admit that it was Pedro&#8217;s idea. It started with the goal of secure storage of the shadow file and, in general, of any database of secret authentication tokens (think of passwords -actually hashes of passwords- of users [...]]]></description>
			<content:encoded><![CDATA[<p><a href="http://thesibyl.net">The Sibyl</a> is a project invented and implemented by <a href="http://pfortuny.net">Pedro</a> (<a href="http://commandliners.com/author/pfortuny">pfortuny</a>) and <a href="http://rafacas.net">me</a> (<a href="http://commandliners.com/author/rafacas">rafacas</a>). Although I have to admit that it was Pedro&#8217;s idea.</p>
<p>It started with the goal of secure storage of the shadow file and, in general, of any database of secret authentication tokens (think of passwords -actually hashes of passwords- of users of a Web-based service, for example). We consider it addresses the main concern on those databases: dictionary attacks and rainbow tables, which have become available at negligible cost: there is a cloud-based service <a href="http://www.schneier.com/blog/archives/2010/07/wpa_cracking_in.html">for doing dictionary attacks</a> on a WPA key.</p>
<p>Our approach for storing shadow files is to use a separate server for checking the correctness of the password introduced by the user, taking advantage of <a href="http://en.wikipedia.org/wiki/Asymmetric_key_encryption">asymmetric key encryption</a>.</p>
<p>Instead of keeping the hash (as crypt(3) does, or SHA1) of the password in the shadow file, we store an OAEP RSA-cyphertext of the hashed password (using a public encryption key) and, each time the user tries to log in, ask via TCP someone (the owner of the private key) if another OAEP-encryption of the hash of the password issued by the logging user matches the stored token. That is: use an&#8221;oracle&#8221; to check if the user has entered the correct password or not. This &#8220;oracle&#8221;, which is a standalone machine, is the <strong>Sibyl</strong> and the device we use to implement it is a <a href="http://bifferos.bizhat.com/">Bifferboard</a>.</p>
<p>The details are on <a href="http://thesibyl.net">the web of the Sibyl project</a>. We hope you like it and <strong>use</strong> it.</p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/7ezcNH1ctyM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2010/08/the-sibyl/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://commandliners.com/2010/08/the-sibyl/</feedburner:origLink></item>
		<item>
		<title>Vim. Saving keystrokes: abbreviations</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/5w97QVtiZO8/</link>
		<comments>http://commandliners.com/2010/07/vim-saving-keystrokes-abbreviations/#comments</comments>
		<pubDate>Fri, 30 Jul 2010 08:16:35 +0000</pubDate>
		<dc:creator>n0str0m0</dc:creator>
				<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=1949</guid>
		<description><![CDATA[Welcome to a new issue of this short Vim tutorial! As we saw in previous posts, Vim is the perfect tool if you want to save time in your daily work. It helps you in the write-compile-debug cycle, it indents and autoindents code, it is extremely powerful for searching, replacing and many other frequent tasks. [...]]]></description>
			<content:encoded><![CDATA[<p>Welcome to a new issue of this short Vim tutorial!</p>
<p>As we saw in previous posts, Vim is the perfect tool if you want to save time in your daily work. It helps you in the <a href="http://commandliners.com/2010/01/vim-for-programmers-ii/">write-compile-debug cycle</a>, it <a href="http://commandliners.com/2009/12/vim-for-programmers-i/">indents</a> and autoindents code, it is extremely powerful for searching, replacing and many other frequent tasks.</p>
<p>In this post I will introduce an interesting feature meant to make you type less: <strong>abbreviations</strong>.</p>
<p>Abbreviations are, as their name indicates, a way to create an association between a short set of characters and a piece of text (or a command).</p>
<p>Abbreviations can be used in <i>insert</i>, <i>replace</i> or <i>command</i> mode. The keywords used to work with abbreviations are all the same, but adding a proper prefix if necessary (<code>i</code> for insert mode, <code>c</code> for command mode and <code>!</code> for both).</p>
<pre><code>iab        Create abbreviation for theinsert mode
cab        Create abbreviation for the command mode
</code></pre>
<p>Recently, I had to write a dockbook template using perl and the <a href="http://www.perl.org/books/library.html#masonbook">Mason library</a> and found myself typing continuously the following thing:</p>
<pre><code>$data-&gt;[0]-&gt;{}</code></pre>
<p>and between the curly braces the hash key. After writing that twice I got bored of doing it (yep, I am a lazy guy) so I created the following abbreviation:</p>
<pre><code>iab dh $data-&gt;[0]-&gt;{!cursor!}:call search('!cursor!', 'b')cf!</code></pre>
<p>It associates the &#8220;dh&#8221; characters with the $data-&gt;[0]-&gt;{!cursor!}:call search(&#8216;!cursor!&#8217;, &#8216;b&#8217;)cf! string. This string writes &#8220;$data-&gt;[0]-&gt;{}&#8221; and places the cursor between the curly braces (do not worry about the &#8220;call search&#8221; stuff, the example could have been iab dh $data-&gt;[0]-&gt;{} ) By the way, abbreviations are not recursive, so you will never end up stuck in an infinite loop.</p>
<p>Since writing a tag-like document is a real pain, I decided to abbreviate some of the common tags I was using the most, so I created the following abbreviations:</p>
<pre><code>iab fp &lt;formalpara&gt;&lt;CR&gt;&lt;LF&gt;&lt;/formalpara&gt;
iab p &lt;para&gt;&lt;/para&gt;
iab il &lt;itemizedlist&gt;&lt;CR&gt;&lt;LF&gt;&lt;/itemizedlist&gt;
iab li &lt;listitem&gt;&lt;/listitem&gt;
iab e &lt;entry&gt;&lt;CR&gt;&lt;LF&gt;&lt;/entry&gt;
iab t &lt;title&gt;&lt;/title&gt;
iab it &lt;informaltable&gt;&lt;CR&gt;&lt;LF&gt;&lt;/informaltable&gt;
iab r &lt;row&gt;&lt;CR&gt;&lt;LF&gt;&lt;/row&gt;<tt><span style="font-size: x-small"></span></tt></code></pre>
<p><code>&lt;CR&gt;</code> and <code>&lt;LF&gt;</code> have the common meanings (Carriage Return and Line Feed respectively). They were very convenient. You can copy them to your <code>.vimrc</code> file.
<p>But what if you do not want an abbreviation to be expanded?
<p>Suppose we have the following abbreviation:</p>
<pre><code>iab to Total</code></pre>
<p>and we want to write the following sentence:</p>
<pre><code>"I went to Paris"</code></pre>
<p>As soon as you type the space after &#8220;to&#8221;, the abbreviation will be expanded and you will end up with:</p>
<pre><code>"I went Total "</code></pre>
<p>To avoid this problem, press <em>Ctrl-V</em> after the problematic abbreviation and then continue typing normally.</p>
<p>To disable an abbreviation permanently you can use &#8220;unabbreviate&#8221;. For instance:</p>
<pre><code>:unabbreviate dh</code></pre>
<p>&#8220;abbreviate&#8221; lists the current abbreviations. E.g:</p>
<pre><code>i  t             Total
i  b             back
</code></pre>
<p>The first column shows the mode in which the abbreviate is available, the second shows the abbreviation and the third one the text it expands to.</p>
<p>Abbreviations are a convenient way of saving some (or possibly a lot of) work, specially if it is repetitive.</p>
<p><u>Vim Sheet(VII)</u></p>
<ul>
<li><b>[i/c/!]ab</b> Create an abbreviation in the specified mode
<li><b>unabbreviate</b> Deletes an abbreviation
<li><b>abbreviate</b> List available abbreviations
</ul>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/5w97QVtiZO8" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2010/07/vim-saving-keystrokes-abbreviations/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://commandliners.com/2010/07/vim-saving-keystrokes-abbreviations/</feedburner:origLink></item>
		<item>
		<title>Which package does this file belong to?</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/Q0CFCvjlFJs/</link>
		<comments>http://commandliners.com/2010/07/which-package-does-this-file-belong-to/#comments</comments>
		<pubDate>Fri, 02 Jul 2010 22:01:38 +0000</pubDate>
		<dc:creator>n0str0m0</dc:creator>
				<category><![CDATA[cmd]]></category>
		<category><![CDATA[FreeBSD]]></category>
		<category><![CDATA[pkg_info]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=1937</guid>
		<description><![CDATA[On FreeBSD, we use the pkg_info command this way: $pkg_info -W /usr/local/bin/mysql /usr/local/bin/mysql was installed by package mysql-client-5.5.2 Enjoy!]]></description>
			<content:encoded><![CDATA[<p>On FreeBSD, we use the <code>pkg_info</code> command this way:</p>
<pre><code>$pkg_info -W /usr/local/bin/mysql
/usr/local/bin/mysql was installed by package mysql-client-5.5.2
</code></pre>
<p>Enjoy!</p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/Q0CFCvjlFJs" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2010/07/which-package-does-this-file-belong-to/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://commandliners.com/2010/07/which-package-does-this-file-belong-to/</feedburner:origLink></item>
		<item>
		<title>hex2bin preserving endianness in C</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/nFXufWxmts4/</link>
		<comments>http://commandliners.com/2010/06/hex2bin-preserving-endianness-in-c/#comments</comments>
		<pubDate>Fri, 11 Jun 2010 12:35:58 +0000</pubDate>
		<dc:creator>pfortuny</dc:creator>
				<category><![CDATA[automated]]></category>
		<category><![CDATA[C]]></category>
		<category><![CDATA[char]]></category>
		<category><![CDATA[conversion]]></category>
		<category><![CDATA[hex]]></category>
		<category><![CDATA[hex dump]]></category>
		<category><![CDATA[sha1]]></category>
		<category><![CDATA[string]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=1926</guid>
		<description><![CDATA[I cannot help copying this snippet. Assume f is a (char *) of length L, containing an hex string like '0aabdda' (without the leading &#8220;0x&#8221;, like something coming from a sha function &#8212;or like the sha1 stored by Leopard in the password files, which is the origin of this problem). You want to transform it [...]]]></description>
			<content:encoded><![CDATA[<p>I cannot help copying this snippet. Assume <code>f</code> is a <code>(char *)</code> of length <code>L</code>, containing an hex string like <code>'0aabdda'</code> (without the leading &#8220;0x&#8221;, like something coming from a sha function &#8212;or like the sha1 stored by Leopard in the password files, which is the origin of this problem). You want to transform it into the corresponding sequence of bytes (that is, assuming the string is of even length, otherwise, we add a trailing, yes, trailing, at the end, &#8217;0&#8242;). We shall store the result in <code>t</code>, which points to a <code>(char *)</code> of length <code>L/2</code>.</p>
<p>The following C code does the trick: (first of all we <strong>must</strong> set <code>t</code> to <code>0</code>);</p>
<pre><code>int k = (L%2 ? L/2+1 : L/2);
memset(t, 0, L/2);
for(i=0; i&lt;L; i++){
  t[i/2] += ((i%2) ? 1 : 16) *
    ((f[i] > 'F') ? (f[i] - 'a' + 10) :
      ((f[i] > '9') ? (f[i] - 'A' + 10) :
        (f[i] - '0')))
}
</code></pre>
<p>Thus, if <code>f</code> points to the string <code>100aff</code>, <code>t</code> points to the sequence of bytes <code>16, 10, 255</code> after the loop.</p>
<p>The reverse operation is well known:</p>
<pre><code>for(i=0; i&lt;k; i++){
  sprintf(f+2*i, "%02X", t[i]);
}
</code></pre>
<p>I just don&#8217;t want to forget it.</p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/nFXufWxmts4" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2010/06/hex2bin-preserving-endianness-in-c/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://commandliners.com/2010/06/hex2bin-preserving-endianness-in-c/</feedburner:origLink></item>
		<item>
		<title>echo -n woes</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/pk-3oNHXiDM/</link>
		<comments>http://commandliners.com/2010/05/echo-n-woes/#comments</comments>
		<pubDate>Thu, 20 May 2010 15:42:10 +0000</pubDate>
		<dc:creator>pfortuny</dc:creator>
				<category><![CDATA[scripts]]></category>
		<category><![CDATA[shell]]></category>
		<category><![CDATA[base64]]></category>
		<category><![CDATA[echo]]></category>
		<category><![CDATA[newline]]></category>
		<category><![CDATA[openssl]]></category>
		<category><![CDATA[pipe]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=1916</guid>
		<description><![CDATA[It took me quite a while to realize that the following line does not do what you think it does: $ echo '$1$CSmo96nX$G0PL/Cs/of5qDN2vMnyHp0' &#124; openssl base64 &#124; tr -d '\n' You should always use the -n option if you want to make sure there is no spurious trailing newline: $ echo -n '$1$CSmo96nX$G0PL/Cs/of5qDN2vMnyHp0' &#124; openssl [...]]]></description>
			<content:encoded><![CDATA[<p>It took me quite a while to realize that the following line does <strong>not</strong> do what you think it does:</p>
<pre><code>$ echo '$1$CSmo96nX$G0PL/Cs/of5qDN2vMnyHp0' | openssl base64 | tr -d '\n'</code></pre>
<p>You should <strong>always</strong> use the <code>-n</code> option if you want to make sure there is no spurious trailing newline:</p>
<pre><code>$ echo -n '$1$CSmo96nX$G0PL/Cs/of5qDN2vMnyHp0' | openssl base64 | tr -d '\n'</code></pre>
<p>(By the way, the encrypted message says just <code>'patata0'</code> and it is <strong>not</strong> my password).</p>
<p>Or&#8230; is it?</p>
<p>Tested on two Linux systems (Fedora &#038; Ubuntu) and one Snow Leopard.</p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/pk-3oNHXiDM" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2010/05/echo-n-woes/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		<feedburner:origLink>http://commandliners.com/2010/05/echo-n-woes/</feedburner:origLink></item>
		<item>
		<title>Setting variables in emacs at file header</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/iHETjX-co3M/</link>
		<comments>http://commandliners.com/2010/04/setting-variables-in-emacs-at-file-header/#comments</comments>
		<pubDate>Tue, 27 Apr 2010 07:00:08 +0000</pubDate>
		<dc:creator>pfortuny</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[LaTeX]]></category>
		<category><![CDATA[master file]]></category>
		<category><![CDATA[variables]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=1902</guid>
		<description><![CDATA[When editing LaTeX files, I usually call the master file of a project 00father.ltx for historical reasons. Moreover, the following line is part of my .emacs: (setq-default TeX-master "00father.ltx") because most of the time I am editing multifile projects. However, from time to time I need to write a single-file document and in this case, [...]]]></description>
			<content:encoded><![CDATA[<p>When editing LaTeX files, I usually call the master file of a project <tt>00father.ltx</tt> for historical reasons. Moreover, the following line is part of my <tt>.emacs</tt>:</p>
<pre><code>(setq-default TeX-master "00father.ltx")</code></pre>
<p>because most of the time I am editing multifile projects.</p>
<p>However, from time to time I need to write a single-file document and in this case, naming it <tt>00father.ltx</tt> is not <i>that</i> useful, and I do not want to have to set the <tt>master-file</tt> variable each time I load the file.</p>
<p>There is an easy way to get this done. Just include a line at the top of the file -as a comment in the appropriate language- setting the variables. The syntax is as follows (in C, for example):</p>
<pre><code>/* -*- variable1: value1; variable2: value2; -*- */</code></pre>
<p>I am giving two examples. The first one in C again. Assume this is the header of a file called <tt>trial.c</tt></p>
<pre><code>/* *-* tab-width: 8; column-number-mode: 1; fill-column: 80; -*- */</code></pre>
<p>The line tells emacs to set the length of a tab to 8 spaces (usual in BSD), to show the column number in the information line and to wrap lines (if wrapping -fill-mode- is set) at 80 characters.</p>
<p>For my LaTeX issue, the first line of a single-file document <tt>letter_to_my_friend.ltx</tt> goes as follows (notice the difference in the comment syntax):</p>
<pre><code>% -*- TeX-master: "letter_to_my_friend.ltx"; -*-</code></pre>
<p>I have checked and if your file is a shell script, which usually begins with</p>
<pre><code>#!/bin/sh</code></pre>
<p>(or some similar line), you can place the variable-setting line just afterwards.</p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/iHETjX-co3M" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2010/04/setting-variables-in-emacs-at-file-header/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://commandliners.com/2010/04/setting-variables-in-emacs-at-file-header/</feedburner:origLink></item>
		<item>
		<title>Reverting to a previous version with svn (rollback)</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/smqfSdFp51U/</link>
		<comments>http://commandliners.com/2010/04/reverting-to-a-previous-version-with-svn-rollback/#comments</comments>
		<pubDate>Thu, 22 Apr 2010 07:20:38 +0000</pubDate>
		<dc:creator>pfortuny</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[commit]]></category>
		<category><![CDATA[dry-run]]></category>
		<category><![CDATA[merge]]></category>
		<category><![CDATA[revert]]></category>
		<category><![CDATA[rollback]]></category>
		<category><![CDATA[svn]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=1893</guid>
		<description><![CDATA[To rollback (that is, revert to a previous version) some files/dirs&#8230; using subversion, you need as Aral Balkan explains to Merge the previous version Commit Like this (assumming you want to roll back from version 61 to 58): pera $ svn merge r61:58 https://my.project.at.sourceforge/svnroot/project/dir1/src/ [... output ...] pera $ svn ci -m "Reverted to version [...]]]></description>
			<content:encoded><![CDATA[<p>To rollback (that is, revert to a previous version) some files/dirs&#8230; using subversion, you need <a href="http://aralbalkan.com/1381">as Aral Balkan explains</a> to</p>
<ul>
<li> Merge the previous version
<li> Commit
</ul>
<p>Like this (assumming you want to roll back from version 61 to 58):</p>
<pre><code>pera $ svn merge r61:58 https://my.project.at.sourceforge/svnroot/project/dir1/src/
[... output ...]
pera $ svn ci -m "Reverted to version 58"
</code></pre>
<p>which is strange but works. Forget about the <i>revert</i> command, it has a different functionality.<br />
You may want to run</p>
<pre><code>pera $ svn merge --dry-run r61:58 ........
</code></pre>
<p>to check the changes which will take place before messing everything up.</p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/smqfSdFp51U" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2010/04/reverting-to-a-previous-version-with-svn-rollback/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		<feedburner:origLink>http://commandliners.com/2010/04/reverting-to-a-previous-version-with-svn-rollback/</feedburner:origLink></item>
		<item>
		<title>IPCS</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/JcV3tWRUTTw/</link>
		<comments>http://commandliners.com/2010/04/ipcs/#comments</comments>
		<pubDate>Thu, 15 Apr 2010 18:30:28 +0000</pubDate>
		<dc:creator>n0str0m0</dc:creator>
				<category><![CDATA[shell]]></category>
		<category><![CDATA[ipcs]]></category>
		<category><![CDATA[semaphore]]></category>
		<category><![CDATA[system V]]></category>
		<category><![CDATA[sysv]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=1880</guid>
		<description><![CDATA[ipcs shows the status of SYSV inter process communication facilities. $ ipcs -s ------ Semaphore Arrays -------- key semid owner perms nsems 0xdd3adabd 0 fernape 600 1 I had forgotten about this command but I remembered it when we ran out of semaphores in our Linux system two days ago. Other way of getting the [...]]]></description>
			<content:encoded><![CDATA[<p><code>ipcs</code> shows the status of SYSV inter process communication facilities.</p>
<pre><code>$ ipcs -s

------ Semaphore Arrays --------
key        semid      owner      perms      nsems
0xdd3adabd 0          fernape    600        1         

</code></pre>
<p>I had forgotten about this command but I remembered it when we ran out of semaphores in our Linux system two days ago.</p>
<p>Other way of getting the same information is to <code>cat</code> the following files:</p>
<pre><code>$ ls /proc/sysvipc
msg        sem        shm
</code></pre>
<p>Enjoy!</p>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/JcV3tWRUTTw" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2010/04/ipcs/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://commandliners.com/2010/04/ipcs/</feedburner:origLink></item>
		<item>
		<title>Setting a Timer</title>
		<link>http://feedproxy.google.com/~r/commandliners/~3/8HIbPzohSvY/</link>
		<comments>http://commandliners.com/2010/04/setting-a-timer/#comments</comments>
		<pubDate>Wed, 07 Apr 2010 07:55:04 +0000</pubDate>
		<dc:creator>rafacas</dc:creator>
				<category><![CDATA[scripts]]></category>
		<category><![CDATA[basename]]></category>
		<category><![CDATA[beep]]></category>
		<category><![CDATA[countdown]]></category>
		<category><![CDATA[exit]]></category>
		<category><![CDATA[if]]></category>
		<category><![CDATA[IFS]]></category>
		<category><![CDATA[POSIX]]></category>
		<category><![CDATA[printf]]></category>
		<category><![CDATA[say]]></category>
		<category><![CDATA[set]]></category>
		<category><![CDATA[sleep]]></category>
		<category><![CDATA[wait]]></category>
		<category><![CDATA[while]]></category>

		<guid isPermaLink="false">http://commandliners.com/?p=1865</guid>
		<description><![CDATA[Sometimes I need a timer to focus on something and to alert me when to stop. Remember, we are real commandliners, so we do not want those fancy applications with a lot of features, we need a script ;-) so here it is: #!/bin/bash usage() { name=`basename $0` echo "Usage: $name hh:mm:ss" echo "Example: $name [...]]]></description>
			<content:encoded><![CDATA[<p>Sometimes I need a timer to focus on something and to alert me when to stop. Remember, we are real commandliners, so we do not want those fancy applications with a lot of features, we <strong>need</strong> a script ;-) so here it is:</p>
<pre><code>#!/bin/bash

usage() {
  name=`basename $0`
  echo "Usage: $name hh:mm:ss"
  echo "Example: $name \"00:15:30\""
}

if [ $# != 1 ]
then
  usage
  exit
fi

IFS=:
set -- $*
secs=$(( ${1#0} * 3600 + ${2#0} * 60 + ${3#0} ))
while [ $secs -gt 0 ]
do
  sleep 1 &#038;
  printf "\r%02d:%02d:%02d" $((secs/3600)) $(((secs/60)%60)) $((secs%60))
  secs=$(( $secs - 1 ))
  wait
done
echo
</code></pre>
<p>It works in any POSIX shell.</p>
<p>I was writing one but I found <a href="http://www.unix.com/shell-programming-scripting/98889-display-runnning-countdown-bash-script.html">this thread of the UNIX and linux forum</a> where the user cfajohnson solves it in a better way.</p>
<p>The code:</p>
<pre><code>sleep 1 &#038;
...
wait
</code></pre>
<p>minimizes the skew of the loop, so every cycle is as close to 1 second as possible.</p>
<p>I have not included the final <em>beep</em> in the script. You can do it with the usual:</p>
<pre><code>printf ("\a")</code></pre>
<p>which works on all unix-like systems.</p>
<p>In linux you can use the <code>beep</code> command that allows you to control pitch, duration, and repetitions, for example:</p>
<pre><code>$ beep -f 300.7 -r 2 -d 100 -l 400</code></pre>
<p>makes 2 repetitions of a beep at 300.7 Hz for 400 milliseconds and a delay between repetitions of 100 milliseconds.</p>
<p>In OS X you can play with the <code><a href="http://commandliners.com/tag/say/">say</a></code> command:</p>
<pre><code>$ say "You deserve some rest"</code></pre>
<img src="http://feeds.feedburner.com/~r/commandliners/~4/8HIbPzohSvY" height="1" width="1"/>]]></content:encoded>
			<wfw:commentRss>http://commandliners.com/2010/04/setting-a-timer/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		<feedburner:origLink>http://commandliners.com/2010/04/setting-a-timer/</feedburner:origLink></item>
	</channel>
</rss><!-- Dynamic Page Served (once) in 0.369 seconds -->
