The slow query log consists of all SQL statements that took more than long_query_time seconds to execute.
Archive for June, 2008
If you’re working on several machines, it’s a good practice to use different prompt colors.
For instance I would leave the prompt normal on my personal development machine, but I would make my prompt yellow on the staging server, and most of all, red on the production servers.
Just to remind me I should think twice before committing commands.
Here’s how to make it red (color code 0;31):
[deploy@sw29 abstracted]$ echo $PS1 [\u@\h \W]\$ [deploy@sw29 abstracted]$ export PS1="\e[0;31m[\u@\h \W]\$ \e[m " [deploy@sw29 abstracted]
Here’s how to make it yellow (color code 0;33):
[deploy@sw29 abstracted]$ export PS1="\e[0;33m[\u@\h \W]\$ \e[m " [deploy@sw29 abstracted]
1. Turn on Alpha channels (Layers/Transparency/Add alpha channels) if not already done
2. Click on the Gradient tool (L shortcut)
3. In the toolbox window under the tools appears the properties for the Gradient tool.
4. Click on the big rectangular icon and you see the setting by default is usually FG to BG (meaning the gradient will appear between the foreground color and the background color, with no transparency)
5. In the drop-down list that appeared select “FG to transparent”
6. Choose you foreground color
7. On the layer, use the gradient tool by clicking and maintaining the left mouse button, moving the mouse in the direction of the gradient, and releasing the button where you want the gradient to stop (the layer will be totally transparent starting from where the mouse was pointing when you released the button)
Here is a quick snippet of bash scripting to build a loop:
for fruit in "apple red" "banana yellow" "pear green" do set -- $fruit #parses the variable $fruit and sets the positional vars ($1, $2, $3,...) echo "The fruit named $1 is of color $2"; done
Your last revision 505 of a file should have never happened? You want to revert to 497? Here’s how:
svn merge -r 505:497 bank.php svn commit
It will bring back locally bank.php to revision 497.
And if you commit right away, it will commit 497, like if commit 505 never happened
SVN hidden directories cache a lot of temporary files. Most of the time when you do a recursive GREP you don’t need to go through them.
You can avoid exploring those sub-directories either manually every time you grep:
grep -r --exclude=\*.svn\*
Or set the GREP_OPTIONS environment variable, either in your .bashrc or by exporting it in your command line like so:
GREP_OPTIONS="--exclude=\*.svn\*" export GREP_OPTIONS
Adding this command to .bashrc will make it permanent, even next time you log in again.
The more recent versions of grep (from 2.5.3) have an exclude-dir option:
Older versions of grep that don’t support the exclude-dir options will return this error:
bash# grep -R "boo" . grep: unrecognized option `--exclude-dir=.svn' Usage: grep [OPTION]... PATTERN [FILE]... Try `grep --help' for more information. bash# bash# grep -V grep (GNU grep) 2.5.1 Copyright 1988, 1992-1999, 2000, 2001 Free Software Foundation, Inc. This is free software; see the source for copying conditions. There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. bash#
If you try to print another column than just a count(*) without specifying a GROUP BY clause, you will get this error:
mysql> SELECT description, count(*) FROM my_table WHERE action='post' AND result='fail'; Mixing of GROUP columns (MIN(),MAX(),COUNT(),...) with no GROUP columns is illegal if there is no GROUP BY clause mysql>
Just add the name of the extra column you are trying to print in the GROUP BY clause and you’re done:
mysql> SELECT description, count(*) FROM my_table WHERE action='post' AND result='fail' GROUP BY 'description';
This has a practical application in printing a Top 10 of most successful players:
mysql> SELECT name, count(*) FROM my_table WHERE action='fight' AND result='success' GROUP BY 'name' LIMIT 10;