Skip to content

Instantly share code, notes, and snippets.

View oclero's full-sized avatar

Olivier Cléro oclero

View GitHub Profile
@oclero
oclero / MacOsTerminalUtilities.md
Created December 6, 2021 16:42
MacOS Terminal Utilities

MacOS Terminal Utilities

Get OS version

sw_vers

Output:

ProductName: Mac OS X
@oclero
oclero / CMakeMtUtils.md
Created December 8, 2021 15:27
CMake utility for mt.exe (Windows)
# Find mt.exe and creates executable target 'Win10::Mt'.
function(find_mt)
  set(MT_TARGET_NAME Win10::Mt)

  if(NOT TARGET ${MT_TARGET_NAME})
    find_program(MT_TARGET_EXE
      NAME "mt.exe"
      PATHS "C:/Program Files (x86)/Windows Kits/10/bin/${CMAKE_VS_WINDOWS_TARGET_PLATFORM_VERSION}/${CMAKE_VS_PLATFORM_TOOLSET_HOST_ARCHITECTURE}"
      NO_DEFAULT_PATH
@oclero
oclero / BitwardCliCheatsheet.md
Created December 10, 2021 09:55
Bitwarden CLI Cheatsheet

Bitwarden CLI Cheatsheet

Copy password to clipboard

bw get password github | Set-Clipboard
@oclero
oclero / PrintSizesInPixels.md
Last active February 22, 2022 14:02
Print sizes in pixels (cheatsheet)

Print sizes in pixels

Portrait

Sizes are displayed as: Width * Height, both in pixels, unless specified otherwise.

Format 150dpi 300dpi 600dpi 1200dpi
A5 (148 * 210 mm) 877 * 1240 1754 * 2480 3508 * 4960 7016 * 9920
A4 (210 * 297 mm) 1240 * 1754 2480 * 3508 4960 * 7016 9920 * 14032
@oclero
oclero / CppConstructorsCheatsheet.md
Last active January 3, 2022 09:24
C++ Constructors Cheatsheet

C++ Constructors Cheatsheet

Legend:

  • 3️⃣ Rule of 3: if a class implements any of these 3 methods, it should implement all 3 of them. The goal is to ensure the correct management of the class member data.
  • 5️⃣ Rule of 5: extension of Rule of 3. Allows for optimized usage (no copies) of the class.

0️⃣ Rule of 0: These constructors and operators are not require when you don't declare any of them and make usage of existing types that support the appropriate copy/move semantics.

It's the rule of "All or Nothing".

@oclero
oclero / CppIteratorsCheatsheet.md
Created January 3, 2022 10:03
C++ Iterators Cheatsheet

C++ Iterators Cheatsheet

Iterator categories

  • Input Iterator (immutable): once, forward, read-only
  • Output Iterator (mutable): once, foward, write-only
  • Forward Iterator (mutable): forward, read/write
  • Bidirectionnal Iterator (mutable): forward/backwards, read/write
  • Random Access Iterator (mutable): jump around, read/write
  • Contiguous Iterator:
@oclero
oclero / CppBinaryOperationsCheatsheet.md
Created January 3, 2022 10:28
C++ Binary Operations Cheatsheet

C++ Binary Operations Cheatsheet

Values

Base 10 Base 2
0 0b
1 1b
2 10b
3 11b
@oclero
oclero / CppSingleProducerSingleConsumer.cpp
Created January 3, 2022 10:37
C++ Single Producer / Single Consumer
std::cond_var cond;
std::mutex mutex;
std::queue<int> queue;
auto finished = false;
std::thread producer([&cond, &mutex, &queue, &finished](){
// Add data to the queue.
auto steps = 100;
while (steps) {
std::lock_guard<std::mutex> lock{ mutex };
@oclero
oclero / CppTreeSearchCheatsheet.md
Created January 3, 2022 10:54
Tree Search in C++

Tree Search in C++

Depth-Search First (DFS)

Recursive

void search(Node& root) {
  // 1. Visit node.
  visit(node);
@oclero
oclero / GitSubmodules.md
Last active July 7, 2023 16:17
Git Submodules

To initialize:

git submodule update --init --recursive

To get latest commits:

git submodule update --init --remote --recursive