Archive for the ‘Ubuntu’ Category

Slow connection

August 29th, 2011 No comments

So there was something peculiar with my Linux box at my office. While my network connection is reasonably fast, it would take about ten seconds sometimes for my browser to start getting information from web sites. And almost 100% of the times I tried to load the URL would just not resolve. I did some research and thought that maybe there was something with the DNS setup that might be awry.

Apparently in Ubuntu there’s thing called “Network Manager” that makes decisions about which nameserver to connect to. While I don’t know why this happened, Network Manager did a very bad job of selecting the nameserver to connect which resulted in this issue. I first tried connecting to Google’s nameserver (didn’t realize this was an option) and had pretty great results. I believe the IP is “” Then I did some more research and learned about this FANTASTIC application that tries its very best to choose the best nameserver for your setup. It’s called “namebench” The smartest part of namebench is it actually looks at your browser history (if available) to get the quickest nameserver for your actual usage. After running that tool, it recommended three nameservers to connect to. So after getting the results, I did the following:
$ sudo emacs /etc/resolv.conf


And then you have to do one more thing to make sure Network Manager doesn’t override your changes the next time the machine starts up.
$ sudo chattr +i /etc/resolv.conf

If you want to edit the file again you need to undo the chattr setting like so:
$ sudo chattr -i /etc/resolv.conf

Categories: Network, Ubuntu Tags:

Backing up your database

June 23rd, 2011 2 comments

Let me start by saying that there are MANY ways to backup databases and this might not be the absolute best way, but it definitely works. I’m backing up my PostgreSQL database that happens to be populated by Django, but you can muck with things as you see fit.

So, one of the decisions I had to make is whether to save a representation of the data or to just dump the database data itself. The first option would be something like this:

python dumpdata --format=yaml

Second option is to talk directly to the database. The benefit of this option is you get everything about the database in its current setup. Let’s say you made some changes to the schema directly within PostgreSQL. If you dumped the data into YAML or JSON you wouldn’t get those changes to the database itself. So it’s probably prefereable to go straight to the DB like so:


What I ended up with is a nightly backup on the database server. Then I pull that data from onto a second server using rsync.


Steps it took:
1. Setup e-mail sending, so that I get cron e-mails.

$ sudo apt-get install mailutils
$ sudo apt-get install exim4-config
$ sudo dpkg-reconfigure exim4-config

Test sending of mail from server

$ echo Test | mail -s Test <YOUR E-MAIL>

E-mail sending log lives here:



2. Setting up cron job on server to stash database schema and data. What I did is ran the cron job as the postgres user so that it would have access to the database.

$ su postgres

$ crontab -e
0 1 * * * pg_dump > "<PATH TO BACKUPS>/$(date +\%Y-%m-%d).psql"


3. Setting up pulling data onto another machine; setup e-mail just as you did on server machine

$ crontab -e
Categories: Django, PostgreSQL, Ubuntu Tags:

Emacs config

February 10th, 2009 No comments

Setting up your emacs to startup with all your settings set, makes life quite a lot simpler. My setup right now isn’t too complicated. I plan to think about a better setup for my Django work in emacs one of these days, but for now a couple things that are useful to know about. First the config file on Ubuntu for emacs

Setting a pretty cool color theme with a black background:

