Archive for September, 2008

Vim Tips

Tuesday, September 23rd, 2008

Since switching to Linux, I have slowly fallen in love with Vim. I love how Vim makes it so that “your hands should never have to leave your keyboard” (Chris). The biggest drawback to using Vim, and Emacs, is that there’s a fairly steep learning curve. You pretty much have to abandon your comfort zone and force yourself to learn all of the different key bindings.

I’m very lucky in that I work with two vim gurus: Chris and Travis. Basically any question I have ever had with Vim, these two were able to answer them. But for times when they are not around I love using these sites:

This is a very short list because Vim is based on a few basic concepts and building on top of that. Once you get the basics, learning how to use buffers and macros gives you the ability to edit your files in any manner.

jQuery: Syncronising Multiple Objects and Animations

Tuesday, September 2nd, 2008

I was just told to do some crazy animations involving multiple css attributes on multiple DOM objects. With jQuery and its animate method, this is fairly easy to do:

$(obj1).animate({height:10,width:32,margin:30,left:5});
$(obj2).animate({height:20,width:62,margin:20,left:45});
$(obj3).animate({height:30,width:92,margin:10,left:25});
$(obj4).animate({height:40,width:122,margin:00,left:23});

Well everything is not entirely prefect because each animation occurs within its own timer interval. If one animation is slighter more complex than the other, it forces the rest of the animations to wait. This problem compounds itself to create an “easing” affect where the animation appears exponentially instead of linearly. This is due to how browsers fail to isolate different javascript timers or tabs from affecting each other.

Now my quest is to find an animation plugin where you can animate multiple objects with their own parameters in a single animation timer interval to ensure smooth, linear animation. If I can’t find one, this might be my chance to finally submit something back to jQuery. It might look something like this:

$.animate([
    {obj: obj1, params:{height:10,width:32,margin:30,left:5}},
    {obj: obj2, params:{height:20,width:62,margin:20,left:45}},
    {obj: obj3, params:{height:30,width:92,margin:10,left:25}},
    {obj: obj4, params:{height:40,width:122,margin:00,left:23}}
]);

Useful Linux Commands: Find and Search

Monday, September 1st, 2008

Learning Linux commands is probably the largest hump anybody new to Linux faces. Over the last year, I’ve compiled some useful, and somewhat non-obvious scripts that are really helpful to me on a weekly basis. Here are commands that deal with finding files and searching for text within a file:

Find and delete a directory:

find /PATH/TO/DIR -type d -name SEARCH -exec rm -rf {} \;

Find and delete a file:

find /PATH/TO/DIR -name SEARCH -exec rm -rf {} \;

Search within files:

 grep -r "SEARCH" *.EXTENSION /PATH/TO/DIR

Find and search within files:

find /PATH/TO/DIR -name "SEARCH" | xargs -I{} grep -H SEARCH {}

For more advanced options there’s always:

man find
man grep