How to start local ActiveMQ (build from source) on Ubuntu when the ActiveMQ package has previously been installed

This is the frustration of the day. I downloaded the ActiveMQ source and compiled it with no issues – however I could not start ActiveMQ (using ./activemq start) and the console output did not really explain what was wrong:
./activemq: 344: ./activemq: "/usr/bin/java" -Djava.util.logging.config.file=logging.properties -Djava.security.auth.login.config=/home/MY_USER/git/activemq/assembly/target/apache-activemq-5.12.1-SNAPSHOT//conf/login.config -Dactivemq.classpath="/home/MY_USER/git/activemq/assembly/target/apache-activemq-5.12.1-SNAPSHOT//conf:/home/MY_USER/git/activemq/assembly/target/apache-activemq-5.12.1-SNAPSHOT//lib/" -Dactivemq.home="/home/MY_USER/git/activemq/assembly/target/apache-activemq-5.12.1-SNAPSHOT/" -Dactivemq.base="/home/MY_USER/git/activemq/assembly/target/apache-activemq-5.12.1-SNAPSHOT/" -Dactivemq.conf="/home/MY_USER/git/activemq/assembly/target/apache-activemq-5.12.1-SNAPSHOT//conf" -Dactivemq.data="/home/MY_USER/git/activemq/assembly/target/apache-activemq-5.12.1-SNAPSHOT//data" -jar "/home/MY_USER/git/activemq/assembly/target/apache-activemq-5.12.1-SNAPSHOT//bin/activemq.jar" : not found

However, when running “./activemq” without any task parameter, then it gave me a hint:
Configuration of this script:
The configuration of this script is read from the following files:
/etc/default/activemq /home/MY_USER/.activemqrc /home/MY_USER/git/activemq/assembly/target/apache-activemq-5.12.1-SNAPSHOT//bin/env
This script searches for the files in the listed order and reads the first available file.

To my surprise, there was actually a file at “/etc/default/activemq” – this was a leftover from a previous ActiveMQ installation (Ubuntu package) – I had forgotten to use the –purge option when I removed the ActiveMQ package:
sudo apt-get remove activeMQ --purge

I ran the remove command again with the purge option and now I can start ActiveMQ with no problems 🙂

Add after body hook hack in wordpress (e.g. for Facebook Like button SDK) without modifying header.php

I wish to add the Facebook Like button to my wordpress – this requires that I add the following code right after <body<:
<div id="fb-root"></div><script>(function(d, s, id) {
...
}(document, 'script', 'facebook-jssdk'));</script>

My solution
Make a functions.php file in your child theme and add the following code (or append it to your main functions.php if you are silly enough to not use child themes). It abuses the body_class hook by finishing the <body< tag and then prints the actual content:
add_action('body_class','hook_after_body');

