Why I’m not a fan of New Year’s Resolutions

Wow, we are already one week into 2017. The Christmas decorations are put away, the leftovers are eaten, and I have to get used to writing the correct year. So far it’s going well, although my brain had a glitch last week where I kept writing “2012.”It’s also the time where I keep getting asked what my New Year’s resolutions are. My standard answer has been “get more sleep and eat more food.” It’s not really a serious answer, because I am not a fan of New Year’s resolutions.

Here’s why. It’s pretty easy to get caught up in the idea that a new year magically brings a clean slate where all past indiscretions are deleted and all the food you’ve eaten suddenly doesn’t have calories. I get that the start of a new year, symbolically, means a whole year ahead to make better choices. However, our past choices tend to follow us. Change is tough, and it is so easy to become disillusioned by the second week of January once it sinks in how difficult our resolutions are.

Instead, I think it’s more realistic to make very small changes. They don’t have to be on New Year’s Day to be effective or meaningful either. Maybe just one small change (like going for a ten minute walk every other day) at a time. That way, it isn’t overwhelming or discouraging. That is what we are hoping the Goal Buddy app will accomplish: help establish a pattern of small, positive choices that are cumulative towards a grander goal.

As for me, I am going to try skiing once per week. I went this morning and I already know I’ll need a paint roller covered in Rub-A535 tomorrow…

paintroller

Save

Posted in Fun, Goal App | Comments Off on Why I’m not a fan of New Year’s Resolutions

Merry Christmas from Saturday Morning Productions

Merry Christmas everyone! We can hardly believe how quickly 2016 has gone by and that the new year is almost here.

xmas3So many things have happened that it’s going to be a challenge to summarize them all here without making you read for the next hour. But hey, challenges are fun! This year Ada got a brand-new full time job that she will start in the new year. She and her family also traveled to Hong Kong and China, and saw tons of interesting things including the Great Wall and the Forbidden City. Chris worked hard on xmas2developing Goal Buddy (as did Ada!), as well as his other computer projects. He said that his big goal is to become a better communicator.

I (Liv, that is) had one heck of a year too. I started the huge goal of joining EPS, and that meant ramping up my fitness to unforeseen levels, and as I write this I am proud to say that I have cleared the first hurdles and have my xmas1physical assessment (the APREP) coming up in January. When I started working out seriously in March, I could barely deadlift 60 pounds and couldn’t do a chin-up to save my life. I’m now proud to say I can deadlift nearly 200 pounds and do wide-grip pull-ups as well as chip-ups.

Thanks for joining us on this journey, and we look forward to achieving goals with you in 2017! Merry Christmas to all and to all a good night.

Posted in Fun | Comments Off on Merry Christmas from Saturday Morning Productions

Today I Learned How to Create a Local Notification in Xamarin Android

In Android you can schedule a notification that shows immediately using the NotificationManager.  However, if you are like me, awesome, and want to schedule a notification for a future date you need to use the Android AlarmManager.  The alarm manager lets you schedule an Intent to occur at a later date.

Quick aside, do you know what an Intent is in Android?  I kind of understand them but not as in-depth as I would like.  Please forgive any errors I make when I setup the alarm intent below.

Without any further hesitation here is the code to schedule a local notification stolen from the SaturdayMP.XPlugins.Notifications:

