Skip to content

Instantly share code, notes, and snippets.

View dictoon's full-sized avatar

François Beaune dictoon

View GitHub Profile

Making Windows more useful and less annoying

Utilities

  • Everything
  • Notepad++
  • 7-Zip
  • Dropbox
  • Backblaze
  • Ubuntu
@dictoon
dictoon / contaminate.cpp
Last active March 6, 2019 12:27
Ad hoc attempt at contaminating the cache hierarchy of a CPU
// Several dependencies to external code, won't compile out of the box.
#include <algorithm>
#include <cassert>
#include <cstdint>
#include <cstddef>
void contaminate_cpu_caches()
{
const std::size_t l3_cache_size = System::get_l3_cache_size();
@dictoon
dictoon / gist:5bafd7c95b9b37b5be4a88ba3e58c6d0
Created December 24, 2018 00:33
This program shows a dialog box
#include <cassert>
#include <Windows.h>
int main()
{
_set_error_mode(_OUT_TO_STDERR);
assert(false);
}
@dictoon
dictoon / gist:2040973d89af7d3372d4c3b99e733778
Created December 23, 2018 22:20
Disable assertion dialog in Debug
SetErrorMode(SEM_FAILCRITICALERRORS | SEM_NOGPFAULTERRORBOX | SEM_NOOPENFILEERRORBOX);
_CrtSetReportMode(_CRT_WARN, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_WARN, _CRTDBG_FILE_STDERR);
_CrtSetReportMode(_CRT_ERROR, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ERROR, _CRTDBG_FILE_STDERR);
_CrtSetReportMode(_CRT_ASSERT, _CRTDBG_MODE_FILE);
_CrtSetReportFile(_CRT_ASSERT, _CRTDBG_FILE_STDERR);
@dictoon
dictoon / gist:82475e9d54faf32bcd5cdd3cacd30c75
Created November 30, 2018 21:05
VS bug around std::initializer_list<>
#include <initializer_list>
#include <iostream>
#include <string>
#include <utility>
struct S
{
std::string m_s;
S(const char* s) : m_s(s)
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" internalLogLevel="Info" internalLogFile="logs/InMagCrawlerNLog.log">
<targets>
<target name="console" xsi:type="ColoredConsole" layout="${longdate:universalTime=True}Z | ${pad:padding=4:inner=${threadid}} | ${pad:padding=5:inner=${level:uppercase=true}} | ${message}${onexception:${newline}${exception:format=tostring}}">
<highlight-row condition="level == LogLevel.Debug" foregroundColor="DarkGray" />
<highlight-row condition="level == LogLevel.Info" foregroundColor="Gray" />
<highlight-row condition="level == LogLevel.Warn" foregroundColor="Magenta" />
<highlight-row condition="level == LogLevel.Error" foregroundColor="Red" />
<highlight-row condition="level == LogLevel.Fatal" foregroundColor="White" backgroundColor="Red" />
</target>
<?xml version="1.0" encoding="utf-8" ?>
<nlog xmlns="http://www.nlog-project.org/schemas/NLog.xsd" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" autoReload="true" internalLogLevel="Info" internalLogFile="logs/InMagCrawlerNLog.log">
<targets>
<variable name="messageLayout" value="${longdate:universalTime=True}Z | ${pad:padding=4:inner=${threadid}} | ${pad:padding=5:inner=${level:uppercase=true}} | ${message}${onexception:${newline}${exception:format=tostring}}"/>
<target name="console" xsi:type="ColoredConsole" layout="${messageLayout}">
<highlight-row condition="level == LogLevel.Debug" foregroundColor="DarkGray" />
<highlight-row condition="level == LogLevel.Info" foregroundColor="Gray" />
<highlight-row condition="level == LogLevel.Warn" foregroundColor="Magenta" />
<highlight-row condition="level == LogLevel.Error" foregroundColor="Red" />