Sunday, May 11, 2014

Installing Liquibase 3.1.1 on Centos 6.5

This is my idiot guide to installing Liquibase 3.1.1 on a Centos 6.5 box. I've done this several times in the past but keep forgetting how to do it, so I'm documenting the steps I followed for future reference.

Install Java

Liquibase 3.x requires Java 1.6+ so lets get that installed first

$ sudo yum install java-1.7.0-openjdk

Get the Liquibase Code

I'm just going to install put Liquibase in the home directory for now

$ wget http://sourceforge.net/projects/liquibase/files/Liquibase%20Core/liquibase-3.1.1-bin.tar.gz/download
$ tar zxvf liquibase-3.1.1-bin.tar.gz
$ sudo chmod + x ./liquibase
$ ./liquibase --version

Install Mysql

$ sudo yum install mysql mysql-server
$ sudo chkconfig --levels 235 mysqld on
$ sudo service mysqld start
$ /usr/bin/mysqladmin -u root password 'root'
$ mysql -uroot -proot

Install the Mysql Connector for Java

$ wget http://dev.mysql.com/get/Downloads/Connector-J/mysql-connector-java-5.1.30.tar.gz
$ tar zxvf mysql-connector-java-5.1.30.tar.gz

Create the database

$ mysql -uroot -proot
mysql> create database example;
mysql> exit;

Create a Changelog file

$ vim ./changelog.xml

Add the following...

 <?xml version="1.0" encoding="UTF-8"?>  
 <databaseChangeLog  
   xmlns="http://www.liquibase.org/xml/ns/dbchangelog"  
   xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"  
   xsi:schemaLocation="http://www.liquibase.org/xml/ns/dbchangelog http://www.liquibase.org/xml/ns/dbchangelog/dbchangelog-3.1.xsd">  
   <changeSet id="1" author="bob">  
     <createTable tableName="department">  
       <column name="id" type="int">  
         <constraints primaryKey="true" nullable="false"/>  
       </column>  
       <column name="name" type="varchar(50)">  
         <constraints nullable="false"/>  
       </column>  
       <column name="active" type="boolean" defaultValueBoolean="true"/>  
     </createTable>  
   </changeSet>  
 </databaseChangeLog>  

Run Liquibase

$ ./liquibase --driver=com.mysql.jdbc.Driver --classpath=mysql-connector-java-5.1.30/mysql-connector-java-5.1.30-bin.jar  --changeLogFile=changelog.xml --url="jdbc:mysql://localhost/example" --username=root --password=root update

Create a liquibase.properties file

$ vim ~/liquibase.properties

Add the following...

 driver: com.mysql.jdbc.Driver  
 classpath: mysql-connector-java-5.1.30/mysql-connector-java-5.1.30-bin.jar  
 url: jdbc:mysql://localhost/example  
 username: root  
 password: root  

Run Liquibase... with the properties file
$ ./liquibase --changeLogFile=changelog.xml update

Sunday, March 23, 2014

My Current Reading List

My house is full of books; it's actually something that I'm really pleased with as I never took the activity of reading that seriously as a teen or later as a student.

I'm really pleased that reading is so influential in my family, and reading my daughter a story every night at bed time since not long after she was born has, I hope, has instilled in her how fantastically liberating reading can be.
Recently she has been fascinated by dinosaurs and was happily reading a fairly text heaving book on the subject this morning.

One of the drawbacks though, of being a reading household, it that there are piles of books everywhere, still waiting to be read. I have about 20 science fiction books by the side of my bed, pleading with me to be read each night before I go to bed. In this respect, Laura is much more obliging to read through the pile of books that adorn her bedside table.

So, since I haven't blogged in such a long time - I thought I would share my current reading list.
Actually, I have 2 reading lists; the one that contains books that I actually read or have read and the list that contains those books, that I will probably not read until I am an old man with more time on his hands.

So I will list My Current Reading List of books. I consider that any book that has been in my bag and I have read on the train to work and back in the last couple of months  deserves to be on this list.

