Software Architect at Genzeon Corporation in Malvern, Pennsylvania, Microsoft .NET MVP, Husband, Dad and Geek.
23801 stories
·
21 followers

Alexa Blueprints Makes You A Code Free Skills Creator

1 Share

This past week Amazon made available a new tool called Alexa Blueprints. This web based site enables you to create your own skills for Alexa without any coding skills. If you can follow a wizard based interface and straight forward instructions then you can build your own unique skills for Alexa. First you must have...

The post Alexa Blueprints Makes You A Code Free Skills Creator appeared first on WindowsObserver.com.

Read the whole story
alvinashcraft
8 hours ago
reply
West Grove, PA
Share this story
Delete

MVX=0 WPF/Mac: A first MvvmCross Application (MVX+1 days of MvvmCross)

1 Share

Further to some feedback on the first couple of posts in the MVX+1 series (MVX=0, MVX=0F and MVX=1), I’ve gone back and added WPF and Mac support to the FirstDemo to show just how powerful MvvmCross is. I’ll cover very briefly here how to add these project types and then I’ll be updating the TipCalc post to include the basics for WPF and Mac setup in there too.

Let’s start with WPF:

  1. Add a WPF App (.NET Framework) called FirstDemo.Wpf
    image
  2. Add a reference to MvvmCross NuGet package
  3. Add reference to FirstDemo.Core project
  4. Add ProxyMvxApplication to App.xaml.cs
    public abstract class ProxyMvxApplication : MvxApplication<MvxWpfSetup<Core.App>, Core.App> { }
  5. Update App class in both App.xaml and App.xaml.cs to inherit from ProxyMvxApplication
  6. Remove all code in the App class (in App.xaml.cs) except for the constructor with call to InitializeComponent
    public App()
    {
         InitializeComponent();
    }
  7. Update MainWindow in both MainWindow.xaml and MainWindow.xaml.cs to inherit from MvxWindow
  8. Create Views folder
  9. Add new User Control (WPF) called FirstView.xaml
  10. Update FirstView in both FirstView.xaml and FirstView.xaml.cs to inherit from MvxWpfView
  11. Add XAML to FirstView.xaml
    <StackPanel Margin="12,12,12,12">
         <TextBox Text="{Binding FirstName, Mode=TwoWay}"></TextBox>
         <TextBox Text="{Binding LastName, Mode=TwoWay}"></TextBox>
         <TextBlock Text="{Binding FullName}"></TextBlock>
    </StackPanel>

You should now be able to build and run the WPF application – notice how little code we have to add/change in order to get MvvmCross to work!

