Ubuntu 16.04 Install Nvidia Drivers

Quick guide on how to install nvidia drivers on Ubuntu 16.04 (tested with 16.04 and 16.04.1 installs with a GTX 1070 and Intel HD Graphics 530 integrated graphics).

  • Disable PCI graphics in the bios or switch to automatic
  • Shutdown and plug in the display output to integrated graphics
  • Boot and install via normal usb ubuntu installer
  • After installation reboot
  • Run update system software via terminal
sudo apt-get update && sudo apt-get upgrade
  • Reboot system
  • Switch to tty1 by ctl-alt-f1 and login
  • Stop x
sudo /etc/init.d/lightdm stop
  • Remove the default nouveau drivers [1]:
sudo apt-get --purge remove xserver-xorg-video-nouveau
  • Add nvidia ppa and install correct driver version replacing nvidia-367 with whatever version you’d like
sudo add-apt-repository ppa:graphics-drivers/ppa
sudo apt-get update
sudo apt-get install nvidia-367
sudo nvidia-xconfig
  • Reboot and enable the PCI graphics back in the bios
  • Shutdown and switch display output back to the graphics card

Special notes about full disk encryption [2],[3],[4],[5]

  1. After reboot, only see a purple screen
  2. After reboot, only see a black screen
  3. Might see the decrypt splash but the keyboard is unresponsive

I had best results editing the grub config with the following via recovery mode

  • Reboot and hold down shift while booting to bring up the grub menu
  • Select advanced options for ubuntu and select ubuntu with recovery mode
  • Add networking to get the file system in read/write
  • Then add root and press enter for maintenance mode
  • Edit file /etc/default/grub with your favorite editor
  • Edit line to: GRUB_CMDLINE_LINUX_DEFAULT="quiet nosplash noplymouth"
  • Add line: GRUB_GFXPAYLOAD_LINUX=keep
  • Add line: GRUB_GFXMODE=2560x1440
  • Then update grub and reboot
update-grub
reboot

Completed grub file looking simpler to:

# /etc/default/grub
# If you change this file, run 'update-grub' afterwards to update
# /boot/grub/grub.cfg.
# For full documentation of the options in this file, see:
#   info -f grub -n 'Simple configuration'

GRUB_DEFAULT=0
GRUB_HIDDEN_TIMEOUT=0
GRUB_HIDDEN_TIMEOUT_QUIET=true
GRUB_TIMEOUT=10
GRUB_DISTRIBUTOR=`lsb_release -i -s 2> /dev/null || echo Debian`
GRUB_CMDLINE_LINUX_DEFAULT="quiet nosplash noplymouth"
GRUB_CMDLINE_LINUX=""
GRUB_GFXPAYLOAD_LINUX=keep

# Uncomment to enable BadRAM filtering, modify to suit your needs
# This works with Linux (no patch required) and with any kernel that obtains
# the memory map information from GRUB (GNU Mach, kernel of FreeBSD ...)
#GRUB_BADRAM="0x01234567,0xfefefefe,0x89abcdef,0xefefefef"

# Uncomment to disable graphical terminal (grub-pc only)
#GRUB_TERMINAL=console

# The resolution used on graphical terminal
# note that you can use only modes which your graphic card supports via VBE
# you can see them in real GRUB with the command `vbeinfo'
GRUB_GFXMODE=2560x1440

# Uncomment if you don't want GRUB to pass "root=UUID=xxx" parameter to Linux
#GRUB_DISABLE_LINUX_UUID=true

# Uncomment to disable generation of recovery mode menu entries
#GRUB_DISABLE_RECOVERY="true"

# Uncomment to get a beep at grub start
#GRUB_INIT_TUNE="480 440 1"

[1] https://help.ubuntu.com/community/BinaryDriverHowto/Nvidia#RemovingNouveau.28advanced.2Fexpert_users.29

[2] http://askubuntu.com/questions/689064/cant-enter-password-for-luks-disk-encryption-after-nvidia-drivers-installed

