Search for files quickly with dir and findstr

One of the linux routines that is always helping me much when I'm investigating a new linux system or searching for something on the hdd is locate. This very simple program queries the database of file names on your disk and returns all paths that match the criteria. What is good about it is extremely fast. Searching for something takes only a few seconds or less. And you can use regular expressions, use the result as input for other programs, etc.

Windows has indexing service, some other third part tools like Google Desktop Search, but they are just very big for me. I do not need all these PDF and email searching addons. Just search for one file or a set of files with similar extension as quickly as possible please and give me this list in text file. No? Hm... Fortunately, it is very simple task that I can do myself.

First of all, I need to create a list of all files on the disk. The "dir" commands will help me:

c:\> dir c:\ /b /s > c:\dirlist.txt

and then this list can be queried by using the findstr command:

Search for all avi files:
c:\> findstr /i /e .avi c:\dirlist.txt

Search for all exe files in C:\Windows:
simple text match:
c:\> findstr /i /b c:\windows\ c:\dirlist.txt | findstr /i /e .exe
regular expressions:
c:\> findstr /i /r ^c:\\windows\\.*\.exe$ c:\dirlist.txt

Search for all doc files in user's folder (Windows Vista):
simple text match:
c:\> findstr /i /b c:\users\alex c:\dirlist.txt | findstr /i /e .doc
regular expressions:
c:\> findstr /i /r ^c:\\users\\alex\\.*\.doc$ c:\dirlist.txt

This search is faster then simple file search in file managers. Of course, it is not as fast as other specialized desktop search engines, but you can use more complex queries by pipelining search results to different findstr calls. And what is very important, you can be sure that after updating dirlist.txt you are searching the latest database without outdated and with all new files.

Help for dir:
c:\> help dir
Help for findstr:
c:\> help findstr

Linus Torvalds on git

You definitely should not miss a talk about "git", a distributed version control system, from its author, Linus Torvalds. The video was posted a year ago but only recently comes to my attention, together with russian translation that may be usefull for my russian-speaking friends and co-workers. If it is really as good in merging as Linus described, it worth trying.

But for me the main point of this talk is not in "git" itself but in difference between the traditional (CVS, SVN) and distributed version control systems (git, mercurial), which is clearly described by the Linus in the video. For me it was very helpful to learn how people really use distributed version control systems in real projects, especially from the leader of Linux kernel project. And BTW, I like his kind of humor :-)

Just in case if you do not know: mercurial is supported by SourceForge and Google code, TortoiseHg is a shell extension (a kind of GUI), Hg is a sign of the mercury chemical element.

Artisteer 2.1 is released


Artisteer 2.1 is released this week with a lot of improvements. The full list of improvements you can find here. The most important of them are the following:

  • New collapsible module/block positions are added in Joomla and Drupal templates.
  • The navigation menu can be right-aligned.
  • Improved HTML/CSS to minimize the number of tables and improve Dreamweaver CS4 compatibility.

Zend Framework news

Zend Framework team continues improving the major framework for PHP developers and recently have released version 1.8 (and then 1.8.1). I've missed the release because of my European vacation but now I come back and my fingers itch to try the excellent improvements the team made when I was far from my computer:

  • Zend_Application - a long-waiting class that represents application and provides module loading hooks that you can bind you code to.
  • Zend_Tool - a set of tools for automatizing some of the project creating and maintaining tasks: creating projects, adding resources, actions, etc.
  • Zend_Navigation - a class for creating breadcrumbs, menus, sitemaps, etc.
  • Improvements in Zend_Validate, Zend_Filter, Zend_Search_Lucene, Zend_Pdf, and many more framework classes.

And my special congratulations to Matthew Weier O'Phinney, who now is the ZF project leader. I wish you finding the best between quality, time, and budget, encourage the framework developers to do new good features and help us to use them right.