public string Create(string title, string message, DateTime scheduleDate, Dictionary<string, string> extraInfo)
 {
 // Create the unique identifier for this notifications.
 var notificationId = Guid.NewGuid().ToString();


 // Create the alarm intent to be called when the alarm triggers. Make sure
 // to add the id so we can find it later if the user wants to update or
 // cancel.
 var alarmIntent = new Intent(Application.Context, typeof(NotificationAlarmHandler));
 alarmIntent.SetAction(BuildActionName(notificationId));
 alarmIntent.PutExtra(TitleExtrasKey, title);
 alarmIntent.PutExtra(MessageExtrasKey, message);


 // Add the alarm intent to the pending intent.
 var pendingIntent = PendingIntent.GetBroadcast(Application.Context, 0, alarmIntent, PendingIntentFlags.UpdateCurrent);


 // Figure out the alaram in milliseconds.
 var utcTime = TimeZoneInfo.ConvertTimeToUtc(scheduleDate);
 var epochDif = (new DateTime(1970, 1, 1) - DateTime.MinValue).TotalSeconds;
 var notifyTimeInInMilliseconds = utcTime.AddSeconds(-epochDif).Ticks / 10000;


 // Set the notification.
 var alarmManager = Application.Context.GetSystemService(Context.AlarmService) as AlarmManager;
 alarmManager?.Set(AlarmType.RtcWakeup, notifyTimeInInMilliseconds, pendingIntent);

 // All done.
 return notificationId;
 }

First thing to notice is the GUID. This is not required when scheduling a notification but can be useful later when you need to find and cancel it.

// Create the unique identifier for this notifications.
var notificationId = Guid.NewGuid().ToString();

Next you need to create the intent you want to occur.  This is the notification as well as what happens when the user clicks on the notification when it appears.  When creating the intent set the class you want to be executed.  In this case it’s the NotificationAlarmHandler.

var alarmIntent = new Intent(Application.Context, typeof(NotificationAlarmHandler));

The title and message are displayed when the notification is displayed.

alarmIntent.SetAction(BuildActionName(notificationId));
alarmIntent.PutExtra(TitleExtrasKey, title);
alarmIntent.PutExtra(MessageExtrasKey, message);

The action name is built using the notification ID and looks something like:

com.saturdaymp.exampleclient.NOTIFICATIONS-[notificationId]

Then you need to wrap the intent in a pending intent.  What is the different between an Intent and PendingIntent?  Well a pending intent is an intent that will occur sometime in the future.  Just like it sounds.  Actually a PendingIntent is a reference to the actual Intent so if your application is shut down your scheduled intent is not destroyed.  Remember I don’t really understand Intents very well.

var pendingIntent = PendingIntent.GetBroadcast(Application.Context, 0, alarmIntent, PendingIntentFlags.UpdateCurrent);

Next we need to translate C# dates to Android dates.  Don’t ask me for the details.  I found this code in edsnider/Xamarin.Plugins project.  Something to do with the Unix epoch.

// Figure out the alaram in milliseconds. var utcTime = TimeZoneInfo.ConvertTimeToUtc(scheduleDate);
var epochDif = (new DateTime(1970, 1, 1) - DateTime.MinValue).TotalSeconds;
var notifyTimeInInMilliseconds = utcTime.AddSeconds(-epochDif).Ticks/10000;

Finally we are at the moment we can actually schedule the notification.  Man that took longer than it should have.  Let me catch my breath.  I think I suffer from Panda Asthma.

Now that I have my breath back let’s schedule the notification.  This part is straight forward. Just get an instance of the AlarmManager and then schedule our pending intent. Ask the alarm to  wake up our application, if it’s asleep, at our scheduled time.

// Set the notification.
var alarmManager = Application.Context.GetSystemService(Context.AlarmService) as AlarmManager;
alarmManager?.Set(AlarmType.RtcWakeup, notifyTimeInInMilliseconds, pendingIntent);

That’s it.  The shows over.  Go home.

Actually the show is not over.  The above will only schedule an alarm but not show the local notification.  Remember when we created the intent linked to the NotificationAlarmHandler?  It’s below for a reminder:

var alarmIntent = new Intent(Application.Context, typeof(NotificationAlarmHandler));

Now we need to implement the NotificationAlarmHandler class.  It should look like the below.

