<?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>Martin Ankerl &#187; tutorial</title> <atom:link href="http://martin.ankerl.com/tag/tutorial/feed/" rel="self" type="application/rss+xml" /><link>http://martin.ankerl.com</link> <description>Chunky bacon!!</description> <lastBuildDate>Sat, 04 Feb 2012 10:02:31 +0000</lastBuildDate> <language>en</language> <sy:updatePeriod>hourly</sy:updatePeriod> <sy:updateFrequency>1</sy:updateFrequency> <item><title>Logical Volume Manager Cheatsheet</title><link>http://martin.ankerl.com/2008/02/05/logical-volume-manager-cheatsheet/</link> <comments>http://martin.ankerl.com/2008/02/05/logical-volume-manager-cheatsheet/#comments</comments> <pubDate>Mon, 04 Feb 2008 23:08:47 +0000</pubDate> <dc:creator>martinus</dc:creator> <category><![CDATA[howto]]></category> <category><![CDATA[linux]]></category> <category><![CDATA[tutorial]]></category> <category><![CDATA[ubuntu]]></category><guid isPermaLink="false">http://martin.ankerl.com/2008/02/05/logical-volume-manager-cheatsheet/</guid> <description><![CDATA[Today I got a new harddisk, so it was finally time for me to have an in depth look at LVM. I use it to combine two harddisks /dev/sdg1 and /dev/sdb1 into one volume group ext_vg which contains one big &#8230; <a href="http://martin.ankerl.com/2008/02/05/logical-volume-manager-cheatsheet/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p>Today I got a new harddisk, so it was finally time for me to have an in depth look at <a href="http://sources.redhat.com/lvm2/">LVM</a>. I use it to combine two harddisks <tt>/dev/sdg1</tt> and <tt>/dev/sdb1</tt> into one volume group <tt>ext_vg</tt> which contains one big logical volume <tt>/dev/ext_vg/ext</tt>. In short, my 250GB and 500GB harddisks are used in one big 750GB ext3 mount point.</p><p>I followed the excellent <a href="http://www.linuxconfig.org/Linux_lvm_-_Logical_Volume_Manager">LVM Tutorial</a>, and was surprised how easy everything goes. Here is a short cheat sheet of the important commands (take care to exchange the partition/volume names if you use this):</p><h2>Installation</h2><p>I use <a href="http://www.ubuntu.com/">Ubuntu</a>, so this is a piece of cake:<pre>sudo apt-get install lvm2</pre><p>There is also <a href="http://ubuntuforums.org/showthread.php?t=216117">a GUI available</a>, but I found the command line tools are very easy to use so there is no real need. I wouldn&#8217;t use <a href="https://wiki.ubuntu.com/Evms">EVMS</a> as it is not supported in Ubuntu 7.10 and may cause problems.</p><h2>Create a New Filesystem</h2><p>First I create the physical volume on the partition <tt>sdg1</tt>, create a new volume group <tt>ext_vg</tt> that contains this physical volume, and create a new logical volume of size 450GB within the volume group. Finally create the filesystem (disabled reservation space, see <a href="http://martin.ankerl.com/2008/01/12/get-more-space-out-of-your-ext3-partition/">Get More Space Out of Your ext3 Partition</a>).<pre>sudo pvcreate /dev/sdg1
sudo vgcreate ext_vg /dev/sdg1
sudo lvcreate -L 450G -n ext ext_vg
sudo mkfs.ext3 -m 0 /dev/ext_vg/ext</pre><h2>Show Status</h2><p>Each LVM layer has its corresponding command to get information about the metadata:<pre>sudo pvdisplay
sudo vgdisplay
sudo lvdisplay
sudo pvs
sudo vgs
sudo lvs</pre><h2>Mount via fstab</h2><p>I use the filesystem mainly for data, so allowing just <tt>rw</tt> is enough (no executables allowed). <tt>noatime</tt> allows quicker access.<pre>sudo mkdir /media/mega
/dev/ext_vg/ext /media/mega     ext3    rw,noatime,user 0       2
mount /media/mega</pre><h2>Resize</h2><p>It is even possible to do an online resize of the system, wohoo <img src="http://martin.ankerl.com/wp-includes/images/smilies/icon_smile.gif?9d7bd4" alt=':-)' class='wp-smiley' /> This extends the logical volume by 200MB.<pre>sudo lvextend -L +200 /dev/ext_vg/ext
sudo resize2fs -p /dev/ext_vg/ext</pre><p> You can watch the resize process going on with <tt>df -h</tt>.</p><h2>Add Another Partition to the Logical Volume</h2><p>To add another partition and use up all the available space in the logical volume, first add the physical volume to the volume group, then use <tt>pvdisplay</tt> to find out the total available number of free PE (add the numbers from the physical volumes), then use <tt>lvextend</tt> to use up all this available space.<pre>sudo pvcreate /dev/sdb1
sudo vgextend ext_vg /dev/sdb1
sudo pvdisplay
sudo lvextend -l +63602 /dev/ext_vg/ext
sudo resize2fs /dev/ext_vg/ext</pre><p>That&#8217;s it! Any questions? please post.</p><div style='clear:both'></div>]]></content:encoded> <wfw:commentRss>http://martin.ankerl.com/2008/02/05/logical-volume-manager-cheatsheet/feed/</wfw:commentRss> <slash:comments>7</slash:comments> </item> <item><title>Ajax Dojo Comet Tutorial</title><link>http://martin.ankerl.com/2007/08/21/ajax-dojo-comet-tutorial/</link> <comments>http://martin.ankerl.com/2007/08/21/ajax-dojo-comet-tutorial/#comments</comments> <pubDate>Tue, 21 Aug 2007 12:41:22 +0000</pubDate> <dc:creator>martinus</dc:creator> <category><![CDATA[ajax]]></category> <category><![CDATA[coding]]></category> <category><![CDATA[java]]></category> <category><![CDATA[programming]]></category> <category><![CDATA[tutorial]]></category> <category><![CDATA[videos]]></category> <category><![CDATA[comet]]></category> <category><![CDATA[dojo]]></category> <category><![CDATA[howto]]></category><guid isPermaLink="false">http://martin.ankerl.com/?p=92</guid> <description><![CDATA[EDIT: This tutorial is for an old version of dojo / comet, and it will not work in a recent version! Markus Holzmann, an intern at Profactor of my fellow colleague Philipp Hartl, had the opportunity to experiment with Ajax &#8230; <a href="http://martin.ankerl.com/2007/08/21/ajax-dojo-comet-tutorial/">Continue reading <span class="meta-nav">&#8594;</span></a>]]></description> <content:encoded><![CDATA[<p><strong>EDIT</strong>: This tutorial is for an old version of dojo / comet, and it will not work in a recent version!</p><p>Markus Holzmann, an intern at <a href="http://www.profactor.at/">Profactor</a> of my fellow colleague <a href="http://leanaustria.net/">Philipp Hartl</a>, had the opportunity to experiment with <a href="http://en.wikipedia.org/wiki/Ajax_(programming)">Ajax</a> during his job. He wrote a tutorial about how to push events from the server to the client. For example, display popup messages on all browsers at the same time (see screencast in <a href="/files/hello_comet.html" target="_blank">full resolution here</a>):<br /><center><br /> <a href="/files/hello_comet.html" target="_blank"> <object width="400" height="317"><param name="wmode" value="transparent"></param> <embed src="/files/Hello_Comet.swf?9d7bd4" wmode="transparent" width="401" height="317" type="application/x-shockwave-flash"></embed></object><br /> </a><br /></center><br /> Read on how Markus did this:</p><p><span id="more-92"></span></p><h1>Cometd Hello World</h1><p> I&#8217;ve read Chris Bucchere&#8217;s <a href="http://thebdgway.blogspot.com/2006/11/say-hello-world-to-comet.html">Say Hello World to Comet</a> and built an application based on this using a more current version of <a href="http://www.mortbay.org/">Jetty</a> (version <a href="http://dist.codehaus.org/jetty/jetty-6.1.5/">6.1.5</a>) which I embedded into a <a href="http://tomcat.apache.org/">Tomcat</a> v5.5 Server. For the developing I used <a href="http://www.eclipse.org/">Eclipse</a> 3.2.</p><p><h1>Start your Engines</h1><p>At first you have to get the server running. As I mentioned I embedded Jetty into a Tomcat server. Therefore you have configure the libraries:</p><ol><li>Add the packages <tt>org.mortbay.cometd</tt> and <tt>dojox.cometd</tt> to your source folder and delete the <tt>client</tt> package in the <tt>org.mortbay.cometd</tt> package.</li><li>Add <tt>jetty-util-6.1.5.jar</tt>, <tt>jetty-6.1.5.jar</tt> and <tt>servlet-api-2.5-6.1.5.jar</tt> to your build path.</li><li>Copy the <tt>jetty-util-6.1.5.jar</tt> file into the <tt>/lib</tt> folder in the <tt>WEB-INF</tt> directory.</li></ol><p>Replace the existing servlets in your web.xml &#8211; file in the WEB-INF &#8211; folder with the following servlets:</p><pre class="brush: xml; title: ; notranslate">&lt;servlet&gt;
  &lt;servlet-name&gt;cometd&lt;/servlet-name&gt;
  &lt;servlet-class&gt;org.mortbay.cometd.continuation.ContinuationCometdServlet&lt;/servlet-class&gt;
  &lt;load-on-startup&gt;1&lt;/load-on-startup&gt;
