Install Python 3 on OSX

Even the the latest version of OSX ships with Python 2.7 which is getting a bit long in the tooth and Python 3.x is where its at these days. Although I wish most Python library developers would update their systems. Its not that hard

Anyway, download the latest version, in this instance Python 3.3

http://www.python.org/getit/

I went with the 64 bit version as default. Run the installer once downloaded and you have 3.3 installed but from the command line, it still shows 2.7, so we need to tell the shell to use Python 3.

Edit ~./bash_rc and add the following 2 lines

alias python=python3
PATH="/Library/Frameworks/Python.framework/Versions/3.3/bin:${PATH}" export PATH

If we want to do anything interesting with Python we will need pip, the pack installer. Get this with the following command

curl https://raw.github.com/pypa/pip/master/contrib/get-pip.py | python3

You can check its installed and working with Python 3 with the following

pip --version

Which should should something line the following

pip 1.5.2 from /Library/Frameworks/Python.framework/Versions/3.3/lib/python3.3/site-packages (python 3.3)

Which shows you are running pip on the latest version of Python you just installed

Adventures in Natural Language Processing – No 1. Setup

Natural Language Processing

So this will be a series of articles on natural language processing, this is based on Python 3, and the NL Toolkit, NLTK 3.0, which can be found at http://www.nltk.org

 

The current version of NLTK is based on Python 2,8, As we are using Python 3, and there is an alpha version available, but requires a bit of a manual process. First we need to install PyYaml 3.10 as NLTK requires a version greater than 3.9 and 3.10 is the latest version.

This can be installed at the command line using pip

> sudo pip install pyyaml

We can then check its installed with ‘pip list’

> pip list

Next head over to http://nltk.org/nltk3-alpha/, download one of the distributions, then unzip and open command line in root of unzipped files

> sudo python setup.py install

This will install NLTK into your current version of Python. You can test the install by starting the Python command line and importing the nltk module

> python
 Python 2.7.5 (default, Oct 11 2013, 15:52:19)
 [GCC 4.2.1 Compatible Apple LLVM 5.0 (clang-500.2.75)] on darwin
 Type "help", "copyright", "credits" or "license" for more information.
 >>> import nltk

If this failed or throws an error, you install failed.

If there are no errors, then download the corpas ( this also tests nltk is install ), remaining in the Python command line.

>>> import nltk
>>> ntlk.download ()

A dialog will appear, select all to download all packages and then click Download

Any errors in the above and its likely nltk installation failed

We are ready to begin….. watch out for No 2. NLP Basics

Agile Smagile

I love agile, I really do, for me it provides such a close cooperation between all parties involved in a project. I love agile pragmatists, people who know what to use when, and more importantly what won’t work for their specific environment, customer or company. These are people who see agile as a toolbox that provides a suite of tools that help you to deliver great software more frequently and better aligned to what your customers want.

However I really disagree with the pursists, delivery is not guaranteed based on the number of books you have read ( and can quote ) or the number of certificates you have, its based on how you apply the core tennets of agile at the appropriate time. You don’t need to follow Scrum, or DSDM, or XP or any of the others by the book, instead you need to know that each has its place, but none are the only solution.

Certification is diluted, every man and his dog has some form of certified agile this, and agile that, its time to talk about experience not paper. Certification should be seen as getting your papers to operate within an agile environment, its says you get it, you want to get it more and you want to operate under its guiding principals.

Where I work, we love Scrum, just about every project we deliver uses Scrum, but we don’t follow it religiously, for example, we have 2 week time boxed sprints but we release as soon as a feature is ready and by release I mean straight into production from the first day of the sprint, right the way through to the last day. When its ready it ships, we don’t hang around.

Sometimes ( shock horror ), Scrum doesn’t work for us, we have a large production system and sometimes we need to get a number of small changes out the door as quickly as possible, this is when we swap between Scrum and Kanban, and allow us to push features through the entire SDLC piece by piece.

In terms of development, TDD is great, its a major innovative step in software quality, but sometimes its hard. Its hard to learn, its hard to practice, but once your get it, personal and team productivity does soar. However sometimes people like to try an idea out, explore a concept, see if it works, if it doesn’t abandon it, if it does work then refactor it with tests to make it stronger. I get no greater thrill out of sitting down at a keyboard and trying to get an idea to work in code. I know and support the power of tests and refactoring, but sometimes ( just sometimes ) they get in the way until you really understand what it is you are trying to solve. Then the discipline kicks in and I can refactor then hell out of the code and build in quality with tests.

