Enable Developer Options on Samsung Galaxy S9

The Developer Options has many useful features that certainly elevate the usability, and user experience of an Android phone. In this tutorial, we are going to learn how to activate/enable Developer Options on Samsung Galaxy S9, and how to use it effectively. All Samsung smartphones come with an option, but it usually it comes hidden within the operating system. But it doesn’t mean that you can’t access it. And importantly, that is not a tough task either. The method is almost same as we perform on other Samsung’s smartphones.

  1. Open the app menu, and then tap on Settings.
  2. Scroll to locate ‘Device information‘ and tap on it.
  3. Next, locate the ‘Software info‘ and tap on it.
  4. Under the hood of this menu, find the ‘Build number‘.
  5. Now tap 7 times on ‘Build number’. Each time you tap on ‘Build number’, it displays a screen with a message about remaining taps to become a developer.
  6. This will activate the Developer Options on your phone:galaxy-s9-developer-options

Now, the Developer Options will appear under Settings.

How to Automatically Backup Your Web Server Files With WinSCP over FTP

WinSCPYou’ve heard it time and time again: back up your data. There are plenty of backup solutions, but nothing is better than an easy and free solution. So with a few lines of code and a very helpful program called WinSCP, we’re going to set up an automatic sync between your FTP server and your home computer.

Requirements

  • An FTP server and access credentials
  • A Windows computer
  • A copy of WinSCP (Windows only)

Setting Up WinSCP

Once you've downloaded your copy of WinSCP, install it on your computer. It also wouldn't be a bad idea to start remembering your FTP address, username, and password while WinSCP is installing.

From the login screen, enter your host name (i.e. ftp.puresourcecode.com), username, and password. You can use either FTP or SFTP, but be sure to change the port number the appropriate port your FTP host has provided you. Then click Save to save the profile. Open the profile to log into your FTP server. This will verify that you typed the right credentials in the profile.

image

Create the script

We’re going to create a simple script that logs into your FTP server, tells WinSCP where to download the missing files to on your computer, and then creates a log file that records FTP activity. Go ahead and open Notepad on your computer. Copy the following script template into Notepad:

option batch on
option confirm off
open ftp.puresourcecode.com
cd backups
option transfer binary
get /testremote* f:\backups\testlocal*
synchronize local f:\backups\testlocal testremote
exit

WinSCP will answer all prompts negatively to avoid holding up the script. Then it will automatically overwrite files when prompted. It then logs into your FTP server using the profile we created earlier, changes directories (if needed), and transfers binary (as opposed to ASCII). Finally, it reads the remote FTP directory and transfers files to the specified local directory. For even more options, check out the official WinSCP scripting page.

Now before you modify or run this script, we suggest creating test directories on both the remote and local targets. The last thing you want is to accidentally wipe your FTP server without any backups. So create a directory on your computer called “testlocal” (we created it under f:\backups) and another called “testremote” on your FTP server (we created it at the root). Once you run the script and it executes successfully, save it as “sync.txt” to your computer (we saved ours in our testlocal folder).

Automating the script

Now you’re ready to automate the script. For this we can use Task Scheduler.

image

Click on Create Basic Task and follow the following screens. First insert a name for your task.

image

Select when you want to start the task.

image

Select Start a program in the next screen.

image

Now click on Browse... and find WinSCP executable file in your program folder.

image

Underneath, add

/console /script=f:\backup\sync.txt /log=f:\backup\log.txt 

to Add arguments. Be sure to change the arguments if your sync.txt is in a different location and if you want to generate the log file in a different location. Click Next.

So the task is created!

Connect ASP.NET MVC 4.6.2 project to IdentityServer4

I have a website running on ASP.NET MVC 4.5.2. I have an IdentityServer4 server running but when I try and authenticate against it I get an:

invalid_request

I googled a bit but I can’t find a solution. Finally, I found the way.

First, in your IdentityServer4 you have to create a new client:

public static IEnumerable GetClients() {
    return new List<client> {
        new Client {
            ClientId = "yourid",
            AllowedScopes = new List<string> { "openid" },
            AllowedGrantTypes = GrantTypes.Hybrid,
            RedirectUris = new List { "http://yoururl/signin-oidc" },
        }
    }
}

When you added the new client, you can update your other MVC project. Under App_Start open Startup.Auth.cs and add this code:

using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.OpenIdConnect;
using Owin;

namespace PSC
{
    public partial class Startup
    {
        public void ConfigureAuth(IAppBuilder app)
        {
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "Cookies"
            });

            app.UseOpenIdConnectAuthentication(
              new OpenIdConnectAuthenticationOptions
              {
                Authority = "https://yourIdentityServerUrl",
                ClientId = "yourid",
                ResponseType = "id_token code",
                SignInAsAuthenticationType = "Cookies",
                RedirectUri = "http://yoururl/signin-oidc",
                Scope = "openid",
              });
        }
    }
}

You have to add a Nuget package called Microsoft.Owin.Security.OpenIdConnect.

Happy coding!

Connect ASP.NET MVC 4.6.2 project to IdentityServer4

I have a website running on ASP.NET MVC 4.5.2. I have an IdentityServer4 server running but when I try and authenticate against it I get an:

invalid_request

I googled a bit but I can’t find a solution. Finally, I found the way.

First, in your IdentityServer4 you have to create a new client:

public static IEnumerable GetClients() {
    return new List<client> {
        new Client {
            ClientId = "yourid",
            AllowedScopes = new List<string> { "openid" },
            AllowedGrantTypes = GrantTypes.Hybrid,
            RedirectUris = new List { "http://yoururl/signin-oidc" },
        }
    }
}

When you added the new client, you can update your other MVC project. Under App_Start open Startup.Auth.cs and add this code:

using Microsoft.Owin.Security.Cookies;
using Microsoft.Owin.Security.OpenIdConnect;
using Owin;

namespace PSC
{
    public partial class Startup
    {
        public void ConfigureAuth(IAppBuilder app)
        {
            app.UseCookieAuthentication(new CookieAuthenticationOptions
            {
                AuthenticationType = "Cookies"
            });

            app.UseOpenIdConnectAuthentication(
              new OpenIdConnectAuthenticationOptions
              {
                Authority = "https://yourIdentityServerUrl",
                ClientId = "yourid",
                ResponseType = "id_token code",
                SignInAsAuthenticationType = "Cookies",
                RedirectUri = "http://yoururl/signin-oidc",
                Scope = "openid",
              });
        }
    }
}

You have to add a Nuget package called Microsoft.Owin.Security.OpenIdConnect.

Happy coding!

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!

Advertsing

125X125_06

Planet Xamarin

Planet Xamarin




TagCloud

MonthList