Tag Archives: Technology

All things hardware, software, and all grey areas in-between.

Installing Redis 2.6.x on Ubuntu 12.04 and running with an ‘init’ script.

Documented here are steps to getting Redis 2.6.x running on Ubuntu 12.04 onwards using an init script (previous versions of Ubuntu should work too). The setup is intended to be used on a developer desktop/laptop rather than production infrastructure.

As ever, first download and unzip Redis from here.

cd /tmp
wget http://redis.googlecode.com/files/redis-2.6.9.tar.gz
tar -zxf redis-2.6.9.tar.gz
cd redis-2.6.9
make
sudo make install

Your Redis binaries should now be located in /usr/local/bin.

To get an init script and Redis config working cleanly with this setup, download my init and config files from my Github ‘dotfiles’ repo. My init script and redis.conf are pretty standard – intended for general development purposes.

wget https://github.com/ijonas/dotfiles/raw/master/etc/init.d/redis-server
wget https://github.com/ijonas/dotfiles/raw/master/etc/redis.conf
sudo mv redis-server /etc/init.d/redis-server
sudo chmod +x /etc/init.d/redis-server
sudo mv redis.conf /etc/redis.conf

Before you can fire up the Redis server for the first time, you’ll need add a redis user and prep a data and logging folder.

sudo mkdir -p /var/lib/redis
sudo mkdir -p /var/log/redis
sudo useradd --system --home-dir /var/lib/redis redis
sudo chown redis.redis /var/lib/redis
sudo chown redis.redis /var/log/redis

Also, you need to activate your Redis services init script by adding it to your system’s run-level configuration. That way the service will startup during the boot sequence and stop nicely during the OS’ shutdown procedure.

sudo update-rc.d redis-server defaults

You’re now ready to launch Redis server with

sudo /etc/init.d/redis-server start

Good luck!

Installing MongoDB 1.8.1 on Ubuntu 10.10 & 11.04 and running with an ‘init’ script.

Installing MongoDB 1.8.1, in my case as a developer database, is easy. This blog post just itemises all the steps so that you can pretty much blindly follow along. I’ll probably use these steps myself as I seem to be doing this regurlarly ;-)

Download the 64bit Linux binaries from here and unzip the contents to /usr/local.

cd /tmp
wget http://fastdl.mongodb.org/linux/mongodb-linux-x86_64-1.8.1.tgz
sudo tar -zxf /tmp/mongodb-linux-x86_64-1.8.1.tgz -C /usr/local

Setup some symbolic links.

sudo ln -s /usr/local/mongodb-linux-x86_64-1.8.1 /usr/local/mongodb
sudo ln -s /usr/local/mongodb/bin/bsondump /usr/local/bin/bsondump
sudo ln -s /usr/local/mongodb/bin/mongo /usr/local/bin/mongo
sudo ln -s /usr/local/mongodb/bin/mongod /usr/local/bin/mongod
sudo ln -s /usr/local/mongodb/bin/mongodump /usr/local/bin/mongodump
sudo ln -s /usr/local/mongodb/bin/mongoexport /usr/local/bin/mongoexport
sudo ln -s /usr/local/mongodb/bin/mongofiles /usr/local/bin/mongofiles
sudo ln -s /usr/local/mongodb/bin/mongoimport /usr/local/bin/mongoimport
sudo ln -s /usr/local/mongodb/bin/mongorestore /usr/local/bin/mongorestore
sudo ln -s /usr/local/mongodb/bin/mongos /usr/local/bin/mongos
sudo ln -s /usr/local/mongodb/bin/mongosniff /usr/local/bin/mongosniff
sudo ln -s /usr/local/mongodb/bin/mongostat /usr/local/bin/mongostat

The first “ln -s” above sets up a handy symbolic link between the versioned mongodb folder and its unversioned counterpart. When 10Gen release updates, say version 1.8.2, all you need to do is download, unzip, and link the ’1.8.2 mongodb folder’ to the unversioned folder and ‘hey presto’ everything should just work.

