29.9.11

Google Plus

After a great deal of thought on the matter, I have decided to de-anonymize this blog. Not that it would have been terribly complicated to reverse-engineer who wrote this, but now I am taking steps to informationally "claim" it as my own.

My public profile on google plus is here.

30.7.11

Multi-Profile baked into Google Chrome (Dev Update Channel)

I have long been a fan of separate profiles for separate concerns. All my devfuel.com posts and management, for example, have been managed on a single profile. To accomplish this in the past, I have (in the past) made use of the command line option (--user-data-dir):

  • Make a short-cut for each profile and set the --user-data-dir flag to a different folder for each
  • Run chrome via the shortcut and then browse normally, but only as a particular profile
  • Use chrome themes to visually distinguish between profile instances
This has worked fairly well, so far, but it is a bit geeky for most users. However, this morning when I logged on, the latest chrome version had improved on its multi-profile support. It now looks like this (as of 14.0.835.8):

There is also further management for changing the profile name and icon available in the settings:


Please note that this has, of course, not hit the stable update channels (and probably won't for some time). To see it, you have to switch to (for me) the dev update channel. This feature will probably evolve further in its look and feel, too. (I have seen several versions of it so far). Regardless, the functionality is fabulously useful. I can't wait to see/use the finished product.


11.7.11

It is important to get closure in c#

Mike Hadlow recently shared a nice, succinct definition of a closure by way of some description and code demonstrations in C#. As always, an elegant, understandable description is invaluable, and so it is collected and referenced here for posterity.

30.6.11

"You do not have the permissions necessary to install this application"

I have been working with Google App Engine in conjecture with Google Apps for your domain, and their have been...quirks. The latest being that I recently added an application identifier that was a randomized series of letters and numbers (to avoid the dreaded "Sorry 'omgponies' is not available" message in the app creation process.

The App ID I made (now disabled and scheduled for deletion) "806df7ef93" created successfully, and I uploaded my app content just fine, but when i went to https://www.google.com/a/cpanel/[domain.com]/SelectServices and entered the correct App ID, I got the message:
"You do not have the permissions necessary to install this application"


I was a bit confused as I was logged in with an account that was an "Owner" of the application, but I happened upon a post by kernixski that suggested that this problem would occur if the App ID ended in a number.


Obviously there are other reasons for this error to manifest, and changing your App ID to not end in a number will probably not affect those cases. However, after choosing a new ID that doesn't end with a number, this process worked perfectly. Now, if I could only use my native Google Apps account in AppEngine without a Gmail.com proxy account, things would really be looking up.

15.6.11

Stringing it out - object.ToString() vs. Convert.ToString()

KodefuGuru has an interesting investigation and analysis of these two methods for serializing object data to strings. Convert.ToString() has some nice features that I will definitely be keeping in mind while I linger in the world of .NET/C#.

4.4.11

Bypass the colon - DRY your WPF/XAML label string resources with an Attached Property

DRY, like KISS (Keep It Simple Stupid), is one of those acronyms that one is unlikely to forget once you get the gist. It stands for Don’t Repeat Yourself and I have long been an adherent to this philosophy, but only recently was acquainted with the acronymic tie.
While working in WPF/XAML, I have see one such repetition battleground emerge: String resources in a .resx file.
Consider:
<data name="UserName" xml:space="preserve">
    <value>User Name</value>
</data>
Versus:
<data name="UserNameLabel" xml:space="preserve">
    <value>User Name:</value>
</data>
The latter might be intended to be used in XAML like:
<TextBlock Text="{x:Static res:Resources.UserNameLabel}" />
But now we can see the problem. If and when you take steps to internationalize, you have to translate both resources. And if you refactor, you have to manage both instances.  While I have seen a couple solutions to this problem, I happened upon an alternative idea, an Attached Property:
<TextBlock ns:Attached.LabelText="{x:Static res:Resources.UserName}" />
At this point, we have handily done away with the “colonated” version of the label (or hyphenated, etc.) in favor of the real, underlying resource. Now we have become more DRY (If I may use this sense).
The implementation is shockingly simple:
public class Attached
{
    public static string GetLabelText(DependencyObject obj)
    {
        return (string)obj.GetValue(LabelTextProperty);
    }
 
    public static void SetLabelText(DependencyObject obj, string value)
    {
        TextBlock textBlock = obj as TextBlock;
        if (textBlock != null)
        {
            textBlock.Text = string.Format("{0} :", value);
            //TODO: Make the string format a localizable resource
        }
        obj.SetValue(LabelTextProperty, value);
    }
    public static readonly DependencyProperty LabelTextProperty =
        DependencyProperty.RegisterAttached("LabelText",
            typeof(string),
            typeof(TextBlock),
            new UIPropertyMetadata("DefaultLabel"));
}
So where does that leave us? We should now be able to use this Attached Property to avoid string resource repetition, and that is a good thing. A similar approach will work for other Controls, text decorations, etc. Let me know if it works out for you.

6.10.10

Workaround: Android DDMS: "Screen not available" for screenshot

Been working more with DDMS as a screen capture mechanism (was using Alt+PrntScrn method before) and have found an alarming trend:

Sometimes, when using the "Device Screen Capture" mechanism, I get the following:

It seems to happen more when I am on certain, custom views that deal with multiple layers of transparency. Usually i could just hit the "refresh" buttons a few times and work past it.

When hit with a more persistent "Screen not available" situation, i was stuck. 15 refreshes never resulted in a capture. Closing and reopening had the same result.

Finally, on a whim, i hit the rotate keys while the focus was on the emulator (either "7" or "9" on the numeric keypad), and then the "refresh" button in DDMS. To my amazement and relief, the capture went through. Now when a capture repeatedly fails, I typically rotate the orientation in the emulator and THEN hit capture. For whatever reason, this seems to do the trick. *shrug*