Change of address

Update your RSS feeds, kids. This blog has now moved to deviouschimp.co.uk/blog.

Future updates will be posted there and not here.

Previous posts on this blog have been copied to the new one.

Posted in Blogroll, Uncategorized | Leave a comment

PayPal v Google Checkout Integration

A comparison of PayPal and Google Checkout API implementation documentation:

Paypal:

Your third-party SOAP client generates business-object interfaces and network stubs from PayPal-provided WSDL and XSD files that specify the PayPal SOAP message structure, its contents, and the PayPal API service bindings.

Google:

Once you update your website’s HTML with the Buy Now code, you can start accepting orders and processing them through Google Checkout immediately.

Posted in Programming, Uncategorized | Leave a comment

MapInfo Removing Special Characters

I needed to remove all characters except letters and numbers from a string in the joyful language that is MapBasic. Might not be the most efficient way of doing it but it works doesn’t it?

Function RemoveSpecialChars(byval str as string) as String
    Dim chr, out, nicechars as String
    Dim i, l as Integer

    nicechars = "ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789"
    l = Len(str)

    For i = 1 to l
        chr = Mid$(str, i, 1)
        If InStr(1, nicechars, chr) > 0 Then
            out = out + chr
        End If
    Next

    RemoveSpecialChars = out
End Function

Posted in MapBasic | Leave a comment

White Spots on Fading Images in Internet Explorer

IE really is the best browser ever…if you’re into puzzle solving.

On the Baker Associates home page I have included an image fader. It’s a simple one that using the JQuery Cycle plugin (a good plugin that I would highly recommend and whose involvement in this bug is purely incidental).

