Welcome to the beta version of newint.org — we have just redesigned it — more features coming soon!
We care about your opinion. Let us know what you think, or report any problems. Feedback »

Charlie Harvey is the IT Manager here at New Internationalist. He's active in both the activist and tech communities and is a vocal advocate of Free Software. You can read more on his main Charlie Harvey site.

twitter: 
ciderpunx
Teaser: 

Charlie Harvey is the IT Manager for New Internationalist

Contributor Image: 

What is your top feminist read?

Simone de Beauvoir’s The Second Sex, Alice Walker’s The Colour Purple, Eve Ensler’s Vagina Monologues…? Did you read it at school, has it shaped your politics, or how you view society? We want to find out what book inspires you and 40 words on why.

We will pick 10 entries and publish them as a web-only feature of recommended reads as part of our double issue on Feminism, out now. If yours is chosen, we’ll send you a free copy. We’ll share all of the entries on social media.

Tech Briefing: Node and more

2013-09-02_node_js.png

© NodeJS project

Note This article originally appeared on Charlie’s blog, entitled Tech briefing: CSS book, Node.js and some other javascript tools.

August reading day CSS book, Node.js and some other javascript tools

This is a writeup of my notes from my August reading day and might therefore be less coherent than my usual ramblings on the site. I read a book called Everything you know about CSS is wrong! and then moved on to some research on node.js which seems to be the thing that all the web hipsters are loving these days.

Everything you know about CSS is wrong!

This is actually rather an old book — hailing as it does from the days of IE8 — and one that I might have done better to read when it came out. It is from SitePoint, whose output I find quite hit and miss. But it has the advantage of being rather short and therefore readable in a few hours.

The book mostly talks about the then "new" features that CSS boasts, and is particularly excited about the prospect of being able to do grid layouts with display and the table layout types. Not layout with HTML tables. I found some of the info interesting and they had taken the trouble to quote some well respected designers, including Jeffrey Zeldman and Andy Clarke, who we worked with at New Internationalist. But I didn’t get much from it that I wasn’t already aware of.

Node.js

What is node.js?

Node.js, or just node (less typing) is a set of libraries that let you use Google’s v8 javascript engine to do networking. It is particularly suitable for DIRT applications. It runs an event loop in what is effectively the Reactor pattern. This means lots of callbacks and callbacks to callbacks and so on, which is the part of the programming model that is less well understood than other concurrency techniques, particularly threads.

It is quite a new technology, though it has been used in production in a few places. It uses reference counting to decide when to exit meaning that when there is nothing left to do it will quit. It is great for constructing network applications and i was able to build a chat server in about half an hour after following along with the presentation from Ryan Dahl who created node.

Example n

Here is the example code for a chat server. I added some features to the one that Ryan made. It can be run and handle letting all the people connected to it chatting and that sort of thing. It just keeps track of the open sockets in an array. You would use a better data structure in a real system.

var net = require("net");

// all the sockets that are connected get pushed into this array
var sockets = [];

// this is the server log such as it is. That is only the admin can see it.
console.log("Starting server ...")
var s = net.Server(function(socket) {
    var joinMsg = "!! " + socket.remoteAddress + " Joins";
    console.log(joinMsg); 
    for(var i=0;i<sockets.length;i++) {
      sockets[i].write(joinMsg + '\n'); // we broadcast that new person joined
    }
    sockets.push(socket); // and add the new socket to the list
    socket.write("Welcome to the chat server.\nUse /q on a line by itself to leave.\n\n");

    /// deal with the case when somebody disconnects by chopping them out
    // of the connected sockets list
    socket.on("end", function(d){
      var i = sockets.indexOf(socket);
      sockets.splice(i,1);
    });
    
    // and process incming data
    socket.on("data", function(d){
      for(var i=0;i<sockets.length;i++) {
        // skip lines starting / and don't broadcast to ourselves
        if(d.toString().charAt(0) != '/' && sockets[i] != socket) 
          sockets[i].write(socket.remoteAddress + ": " + d);
      }

      // /q quits
      if(d=="/q\n") {
          var leaveMsg = "!! " + socket.remoteAddress + " Leaves";
          console.log(leaveMsg);
          socket.end(leaveMsg + '\n');
      }
    });
});

s.listen(8000);

What is it useful for?

Very useful for building web services and other similar things. Don’t see massive advantages over apache or nginx for plain old web serving, but if you had something more realtime it might be useful. Scales well across machines, perhaps not as much over cores. Other concurrency models exist and are arguably easier to code for.

