Skip to content

Instantly share code, notes, and snippets.

View Harold2017's full-sized avatar
๐Ÿ˜ƒ

Harold Harold2017

๐Ÿ˜ƒ
View GitHub Profile
@Harold2017
Harold2017 / Dockfile
Last active November 18, 2019 03:39
OpenAcc docker image with gcc 9, cuda 10, OpenCV on ubuntu 18.04
FROM nvidia/cuda:10.1-devel-ubuntu18.04
MAINTAINER Harold
# GCC 9
RUN apt-get update && apt-get install -y software-properties-common
RUN add-apt-repository ppa:ubuntu-toolchain-r/test && \
apt update && \
apt install -y gcc-9-offload-nvptx g++-9 && \
update-alternatives --install /usr/bin/gcc gcc /usr/bin/gcc-9 60 --slave /usr/bin/g++ g++ /usr/bin/g++-9
@Harold2017
Harold2017 / bench.txt
Created December 12, 2019 02:27 — forked from rodaine/bench.txt
Code snippets for my blog post "The X-Files: Avoiding Concurrency Boilerplate with golang.org/x/sync"
BenchmarkMutexCache/10-8 10000000 180 ns/op 0 B/op 0 allocs/op
BenchmarkMutexCache/100-8 10000000 187 ns/op 0 B/op 0 allocs/op
BenchmarkMutexCache/1000-8 10000000 214 ns/op 0 B/op 0 allocs/op
BenchmarkMutexCache/10000-8 10000000 231 ns/op 0 B/op 0 allocs/op
BenchmarkMutexCache/100000-8 5000000 254 ns/op 2 B/op 0 allocs/op
BenchmarkMutexCache/1000000-8 1000000 1159 ns/op 102 B/op 1 allocs/op
BenchmarkMutexCache/10000000-8 1000000 1481 ns/op 184 B/op 2 allocs/op
BenchmarkMutexCache/100000000-8 1000000 1655 ns/op 187 B/op 3 allocs/op
BenchmarkSyncMapCache/10-8 5000000 221 ns/op 0 B/op 0 allocs/op
C++ 3 hrs 24 mins โ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–ˆโ–โ–‘โ–‘ 87.7%
JSON 15 mins โ–ˆโ–โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 6.7%
CMake 12 mins โ–ˆโ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 5.3%
Other 0 secs โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 0.2%
C 0 secs โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘โ–‘ 0.1%
@Harold2017
Harold2017 / vcpkg.md
Last active June 16, 2020 08:28
vcpkg on mac
# install vcpkg
git clone https://github.com/Microsoft/vcpkg
cd vcpkg
./bootstrap-vcpkg.sh -disableMetrics
sudo ln -s /xxx/vcpkg/vcpkg /usr/local/bin
vcpkg help

# use it in CMakeLists.txt
set(ENV{VCPKG_ROOT} "/xxx/vcpkg/vcpkg")
@Harold2017
Harold2017 / tcmalloc on windows.md
Created July 11, 2020 04:01
tcmalloc on window

cmake

compile libtcmalloc_minimal with Release-Patch

link libtcmalloc_minimal.lib in CMakeList

copy libtcmalloc_minimal.dll to execution folder

without cmake

@Harold2017
Harold2017 / homebrew.md
Created August 17, 2020 04:56
replace brew default src with ustc mirror
@Harold2017
Harold2017 / fitting3D.cpp
Created August 24, 2020 03:39 — forked from ialhashim/fitting3D.cpp
Fitting 3D points to a plane or a line
template<class Vector3>
std::pair<Vector3, Vector3> best_plane_from_points(const std::vector<Vector3> & c)
{
// copy coordinates to matrix in Eigen format
size_t num_atoms = c.size();
Eigen::Matrix< Vector3::Scalar, Eigen::Dynamic, Eigen::Dynamic > coord(3, num_atoms);
for (size_t i = 0; i < num_atoms; ++i) coord.col(i) = c[i];
// calculate centroid
Vector3 centroid(coord.row(0).mean(), coord.row(1).mean(), coord.row(2).mean());
mysql> create database db_name;
mysql> use db_name;
mysql> set autocommit=0;
mysql> source dump_file.sql;
mysql> commit;
@Harold2017
Harold2017 / Eigen Cheat sheet
Created September 23, 2020 02:09 — forked from gocarlos/Eigen Cheat sheet
Cheat sheet for the linear algebra library Eigen: http://eigen.tuxfamily.org/
// A simple quickref for Eigen. Add anything that's missing.
// Main author: Keir Mierle
#include <Eigen/Dense>
Matrix<double, 3, 3> A; // Fixed rows and cols. Same as Matrix3d.
Matrix<double, 3, Dynamic> B; // Fixed rows, dynamic cols.
Matrix<double, Dynamic, Dynamic> C; // Full dynamic. Same as MatrixXd.
Matrix<double, 3, 3, RowMajor> E; // Row major; default is column-major.
Matrix3f P, Q, R; // 3x3 float matrix.
@Harold2017
Harold2017 / qt-without-xcode.md
Created November 22, 2020 09:26 — forked from shoogle/qt-without-xcode.md
Qt without XCode - how to use Qt Creator for macOS software development without installing XCode

Qt without Xcode

How to use Qt Creator for software development on macOS without having to install Xcode

Justification

Qt refuses to install on macOS unless Apple's Xcode is installed beforehand. This is unfortunate because: