Skip to content

Instantly share code, notes, and snippets.

View mridulgain's full-sized avatar
👨‍💻
Tech it easy

Mridul Gain mridulgain

👨‍💻
Tech it easy
View GitHub Profile
@mridulgain
mridulgain / stack.py
Created November 18, 2023 16:37
stack implementation using python list
class Stack:
def __init__(self):
self.items = []
def is_empty(self):
return len(self.items) == 0
def push(self, item):
self.items.append(item)
@mridulgain
mridulgain / bin_file_ops.py
Created November 18, 2023 16:36
binary file handeling using python pickel
import pickle
def write_binary_file(filename, data):
with open(filename, 'wb') as file:
pickle.dump(data, file)
print(f"Data written to {filename}.")
def read_binary_file(filename):
try:
with open(filename, 'rb') as file:
@mridulgain
mridulgain / csv_file_ops.py
Created November 18, 2023 16:36
csv file handeling using python
import csv
def write_to_csv(filename, data):
with open(filename, 'w', newline='') as csvfile:
# Create a CSV writer object
csv_writer = csv.writer(csvfile)
# Write a single row
csv_writer.writerow(["Name", "Age", "City"])
@mridulgain
mridulgain / txt_file_ops.py
Last active November 18, 2023 16:40
text file operations
def write_to_text_file(filename, data):
with open(filename, 'w') as file:
# Write a single line
file.write("Header: Name, Age, City\n")
# Write multiple lines
for line in data:
file.write(','.join(map(str, line)) + '\n')
print(f"Data written to {filename}.")
@mridulgain
mridulgain / .bash_aliases
Last active November 9, 2023 12:42
bash aliases additions
alias k=kubectl
alias kctx=kubectx
alias kns=kubens
# alias kx='f() { [ "$1" ] && kubectx $1 && kprompt || kubectx ; } ; f'
# alias kn='g() { [ "$1" ] && kns $1 && kprompt || kns ; } ; g'
@mridulgain
mridulgain / .bashrc
Created November 9, 2023 12:40
My .bashrc additions
# go
export PATH=$PATH:$(go env GOPATH)/bin
# java
export JAVA_HOME=/usr/lib/jvm/java-8-openjdk-amd64
# kubebuilder autocompletion
if [ -f /usr/local/share/bash-completion/bash_completion ]; then
. /usr/local/share/bash-completion/bash_completion
fi
. <(kubebuilder completion bash)
@mridulgain
mridulgain / test profile snippet - local chart.yaml
Last active January 19, 2024 07:58
use local chart in input profile
HubChartOptions:
Release: kubeslice-controller
Chart: "/home/avesha/office_lab/helm charts/dev-charts/charts/kubeslice-controller"
LocalChart: true
Namespace: kubeslice-controller
SetStrValues:
"kubeslice.controller.logLevel": "debug"
@mridulgain
mridulgain / profile.yaml
Created October 16, 2023 05:12
profile example
Kubeconfig: mainconfig.yaml
ControllerCluster:
Context: oss-mc-br-e2e-1
HubChartOptions:
Release: kubeslice-controller
Chart: kubeslice-controller
Repo: "https://kubeslice.github.io/kubeslice/"
Namespace: kubeslice-controller
SetStrValues:
"kubeslice.controller.logLevel": "debug"