[BroadcastReceiver]
internal class NotificationAlarmHandler : BroadcastReceiver
{
  public override void OnReceive(Context context, Intent intent)
  {
    // Pull out the parameters from the alarm.
    var message = intent.GetStringExtra("message");
    var title = intent.GetStringExtra("title");

    // Create the notification.
    var builder = new NotificationCompat.Builder(Application.Context)
     .SetContentTitle(title)
     .SetContentText(message)
     .SetSmallIcon(Resource.Drawable.logo_square_22x22)
     .SetAutoCancel(true);


    // Set this application to open when the notification is clicked. If the application
    // is already open it will reuse the same activity.
    var resultIntent = Application.Context.PackageManager.GetLaunchIntentForPackage(Application.Context.PackageName);
    resultIntent.SetAction(intent.Action);
    resultIntent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);

    var resultPendingIntent = PendingIntent.GetActivity(Application.Context, 0, resultIntent, PendingIntentFlags.UpdateCurrent);
    builder.SetContentIntent(resultPendingIntent);

    // Show the notification.
    var notificationManager = NotificationManagerCompat.From(Application.Context);
    notificationManager.Notify(0, builder.Build());
  }
}

The first thing we do is pull out the message and title from the alarm intent and add it to the notification.

// Pull out the parameters from the alarm.
var message = intent.GetStringExtra("message");
var title = intent.GetStringExtra("title");

// Create the notification.
var builder = new NotificationCompat.Builder(Application.Context)
  .SetContentTitle(title)
  .SetContentText(message)
  .SetSmallIcon(Resource.Drawable.logo_square_22x22)
  .SetAutoCancel(true);

Next we need to tell the notification what to do when the user clicks on it.  If you just want to show the notification you can skip the next part but in this example we open the application that generated the notification.

Notice that we pass along the alarm intent’s action to the notification result intent.  Because the action contains the notifications unique ID the application will know what notification it received and react accordingly.

// Set this application to open when the notification is clicked. If the application
// is already open it will reuse the same activity.
var resultIntent = Application.Context.PackageManager.GetLaunchIntentForPackage(Application.Context.PackageName);
resultIntent.SetAction(intent.Action);
resultIntent.SetFlags(ActivityFlags.ClearTop | ActivityFlags.SingleTop);

var resultPendingIntent = PendingIntent.GetActivity(Application.Context, 0, resultIntent, PendingIntentFlags.UpdateCurrent);
builder.SetContentIntent(resultPendingIntent);

Finally we need to actually show the local notification.

// Show the notification.
var notificationManager = NotificationManagerCompat.From(Application.Context);
notificationManager.Notify(0, builder.Build());

If you have implemented everything successfully you should see a notification and when you click on it should open you application.  We will talk more about how to handle the received notification in your application in a future post.

For a complete example please check out the Example Client in the XPlugins.Notifications plugin.

P.S. – Today’s programming song is about communication.  Make sure you communicate with those important to you.  Also yelling “Say something, I’m giving up on you” at your phone when your notification code is not working is therapeutic.

Posted in Goal App, Today I Learned | Comments Off on Today I Learned How to Create a Local Notification in Xamarin Android

Operation Add Author Profile Pictures (OAAPP)

You may have noticed that our smiling faces now accompany our posts. This is to prevent confusion among our long time readers who may think that Chris is joining the Edmonton Police (he’s not, Liv is) or that Liv has a behemoth garden (she doesn’t, I do). Also, so you can see our smiling faces.

If you are looking to do the same for your blog, you can follow the steps I took.

Step 0 – Research (and know what you’re looking for)

The real issue we were facing was not being able to add a profile picture unless we had Gravatar accounts.  We wanted to use pictures uploaded to our media library.  I researched how to add a profile photo from our media library to our WordPress blog.  I read technical stuff I didn’t really understand.  You might too.  It’s important to note which ones you looked at but won’t work, and why, if that’s important to you.  Note which ones you want to try out.

Step 1 – Try it out and choose your plugin

Try your solution(s) on a Staging server. Find this under WPEngine –> Staging.

staging

Life does not have an undo button, but luckily your blog does.

