Skip to content

Instantly share code, notes, and snippets.

@parkovski
parkovski / console.cpp
Created December 11, 2018 20:22
Show Windows console events
#define UNICODE
#define _UNICODE
#include <Windows.h>
#include <string>
#include <string_view>
#include <sstream>
#ifndef ENABLE_AUTO_POSITION
#define ENABLE_AUTO_POSITION 0x100
#endif
@parkovski
parkovski / crash.txt
Created May 15, 2018 22:16
Conhost resize crash dump
0:005> !analyze -v
*******************************************************************************
* *
* Exception Analysis *
* *
*******************************************************************************
GetUrlPageData2 (WinHttp) failed: 12002.
KEY_VALUES_STRING: 1
@parkovski
parkovski / line.cpp
Last active November 7, 2017 21:18
Windows ANSI line editor
#include <Windows.h>
class ModeRestore {
HANDLE in, out;
DWORD inmode, outmode;
public:
ModeRestore(HANDLE in, DWORD inmode, HANDLE out, DWORD outmode) : in(in), out(out) {
DWORD written;
if (GetConsoleMode(in, &this->inmode)) {
SetConsoleMode(in, inmode);
@parkovski
parkovski / 1-traits.cpp
Last active September 1, 2021 11:57
"Trait" vtables
#include <stdio.h>
class PartialEq {
public:
virtual bool eq(PartialEq *const) const = 0;
};
class PartialOrd {
public:
virtual int partial_cmp(PartialOrd *const) const = 0;
PS C:\> with RUST_BACKTRACE=1 cargo init --name foo
thread 'main' panicked at 'called `Option::unwrap()` on a `None` value', src\libcore\option.rs:335
stack backtrace:
0: git_reference_type
1: git_reference_type
2: git_reference_type
3: git_reference_type
4: git_reference_type
5: git_reference_type
6: git_reference_type