Monday, November 30, 2015

Request exceeded the limit of 10 internal redirects due to probable configuration error.

I upgraded to Apache 2.4.10 and I am getting these errors for sites which used to work:

AH00124: Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

One strange thing is these happen only with .htaccess files. So if I use exactly the same configuration but written in vhosts config file such as /etc/apache2/sites-enabled/000-default.conf all works well. So yes, one quick fix is to put it there. But after doing some tests, I found out apache 2.4 does not like when you redirect stuff to index.php but you don't have a rule for index.php itsels. So simply keeping all rules and adding something like RewriteRule ^index\.php$ - [L] fixed the problem.

[UPDATE] On many other cases it seems to work without any trouble or extra rule, but on that particular one not... strange.

Sunday, November 29, 2015

kernel: do_IRQ: No irq handler for vector (irq -1)

On a fresh Debian Jessie I kept getting every couple of minutes this error:
do_IRQ: No irq handler for vector (irq -1)
A suggested solution is to add "pci=nomsi,noaer" in /etc/default/grub at GRUB_CMDLINE_LINUX
However,  noaer refers to PCIE Advanced Error Reporting and I don't want only to hide the mess, I want to fix it (if possible).
Only adding pci=nomsi seems to do the trick so far.
Also don't forget to do a update-grub after you edit /etc/default/grub.

Saturday, November 28, 2015

Debian 8 does not execute /etc/rc.local

I have just installed a fresh Debian 8 Jessie and then I put something in /etc/rc.local.
To my suprise, after the reboot, the command did not execute.
Log investigation showed:
Failed to start /etc/rc.local Compatibility.
Failed at step EXEC spawning /etc/rc.local: Exec format error
So I simply added "#!/bin/sh -e" in the first line of rc.local and then it worked well.

Thursday, November 19, 2015

Monday, October 19, 2015

HITACHi Air Conditioner green light turn off

Since last year I have a HITACHI Air Conditioner and the technician told me to clean the filters every two weeks, but he didn't mention anything about the green led. So after a while, this green light turned on, I noticed it has something to do with the filters so I have cleaned them hoping it has some sensor and will turn off automatically. But it didn't. Later I found you have to press the AUTO SWING from the remote while the unit is off. And after 200 hours of functioning it will turn on again to remind you about cleaning the filters.

Pasting source code in friendly format

Here are three tools you can use to paste source codes:

http://codeformatter.blogspot.de
http://hilite.me/
http://markup.su/highlighter/

Tuesday, October 06, 2015

Mass kill processes in MySQL "show processlist"

So your server load is high you did "SHOW PROCESSLIST;" and you noticed many slow queries and you want to kill them.
If the list is too long to do it manually, you may want to try this way:

<?php

include("mySqlClass.inc.php");

$serv="localhost";
$user="root";
$pass="YOUR_PASS";
$database="SOME_DB";


$link = new mySqlClass();
$link->Connect($serv,$user,$pass,$database);
$result=$link->SqlQuery("SHOW FULL PROCESSLIST");
while ($result->NextRow()) {
    $process_id=$result->field["Id"];
    if ($result->field["Time"]>200) $link->SqlQuery("KILL $process_id");
}   

?>


and the mySqlClass.inc.php:


<?php

class mySqlClass {

  public $query_count;
  public $query_time;

  private $database;
  public $link;
  private $db_connected;

  function __construct()
  {
    $this->query_count = 0;
    $this->query_time = 0;
  }

  public function Connect($host, $user, $password, $database)
  {
    $this->database = $database;

    $this->link = @mysql_connect($host, $user, $password, true);

    if ($this->link)
    {
      if (@mysql_select_db($database, $this->link))
      {
        $this->db_connected = true;
        return true;
      }
    }

    $this->_error(mysql_errno(), mysql_error());
    return false;
  }

  public function SqlQuery($sql)
  {
    $time_start = explode(' ', microtime());

    if (!$this->db_connected) $this->_error(0, 'Error: MySQL DB Not Connected');

    $result_resource = @mysql_query($sql, $this->link);

    if (!$result_resource) $this->_error(@mysql_errno($this->link), @mysql_error($this->link));

    $obj = new SqlQueryResult($result_resource);

    if ($obj->RowCount() > 0)
    {
      // Return the first row of data results
      $result_array = @mysql_fetch_array($result_resource, MYSQL_ASSOC);

      if ($result_array)
      {
        while (list($key, $value) = each($result_array))
        {
          $obj->field[$key] = $value;
        }
      }
    }

    $time_end = explode (' ', microtime());
    $query_time = $time_end[1]+$time_end[0]-$time_start[1]-$time_start[0];
    $this->query_time += $time_end[1] + $time_end[0] - $time_start[1] - $time_start[0];
    $this->query_count++;

    return($obj);
  }

  public function QueryCount()
  {
    return $this->query_count;
  }

  public function QueryTime()
  {
    return $this->query_time;
  }