Problems

  • Young platform, maturity eg have to write your own db driver, or maybe there is a sucky one
  • Debuggability: event loops hard to stack trace unlike threads. Small stack traces are a problem (just like web browser) eg. in exceptions. Could have a debug mode which keeps track of who called me? Memory implications on a live system, though.
  • Single threaded process model. So what about multicore boxen? Start more node processes. Shared nothing model. Relies on OS to manage multiple instances of node. At some point you’ll need multiple machines, so might as well get used to talking a protocol between node instances. But there are other ways of doing concurrency that do scale cleanly over cores and don’t need to serialize and deserialize all the time.
  • Javascript
  • Quite possibly relies on Google’s benevolance in continuing to support v8, though the source is out there.
  • Useful resources

  • node: a skeptics view. Intro to node with some interesting thoughts on th event model and the particular challenges it brings up.
  • When node goes wrong, detailed insight into how you debug node in the wild.
  • The last word …

    Hehe! There is one of these videos. I love these. Node.js is bad ass rock star tech

    Other Javascript technologies

    Didn’t look at them in as much depth, but here are quick summaries of some other js things that have ben getting attention.

    Angular JS
    Rather than sprinkling your html with jquery, angular adds a bit of syntax to the html itself. So you can do nice realtime stuff on the page by just changing your markup. Easier to understand potentially than tracking stuff down in jquery.
    Express JS
    Express.js is popular web micro framework designed to run on node and clearly heavily influenced by Sinatra. It doesn’t model your database or anything like that. You might make something out of mongo or redis for doing that part.
    Backbone JS
    Another approach to doing interactivity on pages better than does jquery, backbone.js was originally developed for documentcloud. It isn’t quite an MVC but tries to do similar work.
    Jade
    Jade is a templating engine for node. The syntax looks like it was inspired by HAML, that is that it is heavily optimised for minimising the amount you have to type.

    In finding out more about those projects I found Javascript too, which lists Every js project you should be looking into

    Interactive timeline: 40 years of New Internationalist


    To celebrate New Internationalist’s 40th anniversary we have put together a timeline of some of our best moments. It features seminal articles and issues, game changing campaigns and memorable stories. From the baby milk scandal and tax justice, to climate change and the thorny issue of ‘development’, New Internationalist has documented the milestones in many movements for progress.

    timeline screenshot


    10 steps to software freedom

    1. Embrace free software
    It costs nothing, is often more stable and sometimes works better. It also lets you see the code your computer is running, and change it if need be. Compatibility with other programs has greatly improved.

    2. Get downloading
    Give this software a whirl:
    For browsing: Firefox
    For secure web chat: CryptoCat
    For word processing: LibreOffice
    For graphic editing: GIMP

    3. Start building
    Help grow the free software community. You can report bugs, request new features, offer translation or design skills, or – if your inner geek is struggling to get out – write code.

    4. Stay safe
    Tor is a tool that anonymizes internet connections to allow free expression. Dissidents, who risk their lives to speak truth to power, use Tor as a way to side-step censorship and capture in repressive countries. Adding your traffic to the Tor server makes it harder for governments to crack down on online dissent: torproject.org

    5. Embrace free culture
    More and more artists are releasing their work under free or open licences like those from Creative Commons.
    Listen to their music, read their books, and donate funds to support a blossoming re-mix culture: freemusicarchive.org search.creativecommons.org

    6. Say no to ‘DRM’
    You bought it, it belongs to you – yet you don’t control it. Publishers can stop people from sharing e-books – and music – using Digital Rights Management. DRM adds malicious software into your e-book reader that lets the book publisher mess with your device remotely. Buy a New Internationalist DRM-free e-book! shop.newint.org

    7. Protect your mobile phone
    More and more people are carrying phones which can do things like sell your geo-data to companies, be easily intercepted and lock-down your software. If you have an Android, that means you have a 95% free operating system that can add privacy tools from The Guardian Project to stop snooping governments and marketers.

    8. Put trackers off the scent
    Many websites carry advertising, social media widgets and profile audiences. Somewhere there’s a record of your seeking advice about your embarrassing medical condition, or evidence of your unsavoury political interests. Protect yourself from unwanted tracking and ads with browser plugins like Ghostery or AdBlockPlus.

    9. Get campaigning
    Software can’t go it alone. We need political change, better privacy and copyright regulation too. Join these groups and support the fight for a free internet:

    10. Get savvy
    Digital Survival Guide: Basic intro to computers, internet and mobile use.
    Top 12 ways to protect your online privacy: eff.org
    Browse a selection of privacy-enhancing, technical resources: techtoolsforactivism.org

    Slideshow photo: Vectorportal under a CC License.

    Tips for searching newint.org

    As some readers may have noticed, we've been doing some work on the search facility on the New Internationalist website. Here is an update on how to use it to find that which you seek.

    Search changes

    The biggest change that we have made is to order the search results by date. This means that newer results will be higher up the search by default. We wanted people to see our latest coverage easily and this seemed the best way to achieve that. I'd be interested to hear if you love or hate getting results in that order, let me know in the comments.

    The original relevancy ordered search is still there, but you need to use the link at the top of the page to reorder the results.

    Search basics

    Normally a search looks for content anywhere on the page. The search will search for pages which contain all the keywords you specify. You can search for a longer phrase by quoting it with "s.

    Using fields

    You can narrow your search down by using extra fields on your searches. The syntax for fields is fieldname:keyword. So, for example, you could search for everything about India that we published in 2012 by typing India year:2012. Each of the fields below links to an example for you to play with.

    • tags:environment find articles tagged with your keyword
    • title:politics find articles which include your keyword in their title
    • year:2012 find articles published in the year you specify in YYYY format
    • month:201202 find articles from a particular month in YYYYMM format
    • date:20120201 find articles published on a particular day YYYYMMDD
    • category:blog_post find articles of a particular type, which must be blog_post, publication (for books pages), global_contributor (for contributor pages), story (for all other articles).

    Combining searches

    The searches can be combined if you want to narrow down your search to something quite specific, for example to find all blog posts mentioning India that were tagged climate change and published in 2012, you could search for India category:blog_post tags:"climate change" year:2012.

    URL trickery

    You can link to searches using the link at the top of the page, or just use http://www.newint.org/search/term, for example to link to Monsanto searches, you would link thus: http://www.newint.org/search/monsanto.

    You can specify the page of the search as part of the URL, for example the second page of results about Spain is available at http://www.newint.org/search/spain/2.

    If you'd like to syndicate your search, for example in a news aggregator, you can use the RSS link at the side of the page, or add "rss" into the URL. For the RSS feed of "anarchism" you would use http://www.newint.org/search/rss/anarchism/1.

    The result ordering is specified as a GET parameter. Which means that if you wanted to link to the results of a search for Occupy in order of relevancy you would use the URL http://www.newint.org/search/occupy?order=relevance.

    Other ways to navigate www.newint.org

    Search isn't the only way to locate interesting stuff on our website. You can also use the browse tools in the sidebar, our themes directory, our tag listing or New Internationalist Australia's hand edited magazine guide. Our online shop has its own search to help you find the perfect ethical gift.

    Technical details

    This section is probably only of interest to techies! We use the free/open source Xapian search engine as our backend data repository with the results being processed and presented by perl's Catalyst web framework, using Catalyst::Model::Xapian. We use an in house web spider to populate our database, it is called muffet and is available on github under a GPL licence.

    Lobbyists lie to avoid copyright treaty scrutiny

    I posted last week about ACTA, the staggeringly misguided treaty that the entertainment and pharmaceutical industries are trying to have their government minions pass without any serious public debate.

    This week, the entertainment industry is at it again. The Trans-Pacific Partnership (TPP) is yet another copyright treaty being negotiated in secret by many of the same shadowy corporate éminence grises as ACTA itself.

    Now, some civil society groups heard that there was to be a TPP meeting at a swanky Hollywood hotel and decided that they'd rent out a room and run an open briefing event about the TPP. In the same hotel.

    But the lobbyists heard about the planned meeting and decided to have the hotel cancel the group’s reservations. Sean Flynn, the Associate Director of the Program on Information Justice and Intellectual Property (PIJIP) at American University takes up the story on TechDirt.

    ‘The public interest briefing was booked last week and advertised to all delegations, including the host USTR,’ he said. ‘An hour after the invitation was sent, we received a cancellation of our venue by the hotel.’

    The hotel said that they had ‘a confidential group in house’ and wouldn't be allowing other groups in the hotel that day.

    It turns out that that was a lie. When the group called to rent a function room for another event the hotel was more than happy to oblige.

    Unlike the public interest groups, the film industry got exclusive access to the treaty negotiators. The negotiators even got a ‘multi-hour tour of 20th Century Fox Studios’. Of course that won't have any influence on their objectivity.

    Secrecy and corruption appear to be the modus operandi of the corporate interest groups sponsoring the TPP. Their terror at the prospect of any public debate about their control of popular culture only serves to illustrate the fragility of their position. Expect more shenanigans and more attempts at pervasive internet surveillance coming from the direction of our Hollywood overlords.

    ACTA: undemocratic, dangerous and wrong

    If, as Mark Getty famously claimed, ‘Intellectual Property is the oil of the 21st century’, then the Anti-Counterfeiting Trade Agreement (ACTA) has something of the character of a covert black-op in that war. A covert black-op which will benefit corporate power. The whole thing has been negotiated in secret between rich countries in a policy-laundering scheme designed to avoid the meddlesome interference of democratic debate, transparency or dissent.

    Like the recently defeated SOPA/PIPA legislation in the US, ACTA will introduce de facto censorship of the internet, but ACTA goes one step further and introduces dangerous provisions that can be used by multinationals to restrict access to generic medicines to people in the Global South.

    Lobbyists for big pharma have added their own clauses into the agreement that require customs officials to treat generic medicines as if they were counterfeit goods and seize them.

    ‘Negotiating countries are cynically using legitimate fears of counterfeit medicines to exert greater control over the trade in generic medicines to poor countries,’ says Oxfam spokesperson Rohit Malpani. ‘ACTA is proposing a new, expanded framework of intellectual property protections on behalf of multinational drug companies which will be combined with border measures to stifle the trade in legitimate generic medicines. This will mean that poor people will be denied legitimate and life-saving generic medicines.’

    The obfuscatory tactic of intentionally confusing one thing with another is nothing new on behalf of the multinationals. In fact the whole notion of intellectual property is deeply problematic, confusing as it does the three very different phenomena of copyright, patents and trademarks. Throwing counterfeiting into the mix bamboozles even more. Now, it suddenly becomes possible to talk about countries trying to save lives as if they were some geezer selling knock-off Rolexes down the market. Or to speak of people who share ideas, computer code or music as ‘pirates’.

    The WHO estimates that 1.3 to 2.1 billion of the poorest people in the world do not have access to essential medicines. There is something deeply wrong in a society that values the profits of a global corporation more highly than securing that access. At least 20 legitimate shipments of life-saving generic medicines have already been seized under a similar EU regulation. ACTA will formalize and extend that power. It’s not clear that it will do anything to prevent the circulation of fake medicines.

    ‘We are in danger of ending up with the worst of both worlds,’ says Michelle Childs of Médecins Sans Frontières. ‘Pushing IP rules, which are very effective at stopping access to life-saving drugs but are very bad at stopping or preventing fake drugs.’

    ACTA's censorship provisions are also extremely troubling. Like SOPA/PIPA they introduce virtual fiefdoms for copyright holders, encouraging a chilling effect on freedom of expression online.

    ‘The ACTA enforcement regime imposes a nineteenth century view of intellectual property (IP) that fails to acknowledge the changed relationship between individuals and information in the modern electronic age,’ say Article 19. ‘Consequently, the IP interests of corporations are disproportionately protected at the expense of individuals’ rights to freedom of expression and information.’

    Perhaps the most controversial aspects of ACTA are its intentional avoidence of the usual norms of democratic accountability and introducing a parallel legislative process. As Adam Ma'anit noted in issue 435 of New Internationalist magazine: ‘ACTA is being negotiated in secret between supposedly democratic entities … while some cursory information has been released, there is still concern over the substance of the negotiations and the lack of public debate and scrutiny over some of its more odious details.’ The process has consistently excluded civil society groups, and even parliamentary discussion.

    The EU Parliament development committee is scheduled to hold its first debate about the shadowy legislation today (24 January 2012). Their report, written by Jan Zahradil, a conservative, euro-sceptic from the Czech Republic, is a masterpiece of one-sidedness, failing to mention the extensive criticism that has been made of the legislation, or the frankly scandalous way in which legislators have circumvented the usual checks and balances of the democratic process. There is a much fuller analysis of the agreement over on La Quadrature Du Net's wiki. We all need to stop ACTA before it’s too late.

    Stop SOPA

    You may have noticed that our slideshow is blank today, 18 January 2012. You may also have seen that Wikipedia has blacked out all its pages.

    This is part of a global protest against an internet censorship bill. The proposed legislation in the United States — the Stop Online Piracy Act (SOPA) in the U.S. House of Representatives, and the PROTECT IP Act (PIPA) in the U.S. Senate — would, if passed, seriously damage the free and open Internet.

    Whilst it is an American law, it has far reaching repurcussions for the web as a whole, effectively allowing the entertainment industry to censor websites with at whim with no due process as you can see in the video below.

    We urge all of our readers to do everything that they can to protest the legislation. Readers in the US may want to send an email to their representatives on the EFF action page.

    Update: Well it looks like a show of unity by sites on the internet has stopped both SOPA and PIPA in their tracks. That's the good news. The bad news is that the secretly negotiated ACTA looks like it will be ratified in Europe shortly. You can learn more on the Act on ACTA website. It is a bit like the SOPA/PIPA legislation, but worse. I'll be writing more about it soon.

    Update:  A couple of other sites at which to take action have been suggested by commenters—thanks folks!

    http://www.siliconrepublic.com/new-media/item/25434-lamar-smith-decides-to-post/

    Not the last time London will burn

    The usual round of celebration, condemnation and name calling has begun. The riots in London and elsewhere over the last few nights are being portrayed as something between the collapse of civilization and the final insurrectionary act of the glorious working classes. You pays yer money, you takes yer choice. 

    image of looters and onlookers
    Photo by Hozinja used under a Creative Commons licence.


    The lefties are pointing out that the riots are happening in the context of massive cuts to welfare, in communities that have at best problematic relationships with the police and involving young people alienated by the systematic inequality and racism they suffer routinely. 

    Right-wingers are just looking for someone to blame, from the borderline classist/racist 'it’s these criminal chavs/blacks/muslims/insert Daily Mail hate group' to the 'give the police tanks/machine guns/rocket launchers' to the 'they all use Twitter and Blackberries you know'. 

    But I’m surprised we haven't seen things kick off sooner.  

    Item: A generation of kids are constantly told that having more stuff is the route to fulfilment in life. Item: The same kids have no access to said stuff. Item: Dear old Lady T did away with society in order to free us up for total market domination of every aspect of our lives. Item: Her successors continued the policy and persisted with consumerism as the axiomatic basis of all human fulfilment. Conclusion: Kids with a burning desire for more stuff and no belief in society may very well start smashing up their communities to get a taste of the good life. 

    While Jody McIntyre is correct to say that many of the rioters are angry with the police, and with our society's inequality, I think the rabbit hole goes deeper. If these were the only issues, we could expect to see more police stations blazing, more sharing of the looted consumer durables among the community and fewer homes on fire. 

    We need to examine the dual forces of consumerist dogma and the ideologically driven collapse of community cohesion. These two forces when applied to a poor and alienated underclass of young people who have learned to hate the police are nothing short of incendiary.

    Over the next few weeks we can expect to see the media on both sides of the political divide calling for ever more authoritarian measures to deal with 'these people'. Politicians and politicos will rush to condemn. They will leverage the crisis to push their particular agendas. But, with a looming financial disaster and continuing commitment by the powerful in society to never-ending consumption, uninhibited greed, and systematic inequality as the only way to manage the world, this is probably not the last time London will burn.

    Taking on Tarmageddon - The Movie

    Back in our April 2010 Tar Sands magazine, we covered the the vast destructiveness entailed in the extraction of expensive oil from the tar sands of Alberta, Canada. Now, activist filmmakers Cambell Road Productions have made a documentary about eight student activists from the UK going out to see first hand the industrialization of the wilderness and the trashing of indigenous people's land and ways of life.

    As Jess Worth explained in her keynote, Taking on Tarmageddon, 'The effort to shut down the tar sands is shaping up to be one of the iconic struggles of our age'. As well as the inevitable environmental chaos that the project entails it is also hugely damaging to the people who live nearby, notably the Beaver Lake Cree.

    In the film, also called Taking on Tarmageddon, student activists from the People & Planet network meet the Beaver Lake Cree first nation who live right in the middle of what has been called both the biggest and the most destructive industrial project on Earth. The documentary follows each of the students through their investigations documenting their experiences, thoughts and emotions on seeing the impacts of tar sands oil extraction. Here is Taking on Tarmageddon trailer

    As the project has progressed, the students have been posting regular video blogs from Canada over on vimeo on the people they've met and the actions and adventures they've had.

    The filmmakers of Taking on Tarmageddon are crowd-financing the project and hoping to get contributions on their fundraising page. If they can make their target the film will be released this year. I strongly encourage you to donate to make Taking on Tarmageddon the movie a reality.

    Tar Sands Campaigning Resources

    Pages