Wednesday, 29 July 2020

Android Studio - Required libraries for 64-bit machines

I am running Ubuntu 18.04 64-bit version. 

Need to install some 32-bit libraries for the emulator to work:

$ sudo apt-get install libc6:i386 libncurses5:i386 libstdc++6:i386 lib32z1 libbz2-1.0:i386

Tuesday, 14 March 2017

Installing VirtualBox on Ubuntu 16.10


The most simple way of installing VirtualBox is to use the command:
$ sudo apt-get install virtualbox
However, the version that comes with Ubuntu is fairly old. I decided to connect directly to www.virtualbox.org to get the latest version.
The following commands add virtualbox.org to the list of source repositories used by apt and installs the 5.1 version of VirtualBox.
Add the following line to your /etc/apt/sources.list:
deb http://download.virtualbox.org/virtualbox/debian yakkety contrib
The name yakkety is the name of the Ubuntu 16.10 distribution.
The following commands adds the repository key file so that will be treated as a trusted site. Then the VirtualBox 5.1 is installed. Since I already have dkms the installation should automatically be updated when the kernel is updated.
$ wget -q https://www.virtualbox.org/download/oracle_vbox_2016.asc
$ sudo apt-key add oracle_vbox_2016.asc
$ sudo apt-get update
$ sudo apt-get install virtualbox-5.1

Ready to go.

Saturday, 11 March 2017

Installing ASUS USB-AC56 (chip RTL8812AU) Driver on Linux (Ubuntu)

I have a ASUS USB-AC56 WI-FI Adapter that is based on RTL8812AU chipset.
The Ubuntu kernel did not recognize the adapter automatically, so I downloaded and installed the driver from www.asus.com. However, it did not work. The reason may be that I am using Ubuntu 16.10 (kernel 4.8) and the driver provided by Asus is said to support Linux kernel 2.6 ~ 3.18.

I searched and found a newer driver compiled by Diederik de Haas on GitHub. You find it here.

You need to have git and dkms installed before proceeding.

$ sudo apt-get install git
$ sudo apt-get install dkms
The installation is a 2 step process:

1. Download a copy of the driver from GitHub
2. Install it under /usr/src which is managed by dkms. Then it should automatically be compiled into the kernel whenever it is updated.

You download the source using "git clone" and follow the given instructions when standing in the downloaded directory

$ git clone https://github.com/diederikdehaas/rtl8812AU.git

Dynamic Kernel Module Support (DKMS) is a program/framework that enables generating Linux kernel modules whose sources generally reside outside the kernel source tree. The concept is to have DKMS modules automatically rebuilt when a new kernel is installed.
Install the dkms package like this:

$ sudo -s -H
# DRV_NAME=rtl8812AU
# DRV_VERSION=4.3.14
# mkdir /usr/src/${DRV_NAME}-${DRV_VERSION}
# git archive driver-${DRV_VERSION} | tar -x -C /usr/src/${DRV_NAME}-${DRV_VERSION}
# dkms add -m ${DRV_NAME} -v ${DRV_VERSION}
# dkms build -m ${DRV_NAME} -v ${DRV_VERSION}
# dkms install -m ${DRV_NAME} -v ${DRV_VERSION}
# exit
$

Note that in the following block of commands, the first thing I do is a sudo -s -H as I want to do all the commands as root (superuser).
Reboot the machine and check that the WI-FI adapter works.

Thursday, 10 December 2015

How to get Git using https:// instead of git://

The company network may have blocked the git:// protocol and a package manager like ngm may fail when attempting to update dependencies.

You can get Git to automatically use https:// instead of git:// in URL's.

git config --global url.https://.insteadOf git://

Monday, 9 November 2015

Installing POCO C++ Libraries on MacOS X

Current OS version is 10.11.1.
Current Xcode version is 7.1 (7B91b)

You need GNU make version 3.80 (or newer). On my Mac it is found as 


$ make --version
GNU Make 3.81
Copyright (C) 2006  Free Software Foundation, Inc.
This is free software; see the source for copying conditions.
There is NO warranty; not even for MERCHANTABILITY or FITNESS FOR A
PARTICULAR PURPOSE.

This program built for i386-apple-darwin11.3.0


I downloaded the current version of the libraries from pocoproject.org and moved it to a subdirectory under /Users/robert

$ gunzip poco-1.6.1.tar.gz
$ tar -xf poco-1.6.1.tar
$ cd poco-1.6.1
$ ./configure
$ make -s
$ sudo make -s install

Sunday, 8 November 2015

Installing C++ Boost libraries on MacOS X

This post describes installing Boost on iMac.

Current OS version is 10.11.1.
Current Xcode version is 7.1 (7B91b)

I already have Apple´s SDK Xcode installed. It is free and can be downloaded from App Store. To use it we have to read and accept their license terms, otherwise the bootstrap'ing fails later.

$ sudo xcodebuild -license

I wanted to install the include-files and libraries of boost to /usr/local. 

These are the steps I went through:


Download and unpack Boost from www.boost.org. Current release is Version 1.59.0. I moved the download file boost_1_59_0.tar.bz2 to a directory under my home directory /Users/robert. I will refer to it as /path/to/boost. I decided not to store the whole installation under /usr/local.

$ cd /path/to/boost
$ tar --bzip2 -xf ./boost_1_59_0.tar

To generate the build script issue the commands.

$ cd boost_1_59_0
$ ./bootstrap.sh --prefix=/usr/local


If the toolset darwin is not automatically detected, it may be due to lack of Xcode installation.
If successful you can now build the boost libraries using

$ ./b2 stage

I get a lot of compiler warnings about BOOST_DO_JOIN etc., but no errors at this time. This will build the libraries into subdirectory stage. If successful you can issue the following command to install into /usr/local which was specified using the --prefix option. Use sudo to allow for writing to /usr/local.

$ sudo ./b2 install


Tuesday, 21 October 2008

Accessing Session from a Grails Service

Grails makes the session object (instance of the Servlet API's HttpSession class) directly available in the Controllers and Tag Libraries.

Furthermore, the Grails implementation of HttpSession allows you to access the session as a Groovy map.

session.user = "Robert"

will store a user name in the session's attribute list.

I wanted to encapsulate session data in a service and avoid defining session properties many places.

However, the session is not directly available in a Grails Service. So if you want to access the session from a Service, you do it via the RequestContextHolder class (part of the Spring framework).

Here is simple Service that does exactly this:

import javax.servlet.http.HttpSession
import org.springframework.web.context.request.RequestContextHolder

class SessionStorageService {

static transactional = false
static scope = "singleton"

def setUser(User user) {
getSession().user = user
}

def getUser() {
getSession().user
}

private HttpSession getSession() {
return RequestContextHolder.currentRequestAttributes().getSession()
}
}

This service is made available in Controllers by automatic dependency injection by placing a property in the controller with the name sessionStorageService:

class BaseController {
def sessionStorageService
...
sessionStorageService.setUser("Robert")
...
}
Any comments or suggestions are appreciated .