Skip to content

Instantly share code, notes, and snippets.

@caiorss
caiorss / CMakeLists.txt
Last active November 5, 2021 07:39
Sample TCP/IP with TLS encapsulation
cmake_minimum_required(VERSION 3.9)
project(Sample_SLL)
#========== Global Configurations =============#
#----------------------------------------------#
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_VERBOSE_MAKEFILE ON )
#----------- Set targets -------------------------------#
@caiorss
caiorss / ptrace-attach.cpp
Created December 4, 2020 22:18
Ptrace attach sample code for tracing system calls of running processes
#include <iostream>
#include <string>
#include <sstream>
#include <cstring> // memcpy, memset, ...
#include <cassert> // assert() statement
#include <vector>
#include <functional>
#include <map>
// --- Unix-specific headers -----//
@caiorss
caiorss / CMakeLists.txt
Created November 27, 2020 14:05
QuickJS engine sample project - shows how to embedded in C++
cmake_minimum_required(VERSION 3.9)
project(QuickJS-Experiment)
#========== Global Configurations =============#
#----------------------------------------------#
set( CMAKE_CXX_STANDARD 17 )
set( CMAKE_VERBOSE_MAKEFILE ON )
set( CMAKE_CXX_EXTENSIONS OFF)
@caiorss
caiorss / sock-client1.cpp
Created November 4, 2020 18:29
Simple TCP/IP client socket
#include <iostream>
#include <cassert> // Use: assert() for marking placeholders for future error handling.
#include <string> // std::string
#include <cstring> // memcpy, memset and so on
// ----- Unix/Linux headers -----//
#include <unistd.h>
#include <fcntl.h>
#include <sys/types.h>
#include <sys/socket.h>
@caiorss
caiorss / shmem1.cpp
Created November 1, 2020 18:58
Experiment code for POSIX Shared memory IPC on Unix systems
#include <iostream>
#include <string>
#include <cassert>
#include <cstring>
// ----- Unix and Posix headers ---//
#include <unistd.h>
#include <sys/types.h>
#include <sys/mman.h>
@caiorss
caiorss / inotify-test.cpp
Created October 27, 2020 18:49
Linux-only Inotify API sample code
#include <iostream>
#include <string>
#include <cstring> // strerror()
#include <memory>
#include <cassert>
#include <map>
// ---- Unix-specific headers ----------//
#include <unistd.h>
#include <limits.h>
@caiorss
caiorss / CMakeLists.txt
Created October 26, 2020 15:13
Xlib X11 query windows information
cmake_minimum_required(VERSION 3.9)
project(X11-Xtoll-Project)
#========== Global Configurations =============#
#----------------------------------------------#
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_VERBOSE_MAKEFILE ON)
find_package(X11 REQUIRED)
@caiorss
caiorss / CMakeLists.txt
Last active October 18, 2020 17:22
Xlib demo - X11 X Windows System
cmake_minimum_required(VERSION 3.9)
project(Simple_Cmake_Project)
#========== Global Configurations =============#
#----------------------------------------------#
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_VERBOSE_MAKEFILE ON)
find_package(X11 REQUIRED)
@caiorss
caiorss / linux-info.cpp
Created October 10, 2020 20:43
Sample C++ code for getting system info via virtual file system
/* Summary: Gets Linux runtime information from VSF virtual file system.
*
*/
#include <iostream>
#include <fstream>
#include <sstream>
#include <string>
#include <iomanip> // std::seprecision, std::fixed
// See: https://man7.org/linux/man-pages/man2/sysinfo.2.html
@caiorss
caiorss / CMakeLists.txt
Last active July 8, 2020 20:09
Sample multi-command CLI - command line application
cmake_minimum_required(VERSION 3.9)
project(cliapp)
#========== Global Configurations =============#
#----------------------------------------------#
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_VERBOSE_MAKEFILE ON)
set(CMAKE_CXX_EXTENSIONS OFF)