Skip to content

Instantly share code, notes, and snippets.

View misha130's full-sized avatar
😀

Michael Tarnorutsky misha130

😀
View GitHub Profile
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore;
using BenchmarkDotNet.Running;
[SimpleJob(RuntimeMoniker.Net60)]
[MemoryDiagnoser]
[ThreadingDiagnoser]
public class AsyncVsNonAsyncEF
using BenchmarkDotNet.Attributes;
using BenchmarkDotNet.Jobs;
using Microsoft.Extensions.DependencyInjection;
using Microsoft.EntityFrameworkCore;
using BenchmarkDotNet.Running;
[SimpleJob(RuntimeMoniker.Net60)]
[MemoryDiagnoser]
[ThreadingDiagnoser]
public class AsyncVsNonAsyncEF
// Service Registration
services.AddSingleton(provider => new MapperConfiguration(cfg =>
{
var profiles = typeof(Startup).Assembly.GetTypes()
.Where(t => t.BaseType == typeof(Profile) && !t.IsAbstract && t.IsPublic);
var serviceFactory = provider.GetService<IServiceScopeFactory>();
foreach (var profile in profiles)
{
var profileInstance = Activator.CreateInstance(profile, serviceFactory) as AutoMapper.Profile;
services.AddDbContext<ApplicationDbContext>((scope, options) =>
{
var context = scope.GetRequiredService<IActionContextAccessor>();
string connectionString = "DefaultConnection";
var actionContext = context.ActionContext;
if (actionContext != null)
{
var routeValues = actionContext.RouteData.Values;
if (routeValues.ContainsKey("community"))
{
@misha130
misha130 / CustomEventManager.ts
Created August 30, 2017 16:54
custom event manager
import { Injectable, Inject, NgZone } from '@angular/core';
import { EVENT_MANAGER_PLUGINS, EventManager } from '@angular/platform-browser';
@Injectable()
export class CustomEventManager extends EventManager {
constructor( @Inject(EVENT_MANAGER_PLUGINS) plugins: any[], private zone: NgZone) {
super(plugins, zone);
}
addGlobalEventListener(target: string, eventName: string, handler: Function): Function {
if (eventName.endsWith('out-zone')) {
const fs = require('fs');
const path = require('path');
const ProgressPlugin = require('webpack/lib/ProgressPlugin');
const CircularDependencyPlugin = require('circular-dependency-plugin');
const HtmlWebpackPlugin = require('html-webpack-plugin');
const autoprefixer = require('autoprefixer');
const postcssUrl = require('postcss-url');
const cssnano = require('cssnano');
const { NoEmitOnErrorsPlugin, SourceMapDevToolPlugin, NamedModulesPlugin } = require('webpack');
@misha130
misha130 / PDFHandler.ts
Last active June 22, 2017 18:06
PDF Handler class
import { Injectable } from '@angular/core';
import pdfMake from 'pdfmake/build/pdfmake';
import './CustomPDFFont';
@Injectable()
export
class PDFHandler {
constructor() {
pdfMake.fonts = {
@Injectable()
export class QueryBuilder<T> {
private queryString: string;
private postObject: Object;
private method: string;
private controller: string;
constructor(public http: HttpHandler) {
}
public Query(controller: string): this {
this.controller = controller;
import { Http, RequestOptionsArgs, Headers, RequestOptions, Response } from '@angular/http';
import 'rxjs/add/operator/toPromise';
import { Injectable } from '@angular/core';
@Injectable()
export class HttpHandler {
constructor(public http: Http) {
}
public Get(url: string): Promise<Response> {