Skip to content

Instantly share code, notes, and snippets.

View M0nteCarl0's full-sized avatar
evolve or repeat

Alex M0nteCarl0

evolve or repeat
View GitHub Profile
@M0nteCarl0
M0nteCarl0 / DQE_MTF.py
Created August 3, 2023 08:03
DQE_MTF example
import numpy as np
from scipy.fft import fft2
from scipy.ndimage import sobel, gaussian_filter
from PIL import Image
def compute_dqe(image_path):
# Load the X-ray image
image = Image.open(image_path).convert("L")
image = np.array(image)
@M0nteCarl0
M0nteCarl0 / parser_pwned_passwd.go
Created August 2, 2023 06:49
parser pwned_passwd
package main
import (
"crypto/sha1"
"fmt"
"io/ioutil"
"net/http"
"os"
"strings"
)
@M0nteCarl0
M0nteCarl0 / Cupy_CPA.py
Created August 1, 2023 14:11
SIMON Cipher CPA
import cupy as cp
from tqdm import tnrange
@cp.fuse()
def rol32(x, n):
return (x << n | x >> (32 - n))
@cp.fuse()
def simon_round_function(x):
return (rol32(x, 1) & rol32(x, 8)) ^ rol32(x, 2)
@M0nteCarl0
M0nteCarl0 / sqlite_task.c
Created July 31, 2023 18:34
SQLlite task for fetch data from database and write to textual file
#include <iostream>
#include <fstream>
#include <string>
#include <vector>
#include "sqlite3.h"
using namespace std;
// Функция обработки результатов запроса к базе данных
static int callback(void* data, int argc, char** argv, char** azColName) {
@M0nteCarl0
M0nteCarl0 / connection manger_HighLoad.go
Last active July 31, 2023 17:14
Golang connection manager
package main
import (
"fmt"
"sync"
)
// ConnectionManager интерфейс определяет методы для управления соединениями
type ConnectionManager interface {
AddConnection(connection Connection)
@M0nteCarl0
M0nteCarl0 / client.go
Last active July 31, 2023 10:41
Simple TCP chat client and server with private messages for connected users
package main
import (
"bufio"
"fmt"
"net"
"os"
)
func readMessages(reader *bufio.Reader) {
@M0nteCarl0
M0nteCarl0 / ActiveConnection.go
Created July 28, 2023 08:44
ActiveConnection storage
package main
import (
"fmt"
"net"
"sync"
)
type ActiveConnection struct {
conn net.Conn
@M0nteCarl0
M0nteCarl0 / info.txt
Created July 28, 2023 08:02
Load balacer info
Есть несколько алгоритмов балансировки нагрузки, которые могут быть использованы в балансировщиках нагрузки. Вот несколько примеров:
Round Robin (циклический):
Балансировщик нагрузки последовательно отправляет запросы к каждому серверу в циклическом порядке.
Каждый следующий запрос отправляется на следующий сервер в списке.
Этот алгоритм прост в реализации, но не учитывает текущую нагрузку серверов.
Least Connection (с наименьшим количеством соединений):
Балансировщик нагрузки направляет запросы к серверу с наименьшим количеством активных соединений.
Это позволяет распределить нагрузку равномерно между серверами в зависимости от их текущей загрузки.
Однако этот алгоритм требует отслеживания состояния каждого соединения на всех серверах.
@M0nteCarl0
M0nteCarl0 / notifications.html
Created July 28, 2023 07:12
Web socket notification on golang
<!DOCTYPE html>
<html>
<head>
<title>Notifications</title>
<script>
var socket = new WebSocket("ws://" + window.location.host + "/ws");
socket.onmessage = function(event) {
var notification = JSON.parse(event.data);
alert("Title: " + notification.title + "\nMessage: " + notification.message);
@M0nteCarl0
M0nteCarl0 / linux_log_storage_db.py
Created July 27, 2023 06:34
Windows and linux logs store in Redis and SQLlite
import syslog
import redis
import sqlite3
# Подключение к Redis
redis_client = redis.Redis(host='localhost', port=6379)
# Подключение к SQLite
conn = sqlite3.connect('syslog.db')
cursor = conn.cursor()