function hook_after_body()
{?>
<div id="fb-root"></div><script>(function(d, s, id) {
<script>(function(d, s, id) {
...
}(document, 'script', 'facebook-jssdk'));</script
<?}

Solutions that I don’t like

  • I could just override header.php in my (child)theme, but then my modifications will be lost, if I update my wordpress theme. Plus it makes it harder for me to know what code that I have changed.
  • I could also just use a plugin to get extra hooks, but I hate to install extra plugins because they makes me depend code from more on other people and the plugins can also be a security risk.


Fernando pointed out that this generates invalid HTML. While there are some ways of adding content after the body (http://wordpress.stackexchange.com/questions/73370/how-to-inject-content-after-body), I have decided to just use override header.php in my child theme – I had to do that anyway.

Installing Quake III Arena for Linux (especially x64 bit)

The original installer for Quake III Arena will not work on my Ubuntu 12.10 x64 – I have tried many solutions with no luck 🙁 However, Quake III Arena is opensource (except data such as music and graphics) now and some nice people have made a great installer (link) where we only need to add the non-opensource stuff (called pak0.pk3) from the quake 3 arena cd and then we have a fully functional Quake III Arena. This is not a weird Quake III Arena clone – it is the real thing – essentially just with a different installer. Here is what you do…

1. Download the engine and data files installers from link. You should get two files called something like:
ioquake3-1.36-7.1.i386.run and ioquake3-q3a-1.32-9.run
2. Open a terminal (press CTRL+ALT+T on Ubuntu) and navigate to the directory containing the installer files – use the “cd” (change directory) command – e.g. “cd Downloads” in Ubuntu to go to your Downloads folder.
3. Write “chmod +x ioquake3-1.36-7.1.i386.run” and “chmod +x ioquake3-q3a-1.32-9.run” to make it possible to execute the installers.
4. Install the engine by writing “./ioquake3-1.36-7.1.i386.run” and run through the wizard.
5. Copy the “pak0.pk3” file from the Quake III Arena CD to the baseq3 subfolder of the IOQuake3 install directory. On my computer I just copy “/media/<username>/Quake III Arena/Quake3/baseq3/PAK0.PK3” to “/home/<username>/ioquake/baseq3/PAK0.PK3”. You can copy the files using the “cp” command in the terminal or use the File Manager Nautilus on Ubuntu (start it by writing “nautilus&“).
6. Install the game files by writing “./ioquake3-q3a-1.32-9.run” and run through the wizard.
7. Run the game by writing “./ioquake3” from the IOQuake3 install directory – happy fragging 🙂

Please let me know if this guide was helpful or if you have any questions.

MySQL/PHP character encoding errors (e.g. æ,ø,å) – import, connection, table encoding and html meta header

Today I’ve got four hints that usually solves the character encoding errors I encounter with MySQL and PHP (usually triggered by the special Danish vowels æ,ø,å):

  • PhpMyAdmin import: use the official import function rather than executing crude sql inserts – because then you can specify the character encoding instead of using the default one which is NOT UTF-8.
  • Set encoding for PHP-MySQL connection: Here is an example:
    $conn = mysql_connect('localhost', 'mysql_user', 'mysql_password');
    mysql_set_charset('utf8',$conn);

    Link to php.net reference.

    If you use the (much better) PDO db access layer, then you can just add an argument to the connection call:
    $conn = new PDO('mysql:host=' . $hostname . ';dbname=' . $dbname, $username, $password, array(PDO::MYSQL_ATTR_INIT_COMMAND => "SET NAMES utf8"));

  • Make sure that the MySQL database and tables are UTF-8 encoded: Use the following SQL-commands:
    ALTER DATABASE db_name
    CHARACTER SET utf8
    DEFAULT CHARACTER SET utf8
    COLLATE utf8_general_ci
    DEFAULT COLLATE utf8_general_ci;

    ALTER TABLE tbl_name
    DEFAULT CHARACTER SET utf8
    COLLATE utf8_general_ci;

  • (x)HTML meta header character encoding: add this in the head section of the HTML code:
    <meta http-equiv="Content-type" value="text/html; charset=UTF-8" />

If you have got a question or more tips then please post it below, then I will update my post 🙂

False Science: The Comparative Anatomy of Eating by M.D. Milton R. Mills

I am not an expert on the topics “diets”, “anatomy” and “evolution” – but still I know how real science works and hence I can discard false science such as the article “The Comparative Anatomy of Eating” by M.D. Milton R. Mills. Creationists (Intelligent Design) have also created many such articles that claims to be scientific research – but real scientists can easily spot that they are wrong. There is no scientific evidence to support the hypothesis “human are herbivores”, so please stop corrupting the real science by spreading false science such as the article by M.D. Milton R. Mills. That is just vegan propaganda:

  1. No recognised scientific institution has published the article into e.g. a scientific journal – i.e. no significant body of experts believes that it is correct.
  2. As the article is not published in a scientific journal, no one has spent time to do a proper scientific peer review on it. In other words: no group of scientists has thoroughly checked whether it’s claims are justified.
  3. There are no references to existing publications and no are experiments conducted – i.e. it is neither based on existing research nor on creating new research. So there is no evidence to prove its claims.

This alone should be enough to stop believing that the article is science.

However, if we really need more dirty details, then a background check on the author reveals that: 1) he is not an expert on the topic and 2) he is biased by being involved with pro-vegetarian organisations.
1) The author is M.D. (from Stanford University link), but that only makes him a doctor, not an expert on this particular topic. I have tried to look for research conducted by him, but neither Google, Google Scholar nor PubMed yielded any relevant results. (Only pubMed actually had an article from him and that was not relevant: PubMed publication) Without having published any relevant research on the topic, M.D. Milton R. Mills is not an expert on the topic – in fact he just works as an outpatient doctor. He is just as much an expert on this topic as an average physics teacher is an expert on Quantum Physics without having published scientific articles on that topic.
2) He is involved in multiple vegetarian propaganda organisations:
Speaking at NY Vegetarian Expo
Advisor for Mid-Hudson Vegetarian Society
Member of Physicians Committee for Responsible Medicine (PCRM), which has strong connections with PETA: PCRM and PETA
Speaking at Healthy Lifestyle Expo 2007 with many comments about animals even though he is just a doctor which deals with human.

The “background check” section was rewritten to reflect feedback from comments, thank you.

Java UML Generator plugin for Eclipse

Yet another brilliant Eclipse plugin: http://www.objectaid.com

Create a Diagram and then drag the wanted files onto it.

Remember to save as a JPG instead of GIF because some text is missing when using GIF.

I recommend the following disabling:

  • Disable package (for smaller projects)
  • attribute defaults (default values)
  • icons (remove eclipse symbols and use normal UML)
  • dependencies/add relationsships/labels/nesting