Setting up Samsung 840 EVO SSDs on Linux

The Samsung 840 EVO SSD is a bit tricky to set up so here are some notes on the process.

Update the firmware

I first tried creating a bootable USB stick using Samsung’s .iso and unetbootin. This didn’t work, it threw an error “PANIC: mcb chain corrupted”. Then I found a great post which described how to use the standard FreeDOS to get it to work. After the update was complete the application warned “FIRMWARE UPDATE UNSUCCESSFUL!!!” although it had actually worked correctly 😀

Partition alignment

Apparently, it’s quite important to align the partitions, especially on SSDs. If it’s wrong the disks can perform poorly and wear out more quickly. This disk uses a new technology (TLC) which has an unusual erase block size of 1536kb. I can’t find anywhere online which explicitly says to use that as the value for the sector boundary, but I guess it would be OK.

I did find a question about aligning the partitions for these disks which explains how to use gdisk to do it. The answer suggests to use the lowest common multiple of 1.5 and 2 to be on the safe side: 6MiB. In brief, you use `gdisk /dev/sdX`, hit “X” for expert mode, “L” to set the sector alignment, and use 6144 as the value. Hit “m” to return to normal mode. Now “p” will show “Partitions will be aligned on 6144-sector boundaries” so you’re ready to create new partitions.

I also created a BIOS boot partition, since my machine uses BIOS rather than UEFI following the instructions from the Arch Linux wiki.

Command line xml queries for Plone configuration using xmlstarlet

One of the nice things about having declarative configuration in xml files is that you can use standard xml tools to do interesting things with them. XMLStarlet is a handy command line tool for manipulating xml. For a migration from a Plone 3 site to Plone 4 I wanted to check some things e.g. Portlets Generic Setup syntax changes explains that the use of the “for” attribute in a portlet element is deprecated. I would like to know if we have any Generic Setup xml with a portlet element which has a “for” attribute:

$ xmlstarlet sel -t -m //portlet[@for] -c . some.xml

This uses the XPath expression “//portlet[@for]” to select any >portlet< elements which have a “for” attribute. It returns a copy of any elements which match. Let’s combine this with find:

$ find . -name "*.xml" -exec xmlstarlet sel -t -m //portlet[@for] -f -n -c . -n {} \;

Here we also output the filename with “-f” and add a few newlines to make it easier to read “-n”.

You will often need to set the namespace too:

find -L . -name "*.zcml" -exec xmlstarlet sel -N x="" -t -m //x:vocabulary -f -n -c . -n {} \;

This can easily be adjusted for more complicated queries. The interesting parts are the XPath expression and if you want a copy of the whole matching element you can use “-c .” as above, if you want the value you can use “-v”. See for more info.

A nice tutorial:


To print the value of an attrtribute you can use -c “string(@attrname)”

<?xml version="1.0"?>
  <name>John Doe</name>
  <phone type="home">555-1234</phone>
  <phone type="work" class="emphasis">555-9876</phone>
xmlstarlet sel -t -m "//contact/phone[@type='work']" -c "string(@class)"  test.xml

The Free Software business model … and how it could save the world?

To me, the most interesting Free Software business model is where people who are interested in a project contribute money directly to the people who work on it. Some equate this with “Tipping” and don’t see it as sustainable. I’m inclined to believe it’s something quite different.

From time to time I daydream about lofty topics such as politics and economics. Fields I have no qualification in, and truly know very little about. I shape my opinions from random chats on irc and the occasional stroll around wikipedia along with the odd series of lectures generously provided by universities as podcasts. In rough terms, my understanding is that the Left aims to protect the weak by distributing wealth and resources and the Right aims to protect the strong by letting everyone fight for their own position.

