Skip to content

Instantly share code, notes, and snippets.

View dyigitpolat's full-sized avatar
🌛

Yigit Polat dyigitpolat

🌛
View GitHub Profile
@dyigitpolat
dyigitpolat / integer_to_english.cpp
Created April 12, 2022 15:08
convert integers to english.
#include <iostream>
#include <string>
#include <array>
std::array<std::string, 10> figures{
"",
"One ",
"Two ",
"Three ",
"Four ",
@dyigitpolat
dyigitpolat / pack_projector_clang.hpp
Last active March 4, 2022 20:47
(clang-friendly) pack projection with non-evaluated lambda
#include <tuple>
#include <variant>
#include <type_traits>
#include <utility>
template <
template <typename Q> typename MetaProj,
typename... Ts>
class PackProjector
{
@dyigitpolat
dyigitpolat / pack_projector.hpp
Last active March 4, 2022 16:57
pack projection with non-evaluated lambda
#include <tuple>
#include <variant>
#include <type_traits>
#include <utility>
template <
template <typename Q> typename MetaProj,
typename... Ts>
class PackProjector
{
@dyigitpolat
dyigitpolat / bounded_arithmetic.cpp
Last active December 15, 2021 15:44
bounded arithmetic demo
template<long MIN, long MAX>
struct BoundedInteger
{
BoundedInteger()
{
value_ = MIN;
}
BoundedInteger(long value)
{
@dyigitpolat
dyigitpolat / static_bounds_checking.cpp
Last active December 2, 2021 08:02
compile time bounds checking proof of concept
template<long MIN, long MAX>
struct BoundedInteger
{
BoundedInteger()
{
value_ = MIN;
}
BoundedInteger(long value)
{
@dyigitpolat
dyigitpolat / type_erasure_with_explicit_params.cpp
Last active November 25, 2021 14:10
type erasure demo with explicit function parameter and return type support.
////////////////// LIBRARY START
#include <memory>
template <typename Common, typename R = void, typename ...Args>
class I {
public:
template <typename T>
I(const T& x) : mptr{std::make_unique<Model<T>>(x)} {}
I(const I& other) : mptr{other.mptr->clone()} {}
@dyigitpolat
dyigitpolat / type_erasure_generic.cpp
Last active November 24, 2021 17:55
generic type erasure mechanism demo
#include <iostream>
#include <vector>
#include <memory>
template <typename Common>
class I {
public:
template <typename T>
I(const T& x) : mptr{new Model<T>(x)} {}
I(const I& x) : mptr{x.mptr->clone()} {}
@dyigitpolat
dyigitpolat / type_erasure.cpp
Created November 24, 2021 17:24
type erasure demo
#include <iostream>
#include <vector>
#include <memory>
template <typename T>
void concrete_impl(const T& t)
{
std::cout << "concrete implementation \n";
}
@dyigitpolat
dyigitpolat / imgur_download.py
Created November 18, 2021 09:53
download images from imgur urls.
from imgur_downloader import ImgurDownloader
list = \
['https://i.imgur.com/TQVJygN.jpeg']
for str in list:
ImgurDownloader(
str, delete_dne=True, debug=True
).save_images()
@dyigitpolat
dyigitpolat / NCNet.py
Created November 10, 2021 13:09
configurable pytorch NCNet model with SNN constructor
import torch
import torch.nn as nn
import numpy as np
from .darts_parser import *
from .new_relu import *
from .spiking_layer import *
from .settings import *