Monday, November 7, 2016

.NET Core Authentication: a taste of what's to come

I've been very busy getting my hands dirty with .NET Core.  It's pretty awesome stuff

The latest endeavor has been to get OpenID Connect to work in 2 directions with ASP.NET Core:

1. Web API server authenticates via JWT thru a Xamarin Android app
2. Regular browseable web pages authenticate via OAuth2/OpenID Connect cookie (I don't fully understand it either but it works!)

Scenario 1 is important because mobile and maybe desktop apps can use this standardized JWT format for API calls in lieu of the likely-proprietary cookie format

Scenario 2 is important because for your web users they want SSO like behavior, which cookies plus OpenID connect provide (i.e. the "sign in with google" button we're all accustomed to seeing)

Importantly, both scenarios are working with Google Sign In.  Thus, in theory, no new account registration required anywhere to be authenticated - presuming you have a Google login of course ;)

I plan to provide example code of how to do all this & understand most of it.  It took a lot of digging around to make it all work!

Tuesday, May 17, 2016

Debian + ASP.NET Core 1.0 RC2 + AngularJS 2

This is a short blurb about my experience implementing the great examples provided at within an open-source Debian linux environment and using slightly newer tooling.

Since he (she? they?) has gone into excellent depth, I'll only cover what I did differently to get it to work in a non-Windows environment (spoiler alert: not much!)

ASP.NET Core 1.0 RC2

Presumably you installed ASP.NET Core 1.0 RC2 already.  If not, head over to  Having only ever built from source, I can't comment on the prebuilt binaries.  My bet is they will work well.


To create ASP.NET boilerplate code, we use Yeoman (installed via npm).  Type:

yo aspnet

Then Choose "Web Application" because conveniently enough, MVC now is Web API with ASP.NET Core!

Check this page for installation tips:

Visual Studio Code

While not strictly necessary, I found Visual Studio Code to be very robust and it sped me through many otherwise slow, trudging tasks.  This includes:

  • C# syntax error highlighting
  • assist with "using" statements
  • Integrated debugging - although I lucked out and didn't need it, it does work very well and having that on tap has a value which cannot be overstated

Building Visual Studio Code ... from code

Most folks will install direct from a download, but if you're like me and want to build vscode from source, be advised - I found no "install" mechanism when building Visual Studio code.

For convenience, after building Visual Studio Code I made a $PATH discoverable symlink called "vscode" to easily start it anywhere.  I suggest you do the same

.vscode folder & tasks.json

Visual Studio code creates a .vscode folder and assists you in creating two files:
  • launch.json - among other things, this feeds the debugger for what configurations you'd like to launch & debug
  • tasks.json - when using vscode's integrated build feature (ctrl-shift-B on non Macs) it reaches out to this file to determine what to do.
I ran into an issue where I wanted typescript files to auto compile, which apparently is also a tasks.json configuration.  So two different behaviors for tasks.json, but everywhere I read had super confusing examples for how to do that.  My conclusion: I don't fully understand tasks.json and assume I must perform typescript compilation manually.

To that end, I use "tsc" (install via npm).  


With my weak JavaScript skills (of which I am not ashamed) it took some fiddling to get paths.npmLibs right.  I deviated from the example as the new boilerplate code is a smidge different.  Here's my paths code:

 For you non-weak JavaScript programmers, I'm sure you've already moved past this one

Don't forget, Visual Studio isn't here to help you with gulp tasks, so you'll have to run them manually (you'll want to run gulp copy-deps and gulp min) after you've done a proper npm install.  Remember, a proper npm install won't work until your package.json is sorted out.


Most of my difficulties in bringing up functioning code boiled down to getting package.json right.  Visual Studio Code provides a lot of help, but still fiddling was required.  Here's what I came up with:


With all that in place, we get results identical to what is seen on the talkingdotnet site (the initially mentioned article) - but now running on 100% open source and free software!

Friday, January 16, 2015

.NET Core and friends

