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
int APIENTRY _tWinMain(HINSTANCE hInstance,
HINSTANCE hPrevInstance,
LPTSTR lpCmdLine,
int nCmdShow)
{
UNREFERENCED_PARAMETER(hPrevInstance);
UNREFERENCED_PARAMETER(lpCmdLine);
return DialogBox(hInstance, MAKEINTRESOURCE(IDD_DLGMAIN), NULL, DlgProc);
@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
@kingsamchen
kingsamchen / MT_Queue.h
Created November 24, 2013 16:34
sample for using SRWLock and Conditional Variables
#pragma once
#include <algorithm>
#include <Windows.h>
class MT_Queue {
public:
MT_Queue(int maxElements);
~MT_Queue();
#!python3
# -*- coding: utf-8 -*-
# 0xCCCCCCCC
import re
import shlex
import subprocess
import sys
FIRST_REV = ''
@kingsamchen
kingsamchen / add_checksum.py
Created January 21, 2014 08:47
one approach for computing checksum
#!/usr/bin/env python
# coding: utf-8
# This file is part of Adblock Plus <http://adblockplus.org/>,
# Copyright (C) 2006-2013 Eyeo GmbH
#
# Adblock Plus is free software: you can redistribute it and/or modify
# it under the terms of the GNU General Public License version 3 as
# published by the Free Software Foundation.
#
class MT_Queue {
public:
struct ELEMENT {
int thread_num;
int request_num;
};
typedef ELEMENT* PELEMENT;
MT_Queue(int max_elements);
~MT_Queue();
@kingsamchen
kingsamchen / IO_Issuer.cpp
Created December 16, 2013 16:35
a tiny tool for issuing high I/O circumstance.
/************************************
** Edition: Demo
** Author: Kingsley Chen
** Date: 2013/11/19
** Purpose: I/O issuer
************************************/
#include "stdafx.h"
#include <conio.h>
#include <string>