Skip to content

Instantly share code, notes, and snippets.

@jefftrull
jefftrull / gist:9d890f6fb67873351d16fb709e9811b2
Last active Apr 14, 2021
long double Boost Python conversion assembly output
View gist:9d890f6fb67873351d16fb709e9811b2
.section .text._Z11extract_fooIeET_N5boost6python3api6objectE,"axG",@progbits,long double extract_foo<long double>(boost::python::api::object),comdat
.p2align 4
.weak long double extract_foo<long double>(boost::python::api::object)
.type long double extract_foo<long double>(boost::python::api::object), @function
long double extract_foo<long double>(boost::python::api::object):
.LFB10151:
.cfi_startproc
.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
.cfi_lsda 0x1b,.LLSDA10151
endbr64
@jefftrull
jefftrull / gist:fc577f994cc613d5f371bad0ca618d26
Created Aug 12, 2020
telling clangd where to find my compile_commands.json
View gist:fc577f994cc613d5f371bad0ca618d26
(setq lsp-clients-clangd-args
(list (concat "--compile-commands-dir="
(projectile-project-root)
"build")
"--log=verbose"
"-j=1"
"--debug"
"--clang-tidy"
"--background-index")))
@jefftrull
jefftrull / tangle.org
Created Jul 28, 2019
org-babel demo from Emacs SF meetup 2019-07-24
View tangle.org

Brief intro to Source Code in Org

Required Setup

;; add support for C++ and Python
(org-babel-do-load-languages
  'org-babel-load-languages
  '((C . t) (python . t)))
View cxx_tangle.org

Testing C++ tangling from org-mode

View ja1.cpp
// std::vector<Eigen::VectorXf> -> Eigen::MatrixXf
#include <iostream>
#include <vector>
#include <Eigen/Dense>
int main() {
using namespace Eigen;
const int cols = 10;
const int rows = 10; // or do you get it from the sizes of each entry in *d?
std::vector<VectorXf> * d = new std::vector<VectorXf>(cols);
View ja1.cpp
// demonstrating use of Eigen::Map
#include <iostream>
#include <vector>
#include <Eigen/Dense>
int main() {
using namespace Eigen;
std::vector<float> foo{1.0, 2.0, 3.0, 4.0};
Map<Matrix<float, Dynamic, 1>> foom(foo.data(), foo.size());
IOFormat OctaveFmt(StreamPrecision, 0, ", ", ";\n", "", "", "[", "]");
@jefftrull
jefftrull / gist:f5d8ecb218815523f5d7af836eea8b9a
Created Apr 25, 2017
Cannot sort with boost::iterator::zip_iterator
View gist:f5d8ecb218815523f5d7af836eea8b9a
// experimenting with zip iterator and sort
#include <vector>
#include <iostream>
#include <boost/iterator/zip_iterator.hpp>
#include <boost/fusion/adapted/std_tuple.hpp>
using zip_it = boost::zip_iterator<std::tuple<std::vector<std::size_t>::iterator,
std::vector<std::size_t>::iterator,
@jefftrull
jefftrull / gist:983d783cf508249e5352de8e844a27cb
Created Sep 20, 2016
Interesting (possibly wrong) synthesized attribute behavior
View gist:983d783cf508249e5352de8e844a27cb
#include <iostream>
#include <boost/spirit/include/qi.hpp>
#include <boost/optional.hpp>
#include <boost/optional/optional_io.hpp>
int main() {
using namespace std;
// parsing parentheses that may or may not contain integers
string in("(10) () (20)");
@jefftrull
jefftrull / gist:0d7ecfef151c39885a7633d7547df8e6
Created Apr 18, 2016
*qi::string is compatible with both std::string (concatenation) and std::vector<std::string> (push_back) attributes
View gist:0d7ecfef151c39885a7633d7547df8e6
#include <string>
#include <vector>
#include <boost/spirit/include/qi.hpp>
using string_it_t = std::string::const_iterator;
int main() {
using namespace boost::spirit;
using namespace boost::spirit::qi;
@jefftrull
jefftrull / gist:2fbbd52a0dec25c1e14d1e69af3361ac
Created Apr 18, 2016
Spirit sequence-of-sequences: struct vs. string
View gist:2fbbd52a0dec25c1e14d1e69af3361ac
// To see if a rule whose attribute is sequence-of-sequence can make appends happen somehow
#include <string>
#include <vector>
#include <boost/spirit/include/qi.hpp>
#include <boost/fusion/include/adapt_struct.hpp>
struct tiny {
std::string thing;