Skip to content

Instantly share code, notes, and snippets.

View baileywickham's full-sized avatar
👓

Bailey Wickham baileywickham

👓
View GitHub Profile
@baileywickham
baileywickham / Dockerfile
Created June 20, 2020 19:47
Docker for ssh
# Stolen from the docker website
FROM ubuntu
RUN apt-get update && apt-get install -qq openssh-server python
RUN mkdir /var/run/sshd
RUN echo 'root:testpass' | chpasswd
RUN sed -i 's/#PermitRootLogin prohibit-password/PermitRootLogin yes/' /etc/ssh/sshd_config
RUN sed 's@session\s*required\s*pam_loginuid.so@session optional pam_loginuid.so@g' -i /etc/pam.d/sshd
ENV NOTVISIBLE "in users profile"
@baileywickham
baileywickham / metaclasses.py
Last active September 23, 2020 04:58
Metaclasses in python
# Create classes based on csv file data
with open("file.csv", 'r') as f:
header = f.readline().split(',')
metaclass = type('csv', (object,), {h:None for h in header})
for line in f.readlines():
m = metaclass()
line = line.split(',')
for i in range(len(header)):
setattr(m, header[i], line[i])
yield m # Return as generator
def get_data(func, message):
while True:
try:
tmp = input(message)
tmp = func(tmp)
except:
print(f"Input not of type: {func.__name__}")
else:
return tmp