I originally chose User Photo but after installing the plugin, WordPress alerted me that it was outdated and pointed me to User Profile Picture.  Good thing I tried this all in Staging first.  Once you’re satisfied with the results, bring it into Production.

Step 2 – Back up your blog

Go to WP Engine User Portal and back up.

backup

 

Step 3 – Follow the installation instructions

This may be easier said than done since I really didn’t understand the technical stuff that I read.

instructions
I understood 1. Download the plug-in file, upload the folder to the directory and 2. Activate the plugin (hint: there are buttons that say “Add New” and “Upload Plugin” and “Install Now”).  From there I was admittedly lost.

It said “3. Place code-y stuff in your templates and 4. Use the “Override Avatar” function to change your default avatar.”

Knowing what I know now and having done this once in staging, I would advise reversing the two steps:

3. Use the “Override Avatar” function to change your default avatar and
4. Place code-y stuff in your templates.

This is so we could get our smiling faces in a row, add them to our profiles, and then plug in those proverbial Christmas lights.  It’s your choice.

On your side menu, go to Appearance –> Editor. On the right Templates menu, click on Theme Functions (footnote functions.php)

functions

I scrolled down to the bottom of the code-y part and added

 add_filter( 'mpp_avatar_override', '__return_true' );

so the “Override Avatar” checkbox would be checked by default.  You may not want this, but we did.

4. is still gibberish to me, but after some playing around, and with the help of a code-cracking genius husband/business partner, we deciphered this to mean “make changes to loop.php, which is the code for what to display for each of the blog posts (loop, you get it?)”

We opened loop.php.

On your side menu, go to Appearance –> Editor. On the right Templates menu, click on loop.php)

loop

We played around a bit, not really knowing how to go about this.  Admittedly, Chris is rusty in php land.

We scrolled around on the blog and thought out loud “well, we’d want our smiling faces to be near where it says our usernames. i.e. Posted on by…” We searched for the words “Posted on” and found it was a variable called

twentyten_posted_on()

We put this block/chunk of code before the 3rd instance of it.

<?php
if (function_exists ( 'mt_profile_img' ) ) {
    $author_id=get_the_author_meta( 'ID' );
    mt_profile_img( $author_id, array(
        'size' => array(32,32),
        'attr' => array( 'alt' => 'Author Image' ),
        'echo' => true)
    );
}
?>

We also wanted our faces to be smaller than the default “thumbnail” size, so I learned a bit about php arrays from here and chose 32 pixels by 32 pixels. We also changed the Alternative Text to read “Author Image”. That’s it!

Armed with this, you too can run your own OAAPP.

Save

Save

Save

Save

Save

Save

Save

Save

Save

Save

Save

Save

Save

Save

Posted in Fun | Tagged , | Comments Off on Operation Add Author Profile Pictures (OAAPP)

Riding the Dinosaur: The Joys of Old Technology

Using old technology is a bit like driving a Model T on the Indy Speedway. It can be a bit scary, but most of the time it is incredibly frustrating and everything seems dino1to be zooming past at a mind-boggling rate of speed.

Case in point: I have a version of Photoshop from 2002. It’s a robust program that I know inside out. It can do a lot of things, and when it came out, it was pretty mind-blowing. But, it’s from 2002. That means it is 14 years old. In Computer Years, that is like comparing something from the Jurassic Period to Present Day.

This ancient program is on my ancient laptop, which is also from 2002. I’ve never had cause to replace it, because it still works after all these years. However, it cannot go on the internet. It could 14 years ago, but I feel like if I plugged an ethernet cable into it now, it would probdino2ably burst into flames and then explode. I have a much newer computer – I’m clearly on the internet as I am writing this – but the old one has retained its usefulness because it has Photoshop.

And so, I’ve been doing a lot of artwork for Goal Buddy (and for other things like Migrator) on the Ancient Beast, as it is known. Drawing on it is really hard. Do you remember Scary Sun? Yeah. I can’t unsee it either. That’s what happens when I try drawing with the touchpad mouse. I am still puttering away, trying to draw background things (thank goodness for the “gradient” tool), but then I am constantly switching between sitting on the floor with the laptop to sitting at the desk with the real computer. Plus, I am saving things on USB keys and going back and forth between the one with internet and the one without. If this sounds inefficient, you are right.

