How to fix pip under Debian 6.0 (squeeze): ImportError: cannot import name parser

HowTo, Linux, Programmazione, Python, Ubuntu (EN) 1 Comment »

The pip utility distributed with Debian 6.0 has a bug once you upgrade it with pip install -U pip. You will easily get this error when you try to install a new package with it:

root@worker2:~# pip install setproctitle
Traceback (most recent call last):
File "/usr/bin/pip", line 8, in <module>
from pip.baseparser import parser
ImportError: cannot import name parser

Luckly there is a very easy workaround:

easy_install pip
rm /usr/bin/pip
ln -sv /usr/local/bin/pip-2.6 /usr/bin/pip
pip install pip --upgrade

Reference: http://blog.102web.ru/tag/virtualenvs/

Using virtualenv to manage multiple Python/Django environments in the same machine

HowTo, Linux, Programmazione, Python, Ubuntu (EN) No Comments »

Developing Python applications sometimes it's useful to be able to test the code with different environments, for example a particular version of Python or a specific Django version etc... Setting up many different virtual machines would be really too much work and even using a chroot environment is not what you need in some cases. Thanks to virtualenv is it possible to create a self contained Python environment with all the specific libraries you may need. Using virtualenv is very easy:

  • Creating the virtual environment: virtualenv myenv --no-site-packages
  • Entering the virtual environment: source myenv/bin/activate
  • Deactivating the virtual environment: deactivate

That's it! Once you're inside the virtual environment you will be using the Python libraries inside it. I suggest you to install all the Python libraries you need using pip.

Using Twitter Bootstrap with Node.js, Express and Jade

HowTo, Linux, Node.js, Programmazione, Ubuntu (EN) 1 Comment »

I've decided to write this post as a note to myself. I'm still learning Node.js and digging into Express/Jade, but I've read many people using the nice Twitter Bootstrap and I was wondering if there was a way to integrate all these technologies. The short answer is: yes, we can!

Note: once again, I'm not a Node.js expert and surely there are other ways to achieve this task (for example there is a Node.js module called twitter-bootstrap, but I haven't tried it). This tutorial is based on another tutorial I found, but it was not very updated and it had a more complicated way to install Bootstrap, so I decided to write a new one basing it on the original http://www.rs.au.com/31/how-to-install-bootstrap-v2-0-2-in-expressjs-v3-0-0

Preparing the environment

