Thursday, December 19, 2013

A Minor Update

I made a few changes to my website today, including completely changing this blog's layout. I added Flattr integration which wasn't working with the Dynamic layout I had before. Let me know what you think about the change!

Speaking of Flattr, I've added a Flattr button to my main website in addition to other donation options like Paypal and Bitcoins in case people want to support my work (and/or hosting costs).

I've also added a neat little web app over at http://james-firth.com/projects/palettefy that finds the proportion of colours in an image. May need some more tweaks but that's the initial version.

I'll publish another blog post soon about how to setup and run automated tests with Selenium!

Saturday, September 28, 2013

How to install RHQ on CentOS

Centos full

This guide was originally written for a work project, but I was given permission to blog about it.

My Virtual Machine Setup

You can of course use whatever you would like but this is my setup.

OS: CentOS 6.3 64-bit Desktop
Virtual Machine Software: VMWare Player
Virtual Machine Specs: about 2-3GB of memory and 2 Processors

Install the OS with VMWare Player, its handy Easy Install will do most of that work for you, so you can walk away until it's finished.



Linux/CentOS Usage Notes

For those unfamiliar with Linux here are some quick notes
If you are not comfortable with using vi, simply replace any instance of ‘vi’ with ‘nano’.
Nano is a much more user-friendly command line text editor.

Nano overview of nano 


  •  Keys work as you would expect, you can type instantly and arrows move the cursor around. Move the cursor down past the bottom to scroll.     
  • Press Ctrl-O (shown as ^O) to save (shown as WriteOut)
  •   Press Ctrl-X to exit (Shown as ^X)
  • Since you now know what the ^ means (ctrl key) you can read the menu at the bottom of the screen easily!
Vi quick commands:


  • Press i (or the insert key) to go into Insert mode. Press Esc to exit Insert mode.
  • Type :wq (then press enter) to save and quit
  • Type :q (then hit enter) to quit without saving.

Download and Install Requirements

NOTE: The install commands are assuming you are using CentOS. If you are using another package manager you may have to replace the "yum" commands with something else such as "apt-get"

Go to https://docs.jboss.org/author/display/RHQ/Download+RHQ and download the newest version of RHQ (rhq-server.4.6.0.zip at the time of writing). Continue with the following steps while it downloads.

1.       Open a Terminal Window

2.       Login as Super User
2.1.    Type su
2.2.    Enter password

3.       Install PosgreSQL
3.1.1. Type ‘yum install postgresql*’ making sure to include the asterisk (*)
3.1.2. Type ‘y’ when prompted (happens twice)

4.       Confirm java version
4.1.    Type ‘java –version
4.2.    Confirm it’s running at least 1.6 and using OpenJDK (or Oracle/Sun Java or JRockit, but NOT GNU Libgcj)

5.       (If not installed) Install Java
5.1.    Type ‘yum install java
5.2.    Type ‘y’ when prompted

6.       Add RHQ_SERVER_JAVA_HOME environmental variable
6.1.    Type ‘vi /etc/environment
6.2.    Add ‘RHQ_SERVER_JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64’ (or whichever version of Java is running of course)
6.3.    Save
6.4.    Type ‘source /etc/environment’ to load the variables
6.5.    Type ‘echo $RHQ_SERVER_JAVA_HOME’ and the output should be '/usr/lib/jvm/jre-1.6.0-openjdk.x86_64’
6.6.    Type ‘export JAVA_HOME=/usr/lib/jvm/jre-1.6.0-openjdk.x86_64
6.7.    Type ‘export PATH=$PATH:/usr/lib/jvm/jre-1.6.0-openjdk.x86_64


Configure the PostgreSQL Database


1.       Initialize the database
1.1.    Type ‘/etc/init.d/postgresql initdb
This will add all the config files we need to edit


2.       Edit pg_hba.conf
2.1.    Type ‘vi /var/lib/pgsql/data/pg_hba.conf
2.2.    Change the last few lines from

# "local" is for Unix domain socket connections only

local   all         all                               ident

# IPv4 local connections:

host    all         all         127.0.0.1/32          ident



to




# "local" is for Unix domain socket connections only

local   all         all                               trust

# IPv4 local connections:

host    all         all         127.0.0.1/32          trust

3.       Start Postgres service
3.1.    Type ‘service postgresql start

4.       Add a user
4.1.    Type ‘psql postgres postgres’. You should be given a new prompt postgres=#

5.       Type CREATE USER rhqadmin with password ‘rhqadmin’;
with quotes NOTE: Don’t forget the semicolon, otherwise it will give you a new line to enter more text. If this happens simply enter a semicolon (;). Also be sure to use different names than these dummy ones.


