Here youll find CP to unicode converter written by me. I needed such utility for MS-DOS. Yes, MS-DOS doesn’t support unicode, but what to do if you need to convert from windows-1257 to Unicode. Yes, there are some converters written for windows. Some of them are shareware. But I didn’t find any freeware to batch convert lots of files at a time. Well there are linux sollutions such as enca but it didn’t work as I expected. So I written little conversion utility by myself.
To make string separated by commas I needed to make loop, but there is last comma which i do not need, so I used PHP function substr(). In my sample there was MySQL query and i was fetching record by record and writing values to string:
//$rezult – some mysql query’s result
for($i = 0;$i < $kiek; $i++) {
//get array of values
$found = mysql_fetch_array($rezult);
//add record’s value to $record_str, plus comma
$record_str .= $found[record] . ", ";
}
//remove last three symbols from string to get rid of last comma
substr($record_str, 0, sizeof($record_str)-3)
So finaly I got my needed string:
value1, value2, value3, …, valueN
Instead of:
value1, value2, value3, …, valueN,
To check how much users uses space on linux box, simply use du command.
Recently I needed to show report for my boss, how much space used by users’ in a particular server.
As all user data stored in /home directory, I just executed such command:
# mail -s ‘User disk usage report’ boss@workplace.dom < report.txt
# rm -f report.txt
-h parameter means to output in human readable format, append a size letter, such as M for binary megabytes.
–max-depth=1 means, that I need to output only directories with user names (I dont need to show users’ subdirectories).
Of course subdirectories are counted, just not shown.
Report has been written in report.txt file, then sent to my boss by mail with subject User disk usage report.
Recently, I got email from one site admins. Problem was, that their automaticaly generated e-mails didn’t reach our mail server. After log checking I found problem:
Jan 24 10:09:58 mail amavis[6759]: (06759-06) spam_scan: hits=-3.835 tests=BAYES_00,HTML_30_40,HTML_MESSAGE,HTML_TAG_EXISTS_TBODY
Jan 24 10:09:58 mail amavis[6759]: (06759-06) FWD via SMTP: [127.0.0.1]:10025 ->
As you can see, amavis spam scan detected those emails as spam messages. Simplest sollution was to add their host to whitelist there is fragment from /etc/amavisd.conf
map { $whitelist_sender{lc($_)}=1 } (qw(
nobody@cert.org
slashdot@slashdot.org
bugtraq@securityfocus.com
…
<span style="text-decoration: underline;">email@from.dom</span>
));
I will allways emerge logrotate in fresh gentoo install, I will allways emerge logrotate in fresh gentoo install, I will allways emerge logrotate in fresh gentoo install, I will allways emerge logrotate in fresh gentoo install…
Doh, how could I forget such usefull thing. Yesterday I was checking logs in gentoo servers and found, that theyre about 1GB :O
