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 StrToDecInt(const char* str)
{
static const int kMAX = (int)((unsigned)~0 >> 1);
static const int kMIN = -(int)((unsigned)~0 >> 1) - 1;
static const int kMAX_DIV = (int)((unsigned)~0 >> 1) / 10;
static const int kMIN_DIV = (int)((((unsigned)~0 >> 1) + 1) / 10);
static const int kMAX_R = (int)((unsigned)~0 >> 1) % 10;
static const int kMIN_R = (int)((((unsigned)~0 >> 1) + 1) % 10);
int n = 0;
int StrToDecInt(const char* str)
{
static const int kMAX = (int)((unsigned)~0 >> 1);
static const int kMIN = -(int)((unsigned)~0 >> 1) - 1;
static const int kMAX_DIV = (int)((unsigned)~0 >> 1) / 10;
static const int kMIN_DIV = (int)((((unsigned)~0 >> 1) + 1) / 10);
static const int kMAX_R = (int)((unsigned)~0 >> 1) % 10;
static const int kMIN_R = (int)((((unsigned)~0 >> 1) + 1) % 10);
int n = 0;
const unsigned int ID_MSGBOX_STATIC = 0x0000ffff;
const wchar_t kMsgBoxTitle[] = L"Timed Message Box";
int second_left = 0;
void CALLBACK msgbox_timer(PTP_CALLBACK_INSTANCE instance, void* context,
PTP_TIMER timer)
{
HWND hwnd = ::FindWindow(nullptr, kMsgBoxTitle);
if (hwnd) {
if (second_left == 1) {
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);
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])
typedef std::string Record;
class GTAClient {
public:
virtual ~GTAClient() {}
virtual bool Filter(const Record&)
{
return true;
}
/******************************************************************************
Module: Singleton.cpp
Notices: Copyright (c) 2008 Jeffrey Richter & Christophe Nasarre
******************************************************************************/
#include "resource.h"
#include "..\CommonFiles\CmnHdr.h" /* See Appendix A. */
#include <windowsx.h>
#include <tchar.h>
#include <algorithm>
#include <cstdlib>
#include <iostream>
#include <queue>
#include <string>
#include <process.h>
#include <Windows.h>
@kingsamchen
kingsamchen / _vimrc
Created March 3, 2013 08:26
My _vimrc
if(has("win32") || has("win95") || has("win64") || has("win16"))
let g:vimrc_iswindows=1
let g:iswindows=1
else
let g:vimrc_iswindows=0
let g:iswindows=0
endif
autocmd BufEnter * lcd %:p:h
set nocompatible
@kingsamchen
kingsamchen / qsort_partition_twoversions.cpp
Last active December 16, 2015 03:39
two usual versions of implementations
int Partition(int a[], int left, int right)
{
int piv = a[left];
int l = left, r = right + 1;
do
{
do
{
++l;