Skip to content

Instantly share code, notes, and snippets.

View deysumitkr's full-sized avatar

Sumit Kumar Dey deysumitkr

View GitHub Profile
@deysumitkr
deysumitkr / NetworkBoot.md
Last active October 22, 2020 06:35
Network booting and installing ubuntu

Network Boot Steps (PXE)


Network Architecture

@deysumitkr
deysumitkr / ConsoleLogging.c
Last active November 5, 2019 16:45
Console Log
// Console logging
#define RED "\x1B[31m"
#define GREEN "\x1B[32m"
#define CYAN "\x1B[36m"
#define RESET "\x1B[0m"
#define __FILENAME__ (strrchr(__FILE__, '/') ? strrchr(__FILE__, '/') + 1 : __FILE__)
#define LOG_FORMATTED(COLOR, FORMATTED_MSG, ...) fprintf(stderr, COLOR "[My Lib] %s() in [%s:%i] " RESET FORMATTED_MSG "\n", __func__, __FILENAME__, __LINE__, ##__VA_ARGS__)
#define LOG_FORMATTED_INFO(FORMATTED_MSG, ...) LOG_FORMATTED(CYAN, FORMATTED_MSG, ##__VA_ARGS__)
@deysumitkr
deysumitkr / CMakeLists.txt
Created April 19, 2019 18:12
List all variables available in cmake
# List all variables and values in cmake
get_cmake_property(_variableNames VARIABLES)
list (SORT _variableNames)
foreach (_variableName ${_variableNames})
message(STATUS "${_variableName}=${${_variableName}}")
endforeach()
@deysumitkr
deysumitkr / cvMat_pointer_access.cpp
Created August 8, 2018 10:55
Pointer access to opencv Mat
Mat img = imread("filename.jpg",CV_LOAD_IMAGE_COLOR);
unsigned char *input = (unsigned char*)(img.data);
int r,g,b;
for(int i = 0;i < img.cols;i++){
for(int j = 0;j < img.rows;j++){
b = input[img.cols * j + i ] ;
g = input[img.cols * j + i + 1];
r = input[img.cols * j + i + 2];
}
@deysumitkr
deysumitkr / ExecutionTime_AlmostGeneric.cpp
Last active November 5, 2019 15:56
Execution time of a code snippet
#include <chrono>
#include <utility>
/**
* @brief find execution time of a function with non-void return type
*
* @tparam F function signature in form return_type(args...). Eg: double(int, int, char*)
* @tparam R set clock resolution from chrono clock (default = std::chrono::microseconds)
* @tparam Args varidac typenames for function arguments
* @param dt execution time as per resolution given in R
@deysumitkr
deysumitkr / sayIP.py
Last active November 19, 2017 13:02
python script that says IP address. (Fail safe in case avahi-daemon fails/unusable)
"""
Dependency:
Python 2.7
festival (can be downloaded from apt-get)[http://www.cstr.ed.ac.uk/projects/festival/]
Raspberry pi audio device select:
amixer cset numid=3 0 # auto select (inaccurate)
amixer cset numid=3 1 # analog jack 3.5mm
amixer cset numid=3 2 # HDMI
@deysumitkr
deysumitkr / AnnotateImages.cpp
Last active December 30, 2017 06:34
Mark points, lines, boxes (rectangles) or polygons on Images - (OpenCV required) [Example at bottom]
//
// Created by sumit on 20/9/17.
//
#include "Annotate.h"
// ----------- draw --------------
template <> void Annotate<cv::Point_<int>>::draw(cv::Mat &showImage) {
for(int i=0; i<mArray.size(); i++)
@deysumitkr
deysumitkr / getFilesInDir.cpp
Last active March 7, 2023 08:53
get all files in directory - may filter by extension - may recurse - (Boost required)
// usage
std::vector<std::string> exts{".jpg", ".png"};
std::vector<std::string> files = getFilesInDir("/path/to/root/directory/", exts, true);
// --------------------------------------------------------
#define BOOST_FILESYSTEM_NO_DEPRECATED
#include <boost/filesystem.hpp>