See also: Heapify

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

Rename all jpeg files by their exposure date (Bash)

I like to organise my files by when they were taken. So I wrote a script to do it for me. You will need the jhead tool installed. On Debian/Ubuntu/etc this is in the jhead package.

#!/bin/bash
 
rm renameJPEG.restore.sh
 
for file in *.jpg *.jpeg *.JPG *.JPEG; do
        if [ ! -e "$file" ]; then
                continue
        fi
        echo "Inspecting $file"
        DateTime=`jhead "$file" | grep "Date/Time"`
        FoundCount=`jhead "$file" | grep "Date/Time" | wc -l`
        if [ $FoundCount -gt 1 ]; then
                echo "Found too many results for: $file"
                continue
        elif [ $FoundCount -eq 0 ]; then
                echo "No valid headers found."
                continue
        else
            BaseFile=`echo $DateTime | awk '{ print $3 }' | tr ':' '-'`
            for i in `seq 1000`; do
                if [ ! -e "$BaseFile - $i.jpg" ]; then
                    echo "New file: $BaseFile - $i.jpg"
                    mv "$file" "$BaseFile - $i.jpg"
                    echo "mv '$BaseFile - $i.jpg' '$file'" >> renameJPEG.restore.sh
                    break
                fi
            done
        fi
done

This will rename all the files to the format YY-MM-DD - i.jpg where i is a uniquifier. Note that if you've some files with bad headers then you will get the wrong output.

...

Read more

There are no comments on this post.

Deployment System Requirements

Over the past month, my colleague Kurtis and I have been engineering a fully automated deployment system for all of our projects at work. This system was created to remove the painful deployment process from our development environment. This article discusses the requirements that we had for our deployment system. I eventually hope to discuss the entire thing, how we built it, and what revisions we make.

Why Deploying Can Be Painful

Most programmers hate deploying code. I certainly did until this past year. Deploying code is (often times) much harder than writing the code itself. Deploying requires a great deal of knowledge: OS configuration and setup, cloud provider APIs or physical server installation quirks, numerous software components, system monitoring, access lists, and a lot of other things.

It's a pain.

...

Read more

There are no comments on this post.

Web Designers vs Web Developers

It's been a long time. We deserve a post! Even if merely a link.

This is so true. Web Designers vs. Web Developers. Combat trousers are awesome. The principle reason I dislike suits is that there's never enough pockets. When you have more than 10 pockets in your trousers all of your development life, then you put on a suit and are restricted to 4. It the bane of my professional life.

...

Read more

There are no comments on this post.

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.

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

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