With all the hullabaloo around .NET Core, I thought I'd dig in, try it out and see what all the fuss is.

It's taken a bit of effort to cut through the hype and get to the meat of what it is, and what it is expected to be.  Here's the no-nonsense version, based on a few hours of experimentation:

What .NET Core is today:

* A modularized .NET framework whose libraries are acquired through NuGet
* The newest way to do your ASP.NET apps
* A gateway to using .NET Native, for machine-compiled code instead of JIT
* An adoption by MS of many Mono sources and open source in general for .NET

What .NET Core is also today, 

but might/should be categorized under a different name depending where you read:

* A new project file structure focusing on "kproj" and Project.json
* Aforementioned new structure facilitates targeting any combination of multiple .NET frameworks within one project file (yes!)
* A way to do very nifty console apps which demonstrate the power of above multitargeting, with zero relation to ASP.NET or .NET Native

What .NET Core isn't, today:

* A fully functional replacement for current mature .NET Frameworks.  .NET Core is missing many support libraries, such as System.Transaction
* A Client-friendly entity.  No WPF for .NET Core yet, based on what I read.

What .NET Core promises to be in the future:

* The foundation for all upcoming .NET Frameworks
* A unifying force bringing together things like .NET CF, Silverlight, Windows 8 API, etc.
* Cross platform to Linux, Mac OS as well as Windows

What .NET Core promises to be today, but I can't figure the @#$! out:

* A way to build "regular" .NET projects as well, but referencing "regular" .NET Framework libs (like System.Transaction... or any of the others) is darned mysterious
* Can utilize PCL and SHPROJ projects.  Can't find a way to make SHPROJ works


I'm damned excited.  Multitargeting within the confines of csproj files is a disaster area, and SHPROJ helps a lot, but it's still just awful with the way packages.config and repositories.config all collide with each other.  The .NET Core revamped project structure promises to solve all that

Saturday, December 21, 2013

Nexus 5 GPS repair howto & pictures

Some people are experiencing inaccurate GPS on their Nexus 5.  I and my friend were two such people.

