Navigation Menu

Skip to content

Instantly share code, notes, and snippets.

View kingsamchen's full-sized avatar
🐛
Work life balance

0xCCCCCCCC kingsamchen

🐛
Work life balance
View GitHub Profile
@kingsamchen
kingsamchen / stack_alloc.h
Created March 18, 2021 09:02
Howard Hinnant's Stack Allocator
#ifndef SHORT_ALLOC_H
#define SHORT_ALLOC_H
// The MIT License (MIT)
//
// Copyright (c) 2015 Howard Hinnant
//
// Permission is hereby granted, free of charge, to any person obtaining a copy
// of this software and associated documentation files (the "Software"), to deal
// in the Software without restriction, including without limitation the rights
#pragma once
#include <exception>
#include <type_traits>
#include <utility>
namespace folly {
namespace detail {
bool SetProcessSEPrivilege(HANDLE process, PrivilegeOption option)
{
DWORD flags = TOKEN_ADJUST_PRIVILEGES;
base::win::ScopedHandle token;
if (!OpenProcessToken(process, flags, token.Receive()))
{
return false;
}
LUID uid;
@kingsamchen
kingsamchen / gen.py
Created November 21, 2018 16:03
A template for cmake driver
#!/usr/bin/python3
# -*- coding: utf-8 -*-
# 0xCCCCCCCC
import argparse
import os
import shlex
import shutil
import subprocess
#!python3
# -*- coding: utf-8 -*-
# 0xCCCCCCCC
import re
import shlex
import subprocess
import sys
FIRST_REV = ''
#include <tchar.h>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <string>
#include <process.h>
#include <Windows.h>
/******************************************************************************
Module: Singleton.cpp
Notices: Copyright (c) 2008 Jeffrey Richter & Christophe Nasarre
******************************************************************************/
#include "resource.h"
#include "..\CommonFiles\CmnHdr.h" /* See Appendix A. */
#include <windowsx.h>
typedef std::string Record;
class GTAClient {
public:
virtual ~GTAClient() {}
virtual bool Filter(const Record&)
{
return true;
}
def GetMatePrefList(pref_list, person):
for i in range(len(pref_list)):
if person == pref_list[i][0]:
return pref_list[i][1]
def Match(men_pref_list, women_pref_list):
free_man = []
free_woman = []
for man in men_pref_list:
free_man.append(man[0])
void CALLBACK OverlappedCompletionRoutine(PTP_CALLBACK_INSTANCE instance,
PVOID context,
PVOID overlapped,
ULONG io_result,
ULONG_PTR bytes_transferred,
PTP_IO io)
{
auto ov = static_cast<OVERLAPPED*>(overlapped);
std::cout << "read " << bytes_transferred << std::endl;
std::cout << static_cast<char*>(context);