I needed arbitrary precision math in PHP, and wasn’t willing to rebuild PHP to add the bcmath extensions. All hail backticks.
function bceval($expr) {
return trim(`echo "$expr" | bc`);
}
Used like so
$end = bceval("$start + $batchsize - 1");
Wet cat territory.
A lot of you may already know this, but I am willing to bet there are more that don’t. I’m talking about the tee command in the bash shell, and in MySQL. For our purposes, we’ll talk about the tee command in MySQL.
Problem: You have a series of SQL statements whose results take up a few screens worth of output, and you need to take this output and send it to someone else (A DBA, MySQL Support, your mentor). You could just do a copy/paste from your terminal, but what if you realized in the end that your scroll back buffer isn’t as large as you thought it was?
Solution: Tee. Apparently, the mysql client comes with tee.
mysqlshell> tee mysqlog.sql ;
Logging to file ‘mysqlog.sql’
use dbname;
select foo from bar;
….
mysqlshell> notee;
quit;
bash> cat mysqlog.sql
This could be filed under “my bag of neat mysql tricks”
PS: Sorry for the K.T Tunstall song reference/joke.. I heard it on Saturday and it’s not leaving my head.
opensource: del.icio.us tag/opensource
Ajax
PHP
JavaScript
shell
opensource
jQuery
system:has:license
Corsi di informatica linux ed opensource in aula a Roma