Skip to content

Instantly share code, notes, and snippets.

@ChunMinChang
ChunMinChang / README.md
Last active August 29, 2019 04:46
A counter examples for writing a share library

Duplicate symbol when compiling

We will have duplicate symbol for architecture x86_64 when we compile the programs as follows:

$ g++ -c -Wall bye.cpp   # Generate bye.o
$ g++ -c -Wall hello.cpp # Generate hello.o
$ g++ -Wall main.cpp bye.o hello.o -o run
duplicate symbol __Z3LOGNSt3__112basic_stringIcNS_11char_traitsIcEENS_9allocatorIcEEEE in:
    bye.o
# data from http://ec.europa.eu/eurostat/web/gisco/geodata/reference-data/population-distribution-demography/geostat
# Originally seen at http://spatial.ly/2014/08/population-lines/
# So, this blew up on both Reddit and Twitter. Two bugs fixed (southern Spain was a mess,
# and some countries where missing -- measure twice, submit once, damnit), and two silly superflous lines removed after
# @hadleywickham pointed that out. Also, switched from geom_segment to geom_line.
# The result of the code below can be seen at http://imgur.com/ob8c8ph
library(tidyverse)
@mbinna
mbinna / effective_modern_cmake.md
Last active May 30, 2025 01:10
Effective Modern CMake

Effective Modern CMake

Getting Started

For a brief user-level introduction to CMake, watch C++ Weekly, Episode 78, Intro to CMake by Jason Turner. LLVM’s CMake Primer provides a good high-level introduction to the CMake syntax. Go read it now.

After that, watch Mathieu Ropert’s CppCon 2017 talk Using Modern CMake Patterns to Enforce a Good Modular Design (slides). It provides a thorough explanation of what modern CMake is and why it is so much better than “old school” CMake. The modular design ideas in this talk are based on the book [Large-Scale C++ Software Design](https://www.amazon.de/Large-Scale-Soft

@dhicks
dhicks / mwe.R
Created July 10, 2018 19:02
Spatial Durbin Model
library(rstan)
## options(mc.cores = parallel::detectCores())
## Data should be here: <https://drive.google.com/open?id=1BUV8mChrZ0UkyW2G4EHB5wc1taUpMZUM>
load('mwe.Rdata')
## dataf: The data; response is `w_use`
## W_3nn: row-normalized spatial weights matrix, based on 3 nearest neighbors, in triplet sparse form
## W_dnn: row-normalized spatial weights matrix, distance-based, in triplet sparse form
parsed = stanc(file = 'sdm.stan', verbose = TRUE)