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.

Tuesday, February 16, 2010

Droid recommendation

A friend of mine asked me if I'd recommend the Droid, as he needs a new phone. Here's what I said:

I'm torn. It's a decent, solid enough mini-computing device. But it's almost as if they forgot it's a phone first. I love the ability to sync my Gmail contacts and FB info and all that other social stuff but I hate guessing at what the back/clear key might do, or wondering which application is going to launch when I press the Messaging icon (because sometimes it launches the phone or the FB app, funnily enough). Multi-tasking is cool... but only when it doesn't slow the system down where mis-taps start to happen. Still, I like it better than every other phone I've used short of the iPhone (which has its own host of issues, but at least they were consistent with the UI).
The Messaging app mis-launching is a frustrating one indeed. Once, I had to power cycle the phone because I couldn't get to the messaging app, even indirectly. Who knows what registry-type settings got messed up.

To re-iterate. Decent computing device, poor telephony device, better than most of your other options.

Blank screen on the Droid

Do I really need a blank home screen on the Droid? From my home screen, I can swipe left and get my calendar and a couple of other widgets I put there and if I swipe right, I get a blank screen. Why? Sure, make it available when I'm trying to re-arrange icons, but don't have it there if there is nothing to view.

I'm not sure how long it's been there... the reason I noticed it was that my Google search bar disappeared from the home screen, only to be found by itself on the (now) blank screen. It was an obnoxious pain to drag it back over to it's original starting place.

The UI of the Droid just feels too rushed. Not enough thought when into basic best practices. Sadly, it's still better than a lot of other phones out there.

Monday, February 8, 2010

Droid Keyboard Alt/Shift issues.

For me, the keyboard on the Droid is terrible. Most people complain about the lack of tactile feel, and I agree that it sucks, but that's hardly the sticking point for me.

Instead, the position of the Alt and Shift keys seemed flip. I find I use the keys about equally between capitalization and punctuation. However, it feels unnatural to me to have to stretch my thumbs out the the side to hit the shift key. Instead, I often hit the alt key instead when I need to capitalize a letter. And then I get frustrated and hit it again because I've inadvertantly put a symbol in its place and then hit Del... erasing my entire line because I hit the Alt twice followed by the Del key. Not what I wanted.

I think the problem relates to the normal keyboard on a desktop. To hit the shift key, a person uses their pinkies, not their thumbs. However, on the Droid (or other mobile), you use your thumbs for all tapping; the other fingers are stabilizing the device, or as is the case of the pinkies, not being used at all. So if the usage model changes, so should the layout. Obviously, Motorola/Google didn't think this was a major problem and that people would probably get used to it. But what it really shows in a lack of thoughtfulness on their part. They have an extra blank space on each side of the keypad; they could have extended the either the alt or shift keys to be larger and more accessible, for example, but only after having evaluated which set characters get used most often.

When messaging, I use a lot of contractions... it keeps the sentence structure proper (not using "u" and "ur" and things like that that) while keeping the character count down. So I need the apostrophe a lot. What a pain to type "I'll" Shift-I-Alt-M-L-L." The need to make a shift between the Shift and Alt keys makes the process very cumbersome. A larger keyboard with it's own number row (or pad; does the directional pad ever get used??) would have made life easier; put the key punctuation characters as shifted versions of the number keys instead. That way "I'll" becomes Shift-I-Shift-M-L-L. On top of that, you get the bonus of more easily being able to type numbers into a text field... you know, something that happens a lot on a TELEPHONE.

And don't get me into that overburdened space bar. The space bar simply should not have a double function. It should do one thing and one thing only, no matter what mode the rest of the keyboard is in.

Droid Messaging/Contacts Problems

Been having trouble with the Droid. Everyone asks "Do you like it?" My response is almost always "Meh," mostly because while it does everything I want, it doesn't necessarily do it well. Messaging is a case in point.

If I add a person to my contact list, then later enter the messaging app to send them an SMS, I often cannot find them. I have to instead exit the app, go back to contacts, find them and then tap on the smiley face to send a message.

I know at some point, that new contact will eventually show up in the messaging drop down when I type their name in, but I haven't figured out the connection yet.

Wednesday, January 27, 2010

Searching by name

Here's a suggestion for website developers. If you're going to offer an alphabetical listing on a large or wildly varying set of data, give the user a alphabetical bread crumb trail and not a numerical one. That is, if you have a 1000 listings, don't give me this:

"1 2 3 4 5 >>" where clicking on the brackets jumps you ahead 5 units and you have no idea where the end is.

instead, give me something like this:

