<?xml version="1.0" encoding="utf-8"?><?xml-stylesheet title="XSL formatting" type="text/xsl" href="http://mirmodynamics.com/feed/rss2/xslt" ?><rss version="2.0"
  xmlns:dc="http://purl.org/dc/elements/1.1/"
  xmlns:wfw="http://wellformedweb.org/CommentAPI/"
  xmlns:content="http://purl.org/rss/1.0/modules/content/"
  xmlns:atom="http://www.w3.org/2005/Atom">
<channel>
  <title>Mirmo Dynamics - Tag - handy</title>
  <link>http://mirmodynamics.com/</link>
  <atom:link href="http://mirmodynamics.com/feed/tag/handy/rss2" rel="self" type="application/rss+xml"/>
  <description>Si tu kiffes pas reunoi, t'écoutes pas et puis c'est tout.</description>
  <language>en</language>
  <pubDate>Sun, 14 Mar 2010 19:59:01 +0100</pubDate>
  <copyright>2003-2009 &amp;copy; Geoffrey Bachelet</copyright>
  <docs>http://blogs.law.harvard.edu/tech/rss</docs>
  <generator>Dotclear</generator>
  
    
  <item>
    <title>Passing arbitrary parameters to a route in symfony</title>
    <link>http://mirmodynamics.com/post/2008/11/02/Passing-arbitrary-parameters-to-a-route-in-symfony</link>
    <guid isPermaLink="false">urn:md5:7954eb5f9f623e4d1fcd8829f2d32adb</guid>
    <pubDate>Sun, 02 Nov 2008 21:12:00 +0100</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Symfony</category>
        <category>handy</category><category>parameters</category><category>routing</category><category>symfony</category><category>tips</category>    
    <description>    &lt;p&gt;Parameters are an important parts of routes in symfony, and in any other routing framework for that matter, and everyone knows how to add mandatory or optional parameters to a route. But did you know you can also silently pass arbitrary parameters to a route from the routing definitions ? This may not be a very clear description, so let's take an example. Say you have a tabbed navigation system, and you want to know in your template which tab is the current one. In a perfect world, you could assume one tab corresponds to a module and check this module, but let's say that one tab can contain multiples modules. How are you doing now ? Quite simply actually, by passing a &lt;code&gt;tab&lt;/code&gt; parameter to your route.&lt;/p&gt;

&lt;pre&gt;
foo_route:
  url:       /foo
  param: { tab: foobar }

bar_route:
  url:       /bar
  param: { tab: foobar }
&lt;/pre&gt;


&lt;p&gt;Now you can access the tab parameter in your layout:&lt;/p&gt;

&lt;pre&gt;
&amp;lt;?php $currentTab = $sf_params-&amp;gt;get('tab'); ?&amp;gt;
&lt;/pre&gt;


&lt;p&gt;Easy heh ? Of course this kind of parameters is not limited to tell which tab we're currently in, you can, for example, bypass the limitation of a system that requires a particular file to be in a particular location (not that using mod_rewrite would not be more efficient, I just wanted one more example):&lt;/p&gt;

&lt;pre&gt;
foobar_xml:
  url:       /a/stupid/url/that/you/cant/change/foobar.xml
  param: { module: default, action: static, file: &amp;quot;/assets/foobar.xml&amp;quot;, mimetype: &amp;quot;text/xml&amp;quot; }
&lt;/pre&gt;


&lt;p&gt;Here we simply pass the &lt;code&gt;file&lt;/code&gt; and &lt;code&gt;mimetype&lt;/code&gt; parameters to an action that'll take care to serve the right file.&lt;/p&gt;


&lt;p&gt;Handy ! But please note that you can't pass such parameters in &lt;code&gt;sfPropelRouteCollection&lt;/code&gt; for now (yup, this a bug, and there's a ticket already).&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2008/11/02/Passing-arbitrary-parameters-to-a-route-in-symfony#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2008/11/02/Passing-arbitrary-parameters-to-a-route-in-symfony#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1150</wfw:commentRss>
      </item>
    
  <item>
    <title>Mass vim file opening reloaded</title>
    <link>http://mirmodynamics.com/post/2008/10/16/Mass-vim-file-opening-reloaded</link>
    <guid isPermaLink="false">urn:md5:043b3c3596084fc127d581eb3ee0bb15</guid>
    <pubDate>Thu, 16 Oct 2008 21:20:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Geekeries</category>
        <category>bash</category><category>grep</category><category>handy</category><category>script</category><category>tips</category><category>vim</category>    
    <description>    &lt;p&gt;Thinking about it, &lt;a href=&quot;http://mirmodynamics.com/post/2008/10/14/Mass-vim-file-opening&quot;&gt;the snippet I posted earlier&lt;/a&gt; was a bit silly as vim can open by itself multiple files way more efficiently. The only benefit from my script is that I don't have to type the &lt;code&gt;--servername&lt;/code&gt; and &lt;code&gt;--remote-silent-tab&lt;/code&gt;.&lt;/p&gt;


