<?xml version="1.0" encoding="UTF-8"?>
<rss version="2.0"
	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/"
	>

<channel>
	<title>coding &#187; gnu</title>
	<atom:link href="http://www.coding.com.br/category/gnu/feed/" rel="self" type="application/rss+xml" />
	<link>http://www.coding.com.br</link>
	<description>have you coded today?</description>
	<lastBuildDate>Thu, 18 Aug 2011 17:29:43 +0000</lastBuildDate>
	<generator>http://wordpress.org/?v=2.9.2</generator>
	<language>en</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
			<item>
		<title>avoid typos with dd wrapper</title>
		<link>http://www.coding.com.br/gnu/avoid-typos-with-dd-wrapper/</link>
		<comments>http://www.coding.com.br/gnu/avoid-typos-with-dd-wrapper/#comments</comments>
		<pubDate>Sat, 23 Jul 2011 18:08:30 +0000</pubDate>
		<dc:creator>Tiago Maluta</dc:creator>
				<category><![CDATA[gnu]]></category>
		<category><![CDATA[python]]></category>

		<guid isPermaLink="false">http://www.coding.com.br/?p=1732</guid>
		<description><![CDATA[When using dd it&#8217;s very common typos that f*ck your important data. I create this 5-minutes python code do wrapper dd and make my life more safe. The usage is simple, just a config file with partition(s) you should avoid. Suppose that you have 2 disks in your computer and want avoid playing both with [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">When using <a href="http://en.wikipedia.org/wiki/Dd_%28Unix%29" target="_blank">dd</a> it&#8217;s <em>very common</em> typos that f*ck your important data. I create this 5-minutes python code do wrapper dd and make my life more safe. The usage is simple, just a config file with partition(s) you should avoid. Suppose that you have 2 disks in your computer and want avoid playing both with dd.</p>
<p style="padding-left: 30px;">$ echo /dev/sda &gt; ~/.blocklist-dd<br />
$ echo /dev/sdb &gt;&gt; ~/.blocklist-dd</p>
<p style="text-align: justify;">Then run you dd wrapper, I choose call my code &#8220;cc&#8221; (near dd in keyboard layout) and associate in $PATH environment.</p>
<p style="padding-left: 30px;">$ wget https://raw.github.com/gist/1100234/b59055e9ab1e3db8ab9d8185287852330d30e777/cc<br />
$ chmod +x cc</p>
<p style="text-align: justify;">And use &#8220;dd&#8221; normally. Bellow we have a correct example to backup MBR. Since /dev/sda is on our blacklist you need  confirm the operation.</p>
<p style="padding-left: 30px;">$ <strong>cc if=/dev/sda of=mbr.img bs=1 count=512</strong><br />
ooops, you are associating a blocked device (/dev/sda) on dd, proceed? (Y/n)<br />
Y<br />
512+0 records in<br />
512+0 records out<br />
512 bytes (512 B) copied, 0.00221805 s, 231 kB/s</p>
<p style="text-align: justify;">Sometimes adding a layer of complexity sometimes could simplify your life.</p>
<p style="text-align: justify;">Code is <a href="https://gist.github.com/1100234" target="_blank">here</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coding.com.br/gnu/avoid-typos-with-dd-wrapper/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>spliting files with dd</title>
		<link>http://www.coding.com.br/gnu/spliting-files-with-dd/</link>
		<comments>http://www.coding.com.br/gnu/spliting-files-with-dd/#comments</comments>
		<pubDate>Sun, 17 Oct 2010 00:42:23 +0000</pubDate>
		<dc:creator>Tiago Maluta</dc:creator>
				<category><![CDATA[gnu]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.coding.com.br/?p=1473</guid>
		<description><![CDATA[It&#8217;s just in case that you don&#8217;t have* want use split&#8230; (that is much easy). Suppose that you have a 20MB ogv movie and you want split in four parts of 5MB. You can just do:
dd if=MOVIE.ogv of=pt1 bs=1M count=5
dd if=MOVIE.ogv of=pt2 bs=1M skip=5 count=5
dd if=MOVIE.ogv of=pt3 bs=1M skip=10 count=5
dd if=MOVIE.ogv of=pt4 bs=1M skip=15
To merge [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">It&#8217;s just in case that you don&#8217;t <span style="text-decoration: line-through;">have</span>* want use <a href="http://unixhelp.ed.ac.uk/CGI/man-cgi?split" target="_blank">split</a>&#8230; (that is much easy). Suppose that you have a 20MB ogv movie and you want split in four parts of 5MB. You can just do:</p>
<pre>dd if=MOVIE.ogv of=pt1 bs=1M count=5
dd if=MOVIE.ogv of=pt2 bs=1M skip=5 count=5
dd if=MOVIE.ogv of=pt3 bs=1M skip=10 count=5
dd if=MOVIE.ogv of=pt4 bs=1M skip=15</pre>
<p>To merge again&#8230;</p>
<pre>cp pt1 final.ogv # you can ommit this temporary file by using pt1 as final file
dd if=pt2 of=final.ogv bs=1M seek=5 count=5
dd if=pt3 of=final.ogv bs=1M seek=10 count=5
dd if=pt4 of=final.ogv bs=1M seek=15
</pre>
<p>After you can verify the integrity by using some hash generator, <em>md5sum</em> or <em>sha1sum</em> are examples.</p>
<p style="padding-left: 30px;">$ md5sum final.ogv MOVIE.ogv<br />
71ac8962779dcb733599dba1ce54d783  final.ogv<br />
71ac8962779dcb733599dba1ce54d783  MOVIE.ogv</p>
<p>* this will never happen since both <em>dd</em> and <em>split</em> are on <a href="http://www.gnu.org/software/coreutils/" target="_blank">coreutils</a> package.</p>
<p><strong>Code</strong></p>
<p>I wrote a simple proof-of-concept to demonstrate, just:</p>
<p style="text-align: center;"><code>$ git clone <a href="http://gist.github.com/630395" target="_blank">git://gist.github.com/630395.git</a> split-sh<br />
</code></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coding.com.br/gnu/spliting-files-with-dd/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>unnamed files</title>
		<link>http://www.coding.com.br/gnu/unnamed-files/</link>
		<comments>http://www.coding.com.br/gnu/unnamed-files/#comments</comments>
		<pubDate>Fri, 10 Sep 2010 00:18:02 +0000</pubDate>
		<dc:creator>Tiago Maluta</dc:creator>
				<category><![CDATA[gnu]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[shell]]></category>

		<guid isPermaLink="false">http://www.coding.com.br/?p=1449</guid>
		<description><![CDATA[
I&#8217;m a heavy user of command line interface and often named files without extension. This behavior forces me to use file utility every time I have doubts.
$ file stick-note1
stick-note1: ASCII text
When organizing my home/ I came across with many files like that, so I decided make this script to walk throughout files and check if it&#8217;s text file [...]]]></description>
			<content:encoded><![CDATA[<div>
<p style="text-align: justify;">I&#8217;m a heavy user of <em>command line interface </em>and often named files without extension. This behavior forces me to use <strong>file </strong>utility every time I have doubts.</p>
<div id="_mcePaste" style="padding-left: 30px; text-align: justify;">$ file stick-note1</div>
<div id="_mcePaste" style="padding-left: 30px;">stick-note1: ASCII text</div>
<p style="text-align: justify;">When organizing my <em>home/</em> I came across with many files like that, so I decided make this script to walk throughout files and check if it&#8217;s text file without extension and put .txt after.</p>
<p style="text-align: center;"><a href="http://gist.github.com/raw/572801/382091bf34aa449d8fc0e21a36d48a4a61b084ff/name.py" target="_blank">download script</a></p>
<p>$ python names.py<br />
This only change the file on current directory and it&#8217;s a &#8220;works for me&#8221; approach. Adapt to your needs.</p>
</div>
]]></content:encoded>
			<wfw:commentRss>http://www.coding.com.br/gnu/unnamed-files/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Convertendo videos do Youtube para audio (MP3)</title>
		<link>http://www.coding.com.br/gnu/convertendo-videos-do-youtube-para-audio-mp3/</link>
		<comments>http://www.coding.com.br/gnu/convertendo-videos-do-youtube-para-audio-mp3/#comments</comments>
		<pubDate>Sat, 16 Jan 2010 18:30:58 +0000</pubDate>
		<dc:creator>Tiago Maluta</dc:creator>
				<category><![CDATA[gnu]]></category>
		<category><![CDATA[lame]]></category>
		<category><![CDATA[linux]]></category>
		<category><![CDATA[mp3]]></category>
		<category><![CDATA[mplayer]]></category>
		<category><![CDATA[ogg]]></category>
		<category><![CDATA[youtube]]></category>

		<guid isPermaLink="false">http://www.coding.com.br/?p=487</guid>
		<description><![CDATA[Programas necessários:

Alguma distribuição GNU/Linux
mplayer
lame (caso queria converter para mp3)
vorbis-tools (caso queira converter para ogg)

Os videos do YouTube, normalmente qualquer conteúdo Flash, fica armazenados na pasta /tmp do sistema operacional na forma FlashXXXX (exemplo: FlashaOiW6k). Para cada arquivo flash existirá um arquivo correspondente, para descobrir de qual se trata utilize o mplayer, no console (cd /tmp):
mplayer FlashaOiW6k
Após [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: left;">Programas necessários:</p>
<ul>
<li>Alguma distribuição GNU/Linux</li>
<li><a href="http://www.mplayerhq.hu" target="_blank">mplayer</a></li>
<li><a title="Lame project" href="http://lame.sourceforge.net" target="_blank">lame</a> (caso queria converter para mp3)</li>
<li><a href="http://www.vorbis.com " target="_blank">vorbis-tools</a> (caso queira converter para ogg)</li>
</ul>
<p style="text-align: justify;">Os videos do YouTube, normalmente qualquer conteúdo Flash, fica armazenados na pasta <strong>/tmp</strong> do sistema operacional na forma FlashXXXX (exemplo: FlashaOiW6k). Para cada arquivo flash existirá um arquivo correspondente, para descobrir de qual se trata utilize o mplayer, no console (cd /tmp):</p>
<pre style="text-align: justify;">mplayer FlashaOiW6k</pre>
<p style="text-align: justify;">Após descobrir o arquivo, vamos primeiro converter o arquivo para <strong>wav </strong>e depois para algum formato mais compacto.</p>
<pre>mplayer FlashaOiW6k<span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px; "> -novideo -ao pcm:file=musica.wav</span></pre>
<p><span style="font-family: Consolas, Monaco, 'Courier New', Courier, monospace; line-height: 18px; font-size: 12px; white-space: pre; "><span style="font-family: Georgia, 'Times New Roman', 'Bitstream Charter', Times, serif; line-height: 19px; white-space: normal; font-size: 13px; ">Convertendo para <strong>mp3</strong>:</span></span></p>
<div id="_mcePaste" style="position: absolute; left: -10000px; top: 159px; width: 1px; height: 1px; overflow-x: hidden; overflow-y: hidden;">lame -V2 input.wav output.mp3</div>
<pre>lame -V2 musica.wav musica.mp3</pre>
<div></div>
<p>Ou <strong>ogg</strong>:</p>
<pre>oggenc musica.wav</pre>
<p>No final temos os seguintes tamanhos para cada arquivo, considerando uma música de 4 minutos.</p>
<ul>
<li>8.9M    FlashaOiW6k</li>
<li>21.0M    saida.wav</li>
<li>2.4M   saida.mp3</li>
<li>1.5M   saida.ogg</li>
</ul>
<p>Este procedimento provavelmente irá funcionar para qualquer conteúdo Flash (ex. outros sites de video) que fique armazenado na tmp.</p>
]]></content:encoded>
			<wfw:commentRss>http://www.coding.com.br/gnu/convertendo-videos-do-youtube-para-audio-mp3/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>Acessando o Gmail pelo Mutt</title>
		<link>http://www.coding.com.br/gnu/acessando-o-gmail-pelo-mutt/</link>
		<comments>http://www.coding.com.br/gnu/acessando-o-gmail-pelo-mutt/#comments</comments>
		<pubDate>Wed, 11 Nov 2009 16:59:15 +0000</pubDate>
		<dc:creator>Tiago Maluta</dc:creator>
				<category><![CDATA[gnu]]></category>
		<category><![CDATA[gmail]]></category>
		<category><![CDATA[mutt]]></category>

		<guid isPermaLink="false">http://www.coding.com.br/?p=391</guid>
		<description><![CDATA[Para acessar seus emails da conta do GMAIL no modo texto, utilizando o mutt,  adicione ao arquivo ~/.muttrc

set imap_user = "USERNAME@gmail.com"
set imap_pass = "PASSWORD"
set spoolfile = imaps://imap.gmail.com:993/INBOX
set folder = imaps://imap.gmail.com:993
set record="imaps://imap.gmail.com/[Gmail]/Sent Mail"
set postponed="imaps://imap.gmail.com/[Gmail]/Drafts"
set header_cache="~/.mutt/cache/headers"
set message_cachedir="~/.mutt/cache/bodies"
set certificate_file=~/.mutt/certificates

set move = no

set sort = 'threads'
set sort_aux = 'last-date-received'
set imap_check_subscribed

ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
ignore "Received:"
ignore "Return-Path"
ignore "MIME-Version"
ignore "X-Spam-Details"
ignore "Received-SPF"
ignore "List-Id"
ignore [...]]]></description>
			<content:encoded><![CDATA[<p style="text-align: justify;">Para acessar seus <em>emails</em> da conta do GMAIL no modo texto, utilizando o <a title="mutt website" href="http://www.mutt.org/" target="_blank">mutt</a>,  adicione ao arquivo ~/.muttrc</p>
<pre style="text-align: justify;">
set imap_user = "USERNAME@gmail.com"
set imap_pass = "PASSWORD"
set spoolfile = imaps://imap.gmail.com:993/INBOX
set folder = imaps://imap.gmail.com:993
set record="imaps://imap.gmail.com/[Gmail]/Sent Mail"
set postponed="imaps://imap.gmail.com/[Gmail]/Drafts"
set header_cache="~/.mutt/cache/headers"
set message_cachedir="~/.mutt/cache/bodies"
set certificate_file=~/.mutt/certificates

set move = no

set sort = 'threads'
set sort_aux = 'last-date-received'
set imap_check_subscribed

ignore "Authentication-Results:"
ignore "DomainKey-Signature:"
ignore "DKIM-Signature:"
ignore "Received:"
ignore "Return-Path"
ignore "MIME-Version"
ignore "X-Spam-Details"
ignore "Received-SPF"
ignore "List-Id"
ignore "List-Unsubscribe"
ignore "List-Post"
ignore "List-Help"
ignore "List-Subscribe"
ignore "Content-Type"
ignore "Content-Transfer-Encoding"
ignore "Sender"
ignore "Errors-To"
ignore "X-BeenThere"
ignore "X-Mailman-Version"
ignore "Precedence"
ignore "List-Archive"
ignore "X-MIME-Autoconverted"
ignore "Message-ID"
ignore "Delivered-To"
ignore "User-Agent"
ignore "X-Spam-Score"
ignore "X-Spam-OrigSender"
ignore "X-Spam-Bar"
ignore "In-Reply-To"
ignore "References"
ignore "X-System-Of-Record"

hdr_order Date From To Cc
</pre>
]]></content:encoded>
			<wfw:commentRss>http://www.coding.com.br/gnu/acessando-o-gmail-pelo-mutt/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Busca textual em arquivos</title>
		<link>http://www.coding.com.br/gnu/busca-textual-em-arquivos/</link>
		<comments>http://www.coding.com.br/gnu/busca-textual-em-arquivos/#comments</comments>
		<pubDate>Sun, 25 Oct 2009 15:53:50 +0000</pubDate>
		<dc:creator>Tiago Maluta</dc:creator>
				<category><![CDATA[gnu]]></category>

		<guid isPermaLink="false">http://www.coding.com.br/?p=329</guid>
		<description><![CDATA[Como resolver o problema de arquivos com espaço em branco na hora de fazer uma busca textual?
Qualquer uma das três formas funciona:

   1. find PATH -iname FILTRO -exec grep -n PALAVRA '{}' \; -print
   2. find PATH -iname FILTRO -exec grep -n PALAVRA /dev/null '{}' \;
   3. find PATH [...]]]></description>
			<content:encoded><![CDATA[<p>Como resolver o problema de arquivos com espaço em branco na hora de fazer uma busca textual?</p>
<p>Qualquer uma das três formas funciona:</p>
<pre>
   1. find PATH -iname FILTRO -exec grep -n PALAVRA '{}' \; -print
   2. find PATH -iname FILTRO -exec grep -n PALAVRA /dev/null '{}' \;
   3. find PATH -iname FILTRO -exec grep -Hn PALAVRA '{}' \;
</pre>
<p>Exemplo:</p>
<p>Vamos imaginar a seguinte hieraquia de pastas e arquivos:</p>
<p><a href="http://www.coding.com.br/wp-content/uploads/2009/10/tree.jpeg"><img src="http://www.coding.com.br/wp-content/uploads/2009/10/tree.jpeg" alt="" title="" width="321" height="465" class="aligncenter size-full wp-image-348" /></a><br />
De modo que o comando:</p>
<pre>
$ find . -iname "nome*"
</pre>
<p>Mostre todos os arquivos que começam com &#8220;nome&#8221;</p>
<p style="padding-left: 30px;">
<span style="color: #ff0000;"><br />
./c/c3/nome2 sobrenome2<br />
./c/c3/nome1 sobrenome1<br />
./b/b2/nome1 sobrenome1 final1<br />
./b/b3/nome2 sobrenome2<br />
./b/b1/nome1 sobrenome2 mais um pouco<br />
./a/a3/nome1 sobrenome1<br />
./a/a1/nome2 sobrenome3<br />
./a/a1/nome sobrenome<br />
./a/a1/nome1 sobrenome1<br />
</span>
</p>
<p>Para fazer a busca do algum texto dentro desses arquivos, poderiamos pensar algo como:</p>
<pre>
$ find . -iname "nome*" | xargs grep teste
</pre>
<p>Mas o espaço em branco iria atrapalhar a interpretação dos arquivos&#8230;</p>
<p style="padding-left: 30px;">
<span style="color: #ff0000;"><br />
grep: ./c/c3/nome2: No such file or directory<br />
grep: sobrenome2: No such file or directory<br />
grep: ./c/c3/nome1: No such file or directory<br />
grep: sobrenome1: No such file or directory<br />
</span>
</p>
<p style="padding-left: 30px;">
<span style="color: #ff0000;"><br />
		(&#8230;)<br />
</span>
</p>
<p style="padding-left: 30px;">
<span style="color: #ff0000;"><br />
grep: ./a/a1/nome1: No such file or directory<br />
grep: sobrenome1: No such file or directory<br />
</span>
</p>
<p>Uma das soluções está no próprio find:</p>
<pre>
$ find . -iname "nome*" -exec grep teste '{}' \;
</pre>
<p style="padding-left: 30px;">
<span style="color: #ff0000;"><br />
teste 123<br />
</span>
</p>
<p>Contudo, é importante saber o número da linha da ocorrência e o nome do arquivo, logo:</p>
<pre>
find . -iname "nome*" -exec grep -n teste '{}' \; -print
</pre>
<p style="padding-left: 30px;">
<span style="color: #ff0000;"><br />
1:teste 123<br />
./c/c3/nome2 sobrenome2<br />
</span></p>
]]></content:encoded>
			<wfw:commentRss>http://www.coding.com.br/gnu/busca-textual-em-arquivos/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
	</channel>
</rss>
<!-- WP Super Cache is installed but broken. The path to wp-cache-phase1.php in wp-content/advanced-cache.php must be fixed! -->
