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 πŸ™‚

Getting wireless to stop disconnecting on HP ProBook 430 G2 on Ubuntu 14.04 (Linux)

The default wireless driver settings for the HP ProBook 430 G2 on Ubuntu Linux 14.04 makes the internet connection drop frequently and the wireless connection first works again when the machine has been rebooted (or the wireless netcard driver has been removed and added again). The solution is to change the driver settings (disable e.g. power save mode) – here is a guide for your convenience and such that I don’t forget how to do it πŸ™‚

This guide is only made for “HP ProBook 430 G2”. It might work for other computers, but the wireless netcard driver probably has a different name and different settings. Please tell me if you get it to work for other models πŸ™‚

1. Find the wireless netcard model – open a terminal using CTRL+ALT+T and write the following command:
ls /sys/class/net/wlan0/device/driver/module/drivers

Mine says “pci:rtl8723be”, where “rtl8723be” is the driver name. If you have a different driver, then you need to replace “rtl8723be” in the rest of this guide with whatever your terminal outputs after the colon (pci:).

Now we need to check the driver settings – this requires the program sysutils that is not installed by default – try to write the following command in the terminal:
sudo apt-get install sysfsutils

Write the following command in the terminal to get the current driver settings (replace “rtl8723be” if you use a different driver):
systool -v -m rtl8723be

In the “Parameters:” section, there should be a number of settings. Look at the value that is written next to the power save settings “fwlps” and “ips” – if it says “Y” or “1” then that is probably the reason why your internet connection gets disrupted.

You can see what the two settings means by writing the following in the terminal (replace “rtl8723be” if you use a different driver):
modinfo rtl8723be

Disable power save by writing the following in a terminal (replace “rtl8723be” if you use a different driver):
echo 'options rtl8723be ips=0' | sudo tee -a /etc/modprobe.d/rtl8723be.conf
echo 'options rtl8723be fwlps=0' | sudo tee -a /etc/modprobe.d/rtl8723be.conf

Remove and add the wireless netcard driver by writing this in a terminal (replace “rtl8723be” if you use a different driver):
sudo rmmod rtl8723be && sudo modprobe rtl8723be

Verify the new settings by once again writing this in a terminal (replace “rtl8723be” if you use a different driver):
systool -v -m rtl8723be

In the “Parameters:” section, “fwlps” and “ips” should now be “N” and your internet connection should stop crashing. Feel free to post a comment πŸ™‚

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.

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.

Install Tex Live 2011 on Ubuntu 12.04

The default Tex Live package in Ubuntu 12.04 is very outdated (version 2009) which is bad because it does not contain e.g. the paralist package that is great for making compact lists. This is easy to fix, just install the newest Tex Live directly from the source (Tex Live 2011 @ Tex Users Group) – it is actually really easy and it does not conflict with the Ubuntu Tex Live 2009 package. Below is a guide on how to install it – I got much inspiration from Quick Install Guide by the Tex Users Group.

Prerequisites
Make sure that you have got Perl installed. (Ubuntu should have this already) You can check it by opening a terminal (shortcut: “CTRL+ALT+T“) and write “man perl” which should open up the Perl Interpreter manual page (which you can quit by pressing “q“) – if there is no manual entry then you should be able to install perl by writing “sudo apt-get install perl“.

Also make sure that you have a stable internet connection and sufficient amount of available space, because you gotta download minimum 3.1 GB of Tex Live program data.

Download and installation
1. Download the installation archieve (Tex User Group Tex Live 2011 Download) and unzip it somewhere in your home folder.

2. Open a terminal (shortcut: “CTRL+ALT+T“) and navigate into the unzipped folder that starts with “install-tl” using the “cd” command.

3. Now we gotta start the installation. The default setting is to install Tex Live at the location “/usr/local/texlive” and that should not be a problem unless you have made a separate system partition (the one that contains the “/usr” folder) that is not big enough to contain minimum 3.1 GB data from Tex Live. – that was the case for me πŸ™ (I use separate “/home” and “/” partitions to enable easier clean Ubuntu upgrades.)

3a) If you have plenty of space on the system partition then you can just install by writing “sudo ./install-tl”. (“sudo” has to be used because a normal user does not have permissions to change stuff in the “/usr” folder.

3b) Else you can specify the installation path of Tex Live by using the following command instead (replace “/home/USER_NAME/texlive” by what “/path/to/folder” you want, but remember “sudo” in front if you install outside of the “/home” folder): “TEXLIVE_INSTALL_PREFIX=/home/USER_NAME/texlive ./install-tl

If there are no warnings, then press “I” to start the download and installation. Now the Tex Live installation program will automatically download and install 3.1 GB of data – it will take quite a while.