I will assume that you're running any Linux distribution (in my case I'm using Ubuntu 12.10, but feel free to use your own distribution). Be sure to have installed a recent version of nodejs and npm packages (I'm using Node.js 0.8.20 and npm 1.2.11).

Create a project folder and install the required dependencies

mkdir node-bootstrap
cd node-bootstrap
npm install express
npm install jade

Create the basic project structure with Express

andrea@andrea-Inspiron-660:~/Documents/sviluppo/nodejs/node-bootstrap$ node_modules/express/bin/express nodebootstrap

create : nodebootstrap
create : nodebootstrap/package.json
create : nodebootstrap/app.js
create : nodebootstrap/public
create : nodebootstrap/public/javascripts
create : nodebootstrap/public/images
create : nodebootstrap/public/stylesheets
create : nodebootstrap/public/stylesheets/style.css
create : nodebootstrap/routes
create : nodebootstrap/routes/index.js
create : nodebootstrap/routes/user.js
create : nodebootstrap/views
create : nodebootstrap/views/layout.jade
create : nodebootstrap/views/index.jade

install dependencies:
$ cd nodebootstrap && npm install

run the app:
$ node app

You should already have installed all the needed dependencies, even without executing npm install, anyway executing it won't hurt.

Download and install Bootstrap

Download Twitter Boostrap from the official website http://twitter.github.com/bootstrap/assets/bootstrap.zip and unzip it under the nodebootstrap/public folder.

Bootstrap integration with Jade template system

At this point you need to edit the views/layout.jade file and include the references to Bootsrap

!!!
html
  head
    title= title
    link(rel='stylesheet', href='/bootstrap/css/bootstrap.min.css')
    link(rel='stylesheet', href='/bootstrap/css/bootstrap-responsive.min.css')
    link(rel='stylesheet', href='/stylesheets/style.css')
    script(src='http://ajax.googleapis.com/ajax/libs/jquery/1/jquery.min.js')
    script(src='/bootstrap/js/bootstrap.min.js')
  body
    block content

Test the Bootstrap integration

At this point we will modify views/index.jade that is the default template used to render the index

extends layout

block content
  div.top
    form.form-horizontal(method="post", id="loginForm")
      label Username
      input.span3(id="username", type="text", name="User", placeholder="Enter your username")
      label Password
      input.span3(id="password", type="password", name="Password")
      input.btn(type="submit", value="Log In")
  div.container
    div.content
      table.table.table-striped
        thead
          tr
            th Table
            th Heading
        tbody
          tr
            td Blah
            td Test
          tr
            td Hello
            td World

  div.footer

Now go back to the terminal and execute the app:

andrea@andrea-Inspiron-660:~/Documents/sviluppo/nodejs/node-bootstrap/nodebootstrap$ node app.js
Express server listening on port 3000

Open your favourite browse and visit http://localhost:3000 to see your first Bootstrap + Node.js application app and running.

Fundraising for CuteSoma (Soma.fm mobile client) development

BlackBerry, Maemo (EN), MeeGo, Programmazione, Windows Phone No Comments »

Developing CuteSoma and maintaining it for three different platforms (Nokia N9, Windows Phone, BlackBerry 10) is really taking me a lot of time. I've many features in mind to add but I can't dedicate much spare time to them and to do it I should take time from other paid projects. I've also discarded the idea to make CuteSoma a paid app, because it's been always free (except the Windows Phone one that was non-free for just a month, but only 6 people "SIX" bought the app).

So I decided to open a fundraising campaign on Indiegogo that is a service like KickStarter, but it's available all around the world (not just in USA and UK like Kickstarter).

What do I Need & What You Get

I would like to raise at least 5.000€ to be able to keep maintaining the existing features and to implement new one. Developing for 3 different platforms really takes a lot of time. I also need to find a way to get a Windows Phone 8 device because at the moment I cannot test some features using just the emulator.

What the application currently does:

  • You can view the list of Soma.fm channels
  • You can listen any channel

Features I would like to add:

  • Scrobbling song to Last.fm
  • Write a new MediaSource for Windows Phone (the default one is quite bugged and I need to implement one from scratch)
  • Port the BlackBerry10 version to the native CascadesUI

The Impact

Funding the development of CuteSoma you will make thousands of people really happy, because they will be able to listen to Soma.fm on their Nokia N9, Windows Phone and BlackBerry 10 devices. You will also make me feel apreciated for all the hours I'm spending to write the code :)

Completly Opensource

Yes. CuteSoma is completly opensource. I keep my source code on GitHub and BitBucket and it's always updated. All the CuteSoma versions are released under the GPL license.

Other Ways You Can Help

If you want to contribute but you can't or you don't want to send money, you could help me in the following ways:

1) Download and use the application:

2) Tweet/Blog about this fund raising campaign: http://www.indiegogo.com/projects/cutesoma-soma-fm-client/x/2353169

How to install latest stable Node.js on Ubuntu

HowTo, Linux, Programmazione, Ubuntu (EN) No Comments »

If you develop with Node.js and you want to be sure to have the latest stable version, luckly there is a PPA for it. All you need is to follow these instructions:

sudo apt-get install python-software-properties python g++ make
sudo add-apt-repository ppa:chris-lea/node.js
sudo apt-get update
sudo apt-get install nodejs npm

That's it!

Reference: https://github.com/joyent/node/wiki/Installing-Node.js-via-package-manager

WP Theme & Icons by N.Design Studio
Entries RSS Comments RSS Log in

Switch to our mobile site