<?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>{Dev Tricks}</title>
	<atom:link href="http://dev-tricks.net/feed" rel="self" type="application/rss+xml" />
	<link>http://dev-tricks.net</link>
	<description>Blogging developper tips and tricks</description>
	<lastBuildDate>Thu, 17 May 2012 13:09:44 +0000</lastBuildDate>
	<language>en-US</language>
	<sy:updatePeriod>hourly</sy:updatePeriod>
	<sy:updateFrequency>1</sy:updateFrequency>
	<generator>http://wordpress.org/?v=3.5.1</generator>
		<item>
		<title>How to check if a string is valid utf-8</title>
		<link>http://dev-tricks.net/check-if-a-string-is-valid-utf8</link>
		<comments>http://dev-tricks.net/check-if-a-string-is-valid-utf8#comments</comments>
		<pubDate>Thu, 17 May 2012 13:09:44 +0000</pubDate>
		<dc:creator>Julien Palard</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://dev-tricks.net/?p=387</guid>
		<description><![CDATA[Every day (at least) I&#8217;m facing a problem: how to check if a string is valid in utf-8 ? So I wrote a little C program, that I put on my github. Just be aware that pure ASCII is valid &#8230; <a href="http://dev-tricks.net/check-if-a-string-is-valid-utf8">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Every day (at least) I&#8217;m facing a problem: how to check if a string is valid in utf-8 ?<br />
So I wrote <a href="https://github.com/JulienPalard/is_utf8" title="is_utf8" target="_blank">a little C program, that I put on my github</a>. Just be aware that pure ASCII is valid UTF-8 and that&#8217;s not a bug: my program is checking if a string is valid utf-8, not if the string is in utf-8.</p>
<p>Enjoy :-)</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tricks.net/check-if-a-string-is-valid-utf8/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>emacs: standard input is not a tty</title>
		<link>http://dev-tricks.net/emacs-standard-input-is-not-a-tty</link>
		<comments>http://dev-tricks.net/emacs-standard-input-is-not-a-tty#comments</comments>
		<pubDate>Sun, 11 Dec 2011 11:54:02 +0000</pubDate>
		<dc:creator>Julien Palard</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://dev-tricks.net/?p=377</guid>
		<description><![CDATA[Did you ever tried something like : $ find -name '*.c' &#124; xargs emacs or $ grep -rl snmp . &#124; xargs emacs and got the error &#8220;emacs: standard input is not a tty&#8221; ? That&#8217;s normal, as the stdin &#8230; <a href="http://dev-tricks.net/emacs-standard-input-is-not-a-tty">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Did you ever tried something like :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;">$ <span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.c'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> emacs
or
$ <span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-rl</span> snmp . <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> emacs</pre></td></tr></table></div>

<p>and got the error &#8220;emacs: standard input is not a tty&#8221; ?</p>
<p>That&#8217;s normal, as the stdin for emacs is here the pipe, not your tty, you need a workaround to leave the normal stdin to your emacs.</p>
<p>There are different approches, the one I used for a long time was a command substitution :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>emacs $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.c'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></td></tr></table></div>

<p>But other approches exists, redirecting /dev/tty to emacs&#8217; stdin :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">find</span> <span style="color: #660033;">-name</span> <span style="color: #ff0000;">'*.c'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">xargs</span> <span style="color: #c20cb9; font-weight: bold;">sh</span> <span style="color: #660033;">-c</span> <span style="color: #ff0000;">'emacs &quot;$@&quot; &lt; /dev/tty'</span> emacs</pre></td></tr></table></div>

<p>And if you are searching for a specific pattern with grep, you should want to jump directly to the right line using the &#8216;+line file&#8217; syntax of emacs, and the shell substitution :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span>emacs $<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-rn</span> snmp services<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">'s/([^:]*):([0-9]*):.*/+\2 \1/g'</span><span style="color: #7a0874; font-weight: bold;">&#41;</span></pre></td></tr></table></div>

<p>It&#8217;s good while having only one occurence of the pattern in each file, but if many occurences exists, the file is oppened only once, with a while you can open one emacs for each occurence of the searched pattern and the /dev/tty redirection :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666;">$ </span><span style="color: #c20cb9; font-weight: bold;">grep</span> <span style="color: #660033;">-rn</span> snmp services<span style="color: #000000; font-weight: bold;">/</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #c20cb9; font-weight: bold;">sed</span> <span style="color: #660033;">-r</span> <span style="color: #ff0000;">'s/([^:]*):([0-9]*):.*/+\2 \1/g'</span> <span style="color: #000000; font-weight: bold;">|</span> <span style="color: #000000; font-weight: bold;">while</span> <span style="color: #c20cb9; font-weight: bold;">read</span> line <span style="color: #c20cb9; font-weight: bold;">file</span>; <span style="color: #000000; font-weight: bold;">do</span> emacs <span style="color: #007800;">$line</span> <span style="color: #007800;">$file</span> <span style="color: #000000; font-weight: bold;">&lt;</span> <span style="color: #000000; font-weight: bold;">/</span>dev<span style="color: #000000; font-weight: bold;">/</span>tty; <span style="color: #000000; font-weight: bold;">done</span></pre></td></tr></table></div>

]]></content:encoded>
			<wfw:commentRss>http://dev-tricks.net/emacs-standard-input-is-not-a-tty/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>Automating GNU screen startup</title>
		<link>http://dev-tricks.net/automating-gnu-screen-startup</link>
		<comments>http://dev-tricks.net/automating-gnu-screen-startup#comments</comments>
		<pubDate>Thu, 17 Nov 2011 22:13:58 +0000</pubDate>
		<dc:creator>Julien Palard</dc:creator>
				<category><![CDATA[Code]]></category>

		<guid isPermaLink="false">http://dev-tricks.net/?p=367</guid>
		<description><![CDATA[At work I use GNU screen with one window per server (ssh connection), and when I loose my screen, it takes minutes to rebuild the naming and the ssh connections &#8230; So I searched and found a PHP version on &#8230; <a href="http://dev-tricks.net/automating-gnu-screen-startup">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>At work I use GNU screen with one window per server (ssh connection), and when I loose my screen, it takes minutes to rebuild the naming and the ssh connections &#8230;</p>
<p>So I searched and found a PHP version on <a href="http://snowulf.com/2011/09/13/automated-screen-launch/">Jon&#8217;s blog</a> but I don&#8217;t like PHP and don&#8217;t want a PHP cli on my machine (even to start screen !)</p>
<p>So I rewrote it in bash (not sh, bash, to have brace expansion !)</p>
<p>Enjoy :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash -f</span>
&nbsp;
<span style="color: #007800;">SCREEN_NAME</span>=julien
<span style="color: #007800;">SERVERS</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">echo</span> <span style="color: #7a0874; font-weight: bold;">&#123;</span>julien,root<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #000000; font-weight: bold;">@</span>dev root<span style="color: #000000; font-weight: bold;">@</span><span style="color: #7a0874; font-weight: bold;">&#123;</span>www,sql<span style="color: #7a0874; font-weight: bold;">&#125;</span><span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">1</span>,<span style="color: #000000;">2</span><span style="color: #7a0874; font-weight: bold;">&#125;</span> root<span style="color: #000000; font-weight: bold;">@</span>media<span style="color: #7a0874; font-weight: bold;">&#123;</span><span style="color: #000000;">1</span>,<span style="color: #000000;">2</span>,<span style="color: #000000;">3</span>,<span style="color: #000000;">4</span>,<span style="color: #000000;">5</span>,<span style="color: #000000;">6</span><span style="color: #7a0874; font-weight: bold;">&#125;</span>
&nbsp;
&nbsp;
&nbsp;
&nbsp;
<span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-dmS</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$SCREEN_NAME</span>&quot;</span>
<span style="color: #007800;">NUM</span>=<span style="color: #000000;">0</span>
<span style="color: #000000; font-weight: bold;">for</span> SERVER <span style="color: #000000; font-weight: bold;">in</span> <span style="color: #007800;">$SERVERS</span>
<span style="color: #000000; font-weight: bold;">do</span>
    <span style="color: #007800;">NUM</span>=$<span style="color: #7a0874; font-weight: bold;">&#40;</span><span style="color: #7a0874; font-weight: bold;">&#40;</span>NUM + <span style="color: #000000;">1</span><span style="color: #7a0874; font-weight: bold;">&#41;</span><span style="color: #7a0874; font-weight: bold;">&#41;</span>
    <span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-S</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$SCREEN_NAME</span>&quot;</span> <span style="color: #660033;">-X</span> <span style="color: #c20cb9; font-weight: bold;">screen</span>
    <span style="color: #000000; font-weight: bold;">if</span> <span style="color: #7a0874; font-weight: bold;">&#91;</span> z<span style="color: #ff0000;">&quot;<span style="color: #007800;">$SERVER</span>&quot;</span> <span style="color: #000000; font-weight: bold;">!</span>= z<span style="color: #ff0000;">&quot;&quot;</span> <span style="color: #7a0874; font-weight: bold;">&#93;</span>
    <span style="color: #000000; font-weight: bold;">then</span>
        <span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-S</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$SCREEN_NAME</span>&quot;</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$NUM</span> <span style="color: #660033;">-X</span> title <span style="color: #ff0000;">&quot;<span style="color: #007800;">$SERVER</span>&quot;</span>
        <span style="color: #c20cb9; font-weight: bold;">screen</span> <span style="color: #660033;">-S</span> <span style="color: #ff0000;">&quot;<span style="color: #007800;">$SCREEN_NAME</span>&quot;</span> <span style="color: #660033;">-p</span> <span style="color: #007800;">$NUM</span> <span style="color: #660033;">-X</span> stuff <span style="color: #ff0000;">&quot;ssh <span style="color: #007800;">$SERVER</span> <span style="color: #007800;">$(printf \\r)</span>&quot;</span>
    <span style="color: #000000; font-weight: bold;">fi</span>
<span style="color: #000000; font-weight: bold;">done</span>
<span style="color: #7a0874; font-weight: bold;">printf</span> <span style="color: #ff0000;">&quot;Done,  now you can join your screen with :<span style="color: #000099; font-weight: bold;">\n</span>&quot;</span>
<span style="color: #7a0874; font-weight: bold;">printf</span> <span style="color: #ff0000;">&quot;$ screen -dr -S <span style="color: #007800;">$SCREEN_NAME</span><span style="color: #000099; font-weight: bold;">\n</span>&quot;</span></pre></td></tr></table></div>

<p>Don&#8217;t forgot to start your ssh-agent just before starting this script !</p>
<p>PS : If you don&#8217;t have a ssh-agent, you may want to remove the  $(printf \\r) and press enter yourself.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tricks.net/automating-gnu-screen-startup/feed</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>ashttp: vt100 screen scraping exported over HTTP</title>
		<link>http://dev-tricks.net/ashttp-vt100-screen-scraping-exported-over-http</link>
		<comments>http://dev-tricks.net/ashttp-vt100-screen-scraping-exported-over-http#comments</comments>
		<pubDate>Sat, 27 Aug 2011 13:08:21 +0000</pubDate>
		<dc:creator>Julien Palard</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Python]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://dev-tricks.net/?p=358</guid>
		<description><![CDATA[Originally wrote for logtop I just wrote a vt100 screen scraper that listen to a port and serve the screen over HTTP. Basically, you want a `top` (or logtop ;-) ) to be displayed in your website back office ? &#8230; <a href="http://dev-tricks.net/ashttp-vt100-screen-scraping-exported-over-http">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Originally wrote for <a href="https://github.com/JulienPalard/logtop" title="https://github.com/JulienPalard/logtop">logtop</a> I just wrote a vt100 screen scraper that listen to a port and serve the screen over HTTP.</p>
<p>Basically, you want a `top` (or logtop ;-) ) to be displayed in your website back office ? But top outputs in your terminal and you don&#8217;t know how to capture it ? Use ashttp, like this :</p>
<pre lang=bash>
$ ashttp -p 8080 top
</pre>
<p>And then just open the port 8080 with an HTTP client and enjoy (typing some F5&#8230;) :</p>
<p><img src="http://dev-tricks.net/wp-content/uploads/2011/08/ashttp1.png" alt="" title="ashttp-capture" width="668" height="424" class="aligncenter size-full wp-image-362" /></p>
<p>You can find the code on <a href="https://github.com/JulienPalard/ashttp" title="https://github.com/JulienPalard/ashttp"> my github</a>.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tricks.net/ashttp-vt100-screen-scraping-exported-over-http/feed</wfw:commentRss>
		<slash:comments>3</slash:comments>
		</item>
		<item>
		<title>squid: (101) Network is unreachable when DNS returns IPv6</title>
		<link>http://dev-tricks.net/squid-101-network-is-unreachable-when-dns-returns-ipv6</link>
		<comments>http://dev-tricks.net/squid-101-network-is-unreachable-when-dns-returns-ipv6#comments</comments>
		<pubDate>Fri, 24 Jun 2011 15:32:38 +0000</pubDate>
		<dc:creator>Julien Palard</dc:creator>
				<category><![CDATA[Sysadmin]]></category>

		<guid isPermaLink="false">http://dev-tricks.net/?p=353</guid>
		<description><![CDATA[If you have a Squid proxy configured on a machine that have no IPv6 access, and try to reach an IPv6 powered site, you squid will try to reach the site using IPv6 (I use squid 3.1.6 from Debian Squeeze) &#8230; <a href="http://dev-tricks.net/squid-101-network-is-unreachable-when-dns-returns-ipv6">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>If you have a Squid proxy configured on a machine that have no IPv6 access, and try to reach an IPv6 powered site, you squid will try to reach the site using IPv6 (I use squid 3.1.6 from Debian Squeeze) and will fail without failover, displaying a beautiful : (101) Network is unreachable.</p>
<p>The ONLY trick I found to force squid to use IPv4 (After disabling IPv6 on the interface, after disabling IPv6 in the kernel that leads to nothing better&#8230;) is :</p>
<p><code><br />
tcp_outgoing_address [YOUR PUBLIC IP HERE]<br />
</code></p>
<p>And can enjoy again living on you old IPv4 network !</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tricks.net/squid-101-network-is-unreachable-when-dns-returns-ipv6/feed</wfw:commentRss>
		<slash:comments>9</slash:comments>
		</item>
		<item>
		<title>emacs: Highlighting errors for c, python, and other languages</title>
		<link>http://dev-tricks.net/emacs-syntax-error-highlighting</link>
		<comments>http://dev-tricks.net/emacs-syntax-error-highlighting#comments</comments>
		<pubDate>Sat, 11 Jun 2011 11:54:12 +0000</pubDate>
		<dc:creator>Julien Palard</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[emacs]]></category>
		<category><![CDATA[Python]]></category>

		<guid isPermaLink="false">http://dev-tricks.net/?p=343</guid>
		<description><![CDATA[Hi ! Today we&#8217;ll see how to highlight syntax errors in emacs, with exemples for C and Python. First you should learn about flymake-mode here : http://www.emacswiki.org/emacs/FlyMake In a nutshell Flymake is a minor mode to perform on the fly &#8230; <a href="http://dev-tricks.net/emacs-syntax-error-highlighting">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Hi ! Today we&#8217;ll see how to highlight syntax errors in emacs, with exemples for C and Python.</p>
<p>First you should learn about flymake-mode here : <a href="http://www.emacswiki.org/emacs/FlyMake">http://www.emacswiki.org/emacs/FlyMake</a><br />
In a nutshell Flymake is a minor mode to perform on the fly checks on your files. It can run any external syntax checker by different means, I let you check out the documentation.</p>
<p>Quick and easy setup to highlight C syntax :<br />
You already have a Makefile, that&#8217;s good, so you just have to add a new rule to your Makefile, named &#8216;check-syntax&#8217; :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="make" style="font-family:monospace;">check<span style="color: #004400;">-</span>syntax<span style="color: #004400;">:</span>
    gcc <span style="color: #004400;">-</span>o <span style="color: #004400;">/</span>dev<span style="color: #004400;">/</span>null <span style="color: #004400;">-</span>D<span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">DEFINE</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">$</span><span style="color: #004400;">&#40;</span><span style="color: #000088;">CFLAGS</span><span style="color: #004400;">&#41;</span> <span style="color: #004400;">-</span>S <span style="color: #004400;">$</span><span style="color: #004400;">&#123;</span><span style="color: #000088;">CHK_SOURCES</span><span style="color: #004400;">&#125;</span></pre></td></tr></table></div>

<p>You can fix my -D$(DEFINE) $(CFLAGS) to match your compile options &#8230;<br />
Then open a .c file in your project, and if you .emacs file don&#8217;t automatically start flymake-mode, type &#8216;M-x flymake-mode&#8217; and enjoy error highlighting !</p>
<p>Next trick is, if you&#8217;re using a non graphical emacs, you don&#8217;t have, by default, the error message, so i&#8217;s a bit anying&#8230;<br />
So you&#8217;ll add some lines in you .emacs and a file in you .emacs.d<br />
First, download flymake-cursor.el here http://www.emacswiki.org/emacs/download/flymake-cursor.el and put it in your ~/.emacs.d/<br />
Then in your .emacs, add :</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #66cc66;">&#40;</span>require 'cl<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>require 'flymake-cursor<span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>Now, when you stop your cursor on an error, the message should appear in the minibuffer.</p>
<p>Last trick, for Python developers, how to use flymake-mode with pyflakes ?<br />
Just add this to you .emacs file, and tweak it if you want. You should install pyflakes in order to make it work.</p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="lisp" style="font-family:monospace;"><span style="color: #808080; font-style: italic;">;; aptitude install pyflakes to check python code                                                                                                                                  </span>
<span style="color: #66cc66;">&#40;</span>require 'flymake-cursor<span style="color: #66cc66;">&#41;</span>
<span style="color: #66cc66;">&#40;</span>global-set-key <span style="color: #66cc66;">&#91;</span>f4<span style="color: #66cc66;">&#93;</span> 'flymake-goto-next-<span style="color: #b1b100;">error</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">when</span> <span style="color: #66cc66;">&#40;</span>load <span style="color: #ff0000;">&quot;flymake&quot;</span> t<span style="color: #66cc66;">&#41;</span>
  <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">defun</span> flymake-pyflakes-init <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#41;</span>
    <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">let</span>* <span style="color: #66cc66;">&#40;</span><span style="color: #66cc66;">&#40;</span>temp-file <span style="color: #66cc66;">&#40;</span>flymake-init-create-temp-buffer-copy
                       'flymake-create-temp-inplace<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
           <span style="color: #66cc66;">&#40;</span>local-file <span style="color: #66cc66;">&#40;</span>file-relative-<span style="color: #b1b100;">name</span>
                        temp-file
                        <span style="color: #66cc66;">&#40;</span>file-name-directory buffer-file-<span style="color: #b1b100;">name</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
      <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">list</span> <span style="color: #ff0000;">&quot;pyflakes&quot;</span> <span style="color: #66cc66;">&#40;</span><span style="color: #b1b100;">list</span> local-file<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
  <span style="color: #66cc66;">&#40;</span>add-to-<span style="color: #b1b100;">list</span> 'flymake-allowed-file-name-masks
               '<span style="color: #66cc66;">&#40;</span><span style="color: #ff0000;">&quot;<span style="color: #000099; font-weight: bold;">\\</span>.py<span style="color: #000099; font-weight: bold;">\\</span>'&quot;</span> flymake-pyflakes-init<span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span><span style="color: #66cc66;">&#41;</span>
&nbsp;
<span style="color: #66cc66;">&#40;</span>add-hook 'find-file-hook 'flymake-find-file-hook<span style="color: #66cc66;">&#41;</span></pre></td></tr></table></div>

<p>Bonus trick you should try :<br />
Replace &#8220;pyflakes&#8221; in (list &#8220;pyflakes&#8221; (list local-file)))) to a shell script of you own, running pyflakes, pep8, etc&#8230;as I just found here :<br />
<a href="http://stackoverflow.com/questions/1259873/how-can-i-use-emacs-flymake-mode-for-python-with-pyflakes-and-pylint-checking-cod">http://stackoverflow.com/questions/1259873/how-can-i-use-emacs-flymake-mode-for-python-with-pyflakes-and-pylint-checking-cod</a></p>

<div class="wp_syntax"><table><tr><td class="code"><pre class="bash" style="font-family:monospace;"><span style="color: #666666; font-style: italic;">#!/bin/bash</span>
&nbsp;
epylint <span style="color: #ff0000;">&quot;$1&quot;</span> <span style="color: #000000;">2</span><span style="color: #000000; font-weight: bold;">&gt;/</span>dev<span style="color: #000000; font-weight: bold;">/</span>null
pyflakes <span style="color: #ff0000;">&quot;$1&quot;</span>
pep8 <span style="color: #660033;">--ignore</span>=E221,E701,E202 <span style="color: #660033;">--repeat</span> <span style="color: #ff0000;">&quot;$1&quot;</span>
<span style="color: #c20cb9; font-weight: bold;">true</span></pre></td></tr></table></div>

<p>Enjoy !</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tricks.net/emacs-syntax-error-highlighting/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Emacs: replace tabs with spaces</title>
		<link>http://dev-tricks.net/emacs-replace-tabs-with-spaces</link>
		<comments>http://dev-tricks.net/emacs-replace-tabs-with-spaces#comments</comments>
		<pubDate>Fri, 06 May 2011 16:27:59 +0000</pubDate>
		<dc:creator>Julien Palard</dc:creator>
				<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://dev-tricks.net/?p=340</guid>
		<description><![CDATA[When you want to replace tab with spaces or vice versa don&#8217;t use M-% (query-replace) but M-x tabidy or M-x untabify. They work on the current selection so if you want it to be applied to a whole buffer, try &#8230; <a href="http://dev-tricks.net/emacs-replace-tabs-with-spaces">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>When you want to replace tab with spaces or vice versa don&#8217;t use M-% (query-replace) but M-x tabidy or M-x untabify. They work on the current selection so if you want it to be applied to a whole buffer, try C-x h (mark-whole-buffer) before to select the whole buffer.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tricks.net/emacs-replace-tabs-with-spaces/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Searching and replacing in emacs</title>
		<link>http://dev-tricks.net/emacssearching-string-in</link>
		<comments>http://dev-tricks.net/emacssearching-string-in#comments</comments>
		<pubDate>Tue, 03 May 2011 17:16:16 +0000</pubDate>
		<dc:creator>Julien Palard</dc:creator>
				<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://dev-tricks.net/?p=337</guid>
		<description><![CDATA[Day two of my serie about emacs, about searching and replacing. Function name : isearch-forward Typical Key sequence : C-s How to get help : C-h f isearch-forward Usage : isearch-forward let you type a string to be searched incrementally &#8230; <a href="http://dev-tricks.net/emacssearching-string-in">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>Day two of my serie about emacs, about searching and replacing.</p>
<p>Function name : isearch-forward<br />
Typical Key sequence : C-s<br />
How to get help : C-h f isearch-forward<br />
Usage : isearch-forward let you type a string to be searched incrementally in the current buffer, successive following C-s will jump to the next match.</p>
<p>Function name : isearch-forward-regexp<br />
Typical Key sequence : C-M-s or C-u C-s<br />
How to get help : C-h f isearch-forward-regexp<br />
Usage : isearch-forward-regexp let you type a regexp to be searched incrementally in the current buffer, successive following C-s will jump to the next match.</p>
<p>Function name : query-replace<br />
Typical Key sequence : M-%<br />
How to get help : C-h f query-replace<br />
Usage : M-% <em>search</em> RET <em>replace</em> RET<br />
Then, for each term found, query-replace will ask you what to do : space or y to replace, delete or n to skip, RET or q to exit, ! for &#8216;yes for all&#8217;, ? to get help about how to enter recursive edit / delete match and recursive edit / edit replacement string / &#8230;</p>
<p>Then you should read about replace-string, replace-regexp, occur, list-matching-lines, multi-occur, multi-occur-in-matching-buffers, how-many, flush-lines, and keep-lines.</p>
<p>Case sensitivity :<br />
A search is by defaut case insensitive, but if you input an upper case letter, it become case sensitive. M-c during a search toggle the case sensitivity.</p>
<p>Configuration variables :<br />
You may consult the documentation about those variable typing :<br />
C-h v <em>variable</em><br />
or<br />
M-x apropos-variable RET case-fold-search RET</p>
<ul>
<li>case-fold-search (Non-nil if searches and matches should ignore case.)</li>
<li>default-case-fold-search (Default value of `case-fold-search&#8217;)</li>
<li>tags-case-fold-search (Whether tags operations should be case-sensitive.)</li>
</ul>
]]></content:encoded>
			<wfw:commentRss>http://dev-tricks.net/emacssearching-string-in/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Numeric arguments in emacs</title>
		<link>http://dev-tricks.net/emacsnumeric-arguments-in</link>
		<comments>http://dev-tricks.net/emacsnumeric-arguments-in#comments</comments>
		<pubDate>Mon, 02 May 2011 13:47:31 +0000</pubDate>
		<dc:creator>Julien Palard</dc:creator>
				<category><![CDATA[emacs]]></category>

		<guid isPermaLink="false">http://dev-tricks.net/?p=334</guid>
		<description><![CDATA[I&#8217;m starting a &#8216;emacs trick of the day&#8217; sequence with : Function name : universal-argument Typical Key sequence : C-u How to get help : C-h f universal-argument Usage : C-u receive a numeric argument that is given to the &#8230; <a href="http://dev-tricks.net/emacsnumeric-arguments-in">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;m starting a &#8216;emacs trick of the day&#8217; sequence with :</p>
<p>Function name : universal-argument<br />
Typical Key sequence : C-u<br />
How to get help : C-h f universal-argument<br />
Usage : C-u receive a numeric argument that is given to the next called function, when no numeric argument is typed, the value defaults to 4.</p>
<p>So today you can try :<br />
C-u 9 C-n # that move cursor vertically down 9 lines<br />
C-u C-k # that kills 4 lines<br />
C-u C-u C-k # that kills 4 * 4 = 16 lines<br />
C-u 10 n # that enters nnnnnnnnnn<br />
You may ask, what about if I want to input 25 &#8217;6&#8242; ? C-u 256 can&#8217;t work &#8230; so you just have to separate with another C-u :<br />
C-u 25 C-u 1 # enters 6666666666666666666666666</p>
<p>Some functions does not have the simple &#8216;repeating&#8217; effect of receiving a numeric parameter, for example, running C-u C-l does not recenter 4 times your screen ! but the help page of recenter-top-bottom states that :<br />
> A prefix argument is handled like `recenter&#8217;:<br />
>  With numeric prefix ARG, move current line to window-line ARG.<br />
>  With plain `C-u&#8217;, move current line to window center.</p>
<p>A negative argument to C-l move the current line to the line ARG from the bottom of the screen.</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tricks.net/emacsnumeric-arguments-in/feed</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>nfsmount : rpc failed: 2</title>
		<link>http://dev-tricks.net/nfsmount_rpc_failed_2</link>
		<comments>http://dev-tricks.net/nfsmount_rpc_failed_2#comments</comments>
		<pubDate>Mon, 18 Apr 2011 12:45:03 +0000</pubDate>
		<dc:creator>Julien Palard</dc:creator>
				<category><![CDATA[Code]]></category>
		<category><![CDATA[Sysadmin]]></category>
		<category><![CDATA[unix]]></category>

		<guid isPermaLink="false">http://dev-tricks.net/?p=331</guid>
		<description><![CDATA[For those, here on the internet, asking themselves what is this f*cking `rpc failed: 2` while mounting an NFS, i&#8217;ts possible that teh response is here : Your NFS client, trying to mount the NFS share will use RPC to &#8230; <a href="http://dev-tricks.net/nfsmount_rpc_failed_2">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description>
				<content:encoded><![CDATA[<p>For those, here on the internet, asking themselves what is this f*cking `rpc failed: 2` while mounting an NFS, i&#8217;ts possible that teh response is here :</p>
<p>Your NFS client, trying to mount the NFS share will use RPC to communicate with the serveur, il will go like :</p>
<p>> PORTMAP GETPORT(Program: NFS, Version: 3, Proto: TCP)<br />
< PORTMAP Port: 2049<br />
> PORTMAP GETPORT(Program: MOUNT, Version: 3, Proto: TCP)<br />
< PORTMAP Port 49066<br />
> MOUNT MNT(Program Version: 3, Path: /srv/nfsroot/ )<br />
< MOUNT Reply error 2, "remote can't support version #", Program Version (Minimum): 1, Program Version (Maximum): 2</p>
<p>You can see that the response is "remote can't support version #" and we should have found this solution in the <a href="http://www.ietf.org/rfc/rfc1831.txt">RFC 1831 (RPCv2)</a> stating :</p>
<pre>
  Given that a call message was accepted, the following is the status
   of an attempt to call a remote procedure.

      enum accept_stat {
         SUCCESS       = 0, /* RPC executed successfully             */
         PROG_UNAVAIL  = 1, /* remote hasn't exported program        */
         PROG_MISMATCH = 2, /* remote can't support version #        */
         PROC_UNAVAIL  = 3, /* program can't support procedure       */
         GARBAGE_ARGS  = 4, /* procedure can't decode params         */
         SYSTEM_ERR    = 5  /* errors like memory allocation failure */
      };
</pre>
<p>So the problem is you client is asking for a NFS version greater that your server runs &#8230; but if your server is running NFS v3, check a `ps aux | grep [r]pc.mountd` for :</p>
<p>root      1411  0.0  0.0  18808  1036 ?        Ss   Apr15   0:00 /usr/sbin/rpc.mountd &#8211;manage-gids &#8211;no-nfs-version 3</p>
<p>Did you catch the &#8211;no-nfs-version 3 ? If your server is compiled with NFSv3 support, drop the &#8211;no-nfs-version 3 in your configuration and it should work !</p>
<p>Enjoy !</p>
]]></content:encoded>
			<wfw:commentRss>http://dev-tricks.net/nfsmount_rpc_failed_2/feed</wfw:commentRss>
		<slash:comments>6</slash:comments>
		</item>
	</channel>
</rss>
