Charles v3.4b1 featuring SSL improvements

March 30th, 2009

Charles v3.4 is in the works. I haven’t settled on a final feature list for this yet; my focus is intended to be UI improvements, but I couldn’t resist releasing some new SSL features. So this isn’t really a beta, but I’m calling it 3.4b1.

Charles now supports client-side SSL certificates, so you can authenticate with servers that require them. You must configure Charles to use your P12 file for each site that requires it using the Client SSL Certificates option in the Proxy menu. Charles will ask for your password when it needs it, and it doesn’t remember it beyond the session for your security. Please let me know how this works for you!

You can now list SSL sites that should not be proxied / decrypted by Charles. In the process I also renamed “Decrypt SSL” to “SSL Proxying” as it wasn’t the right terminology. So if you have software that accesses specific sites and doesn’t like Charles’s certificates you can add them here; by default it has PayPal and Kagi in there to ward off the emails I get about those sites having invalid certificates! For myself I’ve added *.getdropbox.com as it doesn’t like the SSL certificates it sees even with Charles’s CA certificate trusted by the system - that’s good security.

Finally, the SSL certificates that Charles generates for sites are now cached. This means when you say “permanently trust this certificate” in your browser, it will actually work!

Download the beta.

RomanNumeralFormat

March 15th, 2009

Several years ago I wrote this RomanNumeralFormat class which extends java.text.NumberFormat but parses and formats Roman numerals. I just stumbled across it and thought it belonged here. This sort of thing should definitely be included in Java 7, then it will truly rule over Perl 6.

import java.text.FieldPosition;
import java.text.NumberFormat;
import java.text.ParseException;
import java.text.ParsePosition;

public class RomanNumeralFormat extends NumberFormat {

  private static char[] roman_alpha = new char[] { 'M', 'D', 'C',
    'L', 'X', 'V', 'I' };
  private static int[] roman_num = new int[] { 1000, 500, 100, 50,
    10, 5, 1 };

  public StringBuffer format(double number, StringBuffer toAppendTo,
    FieldPosition pos) {
    // Too lazy
    return null;
  }

  public StringBuffer format(long l, StringBuffer toAppendTo,
    FieldPosition pos) {
    StringBuffer buf = new StringBuffer(20);

    while (l > 0) {
      for (int i = 0; i < roman_num.length; i++) {
        if (l >= roman_num[i]) {
          buf.append(roman_alpha[i]);
          l -= roman_num[i];
          break;
        } else {
          int peek = i + 2 - (i % 2);
          if (peek < roman_num.length) {
            int j = roman_num[i] - roman_num[peek];
            if (l >= j && j > 0) {
              buf.append(roman_alpha[peek]);
              buf.append(roman_alpha[i]);
              l -= j;
              break;
            }
          }
        }
      }
    }

    return buf;
  }

  public Number parse(String source, ParsePosition parsePosition) {
    long l = 0;
    int max = 0;

    source = source.toUpperCase();

    for (int i = source.length() - 1; i >= 0; i--) {
      char c = source.charAt(i);
      boolean validChar = false;
      for (int j = 0; j < roman_alpha.length; j++) {
        if (roman_alpha[j] == c) {
          int k = roman_num[j];
          if (k >= max) {
            l += k;
            max = k;
          } else {
            l -= k;
          }
          validChar = true;
          break;
        }
      }
      if (!validChar) {
        parsePosition.setErrorIndex(i);
        return null;
      }
    }

    parsePosition.setIndex(source.length());
    return new Long(l);
  }
}

I was obviously pretty concerned about getting some large roman numerals through here - using a long rather than an int. Built to last.

iTunes App Store promotion

March 2nd, 2009

Half a year on from the launch of the iTunes App Store, one of the biggest difficulties for developers is getting noticed amongst the 10,000+ apps. We’ve talked about traditional marketing; we’re trying new forms of marketing (twitter, social networking), but mostly agree that promotion within the App Store itself is the golden ticket. I’ve had this idea rolling around for some time; today I’m appeasing my Things todo list by blogging about it.

Promotion within the App Store is available in two areas; the masses purchase apps creating the Top 10 / 25 / 50 / 100 lists, and Apple chooses apps to feature in the New and What’s Hot lists (and some others). Promotion within the App Store is at the whim of Apple and the masses.

The problems with the Top lists has been the topic of much discussion; most recently its penchant for passing wind has been fouling the air. The Top lists create a feedback loop where sales drive sales; it’s great when an app is in the loop, but increasingly developers are finding development unsustainable if it’s not.

