Jonny Barnes.net

My little place on the web.

Last.fm to Spotify Play

Posted by jonny at - Short URL

Spotify recently announced their new Play Button. So I thought it'd be cool to incorporate it into my homepage. But what tracks should I have be played? Then I got the idea of using my Last.fm charts to generate the tracklist.

So first I had to grab my weekly track chart from Last.fm, thankfully they provide a nice xml feed which can be found at ws.audioscrobbler.com/2.0/user/[username]/weeklytrackchart.xml. I just used the cURL extension in PHP to grab the XML and the parsed it to grab the track names and artist names and store them temporarily in an array.

Now, for getting the Spotify track IDs so I can generate the play button. Thankfully Spotify has an open MetaData API that I can use to search for and retrieve the IDs. I took great influence from this PHP library called metatune. However, it does far more than I need, and it uses file_get_contents to query the API, which requires having allow_url_fopen set to true in my php.ini file. I'd rather use cURL, its faster and more versatile.

There is one caveat, searching Spotify normally leads to multiple results. I've assumed that the first track is the one I want. I then get this list of track IDs and save them to file. Its then just a question of reading this list and dumping it into the HTML of the homepage.

You can have a look at my code on GitHub, its not quite finished, I need to incorporate some sort of actual error handling.

Tags: blog php

News this week (12w15)

Posted by jonny at - Short URL

Oxford University and the Vatican are to digitize 1.5 million pages of ancient texts and make them freely available online. This has been made possible by a donation of £2 million by the Polonksy Foundation. This seems exceptional value. For all I may complain about the church, more freely available knowledge can only be a good thing and for that they have a little bit of my repsect. Though it will be interesting to see just how this is made available. This is still huge news though.

An 8.6 Magnitude earthquake struck near Indonesia on 11th April 2012. Thankfully it appears not to have cause a massive tsunami. The earthquake was a strike-slip earthquake so not too much water was displaced. I will be interested to see how the aftermath of this plays out and I hope things recover to normal as quickly as possible for those affected.

Woop! Looks like ACTA might not pass, it appears that the European Parliament will reject the legislation. This looks increasinlgy likely as the person in charge of taking the legislation through parliament is recommending that the bill be voted against. You can sign an Avaaz petition. Though depressingly it appears the powers that be are working on a replacement.

Anders Breivik, who set off a bomb in Norway and went on a shooting spree that killed 77 people, has been declared sane by a second psychiatric evaluation. This would mean he could stand trial for his crimes and face a jailterm. Though its still up for an actual court to find him legally sane or not. Though if insane he will be sent to a ward instead of a cell, either way the guy is facing life.

Yeah, more religious news, Kuwait are provisionally passing an amendment to their penal code which would allow the death penalty for cursing god. I mean, seriously! Come on! Surely if Allah is all-powerful he can look after himself? Unless this is the usual politicians using religion to pass laws useful for their own needs.

Liam Stacey was jailed for some of his tweets. Miss Coren wrote a superb piece on the matter. It really is something that we in the U.K. need to discuss. The Mayor of London recently stopped a gay therapy advert from being run on some London buses. What is allowed and what isn't? I personally feel people should be allowed to say what they want. As long as they aren't directly insulting someone in an overly aggressive manner or harassing people. What offends me may not offend someone else. We have to be careful as to what our law censors.

Tags: weekly.news

News this week (12w14)

Posted by jonny at - Short URL

The U.K. government has said it wants to monitor all web and e-mail activity to combat terrorism and crime. Though thankfully it appears the Liberal Demecrats might fight the bill. Though I don't hold up too much hope, they've turned on every other promise so far. The Guardian talks about this much better than I can. It is indeed a delicate issue, my only strong opinions are with regard to the internet, which is a force for so much good that I wouldn't want that affected, especially when you consider how non-effective any policy will be in dealing with actual criminals, just pipe everything through a VPN and bam, no government snooping! This is made clear in a story this week from Al Jazeera. Anonymous has hacked several Chinese government websites, the defaced websites then explain how someone in China can circumvent the government's restrictions on internet usage.