To get an init script working cleanly with this setup, download mine from my Github ‘dotfiles’ repo. Please note – my init script enables journaling and the REST interface (on line 51).

wget https://github.com/ijonas/dotfiles/raw/master/etc/init.d/mongod
sudo mv mongod /etc/init.d/mongod
sudo chmod +x /etc/init.d/mongod

You’ll need to add a mongodb user and prep some folders

sudo useradd mongodb
sudo mkdir -p /var/lib/mongodb
sudo mkdir -p /var/log/mongodb
sudo chown mongodb.mongodb /var/lib/mongodb
sudo chown mongodb.mongodb /var/log/mongodb

Also, you need to activate your MongoDB service’s init script by adding it to your system’s run-level configuration. That way the service will startup during the boot sequence and stop nicely during the OS’ shutdown procedure.

sudo update-rc.d mongod defaults

Lastly to launch MongoDB

/etc/init.d/mongod start

Good luck!

UPDATE: Since April 6 Ubuntu now has prefabbed packages containing MongoDB 1.8.1, maintained by 10Gen. See the instruction below.

Announcing TechMeetup Glasgow

Tech Meetup is coming to Glasgow on April 22nd.

TechMeetupThere are a ton of events for entrepreneurs to meet investors and bankers and VC’s but let’s face it, we’re tech, so let’s talk about tech. No name badges, no business models, just the growth of our eco-system and the advance of our tech – be it web apps, software, mobile apps, hardware, games… There’s an overlap across many of these and it’s always interesting to hear what people are hacking together, know about or have worked on before.

TechMeetup is just that – a space for everyone to meet up, talk about some of the cool stuff we’re doing, or get help on our projects from others.  It’s been running in Edinburgh for several months, with a good turn out, nice folks and great speakers – held together with the magic of pizza and beer.

On the 22nd April, Tech Meetup Glasgow will start and it’d be great to have you along.  Three excellent speakers are lined up, covering a variety of topics – from running a ticketing startup, to an introduction to developing for Android. Kick-off is at 7pm in Room M329 of the James Weir building on Stratchlyde University’s campus.

With your help and feedback, we are going to work hard to make this functional for everyone around us – a monthly event to allow you to share news, demo the technologies and projects that excite you, meet people with complimentary skillsets that may want to help out, and generally get to know others in the tech community.

So if that sounds good to you, be great to see you there.  Bring yourself, your experiences and your opinions with you.

Sam, Ijonas & Heidi.

Lastly, visit our site http://www.techmeetup.co.uk for a backgrounder on TechMeetup including past talks.

Event: TechMeetup Glasgow
Date & Time: 22nd April 2009 – 7pm (the pizza is delivered then)
Directions: (lift to 3rd floor) Room M329, James Weir Building, Strathclyde Campus, 75 Montrose Street, Glasgow.
Here’s the Google Streetview
And here’s the Google Maps view.
And here’s the iCal entry to stick in your calendar.
Contact:
o.s.collins@gmail.com
ijonas.kisselbach@gmail.com
heidi@sauceandvinegar.com
or twitter: @techmeetup

Storing URIs in SQL Server 2008 using the HIERARCHYID datatype and LINQ-To-SQL

I’ve been playing around with SQL Server 2008 CTP, exploring the benefits of the new HIERARCHYID datatype, which has been designed to efficiently store depth-first tree structures in SQL Server 2008.

My requirements were to store URI paths such as ones you might find in URLs, whereby each path component is held as a separate record in a table. Each path component refers to a folder in file system, e.g.

URL: http://www.vamosa.com/index/information_solutions/technology_and_products/vamosa_content_migrator.htm
URI: path: /index/information_solutions/technology_and_products/vamosa_content_migrator.htm

So traditionally in the database I would end up with parent/child relationship as such

