Wednesday, June 1, 2011

Lightbox Issues

I decided to use Lightbox to display a simple list of images in a slightly more elegant way than just a boring ol' href.

However, I couldn't get it to work! It kept trying to push the images down to below the bottom of the main content and then wouldn't "un-grey" it properly so it could be used. Basically, the lightbox effect was broken.

After a long time of debugging (wherein I was a bit distracted because of a missing image file), I finally figured out the problem. I'm using .htaccess to change the css handler from the normal page to the PHP engine. All I had to do to fix the problem was add the following line to the top of the lightbox.css file:

<?php header("Content-type: text/css; charset: UTF-8") ?>
Boom. Done. Works like a charm now.

(p.s. Here's the Lightbox website: http://www.lokeshdhakar.com/projects/lightbox2/. Yes, it does work as easily as they suggest; you just have to not screw around behind the scenes).

Monday, May 16, 2011

Content-type in PHP headers

I'm working on a BREW program. I need to serve the content from an Apache server running PHP. I know this should work, but the application kept acting as if there was no xml content at all.

I played around with a variety of possible ideas on what the problem could be, but ended up narrowing it down to the fact that Apache/PHP returns Transfer-encoding: chunking. It took me a long time, but I managed to get rid of that by replacing it with Content-length.

The trick was getting the sucker to work. I had my php code totally in the wrong order for a long time; I was deceived by Firefox, which (via WebShark) was telling me there was data and it had length. Web-sniffer.net and other header reader sites kept returning 404 or zero content length header messages... as did the IWeb status.

Turns out, I was using the output buffer incorrectly.

My final code needed to be://setup here
//setup of data here
ob_start();
//header stuff here
echo $strOfStuff
header("Content-length: " . ob_get_length());
And that did the trick. I'd try to explain more, but it took me a long while to get to this point, and I'm still not sure if there is something within IWeb that I could have manipulated to make my life easier. I don't want to speculate at this time.

Sunday, April 17, 2011

g++ command line options

  • -o : name the output file.
  • -Wall : all warnings.
  • -pedantic : follow strict ISO C++ rules.
  • -Weffc++ : follow Scott Myer's Effective C++ solutions.
More to come as a I experiment with them.

'NULL' was not declared in scope

(and cout, for that matter).

  • For NULL: use #include or
  • For cout: use the scope operator: std::cout or put 'using std::cout' at the top of the file.

Local SVN create and import troubles

I have this problem every time I try to create a new repository to use for version control.

First:

svnadmin has this thing about the 'create' feature using a path, not a URL, so the command (on Mac OS X) should be:

$ svnadmin create /Users/adam/vc/code

where /Users/adam/vc was already created via the

$ mkdir /Users/adam/vc

command.

Second:

Say you want to import a folder to your newly created repository. Per the help, it should be as simple as:

$ svn import file:///Users/adam/vc/code

where it assumes that the base folder is '.'. You can use -m to create the initial import message, but I have it bring up Vim as my editor.

Yay, it works, though I did have to fuddle with the invalid URL message a few times.

Great, let me check out my nice shiny new code so it's actually under version control:

$ svn co file://Users/adam/vc/code

Damn! What the hell is: "svn: Unable to open an ra_local session to URL" and "svn: Local URL 'file://Users/adam/vc/code' contains unsupported hostname"?

or for that matter this list of other errors as I play with the command?

svn: Local URL 'file://Users/adam/vc/code' contains unsupported hostname
svn: ':/Users/adam/vc/code' does not appear to be a URL
svn: Client error in parsing arguments

To say the least, it's been a big hassle. Here is what worked.

  1. Delete the folder that you may have already created in the repository folder (in my case 'code')
  2. Create the repository using this command: svnadmin create /Users/adam/vc/code (note: no 'file://' protocol).
  3. Create a folder that has the code you want to put under version control. Make sure the files you want in it are backed up, because you're going to delete it later. I named mine 'code' in this example.
  4. Import the folder (you need to be outside of the folder when you run this): svn import code file:///Users/adam/vc/code
  5. Remove the folder: rm -r code
  6. Checkout the folder from the repository: svn co file:///Users/adam/vc/code
There, that should it. All your files should scroll past you as it creates a new folder (in my case 'code') that is now under version control.

Why is this so painful? Granted, I didn't pay attention closely this time, but I had just done this on a Windows machine (under Cygwin) with no problems at all, so I assumed it'd be the same (of course, forgetting past experiences).

Tuesday, April 27, 2010

Password Requirements


This is from QUALCOMM's BREW MP website. The image capture didn't come out well. It says: "Please enter a password with at least 6 character, including three distinct characters and at least one number."

What is a distinct character? 'a', 'b', and 'c' are all distinct characters. Perhaps they meant at least one alphabetic, one numeric, and one non-alphanumeric character. Or does capitalization also make a character distinct?

What led up to this is even more interesting. When I registered for the site, it didn't ask me for a password, just an e-mail address (and lamely, an alias for the forums, which I obviously hadn't gotten to seeing yet, since I had to register first; don't make me determine a unique alias until I actually need it and understand the context). I couldn't log in (because of the lack of password) until I clicked on the "Forgot password?" link, which then brought me to the issue I started this article with.

QC seems to have issues with password and account registration... not the first time I've had to run through hoops to get a registration working, especially with the original BREW website.

Wednesday, February 17, 2010

How not to title your web pages

I wonder how many people pay attention to providing a good title for a web page. When I find a site I like or need, I often bookmark it, but also often find that I have to rename it so that when I'm glancing through my bookmarks, it's easy to find.

Starting the title of a site with the name of a company or the division, or the website itself is no good (unless it's the main page). Take this example from Qualcomm:


After saving it as a link, I end up with this in my bookmarks:


It's the highlighted one, if it wasn't obvious. And that's my point. Notice the other two Qualcomm links near the bottom. The only difference between them is capitalization. I can't tell what they actually link to. The bookmark titled "Customer ..." is actually the renamed version of the highlighted one above. Just by the fav icon (denoted Brew) and the word "Customer" I know that it's the customer support portal website for Brew. But I had to take action to get that to happen; it wasn't as simple as if Qualcomm had simply rearranged the title to be "Customer Support Portal | Qualcomm Brew" instead.