Skip to content

Instantly share code, notes, and snippets.

View madwayz's full-sized avatar
:octocat:
I may be slow to respond.

Роман Николенко madwayz

:octocat:
I may be slow to respond.
View GitHub Profile
@madwayz
madwayz / SocketServer.py
Created August 11, 2019 14:21
Socket сервер
import socket
ADDRESS = '127.0.0.1'
PORT = 7777
with socket.socket() as s:
s.bind((ADDRESS, PORT))
s.listen(1)
connectionObject, address = s.accept()
connectionObject.sendall(b'Hello, World!')
import socket
ADDRESS = '127.0.0.1'
PORT = '7777'
with socket.socket() as s:
s.connect((ADDRESS, PORT))
data = s.recv(1024)
print(data)
@madwayz
madwayz / GenText.py
Last active November 17, 2019 18:27
Генерирует текст из N символов.
def gentext(length=10, need_int=False):
import random
if need_int:
return ''.join([chr(random.randint(48, 57)) for _ in range(length)])
return ''.join([chr(random.randint(65, 90)) if random.randint(0, 1) else chr(random.randint(97, 122)) for _ in range(length)])