Textarea Line Count 1.4.1 released

I’ve released a minor update to Textarea Line Count. This release fixes two issues:

  1. Default options were not actually included in the plugin, although they are detailed in the documentation
  2. The plugin only took textareas as jQuery objects – it didn’t allow selectors (once again contrary to the documentation)

You can grab the new downloads here.

Debugging Android HTTPS traffic with Fiddler and Connectify

If you’re trying to debug an app (or website) on Android that is using HTTPS, then this short guide might be for you. I’ll show you how to set up Fiddler and Connectify Me so that you can view your device’s encrypted communications.


  • Computer with internet access and WiFi
  • Android device that supports WiFi proxies (Honeycomb or later – older devices might require a proxy app, though I can’t guarantee it will work)



  1. Install Connectify Hotspot (the free version works fine) and start your hotspot. Side note: Don’t pick a stupid password for your hotspot; you probably don’t want world+dog hopping on your connection.
  2. Connect your Android device to your hotspot (via WiFi settings) and ensure you can access the internet using the connection.
  3. Install Fiddler (but don’t open it yet.)
  4. Install this certificate maker plugin (seems to have moved to here). It replaces the default certificate plugin in Fiddler so that the certificates will be compatible with Android.
  5. Open Fiddler and follow these configuration steps:
    1. Go to Tools | Fiddler Options… | General tab. Uncheck “Show a message when HTTP protocol violations are encountered”
    2. Switch to the HTTPS tab. Check “Capture HTTPS CONNECTS” and then “Decrypt HTTPS traffic”. Click Yes twice on the two dialogs that pops up.
    3. Click the “Export Root Certificate to Desktop” button.
    4. Switch to the Connections tab and check “Allow remote computers to connect”. Click Ok on the dialog.
    5. Take note of the port listed next to “Fiddler listens on port:”. We’ll need it soon.
    6. Close the options dialog.
  6. Exit Fiddler and then reopen it.
  7. On this website, upload the certificate that was exported to your desktop. Then, on your Android device, navigate to the URL the page produces to install the certificate.
  8. Determine the IP address of your computer (using ipconfig at the command line) on the ad-hoc WiFi connection that Connectify Hotspot has created.
  9. Using the instructions on this page (halfway down), configure the WiFi connection on your phone to use the following proxy information:
    1. IP address: What you found in step 9.
    2. Port: From step 5.e.


Test it out

Let’s see if everything works. Make sure Fiddler is open on your screen. On your Android device, browse to a random page. You should see the connections on the left-hand side of the Fiddler screen. If all of our HTTPS configurations worked, you should also see HTTPS communications decoded and dumped as well.

It’s possible that not all HTTPS communications will be shown, since some apps might reject the Fiddler root certificate. There’s nothing that can be done about that, unfortunately.

Note that Fiddler will also have changed the proxy settings for your entire computer. Connections from your desktop browser, email clients, etc. will be shown side-by-side with those from your Android device.


When you’re done, you’ll want to do a few things to revert your Android device and computer back to how they were.

  1. Undo the proxy configurations on your Android device.
  2. Uncheck the “Allow remote computers to connect” option in the Fiddler settings
  3. Uninstall Fiddler’s root certificates from both your computer (Google for instructions) and Android device (under settings | Security)

Solving Code Contracts caching errors

If you’re trying to set up caching with Code Contracts (and SQL Server CE) but getting errors, then this is the post for you.

On a fresh install of Code Contracts, enabling caching might spawn this error:

Unhandled Exception: System.IO.FileNotFoundException: Could not load file or assembly 'System.Data.SqlServerCe, Version=, Culture=neutral, PublicKeyToken=89845dcd8080cc91' or one of its dependencies. The system cannot find the file specified.

This error is telling us that we need SQL Server CE (Compact edition) version 3.5.1, but it lies! What we really need is version 3.5.2.

To fix this error, download and install this (yes, on a 64-bit machine you do need to install both the 32 and 64-bit versions). It’s going to ask you where to extract the files, not where you want to install SQL Server itself; I just chose the desktop.

If you are getting errors such as:

... Schema specified is not valid. Errors:
... error 0175: The specified store provider cannot be found in the configuration, or is not valid

