This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"crypto/sha1" | |
"fmt" | |
"io/ioutil" | |
"net/http" | |
"os" | |
"strings" | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
#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) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"sync" | |
) | |
// ConnectionManager интерфейс определяет методы для управления соединениями | |
type ConnectionManager interface { | |
AddConnection(connection Connection) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"bufio" | |
"fmt" | |
"net" | |
"os" | |
) | |
func readMessages(reader *bufio.Reader) { |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
package main | |
import ( | |
"fmt" | |
"net" | |
"sync" | |
) | |
type ActiveConnection struct { | |
conn net.Conn |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Есть несколько алгоритмов балансировки нагрузки, которые могут быть использованы в балансировщиках нагрузки. Вот несколько примеров: | |
Round Robin (циклический): | |
Балансировщик нагрузки последовательно отправляет запросы к каждому серверу в циклическом порядке. | |
Каждый следующий запрос отправляется на следующий сервер в списке. | |
Этот алгоритм прост в реализации, но не учитывает текущую нагрузку серверов. | |
Least Connection (с наименьшим количеством соединений): | |
Балансировщик нагрузки направляет запросы к серверу с наименьшим количеством активных соединений. | |
Это позволяет распределить нагрузку равномерно между серверами в зависимости от их текущей загрузки. | |
Однако этот алгоритм требует отслеживания состояния каждого соединения на всех серверах. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<!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); |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
import syslog | |
import redis | |
import sqlite3 | |
# Подключение к Redis | |
redis_client = redis.Redis(host='localhost', port=6379) | |
# Подключение к SQLite | |
conn = sqlite3.connect('syslog.db') | |
cursor = conn.cursor() |