It’s why I have resorted to hand-drawing art for the blog posts, and most of dino3the art you’ve seen is drawn with ink and pencil crayon, then scanned. It seems a little preposterous that going back to good ol’ pencil and paper is faster than using a computer program, but that’s what happens when you use old technology! I’m still finding uses for my ancient Photoshop, and until it is no longer useful, I will continue to use it. It’s like driving the Model T. It is slow, but you get there eventually and mostly in one piece.

 

Save

Posted in Fun, Goal App | Comments Off on Riding the Dinosaur: The Joys of Old Technology

Today I Learned Bait and Switch for .NET PCL’s

If you have worked with Xamarin for longer than me (i.e. one year) then you probably already know about PCL bait and switch technique, especially if you consumed one of the many Xamarin plugins.

As usual I’m late to the party.  It’s November 2016 and the first article I found was written May 2014.  There is also a good video about the bait and switch technique for creating Xamarin plugins which I think was recorded in September 2014.  That said, I’m more an Early Adopter or Early Majority than an Innovator.

Diffusion of Innovation

Back to bait and switch.  I’m not a fan of it because of its strict requirements for it to work.  A separate project is required for each environment you want to target.  For example BaitAndSwitch.PCL, BatiAndSwitch.Droid, BaitAndSwitch.iOS, etc.

Separate projects are not the problem.  The problem is each of the separate projects must have the same namespace, version numbers, and assembly names.  You also need to share the common interface file between all the projects.  You can then switch out the DLLs for each different platform.

My problem is this seems hacky.  It gets my smelly code senses tingling.  Maybe my senses shouldn’t be tingling.  The technique is used in most of the existing Xamarin plugins.

For now I won’t use that technique but I reserve the right to change my mind.  I’ve been wrong before, as my wife can tell you.  Who knew you could cook bacon and eggs in a paper bag?

P.S. – My programming music this time is the Okeefe music.  It’s kids playing rock songs, such as Slipknot.  The kids are talented and this video is funny.

 

Save

Save

Save

Save

Save

Save

Posted in Today I Learned | Comments Off on Today I Learned Bait and Switch for .NET PCL’s

When the going gets tough, the tough have a training montage

Unforeseen circumstances.

It isn’t a phrase that makes you jump for joy. Instead, it is a vaguely menacing combination of words that foretells of something throwing your plans off the rails. For me, it was a leg injury. If you have been following this blog series, you’ll know that I have been training to apply to the Edmonton Police Service. Things were falling into place. I had collected all the supporting documents for my application (transcripts, first aid certification and so forth), and was studying hard to write the entrance exams. I was in the best shape of my life, thanks to working with a personal trainer.

Then came the unforeseen circumstances. One frosty September morning, my leg felt peculiar as I sprinted up a set of stairs in the river valley. I ignored it, thinking I should “suck it up, buttercup.” I trained the next day and the day after, and the pain screamed at me until I couldn’t ignore it. By Saturday morning, I couldn’t walk. I knew that something had gone majorly wrong.

I discovered that I’d strained part of my quad in my left leg (the rectus femoris muscle, to be exact) and it might be several months before it was healed. My life flashed before my eyes. I was ready to go in and slay those entrance exams and had hoped to do the physical exam soon thereafter. But now I could hardly walk and had no idea how long it would take to heal. At that moment, it felt like my big plans had crashed and burned like a plane falling out of the sky.

montagetime

Being the logical person that I am, I wallowed in misery for a day or two, and then formulated a plan. TRAINING MONTAGE! Stretching. Physio. Exercise. Rest. Repeat. Preferably set to music.

