Paul Chilton
Commenting on comments
I’ve had a lot of comments on my blog. Unfortunately they all seem to be spam bots. So I’ve removed commenting from my posts. If you’d like to contact me, use the reverse of: com (dot) gmail (at) chilton (dot) paul
Git, gitosis-admin and git flow
Both git and gitosis covered well by the Ubuntu help for Git
git flow makes branching a pleasure to use.
Rubyrep with PostgreSQL DB syncing
I’m using Rubyrep to sync databases between a pair of PostgreSQL instances for this blog. Thought I would share the process that I used with you.
Install Rubyrep
sudo gem install rubyrep
Configuration
Use the following of scripts/rubyrep.conf with:
RR::Initializer::run do |config|
config.left = {
:adapter => 'postgresql',
:database => 'example_development',
:username => 'example',
:password => 'example',
:host => '127.0.0.1',
:port => 5432,
}
config.right = {
:adapter => 'postgresql',
:database => 'example_production',
:username => 'example',
:password => 'example',
:host => '127.0.0.1',
:port => 5555,
}
config.options[:auto_key_limit] = 2
config.options[:rep_prefix] = 'rr_example'
config.include_tables 'schema_migrations', :key => 'version'
config.include_tables /./, :sync_conflict_handling => lambda { |sync_helper,conflict_type,rows|
time_left = rows[0]['updated_at'].to_i
time_right = rows[1]['updated_at'].to_i
if time_left > 0 and time_right > 0 and time_left != time_right
if time_left > time_right
sync_helper.update_record(:right, sync_helper.right_table(), rows[0])
else
sync_helper.update_record(:left, sync_helper.left_table(), rows[1])
end
end
}
end
This gives a local left connection, and a remote right connection when configured with SSH tunneling. Conflict resolution is based on the updated_at column of the database.
SSH Tunneling
I already have SSH keys setup on the remote host. Using the following to create a connection locally on port 5555 that connects to the remote PostgreSQL port of 5432
ssh -f -N -T -C -L 5555:localhost:5432 example@example.com
Scan and sync
I do the scan and sync manually, rather than continual replication.
rubyrep scan -c scripts/rubyrep.conf
rubyrep sync -c scripts/rubyrep.conf
Fun things with replication
It is possible to have a master-master replication setup where databases are not always connected. Requires:
- Application aware that databases are synced intermittently.
- Unique ID columns. I’ve used GUID values. Even/odd sequences may work.
- Use of updated_at column, for resolving conflicts.
- Do not delete rows. These will sync back into existence.
There are some significant constraints on what can be done, but it does enable some unique applications.
The games I play
Currently playing ESDAO – a turn based strategy game. Long turns, so I can play it in the background over a long period of time. For example I’m playing a 60 turn game with 24 hour turns, so could take a couple of months. Runs faster if everyone sets their turns earlier on.
On my iPhone I’ve been playing Sudoku. I’ve found that Sudoku is a good game to play during a train ride, in terms of the time to play through a game, and being able to start/stop it easily. Previously I’ve played Tower Madness, but found that games take longer, and interruptions not as easy to deal with.
Enki based blog
It has been a while since I did any postings to my blog. Restarting on an Enki based blog, will start to post on a regular basis to improve my writing and communication skills.
Inspired by a post by Jeff Atwood about writing without writing
Staycation in Wellington
Took a week off to have a break. Thought we would spend some time in Wellington and see some local sights. Spent most of a day in Masterton, an evening in Martinborough, and an afternoon in the Botanical Gardens.
Spent some quality time at home working on a new pet project. Thought I would try to avoid using a computer for a week, instead I built a website I’ll be polishing up and launching in a few weeks.
Nice to take some time out, catch up with people and bring some fresh perspective to things.
Good food. Good company. Good times.
mod_rewrite
Despite the tons of examples and docs, mod_rewrite is voodoo. Damned cool voodoo, but still voodoo.
PixelPaint
PixelPaint:http://www.pixelpaint.co.nz/
Large format print on canvas. Great quality. Don’t like it don’t pay. New Zealand only for now.
Website under development but processing orders now.
luck
The harder I work, the luckier I get.
Movember 2009
Another year, another Mo. Donate below.
PDF Development
Whenever doing development that has PDF as an output, the way to preview it in a browser is with:
http://www.example.com/file.pdf#view=fitV
Refresh in browser doesn’t seem to flow through, so usually best to timestamp the URL.
Best tool I’ve found for turning XHTML/CSS into PDF files: PrinceXML:http://www.princexml.com/. (expensive, but very good)
Holiday in Rotorua
Went up to Rotorua for a three day weekend. Driving up through Taihape was suprised to see random breath tests going on, at 2:15 in the afternoon. Fairly long drive up from Wellington, but eventually got there. The hotel room was nice, with lake views. Had chicken fettucine for dinner, then collapsed into bed.
Next morning had breakfast in town, and that is when it started feeling like a holiday. Purchased a cheap pair of sunglasses (having previously snapped earlier ones in a seating accident), and headed up to the Luge. Went on the first run down, a lot of fun! Coming back up we managed to get a few bus loads of tourists coming through, so went to the cafe. Food was pretty nasty. Second run down took the scenic track, which was more fun than the intermediate track.
Headed to the Polynesian Spa, deluxe private pools. Lovely view across the lake, and very relaxing. Afterwards went across the waterfront, watched part of the sunset, and felt pretty good about the world. Stone grill dinner later on, and an Italian dessert on the way back to the hotel.
Next morning started back on the way to Wellington. Stopped in at Huka Falls in Taupo, and had a go on the jet boat. Wicked fun, with spins and splashes to go along with it. Quick bite to eat in Taupo, then a long drive back home.
Nice to get away for a long weekend. Brings back some balance into life.
Firefox Extension list
Yet another firefox plugin extension listing. Used to keep a track of common plugins for when I rebuild my computer.
BSD vs GPL for web applications
There are a lot of open source licenses available, and when I looked at how to open source a couple of web applications the obvious choices seemed to be either the BSD or the GPL.
The first thing people seem to do is try out a web application. If it looks interesting enough, download and install it on a convenient host. If they really like it, they might start looking at themes, plugins and customizations. Which they can opt to share with the community.
This is something that should be encouraged in a helpful and positive way.
However, what happens if people don’t want to share with the community? They might want to keep their changes in house to start with, possibly distributing them at a later date.
Under the GPL, you are obliged to provide sources if you distribute binaries to anyone. So things like a packed distribution would include customizations. But since its a web based application, there is nothing forcing people to distribute it. The GPL doesn’t have practical enforcement (under version 2 at least) for changes made to a web application to be made available to the community.
Under BSD, you can do a lot more with the code. Including keeping your customizations to yourself, distributing packages as you like. There is a lot more freedom to do what you want with the code. Might as well start out with the code with more freedoms in place.
There is the GNU affero GPL which is a variant that ensures distributing of code for whenever a web application is made available to the public. It does provide for more freedom for the code, but less for the users to be involved in Open Source at their own pace.