Skip to content

Instantly share code, notes, and snippets.

@gglin001
gglin001 / glibc.cmake
Created July 2, 2022 14:34 — forked from likema/glibc.cmake
CMake macro to detect glibc version by filename.
# - Check glibc version
# CHECK_GLIBC_VERSION()
#
# Once done this will define
#
# GLIBC_VERSION - glibc version
#
MACRO (CHECK_GLIBC_VERSION)
EXECUTE_PROCESS (
COMMAND ${CMAKE_C_COMPILER} -print-file-name=libc.so.6
@gglin001
gglin001 / markdown-details-collapsible.md
Created December 3, 2021 03:04 — forked from pierrejoubert73/markdown-details-collapsible.md
How to add a collapsible section in markdown.

A collapsible section containing markdown

Click to expand!

Heading

  1. A numbered
  2. list
    • With some
    • Sub bullets
@gglin001
gglin001 / download_glue_data.py
Created November 23, 2021 09:40 — forked from W4ngatang/download_glue_data.py
Script for downloading data of the GLUE benchmark (gluebenchmark.com)
''' Script for downloading all GLUE data.
Note: for legal reasons, we are unable to host MRPC.
You can either use the version hosted by the SentEval team, which is already tokenized,
or you can download the original data from (https://download.microsoft.com/download/D/4/6/D46FF87A-F6B9-4252-AA8B-3604ED519838/MSRParaphraseCorpus.msi) and extract the data from it manually.
For Windows users, you can run the .msi file. For Mac and Linux users, consider an external library such as 'cabextract' (see below for an example).
You should then rename and place specific files in a folder (see below for an example).
mkdir MRPC
cabextract MSRParaphraseCorpus.msi -d MRPC
@gglin001
gglin001 / CMakeLists.txt
Created November 5, 2021 06:56 — forked from baiwfg2/CMakeLists.txt
How to use add_custom_target and add_custom_command correctly in cmake
# References:
# https://cmake.org/cmake/help/latest/command/add_custom_target.html
# https://samthursfield.wordpress.com/2015/11/21/cmake-dependencies-between-targets-and-files-and-custom-commands/
# https://gist.github.com/socantre/7ee63133a0a3a08f3990
# https://stackoverflow.com/questions/24163778/how-to-add-custom-target-that-depends-on-make-install
# https://stackoverflow.com/questions/30719275/add-custom-command-is-not-generating-a-target
# https://stackoverflow.com/questions/26024235/how-to-call-a-cmake-function-from-add-custom-target-command
# https://blog.csdn.net/gubenpeiyuan/article/details/51096777
cmake_minimum_required(VERSION 3.10)
@gglin001
gglin001 / wireguard-over-tcp.md
Created November 2, 2021 06:38
WireGuard over TCP with udptunnel

WireGuard over TCP with udptunnel

udptunnel is a small program which can tunnel UDP packets bi-directionally over a TCP connection. Its primary purpose (and original motivation) is to allow multi-media conferences to traverse a firewall which allows only outgoing TCP connections.

Server

# udptunnel -s 443 127.0.0.1/51820

Client

@gglin001
gglin001 / fix_exfat_drive.md
Created September 19, 2021 04:52 — forked from scottopell/fix_exfat_drive.md
Fix corrupted exFAT disk macOS/OSX

exFAT support on macOS seems to have some bugs because my external drives with exFAT formatting will randomly get corrupted.

Disk Utility is unable to repair this at first, but the fix is this:

  1. Use diskutil list to find the right drive id.
  2. You want the id under the IDENTIFIER column, it should look like disk1s1
  3. Run sudo fsck_exfat -d <id from above>. eg sudo fsck_exfat -d disk1s3
  4. -d is debug so you'll see all your files output as they're processed.
  5. Answer YES if it gives you the prompt Main boot region needs to be updated. Yes/No?
@gglin001
gglin001 / unfollow-all.md
Created September 4, 2021 15:48 — forked from xeloader/unfollow-all.md
Unfollow everyone on LinkedIn

Unfollow everyone on Social Media

Unfollow everyone on LinkedIn

LinkedIn is even more clickbait than Facebook nowadays. Adios. 💣

Visit https://www.linkedin.com/feed/following/

Scroll down to load all of your contacts

Open developer console, run the following

@gglin001
gglin001 / use_gold.sh
Created August 31, 2021 10:23 — forked from unhammer/use_gold.sh
Linking with lld on Ubuntu/Debian in CMake projects (or gold in automake projects)
sudo apt install binutils
cd ~/src/an_autotools_project
export CXXFLAGS='-fuse-ld=gold'
export CFLAGS='-fuse-ld=gold'
./configure
make -j4 # no longer wait for linking! =D
# gcc doesn't support -fuse-ld=lld http://gcc.gnu.org/ml/gcc-patches/2016-07/msg00145.html :(
@gglin001
gglin001 / cmake.py
Last active May 17, 2021 12:19
pytorch_edit_cmake.py
...
# old
def convert_cmake_value_to_python_value(cmake_value, cmake_type):
r"""Convert a CMake value in a string form to a Python value.
Args:
cmake_value (string): The CMake value in a string form (e.g., "ON", "OFF", "1").
cmake_type (string): The CMake type of :attr:`cmake_value`.

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