&lt;/servlet&gt;
&lt;servlet-mapping&gt;
  &lt;servlet-name&gt;cometd&lt;/servlet-name&gt;
  &lt;url-pattern&gt;/cometd/*&lt;/url-pattern&gt;
 &lt;/servlet-mapping&gt;
</pre><p>For the project I used the <a href="http://dojotoolkit.org/">dojo toolkit</a> (version 0.4.3) which has an integrated <a href="http://www.cometd.com/">COMETd</a> class that makes it easy to build comet projects. <a href="http://download.dojotoolkit.org/release-0.4.3/dojo-0.4.3-ajax.tar.gz">Download it</a> and add it to your <tt>WebContent</tt> folder.</p><p> When you&#8217;ve done all this, the hardest piece of work for this program is already done.</p><h1>Hack the Code</h1><p>Now you can implement the code for the client side: You need a HTML file with a button on it. The code for this looks like this (<a href="/files/hello_comet_test.html">download</a>):</p><pre class="brush: jscript; title: ; notranslate">&lt;html&gt;
  &lt;head&gt;
    &lt;script type=&quot;text/javascript&quot; src=&quot;../dojo.js&quot;&gt;&lt;/script&gt;
    &lt;script type=&quot;text/javascript&quot;&gt;
      dojo.require(&quot;dojo.io.cometd&quot;);

      cometd.init({}, &quot;cometd&quot;);

      cometd.subscribe(&quot;/hello/world&quot;, false, &quot;publishHandler&quot;);

      publishHandler = function(msg) {
        alert(msg.data.test);
      }
    &lt;/script&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;input type=&quot;button&quot;
       onclick=&quot;&lt;b&gt;cometd.publish('/hello/world', { test: 'hello world' } )&lt;/b&gt;&quot;
       value=&quot;Click Me!&quot;&gt;
  &lt;/body&gt;
&lt;/html&gt;</pre><p>Line by line, the above bold code works like this:</p><ol><li>In the line<pre class="brush: xml; title: ; notranslate">&lt;script type=&quot;text/javascript&quot; src=&quot;../dojo.js&quot;&gt;&lt;/script&gt;</pre><p> you integrate the dojo toolkit into the project.</p><li>To activate the cometd class of dojo:<pre class="brush: jscript; title: ; notranslate">dojo.require(&quot;dojo.io.cometd&quot;);</pre><li>Connect the server with the client:<pre class="brush: jscript; title: ; notranslate">cometd.init({}, &quot;cometd&quot;);</pre><li>Here we say what to do when there is a subscribe event:<pre class="brush: jscript; title: ; notranslate">cometd.subscribe(&quot;/hello/world&quot;, false, &quot;publishHandler&quot;);</pre><li>Last but not least, the <tt>publishHandler</tt> function serves as the callback function, which uses <tt>alert</tt> to show a simple message box:<pre class="brush: jscript; title: ; notranslate">publishHandler = function(msg) {
  alert(msg.data.test);
}</pre></ol><h1>Give it a Try</h1><p>When you load the HTML file now, you can click on the button and an alert box saying <i>hello world</i> will appear:</p><p><center><img src="/files/helloworld.png?9d7bd4" width="324" height="124" /></center></p><p> The reason for this is that when you click the code<pre class="brush: jscript; title: ; notranslate">cometd.publish('/hello/world', { test: 'hello world' } )</pre><p> is executed which publishes a text on the channel with the id <tt>/hello/world</tt>.</p><p> The funny thing is that this is able to run on any number of browsers. Everytime when a client clicks the button, on <i>all</i> browsers that view this page the alert box is shown. (See screencast above).</p><h1>Pushing Data from Server to Client</h1><p>You can also add serverside code to trigger an event. I wrote a JSP file with the following code:</p><pre class="brush: xml; title: ; notranslate">&lt;%@page import=&quot;java.util.*&quot;%&gt;
&lt;%@page import=&quot;dojox.cometd.*&quot; %&gt;
&lt;%
Bayeux b = (Bayeux)getServletContext().getAttribute(Bayeux.DOJOX_COMETD_BAYEUX);
Channel c = b.getChannel(&quot;/hello/world&quot;,false);

Map&lt;String,Object&gt; message = new HashMap&lt;String,Object&gt;();
message.put(&quot;test&quot;, &quot;jsp: hello world&quot;);

c.publish(b.newClient(&quot;server_user&quot;,null),message, &quot;new server message&quot;);
%&gt;</pre><p>When this page is loaded, an alert popup appears at the page saying <i>jsp: hello world</i>.</p><p>Remember pushing too much data from server to client can slow the performance of your site specially is you have a huge amount of traffic. Getting one of the <a href="http://www.webhostingsearch.com/wordpress-hosting.php" title="best wordpress hosting">best wordpress hosting</a> will solve this kind of problem.</p><p>That&#8217;s it. Happy hacking!</p><div style='clear:both'></div>]]></content:encoded> <wfw:commentRss>http://martin.ankerl.com/2007/08/21/ajax-dojo-comet-tutorial/feed/</wfw:commentRss> <slash:comments>30</slash:comments> </item> </channel> </rss>
<!-- Performance optimized by W3 Total Cache. Learn more: http://www.w3-edge.com/wordpress-plugins/

Minified using disk: basic
Page Caching using disk: enhanced
Database Caching 1/12 queries in 0.056 seconds using disk: basic
Object Caching 533/555 objects using disk: basic

Served from: martin.ankerl.com @ 2012-02-04 11:07:03 -->
