Skip to content

Instantly share code, notes, and snippets.

View markhc's full-sized avatar
🏠
Working from home

Marcelo Conceição markhc

🏠
Working from home
View GitHub Profile
@markhc
markhc / main.py
Last active May 20, 2024 21:51
poe div card gamba simulator
#
# python3 main.py startingStack=4 maxStack=9 strat=one winningAmount=300 maxRuns=10000
#
import sys
import random
import time
debug = False
ssh-rsa AAAAB3NzaC1yc2EAAAADAQABAAABAQDLvcICeFH79XX9op7kFxW74HK4TLHuAarbazmwEtzFUZAc52qI6N5OntoNRxMoPF4W/LphWQKYS9lOMnHcjUjnrMAq6MCc5xn2BRfHRuLjCFAfin5DSrA9IG9xxV5Fiuf6dQEFtPq3JjiDe20ZRUl/yGmy/yoJE2QfeZhJ2NBiSkeoQU4b3JlX2vtu1PkK7+TZEE2Z+7hMgzyjy/5pcdBCUo3X48Dae2GY5s+dgSSmzrCHlTN4/H2Y9sBlOLWUE2scVcC8dOyI/2m0snX8C/M7vgZGu23KQ+Z6NYxXOIB6KYh5fQShH+v9wZeHBSKIX6jXHwQ86p3JZSA436Ghbt1f root@srv1
@markhc
markhc / day7.cs
Last active December 7, 2019 15:43
var phaseSetting = new int[] { 0, 1, 2, 3, 4 };
var maxThrusters = UInt64.MinValue;
do {
var vms = phaseSetting
.Select(x => new Intcode((int[])memory.Clone(), x.ToString()))
.ToArray();
var signal = "0";
while (!vms.Last().HasFinished) {
@markhc
markhc / aoc_2019_1.cpp
Created December 2, 2019 04:11
Solution for day 1 of AoC using C++
std::string run(std::string input) override
{
using namespace ranges;
auto const not_empty = [](auto&& l) { return !l.empty(); };
auto const to_integer = [](auto&& l) { return std::stoi(l); };
auto const calc_fuel = [](auto&& mass) {
auto fuel = mass / 3 - 2;
auto fuelMass = fuel;
@markhc
markhc / va.cpp
Created September 25, 2019 01:36
///
/// directoryTableBase is the CR3 register value for the target process (the process that owns virtualAddress)
/// virtualAddress is the address to translate
///
std::uint64_t driver::translate_linear_address(std::uint64_t directoryTableBase, LPVOID virtualAddress)
{
auto va = (std::uint64_t)virtualAddress;
auto PML4 = (USHORT)((va >> 39) & 0x1FF); //<! PML4 Entry Index
auto DirectoryPtr = (USHORT)((va >> 30) & 0x1FF); //<! Page-Directory-Pointer Table Index
Warning: include-what-you-use reported diagnostics:
/home/markhc/Coding/tenshi/include/tenshi/client.hpp should add these lines:
#include <stdint.h> // for uint32_t
#include <boost/asio/detail/socket_types.hpp> // for asio
#include <boost/asio/impl/io_context.ipp> // for io_context::~io_context
#include <boost/asio/io_context.hpp> // for io_context
#include <boost/asio/ssl/context.hpp> // for context
#include <boost/asio/ssl/context_base.hpp> // for context_base::sslv23_c...
#include <boost/asio/ssl/impl/context.ipp> // for context::~context, con...
#include "tenshi/gateway.hpp"
#include <fmt/format.h>
#include <spdlog/spdlog.h>
#include <boost/beast/core/buffers_to_string.hpp>
#include <boost/bind.hpp>
#include <nlohmann/json.hpp>
namespace tenshi
{
using namespace std::literals;
void fail(beast::error_code ec, char const* what)
{
// TODO: Better error logging
std::cerr << what << ": " << ec.message() << "\n";
}
// -------------------------------------------------------------------------------------------------
Gateway::Gateway(net::io_context& ioc, ssl::context& ctx)
: ws_(net::make_strand(ioc), ctx),
resolver_(net::make_strand(ioc)),
host_("gateway.discord.gg"s),
std::string Board::prettyPrint(bool useUnicodeChars) const
{
std::string_view charPieces[2][6] = {
{
useUnicodeChars ? "\u2659" : "P",
useUnicodeChars ? "\u2657" : "B",
useUnicodeChars ? "\u2658" : "N",
useUnicodeChars ? "\u2656" : "R",
useUnicodeChars ? "\u2655" : "Q",
useUnicodeChars ? "\u2654" : "K",
@markhc
markhc / CMakeLists.txt
Last active July 16, 2019 13:10
fmtlib + cmake
cmake_minimum_required (VERSION 3.12)
# not strictly needed, but it helps when you forget to pass the CMAKE_TOOLCHAIN_FILE as argument to cmake
if(DEFINED ENV{VCPKG_ROOT} AND NOT DEFINED CMAKE_TOOLCHAIN_FILE)
set(CMAKE_TOOLCHAIN_FILE
"$ENV{VCPKG_ROOT}/scripts/buildsystems/vcpkg.cmake"
CACHE STRING "")
endif()
project(cmake_example CXX)