I’ve fixed it now but previously white spots were appearing in the images as they faded when viewing on Internet Explorer. Between fades the images looked fine. A little rummaging on the web shows that this is a common problem caused by Internet Explorer’s image filters which sometimes treat pure black (#000000) as transparent.

There are a few ways around it. The simplest is to put a black div behind the images. You may notice there’s still one on the Baker Associates site. It didn’t help in my case but I thought I’d leave it there as it can’t do any harm.

The other, more annoying way is to replace any pure-black pixels with pixels of very, very dark grey. You can do this easily in Photoshop by going to Image > Adjustments > Replace Color. Or in GIMP by going to Colors > Map > Color Range Mapping (apparently).

I was having this problem on IE8. I’m not sure if they’ve fixed it in 9 and I can’t be bothered to find out but I doubt they have.

Here’s some link love for the people who knew the answer:
Alex JuddStack Overflow

Update 26/7/2011: Aaaarg! It’s still doing it!

Posted in Uncategorized | Tagged , , , | Leave a comment

Miranda IM’s Pointless UI “Upgrade”

Miranda IM is a minimal but highly functional multi-protocol chat client for Windows. I have been using it for ages so I was a bit disapointed when I installed the latest build to see my contact list littered with extra buttons and menus. Especially as when I tried clicking on them it seems the icons for these buttons have been chosen at random (A power icon which opens the preferences dialogue? Seriously?). There’s also a thing called “view modes” which is probably very useful if you’re a professional chatter.

Anyway, it’s not hard to get things back the way they were, so I won’t complain too much (though I am a fan of minimalism by default).

It turns out that there are a variety of difference contact list manager plugins and the latest versions of Miranda IM come with four of them installed. To get back to the old-school, minimalist look, just go to the preferences window (you know, press the power button that looks like it’s going to shut the program down or disconnect or something. Alternatively click the menu top-left that has a logo instead of a word (probably to make it awkward for people who are – like me – trying to explain things the old fashioned way – you know, using words and that…)), select “plugins” from the menu on the left. Here you have a list of all installed plugins. It’s the ones that start “clist_” that we’re interested in. We only need one, and clist_classic is the minimalist one, so select that and click “ok” and restart Miranda IM.

There are three other clist plugins:

clist_nicer
Isn’t.

clist_modern
Is fucking ugly in the way that the free software you get with printers usually is – all custom made so it doesn’t fit in with anything else. Gives the contact list a translucent border and title bar as if I’m using Windows 7, even though I’m on Windows XP. Also adds a selection of different – though equally ambiguous – icons to the top of the window.

clist_mw
Multi-window apparently. I can only see one window though.

That said, Miranda IM is still my favourite chat client and is miles ahead of any other I’ve used.

Posted in Uncategorized | Tagged , , | Leave a comment

Linux lshw Command

Here’s a short post about Linux’s lshw command. That’s LSHW as in LiSt HardWare. Pretty vital if you’re doing…well anything really.

sudo lshw
Lists all connected hardware. Outputs a lot of information. You’re probably only interested in a small part of the output, so you probably want to do something like this:

sudo lshw -class memory
…which lists all memory devices. You can shorten -class to -c if your fingers are tired. To find other classes to search for try doing this:

sudo lshw -short
…and looking at the class column.

If you are interested in the entire list of hardware, the easiest way to view it all is probably to save it to a file. Maybe as HTML.

sudo lshw -html > filename.html
That’ll do it. You can also use -xml if you’re like that. Tidy.

Alternatively you could use the less command which will let you scroll up and down the output within the terminal. Like so:

sudo lshw | less
Press q to get back to the prompt.

Note: According to the man page the -sanitize flag removes any potentially sensible [sic.] information from the output. Seems fairly sensitive to me.

Posted in Linux | Tagged , | Leave a comment

MapInfo View Rememberer Version 3

Back in 2009 I made a plugin for MapInfo Pro that stores views to make navigating between sites quicker and easier.

This was all well and good except that I couldn’t store the scale accurately. This meant that what should have been 1:1000 became 1:1001 and 1:5000 became 1:4983. It was weird but I’ve finally got around to giving it another go and I’m pleased to say that it now works perfectly!

Not only does it work but it works better, more accurately, more reliably and with less lines of code! [engaging smug mode]

The link below will direct you to a zip file on my website containing the MapInfo program as well as the source code. Feel free to distribute the file, just don’t charge anyone for it!

Download Now

Posted in Uncategorized | Tagged , , | 1 Comment

MapBasic – Lists of tables and windows

MapBasic is as powerful as it is frustrating. There’s no built-in way to get a list of open tables, so I’ve written some code that does just that.

First I’ll explain how to populate an array with a list of table names and numbers, then how to select a table from this list using a dialogue box, then I’ll package it all nicely into a sub and a function so that you will only need a couple of lines of code. If you don’t want to understand and just want to DO things then just skip to the last section!

Getting a list of all open tables
This is fairly simple. NumTables() returns the total number of tables opened. All open tables are numbered sequentially, starting from 1. Therefore we just need to loop through, from 1 to NumTables() and put all the names into an array, making each name’s array index value correspond with its MapInfo table number. Like so:

    Dim i as integer
    Dim j as integer
    i = NumTables()
    Dim TableArray(1) as String
    ReDim TableArray(i)
    For j = 1 to i
        TableArray(j) = Tableinfo(j, TAB_INFO_NAME)
    Next

Choosing a table via a dialog
Now that you have a variable (TableArray) that contains a list of all open table names with corresponding numbers. This can then be used in dialog boxes, for example in a drop-down menu (or as MapBasic calls it, a pop-up menu):

    Dim TableNum as Integer
    Dim TableName as String
    Dialog
        Title "Choose table"
        Control PopupMenu
            Title From Variable TableArray
            Into TableNum
        Control OKButton
        Control Cancelbutton

    If CommandInfo(CMD_INFO_DLG_OK) Then
        TableName = TableArray(TableNum)
        Note "You chose: " & TableName
    End If

Choosing a table with a sub and a function
MapBasic functions cannot return arrays. Therefore you must create an array variable to store the list and then use a sub to insert the data into the array.

Here are is everything above packaged into a sub and a function.

Sub GetTableList (TableList() as String)
    Dim i as integer
    Dim j as integer
    i = NumTables()
    ReDim TableList(i)
    For j = 1 to i
        TableList(j) = Tableinfo(j, TAB_INFO_NAME)
    Next
End Sub

Function ChooseTable As String
    Dim TableNum As Integer
    Dim TableArray(1) As String
    
    Call GetTableList(TableArray)
    
    Dialog
        Title "Choose table"
        Control PopupMenu
            Title From Variable TableArray
            Into TableNum
        Control OKButton
        Control Cancelbutton
        
    If CommandInfo(CMD_INFO_DLG_OK) Then
        ChooseTable = TableInfo(TableNum, TAB_INFO_NAME)
    End If
End Function

…and here is how you would use them to choose a layer:

Dim TableName as String
TableName = ChooseTable()

…and here’s how you’d get an array of table names.

Dim TableArray(1) as String
Call GetTableList(TableArray)

You can’t get much easier than that… and if you can I’d like to know how you did it!

You can use exactly the same procedure to get a window name or a list of windows. You just need to swap “table” for “window” and “TAB” for “WIN” (literally – a search and replace will work).

Posted in Uncategorized | Tagged , , | Leave a comment

List Writer and Terminal Illness

“Illness” in the Hip Hop sense of the word and “terminal” in the Linux sense of the word. Don’t rejoice, I’m not dying yet! But first…

List Writer

This is a tiny and straightforward function but I have a feeling it’s going to come in useful, so I’ll put it here for safe keeping. It takes an array and simply writes it out as you would in English. There is an example below.

<?php
    /*
     * Writes an array as a list in proper English. Commas and all.
     */

    function write_list($arr){
        $size = sizeof($arr); 
        $n    = 1;
        $out  = '';
        
        foreach($arr as $item){
            if ($n == $size){
                $out .= ' '.$item;
            } else if ($n == ($size-1)){
                $out .= ' '.$item.' and';
            } else {
                $out .= ' '.$item.',';
            }
            $n++;
        }
        
        return $out;
    }
    
    $list = array(  'Queen Elizabeth II',
                    'a paperweight',
                    'Batman',
                    'a feeling of ennui',
                    'Switzerland');
                    
    echo 'In my bag I have '.write_list($list) . '. It\'s quite a big bag.';

The above would output the following:


In my bag I have Queen Elizabeth II, a paperweight, Batman, a feeling of ennui and Switzerland. It's quite a big bag.

Terminal Illness
My main coding project at the moment (apart from the big one, which I’m not allowed to talk about…more on that another time) is a web page that looks and acts like a command-line. I started this after looking at goosh.org/, the unofficial Google command line. “How would you go about making that, then?” a friend asked. And I thought about it. “Like this”, I said and 5 minutes later I had a basic mock-up.

Since then it has gone through a number of iterations. I have now condensed and generalised it into a re-usable class that is easy to expand and customise. It’s not quite ready for public consumption yet but as soon as it is I will release the source code.

I am also using creating a text-based adventure MMO game based on this system… More about that soon.

Edit: oh, you’ll probably want a link!

Posted in Uncategorized | Tagged , , | Leave a comment

Grammar

Please grammar you’re sentences are correct so I can read at them with more easily and reply accurate.

Posted in Uncategorized | Tagged | Leave a comment