Skip to content

Instantly share code, notes, and snippets.

View nixiz's full-sized avatar
🎯
Focusing

Oguzhan KATLI nixiz

🎯
Focusing
View GitHub Profile
@nixiz
nixiz / contiguous_list.c
Last active August 7, 2023 14:37
Example implementation contiguous list in C
#include <stdlib.h>
#include <string.h>
#include "contiguous_list.h"
contiguous_list_t* create_new_list(const size_t size_of_elem) {
return create_new_list_with_cap(size_of_elem, 2);
}
contiguous_list_t* create_new_list_with_cap(const size_t s, const size_t cap) {
contiguous_list_t mlist = {
@nixiz
nixiz / love_calc.rs
Last active August 24, 2022 14:05
Aşk uyumu hesaplayıcı
use std::collections::HashSet;
use itertools::Itertools;
use itertools::EitherOrBoth::{Both, Left, Right};
type Score = usize;
fn main() {
let score = calculate("Selçuk", "Evin");
println!("score: {}", score);
}
@nixiz
nixiz / nqueen.c
Created July 20, 2022 07:32
N Queen Problem Solution done in C language.
#include <stdio.h>
#include <stdlib.h>
#define N_MAX_BOARD_ROW_SIZE 15
/*
Board array keeps queen placement(column index) on given indexed row value
Example board allocation for N = 4
1 2 3 4
1 - Q - -
2 - - - Q
@nixiz
nixiz / multi_observer.cc
Created March 4, 2022 15:14
Multiple Observer handling by using single observer bridge
#include <functional>
#include <iostream>
#include <string>
#include <tuple>
#include <type_traits>
struct IObserver {
virtual ~IObserver() = default;
virtual void OnMessage(const std::string&) = 0;
};
@nixiz
nixiz / thread_safe.cpp
Created April 19, 2021 19:06
Thread safe accessor encapsulation implementation in C++
#include <iostream>
#include <mutex>
#include <assert.h>
/*
From the book "Modern C++ Design: Generic Programming and Design Patterns Applied" Andrei Alexandrescu
There are interesting applications of smart pointer layering, mainly because of the mechanics of
operator->. When you apply operator-> to a type that's not a built-in pointer, the compiler does an
@nixiz
nixiz / contiguous_list.c
Created April 19, 2021 09:49
Contiguous list implementation in C language
#include <stdlib.h>
#include <string.h>
#include "contiguous_list.h"
contiguous_list_t* create_new_list(const size_t size_of_elem) {
return create_new_list_with_cap(size_of_elem, 2);
}
contiguous_list_t* create_new_list_with_cap(const size_t s, const size_t cap) {
contiguous_list_t mlist = {
@nixiz
nixiz / cpp20-range-example.cpp
Last active November 3, 2023 11:06
C++20 ranges example. Compiler Explorer link: https://godbolt.org/z/nG84M1j7a
#include <iostream>
#include <vector>
#include <string>
#include <string_view>
#include <chrono>
#include <random>
#include <range/v3/all.hpp>
#include <ranges>
using namespace std;
@nixiz
nixiz / threadpool.cc
Last active October 12, 2023 20:30
thread pool implementation with modern c++. requires std=c++17 to build and run the tests. https://godbolt.org/z/6oTco3Tjz
#include <iostream>
#include <memory>
#include <thread>
#include <mutex>
#include <future>
#include <condition_variable>
#include <functional>
#include <vector>
#include <deque>
#include <type_traits>
@nixiz
nixiz / cache_friendly_programming.cpp
Last active December 2, 2022 08:15
cache friendly programming best practices with google/benchmark results
#include <benchmark/benchmark.h>
#include <iostream>
#include <random>
#include <algorithm>
#include <vector>
#include <chrono>
#include <iterator>
#include <execution>
static void count_if_random(benchmark::State& state)
#include <iostream>
#include <string>
#include <string_view>
#include <vector>
#include <algorithm>
#include <execution>
using namespace std;
// fix mesaj tag'leri için kullanılacak parser sınıflarının deklerasyonları