−1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
def get_decrease_fan_speed_delta(fan_speed: float, delta: float, turn_off: bool):
# if the fan is already running slower than minimum speed
if fan_speed < MIN_FAN_SPEED:
# we ignore the turn_off argument and always set the fan off
return -fan_speed
# if fan would be running slower than minimum speed after decreasing it by delta:
if (fan_speed - delta) < MIN_FAN_SPEED:
if turn_off:
return -fan_speed # turn the fan off
else:
return -fan_speed + MIN_FAN_SPEED # make it run at minimum speed
return -delta
def get_increase_fan_speed_delta(fan_speed, delta):
new_fan_speed = fan_speed + delta
# if fan would be running faster than maximum speed
if new_fan_speed > 100:
return 100 - fan_speed # cap it at 100%
elif new_fan_speed < MIN_FAN_SPEED:
return MIN_FAN_SPEED - fan_speed # jump to minimum fan speed
return delta
def compute_fan_speed_delta(temp: float, temp_delta: float, fan_speed: float):
if temp >= HOT:
return get_increase_fan_speed_delta(fan_speed, 100.0)
if temp <= COLD:
# if temperature is decreasing, we slowly decrease the fan speed
if temp_delta < 0.0:
return get_decrease_fan_speed_delta(fan_speed, FAN_DELTA, turn_off=True)
# if temperature is constant or increasing we don't change fan speed
# until it rises above COLD
return 0.0
# if temperature is decreasing we decrease fan speed slowly
if temp_delta < 0.0:
return get_decrease_fan_speed_delta(fan_speed, FAN_DELTA, turn_off=False)
# if temperature is increasing we increase fan speed slowly
if temp_delta > 0.0:
return get_increase_fan_speed_delta(fan_speed, FAN_DELTA)
# if temperature is not changing, don't change the fan speed
return 0.0
GAMER,
30 Марта 2023
0
- 1
https://gitlab.com/muzena/iptv/-/blob/master/usr/lib/astronciaiptv/astroncia_iptv.py
тут каждая строчка - это говнокод
ACTPE9I,
27 Марта 2023
0
- 1
AttributeError: type object 'datetime.datetime' has no attribute 'from_timestamp'. Did you mean: 'fromtimestamp'?
ISO,
19 Марта 2023
−9
правда
sashastepuronegro,
04 Марта 2023
−8
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
- 30
- 31
- 32
- 33
- 34
- 35
- 36
- 37
- 38
- 39
- 40
- 41
- 42
- 43
- 44
- 45
- 46
- 47
- 48
- 49
- 50
- 51
- 52
- 53
- 54
- 55
- 56
- 57
- 58
- 59
- 60
- 61
- 62
- 63
- 64
- 65
- 66
- 67
- 68
- 69
- 70
- 71
- 72
- 73
- 74
- 75
- 76
- 77
- 78
- 79
- 80
- 81
- 82
- 83
- 84
- 85
- 86
- 87
- 88
- 89
- 90
- 91
- 92
- 93
- 94
- 95
- 96
- 97
- 98
- 99
print('1 часть тут, 2 в описании')
import re
q = int(input())
b = input()
v = 0
flag = True
if v == 0:
c = len(re.findall('q', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('w', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('e', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('r', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('t', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('y', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('u', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('i', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('o', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('p', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('a', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('s', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('d', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('f', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('g', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('h', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('j', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('k', b))
if c > 1:
print("NO")
flag = False
quit
else:
v = 3
c = len(re.findall('l', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('m', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('n', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('b', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('v', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('c', b))
if c > 1:
print("NO")
flag = False
quit()
else:
v = 3
c = len(re.findall('x', b))
if c > 1:
flag = False
quit()
print("NO")
else:
v = 3
c = len(re.findall('z', b))
if c > 1:
flag = False
print("NO")
quit()
else:
v = 3
if flag == True:
print("YES")
sashastepuronegro,
04 Марта 2023
−1
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
def auth_2FA(request):
mail = request.POST.get('mail')
user = User.objects.get(email=mail)
code2FA = request.POST.get('code2FA')
if pyotp.TOTP(user.secret).verify(code2FA):
auth.login(request, user)
return redirect(settings.HOME_PAGE)
else:
...
# Безопасность
Django, двухфакторка.
Защиты от перебора нет, пароль не проверяется. Зная только mail можно залогиниться перебрав код из 6 цифр
Doorman5302,
01 Марта 2023
0
- 1
print(str(n := int(input())) * 0, sum([(-1) ** i * 1 / (2 ** i) for i in range(n)]), sep='')
fec60394,
04 Февраля 2023
0
- 1
print(str(n := int(input())) * 0, sum([(-1) i * 1 / (2 i) for i in range(n)]), sep='')
Сократил xD
fec60394,
04 Февраля 2023
−2
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
key_base_len = random.randint(30,61)
key_base = bytearray(key_base_len)
for i in range(key_base_len):
key_base[i] = random.randint(0,255)
key = bytearray(8)
key[0] = chip_uid_chksum ^ key_base[ 4 * (key_base_len // 7)]
key[1] = chip_uid_chksum ^ key_base[ key_base_len // 5 ]
key[2] = chip_uid_chksum ^ key_base[ key_base_len // 7 ]
key[3] = chip_uid_chksum ^ key_base[ 6 * (key_base_len // 7)]
key[4] = chip_uid_chksum ^ key_base[ 3 * (key_base_len // 7)]
key[5] = chip_uid_chksum ^ key_base[ 3 * (key_base_len // 5)]
key[6] = chip_uid_chksum ^ key_base[ 5 * (key_base_len // 7)]
key[7] = (chip_id + key[0]) & 0xff
return key, key_base
Китайцы и криптография.
Сначала программатор отдаёт контроллеру key_base, а затем юзает key чтобы ксорить с ним заливаемую прошивку.
bormand,
31 Декабря 2022
+1
- 01
- 02
- 03
- 04
- 05
- 06
- 07
- 08
- 09
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
- 21
- 22
- 23
- 24
- 25
- 26
- 27
- 28
- 29
def __get_column_names(table: str) -> tuple:
try:
with conn:
cur.execute("SELECT name FROM PRAGMA_TABLE_INFO(?)", (table,))
column_names = cur.fetchall()
except Exception as excpt:
print(excpt)
column_names = tuple(i[0] for i in column_names)
return column_names
def db_register_user(user_data: types.User):
"""
SQL запрос для внесения данных о пользователе
Args:
user_data: telebot User объект, содержащий словарь с параметрами пользователя
"""
user_data = user_data.to_dict()
column_names: tuple = __get_column_names('Users')
user_values = tuple(user_data.get(key) for key in column_names if key in user_data)
try:
with conn:
query = 'INSERT INTO Users cn'.replace('cn', str(column_names))+' VALUES (?,?,?,?,0,3)'
parameters = (*user_values,)
conn.execute(query, parameters)
except Exception as excpt:
print(excpt)
conn.close()
На сколько в такой ситуации .format не безопасен? Идея в том, чтобы не объебошится программисту в коде введя неверное значение колонки. Для этого имена колонок берутся из самой базы (есть мысль ещё и типы брать). Есть вариант реализации получше? Спасибо
rockkley94,
26 Декабря 2022