<?xml version='1.0' encoding='UTF-8'?><?xml-stylesheet href="http://www.blogger.com/styles/atom.css" type="text/css"?><feed xmlns='http://www.w3.org/2005/Atom' xmlns:openSearch='http://a9.com/-/spec/opensearchrss/1.0/' xmlns:georss='http://www.georss.org/georss' xmlns:gd='http://schemas.google.com/g/2005' xmlns:thr='http://purl.org/syndication/thread/1.0'><id>tag:blogger.com,1999:blog-1925150244565910364</id><updated>2012-02-16T13:21:28.970+02:00</updated><category term='Zend Framework'/><category term='Mac OS X'/><category term='JQuery'/><category term='Ubuntu'/><category term='PostgreSQL'/><category term='YUI'/><category term='Linux'/><category term='Networking'/><title type='text'>Vlado Chavkov's Blog</title><subtitle type='html'></subtitle><link rel='http://schemas.google.com/g/2005#feed' type='application/atom+xml' href='http://blog.chavkov.com/feeds/posts/default'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default?max-results=100'/><link rel='alternate' type='text/html' href='http://blog.chavkov.com/'/><link rel='hub' href='http://pubsubhubbub.appspot.com/'/><author><name>Vlado Chavkov</name><uri>http://www.blogger.com/profile/03128216458383764972</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_9RxhR8IlDWk/Sif69ObJkCI/AAAAAAAAAr0/Y103Z6QXo1g/S220/b34f.jpg'/></author><generator version='7.00' uri='http://www.blogger.com'>Blogger</generator><openSearch:totalResults>12</openSearch:totalResults><openSearch:startIndex>1</openSearch:startIndex><openSearch:itemsPerPage>100</openSearch:itemsPerPage><entry><id>tag:blogger.com,1999:blog-1925150244565910364.post-1737996500455620818</id><published>2010-10-28T20:20:00.001+03:00</published><updated>2010-10-28T20:39:25.862+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='JQuery'/><category scheme='http://www.blogger.com/atom/ns#' term='YUI'/><title type='text'>jQuery and YUI 3: A Tale of Two JavaScript Libraries</title><content type='html'>jQuery and YUI 3: A Tale of Two JavaScript Libraries "&lt;p&gt;Recently I had the opportunity to build my first JavaScript front end application. What follows is a short story of the discovery and evolution that comes about when trying to use tools that aren’t suited for the job at hand. It is an account of the learning acquired through developing the same front end application using two very different libraries, jQuery and YUI 3. Details of the client and the project have been intentionally omitted.&lt;/p&gt;&lt;br /&gt;&lt;h3&gt;Overview&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;The project involved the refactoring of several disparate Flash tools into a single interactive application based on open standards for a large content publisher. Of high importance, the application had to be highly optimised with a small initial foot print due the large number of daily page impressions the client receives. Several phases were involved, with the first being an initial proof of concept.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;The concept involved the development of one view of what would be the completed application. It consisted of:&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;An initial seed file (&amp;lt; 1KB) responsible for the dynamic loading of any frameworks (e.g., jQuery or YUI 3) and the initial application file.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The development and inclusion of jQuery plugins to support form element styling and validation, and dynamic chart visualisations.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The generation and population of UI, based on user inputs, configuration defaults and the application’s location within the publisher’s site.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;The calculation and presentation of information based on the user’s input.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;In the interest of full disclosure, my own experience up to this point had been in developing small, standalone solutions, the type of which you could typically describe as plugins. These included dynamic UI components such as image carousels, interactive maps and Twitter / Flickr widgets. At the time of first dabbling with JavaScript, jQuery was popular, easy to learn and allowed me to quickly pick up the basics needed for the projects I was working on. However these were all standalone units and had no need to interact with other code or as part of a larger application.&lt;/p&gt;&lt;br /&gt;&lt;h3&gt;First Attempt&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;On completing the first phase of the project, it became painfully obvious that I was dealing with a very different beast than what I was used to. Having had little experience in code organisation, my code quickly became disorganised, inefficient and repetitive. As a result, the first part of what would become a much larger application was slow to load. In fact it took eight seconds to generate that single proof of concept. A big change was needed and while I had considered using a small library like &lt;a href="http://dean.edwards.name/weblog/2006/03/base/" title="Dean Edward&amp;#39;s Base"&gt;Dean Edward’s Base&lt;/a&gt;  or &lt;a href="http://ejohn.org/blog/simple-javascript-inheritance/" title="John Resig&amp;#39;s Simple JavaScript Inheritance"&gt;John Resig’s Simple JavaScript Inheritance&lt;/a&gt; pattern to add class-based inheritance to jQuery, I decided to go one step further.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;What I wanted was a complete, mature framework within which to develop my first OO application. Something that would effectively guide me through the process. In reviewing the available libraries I decided to adopt YUI 3 for the following reasons:&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Integrated, inheritance-based application development support including attribute and class management.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Long term solution:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Support for standards and accessibility.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Funded by a large well known organisation, Yahoo!&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Associated with respected names like &lt;a href="http://www.crockford.com/"&gt;Douglas Crockford&lt;/a&gt;, &lt;a href="http://twitter.com/slicknet"&gt;Nicholas Zakas&lt;/a&gt;, and &lt;a href="http://twitter.com/stoyanstefanov"&gt;Stoyan Stefanov&lt;/a&gt;.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Performance optimisation:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Initial seed file of only 7KB.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Lazy-loaded modules on demand.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;CDN delivery.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Varied and comprehensive documentation:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://developer.yahoo.com/yui/3/"&gt;Yahoo! Developer Network&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://developer.yahoo.com/yui/3/api/"&gt;YUI 3 API Documentation&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://developer.yahoo.com/yui/theater/"&gt;YUI Theater&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://yuilibrary.com/"&gt;YUI Library&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://www.yuiblog.com/"&gt;YUI Blog&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Mature, consistent evolution between releases.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Integrated tools in &lt;a href="http://yuilibrary.com/projects/yuicompressor/"&gt;YUI Compressor&lt;/a&gt;, &lt;a href="http://yuilibrary.com/projects/yuidoc"&gt;YUIDoc&lt;/a&gt;, &lt;a href="http://yuilibrary.com/projects/builder"&gt;YUI Builder&lt;/a&gt;, and &lt;a href="http://developer.yahoo.com/yui/3/console/"&gt;Console&lt;/a&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Not just JavaScript, a CSS framework too.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h3&gt;Take Two&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;Integrating YUI 3 brought several direct and indirect benefits to the project:&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Inheritance-based architecture and class management through the &lt;a href="http://developer.yahoo.com/yui/3/attribute/"&gt;Attribute&lt;/a&gt; interface, and &lt;a href="http://developer.yahoo.com/yui/3/base/"&gt;Base&lt;/a&gt; and &lt;a href="http://developer.yahoo.com/yui/3/widget/"&gt;Widget&lt;/a&gt; classes producing performant, reusable and organised code.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Separation of presentation from model and data using the &lt;a href="http://developer.yahoo.com/yui/3/widget/"&gt;Widget&lt;/a&gt; class to render alternate views (inline or overlay) based on the application’s location within the site.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://developer.yahoo.com/yui/3/yui/#why"&gt;Sandboxing&lt;/a&gt; and dynamic &lt;a href="http://developer.yahoo.com/yui/3/yui/#modulelist"&gt;module&lt;/a&gt; inclusion through YUI.use().&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Cross-browser console debugging using &lt;a href="http://developer.yahoo.com/yui/3/console/"&gt;YUI Console&lt;/a&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;On save, performance optimisation using &lt;a href="http://yuilibrary.com/projects/yuicompressor/"&gt;YUI Compressor&lt;/a&gt; in Eclipse.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Easy inclusion and integration of pre-existing jQuery plugins.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;On save, automated code documentation using &lt;a href="http://developer.yahoo.com/yui/yuidoc/"&gt;YUIDoc&lt;/a&gt;.&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;p&gt;The final result was a happy client and a finished product with sub-second load times (remembering it took 8 seconds to load the initial proof of concept).&lt;/p&gt;&lt;br /&gt;&lt;h3&gt;Lessons Learned&lt;/h3&gt;&lt;br /&gt;&lt;dl&gt;&lt;br /&gt;&lt;dt&gt;Select the right tool for the job&lt;/dt&gt;&lt;br /&gt;&lt;dd&gt;&lt;br /&gt;&lt;p&gt;In reading this post I’m sure some readers will view this as anti-jQuery. Not at all. jQuery is a fantastic project responsible for many innovations. But, as with any tool, it has its strengths and an intended purpose. Its strength lies in normalising browser inconsistencies, lowering the barrier to entry for the novice and improving the efficiency of experienced programmers. The primary learning that came out of the project was that you can’t rely on one tool for every job. YUI builds on what jQuery can provide by also offering a well architected application framework. But it’s fair to say that it comes at a cost, see the next point.&lt;/p&gt;&lt;br /&gt;&lt;/dd&gt;&lt;br /&gt;&lt;dt&gt;Steep learning curve&lt;/dt&gt;&lt;br /&gt;&lt;dd&gt;&lt;br /&gt;&lt;p&gt;You need patience, especially when writing your very first application with an unfamiliar library as I did. However the payoff is immense. By learning another library, not only will your core JavaScript skills improve, you’ll also develop a deeper understanding of how libraries work and the benefits they bring. I try to learn something new about YUI everyday and the more I learn, the more I’m in awe of the thought and sheer talent that’s gone into building YUI.&lt;/p&gt;&lt;br /&gt;&lt;/dd&gt;&lt;br /&gt;&lt;dt&gt;Only load content when you need it&lt;/dt&gt;&lt;br /&gt;&lt;dd&gt;&lt;br /&gt;&lt;p&gt;While it’s certainly programmatically easier to just to load everything you may need upfront, the performance improvements gained as a direct result of lazy loading content only when you need it is huge. This was one of the key contributing factors for drastically improving the performance of the application.&lt;/p&gt;&lt;br /&gt;&lt;/dd&gt;&lt;br /&gt;&lt;dt&gt;Interact with the DOM as little as possible&lt;/dt&gt;&lt;br /&gt;&lt;dd&gt;&lt;br /&gt;&lt;p&gt;This point doesn’t relate to the specific library used. By caching the required DOM elements and utilising HTML templates more, UI rendering time fell considerably. Nodes can be cached using Y.one() while node lists can be captured using Y.all(). Also Y.Node.create() was very useful in efficiently converting large text strings of HTML to DOM elements prior to insertion.&lt;/p&gt;&lt;br /&gt;&lt;/dd&gt;&lt;br /&gt;&lt;dt&gt;Learn by example, use a CDN&lt;/dt&gt;&lt;br /&gt;&lt;dd&gt;&lt;br /&gt;&lt;p&gt;In using YUI’s CDN delivered library we decided to deliver all the project’s assets via CDN. This was probably the next largest contributing factor to the performance improvement.&lt;/p&gt;&lt;br /&gt;&lt;/dd&gt;&lt;br /&gt;&lt;dt&gt;Pub, sub hubbub&lt;/dt&gt;&lt;br /&gt;&lt;dd&gt;&lt;br /&gt;&lt;p&gt;For those experienced programmers out there, try not to laugh at this one. Having been used to writing little more than plugins in the past, I had no idea how applications should communicate internally. Even after reading “Custom Events allow you to publish the interesting moments or events in your own code so that other components on the page can subscribe to those events and respond to them,” I still missed it.&lt;/p&gt;&lt;br /&gt;&lt;p&gt;As it turns out, YUI’s custom event publish-and-subscribe model works beautifully for inter-class and inter-object communication. You can even subscribe pre and post to events and include dynamic logic to suppress bubbling based on certain conditions.&lt;/p&gt;&lt;br /&gt;&lt;/dd&gt;&lt;br /&gt;&lt;dt&gt;Integrate best practice into your workflow&lt;/dt&gt;&lt;br /&gt;&lt;dd&gt;&lt;br /&gt;&lt;p&gt;Using Eclipse we were able to integrate JSLint and YUI Compressor into the build process. Put simply, every time you hit Ctrl / Cmd + S your JavaScript code is validated and optimised. That means you’re testing against optimised, production grade code from the very first line of code. It also means that you won’t forget to optimise in the frantic final race to the delivery deadline.&lt;/p&gt;&lt;br /&gt;&lt;/dd&gt;&lt;br /&gt;&lt;/dl&gt;&lt;br /&gt;&lt;h3&gt;Learning YUI on the Job&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;Although everyone has a different  learning style, I thought I’d share what resources I used to learn YUI with a specific objective in mind.&lt;/p&gt;&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;Watch the relevant YUI Theater episodes to get a general overview of the library or learn a specific module. I can highly recommend starting with:&lt;br /&gt;&lt;ul&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://developer.yahoo.com/yui/theater/video.php?v=miraglia-yuiconf2009-yui3"&gt;Eric Miraglia’s Welcome to YUI 3&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://developer.yahoo.com/yui/theater/video.php?v=kloots-yuiconf2009-sugar"&gt;Todd Kloots on YUI 3 Sugar&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://developer.yahoo.com/yui/theater/video.php?v=sweeney-yuiconf2009-performance"&gt;Matt Sweeney’s YUI 3 Performance&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://developer.yahoo.com/yui/theater/video.php?v=smith-yuiconf2009-debugging"&gt;Luke Smith’s Debugging in YUI 3&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://developer.yahoo.com/yui/theater/video.php?v=schlueter-yuiconf2009-yui3"&gt;Isaac Schlueter on Solving Problems with YUI 3&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://developer.yahoo.com/yui/theater/video.php?v=ericf-yuiconf2009-webapps"&gt;Eric Ferraiuolo on Web App Development with YUI 3&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;&lt;a href="http://developer.yahoo.com/yui/theater/video.php?v=smith-yuiconf2009-events"&gt;Luke Smith’s Events Evolved&lt;/a&gt;&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Read up on YUI on the &lt;a href="http://developer.yahoo.com/yui/3/"&gt;Yahoo! Developer Network&lt;/a&gt;. I try to read a little bit every week and learn more each time I re-read it.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Read the &lt;a href="http://developer.yahoo.com/yui/3/api/"&gt;API&lt;/a&gt; documentation. If you can’t find it on YUI Theater or on the Developer Network, dig into the API. It even pays to read the code directly.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Read and post questions to the &lt;a href="http://yuilibrary.com/forum/"&gt;forum on YUILibrary.com&lt;/a&gt;.&lt;/li&gt;&lt;br /&gt;&lt;li&gt;Play a lot and have fun!&lt;/li&gt;&lt;br /&gt;&lt;/ul&gt;&lt;br /&gt;&lt;h3&gt;Conclusion&lt;/h3&gt;&lt;br /&gt;&lt;p&gt;YUI 3 is a full-featured, mature and constantly evolving library suitable for small to large projects. As front end web applications become more complex, the need for libraries like YUI will grow. While for the uninitiated it can be a daunting experience at first, if you stick with it you will be rewarded.&lt;/p&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;div&gt;&lt;br /&gt;&lt;p&gt;&lt;img src="http://yuiblog.com/assets/mark-rall.jpg" width="150" height="150" hspace="10" vspace="5" align="right"&gt;&lt;strong&gt;About the Author:&lt;/strong&gt; &lt;em&gt;Mark is a Senior Front End Developer at &lt;a href="http://vi.com.au/"&gt;VI&lt;/a&gt;, a multi-disciplinary communications agency established in 1981 with a design orientation. Today the agency fuses its work in digital, direct and design disciplines to deliver measurable outcomes for a broad range of B2C and B2B clients.&lt;/em&gt;&lt;/p&gt;&lt;br /&gt;&lt;/div&gt;&lt;br /&gt;&lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1925150244565910364-1737996500455620818?l=blog.chavkov.com' alt='' /&gt;&lt;/div&gt;</content><link rel='related' href='http://feeds.yuiblog.com/~r/YahooUserInterfaceBlog/~3/Tm2vgJY6EDA/' title='jQuery and YUI 3: A Tale of Two JavaScript Libraries'/><link rel='replies' type='application/atom+xml' href='http://blog.chavkov.com/feeds/1737996500455620818/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1925150244565910364&amp;postID=1737996500455620818' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/1737996500455620818'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/1737996500455620818'/><link rel='alternate' type='text/html' href='http://blog.chavkov.com/2010/10/jquery-and-yui-3-tale-of-two-javascript.html' title='jQuery and YUI 3: A Tale of Two JavaScript Libraries'/><author><name>Vlado Chavkov</name><uri>http://www.blogger.com/profile/03128216458383764972</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_9RxhR8IlDWk/Sif69ObJkCI/AAAAAAAAAr0/Y103Z6QXo1g/S220/b34f.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1925150244565910364.post-3331337582370498654</id><published>2010-07-25T12:29:00.001+03:00</published><updated>2010-07-25T12:30:37.480+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'>tar — how to create and extract tar.gz and tar.bz2 archives</title><content type='html'>Introduction&lt;br /&gt;&lt;br /&gt;The commonly employed archive types on Linux and Unix systems are tar, tar.gz and tar.bz2 archives. Note that tar.gz and tar.bz2 archives are simply gzip-ped and bzip(2)-ped tar archives, respectively. Working with these files is made very simple through the use of GNU tar utility, which is included as part of the base packages in modern distros. In this article, I'll show you how to create and extract compressed archives using tar.&lt;br /&gt;&lt;br /&gt;So, how is tar used? Lets start by looking at some of the common tar operations and options.&lt;br /&gt;&lt;br /&gt;man tar  # ©2007 linux.dsplabs.com.au&lt;br /&gt;&lt;br /&gt;The following tar usage information is taken directly from the man pages.&lt;br /&gt;&lt;br /&gt;Usage:&lt;br /&gt;   tar &lt;operation&gt; [options]&lt;br /&gt;&lt;br /&gt;Common Operations:&lt;br /&gt;   -A, --catenate, --concatenate    append tar files to an archive&lt;br /&gt;   -c, --create                     create a new archive&lt;br /&gt;   -r, --append                     append files to the end of an archive&lt;br /&gt;   -x, --extract, --get             extract files from an archive&lt;br /&gt;&lt;br /&gt;Common Options:&lt;br /&gt;   -f, --file [HOSTNAME:]F          use archive file or device F&lt;br /&gt;                                    (default "-", meaning stdin/stdout)&lt;br /&gt;   -j, --bzip2                      filter archive through bzip2,&lt;br /&gt;                                    use to decompress .bz2 files&lt;br /&gt;   -p, --preserve-permissions       extract all protection information&lt;br /&gt;   -v, --verbose                    verbosely list files processed&lt;br /&gt;   -z, --gzip, --ungzip             filter the archive through gzip,&lt;br /&gt;                                    use to decompress .gz files&lt;br /&gt;&lt;br /&gt;Note that the GNU tar utility does not require a preceding minus for the single letter options (thanks to correct, see comments below).&lt;br /&gt;&lt;br /&gt;Creating archives&lt;br /&gt;&lt;br /&gt;To create a tar archive the c switch is used. To further encode it using gzip compression the z option is also added, or for bzip2 compression the j switch is used instead. Note that tar program pipes its output into gzip and bzip2 tools in order to create the tar.gz and tar.bz2 archives, respectively. OK, to compress a directory called dir into dir.tar, dir.tar.gz and dir.tar.bz2 archives, the following commands are used, respectively.&lt;br /&gt;&lt;br /&gt;tar cf dir.tar dir/  # ©2007 linux.dsplabs.com.au&lt;br /&gt;tar czf dir.tar.gz dir/  # ©2007 linux.dsplabs.com.au&lt;br /&gt;tar cjf dir.tar.bz2 dir/  # ©2007 linux.dsplabs.com.au&lt;br /&gt;&lt;br /&gt;In the above examples, the use of the f option specifies that the compressed version of the dir directory is to be placed in a corresponding archive file. On the other hand, if the f option was not given (and thus the archive name was also omitted), then the stdout, i.e. your terminal screen, would be used as the output instead. This is useful if you want to pipe the output of your tar command into another Linux tool. Anyhow, lets have a look at the resulting archives as well as the original directory using ls -la.&lt;br /&gt;&lt;br /&gt;total 424&lt;br /&gt;drwx------ 3 kamil kamil   4096 Nov 27 22:39 .&lt;br /&gt;drwx------ 3 kamil kamil   4096 Nov 27 22:34 ..&lt;br /&gt;drwx------ 2 kamil kamil   4096 Nov 27 22:36 dir&lt;br /&gt;-rw------- 1 kamil kamil 276480 Nov 27 22:39 dir.tar&lt;br /&gt;-rw------- 1 kamil kamil  83330 Nov 27 22:39 dir.tar.gz&lt;br /&gt;-rw------- 1 kamil kamil  45927 Nov 27 22:39 dir.tar.bz2&lt;br /&gt;&lt;br /&gt;Lets also have a look at the size of the original directory using du -sh dir # ©2007 linux.dsplabs.com.au.&lt;br /&gt;&lt;br /&gt;280K    dir&lt;br /&gt;&lt;br /&gt;From the above shell output, you can see that by default tar only archives files without compressing them, while gzip and bzip2 filters achieve quite high compression. Note that bzip2 typically achieves better compression that gzip, although it might take longer time to do so. Also note, that in this case gzip and bzip2 filters achieve quite high compression ratios because the dir directory contains text files. If the directory contained already compressed files, say f.e. binary images compressed using the JPEG compression, then neither gzip nor bzip2 could do much more in terms of compression.&lt;br /&gt;&lt;br /&gt;Extracting archives&lt;br /&gt;&lt;br /&gt;Extracting archives is also very simple. Instead of the c switch the x is used and the archive name is given as the only other parameter. The commands for archive extraction shown below correspond to the archive creation commands given earlier.&lt;br /&gt;&lt;br /&gt;tar xf dir.tar  # ©2007 linux.dsplabs.com.au&lt;br /&gt;tar xzf dir.tar.gz  # ©2007 linux.dsplabs.com.au&lt;br /&gt;tar xjf dir.tar.bz2  # ©2007 linux.dsplabs.com.au&lt;br /&gt;&lt;br /&gt;Infact, in most cases, tar will figure out what archive type you are trying to extract (from their hex headers I suppose), so that the filter specifications are not really needed. Hence, the following still works fine.&lt;br /&gt;&lt;br /&gt;tar xf dir.tar  # ©2007 linux.dsplabs.com.au&lt;br /&gt;tar xf dir.tar.gz  # ©2007 linux.dsplabs.com.au&lt;br /&gt;tar xf dir.tar.bz2  # ©2007 linux.dsplabs.com.au&lt;br /&gt;&lt;br /&gt;However, if you explicitly specify the decoder, then tar will assume that that is the encoding of the given archive. If for whatever reason that is not the case, an error will occur.&lt;br /&gt;&lt;br /&gt;The verbose mode&lt;br /&gt;&lt;br /&gt;The v switch can be used to enable the verbose mode. This can be useful if you would like to see a list of files being compressed or extracted. For example, lets extract the dir.tar.gz archive, with verbose mode enabled, using the following command.&lt;br /&gt;&lt;br /&gt;tar xvzf dir.tar.gz  # ©2007 linux.dsplabs.com.au&lt;br /&gt;&lt;br /&gt;The above command produces a list of inflated files as shown in the following output.&lt;br /&gt;&lt;br /&gt;dir/&lt;br /&gt;dir/NVIDIA_DRIVER_README.txt&lt;br /&gt;dir/NVIDIA_LICENSE.txt&lt;br /&gt;dir/readme.txt&lt;br /&gt;&lt;br /&gt;Some common errors&lt;br /&gt;&lt;br /&gt;Lets take a look at some common error examples. As described previously, specifying incorrect filter type, f.e. using the following commands&lt;br /&gt;&lt;br /&gt;tar xjf dir.tar  # ©2007 linux.dsplabs.com.au&lt;br /&gt;tar xzf dir.tar.bz2  # ©2007 linux.dsplabs.com.au&lt;br /&gt;&lt;br /&gt;results in the respective errors messages shown below.&lt;br /&gt;&lt;br /&gt;bzip2: (stdin) is not a bzip2 file.&lt;br /&gt;tar: Child returned status 2&lt;br /&gt;tar: Error exit delayed from previous errors&lt;br /&gt;&lt;br /&gt;gzip: stdin: not in gzip format&lt;br /&gt;tar: Child returned status 1&lt;br /&gt;tar: Error exit delayed from previous errors&lt;br /&gt;&lt;br /&gt;Also, if a file becomes damaged, say truncated, then obviously an error will occur. Lets simulate such a corruption. Lets keep only the initial 100 bytes of the dir.tar.bz2 archive by using the following command.&lt;br /&gt;&lt;br /&gt;head -c100 dir.tar.bz2 &gt; corrup.tar.bz2  # ©2007 linux.dsplabs.com.au&lt;br /&gt;&lt;br /&gt;If we now try to extract this archive,&lt;br /&gt;&lt;br /&gt;tar xjf corrupt.tar.bz2  # ©2007 linux.dsplabs.com.au&lt;br /&gt;&lt;br /&gt;then the following error message will be produced.&lt;br /&gt;&lt;br /&gt;bzip2: Compressed file ends unexpectedly;&lt;br /&gt;        perhaps it is corrupted?  *Possible* reason follows.&lt;br /&gt;bzip2: Inappropriate ioctl for device&lt;br /&gt;        Input file = (stdin), output file = (stdout)&lt;br /&gt;&lt;br /&gt;It is possible that the compressed file(s) have become corrupted.&lt;br /&gt;You can use the -tvv option to test integrity of such files.&lt;br /&gt;&lt;br /&gt;You can use the `bzip2recover' program to attempt to recover&lt;br /&gt;data from undamaged sections of corrupted files.&lt;br /&gt;&lt;br /&gt;tar: Child returned status 2&lt;br /&gt;tar: Error exit delayed from previous errors&lt;br /&gt;&lt;br /&gt;Interestingly, we are told to check archives integrity, so lets do that.&lt;br /&gt;&lt;br /&gt;bzip2 -tvv corrupt.tar.bz2  # ©2007 linux.dsplabs.com.au&lt;br /&gt;&lt;br /&gt;The bzip2 utility tells us what we already know… we are missing part of the file.&lt;br /&gt;&lt;br /&gt;corrupt.tar.bz2:    [1: huff+mtf file ends unexpectedly&lt;br /&gt;&lt;br /&gt;You can use the `bzip2recover' program to attempt to recover&lt;br /&gt;data from undamaged sections of corrupted files.&lt;br /&gt;&lt;br /&gt;Lets try the second suggestion, the bzip2recover utility.&lt;br /&gt;&lt;br /&gt;bzip2recover corrupt.tar.bz2  # ©2007 linux.dsplabs.com.au&lt;br /&gt;&lt;br /&gt;Unfortunately, with only 100 bytes it is not possible to recover anything from the corrupted archive.&lt;br /&gt;&lt;br /&gt;bzip2recover 1.0.3: extracts blocks from damaged .bz2 files.&lt;br /&gt;bzip2recover: searching for block boundaries ...&lt;br /&gt;   block 1 runs from 80 to 800 (incomplete)&lt;br /&gt;bzip2recover: sorry, I couldn't find any block boundaries.&lt;br /&gt;&lt;br /&gt;Similarly, if we truncate the gzip archvie, then gzip will inform us of unexpected end of file.&lt;br /&gt;&lt;br /&gt;gzip: stdin: unexpected end of file&lt;br /&gt;tar: Child returned status 1&lt;br /&gt;tar: Error exit delayed from previous errors&lt;br /&gt;&lt;br /&gt;On the other hand, truncating a tar archive does not cause error messages during extraction process. Obviously, only the files still fully contained (an not truncated/corrupted) in such an archive will be extracted. Such tuncation/corruption errors often occur when extracting archives downloaded from the Internet.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1925150244565910364-3331337582370498654?l=blog.chavkov.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.chavkov.com/feeds/3331337582370498654/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1925150244565910364&amp;postID=3331337582370498654' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/3331337582370498654'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/3331337582370498654'/><link rel='alternate' type='text/html' href='http://blog.chavkov.com/2010/07/tar-how-to-create-and-extract-targz-and.html' title='tar — how to create and extract tar.gz and tar.bz2 archives'/><author><name>Vlado Chavkov</name><uri>http://www.blogger.com/profile/03128216458383764972</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_9RxhR8IlDWk/Sif69ObJkCI/AAAAAAAAAr0/Y103Z6QXo1g/S220/b34f.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1925150244565910364.post-6863905977433719986</id><published>2009-12-19T20:32:00.000+02:00</published><updated>2009-12-19T20:33:27.423+02:00</updated><title type='text'>Can I Set Up User Name Mapping in Windows Vista?</title><content type='html'>Can I Set Up User Name Mapping in Windows Vista?&lt;br /&gt;&lt;br /&gt;Unfortunately, no if you don't have a SFU 3.5 or W2K3 R2 machines on the network that is running User Name Mapping service. This has been a major disappointment with NFS deployments using Windows Vista.&lt;br /&gt;&lt;br /&gt;However, there is a tiny little good news for you if you are looking for a way to enable Client for NFS in Windows Vista to be able to do something other than anonymous mounts. There is a registry tweak that you can modify to tweak Vista NFS client to use a pair of UNIX UID and GID while mounting and accessing NFS shares.&lt;br /&gt;&lt;br /&gt;Here's how you can do it -&lt;br /&gt;&lt;br /&gt;Start Registry Editor&lt;br /&gt;Locate HKEY_LOCAL_MACHINE\SOFTWARE\Microsoft\ClientForNFS\CurrentVersion\Default&lt;br /&gt;Create two DWORD values namely AnonymousUid and AnonymousGid&lt;br /&gt;Set these values to the UID and GID you would like this NFS client to use&lt;br /&gt;Restart your Client for NFS service using the Microsoft Services for NFS MMC snap-in&lt;br /&gt;Go ahead and mount shares on this machine and now the Client for NFS driver will send those values as the UID and GID to the NFS server. You can also use the mount command without any parameters to verify if these values are being used. You should see something like this -&lt;br /&gt;&lt;br /&gt;C:\&gt;mount&lt;br /&gt;&lt;br /&gt;Local    Remote                                 Properties&lt;br /&gt;-------------------------------------------------------------------------------&lt;br /&gt;x:       \\NFSSERVER\NFSSHARE                   UID=10012, GID=10011&lt;br /&gt;                                                rsize=8192, wsize=8192&lt;br /&gt;                                                mount=soft, timeout=1.6&lt;br /&gt;                                                retry=1, locking=yes&lt;br /&gt;                                                fileaccess=644, lang=ANSI&lt;br /&gt;                                                casesensitive=no&lt;br /&gt;Try creating a file on the share and on the UNIX box, you can see that they bear the same UID and GID values as we have mentioned in the above DWORD values. If you use the ls command that comes with SUA, you will not see the correct ownership information because the client is still doing anonymous mounts and as you might have guessed already - we are just changing the UID and GID that the client is sending to the server. It is more like squashing from a client side instead of doing it from the server.&lt;br /&gt;&lt;br /&gt;There's a security consideration as well - Every user on this machine will start sending these same NFS credentials so if you are going to have multiple users using this machine - think carefully about using this registry tweak. You also will not be able to use any secondary groups. I guess that can also be a consideration for many environments.&lt;br /&gt;&lt;br /&gt;BTW, this works the same way on Windows 7 box ;)&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1925150244565910364-6863905977433719986?l=blog.chavkov.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.chavkov.com/feeds/6863905977433719986/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1925150244565910364&amp;postID=6863905977433719986' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/6863905977433719986'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/6863905977433719986'/><link rel='alternate' type='text/html' href='http://blog.chavkov.com/2009/12/can-i-set-up-user-name-mapping-in.html' title='Can I Set Up User Name Mapping in Windows Vista?'/><author><name>Vlado Chavkov</name><uri>http://www.blogger.com/profile/03128216458383764972</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_9RxhR8IlDWk/Sif69ObJkCI/AAAAAAAAAr0/Y103Z6QXo1g/S220/b34f.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1925150244565910364.post-5925269956332406391</id><published>2009-11-23T18:00:00.001+02:00</published><updated>2009-11-23T18:00:52.807+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><category scheme='http://www.blogger.com/atom/ns#' term='Networking'/><title type='text'>Bandwidth Monitoring Tools for Ubuntu Users</title><content type='html'>Bandwidth in computer networking refers to the data rate supported by a network connection or interface. One most commonly expresses bandwidth in terms of bits per second (bps). The term comes from the field of electrical engineering, where bandwidth represents the total distance or range between the highest and lowest signals on the communication channel (band).&lt;br /&gt;Bandwidth represents the capacity of the connection. The greater the capacity, the more likely that greater performance will follow, though overall performance also depends on other factors, such as latency.&lt;br /&gt;&lt;br /&gt;Here is the list of bandwidth monitoring tools for your network bandwidth&lt;br /&gt;&lt;br /&gt;bmon&lt;br /&gt;bwbar&lt;br /&gt;bwm&lt;br /&gt;bwm-ng&lt;br /&gt;iftop&lt;br /&gt;iperf&lt;br /&gt;ipfm&lt;br /&gt;speedometer&lt;br /&gt;cbm&lt;br /&gt;ibmonitor&lt;br /&gt;pktstat&lt;br /&gt;mactrack&lt;br /&gt;MRTG&lt;br /&gt;Cacti&lt;br /&gt;&lt;br /&gt;Now we will see each tool separately&lt;br /&gt;&lt;br /&gt;bmon&lt;br /&gt;&lt;br /&gt;bmon is a portable bandwidth monitor and rate estimator running on various operating systems. It supports various input methods for different architectures.&lt;br /&gt;&lt;br /&gt;Various output modes exist including an interactive curses interface, lightweight HTML output but also formatable ASCII output&lt;br /&gt;&lt;br /&gt;Current Stable Version :- 2.1.0&lt;br /&gt;&lt;br /&gt;Install bmon in Ubuntu&lt;br /&gt;&lt;br /&gt;sudo apt-get install bmon&lt;br /&gt;&lt;br /&gt;This will complete the installation.&lt;br /&gt;&lt;br /&gt;If you want to open the application you need to enter the following command&lt;br /&gt;&lt;br /&gt;bmon&lt;br /&gt;&lt;br /&gt;you should see the following output&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If i select the eth0 i should see all the traffic details&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you want to know more available options check man page&lt;br /&gt;&lt;br /&gt;bwbar&lt;br /&gt;&lt;br /&gt;This program will output a PNG and a text file that can be used in scripts or be included in web pages to show current bandwidth usage. The amount of total bandwidth can be customized. The PNG output appears as a bar graph showing maximum possible usage with the current inbound or outbound usage shown as a differently colored bar.&lt;br /&gt;&lt;br /&gt;Current Stable Version :- 1.2.3&lt;br /&gt;&lt;br /&gt;Install bwbar in ubuntu&lt;br /&gt;&lt;br /&gt;sudo apt-get install bwbar&lt;br /&gt;&lt;br /&gt;This will complete the installation&lt;br /&gt;&lt;br /&gt;There is a /etc/default/bwbar file to configure before this package will work and here is my config&lt;br /&gt;&lt;br /&gt;# Directory to put files into&lt;br /&gt;DIR=/var/www&lt;br /&gt;# Who to run as&lt;br /&gt;RUNAS=www-data&lt;br /&gt;# What are the options (eth0, scale of 1.5mbps)&lt;br /&gt;OPTIONS=”eth0 1.5″&lt;br /&gt;&lt;br /&gt;Now you need to chnage the permissions using the following command&lt;br /&gt;&lt;br /&gt;sudo chown -R www-data:www-data /var/www/bwbar/&lt;br /&gt;&lt;br /&gt;Start the bwbar using the following command&lt;br /&gt;&lt;br /&gt;sudo /etc/init.d/bwbar start&lt;br /&gt;&lt;br /&gt;You can also launch bwbar using the following command&lt;br /&gt;&lt;br /&gt;bwbar eth0 100 -x 200 -y 7 -t 10 -p network.png -f network.txt -d /var/www/bwbar &amp;&lt;br /&gt;&lt;br /&gt;Now you need to go to http://serverip/bwbar you should see the bandwidth bar as follows&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you want to know about available option check man page&lt;br /&gt;&lt;br /&gt;bwm&lt;br /&gt;&lt;br /&gt;BandWidth Monitor This is a very tiny bandwidth monitor (not X11). Can monitor up to 16 interfaces in the in the same time, and shows totals too.&lt;br /&gt;&lt;br /&gt;Current Stable Version :- 1.1.0&lt;br /&gt;&lt;br /&gt;Install bwm ubuntu&lt;br /&gt;&lt;br /&gt;sudo apt-get install bwm&lt;br /&gt;&lt;br /&gt;This will complete the installation now&lt;br /&gt;&lt;br /&gt;If you want to run the application use the following command&lt;br /&gt;&lt;br /&gt;bwm&lt;br /&gt;&lt;br /&gt;Output looks like below&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you want more details and available options check man page&lt;br /&gt;&lt;br /&gt;bwm-ng&lt;br /&gt;&lt;br /&gt;small and simple console-based bandwidth monitor.Bandwidth Monitor NG is a small and simple console-based live bandwidth monitor.&lt;br /&gt;&lt;br /&gt;Current Stable Version :- 0.5&lt;br /&gt;&lt;br /&gt;features&lt;br /&gt;&lt;br /&gt;supports /proc/net/dev, netstat, getifaddr, sysctl, kstat and libstatgrab&lt;br /&gt;&lt;br /&gt;unlimited number of interfaces supported&lt;br /&gt;&lt;br /&gt;interfaces are added or removed dynamically from list&lt;br /&gt;&lt;br /&gt;white-/blacklist of interfaces&lt;br /&gt;&lt;br /&gt;output of KB/s, Kb/s, packets, errors, average, max and total sum&lt;br /&gt;&lt;br /&gt;output in curses, plain console, CSV or HTML&lt;br /&gt;&lt;br /&gt;configfile&lt;br /&gt;&lt;br /&gt;Install bwm-ng in ubuntu&lt;br /&gt;&lt;br /&gt;sudo apt-get install bwm-ng&lt;br /&gt;&lt;br /&gt;This will complete the installation&lt;br /&gt;&lt;br /&gt;If you want to run the application you need to use the following command&lt;br /&gt;&lt;br /&gt;bwm-ng&lt;br /&gt;&lt;br /&gt;Output looks like below&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you want more details and available options check man page&lt;br /&gt;&lt;br /&gt;iftop&lt;br /&gt;&lt;br /&gt;iftop does for network usage what top does for CPU usage. It listens to network traffic on a named interface and displays a table of current bandwidth usage by pairs of hosts.&lt;br /&gt;&lt;br /&gt;Current Stable Version :- 0.17&lt;br /&gt;&lt;br /&gt;Install iftop in ubuntu&lt;br /&gt;&lt;br /&gt;sudo apt-get install iftop&lt;br /&gt;&lt;br /&gt;This will complete the installation&lt;br /&gt;&lt;br /&gt;If you want to run the application you need to use the following command&lt;br /&gt;&lt;br /&gt;iftop&lt;br /&gt;&lt;br /&gt;Output looks like below&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you want more details and available options check man page&lt;br /&gt;&lt;br /&gt;ipfm&lt;br /&gt;&lt;br /&gt;IP Flow Meter (IPFM) is a bandwidth analysis tool, that measures how much bandwidth specified hosts use on their Internet link.&lt;br /&gt;&lt;br /&gt;Current Stable Version :- 0.11.5&lt;br /&gt;&lt;br /&gt;Install ipfm in Ubuntu&lt;br /&gt;&lt;br /&gt;sudo apt-get install ipfm&lt;br /&gt;&lt;br /&gt;This will complete the installation&lt;br /&gt;&lt;br /&gt;Now if you want to configure this for your network you need to copy example configuration file from /usr/share/doc/ipfm/examples if you want to check this file click here&lt;br /&gt;&lt;br /&gt;once you configure this file you need to start the service using the following command&lt;br /&gt;&lt;br /&gt;sudo /etc/init.d/ipfm start&lt;br /&gt;&lt;br /&gt;If you want more details and available options check man page&lt;br /&gt;&lt;br /&gt;Speedometer&lt;br /&gt;&lt;br /&gt;Measure and display the rate of data across a network connection or data being stored in a file.&lt;br /&gt;&lt;br /&gt;Current Stable Version :- 2.4&lt;br /&gt;&lt;br /&gt;Install speedometer in ubuntu&lt;br /&gt;&lt;br /&gt;Check which version of python is the default by running&lt;br /&gt;&lt;br /&gt;python -V&lt;br /&gt;&lt;br /&gt;Then issue the following commands as root to install speedometer (choose the correct Urwid package for your python version, ie. if python -V reports version 2.3.X then install python2.3-urwid)&lt;br /&gt;&lt;br /&gt;apt-get install python2.4-urwid&lt;br /&gt;&lt;br /&gt;Download the speedometer.py source file.&lt;br /&gt;&lt;br /&gt;As user issue the following commands in the directory that you downloaded the source file&lt;br /&gt;&lt;br /&gt;sudo cp speedometer.py /usr/local/bin/speedometer&lt;br /&gt;&lt;br /&gt;sudo chown root: /usr/local/bin/speedometer&lt;br /&gt;&lt;br /&gt;sudo chmod 755 /usr/local/bin/speedometer&lt;br /&gt;&lt;br /&gt;Now you can run the speedometer application using the following&lt;br /&gt;&lt;br /&gt;/usr/local/bin/speedometer&lt;br /&gt;&lt;br /&gt;Now you should see the following screen output&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;Speedometer Usage&lt;br /&gt;&lt;br /&gt;Usage: speedometer [options] tap [[-c] tap]&lt;br /&gt;&lt;br /&gt;Available options&lt;br /&gt;&lt;br /&gt;speedometer -h&lt;br /&gt;&lt;br /&gt;Usage: speedometer [options] tap [[-c] tap]…&lt;br /&gt;&lt;br /&gt;Monitor network traffic or speed/progress of a file transfer. At least one tap must be entered. -c starts a new column, otherwise taps are piled vertically.&lt;br /&gt;&lt;br /&gt;Taps:&lt;br /&gt;&lt;br /&gt;[-f] filename [size] display download speed [with progress bar]&lt;br /&gt;&lt;br /&gt;-f must be used if directly following another&lt;br /&gt;&lt;br /&gt;file tap without an expected size specified&lt;br /&gt;&lt;br /&gt;-rx network-interface display bytes received on network-interface&lt;br /&gt;&lt;br /&gt;-tx network-interface display bytes transmitted on network-interface&lt;br /&gt;&lt;br /&gt;Options:&lt;br /&gt;&lt;br /&gt;-i interval-in-seconds eg. “5″ or “0.25″ default: “1″&lt;br /&gt;&lt;br /&gt;-p use plain-text display (one tap only)&lt;br /&gt;&lt;br /&gt;-b use old blocky display instead of smoothed display even when UTF-8 encoding is detected&lt;br /&gt;&lt;br /&gt;-z report zero size on files that don’t exist instead of waiting for them to be created&lt;br /&gt;&lt;br /&gt;Usage Examples&lt;br /&gt;&lt;br /&gt;How long it will take for my 38MB transfer to finish?&lt;br /&gt;&lt;br /&gt;speedometer favorite_episode.rm $((38*1024*1024))&lt;br /&gt;&lt;br /&gt;How quickly is another transfer going?&lt;br /&gt;&lt;br /&gt;speedometer dl/big.avi&lt;br /&gt;&lt;br /&gt;How fast is this LAN?&lt;br /&gt;&lt;br /&gt;$ cat /dev/zero | nc -l -p 12345&lt;br /&gt;&lt;br /&gt;$ nc host-a 12345 &gt; /dev/null&lt;br /&gt;&lt;br /&gt;$ speedometer -rx eth0&lt;br /&gt;&lt;br /&gt;How fast is the upstream on this ADSL line?&lt;br /&gt;&lt;br /&gt;speedometer -tx ppp0&lt;br /&gt;&lt;br /&gt;How fast can I write data to my filesystem? (with at least 1GB free)&lt;br /&gt;&lt;br /&gt;dd bs=1000000 count=1000 if=/dev/zero of=big_nothing &amp;&lt;br /&gt;speedometer big_nothing&lt;br /&gt;&lt;br /&gt;cbm&lt;br /&gt;&lt;br /&gt;cbm — the Color Bandwidth Meter — displays the current traffic on all network devices.&lt;br /&gt;&lt;br /&gt;Current Stable Version :- 0.1-1&lt;br /&gt;&lt;br /&gt;Install cbm in ubuntu&lt;br /&gt;&lt;br /&gt;First you need to download the .deb package from here&lt;br /&gt;&lt;br /&gt;once you have the .deb package you need to install using the following comamnd&lt;br /&gt;&lt;br /&gt;sudo dpkg -i cbm_0.1-1_i386.deb&lt;br /&gt;&lt;br /&gt;this will complete the installation now if you want to use the appltcation use the following command&lt;br /&gt;&lt;br /&gt;cbm&lt;br /&gt;&lt;br /&gt;Output looks like below&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;pktstat&lt;br /&gt;&lt;br /&gt;pktstat listens to the network and shows the bandwidth being consumed by packets of various kinds in realtime. It understands some protocols (including FTP,HTTP, and X11) and adds a descriptive name next to the entry (e.g., ‘RETR cd8.iso’, ‘GET http://slashdot.org/’ or ‘xclock -fg blue’).&lt;br /&gt;&lt;br /&gt;Current Stable Version :- 1.8.3&lt;br /&gt;&lt;br /&gt;Install pktstat in Ubuntu&lt;br /&gt;&lt;br /&gt;First you need to download .rpm package from here once you have the .rpm package you need to convert this .rpm file to .deb file using alien&lt;br /&gt;&lt;br /&gt;Install alien&lt;br /&gt;&lt;br /&gt;sudo apt-get install alien&lt;br /&gt;&lt;br /&gt;Now you need to use the follwoing command to convert .rpm to .deb&lt;br /&gt;&lt;br /&gt;sudo alien -k pktstat-1.7.2q-0.i386.rpm&lt;br /&gt;&lt;br /&gt;Now you should be having pktstat_1.7.2q-0_i386.deb package&lt;br /&gt;&lt;br /&gt;Install pktstat in Ubuntu&lt;br /&gt;&lt;br /&gt;sudo dpkg -i pktstat_1.7.2q-0_i386.deb&lt;br /&gt;&lt;br /&gt;This will complete the installation now you can open the application using the following command&lt;br /&gt;&lt;br /&gt;pktstat&lt;br /&gt;&lt;br /&gt;output looks like below&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;If you want more available options for pktstat check man page&lt;br /&gt;&lt;br /&gt;ibmonitor&lt;br /&gt;&lt;br /&gt;ibmonitor is an interactive linux console application which shows bandwidth consumed and total data transferred on all interfaces.&lt;br /&gt;&lt;br /&gt;Current Stable Version :- 1.4&lt;br /&gt;&lt;br /&gt;Its main features are:&lt;br /&gt;&lt;br /&gt;Shows received, transmitted and total bandwidth of each interface&lt;br /&gt;&lt;br /&gt;Calculates and displays the combined value of all interfaces&lt;br /&gt;&lt;br /&gt;Displays total data transferred per interface in KB/MB/GB&lt;br /&gt;&lt;br /&gt;Values can be displayed in Kbits/sec(Kbps) and/or KBytes/sec(KBps)&lt;br /&gt;&lt;br /&gt;Can show maximum bandwidth consumed on each interface since start of utility&lt;br /&gt;&lt;br /&gt;Can show average bandwidth consumption on each interface since start of utility&lt;br /&gt;&lt;br /&gt;The output with all features (max, avg and display in Kbps and KBps) easily fits on a 80×24 console or xterm&lt;br /&gt;&lt;br /&gt;Can interactively change its output display format depending on key pressed by user.&lt;br /&gt;&lt;br /&gt;Install ibmonitor in Ubuntu&lt;br /&gt;&lt;br /&gt;First you need to download the latest version from here&lt;br /&gt;&lt;br /&gt;wget http://ovh.dl.sourceforge.net/sourceforge/ibmonitor/ibmonitor-1.4.tar.gz&lt;br /&gt;&lt;br /&gt;Now you have ibmonitor-1.4.tar.gz&lt;br /&gt;&lt;br /&gt;Extract this file using the following commands&lt;br /&gt;&lt;br /&gt;tar xvfz ibmonitor-1.4.tar.gz&lt;br /&gt;&lt;br /&gt;cd ibmonitor&lt;br /&gt;&lt;br /&gt;If you want to run the application use the following command&lt;br /&gt;&lt;br /&gt;Once you are in ibmonitor folder use&lt;br /&gt;&lt;br /&gt;./ibmonitor&lt;br /&gt;&lt;br /&gt;Output looks like the following screen&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;iperf&lt;br /&gt;&lt;br /&gt;While tools to measure network performance, such as ttcp, exist, most are very old and have confusing options. Iperf was developed as a modern alternative for measuring TCP and UDP bandwidth performance.&lt;br /&gt;&lt;br /&gt;Iperf is a tool to measure maximum TCP bandwidth, allowing the tuning of various parameters and UDP characteristics. Iperf reports bandwidth, delay jitter, datagram loss.&lt;br /&gt;&lt;br /&gt;Current Stable Version :- 2.0.2&lt;br /&gt;&lt;br /&gt;Install iperf in ubuntu&lt;br /&gt;&lt;br /&gt;sudo apt-get install iperf&lt;br /&gt;&lt;br /&gt;iperf Syntax&lt;br /&gt;&lt;br /&gt;iperf [-s|-c host] [options]&lt;br /&gt;&lt;br /&gt;Example&lt;br /&gt;&lt;br /&gt;iperf -c server address -F file-name&lt;br /&gt;&lt;br /&gt;iperf -c server address -I&lt;br /&gt;&lt;br /&gt;The -F option is for file input.&lt;br /&gt;&lt;br /&gt;The -I option is for input from stdin.&lt;br /&gt;&lt;br /&gt;If you want more details and available options check man page&lt;br /&gt;&lt;br /&gt;tcptrack&lt;br /&gt;&lt;br /&gt;tcptrack is a sniffer which displays information about TCP connections it sees on a network interface. It passively watches for connections on the network interface, keeps track of their state and displays a list of connections in a manner similar to the unix ‘top’ command. It displays source and destination addresses and ports, connection state, idle time, and bandwidth usage.&lt;br /&gt;&lt;br /&gt;Current Stable Version :- 1.1.5&lt;br /&gt;&lt;br /&gt;Install tcptrack in Ubuntu&lt;br /&gt;&lt;br /&gt;sudo apt-get install tcptrack&lt;br /&gt;&lt;br /&gt;this will complete the installation&lt;br /&gt;&lt;br /&gt;tcptrack Syntax&lt;br /&gt;&lt;br /&gt;tcptrack [-dfhvp] [-r ] -i []&lt;br /&gt;&lt;br /&gt;Examples&lt;br /&gt;&lt;br /&gt;tcptrack requires only one parameter to run: the -i flag followed by an interface name that you want tcptrack to monitor. This is the most basic way to run tcptrack&lt;br /&gt;&lt;br /&gt;tcptrack -i eth0&lt;br /&gt;&lt;br /&gt;tcptrack can also take a pcap filter expression as an argument. The format of this filter expression is the same as that of tcpdump and other&lt;br /&gt;libpcap-based sniffers. The following example will only show connections from host 10.45.165.2&lt;br /&gt;&lt;br /&gt;tcptrack -i eth0 src or dst 10.45.165.2&lt;br /&gt;&lt;br /&gt;The next example will only show web traffic (ie, traffic on port 80)&lt;br /&gt;&lt;br /&gt;tcptrack -i eth0 port 80&lt;br /&gt;&lt;br /&gt;The following output screen will show you more details&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;&lt;br /&gt;MRTG&lt;br /&gt;&lt;br /&gt;The Multi Router Traffic Grapher or just simply MRTG is free software for monitoring the traffic load on network links. It allows the user to see traffic load on a network over time in graphical form.&lt;br /&gt;&lt;br /&gt;Current Stable Version :- 2.15.0&lt;br /&gt;&lt;br /&gt;Project Homepage&lt;br /&gt;&lt;br /&gt;http://oss.oetiker.ch/mrtg/&lt;br /&gt;&lt;br /&gt;Cacti&lt;br /&gt;&lt;br /&gt;Cacti is a complete network graphing solution designed to harness the power of RRDTool’s data storage and graphing functionality. Cacti provides a fast poller, advanced graph templating, multiple data acquisition methods, and user management features out of the box. All of this is wrapped in an intuitive,easy to use interface that makes sense for LAN-sized installations up to complex networks with hundreds of devices.&lt;br /&gt;&lt;br /&gt;Current Stable Version :- 0.8.6i&lt;br /&gt;&lt;br /&gt;Project Homepage&lt;br /&gt;&lt;br /&gt;http://www.cacti.net&lt;br /&gt;&lt;br /&gt;Regarding MRTG and Cacti i am going write detailed articles in future&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1925150244565910364-5925269956332406391?l=blog.chavkov.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.chavkov.com/feeds/5925269956332406391/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1925150244565910364&amp;postID=5925269956332406391' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/5925269956332406391'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/5925269956332406391'/><link rel='alternate' type='text/html' href='http://blog.chavkov.com/2009/11/bandwidth-monitoring-tools-for-ubuntu.html' title='Bandwidth Monitoring Tools for Ubuntu Users'/><author><name>Vlado Chavkov</name><uri>http://www.blogger.com/profile/03128216458383764972</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_9RxhR8IlDWk/Sif69ObJkCI/AAAAAAAAAr0/Y103Z6QXo1g/S220/b34f.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1925150244565910364.post-1070948812408713361</id><published>2009-11-06T14:49:00.001+02:00</published><updated>2009-11-06T14:49:58.201+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Zend Framework'/><title type='text'>Zend Performance</title><content type='html'>Let me first start off by saying that the Zend Framework has been very good to us.&lt;br /&gt;&lt;br /&gt;It enabled us to build a kick-ass application in a relatively short amount of time. On top of that, we followed the conventions from Zend and PEAR and essentially have a very maintainable piece of software which I don't hate looking at every day (which is as one can imagine, a huge plus).&lt;br /&gt;&lt;br /&gt;The other day our servers were overwhelmed with the rising traffic and I started profiling my application through Xdebug. Initially I tried to use Zend Studio and the Zend_Debugger but Zend doesn't like my (awesome) operating system (FreeBSD) and only provides Linux and Windows extensions. Xdebug, while being free and awesome in general, doesn't know this prejudice. :-)&lt;br /&gt;&lt;br /&gt;On this project we currently run with 100,000 visitors per day on average, our peak is Sunday night where we get a ton more traffic than usually. We run the latest PHP (5.2.6 at this time), etc.. The software comes from FreeBSD ports, there are no magic secret patches. I'm picky about the modules I compile and load but the list is far from optimized.&lt;br /&gt;&lt;br /&gt;To our defense, we just relaunched over summer and since we are a team of four total and only two of those four people write code. Since we started off slow with 60,000-80,000 visitors per day since summer, we never really had a chance or need to optimize and tried to avoid all premature optimization.&lt;br /&gt;&lt;br /&gt;We currently use 50-some Zend-classes. I wish I could provide a better number, but as you may know, the Zend Framework is only bundled as a whole and figuring out which classes are all in the mix is tricky. So the 50 is an estimation based on grepping through our own class code mostly.&lt;br /&gt;&lt;br /&gt;On the server we run Apache 1.3. Currently we have a total of four webservers (two older (dual core, 6 GB RAM, slow disks (7.5k rpm)), two newer models (eight cores and 6 GB RAM, faster disks (15k rpm)). The backend consists of two powerful workhouses with eight cores, more RAM (than the frontends) and a lot of disk (at 12k rpm each).&lt;br /&gt;&lt;br /&gt;Prior to starting the quest for performance one of our older servers was able to handle ten (10) requests/second at peaks, now we are at 42 requests/second. (Give or take a few.) In regard to page loading time, we went with a few optimizations from 340 ms to 76 ms in no time (all figures according to Xdebug). So I feel like we are right on the right track to Getting rich with PHP. (Where's my Lexus at? :-))&lt;br /&gt;&lt;br /&gt;We benchmarked using Apache Bench (at moderate ab -n 1000 -c 100 http://url) and Siege, which are both really awesome tools and provide you with an instant DoS attack on your servers. I might add that you are better off running those tools from "localhost" vs. remote as you might trigger your providers IDS/snort/DoS protection otherwise.&lt;br /&gt;&lt;br /&gt;Here are a few things, that helped us. Suggestions are in no particular order and I should add that whatever is applicable for my suitation, doesn't have to work for you. Also, my number game could be off and if you have suggestions on how to improve, please comment or drop me a line.&lt;br /&gt;&lt;br /&gt;1) APC&lt;br /&gt;It cannot be stressed enough. Please run APC. Please take into account to adjust the default settings, also check apc.slam_defense, apc.write_lock and apc.stat.&lt;br /&gt;&lt;br /&gt;We had APC before, but I felt like I needed to mention it on the list of things.&lt;br /&gt;&lt;br /&gt;Also, apc_fetch, apc_store etc. are great ways to add little caches throughout your application.&lt;br /&gt;&lt;br /&gt;And they almost require zero time to implement. I may suggest you use apc_fetch/apc_store directly vs. wrapping the Zend_Cache layer around it which provides (IMHO) little added value and benefit but just adds more class code around the obvious.&lt;br /&gt;&lt;br /&gt;2) Adjust PHP's realpath.cache setting and .ttl&lt;br /&gt;This helps, somewhat.&lt;br /&gt;&lt;br /&gt;3) Get rid off require_once, use __autoload (and the Zend_Loader)&lt;br /&gt;&lt;br /&gt;This might be a hassle when during development, because require_once evaluates each include, thus letting you know if it finds a parse error, and also where.&lt;br /&gt;&lt;br /&gt;With include_once (which Zend_Loader essentially uses), it's a bit tricky at times. A good idea here would be a phing task (or some other script) which strips out or replaces require_once when you deploy your application to production.&lt;br /&gt;&lt;br /&gt;Removing require_once in favour of __autoload shows one of the biggest performance improvements in my entire application - I shaved off roughly 220 milliseconds by removing about 15 (or so) calls to require_once in my bootstrap.php file. And that's with APC enabled, and a decent sized realpath.cache (and .ttl).&lt;br /&gt;&lt;br /&gt;Beyond weird coding conventions (I shall bitch about those in another blog post), require_once is also the number one performance killer from the entire Zend_* code base. The before/after is amazing. Without any of those enhancements from the list just by stripping out require_once from our ZendFramework "install", we went from 9-10 requests/second to 27 requests/second.&lt;br /&gt;&lt;br /&gt;Use the following shellscript to strip them:&lt;br /&gt;&lt;br /&gt;grep -rl require_once . | grep -v svn |grep -v Loader | xargs perl -pi~ -e 's/require_once/#require_once/'&lt;br /&gt;&lt;br /&gt;3) Zend_Loader&lt;br /&gt;I know, I just recommended using the Zend_Loader but with no offense, the Zend_Loader sucks is not so great when it comes to general performance. Obviously I did not write it and really no offense meant, but it does some really weird stuff on the inside which I am not sure what the use-case is. But I am sure there is one. ;-)&lt;br /&gt;&lt;br /&gt;In order to preserve the API, I extended Zend_Loader and started overwriting functions such as Zend_Loader::_securityCheck(), which runs a regular expression on the name of each file you feed to __autoload/Zend_Loader.&lt;br /&gt;&lt;br /&gt;On top of that I switched to usig the Zend_Loader only for models and controllers. But not for Zend_ and Company_-classes. Since Zend (and we) essentially follow the great PEAR coding standard in regard to one class per file and a very explicit naming scheme, all you have to do in your __autoload is the following:&lt;br /&gt;&lt;br /&gt;function __autoload($className) {&lt;br /&gt;    include_once $className = str_replace('_', '/', $className) . '.php';&lt;br /&gt;}&lt;br /&gt;&lt;br /&gt;Now, that would be the bare minimum and our loader looks slightly more complicated but I haven't stopped there and we are still in the process of "dumbing" it down even further, but so far it saved us between five and 15 ms per page.&lt;br /&gt;&lt;br /&gt;4) Cache DB results, avoid queries!&lt;br /&gt;&lt;br /&gt;Those tricky, tricky DB queries.&lt;br /&gt;&lt;br /&gt;Even though our DB backends idle mostly even when we get beat with traffic, there's a few things to keep in mind.&lt;br /&gt;&lt;br /&gt;One of them is - DB queries are really expensive. And by queries I am not talking about the "SELECT * FROM foo"-part, but rather about opening a connection to another server, sending the query, receiving it and so on. Let alone by caching one of those, we roughly gained another 20 ms on the frontpage. And it's not a very complex query either.&lt;br /&gt;&lt;br /&gt;I remember looking puzzled when ahem... I was presented with the code that pulls a status message on each request to the homepage but I had forgotten about this already and just noticed it again when it popped up in xDebug with a notable amound of milliseconds.&lt;br /&gt;&lt;br /&gt;5) Zend_Db_Table&lt;br /&gt;&lt;br /&gt;Zend_Db_Table is very easy to use, in fact most of our models wrap around a couple tables and that's why we got a bunch of them. Now what I did not realize (but thanks to JamesG@#zftalk now I do), is that the meta data the class uses to provide all those nifty interfaces is generated on each request. That's a DESCRIBE TABLE in the background, which is pure overhead.&lt;br /&gt;&lt;br /&gt;Zend_Db_Table_Abstract::setDefaultMetadataCache() to the rescue.&lt;br /&gt;&lt;br /&gt;5) Apache&lt;br /&gt;&lt;br /&gt;5a)&lt;br /&gt;I sometimes hate Apache, but I also can't live without it.&lt;br /&gt;&lt;br /&gt;Over the past years, I have tried all sorts of things in the webserver market - Lighttpd and nginx with php-cgi (fastcgi) seem to be no fun. A commercial solution such as Resin or Zeus has never been an option either.&lt;br /&gt;&lt;br /&gt;I've always come back to Apache (1.3) for the simple fact that Apache and PHP are really so tightly integrated that nothing ever will go wrong.&lt;br /&gt;&lt;br /&gt;Remember that guy Nik who claimed that Apache/PHP sometimes fail and deliver the sourcecode to the browser (because Facebook obviously failed to configure Apache)? Well, that doesn't happen - ever. The only problem with Apache is that Apache and client(browser)-communication is a bitch.&lt;br /&gt;&lt;br /&gt;Nginx to the rescue! Fast install, easy to configure (don't let the Russian FAQ scare you, the nginx.conf-dist will teach you all you need!) - just chain your Apache to localhost:8080 and let Nginx proxy all requests to it and your Apaches move from "lockf" status, to "run" and "accept" always.&lt;br /&gt;&lt;br /&gt;Whenever Apache receives a request of a slower client, it will have to wait until the slower client is done reading all of the response. While waiting, your 30 MB Apache sits there unable to do anything else. Which nginx in the mix, the Apache sends the response as fast as it can to nginx, thus having more time to take care of what it's supposed to do for you - PHP.&lt;br /&gt;&lt;br /&gt;Judging from my poor benchmarks, nginx adds to the number of requests by factor six or seven (6 or 7). It's amazying and I never expected it to have such a great impact. It also doesn't eat away on resources, so beware of the Russians! :-)&lt;br /&gt;&lt;br /&gt;Take all "optimizations" into account, Apache 1.3, proxied by Nginx can now handle over 3000 requests/second (ab -n 10000 -c 1000 http://url).&lt;br /&gt;&lt;br /&gt;5b)&lt;br /&gt;The obvious quirks, for example check out your default Apache install and unload all the modules and extensions you never use anyway.&lt;br /&gt;&lt;br /&gt;For example, we don't have any of those HTTP authentication boxes ever. So why do we need *_auth_* modules. Then, we don't use a user_dir, why load mod_userdir, our Apache does not log - why load mod_config_log, or my most favorite: mod_status.&lt;br /&gt;&lt;br /&gt;Make sure mod_status is really disabled because otherwise that's one very, very expensive operation you got right there, with each request.&lt;br /&gt;&lt;br /&gt;A good idea is to check top, unload, and look again:&lt;br /&gt;&lt;br /&gt;  PID USERNAME  THR PRI NICE   SIZE    RES STATE  C   TIME   WCPU COMMAND&lt;br /&gt;42601 root        1  96    0  7092K  2324K CPU1   1   0:00  1.00% top&lt;br /&gt;36242 www         1  20    0   114M 33304K lockf  1   0:22  0.29% httpd&lt;br /&gt;38251 www         1  20    0   114M 32184K lockf  0   0:08  0.29% httpd&lt;br /&gt;42579 www         1  20    0   114M 28016K lockf  1   0:02  0.29% httpd&lt;br /&gt;37975 www         1  20    0   115M 34688K lockf  1   0:18  0.24% httpd&lt;br /&gt;36344 www         1  20    0   115M 34036K lockf  1   0:18  0.24% httpd&lt;br /&gt;&lt;br /&gt;Take into account (thanks, Jan), that the size column, is not the real size. It's like the theoretical size including whatever the Apache could use if it had to, but you want to look at RES (resident) instead. Because that's what's in the memory right now.&lt;br /&gt;&lt;br /&gt;Another smart move is to put all the rules from .htaccess into your server configuration because otherwise Apache searches for various (!) .htaccess files with each requests and tries to evaluate the rules you have in there.&lt;br /&gt;&lt;br /&gt;Imagine this:&lt;br /&gt;&lt;br /&gt;/htdocs/foo/bar/index.html&lt;br /&gt;&lt;br /&gt;In this request Apache will look for .htaccess in the following directories:&lt;br /&gt;/htdocs&lt;br /&gt;/htdocs/foo&lt;br /&gt;/htdocs/foo/bar&lt;br /&gt;&lt;br /&gt;Turn it off (AllowOverride none) instead and move on because when you move all your directives into httpd.conf (or similar) at least they get evaluated once when the server process starts up.&lt;br /&gt;From a deployment perspective it's nicer to have .htaccess because all you need to do is re-deploy one file vs. editing a server config and restarting a server, but this really pays off. With certain APC settings, you will need to restart the server anyway, also, "No pain, no gain!".&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1925150244565910364-1070948812408713361?l=blog.chavkov.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.chavkov.com/feeds/1070948812408713361/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1925150244565910364&amp;postID=1070948812408713361' title='1 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/1070948812408713361'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/1070948812408713361'/><link rel='alternate' type='text/html' href='http://blog.chavkov.com/2009/11/zend-performance.html' title='Zend Performance'/><author><name>Vlado Chavkov</name><uri>http://www.blogger.com/profile/03128216458383764972</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_9RxhR8IlDWk/Sif69ObJkCI/AAAAAAAAAr0/Y103Z6QXo1g/S220/b34f.jpg'/></author><thr:total>1</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1925150244565910364.post-2775174127347634700</id><published>2009-10-29T10:37:00.002+02:00</published><updated>2009-10-29T10:44:21.333+02:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='PostgreSQL'/><title type='text'>REPLACE in PostgreSQL</title><content type='html'>I've recently made the switch from MySQL to PostgreSQL for some of my more complicated database projects, such as the ad matching discussed in my last post. PostgreSQL has a much richer feature set (although MySQL 5 is catching up). One feature I couldn't find in PostgreSQL however was the REPLACE extension offered by MySQL where rows that occur in duplicated primary keys replace the existing rows instead of give errors. Fortunately, PostgreSQL's advanced rules system allows the creation of an equivalent feature.&lt;br /&gt;&lt;br /&gt;For the sake of this example we'll use a very simple table called 'map' with a two fields: 'key' and 'value'. Not surprisingly, key is the primary key.&lt;br /&gt;&lt;br /&gt;Let's further assume that every insert into this table should actually be a replace. Then all we need is this simple statement and we're done:&lt;br /&gt;&lt;br /&gt;-- Merge rule&lt;br /&gt;CREATE OR REPLACE RULE merge_btv_lookup_weather_locations AS&lt;br /&gt;    ON INSERT TO btv.lookup_weather_locations&lt;br /&gt;   WHERE (EXISTS ( SELECT 1&lt;br /&gt;           FROM btv.lookup_weather_locations&lt;br /&gt;          WHERE lookup_weather_locations.code = new.code)) DO INSTEAD  UPDATE btv.lookup_weather_locations SET name = new.name, type = new.type, active = new.active&lt;br /&gt;  WHERE lookup_weather_locations.code = new.code;&lt;br /&gt;&lt;br /&gt;That's it! So how does it work? First, we create a rule to be processed whenever a row is inserted into the map table. Then, we use the subquery EXISTS(SELECT 1 FROM map WHERE key=NEW.key) to test for a row on the same primary key. If there isn't a row, the query proceeds as a normal INSERT. But if there is a row, the query is converted into an UPDATE that sets the value instead of trying to insert it. The 'NEW.var' means whatever values we were trying to INSERT.&lt;br /&gt;&lt;br /&gt;This is why I'm starting to become a PostgreSQL fan.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1925150244565910364-2775174127347634700?l=blog.chavkov.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.chavkov.com/feeds/2775174127347634700/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1925150244565910364&amp;postID=2775174127347634700' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/2775174127347634700'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/2775174127347634700'/><link rel='alternate' type='text/html' href='http://blog.chavkov.com/2009/10/replace-in-postgresql.html' title='REPLACE in PostgreSQL'/><author><name>Vlado Chavkov</name><uri>http://www.blogger.com/profile/03128216458383764972</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_9RxhR8IlDWk/Sif69ObJkCI/AAAAAAAAAr0/Y103Z6QXo1g/S220/b34f.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1925150244565910364.post-2603424463217871854</id><published>2009-10-11T09:21:00.000+03:00</published><updated>2009-10-11T09:22:26.921+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Mac OS X'/><title type='text'>How to convert dmg file to an iso image</title><content type='html'>I found this out a while ago when looking for info on reading .DMG files on Windows or Linux boxes. I found out it was not possible, and I wasn't too happy. You see, my iMac has no CD-R drive, just a CD-ROM. This tip creates ISO images from DMG images, so they can be burned elsewhere. To convert the file to an ISO image, type the following command at your terminal window:&lt;br /&gt;&lt;br /&gt;hdiutil convert /path/to/filename.dmg -format UDTO -o /path/to/savefile.iso&lt;br /&gt;&lt;br /&gt;Replace /path/to/filename.dmg with the path and name of the existing .DMG file, and replace /path/to/savefile.iso with the desired path and name for the converted image.&lt;br /&gt;&lt;br /&gt;This then creates an ISO image burnable in Nero on Windows, or pretty much anything on Windows that will burn ISOs and same with Linux. I just converted a DMG image as a test, and it took a while -- it only converted at about 1MByte per secoond, but I only have a 333Mhz imac G3, so speed wise, it may be good.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1925150244565910364-2603424463217871854?l=blog.chavkov.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.chavkov.com/feeds/2603424463217871854/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1925150244565910364&amp;postID=2603424463217871854' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/2603424463217871854'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/2603424463217871854'/><link rel='alternate' type='text/html' href='http://blog.chavkov.com/2009/10/how-to-convert-dmg-file-to-iso-image.html' title='How to convert dmg file to an iso image'/><author><name>Vlado Chavkov</name><uri>http://www.blogger.com/profile/03128216458383764972</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_9RxhR8IlDWk/Sif69ObJkCI/AAAAAAAAAr0/Y103Z6QXo1g/S220/b34f.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1925150244565910364.post-9106749132638511533</id><published>2009-08-19T12:51:00.001+03:00</published><updated>2009-10-11T09:29:23.526+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Ubuntu'/><title type='text'></title><content type='html'>&lt;div class="snap_preview"&gt;&lt;p&gt;Even if you use OpenOffice, you might still want all the &lt;strong&gt;Microsoft TrueType fonts&lt;/strong&gt; so that documents created using Word or PowerPoint look as they were supposed to when you open them with OpenOffice. Also, with the Microsoft Fonts installed we browsing will be better since the pages will look as the designer originally intended them to. Most webpages are designed with Microsoft fonts in mind. The stylesheet specify these fonts. On Linux, when these specified fonts are not available on your computer, they are replaced with generic equivalents. With these fonts installed, you will see the page as it was designed. To install the fonts, all you need to do in Ubuntu is to install the &lt;strong&gt;msttcorefonts&lt;/strong&gt; package. Instructions for installation are given below.&lt;/p&gt; &lt;p&gt;The Truetype Microsoft fonts provided by the package include:&lt;/p&gt; &lt;ul&gt;&lt;li&gt;  Andale Mono&lt;/li&gt;&lt;li&gt;  Arial Black&lt;/li&gt;&lt;li&gt;  Arial (Bold, Italic, Bold Italic)&lt;/li&gt;&lt;li&gt;  Comic Sans MS (Bold)&lt;/li&gt;&lt;li&gt;  Courier New (Bold, Italic, Bold Italic)&lt;/li&gt;&lt;li&gt;  Georgia (Bold, Italic, Bold Italic)&lt;/li&gt;&lt;li&gt;  Impact&lt;/li&gt;&lt;li&gt;  Times New Roman (Bold, Italic, Bold Italic)&lt;/li&gt;&lt;li&gt;  Trebuchet (Bold, Italic, Bold Italic)&lt;/li&gt;&lt;li&gt;  Verdana (Bold, Italic, Bold Italic)&lt;/li&gt;&lt;li&gt;  Webdings&lt;/li&gt;&lt;/ul&gt; &lt;h4&gt;Installing Microsoft Truetype fonts on Ubuntu&lt;/h4&gt; &lt;p&gt;You can install the MS core fonts by installing the &lt;strong&gt;msttcorefonts&lt;/strong&gt; package. To do this, &lt;a href="https://wiki.ubuntu.com/AddingRepositoriesHowto"&gt;enable the “Universe” component of the repositories&lt;/a&gt;. This is done by default in Feisty. After you do that, use the following command from the command line:&lt;/p&gt; &lt;p&gt;&lt;code&gt;$sudo apt-get install msttcorefonts&lt;/code&gt;&lt;/p&gt; &lt;p&gt;This will give you the core fonts, but if there are other TrueType fonts that you want installed, it is as easy as copying the font files to the &lt;em&gt;~/.fonts/&lt;/em&gt; directory. &lt;/p&gt; &lt;p&gt;After installing new fonts, you will have to log out and log in again to be able to see and use the new fonts. If you want to avoid this, you can regenerate the fonts cache by issuing the following command:&lt;br /&gt;&lt;code&gt;$sudo fc-cache -fv&lt;/code&gt;&lt;/p&gt; &lt;/div&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1925150244565910364-9106749132638511533?l=blog.chavkov.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.chavkov.com/feeds/9106749132638511533/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1925150244565910364&amp;postID=9106749132638511533' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/9106749132638511533'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/9106749132638511533'/><link rel='alternate' type='text/html' href='http://blog.chavkov.com/2009/08/even-if-you-use-openoffice-you-might.html' title=''/><author><name>Vlado Chavkov</name><uri>http://www.blogger.com/profile/03128216458383764972</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_9RxhR8IlDWk/Sif69ObJkCI/AAAAAAAAAr0/Y103Z6QXo1g/S220/b34f.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1925150244565910364.post-5468267071102363965</id><published>2009-06-14T15:31:00.001+03:00</published><updated>2009-06-14T15:31:59.873+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>Enable and Disable Ubuntu Root Password</title><content type='html'>Ubuntu is one of the few Linux distributions out there that will not enable the root account.If you want to do something with root permission on the console you have to type sudo before the command. &lt;p&gt;&lt;span id="more-84"&gt;&lt;/span&gt;&lt;br /&gt;sudo” means superuser do. “sudo” will prompt for “Password:”. Please specify user password&lt;/p&gt; &lt;p&gt;As you have noticed during the Ubuntu installation there was no question about the root password, as you might have been used to see during other Linux distribution installation process.Because of this your root accout is inactive.&lt;/p&gt; &lt;p&gt;If you want to enable root account (which is not recommended) enter the following command.&lt;/p&gt; &lt;p&gt;$sudo passwd root&lt;/p&gt; &lt;p&gt;This will prompt for a new root password and once you confirm it, you can start using the root account to login.&lt;/p&gt; &lt;p&gt;If you want to disable root account in ubuntu you need to lock the root account by using the following command&lt;/p&gt; &lt;p&gt;$sudo passwd -l root&lt;/p&gt; &lt;p&gt;If you want to work on a root console you’d better use the following command&lt;/p&gt; &lt;p&gt;$sudo -i&lt;/p&gt;&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1925150244565910364-5468267071102363965?l=blog.chavkov.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.chavkov.com/feeds/5468267071102363965/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1925150244565910364&amp;postID=5468267071102363965' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/5468267071102363965'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/5468267071102363965'/><link rel='alternate' type='text/html' href='http://blog.chavkov.com/2009/06/enable-and-disable-ubuntu-root-password.html' title='Enable and Disable Ubuntu Root Password'/><author><name>Vlado Chavkov</name><uri>http://www.blogger.com/profile/03128216458383764972</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_9RxhR8IlDWk/Sif69ObJkCI/AAAAAAAAAr0/Y103Z6QXo1g/S220/b34f.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1925150244565910364.post-2996037786044936535</id><published>2009-06-07T10:19:00.001+03:00</published><updated>2009-06-07T10:19:50.265+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'></title><content type='html'>Как да си изключа swap partion-а, за да проверя дали няма да имам подбрение в performance-a. Тази стъпка се препоръчва на машини с повечко RAM, които се ползват desktop или тестови машини, в никакъв случай не препоръчвам тази стъпка за машини в production. Идеята е да изстискаме малко performance, но машината трябва да се наблюдава, за да няма странни проблеми.&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1925150244565910364-2996037786044936535?l=blog.chavkov.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.chavkov.com/feeds/2996037786044936535/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1925150244565910364&amp;postID=2996037786044936535' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/2996037786044936535'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/2996037786044936535'/><link rel='alternate' type='text/html' href='http://blog.chavkov.com/2009/06/swap-partion-performance.html' title=''/><author><name>Vlado Chavkov</name><uri>http://www.blogger.com/profile/03128216458383764972</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_9RxhR8IlDWk/Sif69ObJkCI/AAAAAAAAAr0/Y103Z6QXo1g/S220/b34f.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1925150244565910364.post-1369616819587943849</id><published>2009-06-04T22:28:00.003+03:00</published><updated>2009-06-05T12:55:33.663+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>How to grep in files by specific extension</title><content type='html'>For example lets search for "*.php" files&lt;br /&gt;&lt;br /&gt;We should have something like this:&lt;br /&gt;&lt;br /&gt;find ./ -name "*.php"&lt;br /&gt;&lt;br /&gt;Now let grep for specific string "$GLOBALS" in a specific php file - test.php&lt;br /&gt;&lt;br /&gt;grep -n  "$GLOBALS" test.php&lt;br /&gt;&lt;br /&gt;Now let combine what we learn&lt;br /&gt;&lt;br /&gt;find ./ -name "*.php" -type f -exec grep -H -n "$GLOBALS" {} \;&lt;br /&gt;&lt;br /&gt;the above code search the current directory for php files and search in them "$GLOBALS"&lt;br /&gt;&lt;br /&gt;-H -n means show me filename and line number.&lt;br /&gt;&lt;br /&gt;This should work.&lt;br /&gt;&lt;br /&gt;For best results use GUI editor with search in files :-)&lt;br /&gt;&lt;br /&gt;For more info&lt;br /&gt;&lt;br /&gt;man grep&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1925150244565910364-1369616819587943849?l=blog.chavkov.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.chavkov.com/feeds/1369616819587943849/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1925150244565910364&amp;postID=1369616819587943849' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/1369616819587943849'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/1369616819587943849'/><link rel='alternate' type='text/html' href='http://blog.chavkov.com/2009/06/how-to-grep-in-files-by-specific.html' title='How to grep in files by specific extension'/><author><name>Vlado Chavkov</name><uri>http://www.blogger.com/profile/03128216458383764972</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_9RxhR8IlDWk/Sif69ObJkCI/AAAAAAAAAr0/Y103Z6QXo1g/S220/b34f.jpg'/></author><thr:total>0</thr:total></entry><entry><id>tag:blogger.com,1999:blog-1925150244565910364.post-3546556981562021311</id><published>2009-06-04T22:25:00.001+03:00</published><updated>2009-06-05T12:44:12.726+03:00</updated><category scheme='http://www.blogger.com/atom/ns#' term='Linux'/><title type='text'>How to remove '*.svn' files from a repository copy</title><content type='html'>find . -name '*.svn' | while read i; do rm -r -d -f "$i"; done&lt;div class="blogger-post-footer"&gt;&lt;img width='1' height='1' src='https://blogger.googleusercontent.com/tracker/1925150244565910364-3546556981562021311?l=blog.chavkov.com' alt='' /&gt;&lt;/div&gt;</content><link rel='replies' type='application/atom+xml' href='http://blog.chavkov.com/feeds/3546556981562021311/comments/default' title='Post Comments'/><link rel='replies' type='text/html' href='http://www.blogger.com/comment.g?blogID=1925150244565910364&amp;postID=3546556981562021311' title='0 Comments'/><link rel='edit' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/3546556981562021311'/><link rel='self' type='application/atom+xml' href='http://www.blogger.com/feeds/1925150244565910364/posts/default/3546556981562021311'/><link rel='alternate' type='text/html' href='http://blog.chavkov.com/2009/06/hw-to-remove-svn-from-directory.html' title='How to remove &apos;*.svn&apos; files from a repository copy'/><author><name>Vlado Chavkov</name><uri>http://www.blogger.com/profile/03128216458383764972</uri><email>noreply@blogger.com</email><gd:image rel='http://schemas.google.com/g/2005#thumbnail' width='32' height='32' src='http://3.bp.blogspot.com/_9RxhR8IlDWk/Sif69ObJkCI/AAAAAAAAAr0/Y103Z6QXo1g/S220/b34f.jpg'/></author><thr:total>0</thr:total></entry></feed>