Agile is now so close to becoming mainstream its scary, but its still fragmented, and still too many high priests ( and their followers ) telling us their way is best, or jumping on the band wagon too late and telling us their re-interpretation of agile is best. Lets get back to the 4 key principles and make them work for you.

 

 

Finally a half decent Scala IDE

For some time now programming in Scala has required you to take a standard eclipse install and add a one of 2 pretty poor Scala plugins. Both of which left you feeling that you are not really getting the full Scala experience.

Enter Scala IDE 3.0, built on top of the Keplar release of Eclipse, for the first time, the support for Scala is well integrated, smooth and works really well.

Now just need to find a decent Clojure IDE and I’m sorted….

Install Java 7 on OSX

If you currently have your JAVA_HOME environment variable set as the trusty:

export JAVA_HOME=/Library/Java/Home

then when you upgrade to Lion you will need to adjust it, as the install location has changed. The new environment variable should be:

export JAVA_HOME=$(/usr/libexec/java_home)

This is actually a command which (in true OS X Java fashion) is a symlink to another command that outputs the true location of Java.

 

Techcrunch – Installing Postgres on EC2 Ubuntu Server

Most of this section if cribbed directly from an article at Digital Ocean

sudo apt-get install postgresql
sudo apt-get install postgresql-contrib
sudo apt-get install phppgadmin

Change Apache access for phppgadmin we just installed

sudo vim /etc/apache2/conf.d/phppgadmin

Change so it looks like ( remove # from 4th line )

order deny,allow
deny from all
allow from 127.0.0.0/255.0.0.0 ::1/128
allow from all

Restart Apache

sudo /etc/init.d/apache2 restart

If you now head over to http://localhost/phppgadmin you’ll see PHPAdmin for Postgres

Now we add some more security

sudo vim /etc/apache2/sites-enabled/000-default

Add the following to Virtual Host at the bottom

<Directory "/usr/share/phppgadmin">
AuthUserFile /etc/phppgadmin/.htpasswd
AuthName "Restricted Area"
AuthType Basic
require valid-user
</Directory>

Save and exit, n ow lets create a user id and password for access

sudo htpasswd -c /etc/phppgadmin/.htpasswd username

Enter userid and password, then restart Apache

sudo /etc/init.d/apache2 restart

Next we set the Postgres login credentials

sudo vim /etc/postgresql/9.1/main/pg_hba.conf

Look for the line that looks like

local all all peer

And change the peer to md5 so it looks like

local all all md5

Now we can su to postgres and create a database

sudo su - postgres

Then create a new database
createdb <newdbname>
And then create credentials for that database
createuser -P
Enter the name and password of the database user, making sure to set the user to be superuser

Now we can access the database via the Postgres command line

psql newdbname

You can now perform SQL against the databse. If you need to quit type \q

Head back over to PHPAdmin and we can now login with the credentials we created and access our new database

http://localhost/phppgadmin

Techcrunch – Apache and Tomcat on Amazon EC2 Ubuntu Server

# Install Base Apps
 sudo apt-get update

 

# Tools
 sudo apt-get install vim

 

# Basic Build
sudo apt-get install build-essential
sudo apt-get install subversion
sudo apt-get install git-core

 

# Apache
sudo apt-get install apache2

Go to http://localhost and you will see a web page that begins with

It works !

 

# PHP 5 – Useful for phppgadmin and other stuff
sudo apt-get install php5 libapache2-mod-php5
sudo vim /var/www/info.php

And enter the following
<?php phpinfo() ?>

If you now go to http://localhost/info.php you will see the PHP Info page

 

# Useful PHP Add ons

sudo apt-get install php5-cli php5-common php5-curl php5-dev php-pear

 

# Java 7
sudo apt-get install openjdk-7-jre
sudo apt-get install openjdk-7-jdk

Type in ‘java -version’ and it will tell you which version of Java is now installed

# Tomcat
sudo apt-get install tomcat7

Pop over to http://localhost:8080 and you’ll see the Tomcat home page

 

# Tomcat docs and examples
sudo apt-get install tomcat7-docs
sudo apt-get install tomcat7-examples
sudo apt-get install tomcat7-admin

 

Now add a user to access the tomcat admin screens, as per the instructions on the Tomcat home page
sudo vim /etc/tomcat7/tomcat-users.xml.

<role rolename=”manager-gui” />
<role rolename=”admin-gui”/>
<user username=”[user]” password=”[password]” roles=”manager-gui, admin-gui” />

Obviously replacing [user] and [password] with the userid and password you want to use

sudo /etc/init.d/tomcat7 restart

 

Jobs a good’in !!!!!!