Next up is Mac which at the moment can only be done on a Mac (almost no surprises there – it’s the same as not being able to do UWP development on a Mac I guess):

  1. Add a Cocoa App called FirstDemo.Mac
    image
  2. Add a reference to MvvmCross NuGet package
  3. Add reference to FirstDemo.Core project
  4. At this point I would recommend unloading your project, editing the csproj file manually to removed the legacy nuget reference and add the following ItemGroup. Also remove the reference to package.config, remove the actual package.config file and delete both bin and obj folders. Reload the Mac project and force a rebuild.
    <ItemGroup>
       <PackageReference Include="MvvmCross" Version="6.0.0" />
    </ItemGroup>
  5. Update AppDelegate to inherit from MvxApplicationDelegate
    [Register("AppDelegate")]
    public class AppDelegate: MvxApplicationDelegate<MvxMacSetup<App>, App>
    {
         public override void DidFinishLaunching(NSNotification notification)
         {
             MvxMacSetupSingleton.EnsureSingletonAvailable(this, MainWindow).EnsureInitialized();
             RunAppStart();
            // Due to a bug, do not call base DidFinishLaunching
             //base.DidFinishLaunching(notification);
         }
    }
    Note: There is a bug at the moment where if you don’t override DidFinishLaunching the application will crash on startup
  6. Open main.storyboard – this should open the storyboard in the XCode designer
  7. Select the existing view controller and set the Class and Storyboard ID to FirstView
    image
  8. Make sure the FirstView name change has been saved; return to VS for Mac and confirm that files FirstView.cs and FirstView.designer.cs have been created. If these have not been created, I would suggest doing a rebuild of your project to make sure the changes to the storyboard have been processed and the appropriate designer files created.
  9. From the Object Library drag two TextField and a Label across onto the design surface
    image
  10. Open Project navigator and make sure you have FirstView.h and FirstView.m. If you don’t I would suggest closing both XCode and VS for Mac, deleting the bin and obj folder from within the FirstDemo.Mac folder and reopening the solution in VS for Mac. Rebuild the Mac project and then launch XCode by double clicking on main.storyboard.
    image
  11. Hide both Project navigator (left pane) and Utilities (right pane) and show the Assistant Editor (the icon button that has linked circles in top right corner of XCode)
  12. From the navigator bar in the Assistant Editor, select Manual –> FirstView.Mac –> FirstView.h
    image
  13. Right-click on the first TextField
    image
  14. Click and drag the circle next to New Referencing Outlet across onto the FirstView.h immediately before the @End. When you release, you should be prompted to complete information about the new Outlet where you can specify the Name, textEditFirst, which will be the name of the backing variable you’ll be able to use to reference the TextField in code
    image
  15. Repeat the previous step for the second TextField, textEditSecond, and the Label, labelFull.
  16. Update FirstView.cs to add the MvxFromStoryboard attribute, change the base class to MvxViewController and add data binding using the CreateBindingSet extension
    [MvxFromStoryboard("Main")]
    public partial class FirstView : MvxViewController<FirstViewModel>
    {
         public FirstView(IntPtr handle) : base(handle)
         {
         }
  17.     public override void ViewDidLoad()
         {
             base.ViewDidLoad();
             var set = this.CreateBindingSet<FirstView, FirstViewModel>();
             set.Bind(textEditFirst).To(vm => vm.FirstName);
             set.Bind(textEditSecond).To(vm => vm.LastName);
             set.Bind(labelFull).To(vm => vm.FullName);
             set.Apply();
         }
    }

