C++ Overloading, overriding and hiding, oh my!

Continuing where I left off previously, I’ve been going through chapter 9, Inheritance and Polymorphism from Ivor Horton’s Beginning Visual C++ 2008 and consulting various other books a little more often than I had been up until now. One of those books was C++ Programming: Visual QuickStart Guide, by Larry Ullman and Andreas Signer.

Edit: There is a slightly better (cleaned up) version here.

I was reading chapter 8, Class Inheritance where I ran afoul of this warning:

Pay attention when overriding methods. If you don’t use the exactly same parameters and return values, you’ll end up with an overloaded method, and not an overridden one. Such mistakes are very hard to debug

Continue reading

Counting the number of items in a line

This short script was used to count the number of pipes in a line. I wanted to have 9 per line so the Dokuwiki table would be displayed properly, so this script let me know which lines were busted.

# Purpose: 
#     Get number of pipes per line. The first line should be what you 
#     want the others to match

import re
import os
import sys

game_collection_file = sys.path[0] + os.sep \
    + 'game_collection_dokuwiki_list.txt'
game_collection_fh = open(game_collection_file)

rexp = re.compile(r"\|")

count = 0
for line in game_collection_fh:
    count += 1
    match = rexp.findall(line)
    if len(match) != 9:
        #print "Number of pipes on line %s: %s " % (count, len(match))
        print "line %s: %s " % (count, len(match))

Server sent unexpected return value (502 Bad Gateway) in response to COPY

This was an annoying issue. I initially blamed it on an Apache update and wasted a lot of time going in that direction. When I finally gave up and used Google, I got somewhere.

Thankfully, I wasn’t the only person to run into this and there are at least three different solutions to the problem. Take your pick.

It was explained rather succinctly here:

because nginx pass to backend https:// url in Destination header.
but http:// and https:// urls can not be mixed in COPY request.

In short, the front end speaks https to the client, but it speaks http (non-ssl) to the back end. The header is not changed to reflect this and the COPY command fails.

  1. Rewrite the Destination header via nginx’s rewrite feature:

    set $fixed_destination $http_destination;
    if ( $http_destination ~* ^https(.*)$ )
    set $fixed_destination http$1;

    proxy_set_header Host $host;
    proxy_set_header X-Real-IP $remote_addr;
    proxy_set_header Destination $fixed_destination;
    proxy_pass http://subversion_hosts;

  2. Have Apache also use SSL (I was using this approach until just recently)
  3. Use mod_headers with Apache.

Chill in the air!

This is mainly a note to myself, but Sept saw a few cool moments early morning, but now that we’re into Oct we’re finally getting a few mornings that are truly cool. Not cold, but I can tell it’s on it’s way.

I’d guess it was Wednesday when I stepped out and truly felt there was a chance of snow this year. Where I live, it’s rare enough to be seen as a good thing. 🙂