  private function _error($error_number, $error_text)
  {
    if ($error_number != 1141)
    {
      echo "Error #$error_number: $error_text";
      die();
    }
  }
}


class SqlQueryResult {

  public $field;

  private $result_resource;
  private $num_rows;
  private $current_row;

  function  __construct($result_resource)
  {
    $this->result_resource = $result_resource;
    $this->current_row = 0;
    $this->num_rows = @mysql_num_rows($this->result_resource);
    $this->field = array();
  }

  public function NextRow()
  {
    if ($this->current_row === 0)
    {
      // Row already fetched from SqlQuery() function
      // Do nothing
    }
    else if ($this->num_rows > 0 AND $result_array = @mysql_fetch_array($this->result_resource, MYSQL_ASSOC))
    {
      // This is the next iteration and there is a counted row returned
      // Grab data array
      if ($result_array)
      {
        while (list($key, $value) = each($result_array))
        {
          $this->field[$key] = $value;
        }
      }
    }
    else
    {
      // No more rows, end of data iteration
      // End result
      return false;
    }

    $this->current_row++;

    return true;
  }

  public function RowCount()
  {
    return $this->num_rows;
  }
}

Sunday, September 27, 2015

Anagram and Rhyme Generator

I had some fun today with Anagram Generator and Rhyme Generator. For those who are unfamiliar with these, anagrams are rearrangements of the letters in a word. And of course, the rhyme tool is very useful if you want to do poetry.

Saturday, September 26, 2015

Allow PHP in Posts and preg_match

Allow PHP in Posts is a very cool plugin when you need to execute PHP in your posts, but you need a little time to get used to it, because it is kind of tricky. For instance I did not manage to use the preg_match function with square brackets. It simply replaces [a-z] with <a-z>. The only fix I could find is to use Code Snippets and add all the preg_match parts there, then use Shortcodes like [php function=5].

Also don't forget about [PHP debug=1] option which can be really useful.

Monday, September 21, 2015

remove accents and diacritics from a string in PHP

I needed to remove some diacritics from a text and the easiest way I've found is this:
$newstring = iconv('UTF-8', 'US-ASCII//TRANSLIT', $original_string);

Monday, August 24, 2015

EU ruins the beauty of Internet with cookie control and data protection

Some EU laws are getting ridiculous. Look how many websites have this stupid cookie warning, but only the legitimate ones, the bad guys don't give a f* about this. And the data protection directive is so vague that it will only serve for abusive actions.

Friday, August 21, 2015

WPMU: You do not have sufficient permissions to access this page.

While moving, a blog from WPMU to a single wordpress, I kept getting this message: "You do not have sufficient permissions to access this page." I have played for about an hour with wp_usermeta and wp_users. Tested all kinds of settings in wp_capabilities and wp_user_level but still nothing worked. Then I have spotted it in wp_options. The option_name wp_user_roles was missing and instead was something like wp_123_user_roles. After I renamed it, all worked like a charm.

Sunday, July 26, 2015

your personal website archive

While archive.org is the biggest online website archive - you have no control over it. If you want something that archives on command, you can use archive.is . It takes a "snapshot" of a webpage that will always be online even if the original page disappears. You can use it for your own sites or for other sites you like visiting. This way, you'll be able to see them even if they turn off or get suspended.

I found a firefly in my yard

It seems to be a larvae and every night I find her in the same place. After looking around in the vicinity I have found a few more. But this is the first year they appeared, I have no idea why or where they came from. Anyway, it's very nice to have them around.

Saturday, July 25, 2015

Top 5 automatic watches brands considering price and quality

After reading tons of online materials and testing over a hundred watches, I will summarize here a top of the best watches in terms of quality and price. Please be aware that the top will not include Chinese cheapies and it will not include snob watches.



  1. Seiko - By far, this is the winner. You can find on Amazon a brand new Seiko 5 for $56. They are reliable watches and you simply cannot get better quality for this money. 
  2. Orient - Plenty of models, good prices and decent movements. You can choose from sports or dressy designs and lately even military inspired. You can find nice and reliable models around $100.
  3. Tissot  - Most of their automatic models are using 2824-2 ETA movement. This movement has everything you need: manual winding option, hacking, excellent accuracy and fine tuning adjustments. However, the price is much higher than on any other brand discussed here, you'll need to spend around $500.
  4. Citizen - Their automatic watches come with Miyota movements. You simply cannot go wrong with these movements, there are people reporting 15+ years without any service and still going well.
  5. Vostok - Vostok has the Amphibia line, which to some people may appear rugged and old, but personally I like these watches very much. 200 meters water resistance comes as standard, nice plexiglass and very original appearance.

Friday, July 24, 2015

Baby birds I found today (Red backed shrikes - Lanius collurio)



I have found this nest today. I'm not sure what species of bird is it, I'll have to spy for their parents. I'm very concerned a cat might notice this, because it's very close to the ground.


[UPDATE]: After only a dozen of minutes, the parents came to feed them, so here they are:





It seems they are Red backed shrikes (Lanius collurio).

