Archive for May, 2008
Create a new MySQL-user with all privileges
GRANT ALL PRIVILEGES ON thedatabase.* TO 'theusername'@'localhost' IDENTIFIED BY 'thepassword' WITH GRANT OPTION;
UPDATE 20080916: Skip the last line if the user exists.
Root partition free space
du -xh --max-depth=1 /
On using find
find is an extremely powerful command. In order to leave the directory matching *DIRECTORY* out from your search for .txt-files:
find . -path '*DIRECTORY*' -prune -o -iname '*.txt' -print
If you’re using xargs together with find and xargs complains about file names with spaces, use:
find . YOURFINDOPTIONSHERE -print0 | xargs -0 rm -rf
Finding files larger than a certain limit:
find . -size +200M -print0 | xargs -0 ls -lh
Deleting the complementary files:
find . ! -name "*.mp3" -delete
Courtesy of HÃ¥kon.
Please note that these commands pertains to the BSD find as on Mac OS 10.5.
UPDATE 20080517: Looking for file size
UPDATE 20080602: Added deleting complement
Backup a MySQL database with mysqldump
It’s very easy, but I always have to look it up.
mysqldump --opt -u USERNAME -p -h HOST.HOST.COM DATABASE_TABLE > DUMPFILE.sql
Some useful Vim-commands
There are numerous pages and blog posts about Vi and Vim out there so here’s my small contribution. Here are some less frequently used commands that tends to be useful from time to time:
| Delete lines patching pattern |
:g/pattern/d |
| Go to position previously modified |
g; |
| Go to next modified position in change list |
g, |
| Create bookmark in file |
mLETTER |
| Go to bookmark |
'LETTER |
| Change highlighted text to upper case |
gU |
| Open file under cursor |
gf |
| Coopy text mathich pattern to register a |
:/pattern/yank A |
| Paste text from register a |
"ap |
| Reduce split window size |
C-w - |
| Increase split window size |
C-w + |
| Make split windows equally big |
C-w = |
Prettify print_r output
By putting print_r() statements enclosed by html pre-tag, the output is quite a lot more readable.