Skip to content

Instantly share code, notes, and snippets.

View sulton-max's full-sized avatar
📌
Focusing

Sultonbek Murodbekovich Rakhimov sulton-max

📌
Focusing
View GitHub Profile
@sulton-max
sulton-max / fine-tune.py
Created October 4, 2024 16:45
Example fine-tuning `phi-3.5` mini model using transformers trainer
import pandas as pd
from datasets import Dataset
from transformers import AutoTokenizer, AutoModelForCausalLM, TrainingArguments, Trainer, DataCollatorForLanguageModeling
import torch
# Step 1: Load and prepare the data
df = pd.read_csv('test-data.csv')
def combine_text(row):
return "Input: Pochta bo'limi: {0}\nOutput: Manzil: {1}, Xizmat: {2}, Yangi Indeks: {3}, Eski Indeks: {4}".format(
@sulton-max
sulton-max / HttpRequestContextProvider.cs
Created May 9, 2024 12:04
Request context provider to abstract away http context access
using Domain.Brokers;
using Domain.Constants;
using Domain.Exceptions.Request;
using Force.DeepCloner;
using Microsoft.AspNetCore.Http;
namespace Infrastructure.Common.RequestContexts.Brokers;
/// <summary>
/// Provides client context information for the current request.
@sulton-max
sulton-max / build-and-publish-backend-release.yml
Last active April 26, 2024 17:13
Nuget publish release package with version valdiation
name: Build & Test Backend for Production, Publish Release Version
on:
push:
branches:
- main
paths:
- 'src/**'
env:
@sulton-max
sulton-max / build-and-publish-backend-prerelease.yml
Last active April 26, 2024 17:14
Nuget publishing with semver package validation
name: Build & Test Backend for Development, Publish PreRelease Version
on:
push:
branches:
- dev
paths:
- 'src/**'
env:
@sulton-max
sulton-max / build-and-publish-backend-prerelease.yml
Last active April 26, 2024 04:56
Nuget publish with automatic semver versioning
name: Build & Test Backend for Development, Publish PreRelease Version
on:
push:
branches:
- dev
paths:
- 'src/**'
env:
@sulton-max
sulton-max / TypeDuplicateCheck.cs
Created April 19, 2024 07:05
Checking duplicate types from all assemblies
var test = AccertifyTransactionActionCode.REJECT;
var assemblies = Assembly.GetExecutingAssembly()
.GetReferencedAssemblies()
.Select(Assembly.Load)
.Append(Assembly.GetExecutingAssembly())
.ToList();
var duplicateTypes = assemblies
.SelectMany(assembly => assembly.GetTypes())
@sulton-max
sulton-max / HostConfigurations.Extensions.cs
Created April 11, 2024 09:38
External options settings validator to validate if all options are registered
/// <summary>
/// Records all registered settings types
/// </summary>
internal static WebApplicationBuilder RecordRegisteredSettingsTypes(this WebApplicationBuilder builder)
{
// Get registered option types
if (builder.Environment.IsDevelopment())
{
_registeredDependencyOptionTypes = Assemblies
.SelectMany(assembly => assembly
@sulton-max
sulton-max / ListEqualityComparer.cs
Created October 16, 2023 09:19
Collection equality comparers
public class ListEqualityComparer<T> : IEqualityComparer<List<T>>
{
public bool Equals(List<T> x, List<T> y)
{
if (ReferenceEquals(x, y)) return true;
if (ReferenceEquals(x, null)) return false;
if (ReferenceEquals(y, null)) return false;
if (x.GetType() != y.GetType()) return false;
if (x.Capacity != y.Capacity || x.Count != y.Count) return false;
@sulton-max
sulton-max / ReflectionExtensions.cs
Created September 16, 2023 11:18
Reflection Extensions for type reflection
namespace Cerulean.Core.Extensions;
/// <summary>
/// Provides methods for relfection related operations
/// </summary>
public static class ReflectionExtensions
{
/// <summary>
/// Determines whether type A is child of type B
/// </summary>
using System;
using System.Collections;
using System.Collections.Generic;
using System.Linq;
using System.Linq.Expressions;
public class InMemoryQueryProvider<T> : IQueryProvider
{
private readonly IEnumerable<T> _collection;