And just in case you do not now what to do now, subscribe on my RSS feed, get some beer or coffee, as you like, then download Zend Framework and have good time exploring the new features.

Greetings from Prague

After a dozens of hours spent on preparing our trip and after a short flight, we are in Prague. It is our first day, so we have not visited any historical objects, but already started enjoying out journey.

Have fun :-)

P.S. Of course, I cannot answer your emails and monitor comments on the blog. Just have no time for this. But stay connected, I'll post more photos and notes about our travel.

PowerShell helper: PowerGUI

PowerGUI is an excellent helper for the developers who are just started to investigate PowerShell. With a lot of examples, very good GUI and editor with debugging and intellisence (who ever dreamed of something like this for bat files?) it simplifies the creation of PowerShell scripts in many times. You can also watch a video tutorials on the PowerGUI site, some of them very helpful.

Example of the PowerGUI editor:

When IE6 disappears and Web designers' dream comes true?

I've spend some time investigating when all of us will be free of IE6 bugs and limitations. My estimation is based on the browser statistics and trends page from W3schools.com.

I've compared IE5 and IE6 history and draw a chart:

Both browsers start at 55% of the market share, but in different years. This graph shows that IE5 and IE6 are similar in loosing their market shares. IE6 is little more viable then IE5 but it cannot escape their common destiny. But how far this is from now?

I think that IE6 will touch 10% point of market share in one year from now, 5% in two years after its 10% point, and 0% in next two years. 5 years in total, in 2014.

Update: Magically, the year I've calculated is the same Microsoft declared the end of Windows XP (The future of Windows XP).

We plan to provide support for Windows XP until 2014.

File stream wrapper is overwritable in PHP

I find today that the default "file" stream wrapper in PHP is overwritable. You only need to call stream_wrapper_unregister and then stream_wrapper_register with your wrapper.

Imagine that you want to integrate your system A with another system B and you need to "catch" some of the files the B system includes and modify them or replace with another file.

Implementing this by patching the files of the system B comes to mind first but making the same with a custom "file" stream wrapper may be more interesting.

File: test.php5

<?php echo "I'm " . basename(__FILE__);

File: sample.php

<?php

class CustomFileStreamWrapper
{
  private $_handler;
  function stream_open($path, $mode, $options, &$opened_path) {
    stream_wrapper_restore('file');
    $this->_handler = fopen($path . '5', $mode);
    stream_wrapper_unregister('file');
    stream_wrapper_register('file', 'CustomFileStreamWrapper');
    return true;
  }
  function stream_read($count) {
    return fread($this->_handler, $count);
  }
  function stream_write($data) {
    return fwrite($this->_handler, $data);
  }
  function stream_tell() {
    return ftell($this->_handler);
  }
  function stream_eof() {
    return feof($this->_handler);
  }
  function stream_seek($offset, $whence) {
    return fseek($this->_handler, $offset, $whence);
  }
}

stream_wrapper_unregister('file');
stream_wrapper_register('file', 'CustomFileStreamWrapper');

// Includes test.php, not test.php5!
require 'test.php';

Output:

I'm test.php

Follow me on twitter

You can follow me on twitter:

/alex_at_net

Alex@Net design contest

You can see that I've changed my site design a few week ago. Generally, I like it, but maybe you can propose something better. Especially because making proposal becomes very simple with Artisteer.

What you need to do is to download Web Design Generator - Artisteer and create design you like or want my site look like and send the Artisteer project file to me (to alex.netkachov@gmail.com) together with your blog/site link (no adult, warez, etc links, please), the word "Artisteer" should be included in the subject of the mail. Any graphics you use in design should be in public domain.

Some specific design skills are not required. If you have not designed anything before, it is ok.

There will be two winners: first will be chosen by me, second will be chosen by the community. If I do not choose any of the designs for my site there will be two community winners.

Prizes: link in footer as long as design stays on my site (my winner), Artisteer Home Edition license (community winner).

Time limit: two weeks from now.