Thursday, May 9, 2013

Developer humor

I literally cried this morning as I scanned these posts.

Note: Don't have a drink in hand or mouth when reading these.

Enjoy:

If you’re a git user.

Tuesday, March 19, 2013

RichEditBox gives UnauthorizedAccessException (Access is denied) error when SetText called.

While working on a little WinRT app I recently spent WAY too much time trying to figure out why I was getting the following exception

System.UnauthorizedAccessException was unhandled by user code
  HResult=-2147024891
  Message=Access is denied. (Exception from HRESULT: 0x80070005 (E_ACCESSDENIED))
  Source=Windows.UI
  StackTrace:
       at Windows.UI.Text.ITextDocument.SetText(TextSetOptions options, String value)

when all I was trying to do was programmatically set the text of a RichEditBox. EX:

theRichEditBox.Document.SetText(Windows.UI.Text.TextSetOptions.FormatRtf, textValue);

After searching and searching and eventually taking a walk to cool down, I decided that I would play with the IsReadOnly flag. I have it set to “True” in the XAML because I don’t want users to edit the text. I then wondered if this was causing the problem.

I tweaked the code as shown below and it magically started working. Notice how I’m turning off the IsReadOnly flag off, then setting the text, and returning the read only state after the text has changed.

theRichEditBox.IsReadOnly = false;
theRichEditBox.Document.SetText(Windows.UI.Text.TextSetOptions.FormatRtf, textValue);
theRichEditBox.IsReadOnly = true;

Dear Exception: you were not helpful. Sigh.

Tuesday, March 12, 2013

Windows 8 Share Charm Data Inspector

In a previous post I mentioned I would share the app I created during a Windows 8 hackathon event.

I spent some more time adding polish, testing, re-thinking my initial designs and today, I’m excited to say that it is now in the app store!

What does this app do?

The Share Data Inspector is an application that allows you to inspect the details of data being shared from other applications through the Windows 8 Share Charm (Win+H).

For example, if you open the Video app, select a movie and use the share charm (Win+H) to share the video, what data is actually shared? The Share Data Inspector will appear up as an application you can share the just about any data with and you can inspect at a lower level what values are shared.

This application will give you insights into data that you never thought was being shared.

How do I get the app?

