All posts by Rudolf Vavruch

PostgreSQL functions and triggers

It is desirable to avoid using database functions. They are black boxes which gift only night horrors to unwary developers. A system is difficult to understand, maintain and debug when chunks of it lurk unseen in the DB.

Despite this – for certain features – using them does make sense. Provided the database function’s code is source controlled and huge lumps of comments referring to both the location and function of said code is spread evenly throughout the associated application code.

For example, in order to bill Ekaya agents accurately we needed a log of show house status changes, from upcoming to active to past or cancelled. Most of these changes were implemented in sweeping SQL statements that, while efficient at their own task, made it difficult to track individual changes.

Continue reading PostgreSQL functions and triggers

Postgresql date formatting

Preamble

Formatting of data should only occur in the final steps of output. Until that point, and as a rule, internally data should remain in a base format that can easily be converted into many others – without being converted into another more basic format first.

For example Unix timestamp for dates or a floating point number for money. Both can readily be converted into more expressive formats without writing code to first parse or disassemble the initial format.

However in a situation where the flow is very specific and unlikely to ever be used to generate a different output it is permissible, even desirable, to generate data in the format it will be finally outputted.

Continue reading Postgresql date formatting

Bash script to download SXSW podcasts

For the last few years I have listened to the podcasts from SXSW while travelling to work or more recently while at gym.

Each year the number of podcasts has increased to the point where this year I am now too lazy to click through to every page and DownThemAll!. Besides it’s more fun to write a bash script to do the heavy lifting.

Continue reading Bash script to download SXSW podcasts

Inside every DVD is a small movie trying to get out. Part 1: A quick guide to K9Copy

The problem with backing up a regular store bought movie DVD is that it simply won’t fit into a normal blank DVD. The movie DVD is a 9GB monster, and the blank a svelte 4.4GB. There are two solutions to this: re-encoding and transcoding. This article is a quick guide to performing a transcode using K9Copy (similar to DVDShrink) on GNU/Linux.

Simplifying terribly, re-encoding takes the better part of a day or longer and the result is an .avi or similar file. These are so much smaller than the original that you can fit four or more reencoded movies onto a single 4.4GB DVD, but they won’t play in a regular DVD player. On the other hand a transcode takes about an hour and results in a single movie on 4.4GB DVD, which will play on a regular DVD player.

Transcoding works by lowering the quality of the movie to make it smaller. The smaller the desired end result, the worse it is going to look, but with a normal sized movie you shouldn’t be able to tell the difference.

Continue reading Inside every DVD is a small movie trying to get out. Part 1: A quick guide to K9Copy

PHP cURL over SSL

WARNING: Using this method will open you to Man-In-Middle_Attacks. As suggested by Filip Procházka in the comments below, you should get an up to date CA root certificate bundle and use CURLOPT_CAINFO. This article suggests a secure method for dealing with self-signed certificates.

If you’re getting stuck trying to use cURL over https in PHP, try setting both the verify peer and verify host options to false:

