Skip to content

Instantly share code, notes, and snippets.

View vicradon's full-sized avatar
🥑
creating technical content

Osinachi Chukwujama vicradon

🥑
creating technical content
View GitHub Profile
@vicradon
vicradon / create-a-cosmos-db-doc.ts
Created August 19, 2023 08:03
Create a new document in a cosmos db container using an extra outputs binding
import {
app,
HttpRequest,
HttpResponseInit,
InvocationContext,
output,
} from "@azure/functions";
const cosmosDBOutput = output.cosmosDB({
connection: "CosmosDBConnection",
@vicradon
vicradon / source_rvm.sh
Created August 10, 2023 12:44
A way to source rvm when switching ruby version
source $(rvm 3.1.2 do rvm env --path)
@vicradon
vicradon / array-diff.rs
Last active June 2, 2023 05:05
Rust snippets
/**
* This program finds the difference between two arrays.
* It essentially removes elements from the first array that are present in the second array.
*/
use std::collections::HashSet;
use std::hash::Hash;
use std::iter::FromIterator;
fn array_diff<T: PartialEq + std::clone::Clone>(a: Vec<T>, b: Vec<T>) -> Vec<T>
where
@vicradon
vicradon / simple-linear-regression-model.py
Created May 21, 2023 15:41
A python script that calculates the weights necessary for a simple linear regression prediction model
'''
In this program, we implement a simple linear regression ML model
that tries to find weights that will match the input tensor x to
the output tensor y in a multiplication operation
'''
import torch
x = torch.tensor(1.0)
y = torch.tensor(2.0)
@vicradon
vicradon / find-number-of-files.sh
Created April 3, 2023 04:28
This script finds the number of each file type excluding the node_modules and .git subfolders.
find . ! -path "*/node_modules/*" ! -path "*/.git/*" -type f | awk -F. '{print $NF}' | sort | uniq -c
###########################
# Persistent Volume Claim
###########################
kind: PersistentVolume
apiVersion: v1
metadata:
name: postgres-pv
namespace: argo
# labels:
# type: local
# Definition for a binary tree node.
# class TreeNode:
# def __init__(self, val=0, left=None, right=None):
# self.val = val
# self.left = left
# self.right = right
class Solution:
def widthOfBinaryTree(self, root: Optional[TreeNode]) -> int:
'''
{
class Solution:
def letterCasePermutation(self, s: str) -> List[str]:
output = []
def recur(ptr, buildup):
if ptr >= len(s):
output.append(buildup)
return
if s[ptr].isalpha():
class Solution:
def spiralOrder(self, matrix: List[List[int]]) -> List[int]:
directions = [(0, 1), (1, 0), (0, -1), (-1, 0)]
ROWS, COLS = len(matrix),len(matrix[0])
visited = set()
ptr = 0
pos = (0, 0)
output = [matrix[0][0]]
for _ in range(ROWS * COLS - 1):
@vicradon
vicradon / access websites through ssh on localhost.md
Last active May 29, 2024 03:13
Forward a remote port to local machine

ssh -L localport:localhost:remoteport username@hostip

e.g. ssh -L 9000:localhost:36839 azureuser@52.186.170.39

You can then access the website on your local machine on this url http://localhost:9000

If you need to use a private key file, then do

ssh -i ./path-to-private-key-file -L localport:localhost:remoteport username@hostname