8000 GitHub - giik/write: Collection of writings about stuff related to math, coding, and engineering. · GitHub
[go: up one dir, main page]

Skip to content
giikPublic

About

Collection of writings about stuff related to math, coding, and engineering.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Latest commit

 

History

5 Commits

Folders and files

NameName
Last commit message
Last commit date
 
 
 
 

Repository files navigation

Table of Contents

TODO: Need to figure this out.

Prologue

Collection of writings about stuff related to math, coding, and engineering.

About C++

Do Fold Expressions Shortcut?

It wasn't vey clear to me whether fold expressions (introduced in C++17) shortcut, e.g., when the fold's binary operator is logical and && or logical or ||. They should be due to the fact that the operators && and || shortcut themselves, and, here is an example to demonstrate that yes, fold expressions shortcut (also Compiler Explorer link):

#include <iostream>

bool g(int x) {
  std::cout << "g(" << x << ") is evaluated" << std::endl;
  return x % 2 == 0;
}

template <typename... Vs> bool all_even(Vs... vs) {
  return (... && g(vs));
}

int main() { return all_even(4, 7, 2, 0); }

Also note: because of the sequence point requirement for the first (left) operand of either && or || the order of evaluation of the expressions is always the same, left to right:

// left-fold requires that (E1 op E2) is evaluated first so the order is E1, E2,
// E3
(E1 op E2) op E3

// right fold requires that E1 is evaluated first so the order is E1, E2, E3
E1 op (E2 op E3)

About Go

Nothing yet.

MacOs Setup

How I setup my MacBook Pro M1 (13-inch, 2020), Apple Silicon, to work they way I wanted it.

Install Software

  • Install Xcode from the App Store;

    • also install the command line tools.
  • Install QLMarkdown to be able to use the Apple Quick Look feature to preview files, specifically *.md and *.markdown files as rendered markdown and not the source. Works really well so far!

  • Install MacPorts by downloading the package installer directly from http://www.macports.org/install.php, make sure to get the Big Sur version v2.7.1.

  • Use MacPorts to install emacs, I mostly use it command line mode. It is installed in /opt/local/bin/emacs.

    • Enable packages in emacs (see MELPA), make sure to enable normal and stable versions; if only stable is enabled you will not see many packages

    • Install markdown mode.

    • Install a few color themes.

    • Install the clang-format package so I can format C and C++ files. It didn't work right out of the box because it could not find the clang-format binary so I had to figure out how to get this. Downloaded clang v12.0, then copied just clang-format to the MacPorts bin directory using

      sudo cp ~/Downloads/clang+llvm-12.0.0-x86_64-apple-darwin/bin/clang-format /opt/local/bin
      

      As expected, needed to approve running it in the Security & Privacy preferences. TODO: this is still not fully functional, the formatting works on the command line but not in emacs, apparently some sort of config file needs to be generated. Will try and follow these instructions.

    • Set up Authy (app from Twillio) for 2FA for Github. A bit of a mess, but mostly worked. Need to figure out how to cache the token in the keychain so I don't have to enter it every time I git push.

  • Install the GitHub gh CLI. This is not necessary if you want to use git

    • brew install gh to install
    • gh auth login after installation; might have to update the ~/.ssh/known_hosts to the GitHub's SSH key fingerprints and generate the required classic authentication token if you don't have one already (see the complete instructions on Testing your SSH connection).

About

Collection of writings about stuff related to math, coding, and engineering.

Resources

Stars

0 stars

Watchers

1 watching

Forks

Releases

Packages

Contributors

0