PostgreSQL and PostGIS on Ubuntu 15.10

These are my install notes for PostgreSQL 9.5:
In this scenario I assume you do not have PostgreSQL installed and that you are going to install PostgreSQL with the PostGIS extentions on a server with no GUI. We are going to install directly from the apt repository provided by postgresql.org. I plan to use this database in conjunction with my WildFly server. My install notes for setting up Wildfly 10.0.0.Final can be found here: https://gesker.wordpress.com/2016/02/09/wildfly-10-on-ubuntu-15-10/

On the server…

Elevate to root:
sudo -s

Add apt.postgresql.org to you apt repository lists:
sh -c 'echo "deb http://apt.postgresql.org/pub/repos/apt/ $(lsb_release -cs)-pgdg main" > /etc/apt/sources.list.d/pgdg.list'

Install base packages:
aptitude update
aptitude install --with-recommends wget ca-certificates
wget --quiet -O - https://www.postgresql.org/media/keys/ACCC4CF8.asc | sudo apt-key add -
aptitude dist-upgrade
aptitude install --with-recommends postgresql-9.5 postgresql-contrib-9.5 postgis postgresql-9.5-postgis-2.2

Become user postgres:
su postgres

Add user/role to the database system:
createuser -s -P wildfly <– You will be prompted for a password. Remember your credentials. User will be a SUPERUSER in this case.

Add a database with the user wildfly (from above) as the owner:
createdb -O wildfly -E UTF8 wildflyDb

On your workstation…

Launch PgAdmin3 and connect using the credentials you setup above. Run the following against the wildflyDb to enable the PostGIS extentions:

CREATE EXTENSION IF NOT EXISTS postgis;
CREATE EXTENSION IF NOT EXISTS postgis_topology;
CREATE EXTENSION IF NOT EXISTS fuzzystrmatch;
CREATE EXTENSION IF NOT EXISTS address_standardizer;
CREATE EXTENSION IF NOT EXISTS address_standardizer_data_us;
CREATE EXTENSION IF NOT EXISTS postgis_tiger_geocoder;

Enable a couple more extentions that are very useful:
CREATE EXTENSION IF NOT EXISTS btree_gist;
CREATE EXTENSION IF NOT EXISTS pgcrypto;

WildFly 10 on Ubuntu 15.10

These are my notes for installing JBoss WildFly 10.0.0.Final

Elevate to root:
sudo -s

Install Java JDK 8:
aptitude update
aptitude install --with-recommends software-properties-common
add-apt-repository ppa:webupd8team/java
aptitude update
aptitude --with-recommends install oracle-java8-installer vim

Verify your java install
java -version