6.       Create database
6.1.    Type CREATE DATABASE rhq owner=rhqadmin;

7.       Test Database connection
7.1.    Type ‘\c rhq rhqadmin’ to test connection
7.2.    Type ‘\q’ to exit psql

8.       Config postgresql to start on boot
8.1.    Type ‘chkconfig --list postgresql
Should display
postgresql         0:off      1:off      2:off      3:off      4:off      5:off      6:off
8.2.    Type ‘chkconfig --level 0123456 postgresql on
8.3.    Type ‘chkconfig --list postgresql’ (or hit the up arrow twice) to confirm config
Should display
postgresql                  0:on       1:on       2:on       3:on       4:on       5:on       6:on



Install RHQ

Once it’s downloaded unzip it

1.       Unzip using either the Archive Manager GUI or the command unzip rhq-server-4.6.0
1.1.    Commandline Option type: ‘unzip rhq-server-4.6.0.zip –d ../Desktop’ (if you’re in the Download directory)

2.       Change directory to the rhq server’s bin folder
2.1.    Type ‘cd /home/user/Desktop/rhq-server-4.6.0/bin/

3.       Start the server
3.1.    In the server bin directory type ‘./rhq-server.sh start

4.       Add password
4.1.    Type ‘./rhq-installer.sh --dbpassword=rhqadmin’ (that’s 2 dashes)        
So the installer has the correct password


5.       Edit the rhq-server.properties files
5.1.    Change rhq.autoinstall.enabled=false to true in the Installer Settings section

6.       Run the installer
6.1.    Type ‘./rhq-installer.sh

You can now access the following applications through firefox using ‘rhqadmin’ as both the username and password.

JBoss Application server http://localhost:6990
RHQ http://localhost:7080

Notes:
1.       I had an error logging into RHQ, may have been a typo on the password. To resolve I opened JBoss then RHQ then my password worked again. Opening and closing the webpages and retrying also seemed to fix it. Not entirely sure why this happens, but it was solvable within a few minutes each time.

2.       Do not forget the http:// if you are manually typing it out. Firefox does not recognize localhost:6990 as a webpage

To start all the services when logging in again:

Login as root (type ‘su’)
Type ‘/home/user/Desktop/rhq-server-4.6.0/bin/rhq-server.sh start’ to startup RHQ again


PostgreSQL should already be started.


Comments, Questions, and Criticism for this guide are appreciated to help keep it relevant!


Image Sources:
RHQ Logo - RHQ Homepage
CentOS logo - Wikimedia - License: Public Domain

Saturday, June 29, 2013

What should I buy?: A Smartphone Guide



My friend asked for information on what phone to get on Facebook and I ended up writing way too much in the comments and decided to put it here.

Unlocking

Rogers (and I believe others) won't unlock a phone right away (90 days for Rogers). You could also buy a phone unlocked, or get it unlocked by someone besides the carrier (may void the warranty). The Nexus 4 can be bought from Google unlocked, unsubsidised.

NOTE: Starting in December carriers will be required to allow you to unlock the phone immediately if you pay full price and after 90 days if it's subsidised. CRTC Phone rights

iOS vs. Android

I would recommend looking at both of these a bit to figure out what features you like most.

Personally I like Android, but iOS works perfectly well for many people. iOS 7 (latest) has many features from Android which I also like.

I won't go into the details on iOS as I'm no expert and not sure of everything included in iOS 7.

Android however I could go on about for a while.

  • Things I like (Software) Customization, if I don't like something I can replace it (music player, texting app, even the dialer. Oh and keyboard! Lots of cool keyboards).
  • More than one button! (Back button for instance)
  • Integrates with Gmail and other Google products very well which I use a lot.
  • Widgets (are still Android-only I believe) let you control lots of nice things from your home screens. For instance wifi, or give you news feeds (for instance you could have your twitter feed on the home screen without opening the app)


  • Android Beam. If you have a phone with NFC (the big phones this year all do) then you can simply touch phones with another Android (with NFC) and send them stuff. I've sent contact info, web pages and even songs through it. (Song just to test it out).



Hardware

You could read plenty of reviews on the 3 big names in phones right now: HTC One, Samsung Galaxy S4, and iPhone 5. (Sometimes the Nexus 4 gets thrown in, but it's a bit older so I wouldn't recommend it as it could get outdated quicker).

I won't give a full run-down as I'd recommend just Googling and comparing some phones but taking reviews with a grain of salt as everyone has preferences. Here's one such quick side-by-side comparison.

Here's a quick break down though:

Screens: iPhone 5 is 4 inches, One & S4 are around 5".

Processor: iPhone is a duo-core, One & S4 are both quad-core

