<?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>Emile &#34;iMil&#34; Heitor &#039;s home</title>
	<atom:link href="http://imil.net/wp/feed/" rel="self" type="application/rss+xml" />
	<link>http://imil.net/wp</link>
	<description>life ∴ unix and stuff</description>
	<lastBuildDate>Fri, 07 Jun 2013 14:48:09 +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>SaltStack: dynamic sls (updated for 0.15.3)</title>
		<link>http://imil.net/wp/2013/06/06/saltstack-dynamic-sls/</link>
		<comments>http://imil.net/wp/2013/06/06/saltstack-dynamic-sls/#comments</comments>
		<pubDate>Thu, 06 Jun 2013 19:26:39 +0000</pubDate>
		<dc:creator>iMil</dc:creator>
				<category><![CDATA[Blogroll]]></category>
		<category><![CDATA[nginx]]></category>
		<category><![CDATA[python]]></category>
		<category><![CDATA[Salt]]></category>

		<guid isPermaLink="false">http://imil.net/wp/?p=2915</guid>
		<description><![CDATA[<p>I&#8217;ve been learning and diving into SaltStack for about a month now, for both work and personal interest, that thing simply rocks. In the meantime, I&#8217;ve contributed a couple of modules, like bridging and Xen support, plus a couple of grains improvements for NetBSD.
But most of all, I&#8217;ve been preparing my ${DAYJOB} infrastructure for Salt, [...]</p><p>The post <a href="http://imil.net/wp/2013/06/06/saltstack-dynamic-sls/">SaltStack: dynamic sls (updated for 0.15.3)</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been learning and diving into <a href="http://saltstack.com/community.html">SaltStack</a> for about a month now, for both work and personal interest, that thing simply rocks. In the meantime, I&#8217;ve contributed a couple of modules, like <a href="https://github.com/saltstack/salt/blob/develop/salt/modules/bridge.py">bridging</a> and <a href="https://github.com/saltstack/salt/blob/develop/salt/modules/xapi.py">Xen</a> support, plus a couple of <a href="http://docs.saltstack.com/topics/targeting/grains.html">grains</a> improvements for NetBSD.</p>
<p>But most of all, I&#8217;ve been preparing my <i>${DAYJOB}</i> infrastructure for <i>Salt</i>, and I must say this has been much easier than I thought, thanks to this beautifully designed piece of code.<br />
One aspect I&#8217;d like to share is the simple way I found to make a <a href="http://docs.saltstack.com/ref/configuration/minion.html">minion</a> dynamically configured, through custom-made grains.</p>
<p>Like many companies, we have an Information System, which has a bunch of informations about everything on our network, and among those, the roles of the virtual machines which are started. Those informations are made available to a <i>minion</i> through an HTTP server, which will recognize the <i>minion&#8217;s</i> <code>REMOTE_ADDR</code> and tell him what are its «roles».</p>
<p>The webserver is our always-favorite <a href="http://wiki.nginx.org/Main">nginx</a>, which interfaces a <a href="http://en.wikipedia.org/wiki/Web_Server_Gateway_Interface">WSGI</a> server, <a href="http://uwsgi-docs.readthedocs.org/en/latest/">uWSGI</a>.</p>
<p><i>nginx</i>&#8216;s configuration is simple:</p>
<pre>
location / {
        include uwsgi_params;
        uwsgi_pass unix:///var/run/uwsgi/app/is/socket;
}
</pre>
<p><i>uwsgi</i> application&#8217;s <i>.ini</i> is pretty trivial too:</p>
<pre>
[uwsgi]
workers = 2
log-date = true
plugins = python
chdir = /var/www/is
module = is
</pre>
<p>A very simple <i>python</i> script using <a href="http://webpy.org/">web.py</a> resides in <code>/var/www/is</code> and gives the <i>minion</i> which will query him a <a href="http://www.yaml.org/">YAML</a> structured output containing, among other data, the <i>minion</i>&#8216;s roles.</p>
<p>I wrote a basic <i>grain module</i> which retrieves those informations and make them available as <i>grains</i> for the <i>minions</i>:</p>
<pre>
$ cat _grains/is_http.py 

import requests
import yaml

def more_infos():
        '''
        Returns the minion's roles and stuff.
        '''
        r = requests.get('http://private.fqdn/')

        return yaml.load(r.text)
</pre>
<p>After deploying that <i>grain module</i> via <code>salt '*' saltutil.sync_grains</code>, the <i>minions</i> are now aware of what they&#8217;re meant to do, thus making a generic <a href="http://docs.saltstack.com/ref/states/#the-top-file">top.sls</a> easy to write.</p>
<p>Thanks to <a href="http://jinja.pocoo.org/">Jinja2</a>, a <i>sls</i> file can be made more dynamic, and we can write a very complex scenario within a couple of lines:</p>
<pre>
$ cat top.sls 
base:

  {% set states = salt['cp.list_states'](env) %}

  '*':
    - common
    {% if 'roles' in grains %}
    {% for role in grains['roles'] %}
    {% if role in states %}
    - {{ role }}
    {% endif %}  # state exists
    {% endfor %} # for roles
    {% endif %}  # role exists

  'virtual_subtype:Xen PV DomU':
    - match: grain
    - domus

  {% if grains['host'] in states %}
  {{ grains['host'] }}:
    - {{ grains['host'] }}
  {% endif %}
</pre>
<p>There we go, for every <i>role</i> a <i>minion</i> has, we can add a <i>sls</i> to match that <i>role</i> globally, as we can also add a very specific, host-related <i>sls</i>. Beautiful and handy, that&#8217;s what <i>Salt</i> is.</p>
<p><strong>Update for <i>Salt</i> 0.15.3</strong></p>
<p>Since <i>Salt</i> 0.15.3, a <i>sls</i> file can&#8217;t reference an non-existent state anymore, thus the additional checks in order to get sure the target state actually exists.</p>
<p>The post <a href="http://imil.net/wp/2013/06/06/saltstack-dynamic-sls/">SaltStack: dynamic sls (updated for 0.15.3)</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://imil.net/wp/2013/06/06/saltstack-dynamic-sls/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>NetBSD configuration management</title>
		<link>http://imil.net/wp/2013/05/09/netbsd-configuration-management/</link>
		<comments>http://imil.net/wp/2013/05/09/netbsd-configuration-management/#comments</comments>
		<pubDate>Thu, 09 May 2013 20:48:01 +0000</pubDate>
		<dc:creator>iMil</dc:creator>
				<category><![CDATA[Blogroll]]></category>
		<category><![CDATA[NetBSD]]></category>
		<category><![CDATA[Salt]]></category>

		<guid isPermaLink="false">http://imil.net/wp/?p=2906</guid>
		<description><![CDATA[<p>I&#8217;ve been obsessed with SaltStack for over a week. This infrastructure management suite is exactly what I needed for both my personal and professional servers: simple but modular, written in python, not depending on a thousand unnecessary complex messaging stacks as it bundles zeromq, capable of both orchestration and configuration management, all this through comprehensive, [...]</p><p>The post <a href="http://imil.net/wp/2013/05/09/netbsd-configuration-management/">NetBSD configuration management</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I&#8217;ve been obsessed with <a href="http://saltstack.com/community.html">SaltStack</a> for over a week. This infrastructure management suite is exactly what I needed for both my personal and professional servers: simple but modular, written in python, not depending on a thousand unnecessary complex messaging stacks as it bundles <a href="http://www.zeromq.org/">zeromq</a>, capable of both orchestration and configuration management, all this through comprehensive, well documented API and commands.</p>
<p>Only drawback <i>was</i> it had poor <i>NetBSD</i> support. <i>Was</i> :)</p>
<p>It&#8217;s been a long time since I&#8217;ve dug into python, so it took me a little bit of effort, but <i>Salt</i> now has full support of <a href="http://pkgin.net">pkgin</a> in its generic packaging functions, knows how to handle <i>NetBSD</i> services and is capable of dealing with <i>NetBSD</i>&#8216;s <code>sysctl(8)</code> and <code>sysctl.conf</code>.</p>
<p>Those pieces of code have been merged <a href="https://github.com/saltstack/salt">upstream</a>, I hope they&#8217;ll be available in version 0.16!</p>
<p>Some examples:</p>
<pre>
$ cat packages/init.sls 
mypkgs:
  pkg.installed:
    - pkgs:
      - vim
      - tmux
      - bash
      - bash-completion
      - sudo

$ sudo salt '*' state.sls packages
watto:
----------
    State: - pkg
    Name:      mypkgs
    Function:  installed
        Result:    True
        Comment:   All specified packages are already installed.
        Changes:   
korriban:
----------
    State: - pkg
    Name:      mypkgs
    Function:  installed
        Result:    True
        Comment:   All specified packages are already installed.
        Changes:   
tatooine:
----------
    State: - pkg
    Name:      mypkgs
    Function:  installed
        Result:    True
        Comment:   All specified packages are already installed.
        Changes:   
coruscant:
----------
    State: - pkg
    Name:      mypkgs
    Function:  installed
        Result:    True
        Comment:   All specified packages are already installed.
        Changes:   
ragnos:
----------
    State: - pkg
    Name:      mypkgs
    Function:  installed
        Result:    True
        Comment:   All specified packages are already installed.
        Changes:   
exar:
----------
    State: - pkg
    Name:      mypkgs
    Function:  installed
        Result:    True
        Comment:   All specified packages are already installed.
        Changes:

$ sudo salt '*' cmd.run 'uname -a'
tatooine:
    Linux tatooine 3.2.0-4-686-pae #1 SMP Debian 3.2.41-2 i686 GNU/Linux
watto:
    NetBSD watto.home.imil.net 6.1_RC4 NetBSD 6.1_RC4 (GENERIC) i386
exar:
    NetBSD exar 6.0_STABLE NetBSD 6.0_STABLE (EXAR) #0: Sun Nov 25 12:39:12 CET 2012  root@exar:/usr/src/sys/arch/i386/compile/EXAR i386
coruscant:
    NetBSD coruscant 6.0 NetBSD 6.0 (XEN3_DOM0) amd64
korriban:
    NetBSD korriban.imil.net 6.0_STABLE NetBSD 6.0_STABLE (KORRIBAN) #0: Tue Jan  1 23:20:36 CET 2013  root@korriban.imil.net:/usr/src/sys/arch/amd64/compile/KORRIBAN amd64
ragnos:
    NetBSD ragnos 6.0 NetBSD 6.0 (RAGNOS) #2: Wed Oct 17 11:33:31 CEST 2012  root@ragnos:/usr/src/sys/arch/i386/compile/RAGNOS i386

$ sudo salt '*' pkg.version vim   
watto:
    7.3.762
exar:
    7.3.762
korriban:
    7.3.712
coruscant:
    7.3.762
ragnos:
    7.3.762
tatooine:
    2:7.3.547-7

$ sudo salt '*' service.status sshd
tatooine:
    False
watto:
    True
coruscant:
    True
exar:
    True
korriban:
    True
ragnos:
    True
</pre>
<p>If you whish to use these modules without tainting your <i>Salt</i> package installation, simply copy them to a <code>_modules</code> directory within the <code>file_roots</code>.</p>
<p>Happy Salting!</p>
<p>The post <a href="http://imil.net/wp/2013/05/09/netbsd-configuration-management/">NetBSD configuration management</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://imil.net/wp/2013/05/09/netbsd-configuration-management/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>CPU dynamic scaling on NetBSD</title>
		<link>http://imil.net/wp/2013/05/02/cpu-dynamic-scaling-on-netbsd/</link>
		<comments>http://imil.net/wp/2013/05/02/cpu-dynamic-scaling-on-netbsd/#comments</comments>
		<pubDate>Thu, 02 May 2013 07:49:49 +0000</pubDate>
		<dc:creator>iMil</dc:creator>
				<category><![CDATA[Blogroll]]></category>
		<category><![CDATA[CPU]]></category>
		<category><![CDATA[NetBSD]]></category>
		<category><![CDATA[PowerNow]]></category>
		<category><![CDATA[SpeedStep]]></category>

		<guid isPermaLink="false">http://imil.net/wp/?p=2901</guid>
		<description><![CDATA[<p>I know about estd for a while, that daemon &#8220;dynamically sets the CPU-frequency on Enhanced SpeedStep, PowerNow, and APCI P-States-enabled CPUs depending on current cpu-utilization&#8221; (manpage excerpt). Thing is, I&#8217;ve never seen any CPU changing from its current speed while monitoring the machdep.powernow.frequency.current sysctl.
In order to understand what was happening, I started estd with the [...]</p><p>The post <a href="http://imil.net/wp/2013/05/02/cpu-dynamic-scaling-on-netbsd/">CPU dynamic scaling on NetBSD</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I know about <a href="http://wiki.netbsd.org/tutorials/cpu_frequency_scaling/">estd</a> for a while, that daemon &#8220;dynamically sets the CPU-frequency on Enhanced SpeedStep, PowerNow, and APCI P-States-enabled CPUs depending on current cpu-utilization&#8221; (manpage excerpt). Thing is, I&#8217;ve never seen any CPU changing from its current speed while monitoring the <code>machdep.powernow.frequency.current</code> <i>sysctl</i>.</p>
<p>In order to understand what was happening, I started <code>estd</code> with the <code>-o</code> flag, which outputs the CPU-frequencies as they are set. I then realized that the &#8220;ligh watermark percentage&#8221; and &#8220;low watermark percentage&#8221; default values were way too high (respectively 40 and 80) and were never reached, so the CPU speed was never changed.</p>
<p>With lower values, I was able to see the CPU speed increasing and lowering as expected. So I added the following line to the <code>/etc/rc.conf</code> file:</p>
<pre>
estd_flags="-l 5 -h 15 -a -m 800 -d"
</pre>
<p>meaning that the low watermark is set at 5 and the high watermark at 15, which were the values I&#8217;ve considered being the right ones while watching <code> estd -o -a</code> console output.</p>
<p>Since then, whenever a CPU intensive operation occurs, I can see the CPU speed rising with the following <a href="http://conky.sourceforge.net/">conky</a> parameter:</p>
<pre>
CPU Frequency: ${alignr}${exec /sbin/sysctl -n machdep.powernow.frequency.current}
</pre>
<p>The post <a href="http://imil.net/wp/2013/05/02/cpu-dynamic-scaling-on-netbsd/">CPU dynamic scaling on NetBSD</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://imil.net/wp/2013/05/02/cpu-dynamic-scaling-on-netbsd/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>Debian backport of OpenSSH 6.2</title>
		<link>http://imil.net/wp/2013/04/29/debian-backport-of-openssh-6-2/</link>
		<comments>http://imil.net/wp/2013/04/29/debian-backport-of-openssh-6-2/#comments</comments>
		<pubDate>Mon, 29 Apr 2013 10:48:00 +0000</pubDate>
		<dc:creator>iMil</dc:creator>
				<category><![CDATA[Blogroll]]></category>
		<category><![CDATA[Debian]]></category>
		<category><![CDATA[LDAP]]></category>
		<category><![CDATA[OpenSSH]]></category>

		<guid isPermaLink="false">http://imil.net/wp/?p=2898</guid>
		<description><![CDATA[<p>Update
As written on the comments:

Colin Watson Says:
May 17th, 2013 at 7:12 pm
I uploaded 6.2 packages to Debian a week or so after you posted this, so you can/should now just use those instead. I expect they should build fine on wheezy.

As a matter of fact, the following is now deprecated
At ${DAYWORK}, we used to have [...]</p><p>The post <a href="http://imil.net/wp/2013/04/29/debian-backport-of-openssh-6-2/">Debian backport of OpenSSH 6.2</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></description>
				<content:encoded><![CDATA[<p><strong>Update</strong></p>
<p>As written on the comments:<br />
<i><br />
Colin Watson Says:<br />
May 17th, 2013 at 7:12 pm</p>
<p>I uploaded 6.2 packages to Debian a week or so after you posted this, so you can/should now just use those instead. I expect they should build fine on wheezy.<br />
</i></p>
<p><strong>As a matter of fact, the following is now deprecated</strong></p>
<p>At ${DAYWORK}, we used to have our own <a href="http://www.openssh.com/">OpenSSH</a> debian package which included the famous <a href="http://code.google.com/p/openssh-lpk/">OpenSSH LPK</a> patch, which permits the use of an <a href="http://www.openldap.org/">OpenLDAP</a> server as an SSH public key provider.</p>
<p>I&#8217;ve been using OpenSSH-LPK for years, as this is a really handy solution and no valid alternative existed&#8230; until a couple of months.</p>
<p>OpenSSH 6.2 has a new configuration item called &#8220;AuthorizedKeysCommand&#8221;. The value associated to that key permits to call any executable as a public key provider. Yes, that <strong>is</strong> sexy.</p>
<p>Debian only have OpenSSH 6.1p1 packages available and tagged as &#8220;experimental&#8221;, so we had to hack a little bit in order to build 6.2 packages, here&#8217;s how:</p>
<ul>
<li>Fetch experimental source package</li>
<pre>
# echo "deb-src http://ftp2.fr.debian.org/debian/ experimental main contrib non-free" > /etc/apt/sources.list.d/experimental.list
# apt-get update
$ mkdir openssh &#038;&#038; cd openssh
$ apt-get source openssh
</pre>
<li>Bump the release</li>
<pre>
$ wget http://ftp.fr.openbsd.org/pub/OpenBSD/OpenSSH/portable/openssh-6.2p1.tar.gz
$ cd openssh-6.1p1
$ uupdate -v 6.2p2 ../openssh-6.2p1.tar.gz
$ cd ../openssh-6.2p1
$ dch -i # enter changelog informations
</pre>
<li>Get rid of conflicting patches</li>
<p>As expected, many patches from debian don&#8217;t apply anymore, and I was not brave enough to backport them, I&#8217;ve just commented them in <code>debian/patches/series</code>:</p>
<pre>
#gssapi.patch
#selinux-role.patch
#copy-id-restorecon.patch
#ssh-vulnkey.patch
#consolekit.patch
#user-group-modes.patch
#max-startups-default.patch
#package-versioning.patch
#debian-banner.patch
#lintian-symlink-pickiness.patch
#openbsd-docs.patch
#ssh-argv0.patch
#doc-upstart.patch
</pre>
<li>Remove uninstalled files</li>
<p>In order not to check some files that will not be present as we commented the patches which creates them, we&#8217;ll have to remove the following lines from <code>debian/openssh-client.install</code></p>
<pre>
usr/bin/ssh-vulnkey
usr/share/man/man1/ssh-vulnkey.1
</pre>
<p>And the following one from <code>debian/openssh-client.docs</code></p>
<pre>
ChangeLog.gssapi
</pre>
<p>Finally, we just comment out the use of the <code>vulnerable_host_keys</code> shell function in <code>debian/openssh-server.postinst.in</code>:</p>
<pre>
fix_doc_symlink
create_sshdconfig
create_keys
#vulnerable_host_keys
fix_statoverride
</pre>
<p>That&#8217;s it! You can now happily build the brand new OpenSSH version using <code>debuild</code> as usual.</p>
<p>After installing it, you&#8217;ll have access to the <a href="http://www.openssh.org/cgi-bin/man.cgi?query=sshd_config">AuthorizedKeysCommand</a> option.</p>
<p>Thanks gaston, davromaniak and SliX from #GCU for the help.</p>
<p></ul>
<p>The post <a href="http://imil.net/wp/2013/04/29/debian-backport-of-openssh-6-2/">Debian backport of OpenSSH 6.2</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://imil.net/wp/2013/04/29/debian-backport-of-openssh-6-2/feed/</wfw:commentRss>
		<slash:comments>2</slash:comments>
		</item>
		<item>
		<title>vim tabs, tmux and Control-arrows</title>
		<link>http://imil.net/wp/2013/04/26/vim-tabs-tmux-and-control-arrows/</link>
		<comments>http://imil.net/wp/2013/04/26/vim-tabs-tmux-and-control-arrows/#comments</comments>
		<pubDate>Fri, 26 Apr 2013 17:20:25 +0000</pubDate>
		<dc:creator>iMil</dc:creator>
				<category><![CDATA[Blogroll]]></category>

		<guid isPermaLink="false">http://imil.net/wp/?p=2890</guid>
		<description><![CDATA[<p>Here&#8217;s a .vimrc excerpt which permits the use of Control + Arrows sequences to navigate through vim tabs inside the tmux terminal multiplexer:

" inside screen / tmux
map &#60;Esc&#62;[C &#60;C-Right&#62;
map &#60;Esc&#62;[D &#60;C-Left&#62;
" insert mode
map! &#60;Esc&#62;[C &#60;C-Right&#62;
map! &#60;Esc&#62;[D &#60;C-Left&#62;
" no screen
map &#60;Esc&#62;[1;5D &#60;C-Left&#62;
map &#60;Esc&#62;[1;5C &#60;C-Right&#62;
" insert mode
map! &#60;Esc&#62;[1;5D &#60;C-Left&#62;
map! &#60;Esc&#62;[1;5C &#60;C-Right&#62;

nnoremap &#60;C-t&#62; :tabnew&#60;CR&#62;
nnoremap &#60;C-w&#62; :tabclose&#60;CR&#62;
nnoremap &#60;C-right&#62; :tabnext&#60;CR&#62;
nnoremap [...]</p><p>The post <a href="http://imil.net/wp/2013/04/26/vim-tabs-tmux-and-control-arrows/">vim tabs, tmux and Control-arrows</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Here&#8217;s a <code>.vimrc</code> excerpt which permits the use of Control + Arrows sequences to navigate through <a href="http://vim.wikia.com/wiki/Alternative_tab_navigation">vim tabs</a> inside the <a href="http://tmux.sourceforge.net/">tmux</a> terminal multiplexer:</p>
<pre>
" inside screen / tmux
map &lt;Esc&gt;[C &lt;C-Right&gt;
map &lt;Esc&gt;[D &lt;C-Left&gt;
" insert mode
map! &lt;Esc&gt;[C &lt;C-Right&gt;
map! &lt;Esc&gt;[D &lt;C-Left&gt;
" no screen
map &lt;Esc&gt;[1;5D &lt;C-Left&gt;
map &lt;Esc&gt;[1;5C &lt;C-Right&gt;
" insert mode
map! &lt;Esc&gt;[1;5D &lt;C-Left&gt;
map! &lt;Esc&gt;[1;5C &lt;C-Right&gt;

nnoremap &lt;C-t&gt; :tabnew&lt;CR&gt;
nnoremap &lt;C-w&gt; :tabclose&lt;CR&gt;
nnoremap &lt;C-right&gt; :tabnext&lt;CR&gt;
nnoremap &lt;C-left&gt; :tabprevious&lt;CR&gt;
" insert mode
inoremap &lt;C-t&gt; &lt;Esc&gt;:tabnew&lt;CR&gt;
inoremap &lt;C-w&gt; &lt;Esc&gt;:tabclose&lt;CR&gt;
inoremap &lt;C-right&gt; &lt;Esc&gt;:tabnext&lt;CR&gt;
inoremap &lt;C-left&gt; &lt;Esc&gt;:tabprevious&lt;CR&gt;
</pre>
<p>The post <a href="http://imil.net/wp/2013/04/26/vim-tabs-tmux-and-control-arrows/">vim tabs, tmux and Control-arrows</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://imil.net/wp/2013/04/26/vim-tabs-tmux-and-control-arrows/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pkgsrc and github archives</title>
		<link>http://imil.net/wp/2013/04/21/pkgsrc-and-github-archives/</link>
		<comments>http://imil.net/wp/2013/04/21/pkgsrc-and-github-archives/#comments</comments>
		<pubDate>Sun, 21 Apr 2013 21:10:06 +0000</pubDate>
		<dc:creator>iMil</dc:creator>
				<category><![CDATA[Blogroll]]></category>
		<category><![CDATA[github]]></category>
		<category><![CDATA[pkgin]]></category>
		<category><![CDATA[pkgsrc]]></category>

		<guid isPermaLink="false">http://imil.net/wp/?p=2882</guid>
		<description><![CDATA[<p>I recently switched pkgin&#8216;s repository from SourceForge&#8216;s CVS to GitHub. Long story short, I heard here and there that SF was considering to drop CVS support and I found GitHub service to be more responsive and elegant. Also, I was looking for an excuse to learn git :)
Anyway, GitHub interface may be sexy, they used [...]</p><p>The post <a href="http://imil.net/wp/2013/04/21/pkgsrc-and-github-archives/">pkgsrc and github archives</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>I recently switched <a href="http://pkgin.net">pkgin</a>&#8216;s repository from <i>SourceForge</i>&#8216;s CVS to <i>GitHub</i>. Long story short, I heard here and there that SF was considering to drop CVS support and I found GitHub service to be more responsive and elegant. Also, I was looking for an excuse to learn <a href="http://git-scm.com/">git</a> :)</p>
<p>Anyway, GitHub interface may be sexy, they used to have some kind of &#8220;upload&#8221; section which <a href="https://github.com/blog/1302-goodbye-uploads">has been dropped</a>. That may sound like a simple story, but the fact is when it comes to packaging a GitHub-hosted application, things are not that simple when the author has not explicitly tagged a specific release. Another use case, in which I actually am, is when you have an ongoing development, like <code>pkgin</code> in <a href="http://pkgsrc-wip.sourceforge.net/">pkgsrc WIP</a> and do not want to tag every test-release.</p>
<p>The way I found to handle that case with <a href="http://www.pkgsrc.org/">pkgsrc</a> is to use GitHub&#8217;s <i>commit</i> archives. In short, I will use that kind of URL:</p>
<pre>https://github.com/NetBSDfr/pkgin/archive/34b823c158e62e4d347de74499a075a2259382c5.tar.gz</pre>
<p>which is redirected like this by GitHub:</p>
<pre>HTTP/1.1 302 Found
Server: GitHub.com
Date: Sun, 21 Apr 2013 21:05:17 GMT
Content-Type: text/html; charset=utf-8
Connection: keep-alive
Status: 302 Found
Cache-Control: max-age=0, private
Strict-Transport-Security: max-age=2592000
X-Frame-Options: deny
Set-Cookie: logged_in=no; domain=.github.com; path=/; expires=Thu, 21-Apr-2033 21:05:17 GMT; HttpOnly
Location: https://nodeload.github.com/NetBSDfr/pkgin/tar.gz/34b823c158e62e4d347de74499a075a2259382c5
X-Runtime: 13
Content-Length: 156
Vary: Accept-Encoding

HTTP/1.1 200 OK
Server: GitHub.com
Date: Sun, 21 Apr 2013 21:05:18 GMT
Content-Type: application/x-gzip
Connection: keep-alive
Content-Length: 187510
Content-Disposition: attachment; filename=pkgin-34b823c158e62e4d347de74499a075a2259382c5.tar.gz
Vary: Accept-Encoding
</pre>
<p>and permits to point to a particular commit, no matter if it has been tagged or not.</p>
<p>A typical <i>pkgsrc</i> <code>Makefile</code> will look like this:</p>
<pre>
VERSION=                34b823c158e62e4d347de74499a075a2259382c5
DISTNAME=               ${VERSION}
PKGNAME=                pkgin-20130412
CATEGORIES=             pkgtools
MASTER_SITES=           https://github.com/NetBSDfr/pkgin/archive/
FETCH_USING=            curl

# [...]

WRKSRC=                 ${WRKDIR}/pkgin-${VERSION}

# [...]
</pre>
<p>Note that <code>FETCH_USING= curl</code> is mandatory here in order to follow redirect codes along with <i>https</i>.</p>
<p>There you go, happy GitHub packaging!</p>
<p><strong>Update</strong></p>
<p>Here&#8217;s another approach pointed out by Amitai Schlair (schmonz@):</p>
<pre>
GIT_COMMIT=	dd51ac5

DISTNAME=	${GIT_COMMIT}
PKGNAME=	p5-App-Prove-Plugin-ProgressBar-0.01
CATEGORIES=	devel perl5
MASTER_SITES=	-http://nodeload.github.com/Ovid/App-Prove-Plugin-ProgressBar/tar.gz/${GIT_COMMIT}

# [...]

WRKSRC=		${WRKDIR}/App-Prove-Plugin-ProgressBar-${GIT_COMMIT}
</pre>
<p>Here, Amitai doesn&#8217;t use <i>HTTPS</i> so specifying <code>curl</code> as the fetch method is not mandatory. The dash before the URL in the <code>MASTER_SITES</code> line means that <code>DISTNAME</code> will not be appended when fetching, which is very handy when it comes to GitHub archives.</p>
<p>The post <a href="http://imil.net/wp/2013/04/21/pkgsrc-and-github-archives/">pkgsrc and github archives</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://imil.net/wp/2013/04/21/pkgsrc-and-github-archives/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>GLMF 159</title>
		<link>http://imil.net/wp/2013/03/30/glmf-159/</link>
		<comments>http://imil.net/wp/2013/03/30/glmf-159/#comments</comments>
		<pubDate>Sat, 30 Mar 2013 10:13:46 +0000</pubDate>
		<dc:creator>iMil</dc:creator>
				<category><![CDATA[Ma vie, mon oeuvre]]></category>

		<guid isPermaLink="false">http://imil.net/wp/?p=2878</guid>
		<description><![CDATA[<p>Il est là, il est chaud, et il contient deux articles de mon cru:

3NMP: NetBSD, Nginx, Naxsi, MySQL, PHP
Nouvelles commandes et nouveaux démons dans NetBSD 6.0


Enjoy!
</p><p>The post <a href="http://imil.net/wp/2013/03/30/glmf-159/">GLMF 159</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Il est là, il est chaud, et il contient deux articles de mon cru:</p>
<ul>
<li>3NMP: NetBSD, Nginx, Naxsi, MySQL, PHP</li>
<li>Nouvelles commandes et nouveaux démons dans NetBSD 6.0</li>
</ul>
<p><a href="http://imil.net/wp/wp-content/2013/03/damag-01-159.jpg"><img src="http://imil.net/wp/wp-content/2013/03/damag-01-159.jpg" alt="GNU/Linux Magazine 159" width="394" height="525" class="aligncenter size-full wp-image-2877" /></a><br />
Enjoy!</p>
<p>The post <a href="http://imil.net/wp/2013/03/30/glmf-159/">GLMF 159</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://imil.net/wp/2013/03/30/glmf-159/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>pkgtools/pkgin, quick fix</title>
		<link>http://imil.net/wp/2013/02/25/pkgtoolspkgin-quick-fix/</link>
		<comments>http://imil.net/wp/2013/02/25/pkgtoolspkgin-quick-fix/#comments</comments>
		<pubDate>Mon, 25 Feb 2013 21:48:48 +0000</pubDate>
		<dc:creator>iMil</dc:creator>
				<category><![CDATA[Blogroll]]></category>
		<category><![CDATA[Ma vie, mon oeuvre]]></category>
		<category><![CDATA[pkgin]]></category>
		<category><![CDATA[pkgsrc]]></category>

		<guid isPermaLink="false">http://imil.net/wp/?p=2873</guid>
		<description><![CDATA[<p>Damn I love pkgsrc. Let me tell you this story as an example&#8230;
A while ago, a couple of pkgin users told me it was a shame that /usr/pkg/etc/pkgin/repositories.conf was still pointing to a 5.0 URL when pkgin is freshly installed. Thing is, pkgin does support the $osrelease variable, but on NetBSD, the result of kern.osrelease [...]</p><p>The post <a href="http://imil.net/wp/2013/02/25/pkgtoolspkgin-quick-fix/">pkgtools/pkgin, quick fix</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>Damn I love <a href="http://pkgsrc.org/">pkgsrc</a>. Let me tell you this story as an example&#8230;</p>
<p>A while ago, a couple of <a href="http://pkgin.net/">pkgin</a> users told me it was a shame that <code>/usr/pkg/etc/pkgin/repositories.conf</code> was still pointing to a <i>5.0</i> URL when <code>pkgin</code> is freshly installed. Thing is, <code>pkgin</code> does support the <code>$osrelease</code> variable, but on NetBSD, the result of <code>kern.osrelease</code> can be <code>6.0_SOMETHING</code>, which would lead to:</p>
<pre>ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/$arch/6.0_SOMETHING/All</pre>
<p>and this does dot exists on the repository.</p>
<p>So in the <code>REPOSITORIES</code> file, which is used to generate the right <code>repositories.conf</code> entry, I added that line:</p>
<pre>
ftp://ftp.netbsd.org/pub/pkgsrc/packages/NetBSD/$arch/@OSREL@/All
</pre>
<p>And wrote the following trick in <code>pkgtools/pkgin</code>&#8216;s Makefile:</p>
<pre>
.if ${OPSYS} == "NetBSD"
SUBST_CLASSES+=         osrel
SUBST_STAGE.osrel=      pre-configure
SUBST_MESSAGE.osrel=    Adjusting repository OS release
SUBST_FILES.osrel=      REPOSITORIES
SUBST_SED.osrel=        -e "s|@OSREL@|${OS_VERSION:C/_.*//}|"
.endif
</pre>
<p>The <code>SUBST</code> framework, part of <code>pkgsrc</code>, will then use (a portable) <code>sed</code> to replace <code>@OSREL@</code> with the variable ${OS_VERSION}, which is defined in <code>mk/bsd.prefs.mk</code> (included in the Makefile), but will erase anything like the regexp &#8220;_.*&#8221;. This magic is done by the <code>:C</code> modifier, which behaves like the <code>:S</code> modifier but is capable of replacing regexps instead of simple strings.</p>
<p>Learn to know the power of <code>pkgsrc</code>&#8230;</p>
<p>The post <a href="http://imil.net/wp/2013/02/25/pkgtoolspkgin-quick-fix/">pkgtools/pkgin, quick fix</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://imil.net/wp/2013/02/25/pkgtoolspkgin-quick-fix/feed/</wfw:commentRss>
		<slash:comments>0</slash:comments>
		</item>
		<item>
		<title>auto-FQDN logging</title>
		<link>http://imil.net/wp/2013/02/18/auto-fqdn-logging/</link>
		<comments>http://imil.net/wp/2013/02/18/auto-fqdn-logging/#comments</comments>
		<pubDate>Mon, 18 Feb 2013 19:45:33 +0000</pubDate>
		<dc:creator>iMil</dc:creator>
				<category><![CDATA[Blogroll]]></category>
		<category><![CDATA[Ma vie, mon oeuvre]]></category>
		<category><![CDATA[nginx]]></category>

		<guid isPermaLink="false">http://imil.net/wp/?p=2868</guid>
		<description><![CDATA[<p>While migrating the GCU-Squad! website to nginx, I wanted to keep the configuration as small as possible. In order to keep sites configuration files thin, I used this trick to automatically create log files using site&#8217;s FQDN:

access_log /var/log/nginx/$host.access_log;

But I quickly noticed that some unwanted FQDN&#8217;s where appearing on the log directory. In order to keep [...]</p><p>The post <a href="http://imil.net/wp/2013/02/18/auto-fqdn-logging/">auto-FQDN logging</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>While migrating the <a href="http://www.gcu-squad.org">GCU-Squad!</a> website to <a href="http://wiki.nginx.org/Main">nginx</a>, I wanted to keep the configuration as small as possible. In order to keep sites configuration files thin, I used this trick to automatically create log files using site&#8217;s FQDN:</p>
<pre>
access_log /var/log/nginx/$host.access_log;
</pre>
<p>But I quickly noticed that some unwanted FQDN&#8217;s where appearing on the log directory. In order to keep control on the created files, I figured out a simple way to ensure unwanted domains to be logged in the general <code>access.log</code>:</p>
<pre>
if ($host ~ gcu) {
        set $log_fqdn $host;
}

access_log      /var/log/nginx/$log_fqdn.access_log;
</pre>
<p>And no, you can&#8217;t include the <code>access_log</code> keyword in the <code>if</code> statement, I tried :)</p>
<p>Anyway, isn&#8217;t it just beautiful? mmmm nginx&#8230;</p>
<p>The post <a href="http://imil.net/wp/2013/02/18/auto-fqdn-logging/">auto-FQDN logging</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://imil.net/wp/2013/02/18/auto-fqdn-logging/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
		<item>
		<title>A new multiplexed world</title>
		<link>http://imil.net/wp/2013/01/27/a-new-multiplexed-world/</link>
		<comments>http://imil.net/wp/2013/01/27/a-new-multiplexed-world/#comments</comments>
		<pubDate>Sun, 27 Jan 2013 15:20:05 +0000</pubDate>
		<dc:creator>iMil</dc:creator>
				<category><![CDATA[Blogroll]]></category>
		<category><![CDATA[NetBSD]]></category>
		<category><![CDATA[tmux]]></category>

		<guid isPermaLink="false">http://imil.net/wp/?p=2843</guid>
		<description><![CDATA[<p>And voila, I knew this was going to happen, I finally switched to tmux. I will not explain here why this software is better than GNU screen, simply put, tmux is now part of the base system of nearly all BSD derivative operating systems (NetBSD among them), and it makes my life easier.
Instead, I&#8217;ll point [...]</p><p>The post <a href="http://imil.net/wp/2013/01/27/a-new-multiplexed-world/">A new multiplexed world</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></description>
				<content:encoded><![CDATA[<p>And voila, I knew this was going to happen, I finally switched to <a href="http://tmux.sourceforge.net/">tmux</a>. I will not explain here why this software is better than <a href="http://www.gnu.org/software/screen/">GNU screen</a>, simply put, <code>tmux</code> is now part of the base system of nearly all BSD derivative operating systems (NetBSD among them), and it makes my life easier.</p>
<p>Instead, I&#8217;ll point out here all the resources that helped me switching rather quickly:</p>
<ul>
<li>Generic hands-on <a href="https://wiki.archlinux.org/index.php/Tmux">https://wiki.archlinux.org/index.php/Tmux</a></li>
<li>Commented example <a href="http://www.doknowevil.net/2010/10/18/sorry-screen-tmux-is-better-but-here-are-some-screen-lik-hotkeys/">http://www.doknowevil.net/2010/10/18/sorry-screen-tmux-is-better-but-here-are-some-screen-lik-hotkeys/</a></li>
<li>Playing with the statusbar <a href="http://jasonwryan.com/blog/2011/06/10/setting-tmux-statusbar-if-in-x/">http://jasonwryan.com/blog/2011/06/10/setting-tmux-statusbar-if-in-x/</a>, this author has other very good resources on the topic</li>
<li>Fixing the 256colors mess (without using <code>tmux -2</code>) <a href="http://benjaminthomas.org/2012-03-28/256-colors-in-tmux.html">http://benjaminthomas.org/2012-03-28/256-colors-in-tmux.html</a></li>
<li>Another well documented configuration file <a href="http://www.sheevaboite.fr/articles/show-me-your-tmux-conf">http://www.sheevaboite.fr/articles/show-me-your-tmux-conf</a></li>
<li>Screen-to-tmux helper (in french, but easy to comprehend) <a href="http://wiki.soolbox.net/wiki/SysadminTips/tmux">http://wiki.soolbox.net/wiki/SysadminTips/tmux</a></li>
<li>Very well written customization guide <a href="http://blog.hawkhost.com/2010/07/02/tmux-%E2%80%93-the-terminal-multiplexer-part-2/">http://blog.hawkhost.com/2010/07/02/tmux-%E2%80%93-the-terminal-multiplexer-part-2/</a> (author has also written a comprehensive guide on how to basically use tmux)</li>
<li>Enable mouse pane focus and resize <a href="http://tangledhelix.com/blog/2012/07/16/tmux-and-mouse-mode/">http://tangledhelix.com/blog/2012/07/16/tmux-and-mouse-mode/</a></li>
</ul>
<p>Here&#8217;s my <code>~/.tmux.conf</code>, which is pretty much the standard <code>screen-keys.conf</code> available with the package, with only some small customizations like the status bar and some fixes:</p>
<pre>
# Set the prefix to ^Q.
unbind C-b
set -g prefix ^Q
bind q send-prefix

# Bind appropriate commands similar to screen.
# lockscreen ^X x 
unbind ^X
bind ^X lock-server
unbind x
bind x lock-server

# screen ^C c 
unbind ^C
bind ^C new-window
unbind c
bind c new-window

# detach ^D d
unbind ^D
bind ^D detach

# displays * 
unbind *
bind * list-clients

# next ^@ ^N sp n 
unbind ^@
bind ^@ next-window
unbind ^N
bind ^N next-window
unbind " "
bind " " next-window
unbind n
bind n next-window

# title A
unbind A
bind A command-prompt "rename-window %%"

# other ^A
unbind ^A
bind ^A last-window

# prev ^H ^P p ^? 
unbind ^H
bind ^H previous-window
unbind ^P
bind ^P previous-window
unbind p
bind p previous-window
unbind BSpace
bind BSpace previous-window

# windows ^W w 
unbind ^W
bind ^W list-windows
unbind w
bind w list-windows

# quit \ 
unbind \
bind \ confirm-before "kill-server"

# kill K k 
unbind K
bind K confirm-before "kill-window"
unbind k
bind k confirm-before "kill-window"

# redisplay ^L l 
unbind ^L
bind ^L refresh-client
unbind l
bind l refresh-client


# :kB: focus up
unbind Tab
bind Tab select-pane -t:.+
unbind BTab
bind BTab select-pane -t:.-

# split
unbind |
bind | split-window -h
unbind -
bind - split-window -v

# " windowlist -b
unbind '"'
bind '"' choose-window

unbind r
bind r source ~/.tmux.conf

set -g terminal-overrides 'xterm*:smcup@:rmcup@:colors=256'
# Status Bar
set -g default-terminal "screen"

# default statusbar colors
set -g status-fg white
set -g status-bg colour235

# current or active window in status bar
set-window-option -g window-status-current-bg colour53
set-window-option -g window-status-current-fg white
set-window-option -g window-status-current-format '[ #W ]'

# alerted window in status bar (bell, activity or content).
set-window-option -g window-status-alert-bg colour235
set-window-option -g window-status-alert-fg colour53
set-window-option -g window-status-alert-attr reverse

set -g status-right-length 40
set -g status-left-length 40
#set -g status-left '#[fg=purple]#H #[fg=black,bright]#[default]'
set -g status-left '#[fg=colour153]#H #[default]'
set -g status-right '#[fg=colour141]#(sysctl vm.loadavg|cut -f2-4 -d" ")#[default] | #[fg=colour117]%H:%M '
</pre>
<p>In order to pick up the right colors, I used a <i>shell</i> snippet I took from <a href="https://github.com/andersonfreitas/dotfiles/blob/master/zsh/aliases.zsh">this github repository</a>:</p>
<pre>
for i in {0..255} ; do
    printf "\x1b[38;5;${i}mcolour${i}\n"
done
</pre>
<p>Mandatory screenshot:</p>
<p><a href="http://imil.net/wp/wp-content/2013/01/tmux-2.png"><img src="http://imil.net/wp/wp-content/2013/01/tmux-2.png" alt="tmux" width="482" height="302" class="aligncenter size-full wp-image-2861" /></a></p>
<p>The post <a href="http://imil.net/wp/2013/01/27/a-new-multiplexed-world/">A new multiplexed world</a> appeared first on <a href="http://imil.net/wp">Emile &quot;iMil&quot; Heitor &#039;s home</a>.</p>]]></content:encoded>
			<wfw:commentRss>http://imil.net/wp/2013/01/27/a-new-multiplexed-world/feed/</wfw:commentRss>
		<slash:comments>1</slash:comments>
		</item>
	</channel>
</rss>

<!-- Served from: imil.net @ 2013-06-18 08:07:21 by W3 Total Cache -->