Skip to content

Instantly share code, notes, and snippets.

View kwk's full-sized avatar

Konrad Kleine kwk

View GitHub Profile
@kwk
kwk / JsonRpcModule.php
Created July 9, 2012 14:35
Base class for RPC modules that provides getMethods() functionality.
<?php
/**
* This is the base class for all Json RPC Modules.
*
* @author Konrad Kleine (kwk)
*/
abstract class JsonRpcModule {
/**
* Returns the methods available in the concrete RPC Module implementation.
* All final public methods are returned this way:
@kwk
kwk / CMakeLists.txt
Last active February 14, 2024 08:53
Fix for "undefined reference to dlopen" in CMake projects
project(testlink)
add_executable(testlink main.cpp)
target_link_libraries(testlink)
@kwk
kwk / gist:3609801
Created September 3, 2012 14:42
mvn package failed on gerrit-2.4
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Gerrit Code Review - Parent
[INFO] Gerrit Code Review - Utility - SSL
[INFO] Gerrit Code Review - Patch commons-net
[INFO] Gerrit Code Review - Patch JGit
[INFO] Gerrit Code Review - Utility - CLI
[INFO] Gerrit Code Review - ANTLR
@kwk
kwk / gist:3978806
Created October 30, 2012 07:35
(Gerrit) Output of "mvn package"
kleine@mrburns:~/Kunden/GeneralPublic/gerrit (master %)$ mvn package
[INFO] Scanning for projects...
[INFO] ------------------------------------------------------------------------
[INFO] Reactor Build Order:
[INFO]
[INFO] Gerrit Code Review - Parent
[INFO] Gerrit Code Review - Utility - SSL
[INFO] Gerrit Code Review - Patch commons-net
[INFO] Gerrit Code Review - Patch JGit
[INFO] Gerrit Code Review - Utility - CLI
@kwk
kwk / CMakeLists.txt
Last active December 30, 2015 11:39
This parses a Person in the form "Some Name" 123 into a simple struct. `123` is the person's age. I know that his is overly complicated but I want to utilize the setter methods on the `Person` object to have more fine-grained control over the way my `Person` object is being modified. Here, this is just for showing how it can be done. Oh yeah, I …
project(inherited_attribute)
cmake_minimum_required(VERSION 2.8)
add_executable(inherited_attribute boost-spirit-inherited-attribute.cpp)
@kwk
kwk / get_flename_of_decl.cxx
Last active March 28, 2017 20:56
Get filename/path of clang::Decl
static const clang::FileEntry * getFileEntryForDecl(const clang::Decl * decl, clang::SourceManager * sourceManager)
{
if (!decl || !sourceManager) {
return 0;
}
clang::SourceLocation sLoc = decl->getLocation();
clang::FileID fileID = sourceManager->getFileID(sLoc);
return sourceManager->getFileEntryForID(fileID);
}
@kwk
kwk / clang_get_init_value_of_expr.cpp
Created March 7, 2014 11:52
How to get the value of a Clang variable initialization
// clang::VarDecl * varDecl;
// clang::ASTContext & ctx;
const clang::Expr * initializerExpr = varDecl->getInit();
llvm::APSInt result;
if (initializerExpr->EvaluateAsInt(result, ctx)) {
std::cout << "Value as string: " << result.toString(10) << std::endl;
}
@kwk
kwk / CMakeLists.txt
Last active June 9, 2018 17:55
Print the current date + time in UTC using boost::date_time
cmake_minimum_required(VERSION 2.8.8)
project(datetime)
find_package(Boost COMPONENTS date_time REQUIRED)
include_directories(${Boost_INCLUDE_DIRS})
add_executable(datetime datetime.cpp)
target_link_libraries(datetime ${Boost_LIBRARIES})
@kwk
kwk / CMakeLists.txt
Last active April 3, 2021 18:17
Standalone Clang project (outside of LLVM and Clang source tree)
cmake_minimum_required(VERSION 2.8.8)
project(interface_class_printer)
option(BUILD_INTERFACE_CLASS_PRINTER "Build the tool that converts a C++ interface class into a C struct." ON)
mark_as_advanced(BUILD_INTERFACE_CLASS_PRINTER)
if (BUILD_INTERFACE_CLASS_PRINTER)
# Find boost
find_package(Boost COMPONENTS date_time REQUIRED)
@kwk
kwk / Makefile
Last active March 17, 2024 22:54
Compiling with Address Sanitizer (ASAN) with CLANG and with GCC-4.8
.PHONY: using-gcc using-gcc-static using-clang
using-gcc:
g++-4.8 -o main-gcc -lasan -O -g -fsanitize=address -fno-omit-frame-pointer main.cpp && \
ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=$(shell which llvm-symbolizer) ./main-gcc
using-gcc-static:
g++-4.8 -o main-gcc-static -static-libstdc++ -static-libasan -O -g -fsanitize=address -fno-omit-frame-pointer main.cpp && \
ASAN_OPTIONS=symbolize=1 ASAN_SYMBOLIZER_PATH=$(shell which llvm-symbolizer) ./main-gcc-static