A388

Kraken.io API Implementation in C#

Kraken.io is an image optimization service. I use it at work as part of an automated task from our system to optimize photos taken on job sites. As I'm writing this we've uploaded 3.24 million photos with a raw file size of 2.08 TB which were optimized down to 1.05 TB or about 50% saved. Those savings go a long way when storing, especially in the cloud.

There is an official Kraken.io client for .NET, but I didn't really feel comfortable with it. It just looked overly complex, so I opted for creating my own client. Also, when we first started using Kraken.io I had to make it as a scheduled task in Salesforce so I had to make my own client regardless. Eventually I ported it out of Salesforce and into our system because the Salesforce limitations and the amount of hoops I had to jump through to make it work were rediculous. Porting it to .NET and into our system allowed me to make the automated process do what it needed to without worrying about limits and constraints.

The client is available as a NuGet package here and targets .NET Standard 1.3.

To use the client simply create an instance of KrakenClient and pass in an instance of HttpClient and your API access and secret keys. For a short example of how it works, take a look at the linked video above.

On a side note, I really wish Kraken would just use a single API key like Carmine.io, Geocod.io and Google Maps, to name a few. The access and secret keys don't really do anything other than getting passed into requests. A single key would accomplish the same job. If there was an actual purpose to them like calculating a request signature like the AWS APIs, then they'd make sense, but they don't so it's an area where the API could be simplified in the future.

Let's get back on topic.

var kraken = new KrakenClient(httpClient, "{accessKey}", "{secretKey}");

Optimize

var optimize = await kraken.GetOptimizeAsync("{filePath}");

Optimize Wait

var optimizeWait = await kraken.GetOptimizeWaitAsync("{filePath}");

Download

var download = await kraken.DownloadAsync("{krakedUrl}");

Geocod.io API Implementation in C#

Geocod.io is a simple and straightforward geocoding service. I use it at my work to get the positions of job sites needed by some other automated processes.

The client is available as a NuGet package here and targets .NET Standard 1.1.

To use the client, create an instance of GeocodioClient and pass in an instance of HttpClient and your API key. For a short example of how it works, take a look at the linked video.

var geocodio = new GeocodioClient(httpClient, "{key}");

Once you have the client instance you can use the built in helper methods or compose custom requests. For example:

Get Geocode

var geocode = await geocodio.GetGeocodeAsync("1600 Pennsylvania Ave NW, Washington, DC 20500");

Get Geocode Batch

var geocodeBatch = await geocodio.GetGeocodeBatchAsync(new[] {
    "1600 Pennsylvania Ave NW, Washington, DC 20500",
    "East Capitol St NE & First St SE, Washington, DC 20004"
});

Get Reverse Geocode

var reverse = await geocodio.GetReverseGeocodeAsync("38.897675,-77.036547");

Get Reverse Geocode Batch

var reverseBatch = await geocodio.GetReverseGeocodeBatchAsync(new[] {
    "38.897675,-77.036547",
    "38.898976,-77.038219"
});

Carmine.io API Implementation in C#

Carmine.io is a fleet tracking service we use at my work. I integrated it into our system so I could to some more advanced vehicle to job site correlations. I had to make my own client to tap into their API and I want to share it.

It is available as NuGet package here and targets .NET Standard 1.1.

To use the client you just need to create an instance of CarmineClient and pass in an instance of HttpClient and your API key. Using dependency injection you can make this pretty simple, especially when it comes to the HttpClient instance. Take a peek at the linked video for a short example of how it works.

var carmine = new CarmineClient(httpClient, "{key}");

Once you have the client instance, you can just use the helper methods for quick operations, or build a custom request and pass it to the appropriate method. For example:

Get a List of Vehicles

var vehicles = await carmine.GetVehiclesAsync();

Get a Vehicle

var vehicle = await carmine.GetVehicleAsync("{vehicleId}");

Get a List of Users

var users = await carmine.GetUsersAsync();

Get a User

var user = await carmine.GetUserAsync("{userId}");

Get a List of Trips

var trips = await carmine.GetTripsAsync();

Get a Trip

var trip = await carmine.GetTripAsync("{tripId}");

Get Waypoints for a Trip

var waypoints = await carmine.GetWaypointsAsync("{tripId}");

Cleaning up a Fresh Install of Windows 10 using PowerShell

Windows 10, in my opinion, is a great operating system, but it does have its quirks and annoyances. One major annoyance is the number of apps that come pre-loaded on a new installation. At my work, I wrote a PowerShell script around two years ago that does some configuration when domain joining a new computer. It removes the annoying apps, and locks down some settings, among other things.

I had been thinking about re-writing the script to be a bit more generic, and I did. You can find it by going to the TOOLS section and downloading it from there. Here, I will explain how to use it. The script will need to be ran for a total of three times for the best results.

Before we continue, be aware that this has been tested on Windows 10 version 1803 (April 2018) update only. You can follow along below or watch the video demonstration.

1st Run

You will first need to set the execution policy to unrestricted within PowerShell to allow the script to do its job. Open a PowerShell window in Administrator mode and run the following command:

Set-ExecutionPolicy -ExecutionPolicy Unrestricted -Force -Confirm:$false

Then find the downloaded copy of the script and right click on it and select Run with PowerShell. The first run will:

  • Set the power plan to High Performance
  • Disable UAC

After UAC is disabled, the computer will be restarted. Once it's up we'll do the second run.

2nd Run

After the computer has restarted, find and run the script the same way you did in the first run. The second run will:

  • Repeat 1st run
  • Disable hibernation
  • Attempt to run the Windows 10 Decrapifier script
  • Remove app packages
  • Remove OneDrive

If the Windows 10 Decrapifier script was not found in the same directory as my script, then a browser window will be opened to the download location. Download it and wait for the computer to restart to continue into the third run.

3rd Run

On the third and final run, we just re-run the script one more time. This time if the Decrapifier script is available, it will be invoked. The third run will:

  • Repeat 1st run
  • Repeat 2nd run

After the final restart you should have a clean fresh copy of Windows 10. The only annoying thing is that sponsored apps are not removed. You will have to right click and "Uninstall" them yourself, however, thanks to the Decrapifier script they will not reinstall themselves again. From here on out you can customize Windows 10 how you want it to be.

Welcome to my Blog!

Hello and welcome to my blog!

My name is Arex and I work as a software developer. I’ve wanted to make a blog for quite a while now to share things I’ve learned while doing my work and here we are, I’ve finally done it.

I primarily work with ASP.NET and Entity Framework. I’m making my way through ASP.NET Core and Entity Framework Core as well. I’m also the administrator and IT guy at my work, so I have a fair amount of experience with Windows, client and server, and Amazon Web Services. Oh! I forgot, I’m also the database administrator, so I have at least above average SQL skills. Rounding things off are the standard HTML, CSS, and JS.

I’ll also include other topics such as cooking, gardening, herbalism, health, I hope some gaming, and anything else that has my interest.

My mom and I are both vegan, mostly raw, for health reasons and we’ve learned quite a bit about health and nutrition that we want to share.

I hope to get some gaming in and I’m kind of going to use the blog to make that happen. I’ve sadly spent far too many years focusing on thing but work and have abandoned playing video games, amongst other things, except for the 10 hours or so I can put in throughout a year.

Pretty much everything I post will be accompanied with a YouTube video, so if it interests you, please like and please subscribe to the channel, of course once there’s content on it. I’ll be honest, I do intend to monetize the channel once it’s possible, so I’ll be putting in the work and effort to grow the channel with quality content. Hope to see you there!