Skip to content

Instantly share code, notes, and snippets.

View kerrytazi's full-sized avatar

Alexander Akhundzhanov kerrytazi

View GitHub Profile
@kerrytazi
kerrytazi / docker-compose.yaml
Created January 28, 2025 04:06
Docker script to run deepseek-r1 locally.
## Create directories to mount
# mkdir ollama
# mdkir webui
## Run docker compose
# docker compose up -d
## Download models (Run once. It will store model in 'ollama' dir)
# docker exec -it ollama ollama pull deepseek-r1:8b
## Other models are listed at the end of the file
## Open web page (webui might take up to a few minutes to start first time)
# http://localhost:3000
@kerrytazi
kerrytazi / fnumber32.hpp
Created October 30, 2024 00:56
Fixed point number for fast math.
#pragma once
template <unsigned int TPrecision>
class fnumber32
{
static_assert(TPrecision > 0, "fnumber32 precision must be greater than zero");
static_assert(TPrecision < 32, "fnumber32 precision must be less than 32");
private:
@kerrytazi
kerrytazi / astar.hpp
Last active April 2, 2025 03:17
My implementation of A* path finding algorithm. Heavily optimized.
#pragma once
#include <cstddef>
#include <cstdint>
#include <type_traits>
#include <utility>
#include <vector>
#include <memory>
#include <algorithm>
#include <cmath>
#pragma once
#include <cstddef>
#include <type_traits>
#include <tuple>
#include <string_view>
#include <span>
namespace rtti
{
#pragma once
#include <cstddef>
template <typename TRet, typename TVal>
TRet *poff(TVal *ptr, ptrdiff_t offset)
{
return reinterpret_cast<TRet *>(reinterpret_cast<char *>(ptr) + offset);
}
@kerrytazi
kerrytazi / constexpr_offsetof.hpp
Created December 24, 2023 03:57
static_assert(_offsetof_(MyClass, my_field) == 0, "my_field must be first field");
#pragma once
#ifdef _MSC_VER
#define _offsetof_(s, m) offsetof(s, m)
#else
namespace detail {
template<typename T> struct declval_helper { static T value; };
#pragma once
#include <vector>
template <typename T, size_t N>
struct allocator_with_buffer
{
using value_type = T;
template <class U>
struct rebind { typedef allocator_with_buffer<U, N> other; };
@kerrytazi
kerrytazi / Mutexed.hpp
Last active June 12, 2023 19:54
Safe wrapper of mutex that won't allow using data without proper lock.
#pragma once
#include <mutex>
#include <thread>
#include <new>
template <typename TObj, typename TMutex = std::mutex>
class MutexedGuard;
@kerrytazi
kerrytazi / Function.hpp
Created April 14, 2019 01:47
Template copy/move and move-only functors with configurable size.
#pragma once
#ifndef _FUNCTION_HPP_INCLUDED_
#define _FUNCTION_HPP_INCLUDED_
#include <type_traits>
namespace
{