Important post-installation (setup “PATH” environment variable)
Once the installation is complete, you must setup the “PATH” environment variable so the terminal knows where the Tex Live binary programs are located – e.g. when you run “latex fileName.tex” or “pdflatex fileName.tex” in the terminal then the terminal uses the “PATH” environment variable to find the “latex” and “pdflatex” programs.

Navigate using the “cd” command to the folder where you installed Tex Live. (The default folder is once again: “/usr/local/texlive“) Then continue navigating further down into the “2011/bin/” folders and finally navigate down into a folder with a platform dependent name (it is named “x86_64-linux” at my computer, but e.g. “i386-linux” on a different architectures). If you write the command “ls | grep ^pdflatex“, then it should find the “pdflatex” program and hence you have found the correct folder for the PATH environment variable.

Now write “pwd” to get the current folder path – on my computer that is “/home/USER_NAME/texlive/2011/bin/x86_64-linux“. Copy the path, lets call it “TEX_LIVE_BIN_PATH“.

Finally, you need to modify the “.profile” file (in other distributions than Ubuntu it might be “.bash_profile“) in your home directory by writing “gedit ~/.profile“. Add the following at the end of the file (replace “TEX_LIVE_BIN_PATH” by the path from the “pwd” command) and save: “PATH="TEX_LIVE_BIN_PATH:$PATH"” (The “.profile” file will be run every time you login, which will ensure that the “PATH” environment variable always contains the Tex Live path.)

Close the terminal, logout, login and now Tex Live 2011 should work.

Test
Start a new terminal (shortcut: “CTRL+ALT+T“), now if you write “echo $PATH” then the output will contain your “TEX_LIVE_BIN_PATH“-path, otherwise something went wrong in saving it in the “.profile” file (or “.bash_profile” for other than Ubuntu).

Finally, run this command to check that latex works as intended: “latex small2e” The output should start with something like “This is pdfTeX, Version 3.1415926-2.3-1.40.12 (TeX Live 2011)“, where the important bit is that the bracket should say (“Tex Live 2011“) and not e.g. (“Tex Live 2009“) – if the latter is the case, then either you have not setup the “PATH” environment variable correct or the Tex Live 2011 installation failed.

Install HP LaserJet M1132 MFP printer for Ubuntu 12.04

With Ubuntu 12.04, HP LaserJet M1132 MFP Printer/Scanner almost works out of the box – the device is detected correctly but HP-setup must be run to enable printing/scanning. Here is what you gotta do:

(if you are looking for a guide on how to use the built-in scanner, then I have also made a guide for that here: LINK)

INSTALLATION:
1. Make sure that the HP LaserJet M1132 MFP is connected to the computer and power is turned on!
2. Open a terminal (pro-tip: press CTRL+ALT+T)
3. Run the following command in the terminal (pro-tip: paste the code into the terminal using CTRL+ALT+V, once you have copied the code from this website):
sudo hp-setup -i
4. Go through the setup process…
5. At some point, the program wants to download a proprietary binary file (hp-plugin) and that can take a couple of minutes to start downloading – be patient, it will start!
6. Once the setup has finished, printing should work without any problems…

Please write a comment if the guide works for you or if something does not work πŸ™‚

Scanning with HP LaserJet M1132 MFP for Ubuntu 12.04

I also just recently discovered that Ubuntu 12.04 actually supports scanning with the HP LaserJet M1132 MFP and that it is really easy to use – here is what you do:

(if you are looking for a guide on how to actually install the HP LaserJet M1132 MFP device, then I have also made a guide for that here: LINK)

SCANNING GUIDE:
1. Make sure that the HP LaserJet M1132 MFP is connected to the computer and power is turned on!
2. Open a terminal (pro-tip: press CTRL+ALT+T)
3. Run the following command in the terminal (pro-tip: paste the code into the terminal using CTRL+ALT+V, once you have copied the code from this website):
hp-scan
(don’t worry about the following warning: “warning: No destinations specified. Adding ‘file’ destination by default.“, it just means that the resulting scanned JPG file will be saved in your home directory.)
4. Put whatever you want to scan inside the HP LaserJet M1132 MFP scanning area, facing downwards.
5. Then click the physical scan-button on the HP LaserJet M1132 MFP device – you can see the button on the following image:
HP LaserJet M1132 MFP Scan button
6. Now wait while the terminal receives the scanned image – once that is complete then you can find the scan result as an image file (“hpscan001.png”) in your home directory.

Please write a comment if the guide works for you or if something does not work πŸ™‚

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 πŸ™‚

Gnome Nautilus bookmarks/favorites backup (in Ubuntu)

Nautilus (default file manager in Ubuntu) saves bookmarks/favorites in the following file in the home folder:
~/.gtk-bookmarks or home/YOUR_USERNAME/.gtk-bookmarks

You might need to make hidden files (those that starts with a .) visible by pressing CTRL+H in Nautilus in order to find the file.

Just copy the file to another location to make a backup of it πŸ™‚

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.