diff --git a/code/Python/ssl_expiry_datetime.py b/code/Python/ssl_expiry_datetime.py new file mode 100644 index 0000000..6b8102f --- /dev/null +++ b/code/Python/ssl_expiry_datetime.py @@ -0,0 +1,50 @@ +""" +https://stackoverflow.com/questions/41620369/how-to-get-ssl-certificate-details-using-python +""" + + +import socket +import ssl +import datetime + +domains = [ + 'iiiypuk.me', + 'a2s.su', + 'ya.ru' +] + + +def ssl_expiry_datetime(hostname): + ssl_dateformat = r'%b %d %H:%M:%S %Y %Z' + + context = ssl.create_default_context() + context.check_hostname = False + + conn = context.wrap_socket( + socket.socket(socket.AF_INET), + server_hostname=hostname, + ) + + # 5 second timeout + conn.settimeout(5.0) + + conn.connect((hostname, 443)) + ssl_info = conn.getpeercert() + + # Python datetime object + return datetime.datetime.strptime(ssl_info["notAfter"], ssl_dateformat) + + +if __name__ == "__main__": + for value in domains: + now = datetime.datetime.now() + try: + expire = ssl_expiry_datetime(value) + diff = expire - now + print( + "Domain name: {} Expiry Date: {} Expiry Day: {}".format( + value, expire.strftime("%Y-%m-%d"), diff.days + ) + ) + except Exception as e: + print(e) diff --git a/code/SFML/appIcon.cpp b/code/SFML/appIcon.cpp new file mode 100644 index 0000000..cca3cb6 --- /dev/null +++ b/code/SFML/appIcon.cpp @@ -0,0 +1,9 @@ +// ... +auto image = sf::Image{}; +if (!image.loadFromFile("cat.png")) +{ + // Error handling... +} + +window.setIcon(image.getSize().x, image.getSize().y, image.getPixelsPtr()); +// ... diff --git a/projects/AppImage/.gitignore b/projects/AppImage/.gitignore new file mode 100644 index 0000000..10d8a1c --- /dev/null +++ b/projects/AppImage/.gitignore @@ -0,0 +1,2 @@ +MyApp.AppDir/usr/bin/myapp +MyApp.AppDir/myapp.svg diff --git a/projects/AppImage/MyApp.AppDir/AppRun b/projects/AppImage/MyApp.AppDir/AppRun new file mode 100755 index 0000000..b5fcf21 --- /dev/null +++ b/projects/AppImage/MyApp.AppDir/AppRun @@ -0,0 +1,5 @@ +#!/bin/sh + +touch ~/ololo.names + +$APPDIR/usr/bin/myapp diff --git a/projects/AppImage/MyApp.AppDir/myapp.desktop b/projects/AppImage/MyApp.AppDir/myapp.desktop new file mode 100644 index 0000000..73aaf9e --- /dev/null +++ b/projects/AppImage/MyApp.AppDir/myapp.desktop @@ -0,0 +1,6 @@ +[Desktop Entry] +Name=MyApp +Exec=myapp +Icon=myapp +Type=Application +Categories=Utility; diff --git a/projects/AppImage/README.md b/projects/AppImage/README.md new file mode 100644 index 0000000..e69de29 diff --git a/projects/AppImage/build.sh b/projects/AppImage/build.sh new file mode 100755 index 0000000..72d08cf --- /dev/null +++ b/projects/AppImage/build.sh @@ -0,0 +1,9 @@ +#!/bin/sh + +# build executable +tcc example_app.c -lGL -lglfw -o MyApp.AppDir/usr/bin/myapp + +# build icon +# ICON=MyApp.AppDir/myapp.png +# [ ! -f $ICON ] && convert /usr/share/icons/breeze/apps/48/smartgit.svg -transparent white $ICON +cp /usr/share/icons/breeze/apps/48/smartgit.svg MyApp.AppDir/myapp.svg diff --git a/projects/AppImage/example_app.c b/projects/AppImage/example_app.c new file mode 100644 index 0000000..3762e30 --- /dev/null +++ b/projects/AppImage/example_app.c @@ -0,0 +1,34 @@ +#include + +int main(void) { + GLFWwindow *window; + + /* Initialize the library */ + if (!glfwInit()) + return -1; + + /* Create a windowed mode window and its OpenGL context */ + window = glfwCreateWindow(640, 480, "Hello World", NULL, NULL); + if (!window) { + glfwTerminate(); + return -1; + } + + /* Make the window's context current */ + glfwMakeContextCurrent(window); + + /* Loop until the user closes the window */ + while (!glfwWindowShouldClose(window)) { + /* Render here */ + glClear(GL_COLOR_BUFFER_BIT); + + /* Swap front and back buffers */ + glfwSwapBuffers(window); + + /* Poll for and process events */ + glfwPollEvents(); + } + + glfwTerminate(); + return 0; +} diff --git a/projects/CV/CapToRTMP/__main__.py b/projects/CV/CapToRTMP/__main__.py new file mode 100644 index 0000000..5d86e4c --- /dev/null +++ b/projects/CV/CapToRTMP/__main__.py @@ -0,0 +1,42 @@ +import subprocess +import cv2 +rtmp_url = "rtmp://127.0.0.1:1935/stream/pupils_trace" + +# In my mac webcamera is 0, also you can set a video file name instead, for example "/home/user/demo.mp4" +path = 0 +cap = cv2.VideoCapture(path) + +# gather video info to ffmpeg +fps = int(cap.get(cv2.CAP_PROP_FPS)) +width = int(cap.get(cv2.CAP_PROP_FRAME_WIDTH)) +height = int(cap.get(cv2.CAP_PROP_FRAME_HEIGHT)) + +# command and params for ffmpeg +command = ['ffmpeg', + '-y', + '-f', 'rawvideo', + '-vcodec', 'rawvideo', + '-pix_fmt', 'bgr24', + '-s', "{}x{}".format(width, height), + '-r', str(fps), + '-i', '-', + '-c:v', 'libx264', + '-pix_fmt', 'yuv420p', + '-preset', 'ultrafast', + '-f', 'flv', + rtmp_url] + +# using subprocess and pipe to fetch frame data +p = subprocess.Popen(command, stdin=subprocess.PIPE) + + +while cap.isOpened(): + ret, frame = cap.read() + if not ret: + print("frame read failed") + break + + # YOUR CODE FOR PROCESSING FRAME HERE + + # write to pipe + p.stdin.write(frame.tobytes()) diff --git a/projects/Python/OpenCV_to_HTML/motion_detection.py b/projects/Python/OpenCV_to_HTML/motion_detection.py index cfc0253..b881b8b 100644 --- a/projects/Python/OpenCV_to_HTML/motion_detection.py +++ b/projects/Python/OpenCV_to_HTML/motion_detection.py @@ -47,6 +47,5 @@ class SingleMotionDetector: (x, y, w, h) = cv2.boundingRect(c) (minX, minY) = (min(minX, x), min(minY, y)) (maxX, maxY) = (max(maxX, x + w), max(maxY, y + h)) - # otherwise, return a tuple of the thresholded image along - # with bounding box + # otherwise, return a tuple of the thresholded image along with bounding box return (thresh, (minX, minY, maxX, maxY)) diff --git a/projects/Python/OpenCV_to_HTML/templates/index.html b/projects/Python/OpenCV_to_HTML/templates/index.html index ea195cb..2675c52 100644 --- a/projects/Python/OpenCV_to_HTML/templates/index.html +++ b/projects/Python/OpenCV_to_HTML/templates/index.html @@ -23,7 +23,7 @@

OpenCV – Stream video to web browser/HTML page

- +