id 	label					parent_id
0	NULL					NULL		<--- root element
1	index					0
2	information_solutions			1
3	technology_and_products			2
4	vamosa_content_migration.htm		3

HIERARCHYID allows you to perform all sorts of fast hiearchical queries without having to wander up and down the parent/child foreign key relationship. Those are the benefits, however there’s a problem…

At the time of writing the .NET Framework 3.5′s System.Data.SqlTypes namespace does not provide any support for HIERARCHID datatypes, e.g. SqlHierarchId as a class is missing, meaning that if you want to work with the new type you’ll need hide it from your .NET code using stored procedures, and that’s the approach I’ve taken in this post.

The other thing to be aware of is that the HIERARCHYID column is not a foreign key to a record further up the tree. The HIERARCHYID column stores position of the current record within the tree, e.g.

id  	label					hierarchyid_field.ToString()
0	NULL					/		<--- root element
1	index					/1/
2	information_solutions			/1/1/
3	technology_and_products			/1/1/1/
4	vamosa_content_migrator.htm		/1/1/1/1/

The table I’ve created is called URI and is defined as follows:

CREATE TABLE dbo.URI
(
	Id uniqueidentifier NOT NULL,
	Label nvarchar(256) NULL,
	UriHID hierarchyid NOT NULL,           -- the magical new datatype
	CONSTRAINT [PK_URI] PRIMARY KEY
)

I want to be able call my stored proc as follows:

  MyLINQDataContext db = new MyLINQDataContext(); // a previously defined context via .dbml file
  System.Guid? uri_id=null;			  // variable to capture the URI.Id of the last node inserted
  db.InsertURI("/products/vcm/index.html", ref uri_id);	// call to stored proc
  Console.Out.Writeline( uri_id );		 // doing something useful with the return result

Stored procedures aren’t my strongest point by a long stretch so feel free to comment and improve the code, but here’s the InsertURI stored proc:

CREATE Procedure InsertURI
	@uri nvarchar(4000),
	@uri_id uniqueidentifier OUTPUT
AS
	declare @root_uri_id uniqueidentifier
	declare @path_remainder nvarchar(4000)
	declare @pos_slash int
	declare @parent_uri_hid HIERARCHYID

	set @parent_uri_hid = HIERARCHYID::GetRoot()

	-- ensure the root exists
	select @root_uri_id = u.id from URI u where u.label is null
	if @root_uri_id is null
		insert into URI values (NEWID(), NULL, @parent_uri_hid)

	set @path_remainder = @uri
	set @pos_slash = charindex( '/', @path_remainder )
	while (len(@path_remainder) > 0)
	begin
		declare @next_slash int
		declare @uri_label nvarchar(256)
		declare @current_uri_hid HIERARCHYID
		set @next_slash = charindex( '/', @path_remainder, @pos_slash+1 )

		-- determine the next label in the sequence of depth-first node names
		if @next_slash > 0
		begin
			set @uri_label = SUBSTRING( @path_remainder, @pos_slash+1, @next_slash - @pos_slash - 1 )
			set @path_remainder = substring( @path_remainder, @next_slash, len(@path_remainder) )
		end
		else
		begin
			set @uri_label = SUBSTRING( @path_remainder, @pos_slash+1, len(@path_remainder) )
			set @path_remainder = ''
		end
		set @pos_slash = charindex( '/', @path_remainder )
		-- determine if current @uri_label exists as child of @parent_uri_hid
		set @current_uri_hid = NULL
		select @current_uri_hid = u.UriHID from URI u where u.UriHID.GetAncestor(1) = @parent_uri_hid and u.Label=@uri_label
		if @current_uri_hid is null
		begin
			-- the label doesn't exist as a child, hence create it
			-- first determine the new hierarchyid - new node will be last in row of siblings
			declare @last_child_uri_hid HIERARCHYID
			SELECT @last_child_uri_hid = MAX(UriHID) FROM URI u WHERE u.UriHID.GetAncestor(1) = @parent_uri_hid
			set @current_uri_hid = @parent_uri_hid.GetDescendant(@last_child_uri_hid, NULL)

			set @uri_id = NEWID()
			insert into uri values (@uri_id, @uri_label, @current_uri_hid )
		end
		set @parent_uri_hid = @current_uri_hid
	end