(require 'color-theme)
(setq color-theme-is-global t)

Opening a directory to start in:
(setq default-directory "/location/of/folder/")

Lastly starting with a file open:
(find-file "/location/of/folder/")

Categories: Eclipse, Ubuntu Tags:

Pinax update: breaks external dependencies

February 2nd, 2009 5 comments

Have you been working off the Pinax trunk only to be surprised by the following message after an update:
 Error: No module named notification

Basically what happened is summarized on the django-hotclub page, which I apparently should start paying closer attention to:

What this all means is that you will need to change your setup a bit to get Pinax to work in its new setup… What I had to do first was install pip and virtualenv
sudo easy_install pip
sudo easy_install virtualenv

If you need to setup easy_install or you have any trouble with the following step, try updating python-setuptools
sudo apt-get install python-setuptools

You will also need to install git and bzr as mentioned in the wiki page. On my Ubuntu box, it was simple as installing git-core and bzr
sudo apt-get install git-core
sudo apt-get install bzr

After that you need to run the following command to download the apps (Feb 6, typo fixed, thanks Vernon):
sudo pip install -r pinax/requirements/external_apps.txt

And then back to your normal:
python syncdb
python runserver

(of course this is just on your dev box…)

hope that helps.

Categories: Pinax, Ubuntu Tags:

Append to PYTHONPATH in Ubuntu

August 13th, 2008 2 comments

Not sure how other distros have this setup, but I know this works with Ubuntu…

First off, to view your PYTHONPATH. Load the python shell, by just running “python” from your favorite prompt. Then the following.

>>> import sys
>>> for line in sys.path: print line

Modifying it is as simple as adding a path file (such as “myproject.pth”) to this folder:


Then within the file “myproject.pth” put the path to the folder of interest.

Important asside:
Although this is useful to know, the reason I ended up figuring this out was to add the path of my project so that my own project could access a certain folder within the project. What I really missed was just adding an within the folder I added to my project, which is why I couldn’t treat the folder as a module… Arg!

Categories: Linux, Python, Ubuntu Tags:

Synergy: two computers one set of input device

April 22nd, 2008 No comments

Find yourself using two computers right next to each other and having to lift your arms (what a chore!) and move them over to the other keyboard, don’t! There’s a client/server solution to solve this problem called ‘Synergy‘.

Their documentation is actually quite good, but I figured I’d put my config and experience up anyways.

One issue I did have when setting up the system was when trying to use the QuickSynergy GTK program. It was a bit shoddy and did not save the settings after I input them in. Albeit the version that Ubuntu’s got in the repo is outdated…it’s version 0.6 and the most recent version 0.8 setting it up manually seems to be the better bet.

All you need to do is setup one config file named ‘synergy.conf’ and place it in your root (‘~’). This file only belongs on the machine that will actually be controlling the action, namely the machine with the kebyoard/mouse you want to use.

My setup looks as such.

section: screens

section: aliases

section: links
right = client
left = server

All you need to do after saving that file, on the server (the keyboard/mouse machine) machine running:

On the other machines run:

Categories: Ubuntu Tags:

Multiple Desktops in Gutsy Gibbon

March 24th, 2008 No comments

I like having the Cube setup in my environment. To properly set it up of course activate the cube, but you’ll also need to have the desktops setup properly.

From ‘general options’ go to the ‘Desktop Size’ tab and set ‘Horizontal Virtual Size’ to 4 and the other to options to 1.

Categories: Ubuntu Tags:

Subversion – ‘No repository found’ error

March 20th, 2008 2 comments

I was getting a “No repository found in” error which was a result of starting up subversion wrong. Even if you’re in the directory where svn resides you need to call the “-r” option on “svnserve”

svnserve -d -r svn

Another problem I ran into was that my user needed permission to change the files from Ubuntu. To aleviate that run:

sudo chown -R user home-directory/

Categories: Subversion, Ubuntu Tags:

Django through Apache on Ubuntu

March 14th, 2008 No comments

To: /etc/apache2/httpd.conf

<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE <project>.settings
PythonDebug On
PythonPath "['/parent', '/parent/project'] + sys.path"

I found the instructions a bit confusing on the site. So I hope this clears up things a bit. My thought is they think the setup for live systems and where those files reside is different in the minds of the developers although that pathway isn’t really brought to light in the docs. It’s kind of hinted at, but here it goes.

In order to get my project up on Apache I had to include both the path for my project as well as its parent. The reason being is that it needs to be able to tie into your file and wants to know the project that’s a part of. In order to get that relationship it needs the folder of the project itself. I also added the path for the project so that it could tie into the applications.

What this means.
Replace <project>: with the name of your project
Replace /parent:  with the directory of the parent directory to your project
Replace /parent/project: with the directory of your project
Save the file and then restart apache:

apache2ctl restart

Categories: Apache, Django, Ubuntu Tags:

Installing Django from SVN and setting up django-registration (on Ubuntu)

March 14th, 2008 No comments

Go to the shell and navigate to a directory that you want to leave the Django codebase. then enter the following code to check out the current codebase from Django:
svn co django-trunk

Next you will need to make a symbolic link to the Django codebase:

sudo ln -s `pwd`/django-trunk/django/ /usr/lib/python2.5/site-packages/django

Link to django-admin, which is used to create Django projects:

sudo ln -s `pwd`/django-trunk/django/bin/ /usr/local/bin

Make sure not to use regular apostrophes around pwd or else you could run into an error with your libraries.  I was getting this error (since the mapping was going to the wrong place)
Traceback (most recent call last):

File "", line 2, in <module>
from import execute_manager
ImportError: No module named

Django registration

svn checkout registration/
sudo ln -s `pwd`/registration /usr/lib/python2.5/site-packages/registration

Categories: Django, Linux, MSSQL, Ubuntu Tags: