Skip to content

Instantly share code, notes, and snippets.

View Vikaskumargd's full-sized avatar
🎯
Focusing

Vikas Kumar Vikaskumargd

🎯
Focusing
View GitHub Profile
@Vikaskumargd
Vikaskumargd / authenticationWithAsp.netIdentity.cs
Created January 16, 2017 19:14
I felt the same way when taking a look at Identity. It added lots of abstractions and does not suit with my case that I have legacy system which implemented own authentication work-flow. Tons of example about OWIN authentication which uses Identity and EF by default. But technically, you are able to strip out Identity to use only OWIN cookie aut…
[HttpPost]
public ActionResult Login(LoginViewModel model, string returnUrl)
{
var user = _userService.GetByEmail(model.Email);
//check username and password from database, naive checking: password should be in SHA
if (user != null && (user.Password == model.Password))
{
var claims = new[] {
new Claim(ClaimTypes.Name, user.Name),
@Vikaskumargd
Vikaskumargd / introrx.md
Created January 18, 2017 21:33 — forked from staltz/introrx.md
The introduction to Reactive Programming you've been missing
@Vikaskumargd
Vikaskumargd / GenericRepo.cs
Created February 5, 2017 20:52
Repository Pattern Plus Unit of Work
using MyUniversity.Models;
using System;
using System.Collections.Generic;
using System.Data;
using System.Data.Entity;
using System.Linq;
using System.Linq.Expressions;
using System.Web;
namespace MyUniversity.DAL
public static Func<A, R> Memoize<A, R>(this Func<A, R> f)
{
var map = new Dictionary<A, R>();
return a =>
{
R value;
if (map.TryGetValue(a, out value))
return value;
value = f(a);
map.Add(a, value);
@Vikaskumargd
Vikaskumargd / AsyncMediatorPipeline.cs
Created August 20, 2017 11:17
AsyncMediatorPipeline and Autofac Registration
public class AsyncMediatorPipeline<TRequest, TResponse> : IAsyncRequestHandler<TRequest, TResponse> where TRequest : IAsyncRequest<TResponse>
{
private readonly IAsyncRequestHandler<TRequest, TResponse> inner;
private readonly IAsyncPreRequestHandler<TRequest>[] preRequestHandlers;
private readonly IAsyncPostRequestHandler<TRequest, TResponse>[] postRequestHandlers;
public AsyncMediatorPipeline(IAsyncRequestHandler<TRequest, TResponse> inner, IAsyncPreRequestHandler<TRequest>[] preRequestHandlers, IAsyncPostRequestHandler<TRequest, TResponse>[] postRequestHandlers)
{
this.inner = inner;
@Vikaskumargd
Vikaskumargd / launch.json
Created September 20, 2017 06:59
Config for Debugging Typescipt Jest tests in VS Code
{
"version": "0.2.0",
"configurations": [
{
"name": "Debug CRA Tests",
"type": "node",
"request": "launch",
"runtimeExecutable": "${workspaceRoot}/node_modules/.bin/react-scripts-ts",
"runtimeArgs": [
"--inspect-brk",
@Vikaskumargd
Vikaskumargd / useFetch.js
Created April 9, 2020 21:53 — forked from Dromediansk/useFetch.js
fetching data custom hook final version
import { useState, useEffect } from "react";
export const useFetch = (url, ref, initialValue) => {
const [data, setData] = useState(initialValue);
const [error, setError] = useState(null);
const [loading, setLoading] = useState(true);
useEffect(() => {
if (ref.current) {
(async () => {
@Vikaskumargd
Vikaskumargd / findStyles.js
Created April 29, 2020 04:05 — forked from macbookandrew/findStyles.js
List unique CSS properties for all DOM elements
/**
* List unique CSS properties for all DOM elements
* Initially created to list unique font stacks on a page
* @see {@link http://stackoverflow.com/a/35022690/ Inspired by this StackOverflow answer}
*
* @see {@link https://gist.github.com/macbookandrew/f33dbbc0aa582d0515919dc5fb95c00a/ URL for this file}
*
* @author AndrewRMinion Design (https://andrewrminion.com)
* @version 1.1
*