Should get out put of something like
java version "1.8.0_72"
Java(TM) SE Runtime Environment (build 1.8.0_72-b15)
Java HotSpot(TM) 64-Bit Server VM (build 25.72-b15, mixed mode

Create a user acount on the system for wildfly:
adduser --no-create-home --disabled-password --disabled-login wildfly

Download WildFly:
cd /srv
wget --tries=0 --continue http://download.jboss.org/wildfly/10.0.0.Final/wildfly-10.0.0.Final.tar.gz

Extract WildFly:
tar -xzvf wildfly-10.0.0.Final.tar.gz

Make a symbolic link to new folder:
ln -s wildfly-10.0.0.Final wildfly

Change ownership of directory and symbolic link to wildfly:
chown -R wildfly.wildfly wildfly*

Now, while WildFly 10 doesn’t ship as a .deb (which would be awesome!) it does provide a sample init script to get you going on Debian like/based systems of which Ubuntu is one. So, let’s copy that script to the /etc/init.d directory:
cp /srv/wildfly/docs/contrib/scripts/init.d/wildfly-init-debian.sh /etc/init.d/wildfly

Run update-rc.d to ensure wildfly starts on reboot:
update-rc.d /etc/init.d/wildfly defaults

And, copy the wildfly.conf file to /etc/default:
cp /srv/wildfly/docs/contrib/scripts/init.d/wildfly.conf /etc/default/wildfly
cd /etc/default

Edit the file that contains the settings/options for the setup script:
vi wildfly <– Or, editor of your choice

Uncomment and/or Edit the following lines:
JBOSS_HOME="/srv/wildfly"
JBOSS_USER=wildfly
JBOSS_MODE=standalone

JBOSS_CONFIG=standalone-full.xml — Change configuration file name in order to run full Java EE 7 Stack
STARTUP_WAIT=120 –Probably overkill wait time
SHUTDOWN_WAIT=120 –Probably overkill wait time
JBOSS_CONSOLE_LOG="/var/log/wildfly/console.log"

Try out the init.d and wildfly.conf settings and make sure the service can start:
service wildfly start

Shut the wildfly service down and lets make some edits/customizations:
service wildfly stop
cd /srv/wildfly/standalone/configuration
cp standalone-full.xml standalone-full.xml.original
#<– Always backup before edits!

By default WildFly seems to only listen on 127.0.0.1. To make it listen on all interfaces we have to edit the standalone-full.xml (recall we are using the standalone-full.xml per the /etc/default/wildfly configuration file above) file and change each instance of “127.0.0.1” to “0.0.0.0” in the file. Just use find and replace in your editor to do this. I use vim so…

vi standalone-full.xml
:%s/127.0.0.1/0.0.0.0/g
:wq

Start or restart Wildfly
service wildfly start

With WildFly running add a “Management User” and remember your credentials!!!
cd /srv/wildfly/bin
./add-user.sh

That’s it. You now have a basic WildFly 10 install and can reach it and configure further with any browser using the “Management User” credentials you setup above.
http://yourserver:9990/

Pretty General .gitignore File (Using Git 2.5)

Integrated Development Environments (IDEs) and other related development build tools (Gradle, etc.) seem to have the habit of leaving a mess of unnecessary files in your directory structure. I use a number of different IDE’s so I see a lot of these temp files and don’t want them mixed in with my source code.

Fortunately, I use “git” which allows for a “.gitignore” file which allow one to make entries that “pattern out” these unwanted (but necessary for the build) files and in helping to keep your source repository clean.

For a while I was building this file on a per-project basis. But, it occurred to me that I could just start one big generic “.gitignore” file and use across all (most?) of my IDEs and projects. There are a lot of recommendations in this file. Not all will pertain to you but you may find it a helpful start. And, I must admit that it leans toward the fact that I use NetBeans (with Gradle Plugins), IntelliJ and to a much lessor extant Visual Studio. My Gradle projects tend to have a lot of sub-projects (sub-modules) so eliminating unwanted files recursively is important.

Feel free to cut and paste what I have below into your own “.gitignore” file. After adding these entries run the git commands below to clean out some of the noisy files that may be in your repository cache. And, please comment below to add, update and/or make a suggestion. Your input is most welcome!

  1. Make sure you are backed up of course!!!
  2. Update, edit or just use my .gitignore entries below
  3. git commit -a -m “Before Updated/New .gitignore”
  4. git rm -r –cached .
  5. git add .
  6. git commit -a -m “After Updated/New .gitignore”

Currently my “.gitignore” contains:

 ###################################
# Hidden Files/Folders In General #
###################################
.*

##################################
# Uneeded Gradle Generated #
# I don’t use the Gradle Wrapper #
##################################
.gradle
/.gradle/
**/.gradle
**/.gradle/
**/.gradle/**
gradle
gradlew
gradlew.bat
.nb-gradle-properties
**/.gradle
**/gradle
**/gradlew
**/gradlew.bat
**/.nb-gradle-properties

###############################
# Compiled and Output Folders #
###############################
[Bb]uild
/[Bb]uild/
**/[Bb]uild
**/[Bb]uild/
**/[Bb]uild/**
[Tt]arget
/[Tt]arget/
**/[Tt]arget
**/[Tt]arget/
**/[Tt]arget/**
[Oo]ut
/[Oo]ut/
**/[Oo]ut
**/[Oo]ut/
**/[Oo]ut/**
[Gg]en
/[Gg]en/
**/[Gg]en
**/[Gg]en/
**/[Gg]en/**

################
# Libs Folders #
################
[Ll]ibs
/[Ll]ibs/
**/[Ll]ibs
**/[Ll]ibs/
**/[Ll]ibs/**

#########################
# Compiled Source Files #
#########################
**/*.com
**/*.class
**/*.dll
**/*.exe
**/*.o
**/*.so

####################
# VIM Backup Files #
####################
**/*~
**/*.swp
**/*#

##############
# Logs Files #
##############
**/*.log
logfile*
**/logfile*

################################################
# Package Files — Git already has compression #
################################################
**/*.7z
**/*.dmg
**/*.gz
**/*.iso
**/*.jar
**/*.rar
**/*.tar
**/*.zip

###############################
# Misc Operating System Files #
###############################
**/*.DS_Store
**/*.DS_Store?
**/*._*
**/*.Spotlight-V100
**/*.Trashes
**/*ehthumbs.db
**/*Thumbs.db
**/*desktop.ini

###############################
# KDE Dolphin Directory Files #
###############################
.directory
/.directory/
**/.directory
**/.directory/
**/.directory/**

########################################
# IntelliJ Generated Files and Folders #
########################################
.classpath
/.classpath/
**/.classpath
**/.classpath/
**/.classpath/**
.project
/.project/
**/.project
**/.project/
**/.project/**
.settings
/.settings/
**/.settings
**/.settings/
**/.settings/**
.idea
/.idea/
**/.idea
**/.idea/
**/.idea/**
.metadata
/.metadata/
**/.metadata
**/.metadata/
**/.metadata/**
*.iml
**/*.iml
*.ipr
**/*.ipr
*.iws
**/*.iws
atlassian-ide-plugin.xml
**/atlassian-ide-plugin.xml

############################################
# Netbeans IDE Generated Files and Folders #
############################################
.nb-gradle
/.nb-gradle/
**/.nb-gradle
**/.nb-gradle/
**/.nb-gradle/**

###################################
# Visual Studio Files and Folders #
###################################
[Bb]in
[Dd]ebug*/
[Rr]elease*/
*_i.c
*_p.c
*.[Cc]ache
*.[Oo]bj
*.aps
*.bak
*.ilk
*.lib
*.log
*.ncb
*.pch
*.sbr
*.sdf
*.suo
*.tlb
*.tlh
*.user
*.vspscc
*.vssscc
Ankh.NoLoad
ipch/
obj/

####################
# Subversion Files #
####################
.svn
/.svn/
**/.svn
**/.svn/
**/.svn/**

#######################################################
# KEEP Gradle Properties, Build & Settings Files !!!! #
#######################################################
!gradle.build
!**/gradle.build
!gradle.properties
!**/gradle.properties
!settings.gradle
!**/settings.gradle

###############################################
# KEEP Git Ignore (This .gitignore) File !!!! #
###############################################
!.gitignore ###################################
# Hidden Files/Folders In General #
###################################
.*

##################################
# Uneeded Gradle Generated #
# I don’t use the Gradle Wrapper #
##################################
.gradle
/.gradle/
**/.gradle
**/.gradle/
**/.gradle/**
gradle
gradlew
gradlew.bat
.nb-gradle-properties
**/.gradle
**/gradle
**/gradlew
**/gradlew.bat
**/.nb-gradle-properties

###############################
# Compiled and Output Folders #
###############################
[Bb]uild
/[Bb]uild/
**/[Bb]uild
**/[Bb]uild/
**/[Bb]uild/**
[Tt]arget
/[Tt]arget/
**/[Tt]arget
**/[Tt]arget/
**/[Tt]arget/**
[Oo]ut
/[Oo]ut/
**/[Oo]ut
**/[Oo]ut/
**/[Oo]ut/**
[Gg]en
/[Gg]en/
**/[Gg]en
**/[Gg]en/
**/[Gg]en/**

################
# Libs Folders #
################
[Ll]ibs
/[Ll]ibs/
**/[Ll]ibs
**/[Ll]ibs/
**/[Ll]ibs/**

#########################
# Compiled Source Files #
#########################
**/*.com
**/*.class
**/*.dll
**/*.exe
**/*.o
**/*.so

####################
# VIM Backup Files #
####################
**/*~
**/*.swp
**/*#

##############
# Logs Files #
##############
**/*.log
logfile*
**/logfile*

################################################
# Package Files — Git already has compression #
################################################
**/*.7z
**/*.dmg
**/*.gz
**/*.iso
**/*.jar
**/*.rar
**/*.tar
**/*.zip

###############################
# Misc Operating System Files #
###############################
**/*.DS_Store
**/*.DS_Store?
**/*._*
**/*.Spotlight-V100
**/*.Trashes
**/*ehthumbs.db
**/*Thumbs.db
**/*desktop.ini

###############################
# KDE Dolphin Directory Files #
###############################
.directory
/.directory/
**/.directory
**/.directory/
**/.directory/**

########################################
# IntelliJ Generated Files and Folders #
########################################
.classpath
/.classpath/
**/.classpath
**/.classpath/
**/.classpath/**
.project
/.project/
**/.project
**/.project/
**/.project/**
.settings
/.settings/
**/.settings
**/.settings/
**/.settings/**
.idea
/.idea/
**/.idea
**/.idea/
**/.idea/**
.metadata
/.metadata/
**/.metadata
**/.metadata/
**/.metadata/**
*.iml
**/*.iml
*.ipr
**/*.ipr
*.iws
**/*.iws
atlassian-ide-plugin.xml
**/atlassian-ide-plugin.xml

############################################
# Netbeans IDE Generated Files and Folders #
############################################
.nb-gradle
/.nb-gradle/
**/.nb-gradle
**/.nb-gradle/
**/.nb-gradle/**

###################################
# Visual Studio Files and Folders #
###################################
[Bb]in
[Dd]ebug*/
[Rr]elease*/
*_i.c
*_p.c
*.[Cc]ache
*.[Oo]bj
*.aps
*.bak
*.ilk
*.lib
*.log
*.ncb
*.pch
*.sbr
*.sdf
*.suo
*.tlb
*.tlh
*.user
*.vspscc
*.vssscc
Ankh.NoLoad
ipch/
obj/

####################
# Subversion Files #
####################
.svn
/.svn/
**/.svn
**/.svn/
**/.svn/**

#######################################################
# KEEP Gradle Properties, Build & Settings Files !!!! #
#######################################################
!gradle.build
!**/gradle.build
!gradle.properties
!**/gradle.properties
!settings.gradle
!**/settings.gradle

###############################################
# KEEP Git Ignore (This .gitignore) File !!!! #
###############################################
!.gitignore

Monero (XMR) Mining on Ubuntu Linux 15.04

A little discussion…
This isn’t an endorsement of Monero. Just one of the many crypto-currencies (kind of like BitCoin) out there that I’m playing with. I find Monero interesting because the project expresses the intent to make their currency untraceable.
There do seem to be some graphical wallets in the works but the main site recommends using MyMonero as a way to get a wallet set-up quickly.
Assumptions:
I’ll make the assumption you are running Ubuntu, are an sudo’er on your system, are familiar with git and/or github and have a Monero wallet address where you can send your mined coins. And, of course, you should be able to use this address to send and receive coins, too.
We’re going to download and compile the CPU miner published by Wolf at https://github.com/wolf9466/cpuminer-multi
Before we being thanks to Wolf and his fellow developers for publishing a GPLV2 CPU miner for the world to use. If you find the miner useful send these developers a donation at:
XMR: 46sSETXrZGT8bupxdc2MAbLe3PMV9nJTRTE5uaFErXFz6ymyzVdH86KDb9TNoG4ny5QLELfopynWeBSMoT1M2Ga8RBkDqTH
OK, the direction posted by the developers on github are pretty good. But, if you are running an Ubuntu system like me you may not have all the required development libraries installed in order to complete the compile and make process. I figure it doesn’t  really hurt to have more dev libraries and tools than you need so I installed many of the usual suspect.
sudo apt-get install aptitude
sudo aptitude update
sudo aptitude install –with-recommends build-essential autotools-dev autoconf automake libcurl3 libcurl4-gnutls-dev git make cmake libssl-dev pkg-config libevent-dev libunbound-dev libminiupnpc-dev doxygen supervisor jq libboost-all-dev htop
Again, you probably don’t need all that stuff but it doesn’t hurt. From this point the directions provided by the developers are pretty straight forward — and you don’t need to be root to complete most of these steps:
Get the source code and compile it :
cd cpuminer-multi
./autogen.sh
CFLAGS=”-march=native” ./configure
make
See if you have an executable file:
./minerd –help to see all the options
Have the miner run when you reboot:
Now to make life simple — and ensure that your miner starts up when you reboot — it is useful to make a simple shell script and then add it to your crontab. (We’ll make the assumption that the cpuminer-multi folder you pulled from github is in your home directory and that is where you will put your script.)
vi monero ## Or, use whatever editor you like to create the monero file and enter the contents:
#!/bin/bash
~/cpuminer-multi/minerd –background -a cryptonight -o stratum+tcp://xmr.prohash.net:7777 -u 42hx34g3FoM1npNDqGAETC8yertQAzofATbZ2e5XvTogbz3J8cudDehAnREQ1ZxaDg1BPqEM6bvMeg5AePaZAowHJBLqYKF -p x 1>&- 2>&- &
chmod +x monero
crontab -e ## At the bottom add the line then save the file
@reboot ~/cpuminer-multi/monero
When you reboot open a terminal window and run the htop command. You should see the cpu miner working away.
Final step:
Edit ~/cpuminer-multi/monero and change the wallet address from my address to your address. It’s up to you if you want to stick with MyMonero or use a different wallet. Perhaps use the one that comes with the full Monero peer to peer server distribution.
In short the only issue I had was not having the pre-requisite libraries installed. I hope you find the above package install tips useful.
Also, there seem to be a lot of mining pool options. I just happened to pick http://xmr.prohash.net but http://monero.crypto-pool.fr and http://xmr.miner.center also seems to be popular. Check this link for a better list:
If you have some tips to share please leave a comment.
If you want send me some monero (always welcome):
XMR: 42hx34g3FoM1npNDqGAETC8yertQAzofATbZ2e5XvTogbz3J8cudDehAnREQ1ZxaDg1BPqEM6bvMeg5AePaZAowHJBLqYKF

Grive2: Replacement for Grive

“grive” was a useful command line utility for syncing files in local folder on a Linux system with files in your Google Drive account.

It would seem that the grive project is no longer being maintained and no longer functions correctly due to deprecated APIs at Google.

That is the bad news. The good news is that there is a Grive2 project available. But, you will have to add a new repository to your Ubuntu system to get it.

sudo add-apt-repository ppa:nilarimogard/webupd8
sudo apt-get update
sudo apt-get install grive
mkdir ~/myGriveFolder
cd ~/myGriveFolder
grive -a

Thank you Alin Andrei for publishing this package!

Gradle 2.6 — How to set the “Main” class to run using the Application plugin

I had been using an older version of Gradle and when I needed to specify my main class to run I added something similar to the lines below to my build.gradle file.

task run(dependsOn:'build') <<{
ant.java(classname: 'com.gesker.MyMainClass', fork: true,
classpath: "${sourceSets.main.runtimeClasspath.asPath}")
}

However, the Application plugin in newer versions of Gradle makes this much cleaner. Just add two lines similar to those below to your build.gradle file:

apply plugin: 'application'
mainClassName = "com.gesker.MyMainClass"

By main class I of course mean the specific class you want to run that contains the ever necessary:


public static void main(String args[]) {
// Your Code Here
}

The above is another great reason to revisit the docs for projects upon which you depend as you upgrade.

Swappiness in Ubuntu 15.04

You can often get a performance boost from your Ubuntu system by swapping out physical memory to disk (swap partition) less.

Ubuntu seems to have a default “Swappiness” level of 60.

Try dropping this to 20 or even 10

sudo -s
vi /etc/sysctl.conf

Add to the very bottom of this file:

vm.swappiness=20
:wq
reboot

After reboot
cat /proc/sys/vm/swappiness to make sure the new value took effect.

There is an official page that covers this all in excruciating detail but the above is the gist of of it.