Archive for July, 2012

Create permenant aliases with .bashrc

Saturday, July 7th, 2012 | Life, Tech

Sometimes, it’s easier to create an alias when working with the Unix command line. Having to create these every time seems to defeat the point of having a short alias though. Luckily, you can make them persistent.

Lets assume that we are using a user called mike. We need to be in our home directory.

cd /home/mike

The .bashrc file should be in there, but hidden.

ls -a

You should be able to see it listed. Now lets edit it.

vim .bashrc

And add a command in, for example, to save our usual CVS update command.

alias upd='cvs -q update -P -d'

Now save and exit. After that, every time you log onto the box you can use the upd command to run the CVS update.

The cigarette carton dilemma

Saturday, July 7th, 2012 | Thoughts

Recently, I gave a speech on drug legislation, pointing out that tobacco is a far more dangerous drug than ecstasy is. Which is true. To add a bit of colour to my speech, I included in it the use of a bottle of alcohol and a pack of cigarettes as props.

Obviously, being a non-smoker I didn’t have any cigarettes and Ryan having disappeared for the day, I had to resort to going out and buying some. This wasn’t a big deal, they were only £3.95, but it then put forward an interesting question – what to do with the pack of cigarettes after I had used them.

My first instinct would just be to give them to a friend who smoked, so they wouldn’t go to waste. But then, maybe they should go to waste. I had just given a talk on how dangerous cigarettes were after all, and so it seemed that the best thing to do would just be to throw the pack of cigarettes away so that nobody could smoke them.

This seems to undermine freedom of choice though. I don’t want to restrict what people can and cannot do. As both a libertarian and a rationalist, the ideal world for me is one where everything is allowed but people make sensible decisions – so doing heroin would be legal, but nobody would do it because everyone makes rational decisions.

But then, by throwing them away, I wouldn’t be preventing people from smoking. I just wouldn’t be supporting it, which is all I can really do.

In the end, though, I decided to give them to a friend. The decision came down to this – the cigarette company already has my £3.95 from the sale. Now if I throw them anyway, my friends are unlikely to smoke any less, so they’ll just go out and buy some as normal and the cigarette company has got £7.90 out of us. But by giving them away, it avoids the need for them to buy cigarettes and so effectively the tobacco industry hasn’t got any money out of me. This seemed the most satisfying solution.

Going north

Saturday, July 7th, 2012 | Limited, News

Nakna Hemmafruar

Worfolk 18 is proud to announce the launch of our first Swedish language site, Nakna Hemmafruar. The content is not unsuitable for anyone under the age of 18.

Feminist guilt culture

Friday, July 6th, 2012 | Religion & Politics, Thoughts

One of the days that religions very effectively control their followers is through guilt culture. The idea is that just living your life, having natural thoughts and urges like who you want to go to bed with, is “sinful.” Of course we’re genetically wired to want to go to bed with people we find attractive and so just being a normal, well adjusted human being leads up to having thoughts, that The Church then tells you is as evil as having done the act itself and that you must repent in a financial way (and as luck would have it, they’re God’s official debt collectors).

It’s a fantastic way of keeping people under your control for making them feel guilty when they haven’t done anything wrong. In fact, it’s impossible not to think like that, so everyone feels the guilt and therefore stays under control.

As with many of religion’s best ideas (and it is one of their best from the stance of their insidious motives), people see how well it works and attempt to emulate it. Make a customer out of them while they’re young for example, has been a marketing technique that has proved hugely successful for McDonald’s – they’re the largest toy distributor in the world. In 2009, I blogged about how the green movement had also adopted a lot of Best Practice from religious institutions.

As an equal rights campaigner, I’ve had the chance to meet a lot of cool people who are also interested in equality. As with any field though there are some people with good ideas and some people with not so good ideas. Indeed, most people probably have a mix of both, I’m sure many of my ideas would be classified by some people as being in the not so good pile.

So called Lads Mags are a good example of this. Some of my friends would frown on me buying a copy of FHM It objectifies women and is therefore degrading – even though they’re professional models who voluntarily choose to have photos of themselves in exchange of large amounts of cash. This view is entirely at odds with equality – everyone should be free to choose what they want to do, and imposing Feminist Ideals to prevent them from doing so no less oppressive than the Patriarchal Culture we’re trying to escape from. Rachel Barker sums the debate up very nicely on her blog. As she points out, there are instances where people are exploited – and we need to work together to stop such cases! But Katie Price’s £45,000,000 fortune does not fall under that banner.

More widely, I resent the attack on men who consume such content (I use the term men, because it’s mostly men who are attacked for it). If I buy an FHM, it is indeed for the sexually alluring content. But you know what – I like looking at tits. That is a perfectly healthy, natural, biological urge that most people have. Human beings, and indeed all reproductive animals, are wired to find others attractive. And I do.

So given I was born this way, I’m not going to apologise for enjoying such content any more than I’m going to apologise for the way I look or the colour of my skin. I shouldn’t feel any more guilty about it than a homosexual should feel guilty about their feelings when a conservative tells them that their feels are wrong or unnatural.

I mean, what I am supposed to do? Should I lie and pretend that I don’t enjoy looking at scantily clad women? Should I go to my GP, or perhaps a mental health provider, and tell them I appear to be suffering from attraction to other human beings? Or is it a case that “it’s fine to have these feelings, we understand you are born this way – as long as you don’t act on them.” Where have we heard that before?

