Skip to content

My beginnings with C++ - 12th project in the 42 Common Core Curriculum

Notifications You must be signed in to change notification settings

itislu/42-CPP_Modules

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

Table of Contents


📚 Resources

Description Type Link
Learn C++
A site with well structured lessons for absolute beginners. Goes over all concepts.
~300 short Lessons learncpp.com
C++ Overview using the C++98 Standard
One of the few tutorials using the C++98 standard.
~ 25 medium length Articles cplusplus.com
C++ Super-FAQ
A great FAQ about C++ ranging from newbie questions, learning C++ when coming from C, basic and advanced features of C++, coding standards to language updates.
FAQ (100s of questions) isocpp.org
C++ Core Guidelines written by Bjarne Stroustrup himself
Very useful to read about certain features of the language and for best practices, dos and don'ts.
Knowledge Base (~25 sections) isocpp.github.io
42 Intra eLearning Videos
Teaches the concepts needed for all modules. One video for each concept.
~40 Videos elearning.intra.42.fr
Harvard C++ Quick Overview over New Features compared to C
Concise introduction to C++ concepts with really clear code examples.
1 Article read.seas.harvard.edu
C++ tutorial for C users
A tutorial for C programmers who wish to learn C++, showing basic principles of C++. Lots of small code snippets.
1 Article ericbrasseur.org
C++ for C Programmers - University of California, Santa Cruz
A university professor goes over the benefits of C++ compared to C in a slow and easy to understand way.
Video (8h 44min) youtube.com
C++ Programming Wikibook
Easy to read, Wikipedia-style book. Great start when researching a new concept or feature.
Online-Book
(~650 pages)
wikibooks.org
A Tour of C++ - Book
A short book that serves as an overview of all of standard C++, written by Bjarne Stroustrup.
Book
(~200 pages)
PDF
C++ Primer (5th Edition) - Book
In-depth tutorial and reference book.
Book
(~900 pages)
PDF
The C++ Programming Language - Book
Hardcore reference book written by Bjarne Stroustrup.
Book
(~1300 pages)
PDF
C++ Weekly With Jason Turner
Weekly videos about C++ (and Computer Science in general).
400+ short-form Videos youtube.com

⚙️ Automatic labels of your commits for CPP modules monorepo

This alias automatically puts the numbers of the current CPP module and the current exercise at the very front as the scope of the commit. The numbers are extracted from the current directory.

Example:
You are in the directory cpp00/ex00 -> the scope would be 00/00.

The alias also conveniently formats your commit messages according to the Conventional Commits - first a keyword, then the message.
It puts the first argument as the type of the commit, everything else as the message. The type is usually one of the following: feat, fix, refactor, style, test, docs, chore. The message is a short description of the commit.

Usage

This is how you can use the alias:

git cml feat Convert program arguments to uppercase

Result:

[00/00] feat: Convert program arguments to uppercase

Setup

To set this alias up globally for your git configuration, run the following command.
If you prefer to set the alias up just for your CPP repository (so not globally across all repositories), simply remove the --global option.

git config --global alias.cml '!f() {
    local exercise_path=$(echo "$GIT_PREFIX" | sed '"'"'s/^..\///'"'"' | grep -oE '"'"'.*(/|^)ex[0-9]{2}(/|$)'"'"');
    local module=$(dirname "$exercise_path" | xargs basename | sed '"'"'s/^\.$//'"'"');
    local exercise=$(basename "$exercise_path");
    if [ -z "$module" ] && [ -z "$exercise" ]; then
        module=$(basename "$GIT_PREFIX");
    fi;
    local module_num=$(echo "$module" | grep -oE '"'"'[0-9]+'"'"');
    local exercise_num=$(echo "$exercise" | grep -oE '"'"'[0-9]{2}'"'"');
    local type=$1;
    shift;
    local message="$@";
    local scope="";
    if [ -n "$module_num" ] && [ -n "$exercise_num" ]; then
        scope="[$module_num/$exercise_num] ";
    elif [ -n "$module" ]; then
        scope="[$module] ";
    elif [ -n "$exercise" ]; then
        scope="[$exercise] ";
    fi;
    if [ -n "$message" ]; then
        git commit -m "$scope$type: $message";
    else
        git commit -m "$scope$type";
    fi;
}; f'

Pre-populate the scope in the commit message file

If you prefer to use git commit to edit your commit messages in your editor, you can use a git hook to automatically pre-populate the scope in the commit message file.

This means when you git commit, the file that opens already has the scope of your commit in the first line.

Setup

  1. Make sure you are in the root of your repository.

  2. Run the following command:

    cat << 'EOF' >> .git/hooks/prepare-commit-msg
    #!/bin/sh
    
    COMMIT_MSG_FILE=$1
    COMMIT_SOURCE=$2
    SHA1=$3
    
    # Remove the "# Please enter the commit message..." help message.
    /usr/bin/perl -i.bak -ne 'print unless(m/^. Please enter the commit message/..m/^#$/)' "$COMMIT_MSG_FILE"
    
    # Only use if it's a regular commit without -m or -F
    case "$2,$3" in
    	,|template,)
    		# Prepend the scope to the commit message file
    		exercise_path=$(echo "$GIT_PREFIX" | sed 's/^..\///' | grep -oE '.*(/|^)ex[0-9]{2}(/|$)')
    		module=$(dirname "$exercise_path" | xargs basename | sed 's/^\.$//')
    		exercise=$(basename "$exercise_path")
    		if [ -z "$module" ] && [ -z "$exercise" ]; then
    			module=$(basename "$GIT_PREFIX")
    		fi
    		module_num=$(echo "$module" | grep -oE '[0-9]+')
    		exercise_num=$(echo "$exercise" | grep -oE '[0-9]{2}')
    		scope=""
    		if [ -n "$module_num" ] && [ -n "$exercise_num" ]; then
    			scope="[$module_num/$exercise_num] "
    		elif [ -n "$module" ]; then
    			scope="[$module] "
    		elif [ -n "$exercise" ]; then
    			scope="[$exercise] "
    		fi
    		sed -i "1i$scope" "$COMMIT_MSG_FILE"
    		;;
    	*) ;;
    esac
    EOF
    chmod +x .git/hooks/prepare-commit-msg

About

My beginnings with C++ - 12th project in the 42 Common Core Curriculum

Resources

Stars

Watchers

Forks