Skip to content

Instantly share code, notes, and snippets.

View TheBarbellCoder's full-sized avatar
😎
Happily Coding

Avinash C. Ravi Shankar TheBarbellCoder

😎
Happily Coding
View GitHub Profile
@TheBarbellCoder
TheBarbellCoder / test.hpp
Last active July 20, 2020 13:52
Macro Definitions
#include <iomanip>
#include <iostream>
#define BEGIN_TEST(TestSuite, TestName) \
bool test__##TestSuite##__##TestName(void) \
{ \
bool isTrue{true};
#define END_TEST \
return isTrue; \
@TheBarbellCoder
TheBarbellCoder / test.cpp
Last active July 28, 2020 13:34
Sample test case
#include "test.hpp"
// Function to add two integers
int addIntegers(const int& a, const int& b)
{
return a + b;
}
// Test case to check commutative property of addIntegers
BEGIN_TEST(AddProps, Commutative)
@TheBarbellCoder
TheBarbellCoder / test.hpp
Last active July 20, 2020 13:46
Creash-proof testing
#include <sys/types.h>
#include <sys/wait.h>
#include <iostream>
#include <cstdlib>
#define BEGIN_TEST(TestSuite, TestName) \
bool test__##TestSuite##__##TestName(void) \
{ \
bool ret; \
pid_t pid = fork(); \
@TheBarbellCoder
TheBarbellCoder / test_expanded.cpp
Last active July 28, 2020 15:36
Test Case after Macro Expansion
bool test__TestSuite__TestName()
{
bool isTrue{true};
{
isTrue &= (arg1 == arg2);
}
return isTrue;
}
@TheBarbellCoder
TheBarbellCoder / kd_tree.py
Last active November 4, 2020 16:55
Insert a node to a kd-tree.
def insert(point, node, sDim, tDims):
"""Inserts the point to the given tree
Args:
point (tuple) : Coordinates to insert to the tree
node (Node) : Parent node of the tree to compare
sDim (Integer) : Splitting / cutting dimension of the input node
tDims (Integer) : Total number of dimensions
Returns:
Node after insertion
@TheBarbellCoder
TheBarbellCoder / kd_tree.py
Last active October 24, 2020 07:44
Node class to store 2d-points
class Node:
""" A binary-tree node class to store 2d-points"""
def __init__(self, point, left_node, right_node):
"""Class initializations
Args:
point (tuple) : Integer tuple with coordinates
left_node (Node, optional) : Node to attach as the left child
right_node (Node, optional) : Node to attach as the right child
"""
@TheBarbellCoder
TheBarbellCoder / kd_tree.py
Last active November 4, 2020 16:51
Find the node with min value at the given spliting dimension
def find_min(node, dim, sDim, tDims):
"""Finds the node with minimum value in the given dimension
Args:
node (Node) : Entry node to begin search for the min node
dim (Integer) : Dimension to search for the minimum
sDim (Integer) : Splitting / cutting dimension of the input node
tDims (Integer) : Total number of dimensions
Returns:
Point (tuple) with minimum value in the given dimension
"""
@TheBarbellCoder
TheBarbellCoder / kd_tree.py
Last active November 4, 2020 16:51
Delete a node from the kd-tree
def delete(point, node, sDim, tDims):
"""Deletes the given point from the tree
Args:
point (tuple) : Coordinates to delete
node (Node) : Entry node to start the search for the coordinates
sDim (Integer) : Splitting / cutting dimension of the input node
tDims (Integer) : Total number of imensions
Returns:
Input node after deletion
@TheBarbellCoder
TheBarbellCoder / puzl-demo-config.yaml
Last active December 9, 2020 19:05
Kubernetes config file to set up a pod and a volume to run projects
# Setup volume claim
apiVersion: v1
kind: PersistentVolumeClaim
metadata:
name: puzl-volume
spec:
accessModes:
- ReadWriteOnce
resources:
requests:
@TheBarbellCoder
TheBarbellCoder / hello_world.cpp
Created February 3, 2021 16:00
Hello World program in C++
#include <iostream>
int main()
{
std::cout << "Hello World" << std::endl;
return 0;
}