See also: Heapify

Pages: 1 2

Detecting, locating and fixing referenced based heap memory leaks (Java)

A common problem we all have to deal with is fixing memory leaks. In garbage collecting languages like Java we typically expect not to ever need to worry about memory management. However the limitations of how a garbage collector works means that we can still create leaks. Which defeats the advantage of a garbage collector.

How do leaks get formed?

The Java GC determines which objects to collect by looking for references to the object. If there is no references, then the object is no longer in use and can be safely destroyed without making the application unstable. If an object is now unused but still referenced, a leak occurs. Let's create a leak:

...

Read more

There are no comments on this post.

Strong, Soft, Weak and Phantom References (Java)

There are four distinct forms of references in the JVM, and indeed many of these apply to other garbage collected languages.

  • Strong references
  • Soft references
  • Weak references
  • Phantom references

It's important to know the differences, what affect they have on the collector and when you should be using them.

...

Read more

There are 2 comments 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.

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.

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.

A caffine induced sense of humour? I surely hope not

Super serial!

import java.io.PrintWriter;
import java.io.Serializable;    
class Doug implements Serializable {
  public Doug(PrintWriter out) {
    out.println(getMood());
  }
  private static String getMood() {
    return ":-(";
  }
}
/*
 * __        ___   ___   __  ____   ___
 * \ \      / / | | \ \ / / / ___| / _ \
 *  \ \ /\ / /| |_| |\ V /  \___ \| | | |
 *   \ V  V / |  _  | | |    ___) | |_| |
 *    \_/\_/  |_| |_| |_|   |____/ \___/
 *
 *  ____  _____ ____  ___    _    _    ___
 * / ___|| ____|  _ \|_ _|  / \  | |  |__ \
 * \___ \|  _| | |_) || |  / _ \ | |    / /
 *  ___) | |___|  _ < | | / ___ \| |___|_|
 * |____/|_____|_| \_\___/_/   \_\_____(_)
 */

...

Read more

There are no comments on this post.

Cartoon prediction of Corewars Tournament

With the upcoming Core Wars Tournament looming, a small cartoon is in order!

Dont feel sorry, in a past life micmast ate imps for breakfast!

Core Wars is a programming game where programs called warriors face off in an epic battle to crash each other.

...

Read more

There are 2 comments on this post.

tvnamer 1.0

As the "final commit" mentions, 387 days and 330 commits after the I started, tvnamer and tvdb_api are at a point where I'm happy to release "version 1.0"!

tvnamer is probably of most interest, it's an automagical TV episode renamer, turning files from "some.show.s01e01.hdtv.blah.avi" to "Some Show - [01x01] - The Real Episode Name.avi", using information from thetvdb.com

To install, simply do..

...

Read more

There are 2 comments on this post.

irssi, figlet, greatness

/alias figlet /exec - -o echo $0-| figlet -w 60 | awk -F% 'function randint(n){return int(33+n * rand())} {printf("x03%s%sn",randint(12),$1)}'

Combining the joys of shell scripting, figlet, irssi colour escape codes and two different kind of escape sequences, you can achieve the following...

Awe Inspiring Figletification

...

Read more

There are 3 comments on this post.

Download music from songza

Songza is a popular website that allows you to listen to almost any song instantly. Most of the songs are MP3 files, but there doesn't seem to be a way to download them. Some of the results are youtube videos, but the videos are invisible, only the music plays. Let's fix that.

...

Read more

There is 1 comment on this post.

Pages: 1 2

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