This weekend saw a sudden surge of spam comments coming my way. Strangely though, the comments seem legit. No links to various websites, not random text – nothing. Just a few sentances that are so generic they seem relevant.

I let the first couple through – It wasn’t until I noticed i had comments from several different ‘people’ all from the same IP that I started to question it. Further investigation reveals a peculiar email address and that every ‘person’ has google as their website address.

Apparently this was a massive spam attack

So, for those with blogs beware. Comments along these lines should marked as spam:

KattyBlackyard
google.com
katty@ds4ns1ns2.cn
89.28.14.35
Submitted on 2009/06/15 at 11:09am

I really like your post. Does it copyright protected?

,

I’ve just started using PostgreSQL as my database of choice for a few projects, and needed some way of scheduling backups. As a result I’ve created the following small bash script that will backup a given database and put it in a gzipped tar archive.

You can find the script in my svn repository here.

Usage is pretty simple:

backup_pgsql dbname

where dbname is the name of the database you want to backup.

By default, the script tries to put your backup in /tmp/ – you can change this behaviour by modifying the BACKUP_DIR variable in the script – make sure to include the trailing / though.

Now, of course this is only the backup part. To schedule this, you can edit your crontab file (usually found in /etc/crontab) and include a line like this:

1  3  * * *     root    backup_pgsql dbname

This will backup the database, dbname, at 03.01am every day. Assuming your backup_pgsql is in your PATH. I put mine in /usr/local/bin/ and chmod +x it. If you don’t want to do that, simply provide the full path to the script.

, ,

A while ago I rebuilt the video streaming solution at YSTV so that it used flash video. Not wanting to pay for Adobe Media Server, I opted to try and create my own, as it were. I knew that VLC could stream video so I set off to get it to stream flv.

Fortunately for me, the latest builds at the time of vlc could do just that. However, there was one minor flaw – If VLC was transcoding video and streaming it, every client that connected would cause VLC to start up another transcoding process. Not good.

Eventually I found a solution by sending video though ffmpeg first and piping the output into VLC.

The result of my efforts can be found on my wiki here.

The system described there has been happily serving YSTVs live webstream for almost a year now with no major problems – It even survived 150 simulteneous viewers (which considering our previous streaming solution died at 15, isn’t bad going).

I’m not going to say the streaming solution is perfect, because it’s anything but that. However, if your looking for a relatively small scale, cheap flash video streaming system, this should suffice.

Hopefully it’ll help someone, Comments are of course welcome.

, , , , , ,

I recently had a need to display the current svn revision of a php based website on the home page. This is particularly useful when working on a website as part of group and you have a central dev server than runs a copy of the latest code. It allows you to quickly and easily see which revision is being run on that server.

Anyway, on to the doing part.

There are a number of different ways to achieve this, some more complicated and tedious then others.

The simplest method I found was to parse the .svn/entries file. This, of course, relies on the fact that the code you run is based on a checkout of the repo, rather than an export. This probably isn’t a good idea in a production environment, unless you setup your sever to prevent access to the .svn folder.

The code looks like this:

$svn = File('.svn/entries');
$svnrev = $svn[3];

You can now print the contents of $svnrev wherever you want and you should get the revision number dispalyed.

Note that the 3 indicates the 4th line in the file. If you get unexpected results, check the .svn/entries file and adjust the index on $svn[] as required.

The other methods of doing this are discussed here

,

Most of the time this is a relatively trivial exercise. In the majority of cases, simply setting ‘Workbook Calculation’ to ‘Automatic’ in the Excel options will give the desired effect.

However, I recently stumbled across a situation where this doesn’t work. If you find yourself entering data into an Excel workbook through some other means – in my case, using the OpenXML libraries in C# – then you may need to force excel to update any formulas you had.

The solution is simple, using a small VB macro. To get it to happen when the workbook is opened, use the following code:

Private Sub Workbook_Open()
 
 Application.CalculateFullRebuild
 
End Sub

If you put that in the code for the main workbook (as opposed to one of the sheets) then it should happen when the spraedsheet is opened.

, ,

I recently had some fun and games upgrading PostgresSQL on my Gentoo box – I was running 8.2.7 and needed 8.3.x for it’s support of ENUM types.

After some googling I found this blog which explained how to do it. There were a few extra steps for me, however, so I though I’d repost my findings here.

Read the rest of this entry

, ,
I’ve recently been doing some research in the area of producing High Quality MP4 files with the h264 codec. Of course, my program of choice for encoding to this format was ffmpeg with the libx264 codec. I just wanted to share some of my findings, in particular a few example commands for creating these videos.

Read the rest of this entry

, , , , , ,

If like me you learnt SQL using MySQL, and then gone into a job and found yourself using Microsoft’s SQL Server, you’ll probably be as irritated as me to find that Transact-SQL does not feature the ‘AUTO INCREMENT’ keyword that MySQL provides. Fortunately, the solution is far easier here than it is in PostgreSQL.

All you need is to add IDENTITY(1,1) in your column definition. I’m not going to pretend to understand exactly what this does, only that it will Automatically increment and ID field for you. If anyone wants to enlighten me on exactly what it does, then feel free :)

An Example is below:

   1: CREATE TABLE dbo.myTable(
   2:     ID INT NOT NULL IDENTITY(1,1) PRIMARY KEY,
   3:     ColumnA VARCHAR(200),
   4:     ColumnB BIT
   5: )
   6:  

, ,

After a few delays by Microsoft, I finally got a hold of Windows 7 Beta this morning. I must say…I’m pleasantly surprised. It certainly does seem much much better than Vista was – even at the Beta stage!

Read the rest of this entry

, , ,

Page Refresh Animations

This refers to the way in which we can display some form of feedback to the user that the page is being updated, without the need for an ugly page flash or the page seemingly doing nothing.

 As always there are several ways to achieve this – a quick google will probably reveal several. Below is probably the most reliable method for our usages.

Read the rest of this entry

,