The internet really seems to be under attack from all sides. ACTA could pass in 10 weeks, perhaps we should try and do something. Will WW3 be people against their governments? We also have the return of SOPA, though this time it is known as CISPA. Though I'm not sure if the same resistance will be mounted against it by the Internet communities like Wikipedia or reddit. When will the people in power learn?

The I.C.C. says they cannot investigate alleged Israeli crimes in Gaza and the West Bank. They say that because Palestine is not an officially recognised U.N. member state they have not ratified the Rome treaty and therefore these 'crimes' are outside the I.C.C.'s jurisdiction. There is the possibility of the U.N. security council stepping in and giving jurisdiction, but with the U.S. on the council that isn't going to happen. What a sorry state of affairs this all is. I should try and do a post about the whole Israel/Palestine thing sometime.

Some good news from Tunisia, who say they shall reject Sharia law in their new constitution. And some bad news from Tunisia, who jailed two people for drawing cartoons of Mohammed. Religion cannot exist above the law. Of course people should be allowed to practice whatever faith they want in private. The intricacies of such religion cannot be part of the moral fibre that binds us all together. The law needs to protect everyone, especially those that otherwise might find themselves oppressed. This includes people's speech.

Again we have someone decrying the war on drugs. It really is time that politicians realised this. Prohibition doesn't work, it just forces drugs into the black market. So what if someone wants to take drugs. Its their body, its their choice. Hopefully with more people in power taking more moderate stances with regards to drug laws we may some change soon.

And finally, an Irish priest accidentally flashed gay porn during a presentation to parents of children preparing for their first Holy communion.

Tags: weekly.news

News this week (12w13)

Posted by jonny at - Short URL

Guatamala's president Otto Perez says the 'War on Drugs' has failed, and it is time to end the taboo on discussing decriminalisation. Perez thinks that decriminalisation could reduce the amount of drug-related violence. Whilst a complicated issue, there is evidence that this could be a good route. Portugal introduced a progressive drug policy some ten years ago. It is important to realise that information on drugs before this policy change is sketchy, but there are strong indicators of reduced HIV transmission rates and drug related deaths. The workload of the police decreased whilst the amount of drugs seized increased. Perez is right on one thing though. This is something we should be discussing.

Ontario's top court legalises brothels to protect prostitutes. The idea being that it is safer for prostitutes to work in a brothel where protection and security can be provided than in isolation. The situation before the ruling was similar to the situation in my home state the U.K. I agree with the ruling in Canada as I feel nothing will really change except for the improved working conditions of the prostitutes. We won't suddenly be handing them off as we walk down the street!

News surfaces that Murdoch's News Corporation promoted piracy in Australia. By damaging the competing network's pay TV offerings the allegation is that News Corp was able to subsequently corner the market. In case you didn't realise, this is the same News Corp that owned the News of the World newspaper in the U.K. that was ultimately discontinued due to a phone hacking scandal. Ahh, more bad news for Mr. Murdoch, it sometimes makes me wonder weather there is karma in the world, only briefly mind. Here's a Panorama video about the whole thing: http://www.youtube.com/watch?v=0clg2m-ePd0. There's even suggestions they undertook similar business practices in the U.K.

Pakistan is planning to punish parents who do not have their children vaccinated against polio. They plan to fine parents who don't get their kids vaccinated. This part of an effort to stop the spread of the debilitating disease. Pakistan is one of the few remaining countries that hasn't eradicated polio. I am glad that the government is seeing sense, though there are clearly many obstacles to overcome, particularly when the population can be very suspicious of vaccines and other western initiatives.

Denmark aims to get 50% of its electricity from wind power. They ultimately aim to get all their energy from renewables by 2050, a commendable goal. They, like most of us, lag behind Norway, where over 98% of electricity is from renewables. Countries like these are perfect in my opinion in testing and developing the technology required for alternative energy sources on a medium scale. This is going to be one of the toughest challenges the up and coming generation faces, what to do when the oil tap dries up?

