Skip to content

Instantly share code, notes, and snippets.

View plusangel's full-sized avatar
😁
happy coding!

angelos plastropoulos plusangel

😁
happy coding!
View GitHub Profile
@plusangel
plusangel / CMakeLists.txt
Created October 31, 2020 19:04
CMake dependent options
project(cmake_recipe01 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
# set(USE_LIBRARY OFF)
option(USE_LIBRARY "Compile sources into a library" OFF)
message(STATUS "Compile sources into a library? ${USE_LIBRARY}")
include(CMakeDependentOption)
cmake_dependent_option(
@plusangel
plusangel / CMakeLists.txt
Created October 31, 2020 11:25
CMake using conditionals
cmake_minimum_required(VERSION 3.17)
project(cmake_recipe01 LANGUAGES CXX)
set(CMAKE_CXX_STANDARD 14)
set(USE_LIBRARY ON)
message(STATUS "Compile sources into library? ${USE_LIBRARY}")
set(BUILD_SHARED_LIBS OFF)
list(APPEND _sources Message.h Message.cpp)
@plusangel
plusangel / notes.txt
Last active October 3, 2020 19:17
Byobu: basic shortcuts
byobu new -s embedded-cookbook
byobu list-sessions
byobu attach-session -t embedded-cookbook
byobu kill-session -t embedded-cookbook
F6 will detach your current Byobu session
F2 creates new windows within the current session.
F3 and F4 scroll left and right through the windows list.
F8 renames the current open window in the list
@plusangel
plusangel / CMakeLists.txt
Created June 13, 2020 18:02
Extensible factory template
cmake_minimum_required(VERSION 3.16)
project(factory_methods)
set(CMAKE_CXX_STANDARD 17)
add_library(shape_factory shape_factory.cpp)
add_executable(factory_method main.cpp)
target_link_libraries(factory_method shape_factory)
@plusangel
plusangel / CMakeLists.txt
Created June 6, 2020 17:37
Simple factory pattern example
cmake_minimum_required(VERSION 3.16)
project(factory_methods)
set(CMAKE_CXX_STANDARD 17)
add_library(shape_factory shape_factory.cpp)
add_executable(factory_method main.cpp)
target_link_libraries(factory_method shape_factory)
@plusangel
plusangel / CMakeLists.txt
Last active June 5, 2020 18:54
Monostate idiom example in C++
cmake_minimum_required(VERSION 3.16)
project(monostate_idiom)
set(CMAKE_CXX_STANDARD 17)
add_library(monostate monostate.cpp)
add_executable(monostate_idiom main.cpp)
target_link_libraries(monostate_idiom monostate)
@plusangel
plusangel / CMakeLists.txt
Last active June 5, 2020 18:54
Singleton idiom example in C++
cmake_minimum_required(VERSION 3.16)
project(singleton_idiom)
set(CMAKE_CXX_STANDARD 17)
add_library(singleton singleton.cpp)
add_executable(singleton_idiom main.cpp)
target_link_libraries(singleton_idiom singleton)
@plusangel
plusangel / CMakeLists.txt
Created June 2, 2020 18:45
This is an example of the pimpl idiom using smart pointers.
cmake_minimum_required(VERSION 3.16)
project(pimpl_idiom)
set(CMAKE_CXX_STANDARD 17)
add_library(timer timer.cpp)
add_executable(pimpl_idiom main.cpp)
target_link_libraries(pimpl_idiom timer)
//
// Tell me about your birthday!
// Created by angelos on 03/05/2020.
//
#include <ctime>
#include <iostream>
#include <string_view>
int validate_input(int lower_limit, int upper_limit, std::string_view prompt);
void year(tm &birthday);
@plusangel
plusangel / simple_calc.cpp
Created March 1, 2020 10:13
String handling using Boost's tokenizer
#define CATCH_CONFIG_MAIN
#include "catch.hpp"
#include <boost/tokenizer.hpp>
#include <iostream>
using namespace std::literals::string_literals;
int basic_calc(const std::string &input) {
boost::char_separator<char> operators{"+-*/"};