Skip to content

Instantly share code, notes, and snippets.

View mt-akar's full-sized avatar
🎯
Focusing

Mustafa Akar mt-akar

🎯
Focusing
View GitHub Profile
@mt-akar
mt-akar / Showcase.cs
Last active December 14, 2022 01:59
Comprehensive web3 SDK for C#
using System;
using System.Collections.Generic;
var web3 = new Web3("ProjectId", "ProjectSecret");
// Get the chain height
var block1 = await web3.EthMainNet.Eth.GetBlockNumberAsync();
var block2 = await web3.Optimism.Eth.GetBlockNumberAsync();
// Query USDT balance
@mt-akar
mt-akar / ResponsiveWidth.razor
Created November 2, 2022 10:17
Responsive site content width for Blazor and Tailwind
<div class="w-full sm:w-5/6 md:w-4/5 lg:w-3/4 mx-auto px-4 py-6">
@ChildContent
</div>
@code {
[Parameter]
public RenderFragment? ChildContent { get; set; }
}
@mt-akar
mt-akar / BasicAuthUsingConfigurationDbContext.cs
Created August 5, 2022 04:45
This code checks key from url and secret from auth header password for basic auth againts the Client.ClientId as key and ClientSecret.Value as secret-hash.
try
{
var authHeader = Request.Headers.Authorization.ToString();
if (!authHeader.StartsWith("Basic "))
return Unauthorized();
var apiSecretHash = Encoding.ASCII.GetString(Convert.FromBase64String(authHeader[6..]))
.Split(':')[1]
.ToSha256();
@mt-akar
mt-akar / subscription-checkout.component.ts
Created February 26, 2022 22:32
Iyzico checkout form - Angular
import {Component, Inject, OnInit, Renderer2} from '@angular/core';
import {PaymentService} from "../../services/payment.service";
import {DOCUMENT} from '@angular/common';
@Component({
selector: 'app-subscription-checkout',
templateUrl: './subscription-checkout.component.html',
styleUrls: ['./subscription-checkout.component.scss']
})
export class SubscriptionCheckoutComponent implements OnInit {
@mt-akar
mt-akar / ComplexQueryUsingEFCore.cs
Last active August 8, 2021 22:50
This is an example query from one of my projects. It is written using EFCore and LINQ.
/// <summary>
/// Returns all topic information and returns it to the client.
/// If the user is not a paid member, the video urls and document urls are returned null.
/// </summary>
public async Task<TopicModel> GetTopicClassroomModelAsync(string topicId, string userId)
{
// Get the topic entity
var topic = await _db.Topics
.Include(t => t.Lesson) // To get to the UserCourse
@mt-akar
mt-akar / MyApiContainer.java
Last active October 14, 2020 19:02
Simple Retrofit Container
/*
* With help of this class, we reduce the retrofit api call to a single line.
* Example: MyApiContainer.api().getMethod().enqueue(...);
*/
public class MyApiContainer {
interface MyApi {
@GET("someEndpoint")
Call<String> getMethod();