The stored proc takes the @uri string and chops it using the ‘/’-separator (orange highlighted), looping through each element in the path (red brown highlighted), first ‘index’ then ‘information_solutions’, etc. For each element it will check wether or not the element exists (red highlighted code), creating it if necessary (purple highlighted). The position of the new node will always be on the ‘far right’ of its siblings (green highlighted code).
 

 

Joe from Flixster is plain wrong.

Robert Scoble says:

Joe from Flixter denotes why this is SO HUGE: his app will run anywhere that the OpenSocial platform is running. Plaxo. Ning. NewsGator. MySpace. No rewriting of apps.

The Open Social announcement is an equivalent to Sun announcing Java in the mid-nineties… The big promise back then was write-once run-everywhere… Java never became the major success for writing end-user apps that Sun had dreamed off, so the jury has to be out. Hopefully the Open Social API designers will keep Java’s history in mind as they take their technology forward.

MS Windows users don’t care whether Mac users can run AutoCAD. Similarly Bebo users won’t give a damn whether or not Facebook or Ning users can run Flixster…. unless Bebo users can share the Flixtser data, their movie reviews, with their friends on other sites.

Google’s Open Social –> move along, nothing to see

So there we have it… Google has made a big splash into the social networking arena. Open Social is its name and helping widget developers is its game.

Great news for developers, but no news for users of these sites.Robert Scoble is raving about it something rotten on twitter and his blog, like a surfer riding the big kahuna… I love his excitement but I can’t share it.

End users now get the same “virus apps” spreading across multiple social sites (MySpace, Ning, Hi5, etc) because these apps are can now be built atop the same APIs. The problem is the data remains stuck within the “container”, i.e. the social network site and cannot cross the boundary to another site. For example, the developers of Flixster can now write a single app for all social network sites using the Open Social APIs, however I couldn’t share my Flixster data on Hi5 with my some of my friends on Bebo, eventhough the same app would be available.

Marshall Kirkpatrick hits the nail on the head by saying that Open Social should really be called Open Widget, as it more aptly defines the problem it trying to solve.

Open Social helps developers write apps for multiple platforms. Open Social does nothing to help users connect across multiple platforms.

Soup.io –> Microblogger or Content Aggregator

Soup.io is a great new web app coming out of the YEurope oven. In short its a little bit of microblogging mixed up content aggregation from other sites such as flickr, twitter, delicious, and in my case WordPress.com (there’s more take a look).

There’s already some chat in the blogosphere comparing it’s microblogging features to twitter and pownce.Soup.io lacks the immediacy of twitter and its desktop & SMS entrypoints, but that’s ok by me.Soup.io to me is a wonderful way to aggregate the content that I’m producing through various web apps, which I would consider “best-of-breed” or more likely “works-best-for-me”.

My flickr stream gets mashed up with my tweets and delicious discoveries – all wrapped around with my rather wordy ramblings on WordPress and presented by to the world via either a nicely templated website or a singular RSS feed.The “cherry on top” is the ability to point a domain such as www.ijonas.com at soup.io and all of a sudden, all of that content is presented through single page on the web.

Once again, open standards are enabling production as well as consumption of content on the internet. In this case I can try out any RSS-enabled service such as Pownce, take the RSS feed my content generates and wire it into my soup.io page. If I stop using the Pownce service, no problem… my soup.io mashups lives on.

So to me soup.io serves me better as aggregator than a microblogging tool. I’m a little confused by their offering of functions that allow you to post messages, pictures, and videos… IMHO the soup.io developers should expand on the site’s ability to aggregate content from more sources and improve the already great look-and-feel customisation/templating features.

