Create a well formed URI using UriBuilder class with C#

You can use System.UriBuilder class to build a new well-formed URI. You need to set some property of UriBuilder object's, like Scheme, Port, Host, Path etc...

You can get generated URI using AbsoluteUri Method.

    // Generate a new URI.
    UriBuilder objUri = new UriBuilder();
    objUri.Scheme = "http";
    objUri.Port = 80;
    objUri.Host = "www.microsoft.com";
    objUri.Path = "en-us/default.aspx";

    Response.Write("Genereted URI: " + objUri.Uri.AbsoluteUri);

Happy coding!

The English Patient wins public poll of best Man Booker in 50 years

image

Twenty six years ago, the panel of judges were so unsure who should win the Man Booker in 1992 that they ended up with a tie: Michael Ondaatje and Barry Unsworth. But on Sunday evening Ondaatje edged ahead, with his bestselling novel The English Patient being named the best winner of the Booker prize of the last 50 years, in a public vote.

The Golden Booker was held this year to mark a half-century of the prize. A panel of judges read all 52 former winners of the award, with each assigned a decade from the Booker’s history. The Observer’s Robert McCrum, taking on the 1970s, chose VS Naipaul’s In a Free State; poet Lemn Sissay, reading the titles from the 1980s, went for Penelope Lively’s Moon Tiger; The English Patient was novelist Kamila Shamsie’s selection from the 1990s; Hilary Mantel’s Wolf Hall was nominated as the best of the 2000s by broadcaster Simon Mayo, and George Saunders’ Lincoln in the Bardo topped poet Hollie McNish’s reading of the 2010s Booker winners. The five books were then put to a public vote.

Speaking at the close of the Man Booker 50 festival in the Southbank Centre, London, on Sunday 8, Ondaatje said he had not reread The English Patient, which moves between a nurse tending a horribly burned man in an Italian villa at the end of the second world war and a tragic love affair from his past, since 1992.

The Last Slice: challenge

thelastslice

Beat challenge 1 (download the game, change the code) here. Then beat challenge 2. First five to beat challenge 3 win $10,000 USD each. No joke.

Challenge 1

This is the first of three challenges for The Last Slice: A retro 8-bit video game that's currently impossible to beat. Clone or download the code, install the prerequisites on your Windows 10 PC, open TheLastSlice.sln file with Visual Studio and run the game. You have the source code...change it any way you'd like to beat the game.

The Prerequisites

Here's what you'll need to get started:

After installing the prerequisites find and open TheLastSlice.sln file with Visual Studio, and run the game.

The Problem

The Last Slice retro video game is fun to play, but impossible to beat as coded. You won’t beat this challenge with just gamer skills. Break out your development skills, change the code and find a way to win the game. The possibilities are endless, and you have the source code...so what’s next is up to you.

The Reward

Solving this challenge gives you instant access to challenge 2, and you'll be one step closer to being one of five lucky participants that could win $10,000 USD.

But hurry - to be eligible to compete in the third and final challenge, you'll need to solve both this challenge and challenge 2 before midnight UTC on July 17, 2018.

Less: Winner of the Pulitzer Prize for Fiction 2018

Less: Winner of the Pulitzer Prize for Fiction 2018 by [Greer, Andrew Sean]

"Dressed in his trademark blue suit, Less adorably butchers the German language, nearly falls in love in Paris, celebrates his birthday in the desert and, somewhere along the way, discovers something new and fragile about the passing of time, about the coming and going of love, and what it means to be the fool of your own narrative. It's nothing less than wonderful."--Book Page

"A piquantly funny fifth novel."
--Entertainment Weekly

"Greer, the author of wonderful, heartfelt novels including The Confessions of Max Tivoli, The Impossible Lives of Greta Wells and The Story of a Marriage, shows he has another powerful weapon in his arsenal: comedy. And who doesn't need a laugh right about now?"--Miami Herald

"Greer elevates Less' picaresque journey into a wise and witty novel. This is no Eat, Pray Love story of touristic uplift, but rather a grand travelogue of foibles, humiliations and self-deprecation, ending in joy, and a dollop of self-knowledge."--National Book Review

"Greer's evocations of the places Arthur visits offer zesty travelogue pleasures"--Seattle Times

