Wednesday 23 March 2011

Disabling Adverts in Spotify on Ubuntu Linux

Ok .. this is completely unrelated to my Solr stuff.
But - I wanted to share this useful snippet.

(NB)

* This does not actually disable the adverts - it simply mutes the volume for approximately the same time as a spotify ad lasts.
* Its not an automatic solution - Its only really useful if you are listening to spotify whilst you are sitting at the keyboard.
* It works for me!

The reason I wrote this is because some of the Spotify adverts were

* Not relevant to me ( I am most definitely not interested in Tiny Tempah )
* Really irritating (Go Compare / Compare the Meerkat)

So I could have ponied up and gone for the subscription , However there are a few reasons for this.

* My spotify usage is not really very high. (I have my entire CD collection already ripped and sitting locally)
* The Linux version is not up to scratch i use the Windows version through Wine.

I might re-evaluate this at some point in the future - this is how it is now.

So heres how it works

I created a small Shell script to mute the volume for 45seconds , and then bring it back up again.
The script for ubuntu is as follows.


#!/bin/bash

pactl set-sink-mute 0 yes
sleep 45
pactl set-sink-mute 0 no


Save this script somewhere ( eg ~/mute.sh )
make it executable
#> chmod u+x ~/mute.sh
Now you are going to create a custom keybinding in Ubuntu
Go to 
System -> Preferences -> Keyboard Shortcuts
Click "Add"
you will get a pop-up window asking for an name and command
Call it  "MuteVol1Min"
and set the command to "~/mute.sh" (or wherever you saved the script)
Click Apply
Finally you need to bind it to a key combo.
click on the "shortcut" column next to the custom shortcut you just created.
I bound mine to the windows key + pause/break key - that comes up as Mod4+Pause.
You could choose the same combination - or try something different.
To use it - as soon as you notice that an advert comes up hit the key combo - sound will mute and come back up 45seconds later after the advert is finished.
Its not perfect but it works well for me as im usually listening and coding at the same time.
Hope this helps someone
N...

Tuesday 22 March 2011

Installing SOLR on EC2

Detailed below are my steps for installing Solr on EC2 with Ubuntu

Before we go any further , i would like you to note that I am making the assumption that 
you have already signed up for Amazon Web Services and you have also downloaded the command line tools.

If you are not there yet then you are going to have to follow the following resources 
before going any further.


* Install the command line tools https://help.ubuntu.com/community/EC2StartersGuide

Once you are ready please continue.

As of now Lucidworks do not provide an AMI for installing Solr outside of the US.
I am going to need to create my own AMI to solve this problem.
Fortunately this is a fairly simple task - especially if you use the nightly build.

You will need to start by creating a new instance.

Using the ec2 command line tool "ec2-run-instances" fire up a new EC2 Instance based off Ubuntu
The format is as follows

ec2-run-instances AMI-IMAGE-ID --instance-type INSTANCE-TYPE --region eu-west-1 -k AMAZON-KEY

For the purposes of the demo i am using a t1.micro just so we can get the hang of the process. In no way am I recommending that you run the whole SOLR stack on a t1.micro - that's crazy talk. Personally I wouldnt recommend anything lower than a m1.large for production unless you have a very specific use case. eg: very low traffic, very small document set. (Please evaluate sphinx to make sure SOLR is right for you - life might get a lot easier ) Anyhow..

to determine the AMI you wish to use you can query AWS using "ec2-describe-images"
eg


#> ec2-describe-images --region eu-west-1 --all | grep 'ubuntu'


There are plenty of AMI's to choose from so pipe the output into grep to help search for the one 
you are looking for. Or just choose the same one as me. Pick one with "ebs" store you will need this especially if you are testing out a micro instance. The AMI id's are listed in the second column.

Once you are ready to roll issue the following command to fire up the instance...





#> ec2-run-instances ami-e974439d --instance-type t1.micro --region eu-west-1 -k myAWSkey
When this has completed output on the command line will contain the id of the instance you have just fired up. You will now use this information to get the public DNS of the instance. (This is needed so you can log into the VM)

The standard ubuntu instances can be accessed through SSH. 

#> ssh -i /etc/aws-keys/YOUR-AWS-KEY.pem ubuntu@your.public.aws.dns.eu-west.compute.amazon.com
From here on in you are in a standard ubuntu install - so you can go ahead and configure it how you might need. However for our purposes we are just going to set up a search user and place the latest SOLR nightly there for further usage.

#> sudo useradd -d /home/search -m search
Now lets go to that newly created folder and install the nightly

#> sudo useradd -d /home/search -m search
#> cd /tmp
#> wget http://mirror.lividpenguin.com/pub/apache//lucene/solr/1.4.1/apache-solr-1.4.1.tgz
#> gunzip apache-solr-1.4.1.tgz
#> tar -xvf apache-solr-1.4.1.tar
Now lets move it to the search users folder

#> mv /tmp/apache-solr-1.4.1 /home/search

Before we can run Solr for the first time - you will need to install JAVA

#> sudo apt-get update
#> sudo apt-get install openjdk-6-jre-headless
If you have any problems with the install failing try again adding --fix-missing
Thats basically it for now you can  run solr by issuing the 
following command

#> sudo java -server -jar /home/search/apache-solr-1.4.1/example/start.jar
Of course, right now this isnt going to be of much use to you! 
But it at least gives you some steps to go through in order to get a Solr server up and running on EC2.

If you have been following my other posts , or maybe you have a Solr set-up from the nightlies running in a development sandbox. You could quite easily zip up the entire folder and install it on the instance by using "scp" to copy it up - and then follow the rest of the steps.

I hope this helps get you started.

I will probably be doing a follow-up post on this tommorow , so keep posted and let me know if you have any issues.

N.


Wednesday 2 March 2011

Solr : last_index_time -- explained

There seems to be some confusion about what solr's "last_index_time" means.

This is a fairly important thing to understand when setting Solr up to do its Delta Updates.

Solr's last_index_time holds the timestamp that is used to determine the last time an indexing operation STARTED,  not as some people believe when it ended.

When performing updates this value is usually used in the delta query to select records which have been modified or updated since the last indexing operation begun.  It is critical to ensure that there is no timeframe window between the "last_index_time" when doing your first full-import and your scheduled updates. Otherwise this could cause you to have some documents missing from your index.

N...