void Test()
{
var peoples = new People[]
{
new People{LastName = "Ivanov", Name = "Ivan", School = 17, One = 5, Two = 4},
new People{LastName = "Petrov", Name = "Petr", School = 17, One = 5, Two = 3},
new People{LastName = "Dariyana", Name = "Daria", School = 17, One = 5, Two = 4},
new People{LastName = "Ivanov", Name = "Ivan", School = 16, One = 5, Two = 4},
new People{LastName = "Petrov", Name = "Petr", School = 16, One = 5, Two = 3},
new People{LastName = "Dariyana", Name = "Daria", School = 16, One = 5, Two = 4},
new People{LastName = "Dariyana", Name = "Daria", School = 19, One = 2, Two = 2},
};
var path = "file.xml";
Save(path,peoples);
peoples = Load(path);
var schoolList = peoples.Select(s => s.School).Distinct();
var best =
(from sn in schoolList let max = peoples.Where(s => s.School == sn)
.Max(x => x.One + x.Two)
select
peoples.First(x => x.School == sn && (x.One + x.Two) == max))
.ToList();
;
}
private static People[] Load(string path)
{
var formatter = new XmlSerializer(typeof(People[]));
using var fs = new FileStream(path, FileMode.OpenOrCreate);
var peoples = (People[])formatter.Deserialize(fs);
return peoples;
}
private static void Save(string path, People[] peoples)
{
var formatter = new XmlSerializer(typeof(People[]));
using var fs = new FileStream(path, FileMode.OpenOrCreate);
formatter.Serialize(fs, peoples);
}
[Serializable]
public class People
{
public string LastName { get; set; }
public string Name { get; set; }
public int School { get; set; }
public int One { get; set; }
public int Two { get; set; }
}
protected override void WndProc(ref Message m)
{
base.WndProc(ref m);
if (m.Msg == WM_PAINT && DropDownStyle != ComboBoxStyle.Simple)
{
using (var g = Graphics.FromHwnd(Handle))
{
using (var p = new Pen(BorderColor))
{
g.DrawRectangle(p, 0, 0, Width - 1, Height - 1);
var d = FlatStyle == FlatStyle.Popup ? 1 : 0;
g.DrawLine(p, Width - buttonWidth - d,
0, Width - buttonWidth - d, Height);
}
}
}
}
function onChange() {
document.querySelector('селектор элемента для вывода результата проверки').innerText = [
// здесь массив селекторов вида
// input[имя_атрибута1="значение1"][имя_атрибута2="значение2"]:checked
].every(n => document.querySelector(n))
? 'какой-то текст'
: 'какой-то другой текст';
}
onChange();
document.addEventListener('change', e => {
if (e.target.matches('input[type="radio"]')) {
onChange();
}
});
VkLongPoll, VkEventType
VkBotLongPoll, VkBotEventType
import vk_api
from vk_api.bot_longpoll import VkBotLongPoll, VkBotEventType
vk = vk_api.VkApi(token="ТОКЕН")
vk._auth_token()
vk.get_api()
longpoll = VkBotLongPoll(vk, АЙДИ ГРУППЫ)
def send_msg(peer_id: int, message: str, attachment: str = ""):
return vk.method("messages.send", {**locals(), "random_id": 0})
while True:
try:
for event in longpoll.listen():
if event.type == VkBotEventType.MESSAGE_NEW:
if event.object.peer_id != event.object.from_id: #Для беседы
if event.object.text == "Привет":
send_msg(event.obj.peer_id, "Пока")
else:
send_msg(event.obj.peer_id, "Я не знаю такой команды")
if event.object.peer_id == event.object.from_id: #Для Лс
if event.object.text == "Привет":
send_msg(event.obj.peer_id, "Пока")
else:
send_msg(event.obj.peer_id, "Я не знаю такой команды")
except Exception as e:
print(repr(e))
const result = Object.values(runs.reduce(
(acc, n) => (acc[n.projectId]?.description.push(n), acc),
Object.fromEntries(projects.map(n => [ n.id, { ...n, description: [] } ]))
));
const result = projects.map(function(n) {
return {
...n,
description: this[n.id] ?? [],
};
}, runs.reduce((acc, n) => ((acc[n.projectId] = acc[n.projectId] ?? []).push(n), acc), {}));
const result = projects.map(n => ({
...n,
description: runs.filter(m => m.projectId === n.id),
}));
if (localStorage.getItem('mediaObjViewSeen') === true) {
Ключи и значения всегда строки
data: () => ({
view: localStorage.getItem('view') || 'CardsView',
// ...
}),
watch: {
view: val => localStorage.setItem('view', val),
},
data: () => ({
views: [
{
name: 'CardsView',
btnClass: 'btn-left',
img: '...',
},
{
name: 'MediaObjView',
btnClass: 'btn-right',
img: '...',
},
],
// ...
}),
<button
v-for="n in views"
:class="[ n.btnClass, view === n.name ? 'btn-active' : '' ]"
@click="view = n.name"
>
<img :src="n.img">
</button>
view
в TweetPreview
, используете его значение как имя компонента:<component
:is="view"
:tweet="tweet"
/>
function text_cleaner_fio(text){
return text
.replace(/[\W]+/, ' ') # удаление лишних символов
.replace(/([А-Я]{1}[а-яё]{0,23} [А-Я]{1}[а-яё]{0,23} [А-Я]{1}[а-яё]{0,23})|( [A-Z]{1}[a-z]{1,23} [A-Z]{1}[a-z]{1,23})$/, 'FIO'); # замена учеток
}
Проблема в том, что код <...> не удаляет класс
.js-contacts-form
добавляет класс обратно. Останавливайте всплытие в обработчике клика по .detail-work__close
; или проверяйте перед добавлением класса, где был клик и не добавляйте класс, если... ну, думаю понятно. $sum
найти последний div
const last = document.querySelector('#container').lastElementChild;
остальные удалить
Array.prototype.reduceRight.call(
document.getElementById('container').children,
(_, n) => n?.nextElementSibling && (n.outerHTML = ''),
null
);
const last = Array
.from(document.querySelectorAll('[id="container"] > *'))
.reduce((_, n, i, a) => i === ~-a.length ? n : n.remove(), null);
document.addEventListener('click', ({ target: t }) => {
if (t.classList.contains('box')) {
for (const n of document.querySelectorAll('.box')) {
n.style.background = n === t ? 'red' : 'black';
}
}
});