Skip to content

Instantly share code, notes, and snippets.

View loginsmruti's full-sized avatar
🏠
Working from home

loginsmruti loginsmruti

🏠
Working from home
View GitHub Profile
@loginsmruti
loginsmruti / pub_sub_cpp.cpp
Created October 13, 2021 07:51 — forked from makomweb/pub_sub_cpp.cpp
Fun with C++: implementing a pub/sub scenario using std::bind and other standard facilities. The approach is pretty similar to the well known .NET event mechanism.
#include <iostream>
#include <map>
#include <algorithm>
#include <functional>
#include <memory>
using namespace std;
class EventArgs {
public:
@loginsmruti
loginsmruti / redis_cheatsheet.bash
Created October 30, 2019 07:10 — forked from LeCoupa/redis_cheatsheet.bash
Redis Cheatsheet - Basic Commands You Must Know --> UPDATED VERSION --> https://github.com/LeCoupa/awesome-cheatsheets
# Redis Cheatsheet
# All the commands you need to know
redis-server /path/redis.conf # start redis with the related configuration file
redis-cli # opens a redis prompt
# Strings.
@loginsmruti
loginsmruti / c++_cheat-sheet.md
Created October 21, 2019 15:22 — forked from rubienr/c++_cheat-sheet.md
C++ Cheat Sheet
@loginsmruti
loginsmruti / cheatsheet.cpp
Created October 21, 2019 15:06 — forked from satwikkansal/cheatsheet.cpp
C++ STL cheatsheet for competitive progrmming
/*
This a header file that includes every standard library.
You can use it to save time.
NOTE: This header file may not be recognized by compilers
other than gcc.
*/
#include <bits/stdc++.h>
/*
//Use this if the above header file doesn't work.
@loginsmruti
loginsmruti / RB-Tree.cpp
Created October 11, 2019 08:16 — forked from SubCoder1/RB-Tree.cpp
Red Black Tree implementation in C++
#include <bits/stdc++.h>
using namespace std;
struct node {
int data{};
node* left = nullptr;
node* right = nullptr;
node* parent = nullptr;
string color;
};
@loginsmruti
loginsmruti / executionTime.cpp
Created May 22, 2019 10:08 — forked from deysumitkr/ExecutionTime_AlmostGeneric.cpp
Execution time of a code snippet
#include <chrono>
auto start = std::chrono::high_resolution_clock::now();
// Code to time
auto finish = std::chrono::high_resolution_clock::now();
double duration = std::chrono::duration_cast<std::chrono::milliseconds>(finish - start).count();
@loginsmruti
loginsmruti / getFilesInDir.cpp
Created May 22, 2019 10:07 — forked from deysumitkr/getFilesInDir.cpp
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>
@loginsmruti
loginsmruti / binary-search-tree-cpp.cpp
Created September 14, 2017 11:25 — forked from mgechev/binary-search-tree-cpp.cpp
Simple implementation of binary search tree in C++.
#include <iostream>
#include <math.h>
using namespace std;
template <class T>
struct Node {
T value;
Node *left;
Node *right;