$url = 'https://myverysecret.domain/secrets/';
$curl = curl_init($url);
curl_setopt($curl, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($curl, CURLOPT_SSL_VERIFYHOST, false);
curl_exec($curl);

PAM and the Bad password blues

Warning: Only try this at home! Using weak passwords on a computer that this is accessable from the wild and dark Internet, is tantamount to walking up to a spammer and saying “I’d simply love to be part of your zombie network—where do I sign up?”. I could safely do the following because this server is not accessible from the Internet and never will be, it’s a local test box for my own personal use.

I was creating a new user on a local CentOS 5.3 VirtualBox and while I was setting the password I received the following error: BAD PASSWORD: it is based on a dictionary word

After soul searching I found I didn’t feel coming up and then remembering a complicated enough password to make PAM happy, ie. not a dictionary word, long enough etc.

So instead I spent a while reading up on PAM—which, as it turns out, is a small team of alluring ladies and well worth stealing a look at.

Continue reading PAM and the Bad password blues

Monitoring bandwidth with bwm-ng

I discovered how to watch the bandwidth of server today using a tool called bwm-ng. It’s in the Ubuntu Hardy repos, you can install with the following command:

sudo aptitude install bwm-ng

When you run it in a terminal without parameters, it displays a running update of how much bandwidth is being used. This makes it a handy tool to get an immediate idea of what your network traffic is like, and there are also options to examine disk IO. Besides the “live running commentary” mode, it can also output in other forms as well, for example CSV.

Continue reading Monitoring bandwidth with bwm-ng

Using lmc_tween in Flash 8 without installing the extension

My brain is made of honey. In my previous post on lmc_tween. I wrote I would explore ways of getting lmc_tween working in Flash 8 which did not require installing the extension.

The obvious solution that came to me five minutes after posting is to stick all the lmc_tween classes into a directory and include it in your classpath.

Disclaimer: I recommend this method only for working with old code that uses lmc_tween. For new projects I strongly suggest you use Fuse Kit instead.

  1. Go to the lmc_tween site.
  2. Scroll down to the “Ziped version” (sic), and download version 120. Direct link. (lmc_tween is no longer in development, this is the last version).
  3. Extract the downloaded file and copy the new directory to your source folder.
  4. Somewhere inside your code you should have

    #include "lmc_tween.as".

    You need to modify this to point to the new source directory. For instance I renamed the extracted directory “lmc_tween”, so my line changes to

    #include "lmc_tween/lmc_tween.as".

  5. Add your lmc_tween directory to your FLA’s classpath:
    File > Publish Settings > Flash Next to ActionScript version select the Settings... button and add your extracted directory to the list of classpaths.

  6. If you have previously installed the lmc_tween extension, you can disable it now by selecting:

    Help > Manage Extensions

    And untick the box next to Movieclip Tweening Prototypes. You will have to restart Flash.

Now you, and anyone else who works on this project, will be able to compile it without the installing extensions and overwriting Macromedia’s core classes.

Happy Minor Edits!

lmc_tween & Flash 8 – the Bain of my existence

Update 2007/05/23: I’ve found a better way of dealing with legacy lmc_tween code.


Maybe a little harsh, it’s definitely frustrating though.

Since I started my new job in November I have had to deal with legacy code left behind by the previous Flash developer.

I’m not one for working with another’s code to start with. I always get an itch to redo from scratch about a quarter of the way in, but time waits for no redevelopment. I end up hacking at code till it limps in the right direction.

The previous developer had a taste for lmc_tween.

One of lmc_tween’s pitfalls is that in order to use it to extend MovieClips you need to replace Macromedia’s core classes. Which means every person in the workflow who has to work with it needs to know about this, and mess with their core classes. This leaves me feeling uneasy.

Of course the previous developer extended his MovieClips in every project — it’s a natural way of working with objects.

And of course the above method works only in Flash MX 2004. Flash 8 just spits out errors and does no tweens. I have always managed to work my way around this, but tonight I decided to find a proper solution.

After lots of googling I found a very simple answer. Put the location of the two classes you need to replace in your class path:

Preferences > ActionScript > ActionScript 2.0 Settings

C:\Documents and Settings\user\Local Settings\Application Data\Macromedia\Flash 8\en\Configuration\Shared\zigo

This way your core classes remain untainted and the tweens bounce about happily.

This does not help the designers on their Macs, though. I’m going to investigate the possibility of not having to install the extension. Trying to explain to client how to install lmc_tween over the phone is an enriching exercise.

If you’re looking for programmatic tweens — the newer and friendlier Fuse Kit reigns supreme at the moment. It uses the same Zigo engine and Penner tweens as lmc_tween.

You do not have to install the extension, just place the classes in your source directory and import the classes normally. That way you can package the Fuse classes with the project anyone who comes into contact with it can build it without jumping through any hoops.

It can do more than that though, Fuse is a sequencer…