Open your Windows 8 App Store and search for “Share Data Inspector”. (or click the link “View in Windows Store” button.

I’d like to suggest a feature:

If you’ve downloaded the trial app and would like to see some improvements. Head over to this site, suggest a feature and help this application grow from a hackathon created app into a full-fledged application.

Happy Sharing!

Thursday, March 7, 2013

Windows 8 Hackathon: Good for participants. Bad for Microsoft.

Last weekend I participated in a Windows 8 hackathon. In 24 hours of coding I had an app created and submitted to the App Store for certification.

24 hours to create an app?

I'll share details about the app I created in a future post. For now, I have since removed my app from the review process in the Developer Portal.
Before I get into why I (temporarily) removed my app. I would like to first talk about a number of the real benefits I saw with the hackathon.
  • I work from home as a remote employee. Don't worry I'm not at Yahoo. The event was a fun change of pace; working in a room of developers hacking away on their own ideas. You could feel the energy and this energy is probably why it was possible to burn the midnight oil hacking on my own app.
  • This contest forced me to work all the way through submitting an app to the store which I believe to be more of a mental hurdle than an actual one. This process was definitely made easier with Microsoft on hand to answer questions and get over some of the non-obvious steps in the process.
  • Working in a room with the others proved to be useful when you got stuck on something. Shouting out 'I'm stuck on problem X’ and have someone there to point you in the right direction and unblock you is great.
  • The short timeframe forces you to focus on your Minimum Viable Product. Work on what is necessary and avoid getting side tracked.
  • Related to the focus above I really got into the zone hacking away at my app; this certainly reminded me of why I love this profession.
  • Meet developers in the area.
  • Learn interesting problem domains and how others tackle them in their apps.

Now, why am I really writing this post?

I believe Microsoft is shooting themselves in the foot with how they are running these hackathons.
I can’t say I speak for how the hackathons are being run, but my experience showed me the following.
With Microsoft’s own employees running these events and not giving a lick to the quality of the applications being submitted they are setting themselves up for failure.
I can see from a marketing perspective that having a large number of apps in the store will help them drive more people to their platform. That’s crap. There are far too many reasons Microsoft should be driving QUALITY into the store and not quantity.
Let’s list a few reasons this is going to backfire:
  • NOBODY wants to use crappy apps developed in 24 hours. NOBODY!
  • There are very few apps that can be written in 24 hours without maintaining some sort of a quality bar.
  • The certification process will get clogged causing the testers to care less about finding quality issues and pounding through “numbers”.
  • We'll have a huge collection of crappy apps where the sheer number of apps will make finding a good quality app nearly impossible.

How can they make this better?

Something interesting about this is generally when you talk about Pros/Cons to something, you have to give-up something to fix a Con and that sometimes means taking away from the Pros.
However, I feel like we can keep ALL of the pros I listed above while also reducing the amount of Cons if only Microsoft incentivized their employees to drive quality into the store.
  • Do – push people to get an app done and help them through the app store
  • Do – provide guidance around how to build-in quality
  • Do – provide some metrics that will help the app succeed in the end (design, best practices, possibly even saying, “That’s been done”)
  • Do – recommend they cancel submitting their application if it hasn’t met the developers quality metric. (This isn’t going to save the app store, but would help to reduce the number of write-once-let-die-in-the-store apps)
  • Don't – offer a prize for "the most apps submitted" within 24 hours.
I’ve developed on the Microsoft platform for a long time and really hope there is a place for the Microsoft App Store in the future, but with their push for a large number of apps they’re not setting themselves up for an easy road back in the game.

Sunday, February 24, 2013

DefinitelyTyped TypeScript definitions now on NuGet

I recently started playing with TypeScript on an asp.net MVC web application.

We're leveraging some third party js libraries and found the type definition files over at DefinitelyTyped a huge help when dealing with libraries not originally written in TypeScript.

The first thing I tried to do was add them via NuGet and when I didn’t see them up there, I strolled to the DefinitelyTyped issues list and saw an open GitHub issue requesting the functionality.

So I took on the task. Created a PowerShell script to automate publishing and synchronize changes to the DefinitelyTyped repo up to NuGet.

This morning I pulled the trigger and published 127 different NuGet packages for each DefinitelyTyped TypeScript definitions.

As an example:

If you ran this in visual studio NuGet Package Manager console

Install-Package angularjs.TypeScript.DefinitelyTyped

You would get the following installed into your project

image

Note how we didn’t ask it to install jQuery? The powershell script leverages the reference path:

/// <reference path="../jquery/jquery.d.ts" />

in each TypeScript definition to help determine dependencies. We then configure the NuGet package with a dependency on the jquery DefinitelyTyped TypeScript definition package.

image

 

Happy TypeScripting!

Saturday, February 23, 2013

How do I undo a bad rebase in Git?

If you use git and leverage the rebase command, you've probably run across a merge issue during the rebase and if you’ve ever felt like, “man, I wish I had a ‘do-over’.

If you’re still in the middle of a rebase it's easy to start over:

git rebase --abort

But let's say you started with this:

image

Did a git rebase and are now looking at:

image

Except you screwed up during a merge conflict and now un-sure how you can get your ‘do-over’.

 

I was pleasantly surprised at how easy it was. (If you know key)

Leveraging the git reflog, you can go back in time and check out your branch as though the rebase never happened.

In the following link, I put together a set of steps to create a git repo that puts you into this position (of a bad rebase) and then describes how to get out of it.

https://github.com/staxmanade/GitRebaseReflogFixSample

I'd love to hear any feedback on this repo. Or try submitting a pull request or post a GitHub issue.

Happy Git'ing!

Tuesday, February 12, 2013

It's Markdown, no, PowerShell. Wait its Markdown formatted PowerShell.

I created an introductory presentation on PowerShell a while back and posted it on my GitHub. I first gave the presentation at the NNSDG and decided to also submit it as a talk to the Boise Code Camp this year. (Looks like I'll be going – track me down @staxmanade if you’d like to say hello)

I’ve become quite a fan of Markdown lately and thought, “what if this not only looked like PowerShell, but looked even better as Markdown…?”

 

After experimenting a little, I found that it actually works quite well.

For example:

PowerShell (Markdown)

## String Interpolation

### Single quotes `don't` interpolate
'Hello $groupName'

### Double quotes `DO` interpolate
"Hello $groupName"


### Wrap `$(...)` around expression within an string
"groupName variable is of type: $($groupName.GetType().FullName)"
"2 + 1564 = $(2 + 1564)"
"Current DateTime is = $(get-date)"
"Current DateTime is = $([System.DateTime]::Now)"


### Escape characters with the ` (back-tick)
"Escape a quotation `"This is quoted`"."


 



Formatted Markdown



image



 



One issue I have is the way GitHub/markdown formats extra whitespace (it doesn’t). So I’ve worked around that so that I can get the vertical whitespace that I need in the Markdown version by placing a link to a spacer image:



![vertical space](http://is.gd/VertSpace)


This isn’t ideal because my PowerShell is littered with this snippet, but something that can easily be search/replaced before using the raw version as a PowerShell script.



I also think that you could potentially do this with many different programming languages. (At least ones that don’t depend on whitespace and have a form of block comments)



Nifty eh?



Happy PowerDowning or MarkShelling!

 

Copyright 2008 All Rights Reserved - Revolution Theme - by Brian Gardner. Converted into Blogger Template by Bloganol dot com