Wednesday, December 22, 2010

Momentary Lapse In Blogversation

Just a short post today:

I guess some tips/tricks I've picked up recently:

Vim:

For any one who uses the greatest editor on the planet,
I found out how to do visual search and replace,
v
to go to visual mode
select the portion you want,
and use
:s/foo/bar/
as you would in normal mode.

This is extremely handy and quick.

I also falling more in love with vim macro's each day,
My favourite thing to do with them at the minute is for insertion of classes in a html document.

E.g

<\input type="text" value="user" />
<\input type="password" value="pwd" />


Record a macro using
qr
to store in r register (there is a register per letter)
Do what needs to be done on one input, making sure it is generic actions that will work on each input.
and then press
q
again to stop recording.
then
@r
will do the macro, the very cool thing about this is that you can equally do,

4@r
to do it on 4 inputs concurrently once the macro is generic, not only does this look cool, it saves a massive amount of time, particularly on very repetitive tasks.

USE VIM!!!

PHP


I think the more I use it, the more I like it, Its basically the easy man's version of C++ with every possible function you can think of. I had a problem space during the week, (creating a reporting manager) and It was necessary to sort an associative array on the value rather than key.

I was wondering the best way to do this, all sort of crazy ideas popped into my head, e.g (copy all values into an array sort and match back with keys)

turns out php has a method called
asort


and for me who wanted my values numerically sorted in descending order, arsort.

I love php for this. Its slow, heavy and at times feels like Java but at the end of the day, I like how easy and quick it is to get things done.

Out.

No comments:

Post a Comment