Flash forward two months and my leg is finally almost at its pre-injury state. It’s been slow going, but I knew that if I pushed it too hard too soon, I would be worse off. The take-home message here is that unforeseen circumstances are inevitable. You don’t have control over them. The only thing you have control over is how you react.

eyeofthetiger

Grey tracksuit optional but recommended.

Save

Posted in Fun, Goal App | Comments Off on When the going gets tough, the tough have a training montage

Today I Learned Xamarin Push Notification Plugins

I learned this week that there is no built-in support for Push Notifications in Xamarin Forms.  On the plus side there are several open source projects trying to fill this hole.  The one that has caught my eye is edsnider/Xamarin.Plugins.

It only supports local notifications but that is all I need right now.  I like it because it looks simple to use.  The only downside is it looks abandoned.  Hopefully I’ll get around to actually trying it this week.

I was also looking at the EgorBo/Toasts.Forms.Plugin.  At first I was confused about the difference between notifications and toasts.  A Toast is a non-modal, unobtrusive window element used to display brief, auto-expiring windows of information to a user.  You can find that quote here.

My guess is that most users would call toasts notifications.  I think I’ll define the notifications as an actual notification (remote or local) that arrives in the application and the toast one of the ways of showing the notification.  In my case I want the notification to show a pre-defined page in the Xamarin Forms application.  I wonder what will be easier, iOS or Android?

P.S. – I also learned that the new DOOM (2016) soundtrack is excellent music to program to.  Best song, in my humble opinion, is Rip and Tear.

Posted in Today I Learned | Tagged , , | Comments Off on Today I Learned Xamarin Push Notification Plugins

Notes on Converting Mini-Compressor to UWP Application (Trying to at Least)

I was inspired to get Mini-Compressor to UWP into the Windows 10 Store a while back this summer. I saw this video several months ago when it was called Project Centennial:

https://channel9.msdn.com/Events/Build/2015/2-692

Then a couple weeks ago there was a form you could fill out and a Microsoft employee would help you convert your application.  So I filled out the form about my tiny little application called Mini-Compressor and was surprised when I heard back.  The fellow was very helpful but in the end we couldn’t get Mini-Compressor ported to UWP.

Spoiler: UWP applications can have custom context menu items but not for *.jpeg files.

So why am I writing this if we failed?  Because I think there is still something to learn from my failure.  Same reason scientist should publish failed experiments.

Also I setup a goal to post something and figured this would do.  So without further ado here are the notes I took.

Doing Research

Read about converting applications and the requirements.  Right away I saw potential show stopper: Shell Extensions are not supported in UWP.  There where a couple other minor issues, like registry entries not allowed in the machine hive, but I could work around those.  The whole point of Mini-Compressor is to right click on a file or folder to compress the images.  Being the optimistic guy I am I think there might be a way around this so I decide to proceed.  With the help of my new Microsoft contact we made good progress.

The next thing I read was setting up the Desktop App Converter program.  It’s actually not too hard, just follow the instructions.  I’ll show you my instructions a little later.

Upgrade to .NET 4.6.2

Before I did anything I updated Mini-Compressor to .NET 4.6.2.  This was actually pretty painless.  I just picked each C# project and upgraded it to .NET 4.6.2.  Everything still compiled, tests passed, and the automated build succeeded.

Remove the Shell Extension Project

The Shell Extension is what allows users to right click a folder or file to compress them.   In Mini-Compressor this is the MiniCompShellExt project and is responsible for adding the Mini-Compressor menu item to the popup menu that appears when you right click on the folder or file.  It’s also responsible for determining the file(s)/folders clicked on and passing them to the actual Mini-Compressor program.

It’s sad to have to remove this because this is the hardest part of Mini-Compressor to write.  At least for me.  I had to learn how Shell Extensions work and remember C++ (hadn’t been used since university).  It was also the key feature of Mini-Compressor.  You could right click on a file or folder and compress them.

A moment of silence for the MiniCompShellEx project.

removeshellextension

