Skip to content

Instantly share code, notes, and snippets.

View nikkon-dev's full-sized avatar

Nik Konyuchenko nikkon-dev

View GitHub Profile
@nikkon-dev
nikkon-dev / List.rs
Created June 2, 2020 05:10
Rust macro to create lists
#[macro_export]
macro_rules! list {
($val: expr => $($tail: expr)=>+) => {
{
let mut node = ListNode::new($val);
node.next = Some(Box::new($crate::list!($($tail)=>+)));
node
}
};
($val: expr) => {
@nikkon-dev
nikkon-dev / FastPimpl.hpp
Created January 15, 2020 22:53
FastPimpl after Yandex.Taxi
#pragma once
#include <type_traits>
#include <utility>
namespace Fast
{
template <typename Type, size_t Size, size_t Alignment>
class FastPimpl
{
public:
#include <semaphore.h>
#include <atomic>
#include <cerrno>
#include <chrono>
#include <cstdio>
#include <ctime>
#include <memory>
#include <mutex>
#include <system_error>
@nikkon-dev
nikkon-dev / sources.list
Created June 4, 2019 20:21
sources.list
# deb http://snapshot.debian.org/archive/debian/20190506T000000Z stretch main
deb http://deb.debian.org/debian stretch main
# deb http://snapshot.debian.org/archive/debian-security/20190506T000000Z stretch/updates main
deb http://security.debian.org/debian-security stretch/updates main
# deb http://snapshot.debian.org/archive/debian/20190506T000000Z stretch-updates main
deb [arch=amd64] https://download.docker.com/linux/debian stretch stable
# deb-src [arch=amd64] https://download.docker.com/linux/debian stretch stable
deb http://deb.debian.org/debian stretch-updates main
@nikkon-dev
nikkon-dev / install_docker.sh
Created June 4, 2019 20:15
install_docker inside jenkins
#!/usr/bin/env bash
apt-get update && \
apt-get -y install apt-transport-https \
ca-certificates \
curl \
gnupg2 \
software-properties-common && \
curl -fsSL https://download.docker.com/linux/$(. /etc/os-release; echo "$ID")/gpg > /tmp/dkey; apt-key add /tmp/dkey && \
add-apt-repository \
@nikkon-dev
nikkon-dev / Makefile
Created March 20, 2019 01:59
Pass a variable to submake process
# We need to properly escape DCGM_GLOBAL_CFLAGS and DCGM_GLOBAL_LDFLAGS
# in a way that neither submake nor shell breake them due to substitutions rules.
#
# Here is the example of what is going on:
# This makefile:
# DCGM_GLOBAL_LDFLAGS := '-Wl,-rpath,$$ORIGIN/'
# DCGM_GLOBAL_LDFALGS += '-Wl,-static'
#
# To allow another make process to see this variable in exacly the same way, it should be quoted:
# make DCGM_GLOBAL_LDFLAGS=$'\'-Wl,-rpath,\$\$ORIGIN/\' \'-Wl,-static\''
@nikkon-dev
nikkon-dev / Mutex.h
Created November 9, 2018 19:37
Rust-like Mutex
#include <mutex>
#include <utility>
#include <future>
#include <thread>
#include <vector>
#include <cstdio>
struct NoLog{
template <class ... TArgs>
@nikkon-dev
nikkon-dev / gist:5531916
Created May 7, 2013 11:18
Another way to shoot yourself it the foot
#include <iostream>
#include <functional>
#include <memory>
#define THIS_DECORATOR \
private: \
_Tx* This(){ \
return static_cast<_Tx*>(this);\
}\