Tip 1:-
I always need several Cygwin Windows open so I was very frustrated by Windows 7 only allowing me to open one Cygwin from the Windows 7 Taskbar. This is because once you click on an icon it disappears from the Taskbar! This is different to the behavior of the previous XP or Vista Taskbar and often prompts users to select the Vista Taskbar compatibility. There is fortunately a work around depress the SHIFT button and then click the existing open icon on the taskbar and voila you will spawn a application window!
Tip 2:-
The Properties Tab is HIDDEN on the Windows 7 Taskbar and had me hating it until I found it. Rightmouse click the relevant Application Icon on the Taskbar then hover over the revealed tab and Right Mouse Click this and there magically is the Properties Tab!!
There are two ways:-
$price=~tr/0-9.//cd; # delete anything but 0-9 and a real dot
$row_array[6]=~s/[^0-9.]//g; # clean up price, remove pound/dollar sign etc
preg_match_all(‘#<b>.+?</b>#i’, $html, $matches);
// ? means non-greedy and is absolutely critical
$match[1], $match[2] contain the results
Non greedy stops the match gobbling everything between the first bold tag and the very last. I’ve never quite understood why greedy is the default behavior of RegExp (Regular Expressions) but I guess there’s a good reason for it.
PHP also has the very useful strip_tags function.
This for loop is OK
foreach($cargo_data as $cid=>$cargo_record)
{
$cargo_id=$cargo_data[$cid]['cargo_id'];
$section=$cargo_data[$cid]['section'];
…
}
But then later you add a condition cargo_id>6
foreach($cargo_data as $cid=>$cargo_record)
{
if ($cid>6) {$cargo_id=$cargo_data[$cid]['cargo_id'];}
$section=$cargo_data[$cid]['section'];
…
}
Now the bug is that if $cid is less than 6 $cargo_id is not set and will likely inherit the value it was set to in the last loop this type of error may not be immediately noticeable but can cause chaos. In this simple example it is easy to see that their should be an else clause, however the real solution is to systematically initialize all the variables at the beginning of the loop.
This could easily be done with Perl but here is a zsh solution
I want to convert a textified string to a Title Case Phrase
>
> eg
> fred-goat-dog.jpg to Fred Goat Dog
>
% print ${${(Cs:-:):-fred-goat-dog.jpg}%.*}
Fred Goat Dog
This curiously uses a smiley face though
foo=fred-goat-dog.jpg
echo ${(C)foo:gs/-/ /:r} might be more elegant
From the zsh newsgroup (RD&MM)
and to textify a phrase
s=’Fred Goat Dog’
print ${(L)s:gs/ /-/}.jpg
or
print ${(L)s// /-}.jpg
I’d put some new files into a folder before remembering to mothball all the old files:-
Here is a zsh solution:-
>mv *.*(^m-1) ./old
I’ve never got the hang of popd & pushd they seemed a bit pointless. zsh however has extended their abilities eg:-
> dirs -v # number and list your recent directories one per line
> cd ~5 # cd to directory 5 in the directory stack
> cd -<tab> # the tab complete lists the directory stack then type a digit to select the one you require (saves you having to do a dirs -v in the first place
I have to work in very complicated directory structures so this will be fantastically useful.
#don’t forget the zsh cd substitute command
> cd olddir newdir
eg you are in
/inetpub/wwwroot/www.livesite.co.uk/products/
> cd live test
/inetpub/wwwroot/www.testsite.co.uk/products/
I had been using my own ad-hoc system for years but recently started using CVS to maintain a history of my file and document changes. I was quite happy with CVS but everyone told me I should be using Git instead. Git seems to be simpler and more intuitive. I can set up git for a folder or project very quickly. You just need the following 5 commands to get going
git init (set up git for the current directory)
git add *.php (add all your php files or whatever)
git commit -m “first version” (also need to commit all your existing php files)
vi index.php (make a few changes)
git commit -a -m “Added new date feature” (do this periodically to maintain version control)
gitk is a simple TK Gui which allows you to review you versions etc. I am delighted to have version control, all I have to do is remember to do a > git commit -a -m “Added new date feature” every now and again (eg daily)
You know the frustration of being able to log into a website because your browser has
remembered the password but you have forgotten it and so cannot login from another pc.
Well FireFox will show them to you
options->security->Saved Passwords then click Show Passwords
You may want to consider the security implications as well, to disable this feature while
retaining the ability of the browser to remember passwords
go to
options->security-set master password
I personally never let a browser remember say my PayPal password