This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <charconv> | |
#include <iostream> | |
#include <array> | |
constexpr auto ToString = [](auto number) constexpr -> const std::string { | |
std::array<char, 20 /* Max chars in 64 bit number*/> buffer; | |
if (auto [ptr, ec] = std::to_chars(buffer.data(), buffer.data() + buffer.size(), number); ec == std::errc()) | |
{ | |
return std::string{buffer.data(), static_cast<size_t>(ptr - buffer.data())}; | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <filesystem> | |
#include <iostream> | |
#include <format> // C++20 Required | |
namespace fs = std::filesystem; | |
std::string to_long_path(const std::string& short_path) { | |
return fs::canonical(short_path).string(); | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import logging | |
import requests | |
import sys | |
from os import path | |
# https://docs.microsoft.com/en-us/microsoftteams/platform/webhooks-and-connectors/how-to/add-incoming-webhook | |
TEAMS_WEBHOOK = "{YOUR_WEBHOOK_LINK}" | |
LOG_FILE = path.join(path.dirname(__file__), "log.txt") | |
logger = logging.getLogger(__name__) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
#include <string> | |
template <typename T> | |
constexpr auto NullTerminator() { | |
return std::string(sizeof(typename T::value_type), '\0'); | |
} | |
int main() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <string> | |
#include <iostream> | |
#include <chrono> | |
#include <thread> | |
#include <format> // Requires C++20 | |
using system_clock = std::chrono::system_clock; | |
using namespace std::chrono_literals; | |
const std::string& get_static_message() { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#include <tuple> | |
template <typename... Args> | |
constexpr void ignore0(Args... args) | |
{ | |
constexpr auto dummy = [](auto&& a) { std::ignore = a;}; | |
(dummy(std::forward<Args>(args)), ...); | |
} | |
template <typename... Args> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Require `Install-Module VSSetup -Scope CurrentUser` | |
function vsdev | |
{ | |
param( | |
[int] $Version = 16 # VS 2019 | |
) | |
$vspath = Get-VSSetupInstance | where { $_.InstallationVersion.Major -eq $Version } | select -first 1 -ExpandProperty InstallationPath | |
Import-Module "$vspath\Common7\Tools\Microsoft.VisualStudio.DevShell.dll" && Enter-VsDevShell -VsInstallPath $vspath -SkipAutomaticLocation -DevCmdArguments '-arch=x64' | |
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import sys | |
import scapy.all as s | |
pkt_bytes = [0x01, 0x00, 0x5e, 0x00, 0x00, 0xfb, 0x48, 0x4d, 0x7e, 0xb9, 0x4d, 0x34, 0x08, 0x00, 0x45, 0x00, 0x00, 0x6a, | |
0xae, 0x07, 0x40, 0x00, 0xff, 0x11, 0x8e, 0x1a, 0x0a, 0xa6, 0x53, 0xbf, 0xe0, 0x00, 0x00, 0xfb, 0x14, 0xe9, | |
0x14, 0xe9, 0x00, 0x56, 0xf6, 0x08, 0x00, 0x00, 0x00, 0x00, 0x00, 0x01, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, | |
0x05, 0xd7, 0x94, 0xd7, 0x99, 0x21, 0x00, 0x00, 0x0c, 0x00, 0x01, 0xc0, 0x0c, 0x00, 0x0c, 0x00, 0x01, 0x00, | |
0x00, 0x11, 0x94, 0x00, 0x20, 0x1d, 0x48, 0x50, 0x20, 0x4c, 0x61, 0x73, 0x65, 0x72, 0x4a, 0x65, 0x74, 0x20, | |
0x4d, 0x46, 0x50, 0x20, 0x4d, 0x36, 0x33, 0x30, 0x20, 0x5b, 0x43, 0x41, 0x43, 0x39, 0x31] |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
template <typename Func> | |
auto decorator(Func func) { | |
return [&]{ | |
std::cout << "Calling f():\n"; | |
func(); | |
}; | |
} | |
auto foo(fs::path filepath) { | |
auto func = [filepath] { | |
std::cout << filepath << "\n"; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Mounting current directory to C:/tmp inside Server 2016 docker image | |
docker run --mount src="$pwd",dst=C:/tmp/,type=bind -it mcr.microsoft.com/windows/servercore:ltsc2016 powershell |
OlderNewer