See also: Heapify

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

What's Up With the 'File' Menu?

firefox file menu

I'm no usability expert. In fact, I've been called tasteless by many people (my wife included), but what the hell is up with pretty much all programs having a 'File' menu?

http://dictionary.reference.com/ defines 'file' as:

...

Read more

There are no comments on this post.

Object pools (Python)

A very common problem in software engineering is optimising out the problem of construction and destruction of objects. I don't necessarily mean objects exclusively in the context of object orientated programming. I mean objects as in data objects, which could be a large array or a struct and so on.

If you don't need objects for a long time it does seem silly to construct an object, initialise it, then destroy it and discard it. Especially as memory allocation can be expensive.

The most common approach to minimising the impact of this is object pools. An object pool is a collection of pre-constructed objects, sometimes even pre-initialised objects. When a program wants to use an object for a short period of time they can check-out an object, configure it to their needs (if necessary), use the object and then check it back into the pool.

...

Read more

There are no comments on this post.

Brute forcing the touring knight problem

The touring knight problem is a maths problem that takes the movement of a knight in chess and attempts to find a path around a two dimensional board such that every single square is visited exactly once.

There are more sofisicated solutions but as you might have imagined, brute forcing is the most naive approach to solving this problem.

By trying every possible combination of legal move from your current position you can follow through every legal path and check whether you've completed the board or not.

...

Read more

There are no comments on this post.

Why Don't You Use virtualenvwrapper?

If you're a python programmer, you've most likely heard of [virtualenv][a]. If you haven't, then you need to check it out.

virtualenv is a tool to create isolated Python environments.

In a nutshell, you can create as many virtual environments as you want. Each of these virtual environments is a small directory structure, which contains a copy of your python interpreter(s), and provides a sandbox environment in which you can install only the necessary packages you need to run your project, as well as remove your programs' dependence on system packages and python versions.

...

Read more

There are no comments on this post.

How to Streamline Asterisk

So, you use Asterisk professionally, for fun, or both, and you want to know how to optimize the shit out of your Asterisk platform? No problem, I've got you covered.

Grab a beer, free up the next 2 hours of your time, and let's get to it!

...

Read more

There are no comments on this post.

Prototyping in Python

Our good friend Randall was talking about how he liked prototype inheritance such as that in JavaScript. He enjoyed how you can add, modify and remove methods from JavaScript classes and have them apply to all object instances.

Amazed as he was, he's now forcing me at gun point to write a post about it!

The first thing you have to understand about Python classes is that all they are is a collection of references to members. Methods are just function pointers that are referenced by the class, not embedded or copied into the class. This is why all methods require that the first parameter be self, the current instance. Instances themselves contain the real state and reference the class. When you invoke a method on the instance it looks up what function to call.

...

Read more

There are no comments on this post.

Python Challenge Thoughts

If you didn't read my previous post, you'll want to check that out first: The Purely Functional Python Brainfuck Challenge.

So, today was the first day I really invested some thought and time into the challenge. I decided that before just diving into code I'd spend some time reading up on functional programming in python, and learn a bit.

The first thing I read through was the official python functional programming page which you can find here. This had a bunch of useful information regarding functional programming tools in python, but didn't really have any examples of actual functional programs.

...

Read more

There are no comments on this post.

Ternary operator in Python

People are always wondering if Python has a ternary operator. The answer is yes but no.

There is no recognised ternary operator. However it is very simple to construct one out of logic operations.

Python short circuits conditional evaluations. This means that given a series of logic operations, if it can plainly see that a certain branch of that logic is unreachable or of no consequence it wont even attempt to execute it.

...

Read more

There is 1 comment on this post.

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.

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

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