&lt;p&gt;So let's add some usefulness ! First, when I need this script, it's often that I first grepped the files, and then decide that I want to edit them all. From this point of view, having to pass them as &lt;em&gt;arguments&lt;/em&gt; is not that handy, so we'll add a way to pass them via &lt;code&gt;STDIN&lt;/code&gt;.&lt;/p&gt;


&lt;p&gt;Also, what if I want to send them to another vim server ? We'll add this ability too.&lt;/p&gt;


&lt;p&gt;Here is the resulting script:&lt;/p&gt;

&lt;pre&gt;
#!/usr/bin/env bash

# set a default SERVERNAME
SERVERNAME=&amp;quot;ash0&amp;quot;

# look for files on stdin
if ! [ -t 0 ]; then
  FILES=`cat /dev/stdin`
else
  exit;
fi;

# now let's check if we want a specific vim server
if ! [ -z $1 ]; then
  SERVERNAME=$1
fi;

# we can now open the files
/usr/bin/gvim --servername $SERVERNAME --remote-silent-tab $FILES
&lt;/pre&gt;


&lt;p&gt;Tada !&lt;/p&gt;


&lt;p&gt;You can now do the followings:&lt;/p&gt;

&lt;pre&gt;
grep foo | sendtovim
grep foo | sendtovim grep0
&lt;/pre&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2008/10/16/Mass-vim-file-opening-reloaded#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2008/10/16/Mass-vim-file-opening-reloaded#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1144</wfw:commentRss>
      </item>
    
  <item>
    <title>Mass vim file opening</title>
    <link>http://mirmodynamics.com/post/2008/10/14/Mass-vim-file-opening</link>
    <guid isPermaLink="false">urn:md5:d2b7afaa2aaf18ada08b02c96c5185fc</guid>
    <pubDate>Tue, 14 Oct 2008 19:40:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Geekeries</category>
        <category>grep</category><category>handy</category><category>script</category><category>tips</category><category>vim</category>    
    <description>    &lt;p&gt;Remember &lt;a href=&quot;http://mirmodynamics.com/post/2006/11/28/Linux-gVim-Rox-filer-Mon-IDE&quot;&gt;my old post about vim and rox-filer&lt;/a&gt; ? Well I've got one tiny and silly addition to it now, I can mass open files from any shell command line, with this little script placed in my &lt;code&gt;~/bin/&lt;/code&gt; (don't forget to &lt;code&gt;chmod +x&lt;/code&gt;):&lt;/p&gt;

&lt;pre&gt;
for i in $*; do
  /usr/bin/gvim --servername ash0 --remote-silent-tab $i
  sleep 1
done;
&lt;/pre&gt;


&lt;p&gt;The &lt;code&gt;sleep 1&lt;/code&gt; is necessary as vim does not seem to like being flooded with files.&lt;/p&gt;


&lt;p&gt;Example usage:&lt;/p&gt;

&lt;pre&gt;
sendtovim `grep foo *`
&lt;/pre&gt;


&lt;p&gt;Opens in vim all files containing &amp;quot;foo&amp;quot; in the current directory. Who said handy ?&lt;/p&gt;


&lt;p&gt;Note: I know have an &lt;a href=&quot;http://mirmodynamics.com/post/2008/10/16/Mass-vim-file-opening-reloaded&quot;&gt;updated and useful version of this script&lt;/a&gt;&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2008/10/14/Mass-vim-file-opening#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2008/10/14/Mass-vim-file-opening#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1141</wfw:commentRss>
      </item>
    
  <item>
    <title>Rename directories to lowercase</title>
    <link>http://mirmodynamics.com/post/2008/07/10/Rename-directories-to-lowercase</link>
    <guid isPermaLink="false">urn:md5:2cd7b053554f36efc38f1eedf42f7089</guid>
    <pubDate>Thu, 10 Jul 2008 15:35:00 +0200</pubDate>
    <dc:creator>Geoffrey</dc:creator>
        <category>Geekeries</category>
        <category>bash</category><category>handy</category><category>lowercase</category><category>shell</category><category>useless</category>    
    <description>    &lt;p&gt;Using a single (and somewhat simple) shell line, you can rename any directory to its lowercase version.&lt;/p&gt;

&lt;pre&gt;
for i in *; do lcase=`echo $i | tr A-Z a-z`; if [ ! -d $lcase ]; then mv $i $lcase; fi; done;
&lt;/pre&gt;


&lt;p&gt;Viva el chell !&lt;/p&gt;</description>
    
    
    
          <comments>http://mirmodynamics.com/post/2008/07/10/Rename-directories-to-lowercase#comment-form</comments>
      <wfw:comment>http://mirmodynamics.com/post/2008/07/10/Rename-directories-to-lowercase#comment-form</wfw:comment>
      <wfw:commentRss>http://mirmodynamics.com/feed/atom/comments/1111</wfw:commentRss>
      </item>
    
</channel>
</rss>