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 / .gitlab-ci.yml
Last active February 18, 2021 05:09
Cross-platform build with docker executor
docker_x86_build:
stage: build
tags:
- x86
- docker
before_script:
- apt-get update && apt-get upgrade -y
- apt-get install gcc-aarch64-linux-gnu g++-aarch64-linux-gnu -y
script:
- aarch64-linux-gnu-g++ hello_world.cpp -o HelloWorld
@TheBarbellCoder
TheBarbellCoder / .gitlab-ci.yml
Last active February 11, 2021 13:44
HelloWorld program cross-compiled on an x86 device and tested on a Pi
x86_aarch64_build:
stage: build
tags:
- x86-aarch64
script:
- aarch64-linux-gnu-g++ hello_world.cpp -o HelloWorld
artifacts:
paths:
- HelloWorld
@TheBarbellCoder
TheBarbellCoder / .gitlab-ci.yml
Last active February 11, 2021 13:40
.gitlab-ci.yml to build and run HelloWorld over SSH
ssh_build_and_run:
stage: build
tags:
- ssh
script:
- g++ hello_world.cpp -o HelloWorld
- ./HelloWorld
artifacts:
paths:
- build/HelloWorld
@TheBarbellCoder
TheBarbellCoder / CMakeLists.txt
Created February 3, 2021 16:04
CMake script to compile HelloWorld
cmake_minimum_required(VERSION 3.10.2)
project("GitLab Runner Demo"
DESCRIPTION "Demonstrate GitLab Runner"
LANGUAGES CXX)
add_executable(HelloWorld ${CMAKE_SOURCE_DIR}/hello_world.cpp)
@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;
}
@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 / 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 / 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 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: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