Furthermore, I resent the idea that my entire gender is so simple-minded that just because one of us may look at such pictures, he is then unable to treat anyone with respect. I see my girlfriend as a sex object because I find her very attractive and enjoy having sex with her. I also deeply value her personality, her opinions and her kindness. I see her as a whole human being, sexuality included. Such suggestions of viewing women in a single dimension hold no more weight than the idea that someone who plays violent video games must be a violent criminal.

Attacks against such magazines, freely bought by consumers, featuring models who freely chose to appear in them, are not only an assault on freedom of expression and the right for women to choose their own career in life, but also an attempt to control the population through guilt culture, convincing them that just being who they are is somehow a violation of morality. Such action is bigoted, morally wrong and intellectually bankrupt. It also creates a diving line between Feminist Politics and those interested in equality.

Even Jesus is feeling the recession

Friday, July 6th, 2012 | Religion & Politics

Total spending on religious construction is down to almost a third of what it was a decade ago.

FRED graph

Data Source: FRED, Federal Reserve Economic Data, Federal Reserve Bank of St. Louis: Total Construction Spending: Religious (TLRELCONS).

Wing Commander

Thursday, July 5th, 2012 | Limited, Programming

Moustache I’m a big fan of the Flight PHP micro framework, and it’s built-in views component is quite nice when you want to do stuff in a rush.

But recently I have started to use Slim more often as it has almost out of the box support for Mustache templates, whereas Flight does not.

Until now, that is. I wanted to use Mustache with an existing project I had already coded up in Flight, so I’ve now written a wrapper for it and released it on Github. It’s nothing fancy – probably less than 100 lines of code in total. But it seems to get the job done.

So if you’re looking to use Mustache templates in your Flight application, why not give it a go? If you have any improvements, you can always fork it too!

Worfo.lk

Thursday, July 5th, 2012 | Limited, Tech

Inspired by Kieran’s recent registration of kjo.sh to use as his own short URL code, I decided to go on a bit of a search for any names which could be similarly useful.

Wouldn’t you know it, Sri Lanka happens to have a top level domain made up of the last two letters of my name – .lk. Seeing that the domain worfo was available, I’ve now snapped it up to form worfo.lk. Boasting an extra three letters on top of the minimum length of domain names, it isn’t the shortest short URLs in the world, but I’m more than happy to make the trade off.

Of course, please remember that clicking a worfo.lk link doesn’t guarantee you won’t end up on a web page containing hardcore pornography.

Logic-less templates with Mustache

Wednesday, July 4th, 2012 | Limited, Programming

The first thing you probably think about when I mention Mustache is, “you’ve spelt moustache wrong.”

You would be right. But although the creators of such a project clearly do struggle with proper spelling even more than I do, they have never the less created something really interesting – logic-less templates.

Mustache is a templating system, similar to Smarty or Twig, that was originally written for Ruby and has since been ported to almost every other popular language under the sun (it has not been ported to any languages that exist outside our solar system, to my best knowledge).

The idea is that you separate out your logic from your template. So you would have a view class which handles the logic, and then the actual template file which has your presentation in. Why this extra layer of complexity though?

Well the problem with templating systems such as Twig is that they actually aren’t as separate as we like to think they are. You have control statements like looks and if statements, and then people started adding helpers to templating systems where you could call functions and even pass parameters! This made it a lot easier for us to write the view, but by the time you’ve added all that in, why not just place the PHP directly inside the template – it would be just as simple.

Mustache does a way with all that. In Mustache there are two main types of tags you can have – variables and sections. A variable is a straight replacement in double brackets {{like this}}. Sections contain one extra character so you might have a {{#section}} that wraps this text{{/section}}. A section can then be repeated zero or more times depending on whether you pass it a false value, a true value or an array.

There are a few other tags but this for the most part is everything! You don’t have the complicated control statements, the helper functions or other such syntax to deal with – inside a section which repeats from an array for example, you just call the key name, without having to specify the array variable every time. See the example below.

In Twig, you would do this...

{% for item in list %}
{{item.name}}
{% endfor %}

In Mustache, you just do this...

{{#list}}
{{name}}
{{/list}}

You can argue that there is added complexity in having to create an accompanying view class – and you would be right. But this is optional, and only required if you need to do view-time processing – passing an associative array, just like you would with Twig, works fine too!

I highly recommend giving Mustache a go, I was skeptical at first but once you dive in it really produces some beautifully clean code.

Don’t cover it up

Wednesday, July 4th, 2012 | Video

This is a great PSA by Lauren Luke.

YouTube link is here if you’re having problems with the embedded code.

Slim

Tuesday, July 3rd, 2012 | Limited, Programming

Slim is a PHP micro framework, similar to Flight, Silex and Limonade, not to be confused by the Ruby templating system of the same name. It claims to contain “everything you need and nothing you don’t.”

If functions like you would expect a micro framework to work. Here is the standard example.

<?php
require 'Slim/Slim.php';
$app = new Slim();
$app->get('/hello/:name', function ($name) {
    echo "Hello, $name!";
});
$app->run();
?>

My favourite part of Slim, however, is actually the Slim Extras bundle which doesn’t ship with it, but can easily be downloaded and dropped in. This adds easy integration for lots of different templating languages – notably Smarty, Twig and Mustache.

So, for example, if you wanted to integrate Twig, just grab the Extras bundle, the Twig bundle, include the relevant file and change your initialisation statement to the following.

$app = new Slim(array("view" => "TwigView"));

That’s all – now you’re away and can call the render method with a filename and data array to render a template using Twig.