Skip to content

Instantly share code, notes, and snippets.

View qrealka's full-sized avatar

Dmitry Loginov qrealka

View GitHub Profile
@qrealka
qrealka / Makefile
Created May 7, 2024 12:07 — forked from skeeto/Makefile
C Object Oriented Programming Example
CFLAGS = -std=c99 -Wall
main : main.o
.PHONY : test clean
test : main
./$^ "*regex*" "*vtable*" < main.c
clean :
@qrealka
qrealka / add.sh
Created October 26, 2020 19:50 — forked from ArseniyShestakov/add.sh
My compiler alternatives
# Cleanup old alternatives
update-alternatives --remove-all cc
update-alternatives --remove-all c++
update-alternatives --remove-all gcc
update-alternatives --remove-all g++
update-alternatives --remove-all clang
update-alternatives --remove-all clang++
update-alternatives --remove-all icc
update-alternatives --remove-all icc++
@qrealka
qrealka / cpp.std.coroutines.draft.md
Created June 15, 2020 10:52 — forked from MattPD/cpp.std.coroutines.draft.md
C++ links: Coroutines (WIP draft)
@qrealka
qrealka / web-servers.md
Created January 18, 2020 09:55 — forked from willurd/web-servers.md
Big list of http static server one-liners

Each of these commands will run an ad hoc http static server in your current (or specified) directory, available at http://localhost:8000. Use this power wisely.

Discussion on reddit.

Python 2.x

$ python -m SimpleHTTPServer 8000
@qrealka
qrealka / random.h
Created January 7, 2020 10:45 — forked from Leandros/random.h
C++ Pseudo Random Number Generators
/* Copyright (c) 2018 Arvid Gerstmann. */
/* This code is licensed under MIT license. */
#ifndef AG_RANDOM_H
#define AG_RANDOM_H
class splitmix
{
public:
using result_type = uint32_t;
static constexpr result_type (min)() { return 0; }
template <typename InputIt, typename OutputIt>
OutputIt
radix_sort_split(InputIt first, InputIt last, OutputIt output, std::uint64_t bit)
{
std::vector<std::uint64_t> e(std::distance(first, last));
// Count 0s.
std::transform(first, last, e.begin(),
[=] (auto t) { return !(t & (1 << bit)); });
template <typename InputIt, typename OutputIt, typename BinaryOp, typename T, typename Size>
unique_future<OutputIt>
async_inclusive_scan(InputIt first, InputIt last, OutputIt output,BinaryOp op, T init, Size chunk_size)
{
Size const elements = std::distance(first, last);
Size const chunks = (1 + ((elements - 1) / chunk_size)); // Round up.
std::vector<unique_future<T>> sweep;
sweep.reserve(chunks);
@qrealka
qrealka / gitclean.sh
Created August 27, 2019 09:44 — forked from ericelliott/gitclean.sh
gitclean.sh - cleans merged/stale branches from origin
git remote prune origin
git branch -r --merged master | egrep -iv '(master|develop)' | sed 's/origin\///g' | xargs -n 1 git push --delete origin
#!/usr/bin/env bash
#
# Runs clang-format on changed regions before commit.
#
# To install this, copy it to .git/hooks/pre-commit in your repo.
# Remaining installation checks/instructions will be printed when you commit.
#
read -d '' help <<- EOF
This repository requires you to install the git clang-format command.
@qrealka
qrealka / minipool.hpp
Created July 5, 2019 14:42 — forked from rofirrim/minipool.hpp
Very simple memory pool
#ifndef MINIPOOL_H
#define MINIPOOL_H
#include <cassert>
#include <cstddef>
#include <memory>
#include <new>
#include <utility>
/*