Skip to content

Instantly share code, notes, and snippets.

View jordan-carson's full-sized avatar
🌎
Off Planet

Jordan Carson jordan-carson

🌎
Off Planet
View GitHub Profile
@jordan-carson
jordan-carson / secrets.cmd
Created December 4, 2021 19:46
setting secrets in powershell - terminate once session finishes
@echo OFF
set POWERSHELL_SCRIPT=^
$securePwd = Read-Host "Enter passphrase" -AsSecureString; ^
$plainPwd =[Runtime.InteropServices.Marshal]::PtrToStringAuto([Runtime.InteropServices.Marshal]::SecureStringToBSTR($securePwd));^
Write-Host $plainPwd
for /f %%a in ('powershell -Command "&{%POWERSHELL_SCRIPT%}"') do (
set "USER_SECRET=%%~a"
set "ARTIFACTS_SECRET=%%~a"
)
@jordan-carson
jordan-carson / binary_search_tree.py
Created January 11, 2020 17:36
Binary Search Tree Implementation
class Node:
"""
Simple class definition for a Node, in case of trees where nodes may have more
than two children, a `children` list could be used to contain these references instead.
The important thing to note about this representation is that the attributes
`left` and `right` will become references to other instances of the `Node` class.
For example, when we insert a new left child into the tree we create another
instance of `Node` and modify `self.left` in the root to reference the new
@jordan-carson
jordan-carson / linked_list_implementation_python.py
Last active January 8, 2020 03:50
Linked List Implementation Python - Simple yet elegant implementation of a Linked List in python. Will update with more soon.
import numpy as np
class Node:
def __init__(self, value):
self.value = value
self.next = None
class DoubleNode:
def __init__(self, value):
@jordan-carson
jordan-carson / disk_space.py
Last active November 2, 2019 19:32
Readable Disk Space Usage in Python
import os
import collections
_ntuple_diskusage = collections.namedtuple('usage', 'total used free')
__doc__ = """
Function to return the disk usage for a given path. Works for both Windows & Linux/MaxOS systems.
Returns:
Named Tuple: (usage.total, usage.used, usage.free)
"""
class BaseDataStructure:
def __init__(self):
self._items = []
def isEmpty(self):
return self._items == []
def peek(self):
return self._items[len(self._items) - 1]