Jun 17: Uptime-Devil
Mai 26: Did you know ...
Mai 6: Negative ping latency
Apr 28: MySQL 5.4 with new features
MySQL just released a brief overview of MySQL 5.4:
- Scalability Improvements
- Subquery Optimizations and Join Improvements
- Improved Stored Procedure Management
- Information Schema Additions
- OUT Parameter Support in Prepared Statements
Apr 15: Recovering InnoDB databases
There is a bug in MySQL <5.0.48 that prevents dumping damaged tables. If something really fucked up you have to use the innodb_force_recovery parameter to get the InnoDB engine into some kind of repair mode. But when using this option, a select fails with the following error:
mysql> select * from acknowledges limit 1;For further information refer to http://bugs.mysql.com/bug.php?id=28604.
ERROR 1034 (HY000): Incorrect key file for table 'acknowledges'; try to repair it
Aug 6: for-loop in bash
If you want to update several hosts at once you can use a for-loop in a shell to execute a command on serveral hosts
for i in 1 3 `seq 4 7` 9; do HOST="1.2.3.$i"; ssh root@$HOST; done;
As you can see it is very easy to create a custom set of items to loop through. On the one hand you can use any value seperated by a space or you can create a sequence of numbers with the seq-command.
Jul 23: Keep the indent small
Usually PHP-Code looks like this (source):
$dir = "/etc/php5/";
// Open a known directory, and proceed to read its contents
if (is_dir($dir)) {
if ($dh = opendir($dir)) {
while (($file = readdir($dh)) !== false) {
echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
}
closedir($dh);
}
}
But IMHO this is bad coding style. A long indent does not make your code better. Far from it! On the one hand, an ident should be used to separate nested code blocks. On the other hand you should avoid unnecessary deep nesting. Try to alter your code and seperate error-cases in own blocks:
$dir = "/etc/php5/";
if(!is_dir($dir)) {
throw new Exception("...");
}
$dh = opendir($dir);
if(!$dh) {
throw new Exception("...");
}
while (($file = readdir($dh)) !== false) {
echo "filename: $file : filetype: " . filetype($dir . $file) . "\n";
}
closedir($dh);
This is kind of annoying if you have a class (+1 indent) and a method (+1 indent) and switch-block (+1 indent) in your code. If you now start to create further nested code, you have about 5-7 indents and it is hard to track your code. Not only because half of your screen is blank and you have to scroll vertically to see the rest of the line, sometimes the error-handling is several dozen lines behind the original statement that caused the error.
Jun 13: CSS support in email clients
According to an research of http://www.campaignmonitor.com/css/ Outlook 2007 has major problems with CSS. This is the result of a changed render engine for HTML emails in Outlook 2007 based upon Word 2007 - not IE.
So don't even try to common CSS attributes like background-image when sending HTML emails.
Apr 3: Cisco arp cache
When using virutal machines, it happens that an ip address gets reassigned between two VHosts. I recently had the problem, that one of our core routers (12000-Series, IOS Version 12.0(32)S6, RELEASE SOFTWARE (fc3)) didn't flush an malicious arp entry.
As it is a virutual interface, simply clearing the arp cache was not possible, without affecting multiple sytems on the physical interface. But here is an easy solution by configuring an arp entry - and deleting it right afterwards.
#show arp | inc GigabitEthernetX/X.XX
Internet XXX.XXX.XXX.XXX 223 xxxx.xxxx.xxxx ARPA GigabitEthernetX/X.XX
#conf t
#arp YYY.YYY.YYY.YYY yyyy.yyyy.yyyy arpa
#no arp YYY.YYY.YYY.YYY yyyy.yyyy.yyyy arpa
#exit
#show arp | inc GigabitEthernetX/X.XX
Internet YYY.YYY.YYY.YYY 7 yyyy.yyyy.yyyy ARPA GigabitEthernetX/X.XX
Jan 10: First steps on Rails
Ruby just crashed with the following error message:
compile error
/usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1748: syntax error, unexpected tINTEGER
Object::0
^
The last entry in the trace points to:
/usr/lib/ruby/gems/1.8/gems/activerecord-2.0.2/lib/active_record/base.rb:1748:in `compute_type'After searching a while I found a post refering a problem with columns named 'type'. According to a wiki acticle about SingleTableInheritance a column named type must have the fieldtype string. In my case the field contains an integer value, that produces this strage error message.
Jan 4: Concatenation with NULL values
Everybody should know, that NULL values can produce results you dont expect. Usually you are aware of what NULL values are and cause. But if NULL values occure and you didn't expect them, prepare for "Unforeseen Consequences".
Here an example what can happen.
lesen Sie mehrDez 13: cakePHP Subnetcalc Helper
Ever needed some help when calculating a subnetmask or a broadcast address? Then this one is your friend!
lesen Sie mehrDez 13: PHP CSV to DB script
Neither phpmyadmin nor MySQL Query Browser is able to load a CSV file directly into a DB. As this is a frequent issue, i wrote an import script.
lesen Sie mehrDez 5: Rootserver hacking
Nov 23: Locales support
I tried setting up a new blog that should display german date format, but none of the (usually valid) locales worked. The php function setlocale() always returned false. So I searched and found a debian package that fixed my problem, by installing all locales:
apt-get install locales-all






PHP/MySQL