Apparently the GPS antenna has a weak physical connection point within the phone.  After watching some youtube videos ( and (, I tried it repairing this myself.

While extremely helpful (thank you guys!) the videos left out some important factors and image quality could be better.  The photos here aren't exemplary, but the quality is high enough to remove ambiguity.

Items you will need:

- strong, thin plastic wedge.  I used a guitar pick
- card stock.  check your junkmail
- electrical tape
- very sharp knife or jeweler's flathead screwdriver

DISCLAIMER: I am not an authorized repair technician, and am not liable if your phone turns into an internet meme, supermodel, ball of flame, or other unintended result.  Proceed at your own risk!

On to the repair:

#1 Removing the back

Removing the back there are two things to know:

a.  Don't use a knife.  You want something plastic otherwise you'll damage your back case.  I used a heavy-weight guitar pick, worked like a charm.

Bottom adhesive
b.  Some devices have adhesive near the bottom, requiring extra force to pull out.  Mine took an uncomfortable amount of force which resulted in a slight permanent bend in the back.  Ultimately I "cut" the adhesive slowly with the guitar pick, had I done this earlier the bend would not have happened.  Use your own judgement here, it will be obvious if it's bending too much.

c. There's another issue with the adhesive, but we'll get to that later

#2 Lifting the contact

The offending contact is glued down and delicate, so be gentle.

a.  Use a very tiny flathead screwdriver from a jeweler's set, or a very sharp knife (not a butter knife) to carefully lift the antenna contact from the back.

b.  You don't need to lift it so much that it flaps like in the video, just enough to slip 1mm of cardboard underneath.

#3 Prep and place the cardstock

The cardstock provides a shim in which to push the contacts more forcefully from the phone into the GPS antenna.

This is the focal point of the repair.

Any thinnish cardstock will do.  We're only looking to raise the contacts about 1 mm.  I cut up some junkmail, worked like a charm.  You only need a tiny piece, well under 1 cm square, so put down that honkin' refrigerator box.

The pictures make it appear that the cardstock is folded in two, but it is not.  It is one small, flat piece.

Yeah, my tape is janky.  It works, dammit
#4 Taping it down

The cardstock has a bit of free play in there, so we need to secure it with some tape.  Not much is needed, just enough to keep it from moving about.
Don't use too much cardboard or tape, because the bulk will lift the rear and cause other contacts to lose connection, namely the wireless charging contact.

#5 Putting it back together

If your device had no adhesive, then you're good to go, snap it all back together - it's easy

If your device has adhesive at the bottom, you may want to remove it.  It can bunch up and cause a minor lift of the rear case, nullifying your work and also causing problems for other contacts.  My wireless charger stopped working until I scraped it off.  I suggest leaving it on and trying things out, and only remove it if you have to.

Scraped off adhesive

wireless charger contact


Afterwards, GPS appears to be improved slightly.  Locks seem to happen a bit faster and to more satellites.

Accuracy seems to be improved by about 5-10 ft.  Too soon to tell, but it seems like there's less drift and no more "compass freakout"

I'll need more time with the unit to say whether it made a sizable difference or not, but initial results are positive.

Saturday, September 1, 2012

Tapp and NFC payments for the masses

If you own an NFC equipped Android phone but have been left out of the Google Wallet fun, check out Tapp . Finally, almost a year after buying my i777 today I was able to buy something with NFC!

Saturday, August 18, 2012

Android, AOSP, Cyanogenmod and life

So I own an AT&T Galaxy SII i777 I can't say enough good things about this device. Nearly a year and a half old, it still kicks the ass of most devices people have in their pocket. It's fabulous

After hemming, hawing and complaining about the carrier's lack of interest in keeping old (but very capable) phones updated with the newest version of android, I took matters into my own hands.

I've been a longtime fan of CyanogenMod and its close relative AOKP. I happily ran AOKP ICS for a while (task650 variant), cheerfully bragging to my oblivious iOS pals about how behind they were.

Well with Google's Jellybean release, the AOKP front has been silent. And the Cyanogenmod (v10) activity is present, but just beginning. But I said to myself, "I'm a developer, I don't have to wait!". So I've been compiling my own CM10 builds. You can find it here.

Yet more opinions..

But my point wasn't to brag so much about that really nifty XDA thread I posted. That's just a happy accident. The real focus was to go on record and say how awesome android development is. I've tried my hand at Windows Mobile, iOS even a tiny bit of Palm OS back in the day. There's no comparison. Android blows them all away. And I don't say this lightly. I am a self-admitted Microsoft lackey, with a deep and passionate love affair with the .NET framework.

When it's good, it's good. And developing on Android is great.

I'm not loving the AOSP build process, but I see the necessity to its complexity. But as far as the OS and apps are laid out, it follows my #1 most important rule of development: predictability. Things are where you expect them to be. And if they aren't, once you learn a bit, you say - AH, that's a good place for them.

Upping the ante

So now that I've been running my own builds for a while, I've learned a few things. Enough to start tweaking some of the inbuilt CyanogenMod apps. Namely, I've had my eye on DSPManager for a long long time. It's not a major thing, but I've always been annoyed that you couldn't switch your EQ curve/audio profiles easily.

So, I've started a github repository and am once again taking matters into my own hands. My ultimate goal is to get it into the official build, but I have a lot of learning to do between now and then.

Friday, May 11, 2012

More jQuery validation shenanigans

Here's my latest custom rule for doing regex within jQuery validation. Lifted & modified from stack overflow.  Not doing a whole lot, but super useful:

* Malachi Burke.  
* (c) 2012 Apprentice Lib
        function (value, element, regexp) {
            var options = "";
            if (typeof (regexp) != "string") {
                options = regexp.options;
                regexp = regexp.match;
            var re = new RegExp(regexp, options);
            return this.optional(element) || re.test(value);
        "Please check your input."
Using it is like:
fieldName: { required: true, regex: { match: "your regex string" } }