Skip to content

Instantly share code, notes, and snippets.

View Harold2017's full-sized avatar
😃

Harold Harold2017

😃
View GitHub Profile
@Harold2017
Harold2017 / cov_mat.md
Last active July 18, 2019 04:47
Correct way to calculate covariance matrix

Covariance Matrix Calculation

homemade cov function for 3d points:

#include "iostream"
#include "arrayfire.h"
@Harold2017
Harold2017 / Storing-Images-On-Github.md
Created August 9, 2019 05:16 — forked from joncardasis/Storing-Images-On-Github.md
Storing Images and Demos in your Repo

Storing Images and Demos in your Repo

In this quick walkthough you'll learn how to create a separate branch in your repo to house your screenshots and demo gifs for use in your master's readme.

How to

1. Clone a fresh copy of your repo

In order to prevent any loss of work it is best to clone the repo in a separate location to complete this task.

2. Create a new branch

Create a new branch in your repo by using git checkout --orphan assets

@Harold2017
Harold2017 / Octave.md
Created September 10, 2019 04:31
Install Octave on Ubuntu 18.04

Install Octave with flatpak

  • Install flatpak sudo apt-get install flatpak
  • Add flathub flatpak remote-add --if-not-exists flathub https://flathub.org/repo/flathub.flatpakrepo
  • Install Octave flatpak install flathub org.octave.Octave
@Harold2017
Harold2017 / simpleShell.go
Created November 4, 2019 07:41
simple shell in golang
package main
import (
"bufio"
"fmt"
"os"
"os/exec"
"strings"
)
@Harold2017
Harold2017 / bits.go
Created November 12, 2019 12:48
bit operation in golang
package bits
// from `strconv.Iota`
const host32bit = ^uint(0)>>32 == 0
const host64bit = ^uint(0)>>64 == 0
const intSize = 32 << (^uint(0) >> 63)
const shiftToSign = intSize - 1
// Sign returns 1 for positive, -1 for negative and 0 for 0
func Sign(x int) int {
@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
@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