Skip to content

Instantly share code, notes, and snippets.

View kachsheev's full-sized avatar
💩

Anton Kashcheev kachsheev

💩
  • Tashkent, Uzbekistan
View GitHub Profile
@kachsheev
kachsheev / learn.lua
Created May 6, 2017 15:44 — forked from tylerneylon/learn.lua
Learn Lua quickly with this short yet comprehensive and friendly script. It's written as both an introduction and a quick reference. It's also a valid Lua script so you can verify that the code does what it says, and learn more by modifying and running this script in your Lua interpreter.
-- Two dashes start a one-line comment.
--[[
Adding two ['s and ]'s makes it a
multi-line comment.
--]]
----------------------------------------------------
-- 1. Variables and flow control.
----------------------------------------------------
@kachsheev
kachsheev / IntegerChecker.hpp
Created November 25, 2017 18:41
Get count signs in integer
// define
template<
Types::ullong_t MIN, Types::ullong_t MAX
, SizeTraits::SizeType BUFFER_SIZE
>
struct NumberChecker
{
template<typename IntType>
static inline SizeTraits::SizeType get(IntType value);
@kachsheev
kachsheev / fork.c
Created February 27, 2018 21:35 — forked from Cr4sh/fork.c
fork() for Windows
/*
* fork.c
* Experimental fork() on Windows. Requires NT 6 subsystem or
* newer.
*
* Copyright (c) 2012 William Pitcock <nenolod@dereferenced.org>
*
* Permission to use, copy, modify, and/or distribute this software for any
* purpose with or without fee is hereby granted, provided that the above
* copyright notice and this permission notice appear in all copies.
#include <utility>
namespace stdext
{
namespace details
{
template<typename T, T... elems>
struct is_element_of_sequence_impl
@kachsheev
kachsheev / main.cpp
Created December 24, 2019 14:49
Global boost::string_view
#include <iostream>
#include <boost/utility/string_view.hpp>
const boost::string_view globalView = "123";
int main()
{
std::cout << globalView << std::endl; // 123
return 0;
}
@kachsheev
kachsheev / CommandPattern.hpp
Last active June 25, 2020 12:30
CommandPattern.hpp
#ifndef COMMAND_PATTERN_HPP
#define COMMAND_PATTERN_HPP
// declaration
namespace command
{
///
/// \brief The Invoker class
@kachsheev
kachsheev / command_pattern.c
Last active December 10, 2020 14:13
Pure C command pattern
#include "command_pattern.h"
/** private **/
static int executorRun(ExecutorPtr executor)
{
return executor->command->run(executor->command, executor->invoker);
}
static Executor executionContextInit(InvokerPtr invoker, CommandPtr command)
@kachsheev
kachsheev / RandomSequence.h
Created April 28, 2021 19:50
WinAPI Generate Random class
// From stackoverflow: https://stackoverflow.com/a/21429737
#include <wincrypt.h>
class RandomSequence
{
HCRYPTPROV hProvider;
public:
RandomSequence(void) : hProvider(NULL) {
if (FALSE == CryptAcquireContext(&hProvider, NULL, NULL, PROV_RSA_FULL, 0)) {
@kachsheev
kachsheev / main.cpp
Created January 10, 2023 18:48 — forked from sunmeat/main.cpp
client server UDP C++ example
CLIENT SIDE:
#include <iostream>
#include <winsock2.h>
using namespace std;
#pragma comment(lib,"ws2_32.lib")
#pragma warning(disable:4996)
#define SERVER "127.0.0.1" // or "localhost" - ip address of UDP server
@kachsheev
kachsheev / Source.cpp
Created February 14, 2023 22:00 — forked from AngelicosPhosphoros/Source.cpp
Example of OVERLAPPED IO using WinAPI
#include <atomic>
#include <cassert>
#include <iostream>
#include <list>
#include <memory>
#include <mutex>
#include <optional>
#include <thread>
#include <vector>