Ubuntu 18.04 has a nice GNOME GUI for VPN, but it still takes a little effort to get it fully working. Here is what I did:

I connect to a VPN that is based on Cisco AnyConnect, which means that I must use OpenConnect and that is not installed by default. Fortunately, Ubuntu has some useful documentation (https://help.ubuntu.com/community/NetworkManager) that points out which packages to install. I used the following commands to install OpenConnect for Network Manager:

Give the VPN a sensible name, write the URL to the VPN in the “Gateway” field and leave the rest as default. This is sufficient in my case.

Now you can turn the VPN “on” by clicking “off” in “Settings” -> “Network”.

However, when the VPN is turned on, it fails to use the DNS from the VPN which means that I cannot access the internal websites behind the VPN unless I know the IP-adresses. I have tried many different solutions that didn’t work until I found something useful (https://bugs.launchpad.net/ubuntu/+source/network-manager/+bug/1688018). Do the following:

I have tried countless guides on how to install the driver for “HP LaserJet M1132 MFP” on Windows 10. It worked perfectly on Windows 8 and it also works on my laptop with Windows 10 but not my desktop computer with Windows 10. The driver installation just stops after extracting archive is complete, but the actual installation never continues. Windows 10 also tries to install the driver using HP Smart, but that does not work either.

However, I found a solution that worked for me:

Unplug the USB cable to the printer (otherwise windows 10 will keep trying to install the printer driver using HP Smart)

Remove any existing HP-driver for the printer and HP Smart (if Windows 10 installed that already)

Wait for the extraction dialog to complete and then nothing happens. (It should probably have started the installation, but that seems to fail)

Then go to “%userprofile%\AppData\Local\Temp\” (i.e. “C:\Users\<YOUR_USERNAME>\AppData\Local\Temp\”) and locate the latest modified folder which contains HpSetup.exe and run that file. Now the driver will be installed and it works!

Do let me know if it works for you as well or if you have any issues with it 🙂

When coding Groovy, @CompileStatic can help to spot errors and improve performance of production code. Unfortunately, @CompileStatic is optional and hence easy to forget, but thankfully Groovy has documented a way to make @CompileStatic for all production code: http://docs.groovy-lang.org/latest/html/documentation/#_static_compilation_by_default
(Test code is not affected, because it is nice with flexibility when testing.)

However, with Grails you really want to use @GrailsCompileStatic instead of @CompileStatic, because it saves you from adding @CompileDynamic all the places that dynamic Grails functionality is used while still ensuring that your own code is @CompileStatic. Unfortunately, the above solution cannot be used for applying @GrailsCompileStatic to all production code. This is due to @GrailsCompileStatic is not available at the Compile Configuration and trying to @Grab it from grails-core only yields new dependency problems.

Eventually, I realised that @GrailsCompileStatic is just @CompileStatic with some extensions – those can be included in the Compile Configuration manually and then it works as expected.

// Extensions are copied from @GrailsCompileStatic due to that @GrailsCompileStatic is not available in the Compile Configuration
List extensions = ['org.grails.compiler.ValidateableTypeCheckingExtension',
'org.grails.compiler.HttpServletRequestTypeCheckingExtension',
'org.grails.compiler.WhereQueryTypeCheckingExtension',
'org.grails.compiler.DynamicFinderTypeCheckingExtension',
'org.grails.compiler.DomainMappingTypeCheckingExtension',
'org.grails.compiler.RelationshipManagementMethodTypeCheckingExtension']
ASTTransformationCustomizer grailsCompileStatic = new ASTTransformationCustomizer([extensions: extensions], CompileStatic)
configuration.addCompilationCustomizers(grailsCompileStatic)

At build.gradle, I also added the following:
compileGroovy.groovyOptions.configurationScript = file('src/groovyCompile/groovycConfig.groovy')

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 🙂

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 🙂

I wish to add the Facebook Like button to my wordpress – this requires that I add the following code right after <body&lt:<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');

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.

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.

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.

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.

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 🙂

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:
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 🙂