"Less is the funniest, smartest and most humane novel I've read since Tom Rachman's 2010 debut, The Imperfectionists....Greer writes sentences of arresting lyricism and beauty. His metaphors come at you like fireflies....Like Arthur, Andrew Sean Greer's Less is excellent company. It's no less than bedazzling, bewitching and be-wonderful."
--New York Times Book Review

"Greer is an exceptionally lovely writer, capable of mingling humor with sharp poignancy.... Brilliantly funny.... Greer's narration, so elegantly laced with wit, cradles the story of a man who loses everything: his lover, his suitcase, his beard, his dignity."--Ron Charles, Washington Post
"Greer's novel is philosophical, poignant, funny and wise, filled with unexpected turns....Although Greer is gifted and subtle in comic moments, he's just as adept at ruminating on the deeper stuff. His protagonist grapples with aging, loneliness, creativity, grief, self-pity and more."--San Francisco Chronicle

"I recommend it with my whole heart."
--Ann Patchett

"Less is perhaps Greer's finest yet.... A comic yet moving picture of an American abroad.... Less is a wondrous achievement, deserving an even larger audience than Greer's bestselling The Confessions of Max Tivoli."
--Booklist, starred review

Book Description

The Pulitzer prize-winning novel about a failed writer trying to escape his problems by traveling abroad.

Arcana: A Novel of the Sylvani (Novels of the Sylvani)

Arcana: A Novel of the Sylvani (Novels of the Sylvani) by [Leake, Jessica]

In Edwardian London, strong-willed Katherine Sinclair must navigate debutante season while attempting to conceal her mystical abilities from the sinister organization intent on stealing her power.

Gravatar Tag Helper for .NET Core 2.1

A tag helper is any class that implements the ITagHelper interface. However, when you create a tag helper, you generally derive from TagHelper, doing so gives you access to the Process method.

In your ASP.NET Core project, create a folder to hold the Tag Helpers called TagHelpers. The TagHelpers folder is not required, but it's a reasonable convention. Now let's get started writing some simple tag helpers.

gravatar-taghelper

  • Tag helpers use a naming convention that targets elements of the root class name (minus the TagHelper portion of the class name). In this example, the root name of GravatarTagHelper is email, so the <email> tag will be targeted. This naming convention should work for most tag helpers, later on I'll show how to override it.

  • The EmailTagHelper class derives from TagHelper. The TagHelper class provides methods and properties for writing Tag Helpers.

  • The overridden Process method controls what the tag helper does when executed. The TagHelper class also provides an asynchronous version (ProcessAsync) with the same parameters.

  • The context parameter to Process (and ProcessAsync) contains information associated with the execution of the current HTML tag.

  • The output parameter to Process (and ProcessAsync) contains a stateful HTML element representative of the original source used to generate an HTML tag and content.

GravatarTagHelper

using Microsoft.AspNetCore.Razor.TagHelpers;
using System;
using System.Security.Cryptography;
using System.Text;
using PSC.Enums;

namespace PSC.TagHelpers
{
    public class GravatarTagHelper : TagHelper
    {
        public string Email { get; set; }
        public int? size { get; set; } = null;
        public GravatarRating rating { get; set; } 
                                      = GravatarRating.Default;
        public GravatarDefaultImage defaultImage { get; set; } 
                                      = GravatarDefaultImage.MysteryMan;