[3] https://bugs.launchpad.net/ubuntu/+source/linux/+bug/1359689/comments/73

[4] https://bugs.launchpad.net/ubuntu/+source/plymouth/+bug/1386005/comments/72

[5] http://askubuntu.com/questions/362722/how-to-fix-plymouth-splash-screen-in-all-ubuntu-releases

Auditing in Spring Data JPA JavaConfig

In addition to the reference documentation of spring data jpa auditing. This is my interpretation of how to implement auditing and auditor aware in spring applications using JavaConfig. Please note that this requires having version 1.5.0.RELEASE or greater.

First, I created a base abstract class for entities which will hold definitions for created, last modified by and created, last modified by date. These can be described by using annotations @CreatedBy, @LastModifiedBy, @CreatedDate, and @LastModifiedDate. In this case I used joda time to define the type of date. The reference documentation also mentions adding AuditingEntityListener to the orm.xml file, however, if you wish to not include a xml file, you can add @EntityListeners(AuditingEntityListener.class) annotation to the abstract entity class. Here is an example:

@MappedSuperclass
@EntityListeners(AuditingEntityListener.class)
public abstract class AbstractEntity {

    @CreatedDate
    @NotNull
    @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    private DateTime createdDate = DateTime.now();

    @LastModifiedDate
    @NotNull
    @Type(type="org.jadira.usertype.dateandtime.joda.PersistentDateTime")
    private DateTime lastModifiedDate = DateTime.now();

    @CreatedBy
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn
    @NotNull
    private Account createdBy;

    @LastModifiedBy
    @ManyToOne(fetch = FetchType.LAZY)
    @JoinColumn
    @NotNull
    private Account lastModifiedBy;

    ...
}

For created by and last modified by to be filled in with spring security principal information you use the AuitorAware<T> interface. Here is an example calling the account service to gain access for the current account information. The @Component annotation was used so a bean definition did not need to be defined in the configuration class which was suggested in the reference documentation.

@Component
public class SpringSecurityAuditorAware implements AuditorAware<Account> {

    @Inject private AccountService service;

    @Override
    public Account getCurrentAuditor() {
        return service.getCurrentAccount();
    }

}
@Override
public Account getCurrentAccount() {
    SecurityContext securityContext = SecurityContextHolder.getContext();
    UserDetailsCustom springSecurityUser = (UserDetailsCustom) securityContext.getAuthentication().getPrincipal();
    return springSecurityUser.getAccount();
}

Finally, add the annotation @EnableJpaAuditing to have the configuration be loaded. Also be sure to add jadira.usertype.databaseZone to the hibernation configuration (in this case) to set the timezone for joda time.

@Configuration
@EnableJpaAuditing(auditorAwareRef = "springSecurityAuditorAware")
...
public class DataBaseConfig { }

Testing Implementation for Integration Tests

If you care about testing (and you should), here are some tips one getting auditing working with your integration tests. First, create a new component for a mock auditor aware class. This will allow for auditing without the need for spring security.

@Component
public class MockAuditorAware implements AuditorAware<Account> {

    private Account currentAuditor;

    @Override
    public Account getCurrentAuditor() { return currentAuditor; }
    public void setCurrentAuditor(Account account) {this.currentAuditor = account; }

}

Be sure to add the mock auditor aware reference in the test configuration class.

@Configuration
@EnableJpaAuditing(auditorAwareRef = "mockAuditorAware")
...
public class TestConfig { }

Finally, in a base integrations test class, you can add a before statement for setting the auditor for all your tests:

@PersistenceContext protected EntityManager em;
@Inject protected MockAuditorAware auditorAware;

@Before
public void wireUpAuditor() {
    auditorAware.setCurrentAuditor(em.getReference(Account.class, 1));
}

Ubuntu 12.10 Install Eclipse with Android

