const url = 'www.site.ru/users/agent/512/list/france';
const parts = url.split('/');
const agentIndex = parts.indexOf('agent');
const value = parts[agentIndex + 1];
console.log(value); // 512
const url = 'www.site.ru/users/agent/512/list/france';
const match = url.match(/\/agent\/(\d+)\/list/);
const value = match ? match[1] : null;
console.log(value); // 512
Скажите, есть возможность вывести содержимое файла readme.txt в описании публикации?
<div style="max-width:240px; margin:-10px auto 25px;">
<?php
$args = [
'show_option_none' => 'Все рубрики',
'orderby' => 'name',
'show_count' => 1,
'hide_empty' => 1,
'hide_if_empty' => false,
'exclude' => '10,754,121',
'tab_index' => 0,
'id' => 'category',
];
wp_dropdown_categories($args);
?>
</div>
<?php
$categories = get_categories([
'exclude' => '10,754,121',
'hide_empty' => 1,
]);
$category_slugs = [];
foreach ($categories as $category) {
$category_slugs[$category->term_id] = urldecode($category->slug);
}
?>
<script type="text/javascript">
document.addEventListener('DOMContentLoaded', () => {
const dropdown = document.getElementById('category');
const categorySlugs = <?php echo json_encode($category_slugs); ?>;
console.log('Category slugs:', categorySlugs);
dropdown.addEventListener('change', () => {
const selectedValue = dropdown.options[dropdown.selectedIndex].value;
if (selectedValue > 0) {
const selectedCategorySlug = decodeURIComponent(categorySlugs[selectedValue]);
window.location.href = `<?php echo home_url(); ?>/category/${selectedCategorySlug}`;
}
});
});
</script>
import fetch from 'node-fetch';
import {create} from './create.js';
const url = 'https://api.site.ru/endpoint';
const TOKEN = 'TOKEN';
const options = {
method: 'POST',
headers: {
'Content-Type': 'application/json',
'Authorization': `Basic ${Buffer.from(`${TOKEN}:`).toString('base64')}`,
},
body: JSON.stringify({
date: {
from: '2024-07-01T00:00:00',
to: '2024-07-09T00:00:00',
},
}),
};
fetch(url, options)
.then((response) => response.json())
.then((result) => create(result))
.catch((error) => console.error(error.message));
Вопрос,как улучшить код,чтобы при нажатие пробела нажатие на все координаты происходило одновременно
import keyboard as kb
import pyautogui as pt
pt.PAUSE = 0.01
if __name__ == '__main__':
coordinates = [
(-1241, 624),
(-303, 720),
(604, 634),
(1363, 679),
(1363, 679),
(2265, 654),
(558, 1342),
(2476, 1255),
]
while True:
if kb.is_pressed('Space'):
for x, y in coordinates:
pt.click(x, y)
Или есть какое-нибудь другое решение?
заказчику требуется также CMS
или подключить все на WordPress, но там все как-то сделано через одно место
import telebot
from telebot import types
bot = telebot.TeleBot('token')
file = open('./start1.jpg', 'rb')
@bot.message_handler(commands=['start'])
def start(message):
markup = types.InlineKeyboardMarkup()
markup.add(types.InlineKeyboardButton('Оценка', url='https://google.com'))
markup.add(types.InlineKeyboardButton('Кадастровые работы', callback_data='cadastral'))
markup.add(types.InlineKeyboardButton('Строительные экспертизы', callback_data='expertise'))
bot.send_photo(message.chat.id, file,
caption='Здравствуйте, это Бот-помощник группы компаний "Стандарт Оценка", я помогу Вам определиться с нужной услугой, оформить заявку и связаться с администратором. Выберете желаемую услугу',
reply_markup=markup)
@bot.callback_query_handler(func=lambda call: True)
def callback_message(call):
if call.data == 'cadastral':
bot.delete_message(call.message.chat.id, call.message.message_id)
bot.send_message(call.message.chat.id, 'Введите свое ФИО')
bot.register_next_step_handler(call.message, message_input_step)
elif call.data == 'expertise':
bot.send_message(call.message.chat.id, 'Вы выбрали Строительные экспертизы')
elif call.data == 'all':
bot.send_message(call.message.chat.id, 'Все данные верны')
def message_input_step(message):
global name
name = message.text
bot.send_message(message.chat.id, 'Введите свой номер телефона')
bot.register_next_step_handler(message, phone)
def phone(message):
global phone
phone = message.text
markup = types.InlineKeyboardMarkup()
markup.add(types.InlineKeyboardButton('Все верно✅', callback_data='all'))
markup.add(types.InlineKeyboardButton('Начать сначало❌', callback_data='cadastral'))
bot.send_message(message.chat.id, f'Ваше ФИО: {name}\nВаш номер телефона: {phone}', reply_markup=markup)
if __name__ == "__main__":
bot.polling(none_stop=True)
// app/layout.js
'client'
import type { Metadata } from "next";
import { Inter } from "next/font/google";
import "@/base.scss";
import { Provider } from 'react-redux';
import { store } from '../redux/store';
import Layout from "@/components/Layout";
const inter = Inter({ subsets: ["latin"] });
export const metadata: Metadata = {
title: "Home | PlayCloud",
description: "Unique web application for listening to a huge amount of music in a unique format",
}
export default function RootLayout({ children }: Readonly<{ children: React.ReactNode }>) {
return (
<html lang="en">
<body className={inter.className}>
<Provider store={store}>
<Layout>
{children}
</Layout>
</Provider>
</body>
</html>
)
}
Cannot destructure property 'store' of 'useReduxContext2(...)' as it is null?
<?php
$args = array(
'post_type' => 'post', // posts
'posts_per_page' => -1, // counts per page
'order' => 'ASC', // по умолчанию get_posts() возвращает посты в порядке от новых к старым, изменим на обратное
);
$posts = get_posts($args);
if (!empty($posts)) :
foreach ($posts as $post) : setup_postdata($post); ?>
<div>
<h3><?php the_title(); ?></h3>
<h4>Краткое описание:</h4>
<p><?php the_excerpt(); ?></p>
<a href="<?php the_permalink(); ?>">Ссылка на запись</a>
<p>Тип записи: <?php echo get_post_type($post); ?></p> <!-- check post type -->
</div>
<?php endforeach;
wp_reset_postdata();
endif; ?>
Есть 2 сайта. Тематически второй можно разместить на поддомене.
server_response = "..." # https://gist.github.com/serrhiy/56b1f296cb7b4fbf42febaf8c08347a1
def decode_unicode_escapes(string):
return re.sub(r'\\u([0-9A-Fa-f]{4})', lambda m: chr(int(m.group(1), 16)), string)
unicode_decoded = decode_unicode_escapes(server_response)
try:
res = unicode_decoded.encode('utf-8').decode('utf-8')
except UnicodeEncodeError as e:
print(f"Ошибка: {e}.")
res = unicode_decoded.encode('utf-8', errors='replace').decode('utf-8', errors='replace')
print(res) # <a href='https://www.immowelt.de/immoweltag/datenschutz' target="_blank" class="hm_link" title="Datenschutzerklärung der AVIV Germany GmbH">
function test() {
if (is_search()) {
remove_action('wp_head', 'noindex', 10);
}
}
add_action('wp', 'test');
развернуть на субдоменах
Может ли Яндекс зачесть деньги, предназначенные для другого сервиса в счет старого долга?