Skip to content

Instantly share code, notes, and snippets.

View saurabhpati's full-sized avatar

Saurabh Pati saurabhpati

View GitHub Profile
@saurabhpati
saurabhpati / execute.js
Last active September 20, 2017 17:59
creating curry functions to master functional programming. In Progress...
var products = [
{
id: 1,
name: 'IPhone X',
price: 900
},
{
id: 2,
name: 'Samsung S8',
price: 700
@saurabhpati
saurabhpati / Clock.js
Last active November 12, 2017 06:15
Implementing a clock using props in React
import React from 'react' // npm package of react is required
import ReactDOM from 'react-dom' // npm package of react-dom
class Clock extends React.Component {
render() {
return (
<div>
<h2>Hello world, Its {this.props.date.toLocaleString()}</h2>
</div>
);
@saurabhpati
saurabhpati / Clock.js
Created November 12, 2017 12:24
React state clock implementation
import React from 'react'; // npm install react
import ReactDOM from 'react-dom'; // npm install react-dom
class Clock extends React.Component {
constructor(props) {
super(props);
this.state = {
date: new Date()
};
@saurabhpati
saurabhpati / Clock.js
Created November 13, 2017 04:11
Start and Stop the Clock
import React from 'react';
export default Clock extends React.Component {
constructor(props) {
super(props);
this.state = {
date: new Date(),
isClockRunning: true
}
@saurabhpati
saurabhpati / Program.cs
Created January 24, 2018 13:09
ASP.NET Core Program Class
public class Program
{
public static void Main(string[] args)
{
BuildWebHost(args).Run();
}
public static IWebHost BuildWebHost(string[] args) =>
WebHost.CreateDefaultBuilder(args)
.UseStartup<Startup>()
@saurabhpati
saurabhpati / WebHost.cs
Created January 24, 2018 16:25
CreateDefaulterBuilder Method.
public static IWebHostBuilder CreateDefaultBuilder(string[] args)
{
var builder = new WebHostBuilder()
.UseKestrel((builderContext, options) =>
{
options.Configure(builderContext.Configuration.GetSection("Kestrel"));
})
.UseContentRoot(Directory.GetCurrentDirectory())
.ConfigureAppConfiguration((hostingContext, config) =>
{
@saurabhpati
saurabhpati / Startup.cs
Last active January 25, 2018 05:00
Startup class
public class Startup
{
// Use this method to add services to the container.
public void ConfigureServices(IServiceCollection services)
{
services.AddSingleton<IDependecy, Dependency>()
.AddScoped<UserManager<AppUser>>()
.AddTransient<IUserClaimsPrincipalFactory<AppUser>, AppUserClaimsPrincipalFactory>();
}
@saurabhpati
saurabhpati / shortmock.cs
Created April 24, 2018 16:45
short mock
mockSet.Setup(db => db.AsQueryable()).Returns(books);
@saurabhpati
saurabhpati / longmock.cs
Created April 24, 2018 16:47
long mock
mockSet.As<IQueryable<Book>>().Setup(m => m.Provider).Returns(books.Provider); 
mockSet.As<IQueryable<Book>>().Setup(m => m.Expression).Returns(books.Expression); 
mockSet.As<IQueryable<Book>>().Setup(m => m.ElementType).Returns(books.ElementType); 
mockSet.As<IQueryable<Book>>().Setup(m => m.GetEnumerator()).Returns(books.GetEnumerator());
@saurabhpati
saurabhpati / index.html
Created May 20, 2018 13:32
index.html file for setting up a react application
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta http-equiv="X-UA-Compatible" content="ie=edge">
<title>React with Typescript and Webpack</title>
</head>
<body>
<div id="root"></div>