"A-AF AG-AZ B-BL BM-BZ ... J ... N ... Z >>" where clicking on the brackets jumps ahead to the next logical grouping (in this case, the "J" grouping") or I can simply click on the nearby letter of choice.

Friday, November 20, 2009

Failed to load error

Just had an experience where I was trying to load an app onto my phone, but kept getting "Failed to upload to device." I cleaned the source code, tried other miscellaneous things, reset the phone, and nothing. It took quitting Xcode and restarting to get it to work, which I find a very common requirement.

Just to add to the confusion, I think I may have done this to myself. I had already installed the app earlier, but this afternoon, I changed the bundle identifier, so for a short while, two apps with the same name existed on the phone. I think that may have been the ultimate cause of my mionr problem.

Tuesday, November 10, 2009

View Connection Error

While experimenting with the navigation controller, I got this error after having hooked up a nib to the main view controller that show up under the navigation controller in IB:

reason: '-[UIViewController _loadViewFromNibNamed:bundle:] loaded the "MainMenuViewController" nib but the view outlet was not set.'

What I had forgotten to do was to go into the MainMenuViewController and attach the view to the File Owner.

Monday, November 9, 2009

How to access resources in the main bundle.

The app I'm working has images embedded in the bundle; they may be JPG or PNG. Trying to find a path those resources can be done in one of three possible ways, as far as I see right now:

1) NSString *imgPath = [NSString stringWithFormat:@"%@/%@", [[NSBundle mainBundle] bundlePath], nameOfImage];

#1 is what I ended up using, since that's exactly where the images are located and I don't have to be concerned about the type of the image.

2) NSString *docPath = [NSSearchPathForDirectoriesInDomains(NSDocumentDirectory,NSUserDomainMask,YES) objectAtIndex:0]; // And add as part of a formatted string, like in item 1.

#2 was a side path I took, forgetting that you have to add the references as part of a folder structure (which I'm not completely clear on at this time)

3) NSString *jpgPath = [[NSBundle mainBundle] pathForResource:nameOfImage ofType:@"jpg"];

#3 was the way I was recently taught, but the it always bothered me that there was an "ofType" message. How can you rest assured that the image type will ALWAYS be of that type. I'd have to do a bit of extra work (pulling from a plist, or database, or parsing the image name) to ensure I had the proper resource type. And since images are, very generally speaking, interchangeable (at least as far as my content developers are concerned!), I feel this is a case where it pays to be more flexible, so #3 just doesn't work for me (in this situation).

Regarding the Tab Bar control

When adding new tabs and populating the data from another nib view, two things need to be set:

1) In the actual nib view, you need to set the class to the controller, as you would expect.
2) You also need to do the same thing for the view that is listed under the tab controller (once for each tab).

Otherwise you will get a crash if you try to access anything in that particular tab:

'[ setValue:forUndefinedKey:]: this class is not key value coding-compliant for the key webView.'

Friday, November 6, 2009

Don't forget to synthesize!

I decided to reduce the problem I was having by removing extraneous files from the project. In the process, I moved certain properties from one file to another.

All was well, and I solved that initial problem.

However, I started adding back in some additional code, and got this error when trying to assign a UIImageView pointer to a property:

*** Terminating app due to uncaught exception 'NSInvalidArgumentException', reason: '*** -[MainViewController setVideoSlot1:]: unrecognized selector sent to instance 0x3d23150'


As it turns out, I forgot to (re)synthesize those properties that I had earlier moved from one file to another. The odd thing is, Xcode didn't bother to give me the normal warnings for properties that haven't been also synthesized. There maybe an additional condition that has to be fulfilled before you will see that warning. Keep an eye out.

View Linkage Error in Tab Bar Controller

In an attempt to add new views to the tab bar view template app, I got the following error (truncated from its lengthier form:

[UIViewController _loadViewFromNibNamed:bundle:] loaded the "FirstTab" nib

In the MainWindow.xib tab view controller, I had already linked my "FirstTab" nib, but a second step was required:

  • Open FirstTab.xib.
  • Right click on the view (or do this through the inspector).
  • Drag the New Referencing Outlet to the File's Owner.
  • Select the 'view' option (which is likely the only one).
Run the build and it should work. You obviously need to do this for every tab that pulls the information from a nib, else the next one will cause a crash when the app launches.

Thursday, November 5, 2009

Don't move the buttons, please

You can often find this control set on many web comic sites. When you are viewing the most current comic, there is no need for Next/Newest, so they aren't displayed.

However, when you click on Previous, frustration ensues:

The Previous button is shift over to the left. The cursor doesn't move, so the next time I click, I actually end up pressing Newest, returning me back to the beginning. Awkward.

Tuesday, October 27, 2009

Why does 'cd' work differently for drives and paths?

This has been a frustrating pet peeve of mine for a while.

When I hope my Windows command line, it starts me out on a network drive, specifically "H:", which of course I rarely have a need to be in. My first instinct, which is always wrong, is to type:
  • H:>cd c:
in an attempt to get to "C:" drive. I may even have include a path like this: "c:\path\to\my\folder".

This always fails, because what Windows expects you to do is this:
  • H:>c:
which will nicely give you the C:> prompt from which you can then navigate.

Why? Is there a way around this? My main problem is that I don't use the Windows command line that often, so I forget the nuance of switching between drives as opposed to switching paths.