Skip to content

Instantly share code, notes, and snippets.

@unixod
unixod / settings.cpp
Created August 10, 2012 15:59
Settings class with "magic" enums (QSettings wrapper)
#include "settings.h"
#include <QSettings>
#include <QMetaEnum>
#include <QRegExp>
#include <QStringList>
Settings::Settings(){
const QMetaObject &mo = staticMetaObject;
int idx = mo.indexOfEnumerator("Key");
keys = mo.enumerator(idx);
@unixod
unixod / LLVM-IR-analysis.md
Last active September 23, 2018 19:02
LLVM IR analysis

Show hidden options

opt -help-hidden

How the set of passes '-O3' modifies IR.

$ opt -S -O3 file.ll
  • In order to use/access C library functions (such as memcmp, etc) use predefined function call emiters from instead of manully create/insert prototypes into llvm::Module;
@unixod
unixod / graphviz-tips.md
Last active April 23, 2019 06:21
Graphviz tips

Visualize a large graph

$ cat graph.gv | sfdp -Goverlap=prism -Goverlap_scaling=-10 -Tsvg -o out.svg

Consider the using together with cluster:

$ cat graph.gv | cluster | sfdp -Goverlap=prism -Goverlap_scaling=-10 -Tsvg -o out.svg
@unixod
unixod / nfa_to_dfa.h
Last active June 30, 2019 12:46
NFA to DFA (a part of not yet published library). For the entry point see a function makeDfa at the end of the file.
/*
* Copyright (c) 2019 Eldar Zakirov
*
* Dear Reader,
*
* This software can be freely used for any purposes that don't go against
* norms of Islam. Hence, this software shouldn't be used to implement, fix
* or improve the solutions for riba-based banks and other organizations
* that are prohibited in Islam.
*
@unixod
unixod / to_think.cpp
Last active October 29, 2019 09:22
Interesting case.
// This example is supposed to be compiled using C++17 standard.
#include <utility>
static_assert(__cpp_guaranteed_copy_elision);
struct X {
char k[17];
};