Бля, что за пиздец

This commit is contained in:
Alexander Popov 2024-03-23 21:08:38 +03:00
commit 9b63bbef61
11 changed files with 159 additions and 3 deletions

View File

@ -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)

9
code/SFML/appIcon.cpp Normal file
View File

@ -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());
// ...

2
projects/AppImage/.gitignore vendored Normal file
View File

@ -0,0 +1,2 @@
MyApp.AppDir/usr/bin/myapp
MyApp.AppDir/myapp.svg

View File

@ -0,0 +1,5 @@
#!/bin/sh
touch ~/ololo.names
$APPDIR/usr/bin/myapp

View File

@ -0,0 +1,6 @@
[Desktop Entry]
Name=MyApp
Exec=myapp
Icon=myapp
Type=Application
Categories=Utility;

View File

9
projects/AppImage/build.sh Executable file
View File

@ -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

View File

@ -0,0 +1,34 @@
#include <GLFW/glfw3.h>
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;
}

View File

@ -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())

View File

@ -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))

View File

@ -23,7 +23,7 @@
<body>
<div class="video">
<h1>OpenCV Stream video to web browser/HTML page</h1>
<img class="video-frame" src="{{ url_for('video_feed') }}">
<img class="video-frame rounded" src="{{ url_for('video_feed') }}">
</div>
</body>
</html>