RAM: iPhone is 1GB, One & S4 are 2GB

Storage: iPhone comes in 16, 32, & 64 GB (non expandable), the S4 is the same, but you can add a microSD card (up to 64GB) to make it quite large. HTC One only has 32 & 64 (non-expandable). Personally I found the 32 was great. NOTE: Look up what the usable space is as part of those quotes is used up by the OS.

Fancy stuff: S4 & HTC One both have NFC (Near Field Communication) chips & IR Blasters, I have an app that let me turn off the projectors at school :P

Battery: My HTC One is doing fine and I haven't heard any complaints from my girlfriend or friend about their iPhone 5 & S4 respectively.

Cameras: Stats are all different, but they all take decent photos. Again look up camera reviews if you care that much.


Software UI

iPhone has iOS so you've probably seen that before. Personally I don't like that everything is on the homescreens or the single button design. But that's up to you! Here's an article on iOS 7

S4 uses Samsung's TouchWiz UI. Personally I don't like it that much and feel it looks dated. However some people really like it (it's very grey/green with gradients). They also have some very cool gimmick features, such as scrolling through the web browser as you look down the page, pausing videos when you look away from the screen, and some neat gesture stuff.

HTC One uses a brand new UI, called Sense 5 (which is much better than the old one IMO). It's very flat and minimalistic, using black, white, and blue a lot. Some things have been changed from standard Android, but seeing as you haven't used it it wouldn't require any re-learning. It also has the Beats Audio stuff, ie a very nice speaker (as I showed you). You may want to see what it's like with headphones, I enjoy it though. One thing that you may or may not like is "BuzzFeed", by default it's your homescreen (I moved mine to the far left). It's a news feed that you can customize with Facebook, Twitter and news sources, it also gives you time/date/temperature info. You however cannot remove this screen if you keep using the default launcher. Here's a review of the HTC One and Sense UI

I would recommend Googling the terms in Google Image Search to see what the UIs look like in more detail.

NOTE: With the S4 & the One you can always customize the UI however you'd like. For example if you don't like BuzzFeed, install Nova Launcher and you have a completely different home screen experience. And if you don't want the gimmicky features like the scrolling, turn them off in the settings.

Games

iOS (for some reason) will often get more exclusives than Android, but you can side-load apps onto Android without going through the Play Store (such as Humble Bundle games) which is great!

Testing/Feel

I think the most important thing to do is try out the phones! You can go to the stores and try them out, but you won't get a good idea of how they feel in your hands.

Try and find friends or friends-of-friends who have the phones and will let you hold/try them, as it's much different than when they're locked down at a store.

Definitely try them out though even if it's attached to a thing at a store!


Summary


Personally I'm a huge fan of Android and I'm loving my HTC One so that's my current recommendation. However it may not be for you and you may want other opinions than mine.

I read up a lot on Android so at least in that department I'm well-informed (in my opinion).

Thursday, May 30, 2013

Script to create full CVS Changelogs

Background

CVS Commit histories are saved file-by-file. In my coursework we were required to use a CVS repository to create a group project.

Why did I do this?

I didn't like having to check individual files to find out what's been changed so I did some looking and found cvs2cl that would create a changelog.

How I solved the problem

Luckily I have a Raspberry Pi sitting around so I created this script to automatically create full changelogs each time a new commit was found. (Mine checks every 15 minutes for new commits).

Several things one would need to do to replicate this setup.

1) Checkout the project from the CVS repo manually
2) Update the regex on line 15 to match the username naming scheme
3) Install cvs2cl
4) Install/setup exim4 (which allows me to send email through my secondary Gmail account)
5) Change YOU@DOMAIN.COM to the email you wish the log to be sent to.
6) Edit crontab to have the script run automatically (or set it up some other way)


NOTE: The regex on line 15 would need to be changed. This looks for the first UofM username, which starts with "um" all the time.
#!/bin/sh
cd /path/to/local/cvs/repo/
output="$(cvs -qn update)"
echo $output
if [ -x "$output"]
then
        echo "No Updates."
else
        echo "New commit available!"
        echo "Updating..."
        cvs update -C -d
        echo "Creating ChangeLog..."
        cvs2cl;
        sleep 2
        person="$(grep -o -m 1 'um*\w*' ChangeLog)"
        echo $person
        echo "Sending email..."
        mail -s "New Commit by $person. Full ChangeLog Below" YOU@DOMAIN.COM < ChangeLog
        sleep 2
        echo "Removing ChangeLog..."
        rm -f ChangeLog
        echo "Mission Complete."
fi

(Script also available on github)

Questions, Comments, Criticism are welcome below!