Skip to content

Instantly share code, notes, and snippets.

View LYP951018's full-sized avatar

Yupei Liu LYP951018

  • Tencent
  • Shenzhen, Guangdong
View GitHub Profile
#include <memory>
#include <cassert>
#include <Windows.h>
struct FileHandle
{
::HANDLE fileHandle;
//implicit
FileHandle(::HANDLE h) noexcept
bool SkipIfChar(const char* str, const char** newPos, char c)
{
const char* pos = str;
while(*pos == c)
++pos;
*newPos = pos;
return pos != str;
}
bool SkipIfNextChar(const char* str, const char** newPos, char c)
#include <cstdio>
#include <cstdint>
#include <cinttypes>
void MoveCursorTo(std::uint32_t line, std::uint32_t column) noexcept
{
std::printf("\x1B[%" PRIu32 ";%" PRIu32 "H", line, column);
}
void SetBackgroundColor(std::uint8_t color) noexcept
using System;
using System.Collections.Generic;
using System.Text;
using System.Diagnostics;
using System.Diagnostics.Contracts;
namespace Calculator
{
enum SyntaxKind
{
#include <cstdint>
#include <Windows.h>
#include <cassert>
#include <thread>
#include <iostream>
struct Mutex
{
public:
void lock()
@LYP951018
LYP951018 / Future.cpp
Last active May 30, 2017 12:49
NaiveFuture
#include <variant>
#include <functional>
#include <memory>
#include <iostream>
#include <thread>
#include <chrono>
#include <stdexcept>
#include <Windows.h>
using Win32Handle = std::unique_ptr<void, void (*)(void *) noexcept>;
#define UNICODE
#include <string>
#include <experimental/generator>
#include <iostream>
#include <functional>
#include <string_view>
#include <Windows.h>
using namespace std::experimental;
@LYP951018
LYP951018 / Bind.cpp
Created June 10, 2017 16:26
Naive Bind
#include <type_traits>
#include <functional>
#include <tuple>
#include <utility>
#include <iostream>
#include <memory>
template<int I>
struct Placeholder
{
#include <type_traits>
#include <limits>
#include <cassert>
enum class uint32_t : unsigned int {};
constexpr uint32_t operator""_u32(unsigned long long x) {
using underlying = std::underlying_type_t<uint32_t>;
assert(static_cast<unsigned long long>(std::numeric_limits<underlying>::max()) >= x);
return uint32_t{static_cast<underlying>(x)};
@LYP951018
LYP951018 / GaussianOffsetsCalculator.cs
Last active April 29, 2019 08:07
GaussianOffsetsCalculator
using System;
using System.Collections.Generic;
using System.Linq;
namespace GaussianOffsetsCalculator
{
class Program
{
private static long[] _fracCache = new long[30];