My assumption is that there are many apps of quality and utility that deserve to hit the big time, and that without promotion their growth is stunted. Apple can’t promote every app at once, but maybe the promotion can work better.

I am thinking of a system where potentially successful apps are identified in a way that is independent of sales volume and recommendations. Apps are then randomly promoted with a weighting towards those that are more potentially successful. A feedback loop analyses the effect of promotion on sales and increases or decreases promotion to maximise revenue. In this case “success” is defined as sales, that is making money for Apple and for the developers.

How to identify potentially successful apps? If Apple tracks which apps people view and and which apps they buy, then an app with a strong view-buy ratio likely matches consumer needs and has reasonable quality (bonus points for including data on how long the app stays installed; if the user removes it immediately with a 1 star review that counts against). Identifying apps in this way is independent of popularity; in fact popularity will worsen the view-buy ratio as it attracts more views, so this (and a minimum number of views on the other end of the scale) may need to be taken into account. The potential to tailor featured apps to individual users is obvious, but I think one-step-at-a-time is more likely!

Potentially successful apps are then randomly featured on the App Store with a weighting towards apps with a high view-buy ratio. Being featured will increase the number of views, so if an app is successful it should also increase the sales. The feedback loop continually measures the view-buy ratio and adjusts the promotion weighting. Variance in the weighting algorithm would enhance the approach by stepping back slightly from maximising revenue (ie. for Apple) and sharing it amongst a larger group of apps (ie. developers), and allowing new entrants; like mutation in a genetic algorithm.

I think this approach may solve the problem of apps which should have more sales but don’t have the promotion required. It should mean that promoted apps are the apps that are more likely to sell, which means that overall App Store revenue should increase. Good for Apple, good for developers. Remember that this doesn’t replace the existing Top list mechanism, it sits alongside it. I’m not sure what other problems and exploits it creates! It isn’t a complete picture. I hope it’s an interesting one.

Charles v3.3 released

February 15th, 2009

I’ve released Charles v3.3 today. This release adds several new and exciting features including:

  • HTML, CSS & RSS/Atom validation
  • XML export formats
  • JSONP support

I’ve blogged previously about these, and other new features, so I’m just going to link through to those! Read the first announcement and the second announcement.

The next release of Charles will focus on improving various UI and usability features. Particularly the ability to focus in on a small set of hosts, so you don’t get cluttered with others. Also I’ll be making improvements to the Sequence view; probably some sorting. I’ve received lots of suggestions along these lines; if you have anything to add please leave a comment with your thoughts!

Download Charles v3.3

iPhone cannot play video over 3G

February 9th, 2009

We just tracked down an issue where H.264 video would play on the iPhone over WiFi but not over 3G. The problem turned out to be that the server emitted a Vary: User-Agent header as part of its mod_deflate handling. That header alone was causing the video to fail to play over 3G. I suspect that it may have been a problem on the 3G network itself rather than the iPhone. If you have similar head-scratching issues maybe this is the cause.

Charles v3.3 public beta 2

February 9th, 2009

The second public beta of Charles has just been released. This update adds:

  • “Window always on top” setting and window remembers maximised state
  • Summary table column sorting improved to sort numeric columns
  • Map Remote can now map http requests to https servers
  • Location matching now supports adding $ after the final / for an exact directory match rather than an implicit wildcard

It also includes fixes and improvements to JSON and JSON P and validation. In particular you can now repeat a request within the validation results and have it repeat the original request and then validate the result - really handy for iterative testing and fixing!

This release is heading for final this week I hope so please send your feedback.

Download Charles v3.3 public beta 2

iPhone OS 2.2.1, UITableViewCell and UITextAlignmentCenter

February 8th, 2009

As of OS 2.2 there was a problem with UITextAlignmentCenter and UITableViewCells where the text would always show left aligned. The easiest solution was to compile your application for OS 2.0, if you weren’t using any new API features, in which case the original behaviour continued to work. However as of OS 2.2.1 it appears that this no longer works! There were some proposed solutions but they also don’t appear to work anymore.

I’d like to continue building my application for OS 2.0 compatibility so I don’t unnecessarily inconvenience users who haven’t upgraded yet, so I built the following solution that you may find useful - a UITableViewCell subclass that centres the text itself and works when your application is compiled for OS 2.0 or 2.2.1 (and probably others in between).

