Skip to content

Instantly share code, notes, and snippets.

@kumailxp
kumailxp / unique-ptr-test.cpp
Created March 31, 2024 15:20
different unique pointer tests
#include <string>
#include <memory>
#include <iostream>
#include <vector>
#include <optional>
#include <mutex>
#include <chrono>
#include <ctime>
#include <thread>
@kumailxp
kumailxp / menu.sh
Created November 5, 2021 13:22
menu control with bash
#! /bin/bash
NC='\033[0m' # No Color
L_GREEN='\033[1;32m'
L_RED='\033[1;31m'
B_YELLOW='\033[1;39;43m'
# move one key up: \r\e[1A
#include <string>
#include <sstream>
#include <iostream>
struct Shape {
virtual std::string str() const = 0;
};
struct Circle : Shape {
float radius;
@kumailxp
kumailxp / iterator_Example.cpp
Created August 21, 2018 19:01
implementing an iterator
//============================================================================
// Name : class_02.cpp
// Author : Kumail Ahmed
// Version :
// Copyright : Your copyright notice
// Description : Hello World in C++, Ansi-style
//============================================================================
#include <iostream>
#include <iterator>
@kumailxp
kumailxp / levenschtein.cpp
Last active July 19, 2018 09:56
calculate levenschtein distance and find possible match in vector
#include<iostream>
#include<vector>
#include<map>
#include<algorithm>
#include<iterator>
#include <fstream>
#include <cstdlib>
#include <chrono>
using namespace std;
@kumailxp
kumailxp / thread-compare.cpp
Created July 18, 2018 10:54
comparison between using thread vs non-thread and STL accumulate algorithm vs simple for loop
#include<iostream>
#include<thread>
#include <random>
#include <chrono>
using namespace std;
class Timer
{
// make things readable
using clk = std::chrono::steady_clock;
@kumailxp
kumailxp / shared_ptr_inheritance_example.cpp
Created July 18, 2018 09:31
Example of using shared_ptr with inheritance
#include<iostream>
#include<memory>
#include<vector>
using namespace std;
class A {
private:
int val;
public: