Pages: 1 2 3 4 5 6 7 8 9 10 11

Serving Static Content With Django

A question that is frequently asked by new Django programmers is: "How can I serve static content (css, images, javascript) with the Django development server?". This article is my attempt to answer that question by demonstrating the best practices way to do so.

Why Doesn't Django Serve Static Content Automatically?

Well, Django (and python in general) is built around the idea that it is better to be explicit than implicit. This concept means that you may need to write more code in order to do something, but that by doing it that way, you preserve code clarity and reduce complexity.

...

Read more

There are 3 comments on this post.

Fetching network statistics (Python and Linux)

A little bit of code that loads network device statistics from any operating system that supports procfs.

Just a small snippet. Originally used in some network monitoring code that I wrote that graphed your network traffic.

I would include that here too but that's a little messy.

...

Read more

There is 1 comment on this post.

Populating Default ManyToMany Field Values in Django

At work, I'm the lead developer of a rather large, complex web application which interacts with many different technologies (Asterisk, Freeswitch, Cisco routers, python, XML-RPC, JSON, Django--to name a few). A few days ago, while implementing a ban system, I bumped into an interesting problem that was not trivial to find a solution to. So, here it is :)

Background

The web application I'm developing is a private portal which allows users to manage teleconference lines real time. Since all of our telephony services are free of charge, we often get callers onto certain teleconference lines who want to abuse services (think of those trolls on the internet, except over the phone). As you can probably imagine, without strict regulation & technology in place, telephone trolls could cause huge problems for normal users.

...

Read more

There is 1 comment on this post.

The Asterisk Spooling Daemon

While working on the new v2 release of pycall, I was doing some research on the internal limitations of Asterisk call files, and thought I'd share some interesting (technical) bits of information here.

All information below has been gathered from the latest Asterisk release (v1.6.2.7). If you don't do any programming, you may want to skip this article, as it is a bit geeky.

...

Read more

There are no comments on this post.

Basic XML Parsing with Python and LXML

Recently I've been developing an API using python and Django for work, which uses XML responses to speak to clients. One of my goals for the client was to be able to easily parse the XML responses that the server sends, so that I could appropriately handle errors.

Fortunately, python has many tools for building and parsing XML. During my research, I tested several options, but found that the well supported library LXML was a perfect match for what I needed. Unfortunately, I had a hard time figuring this out, as examples to just parse XML content was lacking in the official tutorial, and there were no good resources online with code samples.

So let's take a quick peek at a sample XML document, then we'll analyze some simple LXML code to see how it works. Of course, before you can run any of these code samples, you'll need to download and install LXML (there are packages available on most linux systems already).

...

Read more

There are no comments on this post.

Setting the desktop wallpaper programmatically (C# Snippet)

Here's a little C# program I made that gets the filename of the currently set desktop wallpaper and also can be used to set the desktop wallpaper.

Example usage: SetDesktopWallpaper.exe C:\MyNewWallpaper.jpg

Just something I made for my sister who has Windows 7 Starter edition and lacks the presentation controls. Add it to your 'Send To' folder and just select the file you want to set the wallpaper as and go.

...

Read more

There are 3 comments on this post.

Ignoring certain content-types with urllib (Python Snippet)

This is a little piece of code I wrote to intercept and disregard a http or https request from urllib.urlopen if the Content-Type header on the response is not within a list of accepted content types.

I'm sure somebody might find a use for this.

This snippet creates a customer URLopener and then overrides the open_http and open_https methods, checks for MIME type and halts the request if the response is of a MIME type you do not accept.

...

Read more

There are no comments on this post.

Shut Up Woman, Get On My Horse

I recently found a rather odd but amusing flash animation by Weebl at http://shutupwomangetonmyhorse.com/.

Enjoy

...

Read more

There are no comments on this post.

Bash Script: Start irssi (or any process) if not already running via a cronjob

I know there are a thousand of these available online. This is one I just wrote and wanted to make it a thousand and one. This script will start irssi if there is no irssi process available.

Save the following script somewhere (example /home/kay/bin/irssi_init.sh) and add the following to your crontab:

*/1 * * * * /home/kay/bin/irssi_init.sh >> ~/irssi_init.log

...

Read more

There are no comments on this post.

Designing a user-orientated permission system

System permissions are important. Defining what people can and can't do with your application is a significant part of security.

There are two perspectives I tend to care about with permissioning. The first is user-orientated and the second is data-orientated. In this article I will talk about designing a user-orientated permission system.

For the purposes of this post a permission will be considered a boolean value that represents whether a person can or can't perform an operation. In other systems you might go as far as to consider the extent to which they have permission which ends up working like a priority based permissiong system. This is only really useful in my opinion if you've an operation two people can perform at once and you wish to provide a fine grained hints to the system as to who should have the operation performed first. It's something to consider but usually unnecessary and out of the scope of this article.

...

Read more

There is 1 comment on this post.

Pages: 1 2 3 4 5 6 7 8 9 10 11

Powered by Debian, Guinness, and excessive quantities of caffeine and sugar.