Amplitude 2017: A MasterCard Hackathon

20664840_883428851808374_5819156468309340427_n

MasterCard is going to conduct one of the biggest hackathons of India on November. Name of the hackathon is Amplitude 2017.

The theme of this Hackathon is #CashLessBanoIndia. Name of the theme is self-explanatory, the main focus of this hackathon is to come up with the ideas which will encourage people to use digital payments instead of Cash.

There are mainly 4 themes for this hackathon which includes creating meta data driven rules platform, how to accelerate the adoption of digital payments in India, To develop alternate payment solution for merchants and increase the security of P2P and P2M transactions.

MasterCard has some awesome products which can be used for this hackathon. By the way, developers can use any API or products they want for the hackathon.

Below is the process required for Amplitude 2017:

766a17e

Some useful links:

For Registration: https://www.hackerearth.com/sprints/amplitude-2017/

To know the rules: https://www.hackerearth.com/sprints/amplitude-2017/rules/#rules

To know about the themes: https://www.hackerearth.com/sprints/amplitude-2017/custom-tab/themes/#Themes

So if you are a geek and want to do something for the nation then just register yourself and be a part of the biggest hackathon of MasterCard.

 

Advertisements

Automatic Data refresh in Quicksight

In my last post I have covered insight of Amazon Quicksight. It is here.

In this blog we will see one more powerful feature of Quicksight which is automatic data refresh of any of the data sets you have chosen on Quicksight.

Let us have quick introduction of Quicksight:

Amazon QuickSight is a fast business analytics service you can use to build visualizations, perform ad hoc analysis, and quickly get business insights from your data. Amazon QuickSight seamlessly discovers AWS data sources, enables organizations to scale to hundreds of thousands of users, and delivers fast and responsive query performance by using a robust in-memory engine (SPICE)

Quicksight has launched scheduled data refresh just before few days which can be achieved as below:

  • Go to Your data sets page
  • Choose the data set you want to refresh
  • Click on Schedule refresh

quick7

  • In Schedule refresh window, click on Create
  • Now select as per your requirement (Daily, Weekly, Monthly etc)

 

quick6

Now you can ensure that your SPICE data sets, analyses and dashboards are always in sync with your source data.

Happy coding!

Text to speech utility

We all become lazy sometimes when we get long emails. But at the same time we had to listen to them as the mail contains important information.

If I tell about myself, then I grasp fast if someone speaks to me instead of reading something which is very long. And after talking with different people they had the same feelings.

That is why I thought to make something which takes text as input and speaks whatever is given as text and I created a project.

So now the problem is solved! If you have got a long mail but not in mood to read till end then just open this utility -> copy and paste all mail content into this utility -> Click on speak. It will read it out your whole email.

It is not only useful in above example, but it can be useful in many cases.

Utility looks like below:

text

It is available here.

If anyone wants the code then just contact me, I will provide.

Happy coding.

 

 

 

MVC6 (.Net core) applications are self hosted : Optional IIS integration

All ASP.NET Core applications are self-hosted.

Yes you read it right!

So does it mean IIS is not required?

Yes, I mean we can host MVC6 application even without IIS.

Wow…but How?

I assume you have already downloaded .Net core from here.

Next step would be to create sample MVC6 project.

For now you can directly clone it from Github by below commands:

git clone git@github.com:aspnet/cli-samples.git
cd cli-samples\HelloMvc

Then we would restore and run the project as below:

dotnet restore
dotnet run 

That is it!

Now navigate to localhost:5000 in your web browser and you can see your application hosted there.

You must be wondering how it happened?

You can check it by yourself in code.

Open Program.cs class and you can see below code there:

public class Program
{
    public static void Main(string[] args)
    {
        var config = new ConfigurationBuilder()
            .AddCommandLine(args)
            .AddEnvironmentVariables(prefix: "ASPNETCORE_")
            .Build();

        var host = new WebHostBuilder()
            .UseConfiguration(config)
            .UseKestrel()
            .UseContentRoot(Directory.GetCurrentDirectory())
            .UseIISIntegration() //// Here IIS integration is optional
            .UseStartup()
            .Build();

        host.Run();
    }
}

As you can see in above comments, IIS integration is optional in .Net core.

Happy coding!

Dependency Injection in MVC 1.0(ASP.NET Core)

Please note that below post would be more clear for those who already know what Dependency injection is.

As we all know that things has been little changed in .Net core and things has also been changed the way we suppose to register all of our services that we are going to use as DI.

Suppose you have one HomeController and in that controller you want to inject a service let us say MyService.

In controller it would look like as it was used to :

public HomeController(IMyServcie myService)
{

}

And in a class library called MyService, it would look like as below:

public class MyService : IMyService
{
private readonly IMyRepository _myRepository;

public MyService(IMyRepository myRepository)
{
_myRepository = myRepository;
}
…….
}

You can even inject services into views using @inject. I have already written post on that which is here.

So now you might be wondering like where should we register this.

ConfigurationServices is your composition root so that’s where you register you services.

So it would be as below:

public void ConfigureServices(IServiceCollection services)
{
services.AddMvc();

// Add application services.
services.AddScoped<IMyService, MyService >();
}

Okay so above scenario is ideal scenario but you might be having some questions as below:

  • What if you have some of your code written outside of your MVC application?.
  • Also what if you do not want to bloat the ConfigurationServices method with lots of AddScoped lines of code for other layers like Repository layer and Service layer?
  • What to do if I need to do in my other layers (Repository and Service) to first register them here (both are .NET Core class library projects) and then wire those containers into the parent container?

For that you just need to create different Extension methods in different layers which targets IServiceCollection as below:

public static IServiceCollection AddMyServices(this IServiceCollection services) {
services.AddMyRepositories();
services.AddScoped<IMyService, MyService>();
//…add other services
}

And in Repository layer it would have a extension method as below:

public static IServiceCollection AddMyRepositories(this IServiceCollection services) {
services.AddScoped<IMyRepository, MyRepository>();
//…add other Repositories
}

And now you could just as easily call the AddMyRepositories() in the AddMyServies extension method as opposed to the main project itself:

public void ConfigureServices(IServiceCollection services) {
//…other code

services.AddMyServices();

//…other code
}

That is it!

Happy coding!

Upload file in MVC 6 (ASP.NET Core 1.0)

There are many ways to upload files in MVC 6.

Below code is the simplest way I found till now, If I get any other simpler method then I will update this code.

view (cshtml) :

<form method="post" asp-action="Upload" asp-controller="Home" enctype="multipart/form-data">
    <input type="file" name="file" />
    <input type="submit" value="upload"/>
</form>

controller (cs) :

[HttpPost]
public IActionResult Upload(IFormFile file)
{
    if (file == null || file.Length == 0)
        throw new Exception("file should not be null");

    var originalFileName = ContentDispositionHeaderValue.Parse(file.ContentDisposition).FileName.Trim('"');

    file.SaveAs("your_file_full_address");
}

Happy coding!