Python
13
Вклад в тег
import math
while True:
a = int(input("ax^2+bx+c=0 / a: "))
b = int(input("ax^2+bx+c=0 / b: "))
c = int(input("ax^2+bx+c=0 / c: "))
d = b ** 2 - 4 * a * c
if d > 0:
x1 = (-b + math.sqrt(d)) / (2 * a)
x2 = (-b - math.sqrt(d)) / (2 * a)
print(f'Корней: 2. \n x1 = {x1}')
print(f'Корней: 2. \n x2 = {x2}')
elif d == 0:
x1 = -b / (2 * a)
print(f'Корень: 1. \n x1 = {x1}')
else:
print("Корней: 0")
docker compose run --user $(id -u):$(id -g) composer create-project laravel/laravel .
FROM composer:latest
WORKDIR /var/www/laravel
RUN adduser -D -u USER www-data
USER www-data
ENTRYPOINT ["composer", "--ignore-platform-reqs"]
.case-wrapper {
position: relative;
cursor: pointer;
user-select: none;
-webkit-tap-highlight-color: transparent;
outline: none;
background: transparent;
border: none;
padding: 0;
margin: 0;
box-shadow: none;
}
.case-wrapper:focus {
outline: none;
box-shadow: none;
}
.case-wrapper::-moz-focus-inner {
border: 0;
}
import subprocess
from time import sleep
class CameraMonitor:
def __init__(self):
self.IP12 = '192.168.0.100'
self.IP13 = '192.168.0.101'
self.RODOS12 = '192.168.1.100'
self.RODOS13 = '192.168.1.101'
self.fail_count = {'Купол 12': 0, 'Купол 13': 0}
self.reboot_count = {'Купол 12': 0, 'Купол 13': 0}
def ping_camera(self, ip):
cmd = f'ping {ip} -n 1 -w 100'
response = subprocess.call(cmd, stdout=subprocess.DEVNULL)
return response == 0
def cameras_checker(self):
r_dict = {'Купол 12': self.IP12, 'Купол 13': self.IP13}
while True:
for camera, ip in r_dict.items():
if self.ping_camera(ip):
print(f'Camera {camera} - OK')
self.fail_count[camera] = 0
else:
self.fail_count[camera] += 1
print(f'Camera {camera} - Died')
if self.fail_count[camera] >= 5:
self.cameras_reboot(camera)
sleep(5)
def cameras_reboot(self, camera):
if camera == 'Купол 12':
ip = self.RODOS12
else:
ip = self.RODOS13
self.reboot_count[camera] += 1
print(f'Rebooting {camera} at IP {ip}')
def info(self):
for camera, count in self.reboot_count.items():
print(f'Перезагрузок {camera}: {count}')
if __name__ == "__main__":
monitor = CameraMonitor()
monitor.cameras_checker()
<?php foreach ($fields as $field): ?>
<?= Html::activeHiddenInput($model, "[$field->id]id_field", ['value' => $field->id]) ?>
<?= $form->field($model, "[$field->id]data")->textInput(['value' => $model->data]) ?>
<?php endforeach; ?>
Field_Data[1][id_field] = 1
Field_Data[1][data] = "значение поля 1"
Field_Data[2][id_field] = 2
Field_Data[2][data] = "значение поля 2"
if (Yii::$app->request->post('Field_Data')) {
foreach (Yii::$app->request->post('Field_Data') as $fieldData) {
$model = new FieldData();
$model->id_field = $fieldData['id_field'];
$model->data = $fieldData['data'];
if ($model->validate()) {
$model->save();
}
}
}