this means you installed the wrong version of SQL Server CE (such as version 3.5.1). To fix this, first uninstall any 3.5.x versions of SQL Server CE, and then download and install what I linked to above.

jQuery UI 1.9 released, dialogWrapper still working!

jQuery UI 1.9 is finally here! What does that mean for dialogWrapper? Well, it would seem like the answer to that question is: nothing. A redesign of the dialog API is not present in version 1.9, and it doesn’t look like it will happen until the 2.0 release, according to the official site.

The planned changes for the 2.0 release are something to get excited about now, however. Some of the changes discussed add some nice functionality and improve the overall design of the API. Heads up: so far, it doesn’t sound like the 2.0 release will make dialogWrapper irrelevant.

BaseMemberPromotingProxy – simplify your debugger displays of nested classes


BaseMemberPromotingProxy is a (terribly named) class meant to be used as the target for the DebuggerTypeProxy attribute. The code is based off of Jared Parsons’ FlattenHierarchyProxy. Like the original, BaseMemberPromotingProxy (which will be referred to as BMPP throughout the rest of this post) is designed to improve the debugger displays of classes that inherit from other classes.

What the what?

The best way to demonstrate BMPP is by giving an example. Consider these classes:

public class Dessert {
    public int Calories { get; set; }
    public Dessert(int calories) {
        Calories = calories;

public class Pastry : Dessert {
    public bool Flaky { get; set; }
    public Pastry(bool flaky, int calories) : base(calories) {
        Flaky = flaky;

public class Cake : Pastry {
    private String _baker;
    public Cake(string baker, int calories) : base(false, calories) {
        _baker = baker;

Let’s create an instance of Cake and look at the debugger display that Visual Studio provides by default.

var cake = new Cake("Jerry's bakery", 250);

We set a breakpoint after the instance of Cake is created, and Visual Studio pauses execution. Hovering over cake, we see:

So where are the members of Pastry and Dessert? We need to drilldown further to find them. It takes another click to see the Flaky property of Pastry, and one more additional click to see Calories of Dessert (as pictured below).

This is very inconvenient; even more so when actual complicated class structures are involved. Enter Jared Parsons’ FlattenHierarchyProxy.


Let’s see what FlattenHierarchyProxy (off of which BMPP is based) can do for us. We apply it to Cake with a DebuggerTypeProxy attribute.

public class Cake : Pastry {

Now, when we mouse over the cake variable, we get:

Jared’s type proxy greatly improves the debugger display by displaying all members (from both parent and subclasses) “side-by-side”. I’ve decided to call this the “promotion” of the members of subclasses (hence the name of my class). So what does BMPP provide?



I was really happy with FlattenHierarchyProxy, but felt the need to make a few improvements. BMPP contains the following improvements and new features:


“Opt-in” mode for properties and fields

Sometimes you don’t want to promote every member of the subclass(es) that your class derives from. Maybe a subclass contains a property or field that isn’t relevant to your parent class, so you’d rather not see it in the debugger display. Going back to our Cake example, let’s say that we don’t care about the Flaky property. We could apply a DebuggerBrowsable attribute to hide it (see below), but then we wouldn’t see Flaky even if we were debugging a plain instance of Pastry.
The solution is to use one of BMPP’s spiffy new attributes:

  • PromoteProperty(/* name of property */): Promote the specified property
  • PromoteField(/* name of field */): Promote the specified field

To hide Flaky while debugging instances of cake, we opt-in just Calories by applying a PromoteProperty attribute:

public class Cake : Pastry {

Now we get:

The way this works is that the use of a PromoteProperty attribute switches BMPP to “opt-in” mode for properties. Normally, BMPP grabs whatever properties it can from the parent class and all subclasses. Applying a PromoteProperty attribute turns off this behavior: only properties that are opted-in with PromoteProperty attributes are promoted. This behavior is the same for PromoteField properties. However, PromoteProperty does not switch on opt-in mode for fields, or vice-versa.
Also, note that we didn’t have to explicitly opt-in the _baker field since it was declared in the parent class, not a subclass. Members of the parent class are always included. This behavior exists with properties as well.
Note: I have considered implementing an opt-out mode in addition to opt-in mode. Please comment on my blog or submit an issue on BitBucket if you are interested in this for the next version.


Alphabetical ordering of members

This is something that Visual Studio does automatically, however since we are constructing a custom debugger display, we need to perform the sort ourselves. Replacing the last line of BuildMemberList() with the following does the trick:

return list.OrderBy(m => m.Name).ToList();

Note that the collective list of fields + members is sorted as one list. If you want different behavior (for example, you might want a sorted list of fields to appear before a sorted list of properties), let me know and I can add the functionality.


Honoring of DebuggerBrowsable attributes

Let’s rewrite the declaration of the _baker field from the Cake class as:

private String _baker;

FlattenHierarchyProxy would still display the _baker field, even though we’ve chosen to hide it using the DebuggerBrowsable attribute. The fix that BMPP makes is to introduce this internal helper function:

private static bool IsMemberBrowsable(MemberInfo memberInfo) {
    return memberInfo.GetCustomAttributes(typeof(DebuggerBrowsableAttribute), true)
           .Select(p => (DebuggerBrowsableAttribute)p)
           .All(p => p.State != DebuggerBrowsableState.Never);

Now, when BMPP builds the property and field lists, it uses the IsMemberBrowsable function as a filter.


Get it

The class is hosted on BitBucket. Documentation will be up on BitBucket soon – for now, use this page as a reference.

Performance information

I have not done extensive testing on the performance of BMPP. It is noticeably slower than FlattenHierarchyProxy, however. The performance hit comes from the fact that reading attributes is a fairly expensive reflection task, relative to everything else that the proxy does. If you have any ideas on how to improve performance, please let me know.

Two great articles on customizing debugger displays with C# and Visual Studio

I’ve been working on a rather large project for the past few months (a library), and I’ve had the need to customize how the debugger displays my classes during a debug session. I found two very helpful articles from Jared Par that I wanted to share.

Article #1: FlattenHierarchyProxy

A problem I ran into very recently is how to simplify the creation of DebuggerTypeProxy proxy classes for objects that have several levels of inheritance (I describe the problem on StackOverflow). Briefly, when debugging an object that has one or more base classes, the base and parent properties do not show side-by-side. Base class properties and fields are under a separate expandable list. This means that you need to expand through two lists to view a property that came from the base class. More levels of clicking are required when further levels of inheritance are used.

Solution: In his article, Flattening class hierarchies when debugging C#, Jared creates a proxy class called FlattenHierarchyProxy that accomplishes what I want: parent and base class properties and members are corralled side-by-side in the debugger display. It’s a really useful class that I suggest you check out.

Side note: I’ve made several modifications and improvements on the class which I plan to publish as a new open source project. Details to follow.

Article #2: DebuggerDisplay attribute best practices

This article provided some helpful dos and don’ts on the usage of the DebuggeDisplay attribute. It’s a quick read, but really useful: DebuggerDisplay attribute best practices

Having trouble logging into Origin even though you typed the right password?

For the last few days, Origin (EA’s content delivery system, not Origin.com) was pissing me off because although I entered my correct password, it would still reject my login. Then I would have to start the password reset process by requesting a reset key and choosing a new password. I was then logged in successfully, but the next time I went to log in with the password I just created, I’d have to start the process all over again.

The Origin application helpfully neglects to tell you that your password must be at least 8 and no more than 16 characters. Even worse, Origin still takes passwords that are longer than 16 characters – my guess is that it trims them down to the maximum 16 characters.

Solution: So, if you are having this problem, go through the reset process and be sure that you enter a password that is 8 – 16 characters. Then everything should work.

How to store, protect and organize electronic parts

Over the past few years, I’ve amassed quite the collection of basic electronic components (chips, resistors, etc.), little microcontrollers (Arduinos and Arduino clones), and a few other tiny gadgets (the coolest of which I consider to be this mini WiFi module). With all of these sensitive components and modules, I sought a simple and cost-effective way to store, protect and organize electronic parts. Here is what I’ve found to work.

Resistor kit

I used to consider resistors (and possibly capacitors too) the most difficult things in my collection to organize correctly and compactly. Luckily, I’ve discovered a way to not only stock up my collection but also organize the resistors that I already have. This resistor kit: Joe Knows Electronics 1/4W 86 Value 860 Piece Resistor Kit is perfect.

Each resistor is organized into a labeled baggie, and all the bags fit into the pictured box with a resistor code chart on the lid.

Joe Knows Electronics 1/4W 86 Value 860 Piece Resistor Kit

Capacitor kit

The same company that released the resistor kit also released this awesome capacitor kit. It’s organized just like the resistor kit, with each value of capacitor in its own little labeled bag. I highly recommend it.


Jumper wires

The most annoying thing in the world is making your own breadboardable jumper wires. I refuse to do it. Instead, I bought one of these: Elenco 350 Piece Pre-formed Jumper Wire Kit. The wires are the perfect stiffness, and the box keeps the various sizes from running into each other.

Parts organizer

LEDs, diodes, buttons… where do they go? For these (and similar parts), I’ve found this parts organizer: Stanley Consumer Storage 014725 25-Removable Compartment Professional Organizer.

The organizer has individual compartments that can be rearranged, and parts will not slip around (each compartment has a bottom, and when closed, there is very little space between the compartments and the lid). I wouldn’t suggest dropping the organizer, though, even if closed.

I also keep most of my ICs (integrated circuits, or, chips) in this organizer, but a little more care is needed (see below).

I own three of these things, and they are by far my favorite item in this collection. One day, I’ll post pictures of how I have everything situated in the organizers to give you ideas of how to organize your own parts.


Anti-static foam

Integrated circuits, microcontrollers, and a lot of other electronic components and modules are sensitive to static electricity. Many parts manufacturers protect their chips with anti-static foam. The leads of the part are pushed into the foam, which is slightly conductive. The best deal on this foam that I’ve been able to find is here: Techni-Stat Foam Conductive 24″ X 36″ X 1/4″ High Density

1/4″ is plenty thick, and two by three feet is much more than it sounds.

To store my integrated circuits, I press their little leads into sections of the foam that are the same size as a compartment in my parts organizer. Multiple layers of foam + chips can be stacked in the same compartment. You can also protect your microcontrollers and other electronic gadgets with leads by pressing them into this foam. I will say, however, that this foam does not have enough give to make storing things like Arduino Nanos simple.


Anti-static bags

Where do I store my microcontrollers and similar-sized items? Anti-static bags!

I have three sizes:

The 3 x 5″ size is perfect for storing smallish things like Arduino Unos. Larger boards (and/or those with protruding headers) are best kept in the 4 x 6″ bags. So far I have only needed the 6 x 10″ bags to store cables, but I might use them in the future to store finished projects.

These bags are resealable and reusable. They make it much safer for me to handle my electronics. Just make sure the bags are fully pressed closed, or else they may not block any static.


Label maker

Once everything is filed away and in its place, how do I know what is what? For this task, I use the Epson LabelWorks LW-400 Label Printer. Under $30 and with a bunch of options, it’s perfect for labeling my anti-static bags once their contents are safely tucked away. I also use the labels to label the compartments in my parts organizer.


Barcode scanner

I’ve actually had this for a while; a USB barcode scanner. Goes well with the label maker above, since the label maker can print barcodes. I also use this to manage my collection of books. At about $20, it’s pretty cheap; in fact, it was the cheapest barcode scanner that actually projects a laser that I found. Most of the cheap ones require you to hold the scanner up directly to the barcode.


Grid-It Organizer

Here’s something that I just got recently. It’s not just for electronics per-say, but it is really useful if you want to organize electronic devices such as flashdrives and cables. The best way to tell you about it is to show a picture of it in action:

It’s basically a rigid, flat (no, it doesn’t fold up or zip) organizer with stretchy, grippy straps that criss-cross. They are a variety of sizes and lengths, and to put something in the organizer, you simply lift the strap and slide your item in. The grippiness of the straps aren’t easy to see in the image, but trust me, this thing will hold on to your stuff tight.

What you can’t really see in the picture I posted is that there are tons of other straps behind the items. It’s endlessly configurable. I bought the black one, but I thought the red was easier to see.

Hopefully you enjoy these as much as I do! Please note that I don’t own any of these images; Amazon does.