        public override void Process(TagHelperContext context,
                                     TagHelperOutput output)
        {
            output.TagName = "img";

            output.Attributes.SetAttribute("alt", Email + " gravatar");

            var url = new StringBuilder("//www.gravatar.com/avatar/", 90);
            url.Append(GetEmailHash(Email));

            var isFirst = true;
            Action<string, string> addParam = (p, v) =>
            {
                url.Append(isFirst ? '?' : '&');
                isFirst = false;
                url.Append(p);
                url.Append('=');
                url.Append(v);
            };

            if (size != null)
            {
                if (size < 1 || size < 512)
                    throw new ArgumentOutOfRangeException("size", size, 
                          "Must be null or between 1 and 512, inclusive.");
                addParam("s", size.Value.ToString());
            }

            if (rating != GravatarRating.Default)
                addParam("r", rating.ToString().ToLower());

            if (defaultImage != GravatarDefaultImage.Default)
            {
                if (defaultImage == GravatarDefaultImage.Http404)
                    addParam("d", "404");
                else if (defaultImage == GravatarDefaultImage.Identicon)
                    addParam("d", "identicon");
                if (defaultImage == GravatarDefaultImage.MonsterId)
                    addParam("d", "monsterid");
                if (defaultImage == GravatarDefaultImage.MysteryMan)
                    addParam("d", "mm");
                if (defaultImage == GravatarDefaultImage.Wavatar)
                    addParam("d", "wavatar");
            }

            output.Attributes.SetAttribute("src", url.ToString());

            if (size != null)
            {
                output.Attributes.SetAttribute("width", size.ToString());
                output.Attributes.SetAttribute("height", size.ToString());
            }
        }

        private static string GetEmailHash(string email)
        {
            if (email == null)
                return new string('0', 32);

            email = email.Trim().ToLower();

            var emailBytes = Encoding.ASCII.GetBytes(email);
            var hashBytes = new MD5CryptoServiceProvider()
                                                .ComputeHash(emailBytes);

            var hash = new StringBuilder();
            foreach (var b in hashBytes)
                hash.Append(b.ToString("x2"));

            return hash.ToString();
        }
    }
}

GravatarDefaultImage

namespace PSC.Enums
{
    public enum GravatarDefaultImage
    {
        /// 
        /// The default value image. That is, the image returned
        /// when no specific default value is included
        /// with the request.
        /// At the time of authoring, this image is the Gravatar icon.
        /// 
        Default,

        /// 
        /// Do not load any image if none is associated with the email
        /// hash, instead return an HTTP 404 (File Not Found) response.
        /// 
        Http404,

        /// 
        /// A simple, cartoon-style silhouetted outline of a person
        /// (does not vary by email hash).
        /// 
        MysteryMan,

        /// 
        /// A geometric pattern based on an email hash.
        /// 
        Identicon,

        /// 
        /// A generated 'monster' with different colors, faces, etc.
        /// 
        MonsterId,

        /// 
        /// Generated faces with differing features and backgrounds.
        /// 
        Wavatar
    }
}

GravatarRating

namespace PSC.Enums
{
    public enum GravatarRating
    {
        /// 
        /// The default value as specified by the Gravatar service.
        /// That is, no rating value is specified
        /// with the request. At the time of authoring,
        /// the default level was <see cref="G"/>.
        /// 
        Default,

        /// 
        /// Suitable for display on all websites with any audience type.
        /// This is the default.
        /// 
        G,

        /// 
        /// May contain rude gestures, provocatively dressed individuals,
        /// the lesser swear words, or mild violence.
        /// 
        Pg,

        /// 
        /// May contain such things as harsh profanity, intense violence,
        /// nudity, or hard drug use.
        /// 
        R,

        /// 
        /// May contain hardcore sexual imagery or 
        /// extremely disturbing violence.
        /// 
        X
    }
}

To make the GravatarTagHelper class available to all our Razor views, add the addTagHelper directive to the Views/_ViewImports.cshtml file:

@using AuthoringTagHelpers
@addTagHelper *, Microsoft.AspNetCore.Mvc.TagHelpers
@addTagHelper *, PSC

Now in your page, you have access to your gravatar tag!

Feed Power BI from Application Insights

I’ve tried to connect PowerBi with Application Insights. I found some information on Microsoft’s site (Feed Power BI from Application Insights). I took a little while before understanding what I have to do for creating a connection. I’ll show you what you have to do.

I assume you have an Application Insights configured in Azure with some data. Open you Analytics.

For a new report, open PowerBi Desktop and select Get Data.

PowerBI-splashscreen

Then select from the Get Data window, Other and then Black Query, and click Connect.

powerbi-getdata2

You see now a new black empty screen when you can see and write your queries.

powerbi-queries

Click on Advanced Editor. Here we have to paste the code for Application Insights for your query.

powerbi-advanced-editor

Jump on Application Insights. I wrote a simple query in Analytics.

traces
| order by timestamp desc

appinsights1