@interface MyButtonTableViewCell : UITableViewCell
{

}
- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString*)reuseIdentifier;
@end

@implementation MyButtonTableViewCell

- (id)initWithFrame:(CGRect)frame reuseIdentifier:(NSString*)reuseIdentifier
{
	if ((self = [super initWithFrame:frame reuseIdentifier:reuseIdentifier]) != nil) {
		self.textAlignment = UITextAlignmentCenter;
	}
	return self;
}

- (void)dealloc
{
	[super dealloc];
}

- (void)adjustLabelSize
{
	/* Center the label view. This works around a bug in OS 2.2 which now effects even code compiled for OS 2.0.
	 * When compiled for OS 2.2.1 this code is unnecessary but still works.
	 */
	NSArray *subviews = self.contentView.subviews;
	if ([subviews count] > 0) {
		unsigned int i, c = [subviews count];
		for (i = 0; i < c; i++) {
			UIView *subview = [subviews objectAtIndex:i];

			if ([subview isKindOfClass:[UILabel class]]) {
				CGRect frame = subview.frame;
				frame.origin.x = floorf(self.contentView.frame.size.width / 2 - frame.size.width / 2);
				subview.frame = frame;
			}
		}
	}
}

- (void)layoutSubviews
{
	[super layoutSubviews];
	[self adjustLabelSize];
}

@end

Debian Sarge to Lenny upgrade

February 6th, 2009

This morning I have upgraded a non-production but important server from Debian Sarge to Debian Lenny. Figuring it was about time that I did the upgrade I took some advice that Lenny is very stable and could buy me a longer support period by skipping Etch altogether. Time will tell.

This post itemises the steps I went through for posterity and prosperity if I ever need to refer to them again. I’m writing this up from my notes so it is possible that I’ve missed something; if you do attempt a similar upgrade yourself and something turns up, please feel free to suggest it in the comments.

I started by reading (skimming) the release notes for Lenny on upgrading, which are currently in draft as it is in testing. In the future Lenny will obviously become the release version so that URL will become invalid. If you’re upgrading I suggest you to the same; furthermore if you’re upgrading from Sarge read over the Etch release notes for upgrading too. My process is based on and pretty much identical to the process described therein.

Read the rest of this entry »

Charles v3.3 public beta

December 29th, 2008

Hi all. Happy holidays!

I’ve put the finishing touches on some new features for Charles:

  • Validation of Markup (HTML/XHTML), RSS / Atom & CSS
  • XML import/export format for recorded sessions
  • JSONP support

Download Charles v3.3 b1

Validation is a really exciting addition for web developers. If you’re trying to build valid HTML / XHTML pages (and the accompanying CSS and RSS/Atom feeds) then this will be invaluable for checking your work. First record your pages in Charles, then select them and choose Validate from the context-menu or the toolbar; Charles will validate each page, one at a time, using W3C’s validator web services. You can view a simple summary of the results or detailed warnings & errors for each page. Double-click the error message line numbers to view that line in the source. Note that the validation uses the source recorded by Charles, it doesn’t just pass the URL to the validator, so this correctly validates dynamically generated pages where the same page may emit different markup depending upon input or state. I’m very interested to hear feedback on this feature. Credit to Rowan Simpson and Glen Barnes for the idea to integrate validation into Charles.

Charles can now export and import recorded sessions in an XML format. This is useful if you want to analyse the data collected by Charles in your own software. To this end the Auto Save tool now also supports saving in any export format, rather than just the Charles session format. I’m going to be looking at more ways to integrate Charles into automated monitoring environments in the near future.

Finally, JSONP support was a small but irritating omission in Charles’s JSON support that is now fixed!

This is a public beta so I’m hoping for feedback and bug reports on the new features, especially if I’ve introduced any bugs! There have also been a few bug fixes in this release: fixes to the request editing feature, Map Remote with SSL, and using an external SOCKS proxy.

Please leave feedback in the comments or via the contact form on the Charles website.

Download Charles v3.3 b1

Charles 3.2.2 released

September 6th, 2008

A small bug fix release to Charles after a few quiet months. I’ve been a bit distracted with family and iPhone apps!

This release includes various minor bug fixes, which you read about. New features include remembering whether you use Structure or Sequence view, support for large files (>2GB) and binding reverse proxies and port forwardings to specific IP addresses on the local machine.

The next release won’t be far away and will include one major new feature around HTML validation, and numerous UI improvements as requested by you!

Download Charles 3.2.2