curl -s https://www.cbr.ru/scripts/XML_daily.asp | grep "USD\|EUR" | awk '{print "Курс", $2, "на", $1, "равен", $5, "рублей"}'
class AntispoofModel(nn.Module):
def __init__(self, device="cpu", **kwargs):
super().__init__()
resnet = torch.hub.load('pytorch/vision:v0.10.0', 'resnet18', pretrained=True)
self.resnet = nn.Sequential(*[i for i in list(resnet.children())[:-2]]).to(device)
for ch in self.resnet.children():
for param in ch.parameters():
param.requires_grad = False
self.gat1 = GAT(**kwargs).to(device)
self.gat2 = GAT(**kwargs).to(device)
self.device = device
self.adj = torch.tensor(grid_to_graph(3, 3, return_as=np.ndarray)).to(device)
def forward(self, x):
x = self.resnet(x.to(self.device))
x = nn.functional.avg_pool2d(x, 2)
x = x.view(-1, 9, 512)
x = self.gat1(x, self.adj)
x = self.gat2(x, self.adj)
return torch.sigmoid(x)
import threading
import time
def my_func():
while True:
print("Function is running")
time.sleep(1)
timer = threading.Timer(5, lambda: print("Timer expired"))
timer.start()
my_func()
timer.cancel()
function compareArrays(arr1, arr2) {
if (arr1.length !== arr2.length) {
return false;
}
for (let i = 0; i < arr1.length; i++) {
for (let j = 0; j < arr2.length; j++) {
if (arr1[i][j] !== arr2[i][j]) {
return false;
}
}
}
return true;
}
// Пример использования:
const arr1 = [[1, 2, 3], [4, 5, 6]];
const arr2 = [[1, 2, 3], [4, 5, 6]];
console.log(compareArrays(arr1, arr2)); // true
$parser = xml_parser_create('UTF-8');
$description_buffer = ''; // создаем буфер для описания товара
xml_set_element_handler($parser,
function ($parser, $name, $attrs) {
switch ($name) {
case "DESCRIPTION":
$this->product_description_true = true;
break;
}
},
function ($parser, $name) {
switch ($name) {
case "DESCRIPTION":
$this->product_description_true = false;
$this->xml_products[$this->index_product]['description'] = $description_buffer; // сохраняем описание товара
$description_buffer = ''; // очищаем буфер для следующего описания товара
break;
}
}
);
xml_set_character_data_handler($parser,
function ($parser, $data) use (&$description_buffer) { // передаем буфер по ссылке
...
if ($this->product_description_true) {
$description_buffer .= $data; // добавляем текст между тегами в буфер
}
...
}
);
$remove = file_get_contents(stripslashes('http://....xml'));
// Удаление символов в тексте
$remove = str_replace(array("&", "&"), array("&", "&"), $remove);
xml_parse($parser, $remove, true);
xml_parser_free($parser);
const collageItems = document.querySelectorAll(".collage__item");
collageItems.forEach((item, index) => {
gsap.from(item, {
scrollTrigger: {
trigger: item,
},
autoAlpha: 0,
y: 150,
duration: 1.5,
ease: "power1.out",
delay: index * 0.5, // задержка для каждого элемента
});
});
function splitWord(str) {
let words = str.split(' ');
words.push('!');
return words;
}
let sentence = 'Разбитое на слова предложение';
console.log(splitWord(sentence)); // ["Разбитое", "на", "слова", "предложение", "!"]
["Разбитое", "на", "слова", "предложение", "!"]
import { useState } from 'react';
function App() {
const [items, setItems] = useState([
{ id: 1, name: 'Item 1' },
{ id: 2, name: 'Item 2' },
{ id: 3, name: 'Item 3' },
{ id: 4, name: 'Item 4' },
]);
const [currentIndex, setCurrentIndex] = useState(0);
const handleMoveLeft = () => {
if (currentIndex > 0) {
setItems(prevItems => {
const newItems = [...prevItems];
newItems.splice(currentIndex - 1, 0, newItems[currentIndex]);
newItems.splice(currentIndex + 1, 1);
setCurrentIndex(currentIndex - 1);
return newItems;
});
}
};
const handleMoveRight = () => {
if (currentIndex < items.length - 1) {
setItems(prevItems => {
const newItems = [...prevItems];
newItems.splice(currentIndex + 2, 0, newItems[currentIndex]);
newItems.splice(currentIndex, 1);
setCurrentIndex(currentIndex + 1);
return newItems;
});
}
};
return (
<div>
<ul>
{items.map((item, index) => (
<li key={item.id}>{item.name}</li>
))}
</ul>
<button onClick={handleMoveLeft}>Влево</button>
<button onClick={handleMoveRight}>Вправо</button>
</div>
);
}
export default App;
export const SearchBar = ({ handleSearch, filter, placeholder, name }) => {
const [value, setValue] = useState(filter);
const inputRef = useRef(null);
useEffect(() => {
if (inputRef.current) {
inputRef.current.focus();
}
}, [inputRef.current]);
const updateState = (e) => {
setValue(e.target.value);
handleSearch(e.target.value, name);
};
return (
<input
type="text"
ref={inputRef}
value={value}
placeholder={placeholder}
onChange={updateState}
className={styles.search_input}
/>
);
};