<?xml version="1.0" encoding="UTF-8"?>

<rss version="2.0"
 xmlns:blogChannel="http://backend.userland.com/blogChannelModule"
>

<channel>
<title><![CDATA[Dobrica Pavlinušić's random unstructured stuff: perl]]></title>
<link>https://saturn.ffzg.hr/rot13/index.cgi?action=weblog_display;category=perl</link>
<description></description>
<pubDate>Thu, 08 Nov 2007 12:49:55 -0000</pubDate>
<webMaster>root@saturn.ffzg.hr</webMaster>
<generator>Socialtext Workspace v2.19.0.2</generator>

<item>
<title><![CDATA[vz-tools]]></title>
<link>https://saturn.ffzg.hr/rot13/index.cgi?vz_tools</link>
<description><![CDATA[<div>Creator: Dobrica Pavlinušić</div><hr/><div>Tags: OpenVZ, perl, projects, virtualization</div><hr/><div class="wiki">
<p>
Suite of perl scripts in spirit of <a target="_blank" title="(external link)" href="http://www.xen-tools.org/">xen-tools<!-- wiki-renamed-hyperlink "xen=-tools"<http://www.xen=-tools.org/> --></a> but for <a target="_blank" title="(external link)" href="http://openvz.org/">OpenVZ<!-- wiki-renamed-hyperlink "OpenVZ"<http://openvz.org/> --></a></p>
<div class="nlw_phrase"><table class="wafl_container">
  <tr>
    <td>
      <div class="wafl_box">
        
          <div class="wafl_titlebox">
            <div class="wafl_title">
              
                Contents: [Dobrica Pavlinušić's random unstructured stuff]
              
            </div>
          </div>
          <div class="wafl_items">
            
              <div class="wiki">
<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#installation">Dobrica Pavlinušić's random unstructured stuff (Installation)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Installation} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#install_perl_dependencies_from_debian_packages">Dobrica Pavlinušić's random unstructured stuff (Install perl dependencies from Debian packages)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Install perl dependencies from Debian packages} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#install_utilities_from_debian_packages">Dobrica Pavlinušić's random unstructured stuff (Install utilities from Debian packages)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Install utilities from Debian packages} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#checkout_source">Dobrica Pavlinušić's random unstructured stuff (Checkout source)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Checkout source} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#check_and_install_perl_modules_from_cpan">Dobrica Pavlinušić's random unstructured stuff (Check and install perl modules from CPAN)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Check and install perl modules from CPAN} --></span></li>
</ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#usage">Dobrica Pavlinušić's random unstructured stuff (Usage)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Usage} --></span></li>

<ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#vz_create_pl">Dobrica Pavlinušić's random unstructured stuff (vz-create.pl)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] vz-=create.pl} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#vz_optimize_pl">Dobrica Pavlinušić's random unstructured stuff (vz-optimize.pl)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] vz-=optimize.pl} --></span></li>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#vz_clone_pl">Dobrica Pavlinušić's random unstructured stuff (vz-clone.pl)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] vz-=clone.pl} --></span></li>
</ul>
<li><span class="nlw_phrase"><a title="section link" href="https://saturn.ffzg.hr/rot13/index.cgi?dobrica_pavlinu%C5%A1i%C4%87_s_random_unstructured_stuff#source">Dobrica Pavlinušić's random unstructured stuff (Source)</a><!-- wiki: {link: [Dobrica Pavlinušić's random unstructured stuff] Source} --></span></li>
</ul>
</div>

            
            
          </div>
        
      </div>
    </td>
  </tr>
</table>
<!-- wiki: {toc: }
--></div><br /><br /><h1 id="installation">Installation</h1>
<h2 id="install_perl_dependencies_from_debian_packages">Install perl dependencies from Debian packages</h2>
<p>
This step is optional. If you don't want to use perl modules from packages provided by your distribution, skip this step, and modules will be automatically installed in next one.</p>
<pre>
sudo apt-get install libio-prompt-perl libregexp-common-perl libdata-dump-perl
</pre>
<br /><h2 id="install_utilities_from_debian_packages">Install utilities from Debian packages</h2>
<pre>
sudo apt-get install host
</pre>
<br /><h2 id="checkout_source">Checkout source</h2>
<pre>
svn co svn://svn.rot13.org/vz-tools/trunk vz-tools
</pre>
<br /><h2 id="check_and_install_perl_modules_from_cpan">Check and install perl modules from CPAN</h2>
<pre>
cd vz-tools
perl Makefile.PL
make
</pre>
<br /><p>
Please note that there is no need to run <tt>make install</tt></p>
<p>
Tools are runnable from current directory. This will probably change in later versions.</p>
<h1 id="usage">Usage</h1>
<p>
This is quick hand-on overview of commands to get you started.</p>
<p>
All commands must be started with <tt>root</tt> priviledges</p>
<h2 id="vz_create_pl">vz-create.pl</h2>
<p>
This will perform following steps:</p>
<ul>
<li>Create new virtual machine bootstraped using <tt>debootstrap</tt></li>
<li>Change root password</li>
<li>Create single user</li>
<li>Make small custimization like installing <tt>vim</tt> and <a target="_blank" title="(external link)" href="http://www.rot13.org/~dpavlin/apt-iselect.html">apt-iselect<!-- wiki-renamed-hyperlink "apt=-iselect"<http://www.rot13.org/~dpavlin/apt=-iselect.html> --></a></li>
</ul>
<p>
All commands will be echoed on screen, <strong>even passwords</strong>. However, if you want to learn steps in creating OpenVZ VE, this is very helpful.</p>
<p>
To run interactive session which asks questions use:</p>
<pre>
./vz-create.pl
</pre>
<br /><p>
Other alternative is to just enter hostname (defined in <tt>/etc/hosts</tt> for example)</p>
<pre>
./vz-create.pl my-new-ve.exmple.com
</pre>
<br /><p>
or by specifing IP adress</p>
<pre>
./vz-create.pl 192.168.42.42
</pre>
<br /><h2 id="vz_optimize_pl">vz-optimize.pl</h2>
<h2 id="vz_clone_pl">vz-clone.pl</h2>
<pre>
root@black:~/vz-tools# time ./vz-clone.pl create 1001
Clone VE 1001 -&gt; 101001
found LV /dev/vg/vz for /vz
vzquota : (warning) Quota is running, so data reported from quota file may not reflect current values
quota for 1001 | 10485760 &lt; 20971520 | usage: 7826792
using existing /dev/vg/vz-clone-101001
Mounting /dev/vg/vz-clone-101001 to /tmp/vz-clone-101001
rsync /vz/private/1001 -&gt; /tmp/vz-clone-101001/private
101001 new IP number: 10.42.42.42
101001 new hostname: clone-42.example.com

Please review config file: /etc/vz/conf/101001.conf
Add NAT for new VE with: iptables -t nat -A POSTROUTING -o eth0 -j MASQUERADE
Start clone of 1001 with: vzctl start 101001

real    1m57.347s
user    0m2.252s
sys     0m8.591s
</pre>
<br /><h1 id="source">Source</h1>
<div class="nlw_phrase"><div class="fetchrss_box">
  <div class="fetchrss_titlebox">
    
 <div class="fetchrss_title">
     fetchrss: http://svn.rot13.org/index.cgi/vz-tools/rss/trunk
 </div>

  </div>
  
<ul class="fetchrss_item">
  <li class="fetchrss_item">
    There was an error: 404 Not Found

  </li>
</ul>

</div>
















<!-- wiki: {fetchrss: http://svn.rot13.org/index.cgi/vz-=tools/rss/trunk full}
--></div><br /></div>
]]></description>
<author>Dobrica Pavlinu&#x161;i&#x107;</author>
<category>OpenVZ, perl, projects, virtualization</category>
<guid isPermaLink="true">https://saturn.ffzg.hr/rot13/index.cgi?vz_tools</guid>
<pubDate>Thu, 08 Nov 2007 12:49:55 -0000</pubDate>
</item>
<item>
<title><![CDATA[Exhibit facet browsing]]></title>
<link>https://saturn.ffzg.hr/rot13/index.cgi?exhibit_facet_browsing</link>
<description><![CDATA[<div>Creator: Dobrica Pavlinušić</div><hr/><div>Tags: csv, javascript, perl</div><hr/><div class="wiki">
<p>
We have few mp3 players which no longer work, but are still under warranty. So idea was to pick another device (which will hopefully work longer). However, on-line shops leave a lot to be desired if you want to just do quick filtering of data.</p>
<p>
As a very fortunate incident, I stumbled upon <a target="_blank" title="(external link)" href="http://simile.mit.edu/exhibit/">Exhibit<!-- wiki-renamed-hyperlink "Exhibit"<http://simile.mit.edu/exhibit/> --></a> from <a target="_blank" title="(external link)" href="http://simile.mit.edu/">SMILE<!-- wiki-renamed-hyperlink "SMILE"<http://simile.mit.edu/> --></a> project at MIT which brought us such nice tools as <a target="_blank" title="(external link)" href="http://simile.mit.edu/timeline/">Timeline<!-- wiki-renamed-hyperlink "Timeline"<http://simile.mit.edu/timeline/> --></a> and <a target="_blank" title="(external link)" href="http://simile.mit.edu/potluck/">Potluck<!-- wiki-renamed-hyperlink "Potluck"<http://simile.mit.edu/potluck/> --></a>.</p>
<p>
So, I scraped web, converted it to CSV and tried to do something with it. In the process I again re-visited the problem of semi-structured data: while data is separated in columns, one column has generic description, player name and all characteristics in it.</p>
<p>
So, what did I do? Well, I started with CPAN and few hours later I had a <a target="_blank" title="(external link)" href="http://svn.rot13.org/index.cgi/simile/view/links/csv2js.pl">script which is rather good in parsing semi-structured CSV files<!-- wiki-renamed-hyperlink "script which is rather good in parsing semi=-structured CSV files"<http://svn.rot13.org/index.cgi/simile/view/links/csv2js.pl> --></a>. It supports following:</p>
<ul>
<li>guess CSV delimiter on it's own (using <a target="_blank" title="(external link)" href="http://search.cpan.org/~enell/Text-CSV-Separator/">`Text::CSV::Separator`<!-- wiki-renamed-hyperlink "`Text::CSV::Separator`"<http://search.cpan.org/~enell/Text=-CSV=-Separator/> --></a>)</li>
<li>recognize 10 Kb and similar sizes and normalize them (using <a target="_blank" title="(external link)" href="http://search.cpan.org/~ferreira/Number-Bytes-Human/">`Number::Bytes::Human`<!-- wiki-renamed-hyperlink "`Number::Bytes::Human`"<http://search.cpan.org/~ferreira/Number=-Bytes=-Human/> --></a>)</li>
<li>splitting of comma (<tt>,</tt>) separated values within single field</li>
<li>strip common prefix from all values in one column</li>
<li>group values and produce additional properties in data</li>
<li>generate specified number of groups for numeric data, useful for price ranges</li>
<li>produce JSON output for Exhibit using <a target="_blank" title="(external link)" href="http://search.cpan.org/~audreyt/YAML-Syck/">`JSON::Syck`<!-- wiki-renamed-hyperlink "`JSON::Syck`"<http://search.cpan.org/~audreyt/YAML=-Syck/> --></a></li>
</ul>
<p>
<a target="_blank" title="(external link)" href="&quot;<br />
&nbsp;So how does it look?&quot;http://blog.rot13.org/demo/links/links.html">&quot;<br />
&nbsp;So how does it look?&quot;http://blog.rot13.org/demo/links/links.html</a></p>
<p>
In the end, it is very similar to the way <a target="_blank" title="(external link)" href="http://www.dabbledb.com/">Dabble DB<!-- wiki-renamed-hyperlink "Dabble DB"<http://www.dabbledb.com/> --></a> parses your input. But, I never actually had any luck importing data into Dabble DB, so this one works better for me <tt>:-)</tt></p>
<p>
This will probably evolve to universal munger from CSV to arbitrary hash structure. What would be good name? <tt>Text::CSV::Mungler</tt>?</p>
<p>
This is a first post in series of posts which will cover one hack a week on my blog. This will (hopefully) force me to write at least one post a week on one side, and provide some historic trace about my work for later.</p>
</div>
]]></description>
<author>Dobrica Pavlinu&#x161;i&#x107;</author>
<category>csv, javascript, perl</category>
<guid isPermaLink="true">https://saturn.ffzg.hr/rot13/index.cgi?exhibit_facet_browsing</guid>
<pubDate>Fri, 24 Aug 2007 09:07:17 -0000</pubDate>
</item>
</channel>
</rss>