Skip to content

Instantly share code, notes, and snippets.

View aykuttasil's full-sized avatar
🏍️

Aykut Asil aykuttasil

🏍️
View GitHub Profile
@aykuttasil
aykuttasil / RecyclerViewListAdapter.kt
Created April 4, 2018 23:35
ListAdapter with DiffUtil ItemViewType configuration
class MyCagriPoolRecyclerViewAdapter : ListAdapter<DummyItem, RecyclerView.ViewHolder>(MyCagriPoolRecyclerViewAdapter.DIFF_CALLBACK()) {
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): RecyclerView.ViewHolder {
val view: View
return when (viewType) {
1 -> {
view = LayoutInflater.from(parent.context).inflate(R.layout.item_cagripool, parent, false)
ViewHolder1(view)
}
else -> {
@aykuttasil
aykuttasil / bottomsheetdialog_placing
Last active March 9, 2022 18:29
Flutter bottom sheet dialog is placed above to keyboard
To have the AddTaskScreen sit just above the keyboard, you can wrap it inside a SingleChildScrollView, which determines the padding at the bottom using a MediaQuery.
@aykuttasil
aykuttasil / coordinateDistance.dart
Created June 20, 2020 17:22
Calculate distance of two points
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));
}
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddSerilog();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
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();
public void Configure(IApplicationBuilder app, IHostingEnvironment env, ILoggerFactory loggerFactory)
{
loggerFactory.AddSerilog();
if (env.IsDevelopment())
{
app.UseDeveloperExceptionPage();
}
else
{
app.UseExceptionHandler("/Error");
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();
@aykuttasil
aykuttasil / pre-commit
Created November 8, 2019 12:15
Git Hooks
#!/bin/sh
echo "Running ktlintFormat"
./gradlew ktlintFormat
result=$?
if [ "$result" = 0 ] ; then
echo "ktlintFormat found no problems"
exit 0
else