• Versioning your Python project for Debian

    Version numbers matter! Using a consistent version numbering throughout your project's life matters, too. Changing project name is a high price to pay for cleaning up version errors.

    So there's some good news! The Python community's PEP-440 specifies how to use versions.

    Here are some examples of versions that abide PEP-440, they are in order!!


    • 0.1.dev1 - Our first release, just playing around. We'll delete ...

    Read the rest of this entry »
  • Debating Internet.org

    [also brought on FAIR Denmark]

    Facebook has launched Internet.org, maybe a solution that will provide internet access to lots of people who need it? In this post, I'll explain what I think about it, because certainly it doesn't seem like a project we can just ignore.

    Others are also discussing the issue, and already a group of 65 international organizations have signed a letter with lots of ...

    Read the rest of this entry »
    Posted in Debate, ICT4D |
  • Regenerating Shotwell thumbnails

    When reinstalling, upgrading or moving settings, thumbnails may be missing in Shotwell. The problem can look like this:

    shotwell_missing_thumbs

    Each time you import photos, Shotwell will generate thumbnails in two different sizes. If you loose them, you have the problem that they are regenerated on-demand, everytime you scroll by an image. That stinks.

    Requirements

    You need to do apt-get install sqlite3 imagemagick to fetch requirements.

    Source

    Here's a script that ...

    Read the rest of this entry »
    Posted in Multimedia, shotwell, Ubuntu |
  • Nokia 301 on Wammu / Gammu

    I had an older Nokia and got a new one which I needed to upload my phone book to. In order to connect to Nokia 301 from Gammu, plug the phone in with a USB cable and select the "Modem" option on the phone. The others won't work.

    Wammu is a GTK frontend to Gammu. You can use for various tasks, but I found that restoring my backup through ...

    Read the rest of this entry »
    Posted in Computers, Ubuntu |
  • Ubuntu 14.04 Trusty with DNS server and NetworkManager (disabling dnsmasq)

    I've badly been looking for a way to both run an internal network server on eth0 and connecting to any kind of internet device, be it on wlan0 or a USB dongle.

    That way, I can be online and browsing documentation, downloading new stuff etc. on the server but not depend on a static configuration but still use Network Manager for its intended purpose.

    In /etc/NetworkManager/NetworkManager.conf ...

    Read the rest of this entry »
  • Ubuntu, Kickstart, preseeding, and Wireless (WLAN)

    I have been trying to get an automated network install running. The starting point is a Kickstart (Kickseed) setup that works fine on LAN. Problem is: Computers do not do PXE netbooting from WLAN, and secondly that the debian installer was not configuring the network correctly. But the steps are very simple.


    1. Get mini.iso, basically the same kernel and initrd that the netbooter is running

    2. Put it on a ...

    Read the rest of this entry »
    Posted in Ubuntu |
  • Limiting choices in a ModelAdmin list_filter

    So, you need to limit choices, because the list of related choices is too long? Then do NOT use limit_choices_to parameter on the ForeignKey! Why? Because you risk having options missing in your forms, deleting relations unknowingly.

    For instance, consider that you have the following case, expressed in pseudo code:


    ModelClass.related_instance = models.ForeignKey(MyRelatedModel, limit_choices_to = {'active': True}, blank=True, null=True)
    object = <ModelClass instance>
    object.related_instance = <MyRelatedModel instance>
    object ...

    Read the rest of this entry »
    Posted in django, django-admin |
  • Testing and tracking down Warnings in Django

    Warnings are often suppressed through many layers of control mechanisms in Python and Django. However, you should really be aware of these and clean them up once in a while!

    In other cases, the Warnings reflect an inconsistent state, such as if you are mixing naive and timezone-aware variables. It can be a real pain to track down RuntimeWarning because it doesn't leave a nice stack trace. The scenario ...

    Read the rest of this entry »
    Posted in django, Python |
  • Django: Log and block brute force attempts

    Here is a very simple mechanism for wrapping a decorator around your views to protect them against brute force attempts. For instance, if you have a secret file download available only with the right secret (/view/id/secret-hash/), you expose your view to simple brute force attempts.

    Simply put, this decorator will log a 404 response object or Http404 exception, count pr. IP and return status=400 and send you ...

    Read the rest of this entry »
    Posted in django |
  • Share an internet connection: A nice little script for quickly getting the task done.

    This script uses iptable forwarding and dnsmasq to share an internet connection with full relay of remote DNS servers and a local DHCP server. Before trying the script, here is the over all steps:


    • You connect to the internet in your normal fashion. For instance with a 3G dongle and your network manager applet.

    • Make sure that nothing is running on port 53, run netstat -tlnp to debug

    • READ THE ...

    Read the rest of this entry »
    Posted in Computers, Ubuntu, Web |
  • To Save Everything, Click Here: The Folly of Technological Solutionism

    There is a new book coming up with a very remarkable abstract, to be released on March 5, 2013:

    In the very near future, “smart” technologies and “big data” will allow us to make large-scale and sophisticated interventions in politics, culture, and everyday life. Technology will allow us to solve problems in highly original ways and create new incentives to get more people to do the right thing ...

    Read the rest of this entry »
    Posted in Debate, Web |
  • First impressions of GTK3 migration in Python

    Yesterday, I succeeded in moving a GTK2 project* with a custom Cairo widget to GTK3. It's about 750 lines of Python and took ~5 hours to migrate, mainly because my method was about googling and solving all Exceptions one by one. That's not very advisable.

    You can read a more thorough introduction to GTK3 and Python here -> python-gtk-3-tutorial.rtfd.org

    The first thing, you need to know, is ...

    Read the rest of this entry »
  • django-wiki

    Posted in Main menu |
  • Using gtk with threads? Write a decorator for gobject.idle_add

    Hi there!

    If you've ventured just a little bit into GTK and threading, you have probably noticed how things can explode if you manipulate GTK objects directly from a thread. GTK is not threadsafe.

    However, this tip might help you get stuff done properly:

    1) Do your actual work in a thread and give the thread callbacks for whenever it wants to update the UI. Keep those callbacks in ...

    Read the rest of this entry »
    Posted in pygtk, python, Python, Uncategorized |
  • Making the django foreign key admin widget more useful

    Thanks to a user at Django-snippets, I was able to quickly create an app containing a widget for displaying icons along side the normal related widget for foreignkey fields.

    The result looks like this:

    It's pretty easy to use.

    Check it out on Github!

    Read the rest of this entry »
    Posted in django |
  • Large-scale Computer Reuse Suite (LCRS)

    For the benefit of people and the planet, let us start re-using, repairing and refurbishing computers instead of creating more e-waste!

    This software allows for a computer refurbishing organization (such as FAIR) to keep track computers being broad through a refurbishing system, including individual hardware profiles, hard drive wiping, and in the future also other aspects of quality assurance.

    LCRS is an open source project available through Google Code:

    http ...

    Read the rest of this entry »
  • Ubuntu tip: Save a list of installed packages for reinstallation purposes

    If you have a nicely running Ubuntu system with all your favourite packages installed, it might not seem like a good idea to start all over or to replace your hard drive. But here's a tip: To save a list of all packages that are currently installed! This should be a part of any good backup.

    apt-cache --installed pkgnames

    Save them in a file:

    apt-cache --installed pkgnames > installed.packages ...

    Read the rest of this entry »
    Posted in Ubuntu |
  • Overriding change_form.html and accessing the object instance

    Here's an example for a custom change_form.html located in app/templates/admin/appname/modelname/change_form.html - and the cool thing is that it accesses the actual instance of the object, which I found to be very convenient and undocumented. If you want it to be more explicit than access through the builtin context variable adminform.form.instance, you can also make your own change_view.

    {% extends "admin/change_form.html ...

    Read the rest of this entry »
    Posted in django |
  • To all my Thinkpad friends running Linux

    Hello there!

    A little tip that can really improve your battery life and give you peace of mind while working: Install thinkfan: A simple fan control program.

    Installation

    Here is how it goes on Ubuntu: Step zero is to become superuser (sudo bash). Then you install the thinkfan package.

    ~# apt-get install thinkfan

    Once the package is installed, you can try running it as a normal process to see how it ...

    Read the rest of this entry »
  • django-cms 2.0.2 and Django 1.2 - 1.3

    If you are running an old version of django-cms, you can still upgrade Django. I would strongly suggest doing this since it's very uncomplicated. However, if you are running django-cms 2.0, you should first upgrade to 2.0.2 and run the South migrations, which is also totally uncomplicated.

    django-cms 1.x are most likely stuck on older versions of Django as well. I did once try to ...

    Read the rest of this entry »
    Posted in django, django-cms |
  • Stopforumspam Django Middleware

    I have created a new Django app for keeping out spammers on the basis of data collected by stopforumspam.com. Read all about it here »

    It's free, open source, and I hope people will make it better on github.

    Read the rest of this entry »
    Posted in django, Ubuntu, Web |
  • Automating stopforumspam.com ASAP (updated!)

    In case you need a quick way of getting rid of spammers on your apache server, use this method as a temporary solution until you find a better one.

    Please take not that it will evaluate EVERY SINGLE REQUEST through a Deny policy in Apache's mod_access - it does not halt your performance much if you're just running a site with few requests. But I only suggest this solution ...

    Read the rest of this entry »
  • Automating stopforumspam.com

    THIS DOES NOT WORK WITH APACHE SINCE IT DOES NOT USE /etc/hosts.deny - See this post instead

    Use the following Python script to maintain a file in the hosts.deny syntax so that your Debian/Ubuntu box (or other Linux server) is kept undisturbed by forum spammers -- COMPLETELY undisturbed, as the spammer is disallowed all access to the system.

    1. Copy the script to a file on your server ...

    Read the rest of this entry »
    Posted in Python, Ubuntu, Web |
  • Boycutt Paypal: Installing BitCoin on Ubuntu

    BitCoin is a free and open currency that will exist safely and decentralized online. Read about it.

    This method is reported to work on 10.04 (Lucid), and I can confirm that it works on 10.10 (Maverick). I don't yet know about 11.04 (Natty).


    1. Open a terminal

    2. Type:

      sudo apt-add-repository ppa:stretch/bitcoin
      sudo apt-get update
      sudo apt-get install bitcoin


    3. To run BitCoin, navigate to Applications -> Internet ...

    Read the rest of this entry »
    Posted in Ubuntu |
  • Using GtkBuilder and connect_signals

    I have been hunting spontaneous crashes with errors from the C GTK libs. The errors looked somewhat like these:

    Warning: g_object_ref: assertion `G_IS_OBJECT (object)' failed
    gtk.main()
    Warning: instance of invalid non-instantiatable type `AtkSelection'
    gtk.main()
    Warning: g_signal_emit_valist: assertion `G_TYPE_CHECK_INSTANCE (instance)' failed
    gtk.main()
    (...)
    Warning: instance of invalid non-instantiatable type `'
    gtk.main()

    In most versions of GTK window decorators, this caused a crash - in a few lucky cases, it didn ...

    Read the rest of this entry »
  • Headaches over disabling/enabling services in Ubuntu?


    UBUNTU 12.04 / Upstart 1.3 update

    If you are trying to disable an Upstart script (something that can be started/stopped with "sudo start/stop service-name") , you should really use the method described by Luis Alvarado on AskUbuntu. Please use this to avoid editing scripts that are actually maintained in your repository.


    But all of this is great for temporarily working with the service. How about a way to ...

    Read the rest of this entry »
    Posted in init.d, services, ubuntu, Ubuntu, upstart |
  • Projects


    • Eggplant community open source project that I've participated in since early days. A direct market between biodynamic food coops and growers.

    • Kolibri Next-gen offline learning software for distributing interactive learning materials through an extremely flexible platform for all kinds of contexts.

    • KA Lite a stand-alone offline solution for interactive Khan Academy classroom and single-user experiences.

    • www.django-wiki.org
      Started it in 2008, now making it a prime time state ...

    Read the rest of this entry »
  • Start

    Posted in Main menu |
  • Changing the Django Admin site title

    Often the Django Admin should look a little different for the sake of your users or for the sake of yourself (running multiple django sites with identical looks and titles can be such a pain). Often users don't know what Django is, and it takes ages to explain, and even after that they have no clue. Also, often my administration has nothing to do with a website, so I ...

    Read the rest of this entry »
  • Django tip: Automatic logins

    In the Django documentation we see the following:

    When you're manually logging a user in, you must call authenticate() before you call login().

    That's all really nice, because it makes sure that all your authentication backends are tried out; but if you want a really quick remedy for getting the job done, then you'll need to set the user.backend property to the specific backend that authenticated ...

    Read the rest of this entry »
    Posted in authenticate, django, login |