The Left claims to support the cause of the downtrodden Working Class. According to the literature, the Working Class are kept in their place by the rich elite who pay the workers as little as they can. The logic goes that if people were to organise themselves there would be no need for this upper class at all because the resources would be pooled. This would greatly improve efficiency since there would be no need for “wasteful” competition. There would be so much more to go around that the majority would have to work less and less and be able to enjoy all the benefits of the shared effort in their free time.

The Right claims that people are hampered by high taxes which are being wasted to keep l
azy people comfortably housed and clothed. I guess they also believe that there is some kind of natural order in society and that without wealthy people ruling over the lazy masses there would be chaos. I often wondered why the right has such a strong following among poorer people, since it would seem that they stand to benefit the least from a hierarchical society ruled from above. I can only conclude that the leaders of the Right just take advantage of the poor education and desperate situation of the poor and manipulate their fears and prejudices to gain support.

Central politics seems to be what people mostly vote for and presumably want. People want to have some security i.e. they won’t starve if they loose their jobs and that they will be able to see real benefit in proportion to the amount of effort they put into their careers. Naturally, some people abuse the social welfare system to be lazy and some abuse the economic and legal system to get rich. Both at the expense of the majority of people who contribute to the system.

We’re in an interesting economic situation at the moment which seems to have left people feeling helpless, and misled. Not so long ago, everyone was going crazy trying to invest in property. I looked into it myself too, but luckily I found the idea of paying so much interest to the banks for such a long time unappealing. If I hadn’t been so stingy I would have paid for a flat with money I didn’t have, and at this stage I’d probably be bankrupt, and the taxpayer would be paying off my debt to the banks so that they don’t lose their own savings. But it begs the question, who’s to blame? An awful lot of normal people participated in the mania, driving the prices up as they went. It’s all very well to blame the bankers, but if they didn’t have such eager customers things wouldn’t have gotten so exciting.

I love the welfare state because it gives us a reasonably fair shot at getting any position we want in society through hard work, and we are supported if we are unlucky or unsuccessful. We have a (very small) say in the political system but we are free to choose how we spend most of our money and therefore responsible for the businesses we support. If everyone took their money out of the banks and put it into credit unions instead then the banks would go out of business and that would be that.

Some say the greedy rich are to blame and we just need to tax them more to even things out. There is no doubt that they’ve been making the most of the situation and rewarding themselves with generous bonuses to boot. Capitalist economists argue that this will cause growth to slow because there will be less capital available for investment. The idea here is that the small group of ridiculously rich people have that money because they are talented at making money i.e. they invest in “successful business ideas” which work, create jobs (as a side-effect) and allow them to accumulate more wealth. Since these people create jobs for the masses, the wealth they generate trickles down eventually. Capitalist economists believe this is how it should be. Perhaps they would concede to some regulations here and there to make the act of “making money” be somehow related to providing real jobs rather than simply playing a game in which they make the rules, which they can’t lose, with our money.

So that’s about as far as my understanding goes of how our politics and economics work. Now for Free Software business models as I understand them. There are quite a few and some have already proved themselves well. For niche custom applications it seems to make a lot of sense to share a core set of libraries freely and improve it collaboratively since the developers can include improvements to the core system as part of the cost of creating the custom applications. Everyone wins, everyone gets paid, the solution the client has invested in is constantly improved, they have a selection of providers etc. The Plone Content Management System is a nice example of such a project that is very close to my own heart (and wallet).

Other business models that are working well for free software are the sale of secondary services such as customer support, and advertising. While these do generate revenue, it’s not really very exciting. The less established business model which interests me relates to applications which are consumer oriented. Why would a consumer pay for something which they can have for free? Why would a developer ever work on some boring application that needs to be updated regularly e.g. for doing tax calculations? Many projects have experimented and the voluntary subscription/donation business model seems to be having some success. Ardour (Digital Audio Workstation) earns enough to pay the lead developer to work on it full-time (although not nearly as much as he deserves) and Mandriva (Linux Distribution) has been doing something like this for many years. Blender (3D) has it’s own very interesting spin on this, the project asks the community to regularly pay for a movie or game before they create it, the money is invested directly into the improvement of the software so that this movie or game can be realised. The latest project, Sintel is only a few months away from being released, and the whole community is very motivated and excited about it, watching every step and even helping create some of the content in a series of sprints. Recently had such enormous success by allowing people to pay as much as they wanted for a collection of their games that they decided to release the source code for them.

The implications of this on the economy could possibly be enormous. By donating to these projects you aren’t “giving away” to a charity to improve the lives of the less fortunate. You are in fact investing in the improvement of the services which effect you directly, as well as everyone else. Through the magic of the internet the masses have become the investors. I see no reason why this should only apply to software. There are open hardware projects e.g. Arduino and lots of creative commons music e.g. Jamendo, Dogmazic. Masses of people could just as easily invest in big-budget movies, games, space ships, whatever.

What is in it for people to invest in something they could get for free? Surely the greedy, who take whatever they can get and give nothing back stand to benefit from such an economy. Could it be that it would be embarrassing to be noticeably more wealthy than your peers because it insinuated you didn’t contribute enough? The less you contribute means the less influence you have, and it’s just much less fun. The Blender example is a particularly good one. It’s such an incredible joy to feel part of the process. To know that because you and enough other people contributed a little money there’s a team of cool people working really hard at something they love, creating something amazing and beautiful to share with the whole world. It’s just not so much fun to pay for a cinema ticket or even to download illegally without paying at all.

Such a culture would have no reason to represent the greedy in an appealing manner. Culturally, the greedy would be worthless and perhaps that alone is enough of an incentive. Could it go further? Would people invest in the social welfare system or health system etc. voluntarily instead of being forced to pay tax? What’s the big difference? Through hard work and violent struggle our ancestors created a free society for us to inherit. They didn’t create taxes to oppress us, they created taxes to support us. We created taxes for ourselves, why don’t we take the next step and pay as much “tax” as we want by financially supporting the services we want?

There is a common notion, especially among societies based on the Judeo-Christian-Islam belief system, that people are born evil and greedy. They require threats and punishments and laws to keep them from doing harm to the whole group. Increasingly, there is a drive to monitor more and more of each others’ activities to ensure nobody slips up and does something evil. This is a very efficient belief system for a hierarchical society. Those at the top can conveniently manipulate the legal system and buy their way out of any difficulties. They can avoid taxes and to a large extent influence the laws regarding taxes and regulations to suit their business interests. In a way, the society at large accepts this, since this upper class are considered important for everyone’s welfare. This is a great system for imperialist nations. The masses can effectively be ordered to kill each other to strengthen the power of those above them. This system has undoubtedly proved its success throughout the world and even though most people are ashamed of the gruesome methods their ancestors employed, people generally accept this system as the way things are meant to be.

Part of what makes this hierarchy so effective is the control of information. By having privileged access to “holy books” and the education required to sell these ideas to the masses, the religious hierarchy had a distinct advantage over them. If a large group of people consistently speak of the exact same fairy tales with a great sense of authority  it makes it increasingly difficult to believe otherwise, regardless of how crazy it is, or what rules they impose on you as a result. Once the system is in place to control the information, it is easy to tweak it to the interests of those at the top.

The internet has changed everything. Information about how the world works no longer trickles down via the clergy or wealthy publishers. They are feeling the pinch now as people increasingly turn to blogs, podcasts, wikipedia etc. as sources of information. We already knew that we could not blindly trust the media. Now we are also perfectly aware that we cannot trust what we find on the internet. Whether a sock-puppet actually has a piece of paper from a university to qualify their “opinion” or is published in a “respectable” source matters less and less. It is up to us to process the information we receive and decide who and what we trust. Even the media companies which aren’t obviously under the corporate thumb find themselves under increasing pressure to mix advertising and agenda into their content in order to survive. They claim they don’t have the resources to spend on real journalism anymore and are more inclined to accept what they are fed as information. The more they do so, the more people will come to see that this “professional” media is worth less than the media and opinions which are shared freely.

