niccreate vpn
accountcreate vpn1 /server:"сервер:порт" /hub:"hub сервера" /username:"аккаунт сервера" /nicname:vpn
accountdetailset vpn1 /maxtcp:2 /INTERVAL:1 /TTL /HALF /BRIDGE /MONITOR /NOTRACK /NOQOS yes
accountpasswordset vpn1 /PASSWORD:"пароль" /TYPE:standard
accountconnect vpn1
accountlist
stepper.moveTo(targetPosition1);
stepper.runToPosition();
import json
class User:
def __init__(self, f_name: str) -> None:
self.f_name = f_name
with open(self.f_name) as f:
self.user_list = json.load(f)
self.users = [i['name'] for i in self.user_list.values()]
self.last_id = int(list(self.user_list.keys())[-1])
def add_users(self, name: str, lakes: int) -> None:
if name not in self.users:
self.users.append(name)
self.last_id += 1
self.user_list[str(self.last_id)] = {'name': name, 'lakes': lakes}
with open(self.f_name, 'w') as f:
json.dump(self.user_list, f)
else:
print(f'Пользователь с именем {name} уже существует')
users = User('users.json')
users.add_users('Derill', 23)
users.add_users('David', 21)
import json
answer = {
"id": "12",
"status": "Готов",
"url": "vk.com"
}
answer = json.dumps(answer, ensure_ascii=False).encode('utf-8') #здесь ты переобразуешь str на bytes
answer = str(answer.decode('utf-8')) #здесь обратно в str
print(type(answer)) #вот тип который ты хочешь получить доступ по ключи
import json
answer = {
"id": "12",
"status": "Готов",
"url": "vk.com"
}
answer = json.dumps(answer, ensure_ascii=False)
answer = json.loads(answer) #здесь ты переобразуешь json на данный
print(answer['id']) #получаем данные по ключи
class Solution:
def topKFrequent(self, nums: List[int], k: int) -> List[int]:
return sorted(set(nums), key=nums.count, reverse=True)[:k]
a = [('Илья',), ('Машка',)]
b = "Машка"
for i in a:
if b in a:
print(True)
break
from functools import reduce
def check(txt, tup):
types = [list, set, tuple]
while tup:
if txt in tup:
return True
tup = [i for i in tup if type(i) in types]
tup = reduce(lambda x,y: list(x) + list(y), tup)
return False
a = ((1),(2, ('asd', ('qwer', 1, "Машка"))))
b = "Машка"
print(check(b, a))
import win32api
import time
while True:
if win32api.GetAsyncKeyState(ord('A')):
print('Нажато A')
time.sleep(0.5)
"(?<=href=\")(?!http(s|):\/\/)\/*"
iptables -P FORWARD DROP
iptables -A FORWARD -m state --state ESTABLISHED,RELATED -j ACCEPT
.iptables -A FORWARD -i eth4 -o eth1 -j ACCEPT
iptables -t nat -A POSTROUTING -o eth1 -j MASQUERADE
.import re
txt = '[Win32Window(hWnd=123456)]'
r = re.compile(r'\[Win32Window\(hWnd=(\d+)\)]')
result = r.match(txt)[1]
print(result)
import re
txt = '[Win32Window(hWnd=123456)]ahjkffkfk[Win32Window(hWnd=12)]asdfg[Win32Window(hWnd=)]'
r = re.compile(r'\[Win32Window\(hWnd=(\d+)\)]')
result = r.findall(txt)
for i in result:
print(i)
iptables -t nat -A POSTROUTING -o vpn_vpn -j MASQUERADE
для интерфейса vpn.iptables -t nat -A POSTROUTING -o vpn_vpn -j MASQUERADE
ip route add default via 10.211.254.254 dev vpn_vpn table 120 #шлюз vpn подключение
ip rule add from 172.26.0.0/16 table 120 #подсеть wg0
default via 192.168.1.1 dev eth0 proto dhcp src 192.168.1.103
155.155.155.155 via 192.168.1.1 dev eth0 #это публичный IP VPN сервера интерфейса vpn_vpn
8.8.8.8 via 10.211.254.254 dev vpn_vpn
10.211.0.0/16 dev vpn_vpn proto kernel scope link src 10.211.1.90
172.26.0.0/16 dev wg0 proto kernel scope link src 172.26.3.155
192.168.1.0/24 dev eth0 proto kernel scope link src 192.168.1.103 metric 100
192.168.1.1 dev eth0 proto dhcp scope link src 192.168.1.103 metric 100
default via 10.211.254.254 dev vpn_vpn
import pygame
from random import randrange
import keyboard
class Control:
def __init__(self, dirs: dict, x_y: list, key: str) -> None:
self.dirs = dirs
self.x_y = x_y
self.key = key
def __call__(self, _):
if self.key == 'W' and self.dirs['W']:
self.x_y[:] = [0, -1]
self.dirs.update({'W': True, 'S': False, 'A': True, 'D': True, })
if self.key == 'S' and self.dirs['S']:
self.x_y[:] = [0, 1]
self.dirs.update({'W': False, 'S': True, 'A': True, 'D': True, })
if self.key == 'A' and self.dirs['A']:
self.x_y[:] = [-1, 0]
self.dirs.update({'W': True, 'S': True, 'A': True, 'D': False, })
if self.key == 'D' and self.dirs['D']:
self.x_y[:] = [1, 0]
self.dirs.update({'W': True, 'S': True, 'A': False, 'D': True, })
print(self.dirs)
def run_ctrl():
up = Control(dirs, x_y, 'W')
down = Control(dirs, x_y, 'S')
left = Control(dirs, x_y, 'A')
right = Control(dirs, x_y, 'D')
keyboard.on_press_key('W', up)
keyboard.on_press_key('S', down)
keyboard.on_press_key('A', left)
keyboard.on_press_key('D', right)
RES = 800
SIZE = 80
x, y = randrange(0, RES, SIZE), randrange(0, RES, SIZE)
apple = randrange(0, RES, SIZE), randrange(0, RES, SIZE)
dirs = {'W': True, 'S': True, 'A': True, 'D': True, }
length = 1
snake = [(x, y)]
x_y = [0, 0]
dx, dy = 0, 0
score = 0
fps = 1
pygame.init()
sc = pygame.display.set_mode([RES, RES])
clock = pygame.time.Clock()
font_score = pygame.font.SysFont('Arial', 26, bold=True)
font_end = pygame.font.SysFont('Arial', 66, bold=True)
run_ctrl() #управление
while True:
dx, dy = x_y #передача значение управление
sc.fill(pygame.Color('black'))
# Счёт
render_score = font_score.render(f'SCORE: {score}', 1, pygame.Color('orange'))
sc.blit(render_score, (5, 5))
# Движение змейки
x += dx * SIZE
y += dy * SIZE
snake.append((x, y))
snake = snake[-length:]
# отрисовка
[(pygame.draw.rect(sc, pygame.Color('green'), (i, j, SIZE - 2, SIZE - 2))) for i, j in snake]
pygame.draw.rect(sc, pygame.Color('red'), (*apple, SIZE, SIZE))
# Скушать яблочко
if snake[-1] == apple:
apple = randrange(0, RES, SIZE), randrange(0, RES, SIZE)
length += 1
fps += 0.1
score += 1
# game over
if x < 0 or x > RES - SIZE or y < 0 or y > RES - SIZE or len(snake) != len(set(snake)):
while True:
render_end = font_end.render('GAME OVER', 1, pygame.Color('orange'))
sc.blit(render_end, (RES // 2 - 180, RES // 2.5))
pygame.display.flip()
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
pygame.display.flip()
clock.tick(fps)
# закрытие приложения
for event in pygame.event.get():
if event.type == pygame.QUIT:
exit()
class Pers:
def __init__(self, Name: str, HP: int, Rang: str) -> None:
self.Name = Name
self.HP = HP
self.Rang = Rang
def print_stat(self):
print(self.__dict__)
аvailable_locations = ["Chaes", "Kordon"] #Доступные локации
print(f"Welcome to колхозный S.T.A.L.K.E.R ёпт\nДоступные локации:{аvailable_locations}\n") #Выводит список доступных локаций
a = input("Введите локацию: Пример(Kordon)\n>")
territory = {a: "Территория обитания меченого"} #Словарь в котором записана локация она понадобится для улсовных операторов
print("==============================================================")
if "Chaes" in territory:
monolit = [Pers("Monolit", 120, "Master") for i in range(20)]
[i.print_stat() for i in monolit]
print("Уууууу ты нарвался на монолитов")
elif "Kordon" in territory:
odinochki = [Pers("Stalker", 100, "Noob") for i in range(10)]
[i.print_stat() for i in odinochki]
print("\n")
mut = [Pers("Psevdosobaki", 90, "None") for i in range(5)]
[i.print_stat() for i in mut]
print()
print("Не мельтеши особо и трогать тебя не будут ")
print("==============================================================")
pl = input() #Это для того чтоб после завершения программы консоль сразу не выкидывала
d = {'5':["Сегодня больше отличников", 0],
'4': ["Сегодня больше хорошистов", 0],
'3': ["Сегодня больше троечников", 0]} #ученики с оценкой 3, 4, 5
students = int(input("Введите количество учеников:"))
print()
for grade in range(1, students+1):
print(f'{grade}-й из {students} учеников')
students_grade = input("Какую оценку ученик получил?:")
d[students_grade][1] += 1
print()
print(max(d.items(), key=lambda x: x[1][1])[1][0])
print("\nКоличество учеников,получивших 5:", d['5'][1], ";", "Количество учеников,получивших 4:", d['4'][1], ";", "Количество учеников,получивших 3:", ";", d['3'][1])
import requests
from bs4 import BeautifulSoup
import re
import os
from urllib.request import urlopen
import json
class Parser:
def __init__(self, href) -> None:
self.url = "https://fasie.ru"
self.href = href
self.source = self.url + self.href['href']
self.name = self.href.text
try:
r = requests.get(self.source, timeout=20)
except:
print(f'err. conn: {self.source} in "def __init__"')
soup = BeautifulSoup(r.text, "html.parser")
self.section = soup.find('div',{'class':'tabs'}).find_all('section')
def get_description(self):
l = re.findall(r"[^\n\t\r]+", self.section[2].text)
return '\n'.join(map(str.strip, l))
def get_program(self):
l = re.findall(r"[^\n\t\r]+", self.section[0].text)
return '\n'.join(map(str.strip, l))
def get_contact(self):
l = []
pattern = r"(\+?[\d\(\) -]+)\s\(?доб\.\s?\d{3}\)?"
if self.section[-1].find('tr'):
for i in self.section[-1].find_all('tr'):
d = {}
d['name'] = i.find('h4').text.strip().replace('\xa0', ' ')
d['tel'] = ''
tmp = re.search(pattern, i.text)
if tmp:
d['tel'] = tmp[1].strip()
d['email'] = i.find('a').text
l.append(d)
elif self.section[-1].find('b'):
name = [i.text for i in self.section[-1].find_all('b') if i.text.strip()]
tel = re.findall(pattern, self.section[-1].text)
email = self.section[-1].find_all('a')
for i in zip(name, tel, email):
d = {}
d['name'] = i[0].strip().replace('\xa0', ' ')
d['tel'] = i[1].strip()
d['email'] = i[2].text
l.append(d)
else:
for i in self.section[-1].find_all('p', recursive=False):
if i.find('a'):
d = {}
d['name'] = ''
d['tel'] = ''
tmp = re.search(pattern, i)
if tmp:
d['tel'] = tmp[1].strip()
d['email'] = i.find('a').text
l.append(d)
return l
def get_documents(self):
l = []
for i in self.section[1].find_all('a'):
d = {}
d['source'] = self.url + i['href']
d['path'] = '.'+ self.href['href'] + '/'.join(i['href'].replace('%20', '_').rsplit('/', 2)[-2:])
d['name'] = d['path'].rsplit('/', 1)[-1]
d['extension'] = d['name'].rsplit('.', 1)[-1]
try:
r = requests.get(d['source'], timeout=20)
except:
print(f"err. conn: {d['source']} in 'def get_documents'")
continue
os.makedirs(os.path.dirname(d['path']), exist_ok=True)
with open(d['path'], 'wb') as f:
f.write(r.content)
d['size'] = len(r.content)
l.append(d)
return l
def run(self):
d = {
'source':self.source,
'name':self.name,
'description':self.get_description(),
'programs':self.get_program(),
'contacts':self.get_contact(),
'documents':self.get_documents()
}
return d
def main():
url = "https://fasie.ru"
page = urlopen(url)
html = page.read().decode("utf-8")
soup = BeautifulSoup(html, "html.parser")
div = soup.find_all('div', class_ = 'wrap')
programms_list = div[1].find('ul', class_='').find_all('ul', class_='')[1]
hrefs = programms_list.find_all('a')
data = []
for i in hrefs:
p = Parser(i)
data.append(p.run())
with open('output.json', 'w', encoding="utf-8") as f:
f.write(json.dumps(data, indent=2, ensure_ascii=False))
main()
cnt = 0
for n in range(1, 1000):
n = n << 1 ^ (n.bit_count() > n.bit_length() - n.bit_count()) #добавляем в конец 1 или 0
bit_l = n.bit_length() #длина битов
del_bit_l = 2 + bit_l%2 #длина удаляемого бита
l_r = int((bit_l - del_bit_l)/2) #длина левого и правого бита
l_bit = n >> bit_l - l_r << l_r #левый бит
r_bit = n&2**l_r - 1 #правый бит
r = l_bit|r_bit
if 50 <= r <= 100:
cnt += 1
print(cnt)