Thanks to TortoiseSVN and other Tortoise projects,  I modeled my Shell Extension off these projects.

TortoiseSVN
TortoiseGit
TortoiseHg

Remove Unused Build Configurations

Now that we no longer have the Shell Extension project we can remove some build configurations.  Currently Mini-Compressor has 6 build configurations.
The MiniCompShellExt was a C++ project and needed a separate compile for x86 and x64 operating systems.  Mini-Compressor also has a trail and paid-for builds.

buildconfigurations

Side note: Why the trial and paid for-builds?  The answer is Mini-Compressor didn’t use a key to unlock it after you purchased it.  Instead a trial check was hard coded into the application.  Similar idea to a demo version of a game versus the full release version.
I was not a big fan of keys because people tend to lose them, at least back in the day.  Now that is less of an issue with everyone saving their key to e-mail.

Back on topic, just keep the Debug and Release builds.  No need for the x64 builds and trial builds.  Actually now that I think of it how does Microsoft Store handle demos?  I should check that out.

Update the Installer

I used Advanced Installer to create the installer for Mini-Compressor.  I used Advanced Installer because it let me create a single install for both 32-bit and 64-bit applications.  This is no longer needed.

Actually running the Microsoft Bridge application on the single install exe does not work.  What I really want is a single platform, 64-bit, installer.  To make this happen I made the below changes to my existing project.

Package Type: 64-bit (AMD64, EM64T)

Advanced Installer Change Package Type

Remove 32-bit and Shell Extension files.

Advanced Installer Remove Files

Remove registry entry required for shell extension.

Advanced Installer Remove Registry Entries

Remove trial build.

Advanced Installer Remove Trial Version

Add File Associations. (this actually did nothing but I was hoping it would help)

Advanced Installer Add File Assoications

Remove Stopping the Explorer process and .NET Installer.

Advanced Installer Stop Explorer Process

I am using an old version of Advanced Installer (version 9.9, current version is 13.1) and don’t have a license for the new version.  Maybe in the future I’ll update to the new version so I can build AppX applications directly instead of running the Microsoft Bridge.

Setup the Desktop App Converter

Download the Desktop App Converter and the wim image.  Then open a PowerShell as admin and type the following to setup the image:

PS C:\&amp;amp;amp;gt; Set-ExecutionPolicy bypass

PS C:\&amp;amp;amp;gt; .\DesktopAppConverter.ps1 -Setup -BaseImage .\BaseImage-1XXXX.wim –Verbose

This can take a while and only needs to be done once.

Run the Desktop App Converter

Again in PowerShell run the following command:

PS C:&amp;amp;gt;.\DesktopAppConverter.ps1 
-Installer "&amp;amp;lt;path&amp;amp;gt;\Mini-Compressor-9.9.9.9.exe" 
-InstallerArguments "/qn" 
-Destination "&amp;amp;lt;path&amp;amp;gt;\MiniCompConverted" 
-PackageName "MiniCompressor" 
-Publisher "&amp;amp;lt;Full publisher name on your code signing certificate&amp;amp;gt;" 
-Version 9.9.9.9 
-MakeAppx –Verbose

This command takes the existing installer exe and installs it in the wim image you setup earlier.  The process runs some tests on the install process and also notes what file and other install actions are taken.  It then creates a AppX install file.

convertercreateappx

 

Sign the Appx package.  Do this using the Visual Studio command line and the Saturday MP cert.

PS C:&gt;signtool.exe sign 
-f saturdaymp.pfx 
-p &lt;password&gt;
-fd SHA256 
–v MiniCompressor.appx

If you don’t have a code signing certificate then you can create your own certificate.

Now you can double click your AppX application on a Windows 10 machine and it will get installed.  Notice it didn’t include any of the nice images I had in my old installer.

Install AppX Mini-Compressor

No Right Click

I encountered some small issues following the above steps but overall it was relatively painless.  Unfortunately when I was done I couldn’t right click on anything using Mini-Compressor.  I could run the application from the Start menu but no right click.  That said I kind of knew this would happen based on my initial research.