soup.io –> recommended!

Former FEMA Chief Michael Brown has a new job sells Snake Oil

This is funny because its classic case of desigining a black magic product thats scans all the databases in the world in-place using its adaptable plugin modules that enables it to extract hidden terrorist messages from your mum’s recipe spreadsheet in her Documents folder and correlate with credit card spending in Indonesia, via the included plugin module that sits atop of the VISA global credit card database.

My favourite line in the pitch is…. and I guarantee that I’m not taking it out of context:

because its distributed, its totally secure

Nuts! As someone working for a company where writing connectors into external systems is a constant drain on development resource, leaving data in-place is not a guaranteed best practice.

Still goes to show… You could be building complete and utter nonsense and get a discredited person like Michael Brown to sell it as snake oil.

Oh what a world….

[podtech content=http://media1.podtech.net/media/2007/08/PID_012101/Podtech_Michael_Brown_on_InferX.flv&postURL=http://www.podtech.net/home/3766/former-fema-chief-michael-brown-on-data-mining&totalTime=832000&breadcrumb=18aaed5837da4ebead6f094f122e0d88]

Polar CS300 weblink software, polarpersonaltrainer.com and Mac OS X

Polar CS300 Cycling ComputerI’m noticing quiet a lot of search results hitting this blog, looking for ideas on how to integrate the Polar CS300 and your trusty old Mac… in my case a MacBook Pro.

Well, I’ve got it working but it isn’t the most elegant of solutions… First of all there is to my knowledge no OS X version of the Polar software, therefore I’ve had to employ the following…

Ingredients

  • 1x copy of Parallels Desktop for Mac (installed on your Mac)
  • 1x copy of Windows XP (installed inside Parallels)
  • 1x Mac Book Pro
  • 1x Polar CS300 watch
  • 1x Polar WebLink SW software installed (installed on Windows XP)

The Polar CS300 computer setup uses a PC microphone to transfer and convert the data held on the watch. The great thing about Parallels is that it comes with microphone support, meaning the Windows environment running inside Parallels gets to hear what’s happening in the outside world.

So all you need is to setup the ‘ingredients’ listed above. Then:

  1. Launch Parallels with Windows XP.
  2. Once your inside Windows launch the WebLink SW software providing the details as per the Polar manual. At this point place the software in transfer mode so that its listening out for data.
  3. Now grab your CS300 and activate ‘Connect’ mode, choosing ‘Send’… SonicLink will start squelching all sorts of little sounds.
  4. Quickly place the watch on top of the microphone. In the case of the MacBook Pro, the microphone is underneath the speaker grill to the left of your keyboard.

If you run into any problems, go ahead and use the comments section below… I’ll see if I can help.

Balance – From the Country to the City and back again.

PopTech logo.I found myself drawn into Stewart Brand’s presentation on environmentalism and urbanisation…

He makes some really interesting points on how the environmental- or eco-movement will change over the next couple of decades. The movement will change from a grassroots “nice-to-do” group of Western Industrialised tree-huggers and idealists to a global phenomenon of not just romanticised activisim but cold-hard-fact-based politicking. This change will be brought on by two things. Firstly the internet will enable global organised communication to even the remotest parts. Secondly, day-by-day science is improving the knowledge we have of our own planet and how it is changing. So yesterday’s “moral” debates will turn into debates backed up by stats, that can be proved/disproved with proper scientific rigour.

The second interesting assertion he makes is that global population growth will tail off in the next couple of decades due to, of all things – urbanisation. This year 50% of the Earth’s population will reside in cities (as opposed 3%, 200 years ago). As people move into the cities, women stop having as many children, and this has a profound exponential effect. As one woman decides not to have kids, that “burdon” falls on the next woman who needs to have . Populations get older and aren’t replenished with “new stock”.

All very interesting stuff… recommended!!!