And there you have it – build and run your Mac FirstDemo application

    Read the whole story
    alvinashcraft
    8 hours ago
    reply
    West Grove, PA
    Share this story
    Delete

    Making an AWS static website EVEN MORE secure

    1 Share

    OK, so we have a secure website, hosted on Amazon S3, and served up via HTTPS by CloudFront with an Amazon SSL Certificate. But, as we know from last time, we also have to express this security through our response headers. It was fairly easy with Azure – after all, it’s “just” IIS back there, and web.config is the answer to everything once you know the magic incantations – but how to do the same thing on AWS?

    For this one, I am indebted to an official Amazon blog post: Adding HTTP Security Headers Using Lambda@Edge and Amazon CloudFront. It’s only 4 months old as well, so this is cutting edge stuff. And, I’d have to say, it’s wacky; it took me several goes to get it right.

    First though, please go read or at least skim through that post. It explains what’s going to happen pretty thoroughly and why.

    Create a Lambda function

    Quoting Amazon’s blurb, AWS Lambda lets you run code in the cloud without provisioning or managing servers. Just write it and upload it to Lambda. Sounds OK, and is a whole new kettle of fish, but here we’re just going to use Lambda@Edge. This is a way to run some code every time a trigger is fired from CloudFront. At the edge of the cloud, in other words. The number of triggers is few and we’ll only be interested in one of them: the trigger that fires when CloudFront gets a response packet from the S3 hosting. In essence, what’s going to happen is that a browser asks for our page, CloudFront asks the hosting for the file, the file returns to CloudFront ready to be passed onto the viewer when, boom, the trigger is fired.

    Let’s follow that walkthrough. We go to the Lambda dashboard and click on Create function. As it says, we’re going to Author from scratch. Name the new function (I chose addSecurityHeadersToWITJ). Leave the Runtime option alone. For the Role we’re going to Create new role from Template(s). Name it, and then with the Policy templates dropdown, choose Basic Edge Lambda permissions. Then click the Create function button.

    Write the code

    We now have what seems to me to be a confusing screen. The initial panel is Designer. Just ignore that for now, and instead scroll down to the Function code panel, where there’s a code editor. Replace the code in that index.js file with this:

    'use strict';
    exports.handler = (event, context, callback) => {
        
        //Get contents of response
        const response = event.Records[0].cf.response;
        const headers = response.headers;
    
        //Set new headers 
        headers['strict-transport-security'] = [{key: 'Strict-Transport-Security', value: 'max-age=31536000; includeSubdomains; preload'}]; 
        headers['content-security-policy'] = [{key: 'Content-Security-Policy', value: "default-src 'none'; img-src 'self'; script-src 'self'; style-src 'self'; font-src 'self'; object-src 'none'"}]; 
        headers['x-content-type-options'] = [{key: 'X-Content-Type-Options', value: 'nosniff'}]; 
        headers['x-frame-options'] = [{key: 'X-Frame-Options', value: 'DENY'}]; 
        headers['x-xss-protection'] = [{key: 'X-XSS-Protection', value: '1; mode=block'}]; 
        headers['referrer-policy'] = [{key: 'Referrer-Policy', value: 'same-origin'}]; 
        
        //Return modified response
        callback(null, response);
    };

    As the code indicates, all it does is to retrieve the current response headers, adds the new security-based ones, and then returns the updated response (through a callback). The headers should be familiar from last time, or from the blurb on the securityheaders.com site.

    Click the Save button in the top right.

    Add the trigger

    Now it gets complicated. Well, more weird than complicated. Although we have saved the code, before we can add the trigger, we actually have to publish the new function first, select the new version, and then add the trigger.

    So, from the Actions dropdown at the top of the window, select Publish new version. Give it a description (“First version” perhaps), then hit Publish.

    Now we can add the trigger. Click on CloudFront in the Add triggers list on the left. The panel underneath changes to Configure triggers. Select your new Distribution from the dropdown, leave the Cache behavior as ‘*’. Set the CloudFront event to Origin response. Check the Enable trigger and replicate box, like it asks you to. Finally click the Add button.

    OK, that’s added the trigger, but now you have to save the whole function configuration, so click Save in the upper right.

    Wait, wait, and wait some more

    Now that we’ve created the function, added the code and the trigger, and pushed it onto our CloudFront distribution, we have to wait for it to be deployed. Go back to your CloudFront dashboard and wait for the deployment-in-progress animation to finish. A good half hour, as I said last time, so you’re just hoping you got everything right first time. (Hint: I didn’t and it was a right royal pain in the **** to fix it all.)

    It doesn’t work!

    And then you go to securityheaders.com and your domain is scored as an F. Wut? All that work and palaver and waiting, and the security headers are not coming through? What went wrong?

    The answer, as I alluded to way back in the first part of this blog series, is that one of CloudFront’s jobs is caching. In essence, CloudFront is not only caching the content but the headers as well. The default that we selected when creating the distribution was Use Origin Cache Headers. But we never set up our S3 bucket to serve up these headers, so CloudFront gets the files the first time they’re requested and then stores them in (and serves them from) its cache. Response headers and all. Forevermore.

    What we have to do is invalidate CloudFront’s cache. Go to your CloudFront Distributions dashboard, select your distribution. One of the tabs on the resulting page is Invalidations. Select it.

    Click Create Invalidation. The window that’s shown allows you to specify the Object Paths to invalidate. Me, the first time I tried this, entered /*.* to mean “invalidate everything”. You know, because I’m a DOS/Windows guy. Bzzzt, thanks for playing. It took me a couple of goes (and lots of wasted time) before I realized that it should just be /* with nothing else.

    Click on Invalidate and wait. Once it’s done, your site should serve up the security headers just fine and you get an A+ from the security headers testing site.

    (Aside: Of course you should invalidate the CloudFront cache every time you make a change to the static site otherwise you won’t see your changes in the browser. Another tip I learned through trial and error.)

    Locks on Bridge - banner

    Read the whole story
    alvinashcraft
    8 hours ago
    reply
    West Grove, PA
    Share this story
    Delete

    Xamarin.Forms Application For A ScrollView Multiple Circles Image

    1 Share
    This article demonstrates how to create a Xamarin application for a ScrollView Multiple Circle Image. Xamarin is a platform that allows us to create a multi-platform mobile application for platforms, like Android, Windows, and IOS through a single integrated development environment (IDE).
    Read the whole story
    alvinashcraft
    10 hours ago
    reply
    West Grove, PA
    Share this story
    Delete

    Episode 225 - Azure CXP

    1 Share

     

    We talk to Jeremy Hollett, a Principal Service Engineering Manager, about the CXP organization and how it helps both Azure internally as well its customers, gain the ultimate in reliability. Evan also works for the same organization so the two of them share some good insights.

    Media file: https://azpodcast.blob.core.windows.net/episodes/Episode225.mp3

     

    Other updates:

    We have added Azure Databricks notebook activity in Azure Data Factory. You can now operationalize your Databricks notebooks in Data Factory.  

    From <https://azure.microsoft.com/en-us/updates/support-for-operationalizing-azure-databricks-notebook/>

     

    Azure Stream Analytics customers can now easily build solutions for scenarios such as connected cars, fleet management, and mobile asset tracking.
    Developers can use built-in geospatial functions in their stream-processing logic to define geographical areas. Developers can evaluate incoming geospatial data for containment, proximity, and overlap, and then generate alerts or start necessary workflows.
    These geospatial capabilities are in alignment with the GeoJSON specification.

    https://azure.microsoft.com/en-us/updates/native-support-for-geospatial-functions

     

    With Azure Stream Analytics, customers can combine the power of JavaScript with the simplicity and pervasiveness of SQL.
    Historically, Stream Analytics let developers express their real-time query logic by using a simple SQL-like language. To support more expressive custom code and help customers implement advanced scenarios, Stream Analytics now supports user-defined functions (UDFs) via JavaScript. With this feature, customers can write their custom code in JavaScript, and easily invoke it as part of their real-time stream processing query.

    https://azure.microsoft.com/en-us/updates/javascript-udf-in-azure-stream-analytics/


    The public preview of Azure Stream Analytics tools for Visual Studio includes support for local testing on client machines.

     

    Announcing HTTP/2 support in Azure App Service
    https://blogs.msdn.microsoft.com/appserviceteam/2018/04/13/announcing-http2-support-in-azure-app-service

    Azure Sphere https://azure.microsoft.com/en-us/blog/introducing-microsoft-azure-sphere-secure-and-power-the-intelligent-edge/

    Altair democratizes access to computer-aided engineering with Azure
    https://azure.microsoft.com/en-us/blog/altair-democratizes-access-to-computer-aided-engineering-with-azure/

     





    Download audio: http://feedproxy.google.com/~r/TheAzurePodcast/~5/pVJPPs7fv7Y/Episode225.mp3
    Read the whole story
    alvinashcraft
    10 hours ago
    reply
    West Grove, PA
    Share this story
    Delete

    Connecting Your Azure Bots with QnA Maker Services

    1 Share
    Azure Bot Service is the Bot-Service powered by the Microsoft Bot Framework and Microsoft Azure. It enables rapid intelligent bot development. Azure Bot Service provides an end-to-end integrated environment for setting up backend services bot development. You can develop a bot, deploy it, connect it to different channels, test it in inbuilt web chat emulator, and modify the… Read More »
    Read the whole story
    alvinashcraft
    15 hours ago
    reply
    West Grove, PA
    Share this story
    Delete
    Next Page of Stories