Friday, June 26, 2015

how to make eggdrop identify to nickserv automatically

I did a google search and this was not very well covered. It's understandable, eggdrops are less and less popular nowadays.
The solution is very simple, you don't need extra tcl scripts or anything, just add this line to the .conf:

set init-server { putserv "privmsg nickserv :IDENTIFY nickname password" }


Tuesday, June 02, 2015

Monday, May 25, 2015

Have fun with a simple "Game of Thrones" social activity



The game is very simple. You need some papers, pens and a couple of friends who are familiar with Game of Thrones. Give each a paper+pen and ask them to write the names of everyone in the group, including themselves.

Then for each name, they should associate a Game of Thrones character. It should be done based on personality rather than physical aspect.

To avoid upsets, it may be a good idea if everyone writes with capital letters, making it harder to identify the author. But remember it's only a game and take it easy even if you were associated with "Reek" or "Shae".

After the game you may learn a lot about you as a person. Do you see yourself the same way as your friends do? Do they see you all in the same way or each in his own way?



The most efficient and simple homemade wasp trap

There are many guides to teach you how to build wasp traps from plastic bottles. After trying out everything, I realised the key is in the lure and not in the way you build the trap. And the most efficient is radler beer! Yes, you can simply put 1/4 of a jar with radler and it will catch more wasps then any other honey or vinegar trap.

Thursday, May 21, 2015

spammed while my Paypal account was hacked

So I woke up one normal day and checked my email. I was surprised to see thousands of new emails all spam. Like almost everyone, I get daily spam, but decently, like around thirty emails.

I had no idea what this is was all about, but it definitely looked odd.
Most of these emails were already in the bulk folder, but I like to double check, because legitimate stuff gets there occasionally.

So I start scrolling...
And after fifteen minutes, I've spotted something like "You have added a new credit card to your account". All of a sudden, I realised what was happening and I rushed to login into my Paypal. Surprise, surprise, some a few hundreds were missing as withdrawal on that new credit card.

Fortunately, I've reacted in time and Paypal was able to reverse the process so I got my cash back. Then they also helped with some logs and I've managed to investigate and find out how all this was possible:

Many years ago I have used on a forum the same email and password for creating an account. Yes, I know it was stupid, but I think that was even before having a Paypal account. Now it seems like someone hacked that forum(or maybe the admin/owner shared it on purpose who knows) and tried all those user/pass pairs on Paypal website. And at least on mine, it worked! So they wanted to grab quickly some cash, and they added their credit card. Then they spammed me. But the spammed itself triggered my alertness so I don't know if it was such a smart move.

Wednesday, May 20, 2015

Educative and fun games you can play with your five years old child


Mini Market
Buy some new little figurines and sweets. Don't use something that your child is familiar with, because she might not be interested. "New" is the key. Take a small table and put them on like an ambulant store, with a price tag for each object. Then give some coins to the child and teach him how to buy. Depending on his age and his interest for maths, you can use simple pricing first, like candy = 2 coins. Later you can use real pricing like candy = 14 cents.
Let her have limited money or limit the objects she can buy each day. This way she will have to decide what to spend the cash on and will also show you more about her temperament.

What's in the hat?
Take a winter hat and hide in some small object your child is familiar with. It can be figurine, coin, barrette, dice, spoon and so on. Without looking, by using only the touch, ask her to insert the hand in the hat and identify the object. First she will be very tempted to look, so be careful. Help and give hints when she cannot guess. Repeat with different objects or make her hide something for you. It's a great game for both fun and imagination development.
 
Hot/cold hidden object
Hide an object somewhere in the house. The child should be in another room or blindfold. Then ask her to find the object. Whenever she gets closer to the location where it's hidden, give her hints like "warm", "hot", "very hot" - depending on how close she is - "very hot" = you almost found it. When she is far or moves away, tell "cold".
After the object was found, change roles and make her guide you this time.

Enjoy! And remember that your enthusiasm is sometimes the key to make the child interested in the game.

Sunday, May 17, 2015

How to protect yourself against keyloggers?

A keylogger will record everything you type so whoever installed it will know all your emails, conversations, logins, passwords and so on. Therefore if someone wants to spy on you, a keylogger is the first choice.

So you need to protect yourself and you are probably thinking of an anti-virus. But it is not enough and you should not rely on it! Even if you are 100% that your operating system is clean, there may be hardware keyloggers installed which could be impossible to detect. Don't panic, you have a few solutions:
  1. You can use a virtual keyboard such as http://www.lakefolks.org/cnt/. It is a Click-N-Type keyboard designed for anyone with a disability, but it can be used against keyloggers, simply by clicking keys with the mouse whenever you have to write sensitive information such as passwords. Yes, it will be hard to write an email like this.

  2. If you are familiar with Linux, you should make a copy of Knoppix(Knoppix is a bootable Live system on CD/DVD). Boot your computer with this and no matter how many keyloggers there are, you have your own read only operating system so you are safe... unless there are hardware keyloggers for which you should use the previous solution.