At the moment the system is broken. The funny thing is that people like to support and show their support for things that they are interested in. Media corporations, however, are founded on the notion that there is such a thing as “Intellectual Property” and that if you don’t charge people for it before you allow them to use it (under very specific terms and conditions) then you won’t be able to pay people to make more of it. They believe they are protecting the general public interest by enforcing regulations which ensure they will have money to produce more of what (and they know best) people actually want. Sure, people like the kinds of movies that require thousands of people to dedicate significant time, often years, to produce. People want to see these movies. Why not facilitate people to invest in these movies too? So far this model has worked on some independent movies, but it has yet to be attempted with a big budget movie. Instead of market researchers trying to guess what people want, advising a small number of investors, who then do their best to influence the movie to the apparent desire shown in statistical analysis of public opinion, the whole system could work the other way around.

There could be a whole new sector dedicated to facilitating the public’s desire to invest. The products of the work could be distributed freely, since the people who worked on creating it have already been paid. People involved in successful projects would be justly rewarded and be chosen for future more ambitious projects. People could be allowed to freely reuse the work, since this cultural “property” wouldn’t need to be “protected”. Instead of creating jobs in law enforcement and punishment we could be creating jobs in facilitation and communication.

The free software movement didn’t invent this business model, e.g. Pacifica radio has been financed by its listeners since shortly after it was founded in 1946. There’s nothing new about people pooling resources to create something bigger than they could on their own. If the media companies aren’t willing to take a leap of faith (even though many commercial artists such as Radiohead and Nine Inch Nails already have), then the free software movement is in a great position to show how it works, while also providing the infrastructure to make it happen.

I am excited and optimistic that such an economy and society is naturally taking shape. I see no need for a class war, or segregation, or violent revolution. All we need to do to make it happen is to invest in it.

Naïve? Loopy? Freetarded? Heard it a million times before?

What are your thoughts?

IE 7 and IE 8 on Linux with Wine 1.1.20

In an interview with Jeremy White (C.E.O. of CodeWeavers) on The Linux Action Show he mentioned they have IE7 working in CrossOver Office in the latest beta release of version 8 and that the latest version of Wine has lots of improvements that make this possible. I thought I’d try it out as I’m working on a new site and would like to be able to test it. I installed the latest version available for Mandriva 2009.0 in the package manager and did the following dance:

Created a fresh ~/.wine
Ran winetricks and set the version to win2k and installed IE6.
Ran winetricks and set the version to winxp.
Installed IE7:
$ wine IE7-WindowsXP-x86-enu.exe
Installed IE8:
$ wine IE8-WindowsXP-x86-ENU.exe
I think it installed the first time, but when I tried to run it, it threw an error. For no good reason I ran the installer again. After that it works fine (except it doesn’t seem to run any JavaScript). I think it is very usable for testing layout issues.

Some sites throw an error: “Internet Explorer couldn’t download %ws” and not having JavaScript working is a problem, perhaps I’m just missing a dll or something. I think it’s really great news though. I bet the CrossOver Office folks will have this polished pretty soon (if they don’t already).

It’s really phenominal work the Wine community do and it is greatly appreciated. I have no copy of Microsoft Windows and from time to time I really need to run a Windows application (e.g. Tax Software from the Government) and without Wine this wouldn’t be possible. Up until today I could only partially test in IE7 so it is great to know that I now have a way to make sure that sites I make are at least functional in Internet Explorer. Unless the site is for a client I’m not going to go to kill myself trying to make it work perfectly though, I tend to assume that people who use Internet Explorer are accustomed to things not working perfectly 😀

Are your modules ready for Drupal 6?

