Skip to content

Instantly share code, notes, and snippets.

jefftrull / gist:9d890f6fb67873351d16fb709e9811b2
Last active April 14, 2021 17:50
long double Boost Python conversion assembly output
.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):
.cfi_personality 0x9b,DW.ref.__gxx_personality_v0
.cfi_lsda 0x1b,.LLSDA10151
jefftrull / gist:fc577f994cc613d5f371bad0ca618d26
Created August 12, 2020 01:42
telling clangd where to find my compile_commands.json
(setq lsp-clients-clangd-args
(list (concat "--compile-commands-dir="
jefftrull /
Created July 28, 2019 20:41
org-babel demo from Emacs SF meetup 2019-07-24

Brief intro to Source Code in Org

Required Setup

;; add support for C++ and Python
  '((C . t) (python . t)))

Testing C++ tangling from org-mode

// 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);
// 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.size());
IOFormat OctaveFmt(StreamPrecision, 0, ", ", ";\n", "", "", "[", "]");
jefftrull / gist:f5d8ecb218815523f5d7af836eea8b9a
Created April 25, 2017 17:25
Cannot sort with boost::iterator::zip_iterator
// 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,
jefftrull / gist:983d783cf508249e5352de8e844a27cb
Created September 20, 2016 05:36
Interesting (possibly wrong) synthesized attribute behavior
#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 / gist:0d7ecfef151c39885a7633d7547df8e6
Created April 18, 2016 16:06
*qi::string is compatible with both std::string (concatenation) and std::vector<std::string> (push_back) attributes
#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 / gist:2fbbd52a0dec25c1e14d1e69af3361ac
Created April 18, 2016 03:21
Spirit sequence-of-sequences: struct vs. string
// 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;