French president Sarkozy announces that he will make it a crime to consult web sites advocating terrorism or hate crimes. This is obviously fuelled by the recent killings in Toulouse which was seemingly a terror crime. There is a question of exactly how the French government hopes to do this without unfairly breaching peoples right to privacy on the web.

And finally, Kazakh gold-medallist is shocked when the wrong national anthem is played. Instead of the proper tune, a parody Kazakh anthem made for the film Borat is played instead. Just how lazy was the person responsible for this?

Tags: weekly.news

Can Scotland be independent?

Posted by jonny at - Short URL

Unless you've been living under a rock I'm sure you've no doubt heard that Scotland want independence. Well, the SNP wants an independent Scotland. They currently hold a majority of seats in the Scottish Parliament. Mr. Salmond, leader of the SNP, believes that this gives him a mandate to try and get independence, seeing as this was the idea they ran their election hopes on.

Personally I would be sad to see Scotland leave the United Kingdom. I feel that both Scotland and England have benefited greatly from the partnership. In the long run I feel we are better united than divided. Putting this aside I think there are serious questions that need answering before Independence is ratified.

Mr. Salmond's SNP has said that Scotland would continue to use the Sterling as its currency. This poses certain issues with regards to financial sustainability in my opinion.

First let's consider the U.K. as it currently stands. We are a sovereign state with our own central bank, namely the Bank of England. The central government, located in Westminster, handles the fiscal policy. They decide how much public debt we have. It is important to note here that this public debt is denominated in Sterling. We have an unlimited supply of Sterling. In theory at least, the Bank of England can just 'print' off as much money as is necessary. Obviously this leads directly to inflation and is therefore not the best way to pay off debt. It helps nobody. The point is, however, that the option of simply inflating our way out of debt is there. So technically speaking the U.K. cannot default. Being unable to default makes a government a very safe investment, we shall ignore the situation in the eurozone. Financial institutions with money, e.g. pension schemes, private banks etc., therefore like investing their money in governments. This point is acutely made when we look at the interest rates on U.S. debt. They have real negative interest rates. People are paying America in order to lend America money!

If Scotland leaves the U.K. and remains on the Sterling currency they will be in a position where they take on debt in a denomination they have no control over. They cannot simply inflate there way out of tricky situations. Yes, that last sentence does grossly oversimplify things; but look at the eurozone. The smaller countries are suffering and their situation is in no way being helped by being on the Euro. Greece are the prime example of this. Their economy is not competitive and with the demands being put on them by the rest of the eurozone they are genuinely suffering.

This is the kind of situation Scotland could see themselves in. Staying on Sterling hinders their ability to influence the bond market. So called because if I lend money to a state, they then give me a bond with an interest rate and a maturity date. They have effectively sold me a bond, or debt if you want to call it that. Thus we have the bond market. This is a free market. A government does not decide the interest rate they pay on the debt. The people buying the bonds do. That's how free markets work. If investors think Scotland may default, they won't buy debt unless they get a satisfactory interest rate. If we look in the eurozone we can see the political pressure this is putting on countries like Spain and Italy. An effective tool against this is to buy up some of the debt with the central bank. This doesn't solve any problems directly, it merely delays having to deal with it. If you can get your economy to grow in the meantime you may be able to solve it later.

This is why politicians are always harping on about economic growth. With a bigger economy you can support more debt, which allows us to service the debt we have now. It may seem a weird idea, but that's how our government debt works. Its a bit like musical chairs, though we have seen over the last few years what happens when the music stops playing.

I am simply suggesting that the ability to service debt through the bond market will be of the utmost importance in questioning whether Scotland can exist independently. This is something I think will be made harder by Scotland either staying on the Sterling or joining the Euro.

It is not a question that I am seeing asked.

Tags: politics

« Newer posts Older posts »