Reference for installing Eclipse in Ubuntu 12.10 with the intention of installing Android afterwards. If you are not intending to install Android you can leave out installing ia32-libs and the ADT plugin.

  1. Download Eclipse

  2. Install requirements:

    # openjdk is for java
    # ia32-libs is the 32-bits libs for Android (only needed for 64-bit)
    sudo apt-get install openjdk-7-jdk ia32-libs
    
  3. Extract the eclipse tar:

    tar -xzf eclipse.tar.gz
    
  4. Move folder into opt directory:

    sudo mv eclipse /opt/
    
  5. Create the desktop profile for unity:

    sudo gedit /usr/share/applications/eclipse.desktop
    # Enter the below text:
    #######################
    [Desktop Entry]
    Name=Eclipse
    Type=Application
    Exec=/opt/eclipse/eclipse
    Terminal=false
    Icon=/opt/eclipse/icon.xpm
    Comment=Integrated Development Environment
    NoDisplay=false
    Categories=Development;IDE
    Name[en]=eclipse.desktop
    
  6. Create a symbolic link in your bin folder:

    sudo ln -s /opt/eclipse/eclipse /usr/local/bin/eclipse
    
  7. Clean launch eclipse for the first time:

    /opt/eclipse/eclipse -clean &
    
  8. Install ADT Plugin (Help -> Install New Software):

    https://dl-ssl.google.com/android/eclipse/
    

Compile SVN for OSX

This reference will describe how to install SVN with support for http/https URLS for OSX. This has only been tested in Mountain Lion. This was done to counter “E170000: Unrecognized URL scheme for http*” and from installing SVN through Xcode.

  1. Download needed source files, and untar each of them: SVN from Apache, and Neon to support http and https urls.

  2. Install neon: Make sure that neon is installed to /usr/local/ by default

    cd neon
    ./configure --with-ssl
    make
    sudo make install
    
  3. Install svn:

    cd subversion
    ./configure --with-ssl -with-neon=/usr/local/
    make
    sudo make install
    
  4. Check to see if the installation worked correctly

    svn --version
    

    This is the response you should be looking for:

svn, version 1.7.8 (r1419691)
   compiled Jan 10 2013, 14:40:15

Copyright (C) 2012 The Apache Software Foundation.
This software consists of contributions made by many people; see the NOTICE
file for more information.
Subversion is open source software, see http://subversion.apache.org/

The following repository access (RA) modules are available:

* ra_neon : Module for accessing a repository via WebDAV protocol using Neon.
  - handles 'http' scheme
  - handles 'https' scheme
* ra_svn : Module for accessing a repository using the svn network protocol.
  - with Cyrus SASL authentication
  - handles 'svn' scheme
* ra_local : Module for accessing a repository on local disk.
  - handles 'file' scheme

Setup Arch on Raspberry Pi

This is a basic tutorial running through the steps for partitioning, updating, and installing xfce4 on the Raspberry Pi. Note: This is assuming you already have made the SD card and have booted up, and are logged in as root.

1) Resize Partition

The reason why you need to resize the partition is that you want to match it to the size of the SD card.

  • fdisk \/dev\/mmcblk0
  • p [enter]
  • Note the first number on the second line
  • d [enter]
  • 2 [enter]
  • n [enter]
  • p [enter]
  • 2 [enter]
  • Enter the number that you noted [enter]
  • Select largest number of last sector aka [enter]
  • w [enter]
  • q [enter]
  • reboot
  • resize2fs \/dev\/mmcblk0p2

2) Update the system

pacman -Sy pacman
pacman-key --init
pacman -S archlinux-keyring
pacman-key --populate archlinux
pacman -Syu --ignore filesystem
pacman -S filesystem --force

3) Install X Server (xorg)

pacman -S xorg-server xorg-xinit xorg-server-utils

4) Install Video Divers for Pi

pacman -S mesa xf86-video-fbdev xf86-video-vesa

5) Install xfce4

pacman -S xfce4

6) Start x-session with xfce

startxfce4

Optional:

I think the fonts are terrible with the stock install so, I also installed a set of TrueType fonts:

pacman -S ttf-dejavu