Programming Protips

Small posts meant to document the solutions to problems I've encountered while writing code and deploying apps.

Setting up a FedEx account to test shipping with EasyPost

If you're using EasyPost to send and track carrier shipments, you're going to need a shipping account to test it with. I've found FedEx to be one of the easiest carriers to use for testing, but setting up an account isn't quite as easy as it should be.

Resilient background tasks in Windows and Windows Phone

Setting up background timer tasks is a little harder than the official documentation makes it seem. You need to handle things like app updates, requesting background access and handling situations where the battery saver disables background tasks. In this post you'll learn how to prevent those things and build resilient background tasks for Windows and Windows Phone.

Send and validate an ASP.NET AntiForgeryToken as a request header.

Sometimes you need to send JSON instead of an HTTP form post, but this doesn't work when you're using ASP.NET's AntiForgeryTokens. In this short post you'll learn how you can use jQuery to automatically send form data as JSON along with an ASP.NET AntiForgeryToken. Then to top it all off, you'll create a custom token validation attribute to protect your web application from CSRF attacks.

Load an image from a Base64 string on WinRT

I've been working on a Windows Phone and Windows 8+ app that interacts with a JSON API. This API sends images over the wire as a base64 string which I then need to convert to an image and display it to my users. However, it's not quite as easy to do in a WinRT app as it is in any other XAML program. I'm posting it here for posterity.

Joining KeyValuePairs into an HTTP form post

I had to join a bunch of parameters into an HTTP form post and send to an external API. I've done it before, but I can never seem to get it right on the first try. Instead of Googling around and piecing together a few different StackOverflow questions, I'm just going to post it here for posterity.