This is not some kind of ultimate reading list, that would be a pointless list as books can influence in different ways at different times, so any reference to some kid of high ideal such as ultimate would only be temporal. For example, a book I read today may mean nothing to me, but perhaps the same book would mean much more to me in few years time.

Anyway, here is my current reading list...

Domain Driven Design - Tackling Complexity in the heart of Software by Eric Evans

Affectionately known as the 'Blue Book'; the insight that Eric Evans shares about developing application solutions using domain driven design techniques really opened my eyes to thinking about the code I was writing. When I bought this book, I read it from cover to cover; I'm now reading it for a third time and still learn so much from it.

Implementing Domain-Driven Design by Vaughan Vernon

To go with the 'Blue Book', this is know as the 'Red Book'. This book is fairly new to me; so I'm still only part way through. Vaughan Vernon, regularly refers back to the 'Blue Book' to explain how some of the topics covered can be implemented. 

Design Patterns - Elements of Reusable Object-Oriented Software by Erich Gamma, Richard Helm, Ralph Johnson and John Vlissides

Simply, if you are asked "Do you have this book?" and you answer "No", then your next action had better be to purchase this book. Known as the "Gang of Four" book, this covers the design patterns that any serious developer should be aware of.

The Art of Agile Development by James Shore and Shane Warden

Practicing Agile is something thats fairly new to me; I must admit that I'm not that successful with it at the moment, but I'm keen to learn. This book is fairly heavy going, and I don't think it really that practical unless you are in a position to implement or try to Agile practices.


I love "Martin Fowler Signature Books", I have quite a collection, and this is one book that although covers a fairly particular area of application design, it one that I get a lot from. Web services, both the creation and consumption is something that really interests me.

The Lean Startup by Eric Ries

I'm onto my second read of this book, I would say that it's a fundamental read if you want to learn about the product after software. This book covers many influential ideas such as how to get the most from the MVP (minimal viable product), the Build-Measure-Learn cycle and how it can be used to develop the right product.

David 

Wednesday, January 11, 2012

Create HTML view scripts with li3 Console

To create views with the Lithium console script we run

> li3 create view posts index

This will create the index.php file in a folder called posts in the views directory of out app.

I ran this command successfully but found that my controller was looking for a file call index.html.php.
Notice the html in the file name.

To create the correct file run

> li3 create view posts index.html

Note the addition of html.

Easy.

Sunday, October 30, 2011

The @author Tag Policy

So heres the thing

I've been thinking recently about “ ownership ” & “ responsiblities ” of code.
I am the kind of code monkey that insists that all code I write includes all required docblocks.

Why?

Simply so that any other developer looking at my code (good or bad) knows who to point the finger at if the system is fragged becase I didn't take/have (delete as appropriate) the time or couldn't be bothered to write fully functional code. Its a mentality that I'm at ease with because I don't try to hide that fact that I do on occasion write some attrocious code.

So, on all of my code, you will find my name in the @author tag, hell, just for good measure I'll throw you a few extras in some of the method doc blocks as well.

However, I am the kind of developer that is also at ease, at best rewriting, at worst totally deleting code. Code isnt' precious - believe me - it's not!

I will happily do this to my own code and guess what - I will do it to yours to!

Hell, the code could be the most beautiful fully functioning code in the world - but if it's not right for the domain at hand - its a problem and I will delete it.

Which brings me to a policy that I've had subconciously but not really thought about in any depth until recently - who's code is it?
 
When ever I rewrite code, even when that means totally trashing the file and starting a fresh, I leave the original @author tags in place and add my own to the list (after the original @author(s) I might add).

Even if the original code - line for line, method for method is garbage - the original author still had to start that feature of the code base, they still had the initial understanding that that particular feature was required - even if my three year old daughter could have produced better code.

Authorship is not just about who wrote each line, its bigger and more abstract - authorship is also about who had the original idea and did something enough to make that idea something real - even if poorly written.

If you are not using docblocks in your code - stop hiding in the shadows - be proud to put your name to it - who knows maybe I'll come along, rewrite the whole thing making it better, but I swear I'll leave your name on it - that way you can still claim that at least the idea was yours!

MonkeyPHP