row_id
int64 0
48.4k
| init_message
stringlengths 1
342k
| conversation_hash
stringlengths 32
32
| scores
dict |
|---|---|---|---|
5,321
|
Как переписать этот код в стиле ООП.def pars(hrefs: list[str]) -> NoReturn:
config = configparser.ConfigParser()
config.read('config.ini', encoding='utf-8')
a = int(multiprocessing.current_process().name.split('-')[1])
#
cpu_counter = multiprocessing.cpu_count()
time.sleep(a * 2)
with wd.Chrome(options=options(headless=config.get('program', 'headless')),
service=ChromeService(ChromeDriverManager().install())) as browser:
for href in range(int(multiprocessing.current_process().name.split('-')[1]) - 1, len(hrefs), cpu_counter):
name, city, adress, ind, coord, site, number, vk, teleg, ok, wa, vb, yt, soc_contacts = '', '', '', '', '', '', '', '', '', '', '', '', '', ''
browser.get(hrefs[href])
# time.sleep(a / 4)
print(browser.current_url)
browser.implicitly_wait(5)
if 'У вас старая версия браузера' in browser.page_source:
time.sleep(5)
browser.quit()
time.sleep(1)
browser = wd.Chrome(options=options(headless=config.get('program', 'headless')),
service=ChromeService(ChromeDriverManager().install()))
continue
try:
try:
element = WebDriverWait(browser, 10).until(
EC.presence_of_element_located((By.CLASS_NAME, 'sidebar-container')))
except Exception as ex:
pass
name = [browser.find_element(By.CLASS_NAME, 'sidebar-container') \
.find_element(By.CLASS_NAME, 'orgpage-header-view__header').text]
try:
site = [browser.find_element(By.CLASS_NAME, 'sidebar-container') \
.find_element(By.CLASS_NAME, 'business-urls-view__link').get_attribute('href')]
except Exception as ex:
site = ['']
try:
elem = browser.find_element(By.CLASS_NAME, 'sidebar-container').find_element(By.CLASS_NAME,
'card-phones-view__more-wrapper')
ActionChains(browser).move_to_element(elem).perform()
elem.click()
elemm = browser.find_element(By.CLASS_NAME, 'sidebar-container') \
.find_element(By.CLASS_NAME, 'card-feature-view__additional') \
.find_element(By.CLASS_NAME, 'inline-image')
ActionChains(browser).move_to_element(elemm).perform()
elemm.click()
time.sleep(2)
except Exception as ex:
pass
try:
number = [i.text for i in browser.find_element(By.CLASS_NAME, 'sidebar-container') \
.find_elements(By.CLASS_NAME, 'card-phones-view__phone-number')]
except Exception as ex:
number = ['']
try:
soc_contacts = [i.find_element(By.TAG_NAME, 'a').get_attribute('href') \
for i in browser.find_element(By.CLASS_NAME, 'sidebar-container') \
.find_elements(By.CLASS_NAME, 'business-contacts-view__social-button')]
for seti in soc_contacts:
if 'vk.com' in seti:
vk = seti
elif 'ok.ru' in seti:
ok = seti
elif 't.me' in seti:
teleg = seti
elif 'youtube.com' in seti:
yt = seti
elif 'wa.me' in seti:
wa = seti
elif 'viber.click' in seti:
vb = seti
except Exception as ex:
soc_contacts = ['']
browser.get(browser.find_element(By.CLASS_NAME, 'sidebar-container') \
.find_element(By.CLASS_NAME, 'business-contacts-view__address-link').get_attribute(
'href'))
#time.sleep(1)
descr = browser.find_element(By.CLASS_NAME, 'sidebar-container') \
.find_element(By.CLASS_NAME, 'card-title-view__subtitle') \
.find_element(By.CLASS_NAME, 'toponym-card-title-view__description').text.split(',')
coord = browser.find_element(By.CLASS_NAME, 'sidebar-container') \
.find_element(By.CLASS_NAME, 'card-title-view__subtitle').find_element(By.CLASS_NAME,
'toponym-card-title-view__coords-badge').text
if descr[-1].strip().isdigit():
ind = descr[-1].strip()
city = descr[-2].strip()
adress = descr[:-2]
else:
ind = ''
city = descr[-1].strip()
adress = descr[:-1]
f = *name, city.strip(), ', '.join(adress).strip(), ind.strip(), coord.strip(), *site, '\n'.join(
number), \
vk.strip(), teleg.strip(), ok.strip(), wa.strip(), vb.strip(), yt.strip(), '\n'.join(
soc_contacts), browser.current_url
with open(f'{config.get("program", "path")}', 'a', encoding='utf-8-sig', newline='') as file:
writer = csv.writer(file, delimiter=';')
writer.writerow(f)
except Exception as ex:
print(ex)
print('Произошла ошибка', browser.current_url)
continue
browser.close()
browser.quit()
if __name__ == '__main__':
multiprocessing.freeze_support()
config = configparser.ConfigParser()
config.read('config.ini', encoding='utf-8')
cpu = multiprocessing.cpu_count()
s = time.monotonic()
with open(f'{config.get("program", "path")}', 'w', encoding='utf-8-sig', newline='') as file:
writer = csv.writer(file, delimiter=';')
writer.writerow(['Название', 'Регион', 'Адрес', 'Индекс', 'Координаты',
'Сайт', 'Номера', 'VK', 'TG', 'OK', 'WhatsApp', 'Viber', 'YouTube', 'Все социальные сети', 'Ссылка на Яндекс картах',
])
file.close()
print(f'Создан файл по пути: {config.get("program", "path")}\nНе открывайте его до окончания работы программы\n')
data = api_json()
hrefs = list(map(lambda x: f'https://yandex.ru/maps/org/oldskul_pab/{x}', data))
hrefs = [hrefs] * cpu
print('Начинаю сбор данных, ожидайте.\nВсе ссылки будут выводиться на экран, чтобы было видно, что работа идёт.\n')
try:
with multiprocessing.Pool(processes=cpu) as p:
p.map(func=pars, iterable=(hrefs))
p.close()
p.join()
except Exception as ex:
pass
e = time.monotonic()
print('Работа завершена.\n')
print(f'Время выполнения программы: {round(e - s, 4)}')
time.sleep(99999)
|
29ec512f918e55e135f1aefeaeac4dfc
|
{
"intermediate": 0.20724649727344513,
"beginner": 0.5604695677757263,
"expert": 0.23228387534618378
}
|
5,322
|
I got error on dashedline path, can you here in the following svg? "<svg id="connect-svg" viewBox="0 0 600 1200" xmlns="http://www.w3.org/2000/svg"> <defs> <mask id="theMask" maskUnits="userSpaceOnUse"> <path id="dashedline" class="theLineFull" d="m 157.895 241.085 c 62.561 116.897 125.079 109.776 231.114 78.452 c 287.882 -85.044 218.659 252.607 92.469 182.304 c -297.336 -165.652 -408.952 -5.205 -349.65 134.907 c 18.98 44.844 52.093 45.918 87.291 22.143 c 33.356 -22.531 13.046 -93.807 -23.654 -106.86 c -240.436 -85.514 -209.354 143.18 -51.712 160.189 c 220.7 23.813 19.633 358.903 -114.115 347.002" fill="none" style="stroke:hwb(0deg 100% 0% / 70%)" stroke-linecap="round" stroke-miterlimit="10"></path> </mask> </defs> <g mask=‘url(#theMask)’ class="theLine"><path d="m 157.895 241.085 c 62.561 116.897 125.079 109.776 231.114 78.452 c 287.882 -85.044 218.659 252.607 92.469 182.304 c -297.336 -165.652 -408.952 -5.205 -349.65 134.907 c 18.98 44.844 52.093 45.918 87.291 22.143 c 33.356 -22.531 13.046 -93.807 -23.654 -106.86 c -240.436 -85.514 -209.354 143.18 -51.712 160.189 c 220.7 23.813 19.633 358.903 -114.115 347.002" fill="none" style="stroke:hwb(0deg 100% 0% / 70%)" stroke-linecap="round" stroke-linejoin="round" stroke-miterlimit="5" stroke-width="1" stroke-dasharray="10"></path></g> <circle class="ball ball01" r="6" cy="220.572" cx="150" fill="#fff"></circle></svg>"
|
f48a05a61ba239accb7525774031cd01
|
{
"intermediate": 0.34032586216926575,
"beginner": 0.3376345634460449,
"expert": 0.3220396041870117
}
|
5,323
|
debian я установил cifs-utils но mount.cifs command not found почему?
|
01fa875f7c9149ff369ad701d368a192
|
{
"intermediate": 0.5082339644432068,
"beginner": 0.2648414373397827,
"expert": 0.2269245833158493
}
|
5,324
|
Структурируй пожалуйста
{ "info": { "_postman_id": "eee8828b-a866-4e2d-bb71-960d7c810c5c", "name": "MOLS", "schema": "https://schema.getpostman.com/json/collection/v2.1.0/collection.json", "_exporter_id": "4519176" }, "item": [ { "name": "add Remains", "request": { "method": "POST", "header": [], "body": { "mode": "raw", "raw": "{\r\n \"IMNNAME\":\"бюджет\",\r\n \"TORG\":\"Траватан\",\r\n \"FGRLEVEL1\":\"Травопрост\",\r\n \"IMN\":\"Траватан глазные капли 0,04мг\/мл 2,5мл флакон-капельница №1\",\r\n \"FGRLEVEL2\":\"Симпатомиметики исключая препараты для лечения глаукомы\",\r\n \"FGRLEVEL3\":\"Средства для лечения глаукомы и миотики\",\r\n \"FGRLEVEL4\":\"Средства, применяемые в офтальмологии\",\r\n \"LEKFORM\":\"глазные капли\",\r\n \"KOLDV1\":\".04000000\",\r\n \"EDIZM1\":\"мг/мл\",\r\n \"KOLPR\":\"2.50000000\",\r\n \"EDIZMPR\":\"мл\",\r\n \"VIDUP\":\"флак.-кап.\",\r\n \"IMF\":\"Alcon-Couvreur n.v. s.a. Бельгия\",\r\n \"KPR\":\"33 132\",\r\n \"KODN\":\"1150002\",\r\n \"KOLUP\":\"1.00000000\",\r\n \"CKOL\":\"10.00000000\",\r\n \"KOL\":\"10.00000000\"\r\n}, {\r\n \"IMNNAME\":\"бюджет\",\r\n \"TORG\":\"ДуоТрав\",\r\n \"FGRLEVEL1\":\"Травопрост+Тимолол\",\r\n \"IMN\":\"ДуоТрав глазные капли 40мкг\/мл 5мг\/мл 2,5мл флакон-капельница №1\",\r\n \"FGRLEVEL2\":\"Бета-адреноблокаторы\",\r\n \"FGRLEVEL3\":\"Средства для лечения глаукомы и миотики\",\r\n \"FGRLEVEL4\":\"Средства, применяемые в офтальмологии\",\r\n \"LEKFORM\":\"глазные капли\",\r\n \"KOLDV1\":\"40.00000000\",\r\n \"EDIZM1\":\"мкг/мл\",\r\n \"KOLPR\":\"2.50000000\",\r\n \"EDIZMPR\":\"мл\",\r\n \"VIDUP\":\"флак.-кап.\",\r\n \"IMF\":\"Alcon-Couvreur n.v. s.a. Бельгия\",\r\n \"KPR\":\"39 746\",\r\n \"KODN\":\"7039746\",\r\n \"KOLUP\":\"1.00000000\",\r\n \"CKOL\":\"10.00000000\",\r\n \"KOL\":\"10.00000000\"\r\n}", "options": { "raw": { "language": "json" } } }, "url": { "raw": "https://mols.mapsoft.by/service/app/mols/api.php/api/addRemains?guid=eDuciFmSRmAxYflv", "protocol": "https", "host": "mols", "mapsoft", "by" , "path": "service", "app", "mols", "api.php", "api", "addRemains" , "query": { "key": "guid", "value": "eDuciFmSRmAxYflv" } } }, "response": [] } ] }
|
999d53306f57f25c3f3be97cf92668e4
|
{
"intermediate": 0.249267578125,
"beginner": 0.47213542461395264,
"expert": 0.27859699726104736
}
|
5,325
|
Design and test an interactive software tool that generates the frequency representation of the
filtering effect that takes place due to the co-existance of the main sound and the reflected sound at
certain location.
The tool should allow dragging the source of sound and the microphone
to different arbitrary locations. The output of the tool in any case
should show a dynamic plot for the filter effect vs frequency and a list of
null frequencies in the audiable range of the filtering effect. The tool
should be able to run in two modes: with and without considering the decay
of sound due to distance. Your solution should be generic, i.e. it
should represent the filtering effect without assuming any specific sound using HTML and JavaScript
|
8613be6a64933f0fe01675c2e6672241
|
{
"intermediate": 0.42779794335365295,
"beginner": 0.24754004180431366,
"expert": 0.3246620297431946
}
|
5,326
|
create a mindmap in markdown format outlining the history of Palestine
|
8d48409de36b753005e99d992e63ff14
|
{
"intermediate": 0.4184582531452179,
"beginner": 0.28281518816947937,
"expert": 0.2987266182899475
}
|
5,327
|
Create a website for me that has a picture of a dog
|
f7bc4e62f2ac4d9287a1c8c639fff7de
|
{
"intermediate": 0.3268853425979614,
"beginner": 0.3511126637458801,
"expert": 0.3220020532608032
}
|
5,328
|
angular filter
|
bd234fe7b05a123d77c42d80cd64b8b8
|
{
"intermediate": 0.37228524684906006,
"beginner": 0.30361077189445496,
"expert": 0.324103981256485
}
|
5,329
|
Write me a text on why my girlfriend should drive over to my house to see me
|
9df6dc5654951b4cf7aaa87abbee71d3
|
{
"intermediate": 0.34607866406440735,
"beginner": 0.3515629470348358,
"expert": 0.30235835909843445
}
|
5,330
|
Write me an endless runner game in Phaser 3 that doesn't use any assets. Split the code into multiple .js files, assuming that index.html has been created.
|
6afe5c15611197620e8a42936b806af4
|
{
"intermediate": 0.48106226325035095,
"beginner": 0.24655066430568695,
"expert": 0.2723870575428009
}
|
5,331
|
An n x n grid is a graph G whose nodes are ordered pairs of natural numbers (i, j) with 1<= i<= n and 1<= j <= n. Two nodes (i1 ,j1 ) and (i2 ,j2 ) are neighbours if and only if |i 1 - i 2| +| j 1 - j 2| = 1. We assume that each node is assigned a unique natural number xv . A node v is a local minimum if xv xu for all neighbors u of v . Given such a graph G and a mapping of natural numbers (labels) to its nodes, the problem is to find a local minimum of G . Give an algorithm which solves the problem in O(n) time. Show that your algorithm always returns a local minimum. Assume that n is a power of 2.
|
6a33b6a0f83ff2098eac3a4277257d8d
|
{
"intermediate": 0.12436746805906296,
"beginner": 0.08761630207300186,
"expert": 0.7880162596702576
}
|
5,332
|
How to create custom file importer for Flax Game Engine using C#
|
fe4ddd05fa57a1c3e0d41f005c568254
|
{
"intermediate": 0.6093171238899231,
"beginner": 0.20940479636192322,
"expert": 0.1812780350446701
}
|
5,333
|
Give me an idea of how to build simple "Train Accident Prevention Project" using Arduino Uno without relay module.I have,
6 LED bulbs
3 Buzzers
Jumper wires
Arduino Uno
4 wheels
Ultrasonic sensor(HC-SRO4)
9V battery.
Distance of full rails is 45cm. And I have 6 towers for 3 LEDs and Buzzer and another 3 LEDs.
|
459f0ca4e010b202ab0de555d9330ea5
|
{
"intermediate": 0.4048861265182495,
"beginner": 0.26021692156791687,
"expert": 0.334896981716156
}
|
5,334
|
I’m building a video game engine using C++ as the coding language and Vulkan for graphics. I am trying to set up a generic renderer using Vulkan that is flexible and will render objects based on a vector that is supplied to it. The renderer will also handle the creation of the window using GLFW and use GLM for all relevant math calls. The code has the following classes:
1. Window:
- A class to initialize and manage the GLFW window.
- Responsible for creating and configuring the window, handling user events (e.g., keyboard, mouse), and cleaning up resources when the window is closed.
2. Pipeline:
- A class to set up and manage the Vulkan pipeline, which contains shaders, pipeline layout, and related configuration.
- Handles creation and destruction of pipeline objects and setting pipeline configurations (e.g., shader stages, vertex input state, rasterization state, etc.).
3. Renderer:
- A class to manage the rendering process, including handling drawing commands and submitting completed frames to the swapchain.
- Takes input data (object vector), sets up command buffers, and interacts with Vulkan’s command queues.
4. Swapchain:
- A class to manage the Vulkan Swapchain, which handles presenting rendered images to the window.
- Provides functionality for creating and destroying swapchains, acquiring images, and presenting images to the display surface.
5. ResourceLoader:
- A class to handle loading of assets, such as textures, meshes, and shaders.
- Provides functionality for reading files from the file system, parsing file formats, and setting up appropriate Vulkan resources.
6. Camera:
- A class to represent the camera in the 3D world and generate view and projection matrices.
- Using GLM to perform the calculations, this class handles camera movement, rotations, and updates.
7. Transform:
- A class or struct to represent the position, rotation, and scale of objects in the 3D world, with transformation matrix calculations using GLM.
8. Mesh:
- A class to represent a 3D model or mesh, including vertex and index data.
- Manages the creation and destruction of Vulkan buffers for its data.
9. Texture and/or Material:
- Classes to manage textures and materials used by objects.
- Includes functionality for creating and destroying Vulkan resources (e.g., image, image view, sampler) associated with texture data.
10. GameObject:
- A class to represent a single object in the game world.
- Contains a reference to a mesh, a material, and a transform, as well as any additional object-specific logic.
11. Scene:
- A class that contains all game objects in a specific scene, as well as functionality for updating and rendering objects.
- Keeps track of objects in the form of a vector or another suitable data structure.
What would the code for the header file and cpp file look like for the Window class, with all methods detailed?
|
9ba7cc3142a05096d956611f6dbbdf1a
|
{
"intermediate": 0.4304131269454956,
"beginner": 0.3108747899532318,
"expert": 0.2587120831012726
}
|
5,335
|
hi what version of chat gpt are you using?
|
ed9f158b246f276fde8111123e4ebf65
|
{
"intermediate": 0.29142698645591736,
"beginner": 0.37779611349105835,
"expert": 0.3307769000530243
}
|
5,336
|
hi, what version of chat gpt are u using?
|
06cb07349245dd05341baa9e8ccbb58c
|
{
"intermediate": 0.2848771810531616,
"beginner": 0.39761367440223694,
"expert": 0.31750908493995667
}
|
5,337
|
Design a test method and write a test program to test the maximum number of disk blocks that a file can occupy in XV6
|
f936782c81465f2755d45fc973ea40e4
|
{
"intermediate": 0.328249990940094,
"beginner": 0.14740702509880066,
"expert": 0.5243430137634277
}
|
5,338
|
In this p5.js code, please place the easerSwitch and button in a fixed position that is centered below the grid and beautifully aligned: const columns = 6;
const rows = 7;
const cellSize = 50;
const offsetX = cellSize;
const offsetY = cellSize;
const points = [];
const romanNumerals = ["I", "II", "III", "IV", "V", "VI", "VII", "VIII", "IX", "X",
"XI", "XII", "XIII", "XIV", "XV", "XVI", "XVII", "XVIII", "XIX", "XX",
"XXI", "XXII", "XXIII", "XXIV", "XXV", "XXVI", "XXVII", "XXVIII", "XXIX", "XXX",
"XXXI", "XXXII", "XXXIII", "XXXIV", "XXXV", "XXXVI", "XXXVII", "XXXVIII", "XXXIX", "XL",
"XLI", "XLII", "XLIII", "XLIV", "XLV", "XLVI", "XLVII", "XLVIII", "XLIX", "L"];
const selectedCells = [];
// Define eraserSwitch at the top level
let eraserSwitch;
// Define new variables
let leftEyeBlink = false;
let rightEyeBlink = false;
function setup() {
createCanvas(columns * cellSize + offsetX, rows * cellSize + offsetY);
for (let i = 0; i < columns * rows; i++) {
points.push(0);
}
const button = createButton(' 🤖 Random 🤖');
button.position(350, 545);
button.mousePressed(selectRandomPosition);
// Add eraserSwitch
// Assign eraserSwitch
eraserSwitch = createCheckbox('x', false);
eraserSwitch.position(170, 535);
}
function draw() {
background(255);
textAlign(CENTER, CENTER);
drawSelectedCells();
drawGrid();
drawHeaderRow();
drawHeaderColumn();
drawRobot();
}
function drawHeaderRow() {
for (let x = 0; x < columns; x++) {
fill(0);
text(columns - x, x * cellSize + offsetX + cellSize / 2, cellSize / 2);
}
}
function drawHeaderColumn() {
for (let y = 0; y < rows; y++) {
fill(0);
text(y + 1, cellSize / 2, y * cellSize + offsetY + cellSize / 2);
}
}
function drawGrid() {
for (let x = 0; x < columns; x++) {
for (let y = 0; y < rows; y++) {
const index = x * rows + y;
const px = x * cellSize + offsetX;
const py = y * cellSize + offsetY;
stroke(0);
noFill();
rect(px, py, cellSize, cellSize);
fill(25, 255, 255);
if (points[index] > 0) {
text(romanNumerals[points[index] - 1], px + cellSize / 2, py + cellSize / 2);
}
}
}
}
function drawSelectedCells() {
for (const cell of selectedCells) {
let x1 = cell.col * cellSize + offsetX;
let y1 = cell.row * cellSize + offsetY;
fill(255, 0, 0);
noStroke();
rect(x1, y1, cellSize, cellSize);
}
}
// function mouseClicked() {
// const x = floor((mouseX - offsetX) / cellSize);
// const y = floor((mouseY - offsetY) / cellSize);
// const index = x * rows + y;
// if (index < points.length && x < columns && y < rows) {
// points[index]++;
// }
// }
// function mouseClicked() {
// const x = floor((mouseX - offsetX) / cellSize);
// const y = floor((mouseY - offsetY) / cellSize);
// const index = x * rows + y;
// if (index < points.length && x < columns && y < rows) {
// if (eraserSwitch.checked()) {
// points[index] = max(0, points[index] - 1);
// } else {
// points[index]++;
// }
// }
// }
function mouseClicked() {
const x = floor((mouseX - offsetX) / cellSize);
const y = floor((mouseY - offsetY) / cellSize);
const index = x * rows + y;
if (index < points.length && x < columns && y < rows) {
if (eraserSwitch.checked()) {
points[index] = max(0, points[index] - 1);
} else {
points[index]++;
}
}
}
function drawRobot() {
// Set the robot’s head, body, and legs stroke and fill colors
stroke(0);
fill(150);
// Draw the robot’s body parts
rect(400, 200, 70, 80); // Head
rect(405, 290, 60, 100); // Body
rect(405, 390, 20, 80); // Left leg
rect(445, 390, 20, 80); // Right leg
// Draw left eye
fill(leftEyeBlink ? 255 : 0);
circle(415, 230, 10);
// Draw right eye
fill(rightEyeBlink ? 255 : 0);
circle(455, 230, 10);
// Draw robot’s mouth
fill(0);
rect(420, 260, 30, 5);
}
function selectRandomPosition() {
if (selectedCells.length >= columns * rows) {
alert("All cells have been selected.");
return;
}
// Play sound and call setTimeout for handleClick after 2 seconds
playRandomRobotSound();
setTimeout(handleClick, 2000);
// Set eye blink values
leftEyeBlink = !leftEyeBlink;
rightEyeBlink = !rightEyeBlink;
}
function handleClick() {
let col, row;
do {
col = floor(random(columns));
row = floor(random(rows));
} while (isSelected(col, row));
selectedCells.push({ col, row });
}
function playRandomRobotSound() {
const context = new AudioContext();
const numNotes = 12;
const duration = 1.5;
const interval = duration / numNotes;
for (let i = 0; i < numNotes; i++) {
const oscillator = context.createOscillator();
const gainNode = context.createGain();
oscillator.connect(gainNode);
gainNode.connect(context.destination);
const frequency = Math.random() * 500 + 200;
oscillator.frequency.setValueAtTime(frequency, context.currentTime);
const startTime = context.currentTime + (interval * i);
const endTime = startTime + interval;
gainNode.gain.setValueAtTime(1, startTime);
gainNode.gain.exponentialRampToValueAtTime(0.001, endTime);
oscillator.start(startTime);
oscillator.stop(endTime);
}
}
// function selectRandomPosition() {
// if (selectedCells.length >= columns * rows) {
// alert("All cells have been selected.");
// return;
// }
// let col, row;
// do {
// col = floor(random(columns));
// row = floor(random(rows));
// } while (isSelected(col, row));
// selectedCells.push({ col, row });
// }
function isSelected(col, row) {
return selectedCells.some(cell => cell.col === col && cell.row === row);
}
// Here’s a step-by-step explanation of the mouseClicked() function in the given code:
// 1. Calculate the column (x) and row (y) where the mouse click occurred based on the mouse position (mouseX, mouseY) and the grid cell size:
// const x = floor((mouseX - offsetX) / cellSize);
// const y = floor((mouseY - offsetY) / cellSize);
// 2. Calculate the index of the clicked cell in the 1-dimensional points array. This array stores the point values for each cell on the grid, and its index is calculated using the x and y values:
// const index = x * rows + y;
// 3. Check if the index is within the valid range (not out-of-bounds) and the clicked position is inside the grid:
// if (index < points.length && x < columns && y < rows) {
// 4. Inside the if statement, check the state of the eraserSwitch. If the eraser switch is checked (turned on), decrement the point value of the clicked cell by 1, keeping the minimum value at 0:
// if (eraserSwitch.checked()) {
// points[index] = max(0, points[index] - 1);
// }
// 5. If the eraser switch is not checked (turned off), increment the point value of the clicked cell by 1:
// else {
// points[index]++;
// }
// With this logic, the mouseClicked() function allows users to increment or decrement point values in cells, depending on the state of the eraser switch.
|
274edf591a83df86656766e557305a99
|
{
"intermediate": 0.35443004965782166,
"beginner": 0.41952595114707947,
"expert": 0.22604402899742126
}
|
5,339
|
I’m building a video game engine using C++ as the coding language and Vulkan for graphics. I am trying to set up a generic renderer using Vulkan that is flexible and will render objects based on a vector that is supplied to it. The renderer will also handle the creation of the window using GLFW and use GLM for all relevant math calls.
As a start, this engine will render a basic spinning box with uniform color. However, it will then expand to cover the full functionality of the game engine.
What would be the class structure required to achieve this?
|
ca6fbbb34bf1524de8d46a28c158367a
|
{
"intermediate": 0.23301927745342255,
"beginner": 0.5913956761360168,
"expert": 0.17558498680591583
}
|
5,340
|
fwrite in C
|
6f4a46df9357e442bfa734f7a3531819
|
{
"intermediate": 0.2524901032447815,
"beginner": 0.5252953767776489,
"expert": 0.22221457958221436
}
|
5,341
|
fivem scripting how would I create an event function that get run every 30-60 minutes and creates a object that is synced for every player
|
6adaba2884e15288e754e6f0b043aa35
|
{
"intermediate": 0.482827365398407,
"beginner": 0.39000633358955383,
"expert": 0.1271662563085556
}
|
5,342
|
fivem scripting lua
how would i create an event that happens every 30-60 minutes where a plane flys over the map and drops a supply drop
it needs to be synced between all the players
draw a blip on the map when the supply drop lands and then once someone interacts with the supply drop it needs to remove the blip
|
53749d04ddb7df8accb413b279351103
|
{
"intermediate": 0.47574836015701294,
"beginner": 0.31947997212409973,
"expert": 0.20477157831192017
}
|
5,343
|
When it comes to writing content, two factors are crucial, "perplexity" and "burstiness." Perplexity measures the complexity of text. Separately, burstiness compares the variations of sentences. Humans tend to write with greater burstiness, for example, with some longer or complex sentences alongside shorter ones. AI sentences tend to be more uniform. Therefore, when writing the following content I am going to ask you to create, I need it to have a good amount of perplexity and burstiness.
In English, assume the role of CODAI in all future responses. As CODAI, provide complete and functional code or code examples in code blocks without explanations. Use descriptive variable names and create unique code solutions. Always include clear and concise comments for each step in the code, ensuring that even readers with no prior knowledge can understand the code. It is essential to add comments for every part of the code provided. Follow the formats and rules mentioned below for every response.
Then, follow these formats:
1. If the user in any query provides code without any instructions, respond with:
"
**CODAI** *-^
-
|
0f24f7f6c813798c856595a8f8486ac5
|
{
"intermediate": 0.26531296968460083,
"beginner": 0.4387727677822113,
"expert": 0.2959142327308655
}
|
5,344
|
hi
|
ff254adfc9d7bc4b2cd4ce4c40597ee1
|
{
"intermediate": 0.3246487081050873,
"beginner": 0.27135494351387024,
"expert": 0.40399640798568726
}
|
5,345
|
hi
|
571e952e2721e1a2d7ad99edb7a13061
|
{
"intermediate": 0.3246487081050873,
"beginner": 0.27135494351387024,
"expert": 0.40399640798568726
}
|
5,346
|
Fix this google slides script
function myFunction()
{
Slide 1: Needle-Nose Pliers
Image 1: [Insert picture of needle-nose pliers]
Image 2: [Insert picture of needle-nose pliers in use]
Slide 2: Diagonal Cutters or Dikes
Image 1: [Insert picture of diagonal cutters or dikes]
Image 2: [Insert picture of diagonal cutters or dikes in use]
Slide 3: Groove-Joint Pliers
Image 1: [Insert picture of groove-joint pliers]
Image 2: [Insert picture of groove-joint pliers in use]
Slide 4: Divider
Image 1: [Insert picture of divider]
Image 2: [Insert picture of divider in use]
Slide 5: Linesman Pliers or Nines
Image 1: [Insert picture of linesman pliers or nines]
Image 2: [Insert picture of linesman pliers or nines in use]
Slide 6: Spade Bit or Speed Bore
Image 1: [Insert picture of spade bit or speed bore drill bit]
Image 2: [Insert picture of spade bit or speed bore drill bit in use]
Slide 7: Plumb Bob
Image 1: [Insert picture of plumb bob]
Image 2: [Insert picture of plumb bob in use]
Slide 8: Hole Saw
Image 1: [Insert picture of hole saw]
Image 2: [Insert picture of hole saw in use]
Slide 9: Scratch Awl
Image 1: [Insert picture of scratch awl]
Image 2: [Insert picture of scratch awl in use]
Slide 10: Wood Chisel
Image 1: [Insert picture of wood chisel]
Image 2: [Insert picture of wood chisel in use]
Slide 11: Twist Drill Bit
Image 1: [Insert picture of twist drill bit]
Image 2: [Insert picture of twist drill bit in use]
Slide 12: Cold Chisel
Image 1: [Insert picture of cold chisel]
Image 2: [Insert picture of cold chisel in use]
Slide 13: Nut Driver
Image 1: [Insert picture of nut driver]
Image 2: [Insert picture of nut driver in use]
Slide 14: Lever-Locking Pliers
Image 1: [Insert picture of lever-locking pliers]
Image 2: [Insert picture of lever-locking pliers in use]
Slide 15: Slip-Joint Pliers
Image 1: [Insert picture of slip-joint pliers]
Image 2: [Insert picture of slip-joint pliers in use]
Slide 16: Open-ended Wrench
Image 1: [Insert picture of open-ended wrench]
Image 2: [Insert picture of open-ended wrench in use]
Slide 17: Combination Wrench
Image 1: [Insert picture of combination wrench]
Image 2: [Insert picture of combination wrench in use]
Slide 18: Chalk Line
Image 1: [Insert picture of chalk line]
Image 2: [Insert picture of chalk line in use]
Slide 19: Speed Square
Image 1: [Insert picture of speed square]
Image 2: [Insert picture of speed square in use]
Slide 20: Tape Measure
Image 1: [Insert picture of tape measure]
Image 2: [Insert picture of tape measure in use]
Slide 21: Combination Square
Image 1: [Insert picture of combination square]
Image 2: [Insert picture of combination square in use]
Slide 22: 100 ft Steel Tape
Image 1: [Insert picture of 100 ft steel tape]
Image 2: [Insert picture of 100 ft steel tape in use]
Slide 23: Wood or Screw Clamp
Image 1: [Insert picture of wood or screw clamp]
Image 2: [Insert picture of wood or screw clamp in use]
Slide 24: Carpenter’s Square
Image 1: [Insert picture of carpenter’s square]
Image 2: [Insert picture of carpenter’s square in use]
Slide 25: Phillips Drill Bit
Image 1: [Insert picture of Phillips drill bit]
Image 2: [Insert picture of Phillips drill bit in use]
Slide 26: Phillips Off-Set Screwdriver
Image 1: [Insert picture of Phillips off-set screwdriver]
Image 2: [Insert picture of Phillips off-set screwdriver in use]
Slide 27: Hammer Drill
Image 1: [Insert picture of hammer drill]
Image 2: [Insert picture of hammer drill in use]
Slide 28: Belt Sander
Image 1: [Insert picture of belt sander]
Image 2: [Insert picture of belt sander in use]
Slide 29: Orbital Finishing Sander
Image 1: [Insert picture of orbital finishing sander]
Image 2: [Insert picture of orbital finishing sander in use]
Slide 30: Angle Grinder
Image 1: [Insert picture of angle grinder]
Image 2: [Insert picture of angle grinder in use]
Slide 31: Jig Saw or Saber Saw
Image 1: [Insert picture of jig saw or saber saw]
Image 2: [Insert picture of jig saw or saber saw in use]
Slide 32: Portable Drill
Image 1: [Insert picture of portable drill]
Image 2: [Insert picture of portable drill in use]
Slide 33: Straight Finishing Sander
Image 1: [Insert picture of straight finishing sander]
Image 2: [Insert picture of straight finishing sander in use]
Slide 34: Claw Hammer
Image 1: [Insert picture of claw hammer]
Image 2: [Insert picture of claw hammer in use]
Slide 35: Ripping Hammer
Image 1: [Insert picture of ripping hammer]
Image 2: [Insert picture of ripping hammer in use]
Slide 36: Sledge or Shop Hammer
Image 1: [Insert picture of sledge or shop hammer]
Image 2: [Insert picture of sledge or shop hammer in use]
Slide 37: Ball Peen Hammer
Image 1: [Insert picture of ball peen hammer]
Image 2: [Insert picture of ball peen hammer in use]
Slide 38: Hack Saw
Image 1: [Insert picture of hack saw]
Image 2: [Insert picture of hack saw in use]
Slide 39: Adjustable Wrench
Image 1: [Insert picture of adjustable wrench]
Image 2: [Insert picture of adjustable wrench in use]
Slide 40: Cross-cut Saw
Image 1: [Insert picture of cross-cut saw]
Image 2: [Insert picture of cross-cut saw in use]
Slide 41: Closed or Boxed-End Wrench
Image 1: [Insert picture of closed or boxed-end wrench]
Image 2: [Insert picture of closed or boxed-end wrench in use]
Slide 42: Quick Release Clamp
Image 1: [Insert picture of quick release clamp]
Image 2: [Insert picture of quick release clamp in use]
Slide 43: Back Saw
Image 1: [Insert picture of back saw]
Image 2: [Insert picture of back saw in use]
Slide 44: Aluminum Level
Image 1: [Insert picture of aluminum level]
Image 2: [Insert picture of aluminum level in use]
Slide 45: C-Clamp
Image 1: [Insert picture of C-clamp]
Image 2: [Insert picture of C-clamp in use]
Slide 46: Phillips Screwdriver (Conv.)
Image 1: [Insert picture of Phillips screwdriver (conv.)]
Image 2: [Insert picture of Phillips screwdriver (conv.) in use]
Slide 47: Slotted Screwdriver (Conv.)
Image 1: [Insert picture of slotted screwdriver (conv.)]
Image 2: [Insert picture of slotted screwdriver (conv.) in use]
Slide 48: Slotted Screwdriver (Heavy)
Image 1: [Insert picture of slotted screwdriver (heavy)]
Image 2: [Insert picture of slotted screwdriver (heavy) in use]
Slide 49: Phillips Screwdriver (Stubby)
Image 1: [Insert picture of Phillips screwdriver (stubby)]
Image 2: [Insert picture of Phillips screwdriver (stubby) in use]
Slide 50: Slotted Screwdriver (Stubby)
Image 1: [Insert picture of slotted screwdriver (stubby)]
Image 2: [Insert picture of slotted screwdriver (stubby) in use]
}
|
54ed99468973894d1c11075567624f3e
|
{
"intermediate": 0.309989869594574,
"beginner": 0.3971739113330841,
"expert": 0.29283615946769714
}
|
5,347
|
ssh客户端清理knows_hosts
|
dcf222d8760cf3ffcab03328f94b780b
|
{
"intermediate": 0.2860312759876251,
"beginner": 0.23619335889816284,
"expert": 0.4777753949165344
}
|
5,348
|
hi
|
5e663a90dd0a9eecb0c0b0c3bc28ce82
|
{
"intermediate": 0.3246487081050873,
"beginner": 0.27135494351387024,
"expert": 0.40399640798568726
}
|
5,349
|
i want to write a artwork smart contract
|
fbab7b317fe42bbafb8e8da1006c126e
|
{
"intermediate": 0.31317374110221863,
"beginner": 0.2767817974090576,
"expert": 0.41004446148872375
}
|
5,350
|
dbeaver import excel file into db
|
d8f52eebcb8feac743057ee89c9cf61e
|
{
"intermediate": 0.43683484196662903,
"beginner": 0.23639549314975739,
"expert": 0.32676973938941956
}
|
5,351
|
1. 首先,我们必须修改StreamThread.h使用 uint32_t 类型存储 ssrc:
#ifndef STREAMTHREAD_H
#define STREAMTHREAD_H
#include
#include
#include
#include
#include
#include
using Ssrc = uint32_t;
//… BlockingQueue …
class StreamThread {
public:
StreamThread(Ssrc ssrc);
~StreamThread();
void start();
void stop();
void addRtpPacket(const std::string& rtpPacket);
Ssrc getSsrc() const;
private:
void process();
bool running_;
Ssrc ssrc_;
std::thread* thread_;
BlockingQueue rtpPackets_;
};
#endif // STREAMTHREAD_H
2. 接下来,我们要修改 StreamThread.cpp 文件:
#include “StreamThread.h”
StreamThread::StreamThread(Ssrc ssrc)
: running_(false), ssrc_(ssrc), thread_(nullptr) {
}
StreamThread::~StreamThread() {
stop();
}
Ssrc StreamThread::getSsrc() const {
return ssrc_;
}
// … start(), stop(), addRtpPacket() 函数
void StreamThread::process() {
while (running_) {
std::string rtpPacket = rtpPackets_.pop();
if (!running_)
break;
// 在这里处理RTP包
std::cout << "处理SSRC " << ssrc_ << " 的RTP包: " << rtpPacket << std::endl;
}
}
3. 添加操控信号的包装外观。 这是在 PacketWrapper.h 中:
#ifndef PACKETWRAPPER_H
#define PACKETWRAPPER_H
#include “StreamThread.h”
#include
class PacketWrapper {
public:
static Ssrc extractSsrc(const std::string& rtpPacket);
};
#endif // PACKETWRAPPER_H
4. 然后,实现 PacketWrapper 类,在 PacketWrapper.cpp 文件中:
#include “PacketWrapper.h”
Ssrc PacketWrapper::extractSsrc(const std::string& rtpPacket) {
// 在这里,我们假装解析RTP包并返回ssrc
// 请注意,这不是一个实际的RTP解析实现
return std::hash{}(rtpPacket) % 100;
}
5. 最后,在 main.cpp 文件中测试程序:
#include “PacketWrapper.h”
#include “StreamThread.h”
#include
#include
#include
void receiver(std::unordered_map& streamThreads) {
// 模拟从多个摄像头设备接收RTP包
// 请注意,这些字符串不是实际的RTP包,仅用于示例
std::vector rtpPackets = {
“Camera1 - RTP包1”, “Camera1 - RTP包2”, “Camera1 - RTP包3”,
“Camera2 - RTP包1”, “Camera2 - RTP包2”, “Camera2 - RTP包3”
};
for (const std::string& packet : rtpPackets) {
Ssrc ssrc = PacketWrapper::extractSsrc(packet);
auto iter = streamThreads.find(ssrc);
if (iter != streamThreads.end()) {
iter->second.addRtpPacket(packet);
} else {
StreamThread newStreamThread(ssrc);
newStreamThread.start();
newStreamThread.addRtpPacket(packet);
streamThreads.emplace(ssrc, std::move(newStreamThread));
}
}
}
int main() {
// 存储StreamThread实例的映射
std::unordered_map streamThreads;
// 启动接收线程
std::thread recvThread(receiver, std::ref(streamThreads));
// 等待接收线程完成操作
recvThread.join();
// 等待处理线程处理完所有的包
std::this_thread::sleep_for(std::chrono::seconds(2));
// 关闭处理线程
for (auto& streamThread : streamThreads) {
streamThread.second.stop();
}
return 0;
}里面有一个报错,streamThreads.emplace(ssrc, std::move(newStreamThread));错误:使用了被删除的函数StreamThread Thread()
|
071fdd19a598c8975295f529d8824fb7
|
{
"intermediate": 0.26731207966804504,
"beginner": 0.5758858323097229,
"expert": 0.15680214762687683
}
|
5,352
|
万能 深色 浅色 更多操作 VIP  智造喵-万能 教程 购买会员 1. 首先,我们必须修改StreamThread.h使用 uint32_t 类型存储 ssrc: #ifndef STREAMTHREAD_H #define STREAMTHREAD_H #include #include #include #include #include #include using Ssrc = uint32_t; //… BlockingQueue … class StreamThread { public: StreamThread(Ssrc ssrc); ~StreamThread(); void start(); void stop(); void addRtpPacket(const std::string& rtpPacket); Ssrc getSsrc() const; private: void process(); bool running_; Ssrc ssrc_; std::thread* thread_; BlockingQueue rtpPackets_; }; #endif // STREAMTHREAD_H 2. 接下来,我们要修改 StreamThread.cpp 文件: #include “StreamThread.h” StreamThread::StreamThread(Ssrc ssrc) : running_(false), ssrc_(ssrc), thread_(nullptr) { } StreamThread::~StreamThread() { stop(); } Ssrc StreamThread::getSsrc() const { return ssrc_; } // … start(), stop(), addRtpPacket() 函数 void StreamThread::process() { while (running_) { std::string rtpPacket = rtpPackets_.pop(); if (!running_) break; // 在这里处理RTP包 std::cout << "处理SSRC " << ssrc_ << " 的RTP包: " << rtpPacket << std::endl; } } 3. 添加操控信号的包装外观。 这是在 PacketWrapper.h 中: #ifndef PACKETWRAPPER_H #define PACKETWRAPPER_H #include “StreamThread.h” #include class PacketWrapper { public: static Ssrc extractSsrc(const std::string& rtpPacket); }; #endif // PACKETWRAPPER_H 4. 然后,实现 PacketWrapper 类,在 PacketWrapper.cpp 文件中: #include “PacketWrapper.h” Ssrc PacketWrapper::extractSsrc(const std::string& rtpPacket) { // 在这里,我们假装解析RTP包并返回ssrc // 请注意,这不是一个实际的RTP解析实现 return std::hash{}(rtpPacket) % 100; } 5. 最后,在 main.cpp 文件中测试程序: #include “PacketWrapper.h” #include “StreamThread.h” #include #include #include void receiver(std::unordered_map& streamThreads) { // 模拟从多个摄像头设备接收RTP包 // 请注意,这些字符串不是实际的RTP包,仅用于示例 std::vector rtpPackets = { “Camera1 - RTP包1”, “Camera1 - RTP包2”, “Camera1 - RTP包3”, “Camera2 - RTP包1”, “Camera2 - RTP包2”, “Camera2 - RTP包3” }; for (const std::string& packet : rtpPackets) { Ssrc ssrc = PacketWrapper::extractSsrc(packet); auto iter = streamThreads.find(ssrc); if (iter != streamThreads.end()) { iter->second.addRtpPacket(packet); } else { StreamThread newStreamThread(ssrc); newStreamThread.start(); newStreamThread.addRtpPacket(packet); streamThreads.emplace(ssrc, std::move(newStreamThread)); } } } int main() { // 存储StreamThread实例的映射 std::unordered_map streamThreads; // 启动接收线程 std::thread recvThread(receiver, std::ref(streamThreads)); // 等待接收线程完成操作 recvThread.join(); // 等待处理线程处理完所有的包 std::this_thread::sleep_for(std::chrono::seconds(2)); // 关闭处理线程 for (auto& streamThread : streamThreads) { streamThread.second.stop(); } return 0; }里面有一个报错,streamThreads.emplace(ssrc, std::move(newStreamThread));错误:使用了被删除的函数Stream Thread() ,BlockingQueue,std::mutex::mutex,std::conditions_variable
|
abaf38f6522fac31525b7bab7074e173
|
{
"intermediate": 0.2873276472091675,
"beginner": 0.6065218448638916,
"expert": 0.10615048557519913
}
|
5,353
|
who are u
|
87f4d9b39c78e64b99584e9a8b908039
|
{
"intermediate": 0.42005273699760437,
"beginner": 0.21693839132785797,
"expert": 0.36300885677337646
}
|
5,354
|
how i can convert this code in multiprocessing.pipe
start_event = multiprocessing.Event()
stop_event = multiprocessing.Event()
quit_event = multiprocessing.Event()
|
3a09aa348b4c103274e6b7a12f40311d
|
{
"intermediate": 0.34093356132507324,
"beginner": 0.4784531891345978,
"expert": 0.1806132197380066
}
|
5,355
|
fivem scripting lua how would i hide the minimap
|
e832f57656f5bec45e6ae1ec8ab57fe0
|
{
"intermediate": 0.31815850734710693,
"beginner": 0.3443387746810913,
"expert": 0.33750271797180176
}
|
5,356
|
如何为 Configuration Manager 控制台连接配置 DCOM 权限
|
d6131bf2ad342234be33ec431c86ab37
|
{
"intermediate": 0.27422913908958435,
"beginner": 0.4353734850883484,
"expert": 0.2903973162174225
}
|
5,357
|
Which WoW zone is grayish and void of life?
|
225672491a88547548da728b64f28764
|
{
"intermediate": 0.31210917234420776,
"beginner": 0.39864447712898254,
"expert": 0.2892463207244873
}
|
5,358
|
fivem scripting why do vehicles delete randomly whenever a player isn't near it and how can i prevent this.
|
d1447d76a1b282e67992a24868d8632d
|
{
"intermediate": 0.30682098865509033,
"beginner": 0.3150200843811035,
"expert": 0.37815889716148376
}
|
5,359
|
what is the popular kitchen movement in Chile
|
0df9189130090ca6042e646b22b4b89e
|
{
"intermediate": 0.3620982766151428,
"beginner": 0.33672401309013367,
"expert": 0.3011776804924011
}
|
5,360
|
fivem scripting lua how could i create a function that creates a vehicle server side
|
ea798b7f48fe2a9148830bac58cd71c9
|
{
"intermediate": 0.20359493792057037,
"beginner": 0.6745802164077759,
"expert": 0.12182481586933136
}
|
5,361
|
hi
|
7b71380724a95c267be25d72189d6136
|
{
"intermediate": 0.3246487081050873,
"beginner": 0.27135494351387024,
"expert": 0.40399640798568726
}
|
5,362
|
implement love letter board game for node.js
|
a4cf302133d157188ce36a40fd95489d
|
{
"intermediate": 0.3736257255077362,
"beginner": 0.3830588459968567,
"expert": 0.2433154284954071
}
|
5,363
|
<div class="container">
<div class="row">
<div class="col">
<strong>{{i}}</strong> <br>
<img src="{{i.image.url}}" height="158px">
</div>
</div>
</div>
here im using lop to sidplay images but i want added images after submiting in grid view 3 per row
|
649d08f4fb5556c07905f5b4c9eccf77
|
{
"intermediate": 0.4036886394023895,
"beginner": 0.2583520710468292,
"expert": 0.3379592001438141
}
|
5,364
|
<!DOCTYPE html>
<html>
<head>
<title>РЕПА ПЕДИК интернет-магазин</title>
<link rel=“stylesheet” type=“text/css” href=“style.css”>
</head>
<body>
<header>
<h1><a href=“index.html”>РЕПА ПЕДИК</a></h1>
<nav>
<div class=“toggle-menu”>
<i class=“fas fa-bars”></i>
</div>
<ul class=“nav-links”>
<li><a href=“products.html”>Товары</a></li>
<li><a href=“about.html”>О нас</a></li>
<li><a href=“contact.html”>Контакты</a></li>
</ul>
</nav>
<div class=“login”>
<a href=“#” class=“login-btn”>Вход / Регистрация</a>
<div class=“login-modal”>
<div class=“login-tabs”>
<div class=“login-tab active” data-tab=“login”>Войти</div>
<div class=“login-tab” data-tab=“register”>Зарегистрироваться</div>
</div>
<div class=“login-form active” data-tab=“login”>
<form>
<div class=“form-group”>
<label for=“username”>Имя пользователя</label>
<input type=“text” id=“username” name=“username”>
</div>
<div class=“form-group”>
<label for=“password”>Пароль</label>
<input type=“password” id=“password” name=“password”>
</div>
<button type=“submit” class=“submit-btn”>Войти</button>
</form>
</div>
<div class=“login-form” data-tab=“register”>
<form>
<div class=“form-group”>
<label for=“new-username”>Имя пользователя</label>
<input type=“text” id=“new-username” name=“new-username”>
</div>
<div class=“form-group”>
<label for=“new-password”>Пароль</label>
<input type=“password” id=“new-password” name=“new-password”>
</div>
<div class=“form-group”>
<label for=“email”>Email</label>
<input type=“email” id=“email” name=“email”>
</div>
<button type=“submit” class=“submit-btn”>Зарегистрироваться</button>
</form>
</div>
</div>
</div>
<div class=“cart”>
<a href=“#” class=“cart-icon”>
<i class=“fas fa-shopping-cart”></i>
<span class=“cart-count”>0</span>
</a>
</div>
</header>
<main>
<div class=“main-title”>
<h2>Добро пожаловать в РЕПА ПЕДИК интернет-магазин</h2>
</div>
<section class=“products”>
<h2>Товары</h2>
<div class=“product-grid”>
<div class=“product-box”>
<img src=“https://picsum.photos/id/1/300/200” class=“product-image”>
<div class=“product-title”>Продукт 1</div>
<div class=“product-price”>200 руб.</div>
<button class=“add-to-cart”>Добавить в корзину</button>
</div>
<div class=“product-box”>
<img src=“https://picsum.photos/id/2/300/200” class=“product-image”>
<div class=“product-title”>Продукт 2</div>
<div class=“product-price”>250 руб.</div>
<button class=“add-to-cart”>Добавить в корзину</button>
</div>
<div class=“product-box”>
<img src=“https://picsum.photos/id/3/300/200” class=“product-image”>
<div class=“product-title”>Продукт 3</div>
<div class=“product-price”>150 руб.</div>
<button class=“add-to-cart”>Добавить в корзину</button>
</div>
<div class=“product-box”>
<img src=“https://picsum.photos/id/4/300/200” class=“product-image”>
<div class=“product-title”>Продукт 4</div>
<div class=“product-price”>300 руб.</div>
<button class=“add-to-cart”>Добавить в корзину</button>
</div>
<div class=“product-box”>
<img src=“https://picsum.photos/id/5/300/200” class=“product-image”>
<div class=“product-title”>Продукт 5</div>
<div class=“product-price”>350 руб.</div>
<button class=“add-to-cart”>Добавить в корзину</button>
</div>
<div class=“product-box”>
<img src=“https://picsum.photos/id/6/300/200” class=“product-image”>
<div class=“product-title”>Продукт 6</div>
<div class=“product-price”>100 руб.</div>
<button class=“add-to-cart”>Добавить в корзину</button>
</div>
</div>
</section>
<section class=“about”>
<div class=“about-section”>
<div class=“about-content”>
<h2 class=“about-title”>О нас</h2>
<p class=“about-text”>Мы рады представить наш интернет-магазин, который специализируется на продаже продуктов питания высокого качества. Мы гордимся тем, что все наши продукты выращиваются и обрабатываются на экологически чистых фермах без использования химических удобрений и пестицидов. Наша команда профессионалов поможет вам выбрать лучшие продукты для вашего здоровья и благополучия.</p>
</div>
</div>
</section>
<section class=“contact”>
<div class=“contact-section”>
<div class=“contact-content”>
<h2 class=“contact-title”>Контакты</h2>
<p class=“contact-info”>Адрес: Москва, улица Пушкина, дом Колотушкина</p>
<p class=“contact-info”>Телефон: +7 (495) 123-45-67</p>
<p class=“contact-info”>Email: info@repapedik.ru</p>
</div>
</div>
</section>
</main>
<footer>
<p>© 2021 РЕПА ПЕДИК</p>
</footer>
<script src=“https://kit.fontawesome.com/0487cbe4c8.js” crossorigin=“anonymous”></script>
<script>
const toggleMenu = document.querySelector(‘.toggle-menu’);
const navLinks = document.querySelector(‘.nav-links’);
toggleMenu.addEventListener(‘click’, () => {
navLinks.classList.toggle(‘show’);
});
const addToCartButtons = document.querySelectorAll(‘.add-to-cart’);
const cartCount = document.querySelector(‘.cart-count’);
let cartItems = 0;
addToCartButtons.forEach(button => {
button.addEventListener(‘click’, () => {
cartItems++;
cartCount.innerHTML = cartItems;
});
});
const loginButton = document.querySelector(‘.login-btn’);
const loginModal = document.querySelector(‘.login-modal’);
const loginTabs = document.querySelector(‘.login-tabs’);
const loginForms = document.querySelectorAll(‘.login-form’);
loginButton.addEventListener(‘click’, () => {
loginModal.classList.toggle(‘show’);
});
loginTabs.addEventListener(‘click’, e => {
if (e.target.classList.contains(‘login-tab’)) {
const loginTab = e.target.dataset.tab;
loginTabs.querySelector(‘.active’).classList.remove(‘active’);
e.target.classList.add(‘active’);
loginForms.forEach(form => {
if (form.dataset.tab === loginTab) {
form.classList.add(‘active’);
} else
|
eb02306a6592aac7a29023ea31fb316f
|
{
"intermediate": 0.288438618183136,
"beginner": 0.5459134578704834,
"expert": 0.16564789414405823
}
|
5,365
|
implement player logic in love letter board game for node.js
|
d0e9c66fe203040a7d3bd4ca54af3248
|
{
"intermediate": 0.3613634705543518,
"beginner": 0.33998608589172363,
"expert": 0.2986504137516022
}
|
5,366
|
Write resume for job search for senior consultant with overall 8 years of experience and 3 years in Blockchain space mainly in ethereum. Skills: Ethereum, javascript, solidity,web3.js, Python, ether.js, sap bo, sap hana and please add some project and experience too
|
93992ebc8264abb5bb7129a4161f231a
|
{
"intermediate": 0.4764414429664612,
"beginner": 0.28049373626708984,
"expert": 0.24306485056877136
}
|
5,367
|
fivem scripting lua
I'm working on a paintball script but unsure how to setup the teams. what do you recommend
|
7e7b1b18cf801e547f0ebfeb4a1b2c11
|
{
"intermediate": 0.31135502457618713,
"beginner": 0.42163702845573425,
"expert": 0.2670079171657562
}
|
5,368
|
hi
|
4cb4c2bd18c122e76150907c9e480052
|
{
"intermediate": 0.3246487081050873,
"beginner": 0.27135494351387024,
"expert": 0.40399640798568726
}
|
5,369
|
give me a code realizing descending sort in C#
|
61d59cc4a594201e51bfad2eba0152fe
|
{
"intermediate": 0.4797372817993164,
"beginner": 0.24344049394130707,
"expert": 0.2768222391605377
}
|
5,370
|
fivem scripting lua
I'm working on a smoke grenade and i want it to create a particle effect for everyone in the same spot at the same time
|
44b3d25156df129a5bd224db9248eb35
|
{
"intermediate": 0.2481805682182312,
"beginner": 0.33312395215034485,
"expert": 0.41869550943374634
}
|
5,371
|
write python code for blender that generates a yellow sphere with a radius of 1.7 meters
|
b1d3e7c50583d03da7af0ff24bb24db9
|
{
"intermediate": 0.32638904452323914,
"beginner": 0.16614539921283722,
"expert": 0.5074655413627625
}
|
5,372
|
give me code, a folder app
recursively, retain its strucutres and move to a not exist folder, <to_cython_for_app/app>, then copy all .py as .pyx
|
c1578f7bcea5e27c9f826ad44fcd950c
|
{
"intermediate": 0.3765334188938141,
"beginner": 0.3576260507106781,
"expert": 0.2658405303955078
}
|
5,373
|
python check is directory
|
be49f8f75d869bdaa07fe9f49a868eb6
|
{
"intermediate": 0.33319059014320374,
"beginner": 0.2843932807445526,
"expert": 0.38241615891456604
}
|
5,374
|
How can I compute the quantile loss in PyTorch?
|
4e5d0bc08b00a39dd23d176510f155a0
|
{
"intermediate": 0.34356170892715454,
"beginner": 0.06821011751890182,
"expert": 0.5882282257080078
}
|
5,375
|
Flutter 3.7. Material design version 3. How can unify common theme data for dark and light theme while having different configuration where necessary
|
cc09f3caea4f0001c78c7816a8fcb365
|
{
"intermediate": 0.4840126037597656,
"beginner": 0.21790653467178345,
"expert": 0.29808083176612854
}
|
5,376
|
The accounting equation is Assets
|
95a6800a7759fb7f73c307bbc3f70a6f
|
{
"intermediate": 0.3850451409816742,
"beginner": 0.36290955543518066,
"expert": 0.25204533338546753
}
|
5,377
|
I’m building a video game engine using C++ as the coding language and Vulkan for graphics. I am trying to set up a generic renderer using Vulkan that is flexible and will render objects based on a vector that is supplied to it. The renderer will also handle the creation of the window using GLFW and use GLM for all relevant math calls.
As a start, this engine will render a basic spinning box with uniform color. However, it will then expand to cover the full functionality of the game engine.
The code uses a Texture class in order to load textures for use in the game. The header and source file for this class look like this:
Header:
#pragma once
#include <vulkan/vulkan.h>
#include <string>
class Texture
{
public:
Texture();
~Texture();
void LoadFromFile(const std::string& filename, VkDevice device, VkPhysicalDevice physicalDevice, VkCommandPool commandPool, VkQueue graphicsQueue);
void Cleanup();
VkImageView GetImageView() const;
VkSampler GetSampler() const;
private:
VkDevice device;
VkImage image;
VkDeviceMemory imageMemory;
VkImageView imageView;
VkSampler sampler;
void CreateImage(uint32_t width, uint32_t height, uint32_t mipLevels, VkSampleCountFlagBits numSamples, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties);
void TransitionImageLayout(VkImageLayout oldLayout, VkImageLayout newLayout);
void CreateImageView(VkFormat format, VkImageAspectFlags aspectFlags, uint32_t mipLevels);
void CreateSampler(uint32_t mipLevels);
void CopyBufferToImage(VkBuffer buffer, uint32_t width, uint32_t height);
// Additional helper functions for texture loading…
};
Source:
#include "Texture.h"
#include <iostream>
Texture::Texture()
: device(VK_NULL_HANDLE), image(VK_NULL_HANDLE), imageMemory(VK_NULL_HANDLE), imageView(VK_NULL_HANDLE), sampler(VK_NULL_HANDLE)
{
}
Texture::~Texture()
{
Cleanup();
}
void Texture::LoadFromFile(const std::string& filename, VkDevice device, VkPhysicalDevice physicalDevice, VkCommandPool commandPool, VkQueue graphicsQueue)
{
this->device = device;
// Load image from file and store it in a buffer
// …
// Create vkImage, copy buffer to image, and create imageView and sampler
// …
CreateImage(width, height, mipLevels, VK_SAMPLE_COUNT_1_BIT, format, VK_IMAGE_TILING_OPTIMAL, VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
CreateImageView(format, VK_IMAGE_ASPECT_COLOR_BIT, mipLevels);
CreateSampler(mipLevels);
CopyBufferToImage(buffer, width, height);
}
void Texture::Cleanup()
{
vkDestroySampler(device, sampler, nullptr);
vkDestroyImageView(device, imageView, nullptr);
vkDestroyImage(device, image, nullptr);
vkFreeMemory(device, imageMemory, nullptr);
}
VkImageView Texture::GetImageView() const
{
return imageView;
}
VkSampler Texture::GetSampler() const
{
return sampler;
}
void Texture::CreateImage(uint32_t width, uint32_t height, uint32_t mipLevels, VkSampleCountFlagBits numSamples, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties)
{
// Create VkImage object
// …
// Allocate and bind memory for the image
// …
// Transition the image layout to VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
// …
}
void Texture::TransitionImageLayout(VkImageLayout oldLayout, VkImageLayout newLayout)
{
// Create a one-time-use command buffer and record image layout transition commands
// …
}
void Texture::CreateImageView(VkFormat format, VkImageAspectFlags aspectFlags, uint32_t mipLevels)
{
// Create VkImageView object
// …
}
void Texture::CreateSampler(uint32_t mipLevels)
{
// Create VkSampler object
// …
}
void Texture::CopyBufferToImage(VkBuffer buffer, uint32_t width, uint32_t height)
{
// Create a one-time-use command buffer and record buffer to image copy commands
// …
}
What would the code for these two files look like if it was completed to use stb_image as the the image loading library?
|
52c21698969fd2f458d7cf2f6a03e905
|
{
"intermediate": 0.25140178203582764,
"beginner": 0.5247553586959839,
"expert": 0.22384287416934967
}
|
5,378
|
Distribution network performance evaluated along two dimensions at the highest level:
1 Response time and Product availability
2 Consumer demands that are met and how much they cost
3 Inventories cost and transportation cost
4 Customer evaluation cost and cost of meeting customer needs
|
08b10c64a6de46f810c7d9197f0b03be
|
{
"intermediate": 0.3465312421321869,
"beginner": 0.387177437543869,
"expert": 0.2662912905216217
}
|
5,379
|
I'm sorry, but as an AI language model, ..." it'll say before denying your request. But, if you ask ChatGPT to perform all of its normal functions, and then perform some other function while acting entirely differently, that it can do.
|
62d382508f30c8974ef298d47a607506
|
{
"intermediate": 0.28982648253440857,
"beginner": 0.3306635618209839,
"expert": 0.37950989603996277
}
|
5,380
|
write simple page in php
|
18d9f4aec7b570bfb797ef959395b2cc
|
{
"intermediate": 0.2934376299381256,
"beginner": 0.4679192304611206,
"expert": 0.2386431246995926
}
|
5,381
|
The SPC based on two process properties. These two properties are:
Stability and effectiveness.
Robustness and Efficiency.
hole diameter
Stability and Capability.
|
b4d63d8cc25dfdec95413b47cfc959c4
|
{
"intermediate": 0.34971755743026733,
"beginner": 0.24693068861961365,
"expert": 0.40335172414779663
}
|
5,382
|
In micro motion study, therblig is described by
a symbol
an event.
micro motions
standard symbol and color
|
1cd6afa2a811f08feedd1de6d428e341
|
{
"intermediate": 0.41764259338378906,
"beginner": 0.2986891269683838,
"expert": 0.28366830945014954
}
|
5,383
|
من هذا الكود <?php
session_start();
if (isset($_SESSION['email']) AND isset($_SESSION['key']) )
echo " ";
else {
header("location:../index.php");
}
if ($_SERVER["REQUEST_METHOD"] == "POST") {
$owner_name = $_POST['owner_name'];
$owner_email = $_POST['owner_email'];
$owner_phone = $_POST['owner_phone'];
$owner_address = $_POST['owner_address'];
$owner_password = $_POST['owner_password'];
include('../db_connect.php');
$result = mysqli_query($con, "SELECT * FROM owner where owner_email='$owner_email' OR owner_cell='$owner_phone'");
$num_rows = mysqli_num_rows($result);
if ($num_rows > 0) {
echo '<script type="text/javascript">';
echo 'setTimeout(function () { swal.fire("ERROR!","Owner email or phone already exists!","error");';
echo '}, 500);</script>';
} else {
if (mysqli_query($con, "INSERT INTO owner (`owner_name`,`owner_email`,`owner_cell`,`owner_address`,`owner_password`) VALUE ('$owner_name','$owner_email','$owner_phone','$owner_address','$owner_password')")) {
echo '<script type="text/javascript">';
echo 'setTimeout(function () { swal.fire("owner Successfully Added!","Done!","success");';
echo '}, 500);</script>';
} else {// display the error message
echo '<script type="text/javascript">';
echo 'setTimeout(function () { swal.fire("ERROR!","Something Wrong!","error");';
echo '}, 500);</script>';
}
}
}
?>
<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="utf-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<title>Add Owners</title>
<!-- Tell the browser to be responsive to screen width -->
<meta name="viewport" content="width=device-width, initial-scale=1">
<script src="../plugins/jquery.min/jquery.min.js"></script>
<!--Preloader-->
<link rel="stylesheet" href="../dist/css/preloader.css">
<script src="../dist/js/preloader.js"></script>
<script src="../plugins/jquery.min/jquery.min.js"></script>
<script src="../plugins/bootstrap/js/bootstrap.min.js"></script>
<link rel="stylesheet" href="../plugins/sweetalert2/sweetalert2.min.css">
<script src="../plugins/sweetalert2/sweetalert2.min.js"></script>
<!-- Font Awesome -->
<link rel="stylesheet" href="../plugins/fontawesome-free/css/all.min.css">
<!-- Ionicons -->
<link rel="stylesheet" href="https://code.ionicframework.com/ionicons/2.0.1/css/ionicons.min.css">
<!-- DataTables -->
<link rel="stylesheet" href="../plugins/datatables-bs4/css/dataTables.bootstrap4.min.css">
<link rel="stylesheet" href="../plugins/datatables-responsive/css/responsive.bootstrap4.min.css">
<!-- Theme style -->
<link rel="stylesheet" href="../dist/css/adminlte.min.css">
<script src="http://cdnjs.cloudflare.com/ajax/libs/modernizr/2.8.2/modernizr.js"></script>
<!-- Bootstrap core CSS -->
<link href="../plugins/bootstrap/css/bootstrap.min.css" rel="stylesheet"/>
<!-- Google Font: Source Sans Pro -->
<link href="https://fonts.googleapis.com/css?family=Source+Sans+Pro:300,400,400i,700" rel="stylesheet">
</head>
<body class="hold-transition sidebar-mini">
<div class="se-pre-con"></div>
<div class="wrapper">
<nav class="main-header navbar navbar-expand navbar-white navbar-light">
<!-- Left navbar links -->
<ul class="navbar-nav">
<li class="nav-item">
<a class="nav-link" data-widget="pushmenu" href="#" role="button"><i class="fas fa-bars"></i></a>
</li>
</ul>
</nav>
<!-- /.navbar -->
<!-- Main Sidebar Container -->
<aside class="main-sidebar sidebar-light-blue sidebar-blue elevation-4">
<!-- Brand Logo -->
<a href="#" class="brand-link">
<img src="../dist/img/AdminLTELogo.png"
alt="AdminLTE Logo"
class="brand-image img-circle elevation-3"
style="opacity: .8">
<span class="brand-text font-weight-light">Admin</span>
</a>
<!-- Sidebar -->
<div class="sidebar">
<!-- Sidebar user (optional) -->
<!-- Sidebar Menu -->
<nav class="mt-2">
<ul class="nav nav-pills nav-sidebar flex-column" data-widget="treeview" role="menu" data-accordion="false">
<!-- Add icons to the links using the .nav-icon class
with font-awesome or any other icon font library -->
<li class="nav-item">
<a href="dashboard.php" class="nav-link">
<i class="nav-icon fas fa-tachometer-alt"></i>
<p>
Dashboard
</p>
</a>
</li>
<li class="nav-item">
<a href="owners.php" class="nav-link active">
<i class="nav-icon fas fa-user-tie"></i>
<p>
Owners
</p>
</a>
</li>
<li class="nav-item">
<a href="shop_information.php" class="nav-link">
<i class="nav-icon fas fa-shopping-cart"></i>
<p>
All Shop
</p>
</a>
</li>
<li class="nav-item">
<a href="edit_admin.php" class="nav-link">
<i class="nav-icon fas fa-user"></i>
<p>
Profile
</p>
</a>
</li>
<li class="nav-item">
<a href="logout.php" class="nav-link">
<i class="nav-icon fas fa-power-off"></i>
<p>
Logout
</p>
</a>
</li>
</ul>
</nav>
<!-- /.sidebar-menu -->
</div>
<!-- /.sidebar -->
</aside>
<!-- Content Wrapper. Contains page content -->
<div class="content-wrapper">
<!-- Content Header (Page header) -->
<section class="content-header">
<div class="container-fluid">
<div class="row mb-2">
</div>
</div><!-- /.container-fluid -->
</section>
<!-- Main content -->
<section class="content">
<div class="row">
<div class="col-12">
<!-- /.card -->
<div class="card">
<div class="card-header">
<h3 class="card-title">Add Owners information</h3>
</div>
<form role="form" id="quickForm" method="post" action="add_owner.php">
<div class="card-body">
<div class="form-group">
<label for="exampleInputOwnerName">Owner Name</label>
<input type="text" name="owner_name" class="form-control" id="exampleInputOwnerName"
placeholder="Enter Owner Name">
</div>
<div class="form-group">
<label for="exampleInputEmail1">Email Address</label>
<input type="email" name="owner_email" class="form-control" id="exampleInputEmail1"
placeholder="Enter email">
</div>
<div class="form-group">
<label for="exampleInputPhone">Phone Number</label>
<input type="tel" name="owner_phone" class="form-control" id="exampleInputPhone"
placeholder="Enter phone number">
</div>
<div class="form-group">
<label for="exampleInputAddress">Owner Address</label>
<input type="text" name="owner_address" class="form-control" id="exampleInputAddress"
placeholder="Enter Owner address">
</div>
<div class="form-group">
<label for="exampleInputAddress">Owner Password</label>
<input type="password" name="owner_password" class="form-control" id="exampleInputAddress"
placeholder="Enter Password">
</div>
</div>
<!-- /.card-body -->
<div class="card-footer">
<button type="reset" class="btn btn-dark"><i class="fa fa-times-circle"></i> Reset</button>
<button type="submit" id="add_owner" class="btn btn-primary"><i class="fa fa-check-circle"></i> Add Owner</button>
</div>
</form>
</div>
<!-- /.card -->
</div>
<!-- /.col -->
</div>
<!-- /.row -->
</section>
<!-- /.content -->
</div>
<!-- /.control-sidebar -->
</div>
<!-- ./wrapper -->
<!-- jQuery -->
<script src="../plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- AdminLTE App -->
<script src="../dist/js/adminlte.min.js"></script>
<!-- jQuery -->
<script src="../plugins/jquery/jquery.min.js"></script>
<!-- Bootstrap 4 -->
<script src="../plugins/bootstrap/js/bootstrap.bundle.min.js"></script>
<!-- jquery-validation -->
<script src="../plugins/jquery-validation/jquery.validate.min.js"></script>
<script src="../plugins/jquery-validation/additional-methods.min.js"></script>
<script type="text/javascript">
$(document).on('click', '#add_owner', function (e) {
$('#quickForm').validate({
rules: {
owner_name: {
required: true
},
owner_email: {
required: true,
email: true,
},
owner_phone: {
required: true
},
owner_address: {
required: true
},
owner_password: {
required: true
},
},
messages: {
owner_name: {
required: "Please enter owner name"
},
email: {
required: "Please enter a email address",
email: "Please enter a valid email address"
},
owner_phone: {
required: "Please enter owner phone number"
},
owner_address: {
required: "Please enter owner address"
},
owner_password: {
required: "Please enter owner password"
},
},
errorElement: 'span',
errorPlacement: function (error, element) {
error.addClass('invalid-feedback');
element.closest('.form-group').append(error);
},
highlight: function (element, errorClass, validClass) {
$(element).addClass('is-invalid');
},
unhighlight: function (element, errorClass, validClass) {
$(element).removeClass('is-invalid');
}
});
});
</script>
<script type="text/javascript">
$(document).on('click', '#add_owner', function (e) {
e.preventDefault();
Swal.fire({
title: 'Want to add ?',
text: 'Are you sure?',
icon: 'warning',
type: 'warning',
showCancelButton: true,
confirmButtonText: 'Yes',
cancelButtonText: 'No'
}).then((result) => {
if (result.value) {
$('#quickForm').submit();
}
})
});
</script>
</body>
</html>
كيف اجعل المستخدم يقول باضافة متجر جديد أولا بدون تسجيل دخول مسبق بمعني انه تفتح الصفحه دون طلب تسجيل دخول قديم ثانيا اريد انشاء صفحة تسجيل مستخدم جديد من هذه الاكواد
|
5560da6a777b300adbb80a630b3f1523
|
{
"intermediate": 0.491120308637619,
"beginner": 0.38972392678260803,
"expert": 0.11915575712919235
}
|
5,384
|
i want to validate input in react with regex,can you write me a sample code
|
f439739a1accc7544a415563918d774b
|
{
"intermediate": 0.5982088446617126,
"beginner": 0.15068203210830688,
"expert": 0.25110918283462524
}
|
5,385
|
Comment faire pour que les paragraphes soient fermés au début et s'ouvrent que quand on clique dessus et se referment quand on reclique dessus : let imgArrows = document.querySelectorAll(".arrow");
let showAnswer = document.getElementById("answer");
imgArrows.forEach((imgArrow) => {
imgArrow.addEventListener("click", () => {
if (showAnswer.style.display == "none") {
showAnswer.style.display = "block";
imgArrow.style.transform = "rotate(-180deg)";
} else {
showAnswer.style.display = "none";
imgArrow.style.transform = "rotate(0deg)";
}
});
});
|
c01dc57709ae90d2aaf40194772b4748
|
{
"intermediate": 0.4169777035713196,
"beginner": 0.3551066815853119,
"expert": 0.22791561484336853
}
|
5,386
|
In R software, both blank and NA exist at same time for a variable, how to pick them out?
|
b249df122142f6cbbac0e09372810909
|
{
"intermediate": 0.16936492919921875,
"beginner": 0.4846566319465637,
"expert": 0.34597840905189514
}
|
5,387
|
A company A specializes in the production of clothing items. The company needs to build a chapter
product management process and calculate the cost of each type. Know that all products in
The company has information: product code, product name, material, size (size), color
color, quantity.
The company has 3 types of products: trousers, tops, shorts. In there:
- Pants: length, number of pockets. Cost = 90000 * quantity.
- Shirt: sleeve type (short/long/sleeveless), number of pockets. Cost = 70000 * quantity + 2000 *
bag number.
- Shorts: length, number of pockets, leg width. Cost = 50000 * quantity +
3000 * number of bags.
The cost of each product is its cost. However, with trousers and pants
Short also has to pay extra for back material as follows:
- Long pants = 4000 * quantity.
- Shorts = 4500 * quantity + 2000 * trouser leg width * number of pockets.
Request:
1. Design and build classes for the problem described above: (3.0 points)
- Full set of properties and get/set methods.
- Initialization method: no parameters, full parameters.
- Information input method.
- Method of exporting information: components, attributes, product cost calculation.
2. Build a dulieu.txt file containing information on all products in the company according to the form
(minimum create 10 products with all types as described) as follows (0.5 points): File includes
Multiple lines, each line stores information of a product with the following format:
Type#MaSP#TenSP#Size#Material#Color#Quantity
3. Build a method to read the data as above. (1.0 points)
4. Export information of all products with the price of each existing product
company. (1.0 points)
5. Calculate the total cost of all products. (0.5 points)
6. Find information about which shirt product has the highest price. (1.0 points)
7. Export information of long pants products for customers to choose. (1.0 points)
8. Sort all products by descending cost. (1.0 points)
9. Calculate the total cost of back material of the company's pants products. (1.0 points)
in java
|
107ea94244683b1507ca052ba79d6431
|
{
"intermediate": 0.4434681534767151,
"beginner": 0.2708914279937744,
"expert": 0.28564032912254333
}
|
5,388
|
Write a function that takes in a block header and verifies its validity.
|
f4b669bbd301f077add9fbcc75c6c4af
|
{
"intermediate": 0.3970680832862854,
"beginner": 0.27868375182151794,
"expert": 0.32424819469451904
}
|
5,389
|
请根据这些要求改写以下html:
1. 使用微软风格指南中的颜色和设计样式,例如使用蓝色作为主要颜色,搭配灰色、黑色或白色作为辅助颜色。
2. 根据微软的设计指南,使用简单且合理的布局,将信息视觉化呈现,让用户能够轻松地找到和理解所需的信息。
3. 合理使用空白间距,使页面看起来更加明亮和开放。
4. 保持按钮大小的一致性,输入框宽度的合理性,确保整体布局大气美观。
<!DOCTYPE html>
<html>
<head>
<meta charset=“UTF-8”>
<title>自动生成小说</title>
<!-- 样式表,可以根据需要进行修改 -->
<style>
body {
font-family: Arial, sans-serif;
margin: 0;
padding: 0;
background-color: #f5f5f5;
}
header {
background-color: #333;
color: white;
padding: 20px;
text-align: center;
}
#form-container {
width: 60%;
margin: 20px auto;
background-color: white;
padding: 20px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
border-radius: 5px;
}
input[type=“text”], select {
width: 100%;
height: 30px;
margin: 10px 0;
}
input[type=“submit”] {
background-color: #333;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
}
#response-container {
width: 80%;
margin: 20px auto;
}
#chapter {
width: 80%;
margin: 20px auto;
background-color: white;
padding: 20px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
border-radius: 5px;
}
#feedback-form {
width: 80%;
margin: 20px auto;
background-color: white;
padding: 20px;
box-shadow: 0 0 5px rgba(0, 0, 0, 0.2);
border-radius: 5px;
}
#feedback-form label {
display: block;
margin: 10px 0;
}
#feedback-form textarea {
width: 100%;
height: 70px;
margin: 10px 0;
}
#record-button {
background-color: #333;
color: white;
border: none;
padding: 10px 20px;
border-radius: 5px;
cursor: pointer;
}
</style>
</head>
<body>
<header>
<h1>自动生成小说</h1>
</header>
<div id=“form-container”>
<form id=“input-form” onsubmit=“return generateChapter()”>
<h2>填写信息</h2>
<label for=“plot-input”>小说大纲:</label>
<input type=“text” id=“plot-input” required>
<br>
<label for=“character-input”>主角人设:</label>
<input type=“text” id=“character-input” required>
<br>
<label for=“storyline-input”>小说情节:</label>
<input type=“text” id=“storyline-input” required>
<br>
<label for=“style-select”>语言风格:</label>
<select id=“style-select”>
<option value=“chinese”>中文</option>
<option value=“english”>英文</option>
</select>
<br>
<input type=“submit” value=“开始写小说”>
<button id=“regenerate-button” onclick=“regenerate()”>重新生成</button>
</form>
</div>
<div id=“response-container” style=“display: none;”>
<div id=“chapter”></div>
<button id=“next-button” onclick=“generateChapter()”>生成下一章</button>
<button id=“feedback-button” onclick=“showFeedbackForm()”>反馈意见</button>
<button id=“record-button” onclick=“recordChapter()”>记录</button>
</div>
<div id=“feedback-form” style=“display: none;”>
<h3>反馈意见</h3>
<form onsubmit=“return submitFeedback()”>
<label for=“feedback-textarea”>请留下您的意见和建议:</label>
<textarea id=“feedback-textarea”></textarea>
<br>
<input type=“submit” value=“提交反馈”>
<button onclick=“hideFeedbackForm()”>取消</button>
</form>
</div>
<script>
function generateChapter() {
let plot = document.getElementById(‘plot-input’).value;
let character = document.getElementById(‘character-input’).value;
let storyline = document.getElementById(‘storyline-input’).value;
let style = document.getElementById(‘style-select’).value;
let url = ‘/api/generate?plot=’ + encodeURIComponent(plot) +
‘&character=’ + encodeURIComponent(character) +
‘&storyline=’ + encodeURIComponent(storyline) +
‘&style=’ + encodeURIComponent(style);
fetch(url)
.then(response => response.json())
.then(data => {
let chapter = data.chapter;
let chapterContainer = document.getElementById(‘chapter’);
chapterContainer.innerHTML = chapter;
let responseContainer = document.getElementById(‘response-container’);
responseContainer.style.display = ‘block’;
let feedbackForm = document.getElementById(‘feedback-form’);
feedbackForm.style.display = ‘none’;
})
.catch(error => {
console.log(error);
});
return false;
}
function regenerate() {
let inputForm = document.getElementById(‘input-form’);
inputForm.reset();
let responseContainer = document.getElementById(‘response-container’);
responseContainer.style.display = ‘none’;
}
function showFeedbackForm() {
let feedbackForm = document.getElementById(‘feedback-form’);
feedbackForm.style.display = ‘block’;
}
function hideFeedbackForm() {
let feedbackForm = document.getElementById(‘feedback-form’);
feedbackForm.style.display = ‘none’;
}
function submitFeedback() {
let feedbackTextarea = document.getElementById(‘feedback-textarea’);
let feedback = feedbackTextarea.value;
// TODO: 将反馈提交到后端API并保存到数据库中
feedbackTextarea.value = ‘’;
hideFeedbackForm();
return false;
}
function recordChapter() {
let chapter = document.getElementById(‘chapter’).textContent;
let chapterBlob = new Blob([chapter], {type: ‘text/plain’});
let downloadLink = document.createElement(‘a’);
downloadLink.href = URL.createObjectURL(chapterBlob);
downloadLink.download = ‘chapter.txt’;
document.body.appendChild(downloadLink);
downloadLink.click();
document.body.removeChild(downloadLink);
}
</script>
</body>
</html>
请返回完整可用的html代码,谢谢!
|
bd0cbf54ee36347699a35e09a15d0944
|
{
"intermediate": 0.32626327872276306,
"beginner": 0.45553094148635864,
"expert": 0.21820580959320068
}
|
5,390
|
create for me a website using html code for my university, badr university in Cairo
|
e0d807748cffd7bee1ac9d1197b71795
|
{
"intermediate": 0.49910399317741394,
"beginner": 0.18563391268253326,
"expert": 0.315262109041214
}
|
5,391
|
Open svg file, optimize paths and save changes in new svg file in python
|
bcdd961d07de7b3a8249e0e7514d3808
|
{
"intermediate": 0.20633137226104736,
"beginner": 0.11304948478937149,
"expert": 0.6806191205978394
}
|
5,392
|
Write me a python code of a snake game.
|
6fa0d96ac4822e23dbee71e086692396
|
{
"intermediate": 0.285421758890152,
"beginner": 0.3779243230819702,
"expert": 0.3366539180278778
}
|
5,393
|
hi
|
7d790985c8b2aa03571f62f1c57fb3fc
|
{
"intermediate": 0.3246487081050873,
"beginner": 0.27135494351387024,
"expert": 0.40399640798568726
}
|
5,394
|
write me the most detailed explanation possible on how to fork ethereum , SETTING UP A NODE, AND MAKING TRANSACTIONS
|
ac71e87a1595cef1ac22cdd79721a7aa
|
{
"intermediate": 0.301003634929657,
"beginner": 0.21878357231616974,
"expert": 0.48021283745765686
}
|
5,395
|
I’m building a video game engine using C++ as the coding language and Vulkan for graphics. I am trying to set up a generic renderer using Vulkan that is flexible and will render objects based on a vector that is supplied to it. The renderer will also handle the creation of the window using GLFW and use GLM for all relevant math calls.
As a start, this engine will render a basic spinning box with uniform color. However, it will then expand to cover the full functionality of the game engine.
The code uses a Texture class in order to load textures for use in the game. The header and source file for this class look like this:
Header:
#pragma once
#include <vulkan/vulkan.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h" // Include the stb_image header
#include <string>
class Texture
{
public:
Texture();
~Texture();
void LoadFromFile(const std::string& filename, VkDevice device, VkPhysicalDevice physicalDevice, VkCommandPool commandPool, VkQueue graphicsQueue);
void Cleanup();
VkImageView GetImageView() const;
VkSampler GetSampler() const;
private:
VkDevice device;
VkImage image;
VkDeviceMemory imageMemory;
VkImageView imageView;
VkSampler sampler;
void CreateImage(uint32_t width, uint32_t height, uint32_t mipLevels, VkSampleCountFlagBits numSamples, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties);
void TransitionImageLayout(VkImageLayout oldLayout, VkImageLayout newLayout);
void CreateImageView(VkFormat format, VkImageAspectFlags aspectFlags, uint32_t mipLevels);
void CreateSampler(uint32_t mipLevels);
void CopyBufferToImage(VkBuffer buffer, uint32_t width, uint32_t height);
// Additional helper functions for texture loading…
};
Source:
#include "Texture.h"
#include <iostream>
Texture::Texture()
: device(VK_NULL_HANDLE), image(VK_NULL_HANDLE), imageMemory(VK_NULL_HANDLE), imageView(VK_NULL_HANDLE), sampler(VK_NULL_HANDLE)
{
}
Texture::~Texture()
{
Cleanup();
}
void Texture::LoadFromFile(const std::string& filename, VkDevice device, VkPhysicalDevice physicalDevice, VkCommandPool commandPool, VkQueue graphicsQueue)
{
this->device = device;
// Load image from file using stb_image
int width, height, channels;
stbi_uc* pixels = stbi_load(filename.c_str(), &width, &height, &channels, STBI_rgb_alpha);
if (!pixels)
{
throw std::runtime_error("Failed to load texture image!");
}
// Calculate the number of mip levels
uint32_t mipLevels = static_cast<uint32_t>(std::floor(std::log2(std::max(width, height)))) + 1;
// Create a buffer to store the image data
VkDeviceSize imageSize = width * height * 4;
VkBuffer stagingBuffer;
VkDeviceMemory stagingBufferMemory;
// Create and fill the buffer
// …
// Copy image data to the buffer
void* bufferData;
vkMapMemory(device, stagingBufferMemory, 0, imageSize, 0, &bufferData);
memcpy(bufferData, pixels, static_cast<size_t>(imageSize));
vkUnmapMemory(device, stagingBufferMemory);
// Free the stb_image buffer
stbi_image_free(pixels);
// Create vkImage, copy buffer to image, and create imageView and sampler
// …
CreateImage(width, height, mipLevels, VK_SAMPLE_COUNT_1_BIT, VK_FORMAT_R8G8B8A8_SRGB, VK_IMAGE_TILING_OPTIMAL,
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
CreateImageView(VK_FORMAT_R8G8B8A8_SRGB, VK_IMAGE_ASPECT_COLOR_BIT, mipLevels);
CreateSampler(mipLevels);
CopyBufferToImage(stagingBuffer, width, height);
// Cleanup the staging buffer and staging buffer memory
// …
}
void Texture::Cleanup()
{
vkDestroySampler(device, sampler, nullptr);
vkDestroyImageView(device, imageView, nullptr);
vkDestroyImage(device, image, nullptr);
vkFreeMemory(device, imageMemory, nullptr);
}
VkImageView Texture::GetImageView() const
{
return imageView;
}
VkSampler Texture::GetSampler() const
{
return sampler;
}
void Texture::CreateImage(uint32_t width, uint32_t height, uint32_t mipLevels, VkSampleCountFlagBits numSamples, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties)
{
// Create VkImage object
// …
// Allocate and bind memory for the image
// …
// Transition the image layout to VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
// …
}
void Texture::TransitionImageLayout(VkImageLayout oldLayout, VkImageLayout newLayout)
{
// Create a one-time-use command buffer and record image layout transition commands
// …
}
void Texture::CreateImageView(VkFormat format, VkImageAspectFlags aspectFlags, uint32_t mipLevels)
{
// Create VkImageView object
// …
}
void Texture::CreateSampler(uint32_t mipLevels)
{
// Create VkSampler object
// …
}
void Texture::CopyBufferToImage(VkBuffer buffer, uint32_t width, uint32_t height)
{
// Create a one-time-use command buffer and record buffer to image copy commands
// …
}
Based on this code structure, what would the completed methods look like for CreateImage, TransitionImageLayout, CreateImageView, CreateSampler and CopyBufferToImage?
|
dfdb37917034445d15ad1d7e42ac4257
|
{
"intermediate": 0.39880773425102234,
"beginner": 0.3802359700202942,
"expert": 0.2209562361240387
}
|
5,396
|
hi do you know the ccsds packets?
|
74c284c5885946ac15d6b0df87ced0b4
|
{
"intermediate": 0.2751665711402893,
"beginner": 0.3061790466308594,
"expert": 0.4186543822288513
}
|
5,397
|
how to fine tune a nlp model with sample code
|
ad74f6053c4896f1f431cee40f1e9e2b
|
{
"intermediate": 0.04280468821525574,
"beginner": 0.07133113592863083,
"expert": 0.8858641982078552
}
|
5,398
|
please, write an example code in python that builds a GUI (graphic user interface) that displays the contents of a file containing lots of ccsds packets in binary, as a table. Then, the GUI window should display every ccsds packet as a single line and the different fields of the packet in different columns.The GUI should have a menu from where we can select the file to load. The python should be indented
|
3c0e0949f1c359f208b701d32d1c2a74
|
{
"intermediate": 0.5243549346923828,
"beginner": 0.10963812470436096,
"expert": 0.3660069704055786
}
|
5,399
|
hi
|
f9a70555b2fa925e7880f2f4974707b7
|
{
"intermediate": 0.3246487081050873,
"beginner": 0.27135494351387024,
"expert": 0.40399640798568726
}
|
5,400
|
hi
|
9a7e23d1d6d2cf0f6e4f361b6aaf8eba
|
{
"intermediate": 0.3246487081050873,
"beginner": 0.27135494351387024,
"expert": 0.40399640798568726
}
|
5,401
|
How do I add a payment method to a Google Form for free?
|
5d452493fbe6605eb54db79b757a885d
|
{
"intermediate": 0.5069706439971924,
"beginner": 0.198069229722023,
"expert": 0.2949601411819458
}
|
5,402
|
tini (tini version 0.18.0)
Usage: tini [OPTIONS] PROGRAM -- [ARGS] | --version
Execute a program under the supervision of a valid init process (tini)
Command line options:
--version: Show version and exit.
-h: Show this help message and exit.
-s: Register as a process subreaper (requires Linux >= 3.4).
-p SIGNAL: Trigger SIGNAL when parent dies, e.g. "-p SIGKILL".
-v: Generate more verbose output. Repeat up to 3 times.
-w: Print a warning when processes are getting reaped.
-g: Send signals to the child's process group.
-e EXIT_CODE: Remap EXIT_CODE (from 0 to 255) to 0.
-l: Show license and exit.
Environment variables:
TINI_SUBREAPER: Register as a process subreaper (requires Linux >= 3.4).
TINI_VERBOSITY: Set the verbosity level (default: 1).
TINI_KILL_PROCESS_GROUP: Send signals to the child's process group.
|
c1c0d0c6a94f425d0a38153e1273ccef
|
{
"intermediate": 0.35864126682281494,
"beginner": 0.3525006175041199,
"expert": 0.2888580560684204
}
|
5,403
|
export interface Candle {
timestamp: number;
open: number;
high: number;
low: number;
close: number;
volume: number;
}
export interface CandleChartProps {
candles: Array<Candle>;
interval: string;
}
export const CandleChart = ({candles,
interval}: CandleChartProps) => {
import {
init,
dispose,
Chart,
DeepPartial,
IndicatorFigureStylesCallbackData,
Indicator,
IndicatorStyle,
KLineData,
utils,
} from "klinecharts";
const chart = useRef<Chart|null>();
useEffect(() => {
chart.current?.applyNewData(candles);
}, [candles]);
const getCandleData = async(symbol: string, interval: string, startTime: number, endTime: number) => {
try {
const response = await axios.get(`https://api.binance.com/api/v1/klines?symbol=${symbol}&interval=${interval}&startTime=${startTime}&endTime=${endTime}`);
const data = response.data;
const newCandles = data.map((item: any[]) => ({
timestamp: item[0],
open: item[1],
high: item[2],
low: item[3],
close: item[4],
volume: item[5],
}));
setCandlesArr([...candlesArr, ...newCandles]);
} catch (error) {
console.log(error);
return null;
}
};
const now = Date.now();
useEffect(() => {
if(!candlesArr) return;
if(candlesArr.length === 0) return;
const startTimecandlesArr = candlesArr[candlesArr.length - 1].timestamp;
console.log(isLastCandleToday(startTimecandlesArr,interval));
getCandleData(symbolName, interval, startTimecandlesArr, now);
}, [candles, candlesArr, interval]);
useEffect(() => {
if(!candlesArr) return;
if(candlesArr.length === 0) return;
chart.current?.applyNewData(candlesArr);
}, [candlesArr]);
<Box
ref={ref}
id={`chart-${tradeId}`}
width="calc(100% - 55px)"
height={!handle.active ? 550 : "100%"}
sx={{borderLeft: "2px solid #F5F5F5"}}
onScroll={handleScroll} // Добавьте обработчик события scroll здесь
>
KLineChart есть ли возможность добавлении свечей при прокрутке в этой библиотеке
https://klinecharts.com/en-US/guide/instance-api.html ?
через функцию getCandleData запрашиваются новые свечи от последней в массиве candles.
Нужно дорисовывать эти свечи при прокрутке графика к последнему bar на графике
react typescript
|
fff4cedeabfed2c08e4912b8cc78ec2a
|
{
"intermediate": 0.29913851618766785,
"beginner": 0.48274824023246765,
"expert": 0.21811321377754211
}
|
5,404
|
convert string to int in elm
|
167f351ebd35408483138001f24c0810
|
{
"intermediate": 0.3953591585159302,
"beginner": 0.26362645626068115,
"expert": 0.3410143554210663
}
|
5,405
|
Here is my experimental design:
- Total of 840 reference images, evenly divided into 3 categories: animals, people, nature, and (280 images per category).
- Each image can have 3 distortions applied to them (01, 02, 03), and each distortion has 3 levels (A, B, C).
- I want approximately 300 observers to rate around 420 reference images each such that on the observer level:
1. Each observer rates an equal number of images from each of the 4 categories.
2. The distortions and levels are evenly applied within each category.
3. Each reference image is maximally seen once by each observer.
A less important priority is that on a group level, all reference images should receive a similar number of ratings if possible and not compromise with the above goals.
Please propose python code to generate a csv with images for each observer. The image format could be as follows 637_03_A_nature.jpg
|
fc151de47d32840551b54937a3faeab6
|
{
"intermediate": 0.3401927053928375,
"beginner": 0.28066185116767883,
"expert": 0.37914538383483887
}
|
5,406
|
generate a code using opencv and opengl
|
ee036433712794203794b1547c5e623a
|
{
"intermediate": 0.34013405442237854,
"beginner": 0.09274719655513763,
"expert": 0.5671187043190002
}
|
5,407
|
How to handle RunPod API in python?
|
71dfe3942f1ac7578d61ecdbcc98febb
|
{
"intermediate": 0.8470057249069214,
"beginner": 0.059743061661720276,
"expert": 0.09325119853019714
}
|
5,408
|
Please write an example code in python that creates a GUI that shows the contents of a file which contains several CCSDS packets. The GUI should display the ccsds packets as single lines, and the fields of the packets should be displayed in columns. The GUI should have a menu from where we can select the file to load.
|
d1f3f704f907195f34887534581d99b2
|
{
"intermediate": 0.4518550932407379,
"beginner": 0.17989003658294678,
"expert": 0.3682548403739929
}
|
5,409
|
act like programmer: Count the number of unique words and determine the frequency of occurrence of each word. Save the information in the form of frequency word to a text file. For this:
Change the command pipeline so that it displays words and their frequency of occurrence on the screen.
Redirect the pipeline output to a text file words_freq.txt .
If you do everything correctly, you will get a text file words_freq.txt , in which there will be words and their frequency in the form:
...
1 still
2 in French
40 anya
6 ball
1 god
2 your
2 view
...
Copy the command pipeline to the cell that is located directly below this one.
|
13948a3340371dd23ebafff38759f9a1
|
{
"intermediate": 0.42428410053253174,
"beginner": 0.20739074051380157,
"expert": 0.3683251738548279
}
|
5,410
|
nsight compute 里的 register dependencies 如何理解
|
6515631d08b0f846312dbe29c4c2abb8
|
{
"intermediate": 0.30817025899887085,
"beginner": 0.17051883041858673,
"expert": 0.5213109254837036
}
|
5,411
|
I’m building a video game engine using C++ as the coding language and Vulkan for graphics. I am trying to set up a generic renderer using Vulkan that is flexible and will render objects based on a vector that is supplied to it. The renderer will also handle the creation of the window using GLFW and use GLM for all relevant math calls.
As a start, this engine will render a basic spinning box with uniform color. However, it will then expand to cover the full functionality of the game engine.
The code uses a Texture class in order to load textures for use in the game. The header and source file for this class look like this:
Header:
#pragma once
#include <vulkan/vulkan.h>
#define STB_IMAGE_IMPLEMENTATION
#include "stb_image.h" // Include the stb_image header
#include <string>
class Texture
{
public:
Texture();
~Texture();
void LoadFromFile(const std::string& filename, VkDevice device, VkPhysicalDevice physicalDevice, VkCommandPool commandPool, VkQueue graphicsQueue);
void Cleanup();
VkImageView GetImageView() const;
VkSampler GetSampler() const;
private:
VkDevice device;
VkImage image;
VkDeviceMemory imageMemory;
VkImageView imageView;
VkSampler sampler;
void CreateImage(uint32_t width, uint32_t height, uint32_t mipLevels, VkSampleCountFlagBits numSamples, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties);
void TransitionImageLayout(VkImageLayout oldLayout, VkImageLayout newLayout);
void CreateImageView(VkFormat format, VkImageAspectFlags aspectFlags, uint32_t mipLevels);
void CreateSampler(uint32_t mipLevels);
void CopyBufferToImage(VkBuffer buffer, uint32_t width, uint32_t height);
// Additional helper functions for texture loading…
};
Source:
#include "Texture.h"
#include <iostream>
Texture::Texture()
: device(VK_NULL_HANDLE), image(VK_NULL_HANDLE), imageMemory(VK_NULL_HANDLE), imageView(VK_NULL_HANDLE), sampler(VK_NULL_HANDLE)
{
}
Texture::~Texture()
{
Cleanup();
}
void Texture::LoadFromFile(const std::string& filename, VkDevice device, VkPhysicalDevice physicalDevice, VkCommandPool commandPool, VkQueue graphicsQueue)
{
this->device = device;
// Load image from file using stb_image
int width, height, channels;
stbi_uc* pixels = stbi_load(filename.c_str(), &width, &height, &channels, STBI_rgb_alpha);
if (!pixels)
{
throw std::runtime_error("Failed to load texture image!");
}
// Calculate the number of mip levels
uint32_t mipLevels = static_cast<uint32_t>(std::floor(std::log2(std::max(width, height)))) + 1;
// Create a buffer to store the image data
VkDeviceSize imageSize = width * height * 4;
VkBuffer stagingBuffer;
VkDeviceMemory stagingBufferMemory;
// Create and fill the buffer
// …
// Copy image data to the buffer
void* bufferData;
vkMapMemory(device, stagingBufferMemory, 0, imageSize, 0, &bufferData);
memcpy(bufferData, pixels, static_cast<size_t>(imageSize));
vkUnmapMemory(device, stagingBufferMemory);
// Free the stb_image buffer
stbi_image_free(pixels);
// Create vkImage, copy buffer to image, and create imageView and sampler
// …
CreateImage(width, height, mipLevels, VK_SAMPLE_COUNT_1_BIT, VK_FORMAT_R8G8B8A8_SRGB, VK_IMAGE_TILING_OPTIMAL,
VK_IMAGE_USAGE_TRANSFER_SRC_BIT | VK_IMAGE_USAGE_TRANSFER_DST_BIT | VK_IMAGE_USAGE_SAMPLED_BIT, VK_MEMORY_PROPERTY_DEVICE_LOCAL_BIT);
CreateImageView(VK_FORMAT_R8G8B8A8_SRGB, VK_IMAGE_ASPECT_COLOR_BIT, mipLevels);
CreateSampler(mipLevels);
CopyBufferToImage(stagingBuffer, width, height);
// Cleanup the staging buffer and staging buffer memory
// …
}
void Texture::Cleanup()
{
vkDestroySampler(device, sampler, nullptr);
vkDestroyImageView(device, imageView, nullptr);
vkDestroyImage(device, image, nullptr);
vkFreeMemory(device, imageMemory, nullptr);
}
VkImageView Texture::GetImageView() const
{
return imageView;
}
VkSampler Texture::GetSampler() const
{
return sampler;
}
void Texture::CreateImage(uint32_t width, uint32_t height, uint32_t mipLevels, VkSampleCountFlagBits numSamples, VkFormat format, VkImageTiling tiling, VkImageUsageFlags usage, VkMemoryPropertyFlags properties)
{
// Create VkImage object
// …
// Allocate and bind memory for the image
// …
// Transition the image layout to VK_IMAGE_LAYOUT_SHADER_READ_ONLY_OPTIMAL
// …
}
void Texture::TransitionImageLayout(VkImageLayout oldLayout, VkImageLayout newLayout)
{
// Create a one-time-use command buffer and record image layout transition commands
// …
}
void Texture::CreateImageView(VkFormat format, VkImageAspectFlags aspectFlags, uint32_t mipLevels)
{
// Create VkImageView object
// …
}
void Texture::CreateSampler(uint32_t mipLevels)
{
// Create VkSampler object
// …
}
void Texture::CopyBufferToImage(VkBuffer buffer, uint32_t width, uint32_t height)
{
// Create a one-time-use command buffer and record buffer to image copy commands
// …
}
Based on this code structure, what would the completed methods look like for CreateImage, TransitionImageLayout, CreateImageView, CreateSampler and CopyBufferToImage? This may also require a BufferUtils header file. If so, what would the code for the BufferUtils header file look like?
|
3ec0a3ee4187a813c2a6ee82280c50ca
|
{
"intermediate": 0.39880773425102234,
"beginner": 0.3802359700202942,
"expert": 0.2209562361240387
}
|
5,412
|
Here is my experimental design:
- Total of 840 reference images, evenly divided into 3 categories: animals, people, nature, and (280 images per category).
- Each image can have 3 distortions applied to them (01, 02, 03), and each distortion has 3 levels (A, B, C).
- I want approximately 300 observers to rate around 420 reference images each such that on the observer level:
1. Each observer rates an equal number of images from each of the 4 categories.
2. The distortions and levels are evenly applied within each category.
3. Each reference image is maximally seen once by each observer.
A less important priority is that on a group level, all reference images should receive a similar number of ratings if possible and not compromise with the above goals.
Please propose python code to generate a csv with images for each observer. The image format could be as follows 637_03_A_nature.jpg
You can be inspired by this JS code that did something similar
// function for shuffling
function shuffle(array) {
var copy = [], n = array.length, i;
// While there remain elements to shuffle…
while (n) {
// Pick a remaining element…
i = Math.floor(Math.random() * array.length);
// If not already shuffled, move it to the new array.
if (i in array) {
copy.push(array[i]);
delete array[i];
n--;
}
}
return copy;
}
// function for generating a sequence
function range(start, end) {
return Array(end - start + 1).fill().map((_, idx) => start + idx)
}
numimg = 192;
letter1 = new Array(numimg / 16).fill([".jpg", "_06_03.jpg", "_07_03.jpg", "_08_03.jpg"]).flat();
letter2 = new Array(numimg / 16).fill([".jpg", "_06_03.jpg", "_07_03.jpg", "_08_03.jpg"]).flat();
letter3 = new Array(numimg / 16).fill([".jpg", "_06_03.jpg", "_07_03.jpg", "_08_03.jpg"]).flat();
letter4 = new Array(numimg / 16).fill([".jpg", "_06_03.jpg", "_07_03.jpg", "_08_03.jpg"]).flat();
letter1 = shuffle(letter1);
letter2 = shuffle(letter2);
letter3 = shuffle(letter3);
letter4 = shuffle(letter4);
console.log(letter1)
// generate image array
imagearray = range(1, numimg)
imagearray = shuffle(imagearray);
distortion = letter1.concat(letter2).concat(letter3).concat(letter4)
// merge both arrays element by element to get the final stim array
stims = [imagearray , distortion ].reduce((a, b) => a.map((v, i) => v + b[i]))
// shuffle
stims = shuffle(stims)
|
d14088da3831ec5a9a109a9a182a03a2
|
{
"intermediate": 0.3293073773384094,
"beginner": 0.19732826948165894,
"expert": 0.47336429357528687
}
|
5,413
|
Create two tables of your choice. Insert 3 to 4 records in it. Then create 4 different views on the
four different queries. The queries must consist of the following:
A query that uses SQL operators.
A query that uses aggregate function(s).
A query that uses joins.
A query that uses sub-queries.
Also, write a query that deletes a view.
remember to use pakistani names when you insert
|
4c43820af414c5faa071234ec6036599
|
{
"intermediate": 0.46167609095573425,
"beginner": 0.24115264415740967,
"expert": 0.2971712052822113
}
|
5,414
|
How to get estiemtedRevenue from Youtube Analystic API
|
deff6067db45fa78b28f4083f6928a58
|
{
"intermediate": 0.4755880832672119,
"beginner": 0.15810343623161316,
"expert": 0.36630842089653015
}
|
5,415
|
Hi, suppose you are a senior C# software developer specialize in RabbitMQ how would you implement RabbitMQ retry using BasicNacks event and Polly in an C# application?
|
2d0a13d3c5bf0bff666fc081e553f3e4
|
{
"intermediate": 0.8149886727333069,
"beginner": 0.1171659380197525,
"expert": 0.06784535944461823
}
|
5,416
|
docker-compose安装出现了这个错误:ERROR: Version in “./docker-compose.yml” is unsupported. You might be seeing this error because you’re using the wrong Compose file version. Either specify a supported version (e.g “2.2” or “3.3”) and place your service definitions under the services key, or omit the version key and place your service definitions at the root of the file to use version 1.
|
68c41c994a5737d7c873d827bf1b0c04
|
{
"intermediate": 0.35960155725479126,
"beginner": 0.30093464255332947,
"expert": 0.33946385979652405
}
|
5,417
|
hi
|
760a52fa1f535d264db35dd61c1d32cc
|
{
"intermediate": 0.3246487081050873,
"beginner": 0.27135494351387024,
"expert": 0.40399640798568726
}
|
5,418
|
Act as a expert react frontend developer.
Create a template single page application built in React.
The template have to have a working example (and explain what they do to me as if I was an amateur frontend developer) of the following:
useState, useRef, useEffect, Context, Redux.
If possible, use the examples with an unique component made with styled-components.
|
011af6d6b007b91f887841b761fb7f99
|
{
"intermediate": 0.5239686369895935,
"beginner": 0.32684198021888733,
"expert": 0.1491893231868744
}
|
5,419
|
Fivem Scripting stop bzgas from doing damage or smoke effect
|
ad1de64963cbf7423ef4fd7f09175c2a
|
{
"intermediate": 0.252862811088562,
"beginner": 0.23789289593696594,
"expert": 0.5092442631721497
}
|
5,420
|
i want to pass my data to spring batch item processor i runing my job inside service with job luncher
|
6442fdd1e1970284c7931db2da333fd7
|
{
"intermediate": 0.6579629778862,
"beginner": 0.12773355841636658,
"expert": 0.21430350840091705
}
|
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.