I talked to the helpful fellow at Microsoft and he said there is a way to add shell extensions in AppX applications.  You need to add the following to your AppX manifest file:

<Extensions>
  <uap3:Extension Category="windows.fileTypeAssociation">
    <uap3:FileTypeAssociation Name="imagefiles">
      <uap:DisplayName>Image Files</uap:DisplayName>
      <uap:SupportedFileTypes>
        <uap:FileType>.jpg</uap:FileType>
        <uap:FileType>.jpeg</uap:FileType>
        <uap:FileType>.blah</uap:FileType>
      </uap:SupportedFileTypes>
      <uap2:SupportedVerbs>
        <uap3:Verb Id="Compress" MultiSelectModel="Player" Parameters="&quot;%1&quot;">Compress</uap3:Verb>
        <uap3:Verb Id="CompressExtended" MultiSelectModel="Player" Extended="true" Parameters="&quot;%1&quot;">Compress Extended</uap3:Verb>
      </uap2:SupportedVerbs>
    </uap3:FileTypeAssociation>
  </uap3:Extension>
</Extensions>

Note that after updating the manifest file I needed to re-create the Appx file.  I did this by running the following command:

makeappx.exe pack -d PackageFiles -p Output

Notice that I added the jpg, jpeg, and blah types.  At first I added just the jpg/jpeg types but that did not seem to work.  When I added the blah type I could right click on blah files.

Turns out certain file types are reserved and can’t be used.  Of course the jpg/jpeg file types can’t be used.  That made me sad.  Maybe in the future if Microsoft makes the jpg/jpeg not reserved then maybe I’ll try upgrading Mini-Compressor again.

So that is the end of my long journey.  While it didn’t end the way I wanted it to, I did learn some things and wanted to share them with you.  That, and as I said at the beginning, I think it’s important to share successful as well as failed experiments.

Save

Save

Save

Posted in Business Side, Mini-Compressor, Notes, Software Development | Tagged , , , , , , | Comments Off on Notes on Converting Mini-Compressor to UWP Application (Trying to at Least)

Math is hard.

Math.

Few people tell me that they love math.

It brings back memories of sitting in a small, windowless room, back in grade 11, with my math tutor. My tutor smoked cigars. Lots of cigars. He smelled like a giant cigar. I really didn’t want to be there, but my math grades were abysmal. I tried – superficially, at best – to memorize the patterns of algebra, but desire to receive a non-abysmal grade in that class was overshadowed by a large teenage helping of “not giving a …”

I did pass (somehow), and went on to become a decent statistician in university. The beauty of stats, though, is that you rarely do the computations by hand. You just need to know what kind of analysis need be done on a dataset, plug it into a computer program, and voila. I was so used to doing those analyses that I started to think I was good at math.

math1

Wrong. When a computer does all the analyses for you, it doesn’t mean squat.

I have reached a point in my grander goal that I do not like. Inevitably, there are parts of a goal that you really loathe. For some, it might be getting up early or changing your eating habits. For me, it’s re-learning how to do math by hand. Math is part of the written entrance exams for nearly all police services, EPS included. Yours truly could not do long division to save her life.

math2

Math is worth a significant portion of the exam. I sat down one afternoon, flipped open the study manual, and started math-ing. Ok, first you see how many times the first number goes into…no, wait, what do I do with this decimal…wait, I think you move it over here… no. System failure. Stupid math. I decided to ignore it completely. However, things you ignore have a nasty way of following you around and permeating everything you do. Math was always there, like a malevolent dog that followed me home.

Ignoring it wasn’t making it go away.

There was only one thing left to do. Just study. No way around it. As loathsome a task as math is, refusing to acknowledge its existence is futile. Every goal has nasty bits. In the wise words of Yoda: “Do or do not. There is no try.” Even with math.

 

Posted in Fun, Goal App | Comments Off on Math is hard.