Skip to content

Instantly share code, notes, and snippets.

View klemens-morgenstern's full-sized avatar

Klemens Morgenstern klemens-morgenstern

View GitHub Profile
@klemens-morgenstern
klemens-morgenstern / stubbing.cpp
Created February 18, 2016 12:15
C++ stubbing via --wrap
//_ZN1X1fEv
struct stubs
{
typedef void(stubs::*_ZN1X1fEv_t)();
static _ZN1X1fEv_t _ZN1X1fEv_p;
template<typename T, typename ... Args>
static void set__ZN1X1fEv(void (T::*p)(Args...))
{
_ZN1X1fEv_p = reinterpret_cast<_ZN1X1fEv_t>(p);
#include <system_error>
#include <iostream>
#include <cstring>
#include <boost/type_index/ctti_type_index.hpp>
#include <boost/utility/in_place_factory.hpp>
#include <boost/utility/typed_in_place_factory.hpp>
#include <boost/hana/front.hpp>
#include <boost/hana/back.hpp>
/*
* ChaiScriptSyntaxHighlighter.cpp
*
* Created on: 21.10.2016
* Author: klemens.morgenstern
*/
#include <widgets/ChaiScriptSyntaxHighlighter.hpp>
namespace widgets
/*
* ChaiScriptSyntaxHighlighter.hpp
*
* Created on: 21.10.2016
* Author: klemens.morgenstern
*/
#ifndef WIDGETS_CHAISCRIPTSYNTAXHIGHLIGHTER_HPP_
#define WIDGETS_CHAISCRIPTSYNTAXHIGHLIGHTER_HPP_
#ifndef CTLEX_HPP
#define CTLEX_HPP
#include <ctre.hpp>
#include <string_view>
#include <algorithm>
#include <stdexcept>
namespace ctlex
{
@klemens-morgenstern
klemens-morgenstern / generate.py
Last active June 30, 2020 07:07
Generate a location database using pyelftools
# usage python generate.py <binary>
from elftools.elf.elffile import ELFFile
from elftools.elf.sections import SymbolTableSection
import json
import sys
import os
with open(sys.argv[1], "rb") as binary:
@klemens-morgenstern
klemens-morgenstern / interpret.py
Created June 30, 2020 07:09
Interpret a log output based on a location database
# usage python generate_loc_db.py <database>
import sys
import json
# We will read from stdin, for simplicity sake
# Load the previously generated data from the json
db = None
with open(sys.argv[1]) as f:
@klemens-morgenstern
klemens-morgenstern / constexpr_join_array.cpp
Created August 27, 2015 19:09
A simple way to join two arrays constexpr
namespace detail
{
template<std::size_t ... Size>
struct num_tuple
{
};
template<std::size_t Prepend, typename T>
struct appender {};
#include <iostream>
#include <boost/asio.hpp>
#include <boost/mysql.hpp>
using namespace boost;
struct printer
{
template<typename T>
//
// boost/utility/cstring_view.hpp
// ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
//
// Copyright (c) 2022 Klemens D. Morgenstern
// (klemens dot morgenstern at gmx dot net)
//
// Distributed under the Boost Software License, Version 1.0. (See accompanying
// file LICENSE_1_0.txt or copy at http://www.boost.org/LICENSE_1_0.txt)
//