Skip to content

Instantly share code, notes, and snippets.

Avatar
🏍️

Aykut Asil aykuttasil

🏍️
View GitHub Profile
@aykuttasil
aykuttasil / coordinateDistance.dart
Created Jun 20, 2020
Calculate distance of two points
View coordinateDistance.dart
import 'dart:math' show cos, sqrt, asin;
double _coordinateDistance(lat1, lon1, lat2, lon2) {
var p = 0.017453292519943295;
var c = cos;
var a = 0.5 -
c((lat2 - lat1) * p) / 2 +
c(lat1 * p) * c(lat2 * p) * (1 - c((lon2 - lon1) * p)) / 2;
return 12742 * asin(sqrt(a));
}
View Startup_Configure.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddSerilog();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
View Startup_ConfigureServices.cs
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => false; // <---------------
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddAntiforgery(o => o.SuppressXFrameOptionsHeader = true);
services.AddDistributedMemoryCache();
View configure.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddSerilog();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
View configure_services.cs
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
services.AddAntiforgery(o => o.SuppressXFrameOptionsHeader = true);
services.AddDistributedMemoryCache();
View pre-commit
#!/bin/sh
echo "Running ktlintFormat"
./gradlew ktlintFormat
result=$?
if [ "$result" = 0 ] ; then
echo "ktlintFormat found no problems"
exit 0
else
View HomeController.cs
using System;
using System.Collections.Generic;
using System.Diagnostics;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Mvc;
using aspnetcore_filter.Models;
using aspnetcore_filter.Filters;
namespace aspnetcore_filter.Controllers
View ResultFilterSample.cs
using System;
using Microsoft.AspNetCore.Mvc.Filters;
namespace aspnetcore_filter.Filters
{
public class ResultFilterSampleAttribute : ResultFilterAttribute
{
override public void OnResultExecuting(ResultExecutingContext context)
{
context.HttpContext.Response.Headers.Add("Author", "Aykut Asil");
@aykuttasil
aykuttasil / Startup.cs
Created Apr 29, 2019
Global Scope Filters
View Startup.cs
public void ConfigureServices(IServiceCollection services)
{
services.Configure<CookiePolicyOptions>(options =>
{
// This lambda determines whether user consent for non-essential cookies is needed for a given request.
options.CheckConsentNeeded = context => true;
options.MinimumSameSitePolicy = SameSiteMode.None;
});
View run_middleware.cs
public void Configure(IApplicationBuilder app, IHostingEnvironment env)
{
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Home/Error");
// The default HSTS value is 30 days. You may want to change this for production scenarios, see https://aka.ms/aspnetcore-hsts.
You can’t perform that action at this time.