Posted on March 23, 2007
We can't imagine a web site without at least a rudimentary search functionality. What a frustration when we shop for a particular product or looking for an answer on a community web site and can't find exactly what we are looking for. The search is the paramount for any online business. If a customer can't find a product she's looking for, she would go somewhere else and you lose a sale.
Unfortunately, most of the databases don't provide full-text search capabilities or provide a minimal support which is not enough in most of the cases.
Filed under: Rails |
Posted on March 19, 2007
I've been using TextMate since probably the first public version. At least my license dialog shows October 6th 2004, Serial Number #60. And, oh boy, I've been a happy user. I can't declare that this is the best editor out there, and I don't want to start another editor vs war. I've been using Vi(m)/emacs for such a long time that I can't even remember and I'm not going to give up on them just yet. But I can say that TextMate is definitely a unique piece of software that sets a high mark for other editors to follow.
I think the most innovative feature of this editor is the way it represents the document structure with scopes. Everything else is built around this structure: shortcuts, snippets, commands, code highlighting, etc. This very feature makes it so much easier to customize your editor, than anything I've seen so far. (Whatever I've tried I couldn't make mmm-mode package work for me).
Another thing that I'd love to have from any editor is a desktop integration. Don't get me wrong, I'm an avid terminal and CLI proponent, but I've access to the most powerful desktop out there and it would be sad if I can't enjoy it when I'm writing my documents. And TextMate allows me enjoying both of these worlds.
OK, enough of TextMate praises, there are still some areas where this editor needs some love. One of them is the search capability. The regular and incremental searches are fine, I'm talking about the Find in Project search. First of all, it's quite slow and it used to take a lot of your RAM. Second of all, I've found that in about 95% of all cases, I need to search in a particular directory of my project. So I did what everyone else does, I created my own command, which I am about to share with you.
Quick Search
This command uses grep utility to search in your documents. It's bound to ⌃⇧F keystroke and uses a selected text or prompts you for a query text. What makes it quite useful is that, if you have a project opened, you can select a directory in the project drawer and this command will limit the search only to this directory and all subdirectories. Also you can define the environment variable TM_QS_FILTER in your project settings with a value of a regular expression that selects all files and directories that you don't want to search in. For example, I'm using (tmp|log|rails)$ value for my Rails projects.
Enjoy.
Filed under: TextMate |
Posted on March 15, 2007
Probably the most boring task when writing Rails test cases is entering new fixtures. With a little help from TextMate this process can be made more pleasant.
- Open Bundle Editor and create a new command.
- Name it, for example, 'rails: new fixture'
- Use this script as the command body:
Filed under: Rails TextMate |
Posted on March 15, 2007
This is mostly a maintenance release. The major change is that ruby-debug has been split in two parts:
ruby-debug-base gem contains the debugger core API written in C. Use this gem if you want to create your own interface to the debugger and don't want to depend on changes to the ruby-debug CLI. The API is considered somewhat stable.
ruby-debug gem depends on ruby-debug-base and provides CLI interface.
Filed under: ruby-debug |
Posted on March 09, 2007
Lately I've been playing with MacFuse project and all I could say is that this is a fantastic effort of bringing the well-known user-space(fuse) file system to the OSX land. The latest versions of fuse work well with FreeBSD and MacFuse extends this functionality to OSX platform.
My goal was to make Ruby's fusefs extension play along with it. The major stumbling point was that MacFuse requires using the new fuse API, so I had to make several modifications to fusefs in order to make it possible at least to compile it.
OK. If you are a braveheart type and not afraid that it might damage your computer, these are the steps you need to do in order to install this extension:
Download the latest version of MacFuse and use the installer that it comes with.
Check out my version of fusefs from http://svn.datanoise.com/fusefs-osx and use the standard procedure of installing Ruby extensions:
$ svn co http://svn.datanoise.com/fusefs-osx
$ cd fusefs-osx
$ make
$ sudo make install
That's about it. Now you can start playing with examples located in <fusefs-osx>/sample directory. When you are at it, I'd like you to take a look at one of my personal toys - the remote DRb-based file system. It is located in <fusefs-osx>/sample/drb directory and that's how you use it:
On the remote side (a Windows box will do just fine) start the drb server:
$ ruby ./sample/drb/drbfs_server.rb ~/shared
druby://myhost:7777
The script takes the name of a directory you want to share. When the script is started, it'll print the URL you have to use when you mount your DRb filesystem on the client side.
On the client side, mount DRb file system:
$ ruby ./sample/drb/drbfs.rb mount/ druby://myhost:7777
$ ls mount
The client script takes the name of a directory you want to mount to and the URL of the server from the step one.
Enjoy and don't forget to read <fusefs-osx>/OSX.txt for the important API changes.
Filed under: OSX Ruby |
Posted on March 03, 2007
So many times while watching log files I wanted to find a command that combines tail with grep filtering functionally. The Unix command repository is huge and I'm pretty sure you can do it without resorting to a scripting language. But having spent several minutes googling for this functionality to no avail, I decided to bring Ruby to the rescue.
At first I thought that I had to port File::Tail Perl module to Ruby, but I found that it has been done already by Florian Frank. He has even provided a convenient way of installing it:
$ sudo gem install file-tail
OK, the rest was as obvious as this:
$ cat tailg
#!/usr/bin/env ruby
require 'rubygems'
gem 'file-tail'
require 'file/tail'
if ARGV.size != 2
$stderr.puts "Usage #$0 <regexp> <log-file>"
end
begin
File.open(ARGV[1]) do |log|
log.extend(File::Tail)
log.interval = 2
log.backward(10)
log.tail { |line| puts line if line =~ /#{ARGV[0]}/ }
end
rescue Exception
end
$./tailg 'products' /var/log/searchd_query.log
[Sat Mar 3 13:39:40 2007] 0.000 sec [all/0/rel 3 (0,9)] [products] NOA
[Sat Mar 3 13:39:44 2007] 0.000 sec [all/0/rel 22 (0,9)] [products] lauren
[Sat Mar 3 13:40:09 2007] 0.000 sec [all/0/rel 22 (9,9)] [products] lauren
tailg command accepts two parameters: a regexp to filter for interesting lines and a log file itself.
Filed under: Ruby |