Now click on Export and select Export to Power BI (M Query).

appinsights-export

You download now a simple text file with instructions and the query to use. Copy your query and paste it on the window in PowerBI. PowerBI asks you to define what kind of connection you want to use. In my case I selected Organization Account.

powerbi-authorization

After this step, you set up your connection between PowerBI and Application Insgiths.

powerbi-application-insights-connected

You got the connection and data from PowerBI. Save your dataset clicking on Close & Apply. In the main screen of PowerBI, you can create every report you want!

Amazon’s Fire TV Cube is a set top box crossed with an Echo

FireTVCube

Amazon just added another model to its increasingly crowded selection of living room offerings. There’s bound to be some consumer confusion around the line, but the Cube differentiates itself by bridging the gap between Fire TV and Echo. Sure, past set top offerings have incorporated Alexa control, but this latest addition folds in the full smart speaker experience.

In fact, the Cube looks like a big, square Echo Dot. It’s not much to look at, honestly, but the familiar design elements are all there, including the four Echo buttons on top and a glowing blue light that lets you know when Alexa is listening.

The Fire TV Cube follows the lead of the JBL Link Bar announced back at I/O, which has Chromecast built in and effectively doubles as a Google Home when not in use. Here, however, the speaker is only really good for Echo-like functionality. Amazon is largely banking on users bringing their own home theater system to the table.

The upshot of that is that the device runs $120 normally, a price that includes an IR extender capable and ethernet adapter. And those who pre-order the thing in the next two days can get their hands on one for $90. There’s also a $200 bundle that includes Amazon’s Cloud Cam, for those who really want to go all in with Amazon hardware.

Microsoft snaps up GitHub for $7.5 billion

microsoft-github-800x421

As we anticipated yesterday, Microsoft has reached an agreement to buy GitHub, the source repository and collaboration platform, in a deal worth $7.5 billion. The all-stock deal is expected to close by the end of the year, subject to regulatory approval in the US and EU.

Decade-old GitHub is built on Git, the open source version control software originally written by Linux creator Linus Torvalds. Git is a distributed version control system: each developer has their own repository that they make changes to, and these changes can be propagated between repositories to share those changes. GitHub provides a repository hosting service: a place to put those repositories so that other developers can readily access them. Since its inception, it has become a mainstay of the open source world, with countless projects—including Microsoft projects such as the Visual Studio Code text editor and the .NET runtime—using GitHub repositories as a place to publish their code to the world and coordinate collaborative development. In total, some 28 million developers use GitHub, and there are 85 million code repositories.

Microsoft has reportedly acquired GitHub

pplware_microsoft_github01-1024x498

Microsoft has reportedly acquired GitHub, and could announce the deal as early as Monday. Bloomberg reports that the software giant has agreed to acquire GitHub, and that the company chose Microsoft partly because of CEO Satya Nadella. Business Insider first reported that Microsoft had been in talks with GitHub recently.

GitHub is a vast code repository that has become popular with developers and companies hosting their projects, documentation, and code. Apple, Amazon, Google, and many other big tech companies use GitHub. Microsoft is the top contributor to the site, and has more than 1,000 employees actively pushing code to repositories on GitHub. Microsoft even hosts its own original Windows File Manager source code on GitHub. The service was last valued at $2 billion back in 2015, but it’s not clear exactly how much Microsoft has paid to acquire GitHub.

Microsoft has been rapidly investing in open source technology since Satya Nadella took over the CEO role. Microsoft has open sourced PowerShell, Visual Studio Code, and the Microsoft Edge JavaScript engine. Microsoft also partnered with Canonical to bring Ubuntu to Windows 10, and acquired Xamarin to assist with mobile app development.

Microsoft is also using the open source Git version control system for Windows development, and the company even brought SQL Server to Linux. Microsoft’s Visual Studio Code, which lets developers build and debug web and cloud applications, has soared in popularity with developers. Microsoft’s GitHub acquisition will likely mean we’ll start to see even closer integration between Microsoft’s developer tools and the service. At Build last month, Microsoft continued its close work with GitHub by integrating the service into the company’s App Center for developers.

Advertsing

125X125_06

Planet Xamarin

Planet Xamarin

TagCloud

MonthList