I was wondering when I could upgrade a Drupal 5 site to Drupal 6 so I knocked out a little script which reads the project page for each Drupal module you have installed and tells you the current releases and the version of Drupal that it can be used with:
Release: 6.x-1.0-rc6        Drupal version: 6.x
Release: 5.x-7.3           Drupal version: 5.x

It’s here:
(It requires Python and BeautifulSoup

How to use a git hook to upload to a website that only allows ftp


There absolutely has to be better ways to do this, but with my weak bash-fu and lots of help from the good people on #git I stumbled through and got something working.

I am using gitosis to host a repo that is shared between a couple of people I trust. They have given me their keys and commit via ssh. I just followed the instructions on

I used yafc for the ftp part. It was my first time using it and I love it to bits. No more gui ftp clients for me, or plain old ftp either. The bookmark feature is awesome and really helped me out here.

  1. Login to your site via yafc anc save it as a bookmark
  2. Add the script below to your remote repo i.e. login to the server you are pushing to, if you set it up with gitosis you will have /home/git/repos/YourRepo and put it in hooks/post-receive.
  3. Finally make hooks/post-receive executable to enable it (chmod u+x post-receive)


CHANGES=`mktemp -q -t`

while read oldrev newrev refname
# This gets the paths of the files in the repo that have changed
# and shows if they are added A, deleted D etc.
echo `git diff-tree –name-status -r $oldrev $newrev` > “$CHANGES”
echo $CHANGES >&gt; /home/git/YourRepo.log
UPLOADS=`cat “$CHANGES” | grep -v “^D” | cut -d” ” -f2`
# The sed expression here is to convert the path in the repo to the path on the server
DELETES=`cat “$CHANGES” | grep “^D” | cut -d” ” -f2 | sed -e ‘s/^drupal\/\///g’`
echo `date` “\nUploading: $UPLOADS\nDeleting: $DELETES” >&gt; /home/git/YourRepo-git-ftp.log
for U in $UPLOADS
# Again to change the repo path into the server filesystem path
FTPPATH=`echo “$U” | sed -e ‘s/^drupal\/’`
# This dumps the files out of the repo on to the filesystem to be uploaded later
mkdir -p $FTPSTAGE`dirname $FTPPATH`
git cat-file blob $newrev:$U > $FTPSTAGE$FTPPATH

# Tell yafc to upload everything that has been dumped from the repo
# and delete everything that needs to be deleted
yafc <&lt;**
open YourBookmark
cd /public_html/
put -fr $FTPSTAGE/*
rm -r $DELETES

# Tidy up
rm -rf $FTPSTAGE/*

If you’re any good at bash you are probably screaming in disgust right now but if you can spare a minute to explain how to improve this I would be grateful.

Note: this is so lame it doesn’t delete directories that have been created when you delete them from git. It just deletes the files. That’s just because the git command to get the paths doesn’t show when you’ve deleted the directory higher up. It just about works for me now, even though it’s horrible.

UPDATE: Replace all that gubbins with something like the following procedure:
Clone the repo on the server and set up sitecopy to sync that with the live site. Then in the post-receive hook:

cd /path/to/cloned/repo
unset GIT_DIR
git pull
sitecopy -u name

if you don’t change GIT_DIR you’ll see fatal: Not a git repository: ‘.’ even though running the hook on it’s own will work fine.
Thanks to:

RTÉ: In The Name Of The Fada (direct links if realplayer doesn’t like you)

Bfheidir toisc go bhfuil mé ag usáid Firefox3 Beta faoi láthair ach ar aon nós níl realplayer ag obair i gceart domsa agus bhí sé choimhseach deacair na nascanna díreach a fháil ón súiomh. Ar eagla gr mhaith le éinne eile breathnú ar an chlár íontach seo ó Des Bishop sheo dhuit:

#1 rtsp://

#2 rtsp://

#3 rtsp://

#4 rtsp://

#5 rtsp://

#6 rtsp://