instruction
stringlengths
0
30k
I am trying to make a card animation where a card on the top of the deck would translate upwards when hovered. Unfortunately, it seems like my card flickers if I move my mouse horizontally over the bottom part of the card. I have made some tests and it seems to be related to the translate, as increasing the translate on hover will result in having a greater area accross the flickering happens. Sorry if I explained this bad, hopefully looking at the code will show what my issue is( simply mouse over the translated area after the translate has taken place and move your mouse vertically. You can also increase the translate to see the results). I would be looking for any suggestions regarding this and/ or any advice regarding my code. Thank you for your time and effort! ``` <!DOCTYPE html> <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Karte</title> <link rel="stylesheet" href="style.css"> </head> <body> <div class="container"> <div id="game"> <div id="deck"></div> <div id="hand"></div> </div> </div> <script src="script.js"></script> </body> </html> ``` ``` #deck { display: flex; justify-content: space-around; position: relative; } .card { height: 100px; width: 100px; background-color: red; position: absolute; border: 1px solid black; } #deck .card:last-child { transition: transform 0.3s ease; } #deck .card:last-child:hover { transform: translateY(-20px); } ``` ``` // grab elements let game = document.getElementById('game'); let deckEl = document.getElementById('deck'); let hand = document.getElementById('hand'); // global variables let arr = [{card: 1, text:"Attack"},{card: 2, text:"Attack"},{card: 3, text:"Attack"},{card: 4, text:"Shield"},{card: 5, text:"Shield"},{card: 6, text:"Shield"},{card: 7, text:"Parry"},{card: 8, text:"Parry"},{card: 9, text:"Parry"}]; let cardsInHand = []; // shuffling the deck with selected deck as argument function shuffleDeck(array) { let i = array.length; while(i--) { const i2 = Math.floor(Math.random()*i); [array[i], array[i2]] = [array[i2], array[i]]; } } // drawing cards with card number as argument function drawCards(cardAmount) { for(cardAmount; cardAmount > 0; cardAmount--) { cardsInHand.push(arr[arr.length-1]); arr.pop(); } } // generate deck element function generateDeck() { let cardOutline = 200; arr.forEach(card=> { let cardEl = document.createElement('div'); cardEl.classList.add('card'); cardOutline-=3; cardEl.style.top = cardOutline + "px"; console.log(cardEl.style.top); deckEl.appendChild(cardEl); }) } generateDeck(); shuffleDeck(arr); drawCards(3); ``` I tried increasing modifying the translate and position properties, as well as the top and transitions, however it doesn't make much of a difference.
Hover animation resetting( seemingly reverting back to original CSS and then again to hover)when moving mouse horizontaly accross a part of an element
|javascript|css|animation|hover|position|
null
I fix this error by adding this <property> tag to the <meta-data> tag in the manifest. <meta-data android:name="com.google.android.gms.ads.APPLICATION_ID" android:value="@string/APP_NUMBER" /> <property android:name="android.adservices.AD_SERVICES_CONFIG" android:resource="@xml/gma_ad_services_config" tools:replace="android:resource" />
problem with the automatic jump function - doodlejump pygame
|python-3.x|pygame|
null
I am a grad student getting my MBA with an emphasis in finance. I am struggling to answers this question as I have no experience in coding. I am supposed to work the problem using python. Any help would be greatly appreciated! **PROBLEM** Problem Statement: We have a project with given cashflows. [-50, 20, 10, 30, 10, 15] The first element is negative and represents the initial investment required for the project. The subsequent elements represent the expected cash inflows and outflows from the project over 15 periods. We would like to calculate the Internal Rate of Return (IRR) of this project. As a reminder, the IRR is the discount rate at which the NPV of a project equals zero. Therefore, we are looking for an such that ()=0⇒−50+201++10(1+)2+30(1+)3+10(1+)4+15(1+)5=0. In this exercise, we will numerically solve this equation using Numpy. The idea is to calculate () over a grid of , e.g., [0,0.001,0.002,0.003,…,0.199,0.200] , and find a point on the grid where () is close to zero. The finer our initial grid, the closer we can get to the root of the equation above. Your task is to: Define the cash flows array. Create an array of potential discount rates ranging from 0% to 20%. Calculate the NPV for each discount rate. Identify the discount rate at which the NPV is closest to zero. This rate is the project's approximate IRR. **GUIDE** Step 1: import numpy as np # Define the number of points on the grid N = 10001 # Define cashflows cash_flows = np.array([-60, 20, 10, 30, 10, 15]) # Define the array of potential discount rates r = np.linspace(0, 0.20, N) # Define an array to keep NPV values npv = np.zeros((N,)) Step 2: # Calculate NPVs for each value of the discount rate for i in range(N): # Calculate NPV for discount rate = r[i] Step 3: # Identify the discount rate at which NPV is closest to zero index = np.argmin(np.abs(npv)) Step 4: # Print the IRR Step 5: # Copy the code for N = 1001 Step 6: # Copy the code for N = 10001 Thanks, Marcie I tried used ChatGPT, but I am not getting the correct code.
Calculating IRR Using Numpy
|python|numpy|
null
I am trying to build my object using the below Json payload(which is being fetched from external API), now when ever i use any get method(i.e: jsonObject.getString() or jsonObject.getBoolean(), jsonObject.getObject()) and if the value present for the key is null,I am getting an exception that "the value is not a string/boolean/Jsonobject" now how can i handle this, since if the value is present in object 1 on the above array index 0, it may/maynot present in another object at index 1 here I an apply null checks to resolve this issue, but this object has more than 40 key value pairs and add these many null checks may become cumbersome ```Json data": [ { "employer_name": "Dice", "employer_logo": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKlgydP7sElaJC9qPrtNHwBhyTMHYgii1RPWsy&s=0", "employer_website": null, "employer_company_type": "Information", "job_publisher": "LinkedIn", "job_id": "8yv3oA_2-UYAAAAAAAAAAA==", "job_employment_type": "CONTRACTOR", "job_title": "Web Developer - 6-month Contract - Houston Hybrid", "job_apply_link": "https://www.linkedin.com/jobs/view/web-developer-6-month-contract-houston-hybrid-at-dice-3624857671", "job_apply_is_direct": false ..... }, { "employer_name": "Dicenvskjvks", "employer_logo": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKlgydP7sElaJC9qPrtNHwBhyTMHYgii1RPWsy&s=0", "employer_website": "https://www.someUrl.com" "employer_company_type": "Information", "job_publisher": "LinkedIn", "job_id": "8yv3oA_2-UYAAAAAAAAAAA==", "job_employment_type": null, "job_title": "Web Developer - 6-month Contract - Houston Hybrid", "job_apply_link": "https://www.linkedin.com/jobs/view/web-developer-6-month-contract-houston-hybrid-at-dice-3624857671", "job_apply_is_direct": false ..... } ] ``` My code: ```Java public static List<Response> parseJServer1Response(String responseBody) throws ParseException, JsonProcessingException { JSONObject responseObject = new JSONObject(responseBody); JSONArray data = responseObject.getJSONArray("data"); List<Response> response = new ArrayList<>(); for (int i = 0; i < data.length(); i++) { JSONObject jsonObject = data.getJSONObject(i); JSearch job = Response.builder() .companyName(jsonObject.getString("employer_name")) .companyLogo(jsonObject.getString("employer_logo")) .companyType(jsonObject.getString("employer_company_type")) .jobPublisher(jsonObject.getString("job_publisher")) .... .... .... .... .... .... .build(); response.add(job); } return response; } ```
|php|codeigniter|codeigniter-3|
If you create a `table` of `dice.sums`, then you will get the frequency of each possible sum. Dividing this table by its total will give you the probability of each sum. The rest is just data wrangling to get it into the correct format, for which `dplyr` will be useful: ``` r library(dplyr) table(dice.sums) %>% as.data.frame() %>% mutate(dice.sums = as.numeric(as.character(dice.sums)), prob = Freq/sum(Freq), floor = 10 * floor(dice.sums/10)) %>% summarise(range = paste(min(dice.sums), max(dice.sums), sep = ' - '), prob = round(sum(prob), 8), .by = floor) %>% select(range, prob) #> range prob #> 1 10 - 19 0.00148046 #> 2 20 - 29 0.15502340 #> 3 30 - 39 0.63852791 #> 4 40 - 49 0.20207825 #> 5 50 - 59 0.00288996 #> 6 60 - 60 0.00000002 ```
null
I have the administration of the tour agency website with booking functionality built in Wordpress, Woocommerce and Woocommerce Bookings. For one product at the new order email not mentioned the booking details like how many persons will join to the tour. I am facing this issue only for one product, all the others are ok. I am attaching also some screenshots that many help you. [Screenshot with missing details](https://i.stack.imgur.com/0vUde.png) [Screenshot with correct details](https://i.stack.imgur.com/znCZI.png) It would be great if you can help me to solve the issue.
New Order Email Details Missing // Woocommerce / Woocommerce Bookings
|wordpress|woocommerce|woocommerce-bookings|
null
In my project I am trying to use `net.sf.saxon.s9api.XsltTransformer` in multiple threads using synchronization in java because as per documentation An XsltTransformer must not be used concurrently in multiple threads. It is safe, however, to reuse the object within a single thread to run the same stylesheet several times. Running the stylesheet does not change the context that has been established. Some of the public methods are synchronized: this is not because multi-threaded execution is supported, rather it is to reduce the damage if multi-threaded execution is attempted. but while trying to make stress test using JMeter by sending 100 request per second I found that `net.sf.saxon.s9api.XsltTransformer.transform()` takes more time and sometimes reach to 6 mins. How can I use `net.sf.saxon.s9api.XsltTransformer.transform()` in multiple threads without impacting performance? I tried to make class TransformerSingleton as below ``` public class TransformerSingleton { private static XsltTransformer transformer; private TransformerSingleton() { } public static void xsltLoad() { if (transformer == null) { synchronized (XsltTransformer.class){ try { Processor processor = new Processor(false); XsltCompiler compiler = processor.newXsltCompiler(); XsltExecutable xslt = compiler.compile(new StreamSource("/my_path/")); transformer = xslt.load(); } catch (Exception e) { e.printStackTrace(); } } } } public static XsltTransformer getTransformer(){ if (transformer == null) { synchronized (XsltTransformer.class) { xsltLoad(); } } return transformer; } } ``` ``` public static void main(String[] args) { XsltTransformer transformer = XsltTransformerSingleton.getTransformer(); String xml = "<Users><name>AAA</name></Users>"; // for example try (ByteArrayInputStream byteArrayInputStream = new ByteArrayInputStream(xml.getBytes())) { synchronized (transformer){ Transformer.setSource(new StreamSource(byteArrayInputStream)); XdmDestination chainResult = new XdmDestination(); Transformer.setDestination(chainResult); Transformer.transform(); } } } ``` expected to make throughput reach to 100 requests per second. actual I reached to 60 per second.
You are getting a blank window because you didn't call a `pack()`, `grid()` or `place()` method on the self.menu widget. To fix this you can add `self.menu.pack()` on line 13. The full code is the following: ```python from customtkinter import * class app(CTk): def __init__(self, title, size): # main setup super().__init__() self.title(title) self.geometry(f'{size[0]}x{size[1]}') self.minsize(size[0], size[1]) # widget self.menu = CTkFrame(self) self.menu.pack() # run self.mainloop() class Menu(CTkFrame): def __init__(self, parent): super().__init__(parent) self.place(x=0, y=0, relwidth=0.3, relheight=1) self.create_widgets() def create_widgets(self): heading_var = StringVar(value="Ethan") def heading_combo(choice): print(choice) heading = CTkComboBox(self, values=["Ethan", "Brock", "Liam"], command=heading_combo, variable=heading_var) self.columnconfigure((0, 1, 2), weight=1, uniform='a') self.rowconfigure((0, 1, 2, 3, 4), weight=1, uniform='a') heading.pack() app('Scoring Software', (600, 600)) ``` But your code seems weird, you are creating a Menu class but not using it. If you thought doing this `class Menu(CTkFrame):` would completly overwrite the CTkFrame class, you are wrong, it just creates a new class with modified methods. To use the Menu class you created, you should replace the 12th line by this: ```python self.menu = self.Menu(self) ``` Hope I helped you, have a nice day
I’m beginner in programming and have a problem in next code. the main problem is that when we use to command "math" the program gives you an example and you cant solve it, because program at once says that its uncorrect. How I can solve it? ive heard about about remembering the button status, but i dont know how to realize it. ~~~ import os import telebot from dotenv import load_dotenv from mathematics import lvl1, lvl2, lvl3, lvl4, lvl1_str, lvl2_str, lvl3_str, lvl4_str load_dotenv() TELEGRAM_TOKEN = os.environ['TELEGRAM_TOKEN'] bot = telebot.TeleBot(TELEGRAM_TOKEN, parse_mode=None) a = 1 money = 0 inv = "инвентарь" help = "помощь" fight = "начать битву" math = "стать умным" count = 0 dictionary = { } @bot.message_handler(content_types="text") def message_all(message): global money global count global dictionary global lvl1, lvl2, lvl3, lvl4 global lvl1_str, lvl2_str, lvl3_str, lvl4_str markup = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2) if message.text == "/start": markup = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2) button_fight = telebot.types.KeyboardButton(fight) button_inv = telebot.types.KeyboardButton(inv) button_help = telebot.types.KeyboardButton(help) button_math = telebot.types.KeyboardButton(math) markup.row(button_fight, button_help) markup.row(button_inv, button_math) bot.send_message(message.chat.id, message.text, reply_markup=markup) elif message.text == "помощь" or message.text == "/help": bot.send_message(message.chat.id, "/start - запустить ботa \n/help - высветить все команды \n/fight - начать сражение \n/inv - просмотреть инвентарь \n/math - решать задачи") button_fight = telebot.types.KeyboardButton(fight) button_inv = telebot.types.KeyboardButton(inv) button_math = telebot.types.KeyboardButton(math) markup.row(button_fight) markup.row(button_inv, button_math) bot.send_message(message.chat.id, message.text, reply_markup=markup) elif message.text == "инвентарь" or message.text == "/inv": bot.send_message(message.chat.id, "Ваши предметы:\n тут пока пусто...") # дописать button_fight = telebot.types.KeyboardButton(fight) button_help = telebot.types.KeyboardButton(help) button_math = telebot.types.KeyboardButton(math) markup.row(button_fight) markup.row(button_help, button_math) bot.send_message(message.chat.id, message.text, reply_markup=markup) elif message.text == "стать умным" or message.text == "/math": count += 5 if count < 11: bot.send_message(message.chat.id, f"введите ответ на данный пример:\n {lvl1_str}") if message.text == lvl1: bot.send_message(message.chat.id, 'вы правильно ответили на данный пример\n ваш интеллект немного повысился\n +25 монет') money += 25 else: money -= 5 bot.send_message(message.chat.id, 'вы неверно ответили на данный пример\n -5 монет') elif count < 21: bot.send_message(message.chat.id, f"введите ответ на данный пример:\n {lvl2_str}") if message.text == lvl2: bot.send_message(message.chat.id, 'вы правильно ответили на данный пример\n ваш интеллект немного повысился\n +30 монет') money += 30 else: money -= 10 bot.send_message(message.chat.id, 'вы неверно ответили на данный пример\n -10 монет') elif count < 31: bot.send_message(message.chat.id, f"введите ответ на данный пример:\n {lvl3_str}") if message.text == lvl3: bot.send_message(message.chat.id, 'вы правильно ответили на данный пример\n ваш интеллект немного повысился\n +35 монет') money += 35 else: money -= 15 bot.send_message(message.chat.id, 'вы неверно ответили на данный пример\n -15 монет') elif count < 41: bot.send_message(message.chat.id, f"введите ответ на данный пример:\n {lvl4_str}") if message.text == lvl4: bot.send_message(message.chat.id, 'вы правильно ответили на данный пример\n ваш интеллект немного повысился\n +40 монет') money += 40 else: money -= 15 bot.send_message(message.chat.id, 'вы неверно ответили на данный пример\n -15 монет') markup = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2) button_fight = telebot.types.KeyboardButton(fight) button_inv = telebot.types.KeyboardButton(inv) button_help = telebot.types.KeyboardButton(help) button_math = telebot.types.KeyboardButton(math) markup.row(button_fight, button_math) markup.row(button_inv, button_help) bot.send_message(message.chat.id, message.text, reply_markup=markup) elif count < 51 and message.text == "начать битву" or message.text == "/fight": count = 0 bot.send_message(message.chat.id, "ищем противника...") bot.send_message(message.chat.id, "противник найден!") dictionary.update(enemy="противник найден!") if "enemy" in dictionary: markup = telebot.types.ReplyKeyboardMarkup(resize_keyboard=True, row_width=2) button_heal = telebot.types.KeyboardButton('лечение') button_kick = telebot.types.KeyboardButton('удар') button_superkick = telebot.types.KeyboardButton('суперудар') markup.row(button_superkick) markup.row(button_heal, button_kick) bot.send_message(message.chat.id, message.text, reply_markup=markup) dictionary.clear() # здесь дописать код битвы и после ее окончания вернуть начальные кнопки и отправить поздравительное сообщение игроку bot.infinity_polling() ~~~ file mathematics: ~~~ import random from scipy.optimize import newton m1 = random.randint(-100, 100) m2 = random.randint(-100, 100) m3 = random.randint(1, 10) m4 = random.randint(1, 100) m5 = random.randint(1, 100) def spec(x): return x ** 2 - m4 lvl4_unrounded = newton(spec, 2) lvl1 = m1 + m2 lvl2 = m1 + m2 * m3 lvl3 = m3 ** 2 * m3 ** 3 lvl4 = round(lvl4_unrounded, 1) lvl1_str = f'{m1} + {m2}' lvl2_str = f'{m1} + {m2} * {m3}' lvl3_str = f'{m3} ** 2 * {m3} ** 3' lvl4_str = f'x ** 2 - {m4} = 0' ~~~ Ive tried to made another function and and call it in the right block, but it didnt work. ill be happy if someone can help me :)
Python. problem with Telegram bot [library telebot)
|python|telegram|telegram-bot|python-telegram-bot|
null
OP Here. Both of the following commands working for me: curl -Lfs "https://motivatedsisters.com/2019/07/08/arabic-review-sr-rahat-basit/" | rg -o '<li>.*?href="(.*?)".*?</a> (.*?)<\/li>' -r 'echo $1 $(unescape_html "$2")' | bash | rg -o '(https?://\S+)\s(.*)' -r 'echo $1 $(unescape_html "$2")' -r '{"url": "$1", "title": "$2"}' | jq -s '.' and curl -Lfs "https://motivatedsisters.com/2019/07/08/arabic-review-sr-rahat-basit/" | rg '<li>.*?href="(.*?)".*?</a> (.*?)<\/li>' -or '$1 $2' | while read -r link title; do echo "$link" "$(unescape_html "$title")"; done | rg -o '(https?://\S+)\s(.*)' -r '{"url": "$1", "title": "$2"}' | jq -s '.'
I am using this query to randomly select a row in the **user** table that has not already been inserted into the **task_pool** table, laterally done per id in **task_dispersal** table. ____ PostgreSQL 16.2 INSERT into task_pool(user_id, order_id) select u.user_id, task_dispersal.id from task_dispersal cross join lateral ( select user_id from users tablesample bernoulli(.1) repeatable(random()) where user_id not in ( select user_id from task_pool where order_id = task_dispersal.id ) order by random() limit 1) u ---- Is there anything that can be done to optimize this query? ---- *I added an "explain analyze verbose" Query Plan result at end of this post* create table users( user_id serial primary key, irellevant_columns varchar ); create table task_pool( id serial primary key, irellevant_columns varchar ); create table task_pool( task_id serial primary key, order_id integer, user_id integer ); | user_id(serial key)| irellevant_columns| |:----: |:------:| | 1 | ~~~| | ... | ...| | 49156 | ~~~| **task_dispersal** | id(serial key)| irellevant_columns| |:----: |:------:| | 1 |~~~| | 2 |~~~| | ... | ...| | 100 | ~~~| **task_pool** | task_id(serial key)| order_id(not unique) | user_id (not unique)| |:----: |:------:| :-----:| | 1 | 5 | 267| | 2 | 55| 9,999| | ... | ... | ...| | 1 | 23 | 602| | 985187 | 5 | 15 | For example, let's say there's 100 rows in task_dispersal (therefore 100 order_ids). For each of those 100 order_ids, the query will chose a random user_id in the user_table, filtering out user_id's that have already been inserted into the task_pool for that order_id. The query above works great, but slows down as the amount of rows in users and task_pool increase (expected of course, I'd just hope to minimize the delay). Let's say I have 985187 rows in task_pool (so 985187 task_ids), 49156 rows in user table (49156 user_ids), and 100 rows in task_dispersal (100 order_ids). The query now takes ~9.5 seconds to complete. _______________ Here is the info with explain analyze verbose: "Insert on public.task_pool (cost=21150.09..2115016.50 rows=0 width=0) (actual time=9565.389..9565.390 rows=0 loops=1)" " -> Nested Loop (cost=21150.09..2115016.50 rows=100 width=28) (actual time=81.912..9562.038 rows=100 loops=1)" " Output: nextval('pool_task_id_seq'::regclass), task_dispersal.id, users.user_id, CURRENT_TIMESTAMP, NULL::integer, 0" " -> Seq Scan on public.task_dispersal (cost=0.00..4.00 rows=100 width=4) (actual time=0.019..0.147 rows=100 loops=1)" " Output: task_dispersal.id" " -> Limit (cost=21150.09..21150.10 rows=1 width=12) (actual time=95.599..95.599 rows=1 loops=100)" " Output: users.user_id, (random())" " -> Sort (cost=21150.09..21150.15 rows=24 width=12) (actual time=95.593..95.593 rows=1 loops=100)" " Output: users.user_id, (random())" " Sort Key: (random())" " Sort Method: top-N heapsort Memory: 25kB" " -> Sample Scan on public.users (cost=19563.30..21149.97 rows=24 width=12) (actual time=93.586..95.572 rows=47 loops=100)" " Output: users.user_id, random()" " Sampling: bernoulli ('0.1'::real) REPEATABLE (random())" " Filter: (NOT (hashed SubPlan 1))" " Rows Removed by Filter: 0" " SubPlan 1" " -> Seq Scan on public.task_pool task_pool_1 (cost=0.00..19560.84 rows=985 width=4) (actual time=9.673..93.218 rows=995 loops=100)" " Output: task_pool_1.user_id" " Filter: (task_pool_1.order_id = task_dispersal.id)" " Rows Removed by Filter: 984192" "Planning Time: 0.487 ms" "Execution Time: 9565.444 ms" ________ I don't assume this can really be optimized, but I'm still pretty new to SQL so I thought I'd ask here.
I am experiencing a problem with displaying button icons in the QDialog window. This problem occurs when trying to run the window from the main file, knowing that the QDialog window file is not in the same path as the main file. This is the code to import the design from the `__init__.py` file inside WindowAdd ``` from PySide6.QtUiTools import QUiLoader from PySide6.QtCore import QFile, QDate, Qt, QRect, QPropertyAnimation, QEasingCurve ,QTimer from PySide6.QtWidgets import QApplication, QWidget, QTableWidgetItem, QPushButton, QDialog, QListWidgetItem, QCompleter from PySide6 import QtGui, QtWidgets, QtCore from .ui_Add_Item import Ui_Form from Lib import database3 from datetime import datetime from functools import partial import random import time import os import sys class CustomListWidgetItem(QListWidgetItem): def __init__(self, text, hidden_data): super().__init__(text) self.hidden_data = hidden_data class Widgets(QDialog, Ui_Form): def __init__(self, parent=None, page=""): super(Widgets, self).__init__(parent) self.setupUi(self) if __name__ == "__main__": app = QApplication([]) window = Widgets() window.show() app.exec() ``` I tried to execute a local code inside WindowAdd and the icons appeared very normally without the slightest problem, but when I exit to the main file the problem returns again. These are the libraries and the most important codes used inside the `main.py` ``` from PySide6.QtUiTools import QUiLoader from PySide6.QtCore import QFile, Qt from PySide6.QtWidgets import QApplication, QWidget, QTableWidgetItem, QMenu, QGraphicsBlurEffect from PySide6 import QtGui, QtWidgets, QtCore from PySide6.QtGui import QBrush, QColor, QAction, QTextOption, QIcon from ui_Style3 import Ui_Form from WindowAdd import Widgets as WindowAdd2 from Lib import database3 from datetime import datetime import random import sys class Widgets(QWidget,Ui_Form): def __init__(self): super(Widgets, self).__init__() self.setupUi(self) #Title window name and icon self.setWindowTitle("Business record") #Name title self.setWindowIcon(QtGui.QIcon("path30.png")) #Icon title if __name__ == "__main__": app = QApplication(sys.argv) window = Widgets() window.show() sys.exit(app.exec()) ``` Just for your information, I use the design files from the Qt Designer program to download the ready-made design files. The `main.py` file and the `__init__.py` file are files to control the design files and execute instructions.
{"OriginalQuestionIds":[40566585],"Voters":[{"Id":5577765,"DisplayName":"Rabbid76","BindingReason":{"GoldTagBadge":"pygame"}}]}
def swap(lst): l=len(lst) l2=list(lst) l3=[] if l<4: for i in range(len(l2)): if i+2<len(l2): l3.append(l2[i+2]) l3.append(l2[i]) elif l>4: l4=lst[:4] l5=lst[4:] for i in range(len(l4)): if i+2<len(l4): l3.append(l4[i+2]) l3.append(l4[i]) for i in range(0,len(l5)-1,2): l5[i],l5[i+1]=l5[i+1],l5[i] lst=l3+l6 return lst print(swap([200,456,300,100,234,678])) print(swap([200,456,300,100,234,678,9,10,67,69])) Output: [300, 200, 100, 456, 678, 234] [300, 200, 100, 456, 678, 234, 10, 9, 69, 67] What the question mentioned was not an ordinary shuffle/alternate shuffle Look at the image for understanding:[1] Here is my thought process: For the first four elements, last two elements replace [n-2]th element for the next consecutive terms, each term is swapped with next one continously PS: All the best for exams broo! [1]: https://i.stack.imgur.com/Qgw6u.jpg
I am using the following snippet for preprocessing: ``` # Data augmentation train_datagen = tf.keras.preprocessing.image.ImageDataGenerator( rotation_range=10, width_shift_range=0.1, height_shift_range=0.1, shear_range=0.1, fill_mode='constant', cval = 0) ``` Additionally, I am using GPU P100 on Kaggle. I was having some errors when I would run the `model.fit` method. So I was debugging. Only untill I went through the Keras doc, I knew that the Module: tf.keras.preprocessing is deprecated. Or at least this is what I understood from this doc [link.](https://www.tensorflow.org/api_docs/python/tf/keras/preprocessing) Also, hovering over the preprocessing header that encloses the overview, a small pop-up reads **Deprecated**. [![The image reference](https://i.stack.imgur.com/UIpXa.jpg)](https://i.stack.imgur.com/UIpXa.jpg) I wanted to know what is the alternative now?
What is the alternative to module: tf.keras.preprocessing?
|python|keras|deep-learning|tensorflow2.0|kaggle|
null
{"Voters":[{"Id":7860670,"DisplayName":"user7860670"},{"Id":5577765,"DisplayName":"Rabbid76"},{"Id":8623159,"DisplayName":"httpdigest"}],"SiteSpecificCloseReasonIds":[13]}
The instructions you found were actually broken (missing details) and not recommended (wfastcgi was deprecated). If you revert all changes related to FastCGI and start cleanly with HttpPlatformHandler, you will see how smooth the experience is, ``` xml <?xml version="1.0" encoding="UTF-8"?> <configuration> <system.webServer> <handlers> <add name="httpPlatformHandler" path="*" verb="*" modules="httpPlatformHandler" resourceType="Unspecified" requireAccess="Script" /> </handlers> <httpPlatform stdoutLogEnabled="true" stdoutLogFile=".\python.log" startupTimeLimit="20" processPath="C:\Users\<user name>\AppData\Local\Programs\Python\Python310\python.exe" arguments=".\mysite\manage.py runserver %HTTP_PLATFORM_PORT%"> </httpPlatform> </system.webServer> </configuration> ``` Python/Django still takes care of everything including static files, and IIS/HttpPlatformHandler just passes requests on. More details can be found from [my blog post](https://docs.lextudio.com/blog/running-django-web-apps-on-iis-with-httpplatformhandler/).
i found you need to do something like this is powershell core 7 ``` terraform state rm 'resource[\"thing\"]' ``` this is doc'd with an example over at https://developer.hashicorp.com/terraform/cli/commands/state/show#example-show-a-resource-configured-with-for_each Update 2023-01, dunno what's changed but in PS7 latest and TF latest i haven't needed the \ anymore despite the docs saying i do, this seems to work now ``` terraform state rm 'resource["thing"]' ```
I have scaled my dataset using the standard scaler form sklearn like this: from sklearn.preprocessing import StandardScaler ... # create a StandardScaler object self.scaler = StandardScaler() # fit the scaler to the dataset self.scaler.fit(self.X_org) # transform dataset using the scaler self.X_scalled = pd.DataFrame(self.scaler.transform(self.X_org), columns=self.X_org.columns) return self.X_scalled However, I am now using the last 10% of the entire dataset for a validation run also scaling the data with the scaler from the training dataset like so: X_input_val_data_scalled = pd.DataFrame(self.scaler.transform(X_input_val_data), columns=X_input_tick_data.columns) Now my challenge: In the training X_org set I get a nicely scaled dataset from 3 to -3. In the scaled validation X dataset I get completely wired data ranging from 50 to -75... What am I doing wrong?
Calling Standard Scaler differes between same sets
|python|scikit-learn|
null
I'm trying to setup a report that has line item details summarized by a subgroup for each. On each line, I want to add a checkbox, with the subtotal of each group being a "master" checkbox that would change all of the corresponding checkboxes if it's clicked. My solution is to create an individual click event for each master checkbox that updates everything with a similar name (i.e. line items have checkbox names File1_1, File1_2, and subtotal line has name Master_File1). To create each report, I run the data through a processor spreadsheet, so each of these click events needs to be added through VBA. When I try to apply the event procedure, I get an "Event handler is invalid" error on the `.CreateEventProc` line. The first snippet below is the subprocedure to apply the macro (the proc_lines code has been tested and works how I want it to, just can't get it implemented). I originally received an error for trying to pass the worksheet name I gave it ("Ops Staff 1"), so I changed the sheet name to be the VBA type ("Sheet3") Private Sub add_master_checkbox_module(sheet_name As String, report_book As Workbook, checkbox_name as String) Dim VB_proj As Object Dim VB_comp As Object Dim code_mod As Object Dim line_number As Long Dim proc_lines As String On Error GoTo Error_ClickEvent Set VB_proj = report_book.VBProject Set VB_comp = VB_proj.VBComponents(sheet_name) Set code_mod = VB_comp.CodeModule proc_lines = "Dim cbx As CheckBox" & vbLf & _ "Dim val As Long " & vbLf & _ "Dim grp As String " & vbLf & _ vbLf & _ vbTab & "grp = Application.Caller " & vbLf & _ vbTab & "val = ActiveSheet.CheckBoxes(grp).Value" & vbLf & _ vbTab & "grp = Split(grp, ""_"")(1)" & vbLf & _ vbLf & _ vbTab & "For Each cbx In ActiveSheet.CheckBoxes" & vbLf & _ vbTab & vbTab & "If cbx.Name Like grp & ""_*"" Then" & vbLf & _ vbTab & vbTab & vbTab & "cbx.Value = val" & vbLf & _ vbTab & vbTab & "End If" & vbLf & _ vbTab & "Next cbx" With code_mod Debug.Print checkbox_name line_number = .CreateEventProc("Click", checkbox_name) line_number = line_number + 2 .InsertLines line_number, proc_lines End With Error_ClickEvent: MsgBox Err & ": " & Err.Description End Sub Below is the part of the main procedure where the checkbox is created and the above is called. `rg` refers to a range in a for loop. With temp_sheet.CheckBoxes.Add(Left:=rg.Left + (rg.Width / 2#) - 12, Top:=rg.Top, Width:=12, Height:=rg.Height) .Caption = "" .LinkedCell = rg .Name = checkbox_name End With Call add_master_checkbox_module("Sheet" & sheet_number, report_book, checkbox_name)
|html|css|
null
I keep getting undefined when I try to destructure the body object from my `const { title, body, userId } = request.body;` I have 2 components, a server that post data to an API endpoint and a client component that reads the server component locally and is supposed to send the body data collected from inputs to the server content. am not getting any error aside from undefined. here is the server component: ``` import { NextResponse } from "next/server" export async function GET() { const res = await fetch('https://jsonplaceholder.typicode.com/posts') const data = await res.json() // console.log({ data }) const post = data.slice(0,5) return Response.json({ data:post }) } export async function POST(request, response) { const { title, body, userId } = request.body; console.log({ title, body, userId }) const fetchResponse = await fetch('https://jsonplaceholder.typicode.com/posts', { method: 'POST', headers: { 'Content-type': 'application/json; charset=UTF-8', }, body: JSON.stringify({ title, body, userId, }) }); const data = await fetchResponse.json(); console.log(data) return NextResponse.json(data); } ``` and here is the client component: ``` "use client" import { useState } from "react"; const Postapost = () => { const [title, settitle] = useState("") const [body, setbody] = useState("") console.log(title) console.log(body) const Handlepost = async () => { const userId = 1; const fullpost = { title, body, userId, }; const response = await fetch('http://localhost:3000/api', { method: 'POST', headers: { 'Content-type': 'application/json; charset=UTF-8', }, body: JSON.stringify({title, body, userId}), }, console.log(fullpost) ) .then((response) => response.json()) .then((json) => console.log(json)); }; return ( <div> <input type="text" name="title" onChange={(e) => {settitle(e.target.value)}} /> <input type="text" name="body" onChange={(e) => {setbody(e.target.value)}} /> <button onClick={Handlepost}>add post</button> </div> ); } export default Postapost; ```
how do I send data from my client component to my server side POST route Handler with Next.js app router
|reactjs|typescript|next.js|next.js13|nextjs-dynamic-routing|
My Firebase Realtime Database saves each user with 4 features: name, email, password, and confirm password. The class of users: public class Users { String Username,Email,Password,ConfirmPassword; public Users() { } public Users(String username, String email, String password, String confirmPassword) { Username = username; Email = email; Password = password; ConfirmPassword = confirmPassword; } public String getUsername() { return Username; } public void setUsername(String username) { Username = username; } public String getEmail() { return Email; } public void setEmail(String email) { Email = email; } public String getPassword() { return Password; } public void setPassword(String password) { Password = password; } public String getConfirmPassword() { return ConfirmPassword; } public void setConformPassword(String conformPassword) { ConfirmPassword = conformPassword; } } The Firebase data that i saved: { "user": { "user22": { "confirmPassword": "12345678", "email": "user22@gmail.com", "password": "12345678", "username": "user22" } } } In my app I have the option to change the current password to a new password, it requires you to put in your previous password(the current one that the Firebase saved) and then put new password(the user puts the data about the passwords on UI 'EditText'). See here how it looks: [enter image description here](https://i.stack.imgur.com/xvLcQ.png) Then the user has to click on 'confirm button' to change the old password to a new one. But before its changes,***the computer need to check if the old password compares to the current password that is saved on Firebase*** . I don't know how to do that, please help me!! I tried to do that code but not sure if I get the access to the variable that I want: public void showUserName() { FirebaseDatabase Data= FirebaseDatabase.getInstance(); DatabaseReference myRef=Data.getReference("user"); myRef.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot snapshot) { username.setText(snapshot.child("username").getValue(String.class)); } @Override public void onCancelled(@NonNull DatabaseError error) { } }); } It always changed even when the previous pass don't compare to the current..
private void register (String username, String email, String password) { auth.createUserWithEmailAndPassword(email,password) .addOnCompleteListener(task -> { if (task.isSuccessful()){ FirebaseUser firebaseUser = auth.getCurrentUser(); String userid = firebaseUser.getUid(); reference = FirebaseDatabase.getInstance().getReference("users").child(userid); HashMap<String, String> hashMap = new HashMap<>(); hashMap.put("id",userid); hashMap.put("username",username); hashMap.put("imageURL","default"); reference.setValue(hashMap).addOnCompleteListener(new OnCompleteListener<Void>() { @Override public void onComplete(@NonNull Task<Void> task) { if (task.isSuccessful()){ Intent intent = new Intent(RegisterActivity.this,MainActivity.class); intent.addFlags(Intent.FLAG_ACTIVITY_CLEAR_TASK | Intent.FLAG_ACTIVITY_NEW_TASK); startActivity(intent); finish(); } } }); } else{ Toast.makeText(RegisterActivity.this, "You can't register with this email and password", Toast.LENGTH_SHORT).show(); } }); Users are not showing in my database after registering using this code...pls help asap with this error
Users not registering in database
|android|database|firebase|
null
i have 1 dog page on Facebook, i usually post photo of dogs when ever i have time, so trying to write a scheduler that will take images from my system folder and upload and publish on my page. i want to post images, from my local system to 1 of my managed pages. i have page access token. and using below curl i am getting response as well. ``` curl 'https://graph.facebook.com/v19.0/103269412609092/photos?published=true' -H 'Cookie: ps_l=0; ps_n=0; ps_l=0; ps_n=0' -F 'access_token="my_page_access_toekn"' -F 'source=@"/C:/Users/Downloads/cute_dog.jpg"' -F 'publish="true" ``` and i am getting response back ``` { "id": "388682197392493", "post_id": "103269412609092_388682220725824" } ``` when i login from my own account, i can see the images being posted on the page. but when i login from my friend account, i don't see the image. i tried adding `publish="true` in body as well as in path param, but nothing seems working. for reference, i am following this page https://developers.facebook.com/docs/pages-api/posts what am i missing?
Facebook Post Images from local system on own Page
|facebook|facebook-graph-api|facebook-javascript-sdk|facebook-opengraph|facebook-php-sdk|
null
Is it possible to write a Chrome/Firefox plug-in that can automatically open the dev tools for every open tab and execute code in the console? I have already done this with Selenium, but I would like to have it as a plug-in. Unfortunately, I haven't found a chrome api yet that allows you to automatically insert and execute code in devtools. I would be very grateful to anyone who could help me get a step closer.
Error NullPointerExeception: When trying to add Value in ArrayList & adapter.notifydatachanged
|java|class|arraylist|android-recyclerview|android-arrayadapter|
[please see the screenshot ](https://i.stack.imgur.com/J9zzx.png) I want image slider as like as in image in jetpack compose Android kotlin. I am trying in many way but now working exact same things. There are any way to do in jetpack compose is it. need a help anyone is there to do the same things
Let's assume you have those 2 files : layout.html ``` ...imagine a plain HTML file, with the body having an id attribute set to "body" Somehow I cannot get to get this piece of code inside the SO editor it just won't show... ``` content.htm ``` <h1>DOM content</h1> <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul> ``` Here is the code for index.php that will insert content.htm in layout.html ``` loadHTMLFile('layout.html'); // loads the content of the document $content = new DOMDocument(); $content->loadHTMLFile('content.htm'); // imports a copy of the content into the main document $import = $layout->importNode($content->getElementById('content'), true); $body = $layout->getElementById("body"); $body->appendChild($import); echo $layout->saveHTML(); ``` A few thoughts and notes : - even if you only load a partial html document, DOMDocument::loadHTMLFile will create a complete HTML document and insert your file inside. - for instance, this is what's inside the $content object : ``` <h1>DOM content</h1> <ul> <li>Item 1</li> <li>Item 2</li> <li>Item 3</li> </ul> ``` - you cannot move nodes from one document to another, you need to import those - once imported, the nodes will not show as they are not attached to any other nodes in the document : you have to do it manually (appendChild here).
You should first check loki api `GET ~/loki/api/v1/rules` give the correct response.
I'm attempting to retrieve user data, but the method is returning an empty object. bot.py ``` menuId = "id" webapp = "https://localhost" + "/" + menuId bot = telebot.TeleBot(API_TOKEN) def webAppKeyboardInline(): keyboard = types.InlineKeyboardMarkup(row_width=1) webApp = types.WebAppInfo(webapp) one = types.InlineKeyboardButton(text="Open", web_app=webApp) keyboard.add(one) return keyboard @bot.message_handler(commands=['start']) def handle_start(message): bot.send_message(message.chat.id, "hello!", reply_markup=webAppKeyboardInline()) bot.infinity_polling() ``` There is nothing interesting on the website, I simply get an object. But, despite the button type, it is always an empty object. I've experimented with various button techniques.
{"Voters":[{"Id":4267244,"DisplayName":"Dalija Prasnikar"}]}
I wait until the page is loaded and use the "DOMContentLoaded" method to add eventhandlers on some p tags. This works until I open and close the modal. Can someone please tell me why the page fully freezes? ``` <html lang="en"> <head> <meta charset="UTF-8"> <meta name="viewport" content="width=device-width, initial-scale=1.0"> <title>Document</title> </head> <body> <div id="div_1"> <p>One</p> <p>Two</p> <p>Three</p> </div> <p id="open_modal">open the modal</p> <script> document.addEventListener("DOMContentLoaded", () => { let test = document.querySelector("#div_1") for (let i = 0; i < test.children.length; i++) { test.children[i].addEventListener("click", () => { console.log(test.children[i].innerHTML) }); }; }); document.querySelector("#open_modal").addEventListener("click", () => { if (!document.querySelector("#modal")) { document.body.innerHTML += ` <div id="modal" style="display: block; position: fixed; z-index: 1; padding-top: 100px; left: 0; top: 0; width: 100%; height: 100%; overflow: auto; background-color: rgb(0,0,0); background-color: rgba(0,0,0,0.4)"> <div id="modal_content"> <span id="modal_close">&times;</span> <p style="color: green;">Some text in the Modal..</p> </div> </div> `; } else { document.querySelector("#modal").style.display = "block"; document.querySelector("#modal").style.zIndex = "1"; }; document.querySelector("#modal_close").addEventListener("click", () => { document.querySelector("#modal").style.display = "none"; document.querySelector("#modal").style.zIndex = "-1"; }); }); </script> </body> </html> ```
JsonObject throws an exception: JSONObject["employer_website"] is not a string (class org.json.JSONObject$Null : null)
|java|json|spring-boot|parsing|jsonparser|
I am trying to build my object using the below Json payload(which is being fetched from external API), now when ever i use any get method(i.e: jsonObject.getString() or jsonObject.getBoolean(), jsonObject.getObject()) and if the value present for the key is null,I am getting an exception that "the value is not a string/boolean/Jsonobject" now how can i handle this, since if the value is present in object 1 on the above array index 0, it may/maynot present in another object at index 1 here I can apply null checks to resolve this issue, but this object has more than 40 key value pairs and add these many null checks may become cumbersome, is there any better way to resolve this? ```Json data": [ { "employer_name": "Dice", "employer_logo": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKlgydP7sElaJC9qPrtNHwBhyTMHYgii1RPWsy&s=0", "employer_website": null, "employer_company_type": "Information", "job_publisher": "LinkedIn", "job_id": "8yv3oA_2-UYAAAAAAAAAAA==", "job_employment_type": "CONTRACTOR", "job_title": "Web Developer - 6-month Contract - Houston Hybrid", "job_apply_link": "https://www.linkedin.com/jobs/view/web-developer-6-month-contract-houston-hybrid-at-dice-3624857671", "job_apply_is_direct": false ..... }, { "employer_name": "Dicenvskjvks", "employer_logo": "https://encrypted-tbn0.gstatic.com/images?q=tbn:ANd9GcQKlgydP7sElaJC9qPrtNHwBhyTMHYgii1RPWsy&s=0", "employer_website": "https://www.someUrl.com" "employer_company_type": "Information", "job_publisher": "LinkedIn", "job_id": "8yv3oA_2-UYAAAAAAAAAAA==", "job_employment_type": null, "job_title": "Web Developer - 6-month Contract - Houston Hybrid", "job_apply_link": "https://www.linkedin.com/jobs/view/web-developer-6-month-contract-houston-hybrid-at-dice-3624857671", "job_apply_is_direct": false ..... } ] ``` My code: ```Java public static List<Response> parseJServer1Response(String responseBody) throws ParseException, JsonProcessingException { JSONObject responseObject = new JSONObject(responseBody); JSONArray data = responseObject.getJSONArray("data"); List<Response> response = new ArrayList<>(); for (int i = 0; i < data.length(); i++) { JSONObject jsonObject = data.getJSONObject(i); JSearch job = Response.builder() .companyName(jsonObject.getString("employer_name")) .companyLogo(jsonObject.getString("employer_logo")) .companyType(jsonObject.getString("employer_company_type")) .jobPublisher(jsonObject.getString("job_publisher")) .... .... .... .... .... .... .build(); response.add(job); } return response; } ```
In Rust, how can I create a function that accpets a closure as argument and iterate and print all values captured by the closure reflectively? For example: ```rust fn print_captured_values<F>(f: F) where F: Fn() { // How to implement it? } ```
In Rust, how to inspect values captured by a closure?
I have a `[pscustomobject]` with a property `id`. According to PowerShell documentation, the parameter '-id' can be passed through the pipeline using `ByPropertyName`. I discovered that the approach with `ForEach-Object` works (although I don't understand why), while the approach without `ForEach-Object` does not. $obj = [pscustomobject]@{id=4444} # doesn't work $obj | get-process -id $_.id # it works $obj | foreach{get-process -id $_.id} Apparently the "foreach" does the trick, but why?
How to pass -id parameter to get-process from pipeline?
I have a rest service where it is connecting to mongdb to get the response.Ater the spring boot upgrade the error response was not appearing in Browser. It is displaying like below. Not sure why it is giving null vales in the error response. If I try some other way , it is giving proper response only in Postmand not in Browser . Can any one help me how to format the Error response properly in Browser.Thanks in Advance **Whitelabel Error Page This application has no explicit mapping for /error, so you are seeing this as a fallback. Mon Mar 25 22:57:12 UTC 2024 There was an unexpected error (type=Not Found, status=404). Resource Not Found** Below is the syntax of code: import java.util.Date; public class ErrorMessage { private int statusCode; @JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "dd-MM-yyyy hh:mm:ss") private Date timestamp; private String message; private String path; private String error; public ErrorMessage(int value, Date date, String message, String resourceNotFound) { } public ErrorMessage(String status, String message, String stackTrace) { } public int getStatusCode() { return statusCode; } public void setStatusCode(int statusCode) { this.statusCode = statusCode; } public Date getTimestamp() { return timestamp; } public void setTimestamp(Date timestamp) { this.timestamp = timestamp; } public String getMessage() { return message; } public void setMessage(String message) { this.message = message; } public String getPath() { return path; } public void setPath(String path) { this.path = path; } public String getError() { return error; } public void setError(String error) { this.error = error; } } CustomExceptionClass: public class CustomDataNotFoundException extends RuntimeException { public CustomDataNotFoundException() { super(); } public CustomDataNotFoundException(String message) { super(message); } } Exception Handler : @ControllerAdvice public class ValidationExceptionHandler { @ExceptionHandler(CustomDataNotFoundException.class) public ResponseEntity<ErrorMessage> handleCustomDataNotFoundExceptions( Exception e ) { HttpStatus status = HttpStatus.NOT_FOUND; // 404 // converting the stack trace to String StringWriter stringWriter = new StringWriter(); PrintWriter printWriter = new PrintWriter(stringWriter); e.printStackTrace(printWriter); String stackTrace = stringWriter.toString(); return new ResponseEntity<>( new ErrorMessage( "404", e.getMessage(), stackTrace ), status ); } } Browser: { "statusCode": 0, "timestamp": null, "message": null, "path": null, "error": null } **Postman:** { "statusCode": 0, "timestamp": null, "message": null, "path": null, "error": null } Controller : if (system!= null && !system.isEmpty()) documentMap.put("ClaimId", claimId); List<? extends Bson> pipelines = getAggregate(queryLimit, projectFields, documentMap); List database= collectionDB.aggregate(pipelines).into(Aggregate); if (system.isEmpty() && !system.isEmpty()) { documentMap.remove("system.value"); List<? extends Bson> pipelines= getAggregate(queryLimit, projectFields, documentMap); List database2= collectionDB.aggregate(pipelines2).into(Aggregate2); if (!system.isEmpty()) throw new ValidationException(RESOURCE_NOT_FOUND); } if (system.isEmpty()) throw new CustomDataNotFoundException(RESOURCE_NOT_FOUND);
This may be old, but I'm just doing some support on such an old system: instead of: public EntitiesContext() : base("name=EntitiesContext") just use public EntitiesContext() : base("EntitiesContext") and you should be good to go.
I'm having trouble building v8 and libv8 to use with v8js php library. I'm running `gm x64.release` on the depot_tools git repo after running `fetch v8; cd v8` and the v8 file and g8 file gets created but the problem is that i cannot find the libv8/libnode required to compile v8js using pecl (https://github.com/phpv8/v8js). Here is the tree of the build output: https://pastebin.com/WAfxFegy I tried installing libv8-dev (on Ubuntu 22 it automatically replaces it with libnode-dev) but still nothing. How can i solve this? Thanks a lot! P.S: This is the output i get once i run the pecl install: ```shell sudo pecl install v8js WARNING: channel "pecl.php.net" has updated its protocols, use "pecl channel-update pecl.php.net" to update downloading v8js-2.1.2.tgz ... Starting to download v8js-2.1.2.tgz (102,977 bytes) ........................done: 102,977 bytes 28 source files, building running: phpize Configuring for: PHP Api Version: 20210902 Zend Module Api No: 20210902 Zend Extension Api No: 420210902 configure.ac:22: warning: $as_echo is obsolete; use AS_ECHO(["message"]) instead build/php.m4:2111: PHP_CONFIG_NICE is expanded from... configure.ac:22: the top level configure.ac:165: warning: The macro `AC_PROG_LIBTOOL` is obsolete. configure.ac:165: You should run autoupdate. build/libtool.m4:99: AC_PROG_LIBTOOL is expanded from... configure.ac:165: the top level Please provide the installation prefix of libv8 [autodetect] : /home/romeo/v8/out/x64.release building in /tmp/pear/temp/pear-build-rootfd2rq7/v8js-2.1.2 running: /tmp/pear/temp/v8js/configure --with-php-config=/usr/bin/php-config --with-v8js=/home/romeo/v8/out/x64.release checking for grep that handles long lines and -e... /usr/bin/grep checking for egrep... /usr/bin/grep -E checking for a sed that does not truncate output... /usr/bin/sed checking for pkg-config... /usr/bin/pkg-config checking pkg-config is at least version 0.9.0... yes checking for cc... cc checking whether the C compiler works... yes checking for C compiler default output file name... a.out checking for suffix of executables... checking whether we are cross compiling... no checking for suffix of object files... o checking whether the compiler supports GNU C... yes checking whether cc accepts -g... yes checking for cc option to enable C11 features... none needed checking how to run the C preprocessor... cc -E checking for icc... no checking for suncc... no checking for system library directory... lib checking if compiler supports -Wl,-rpath,... yes checking build system type... x86_64-pc-linux-gnu checking host system type... x86_64-pc-linux-gnu checking target system type... x86_64-pc-linux-gnu checking for PHP prefix... /usr checking for PHP includes... -I/usr/include/php/20210902 -I/usr/include/php/20210902/main -I/usr/include/php/20210902/TSRM -I/usr/include/php/20210902/Zend -I/usr/include/php/20210902/ext -I/usr/include/php/20210902/ext/date/lib checking for PHP extension directory... /usr/lib/php/20210902 checking for PHP installed headers prefix... /usr/include/php/20210902 checking if debug is enabled... no checking if zts is enabled... no checking for gawk... gawk checking for V8 Javascript Engine... yes, shared checking for V8 files in default path... not found configure: error: Please reinstall the v8 distribution ERROR: `/tmp/pear/temp/v8js/configure --with-php-config=/usr/bin/php-config --with-v8js=/home/romeo/v8/out/x64.release' failed ```
|java|android|firebase|firebase-realtime-database|
null
null
**TL;DR** ```python pl_series = [pl.Series(name, values) for name, values in zip(features, shuffle_arr.T)] X_train_permuted = ( X_train_permuted.with_columns( pl_series ) ) ``` ----- Let's work with a simple example. **X_train_permuted** ```python import polars as pl import numpy as np np.random.seed(0) data = {f'feature_{i}': np.random.rand(4) for i in range(0,3)} X_train_permuted = pl.DataFrame(data) X_train_permuted shape: (4, 3) ┌───────────┬───────────┬───────────┐ │ feature_0 ┆ feature_1 ┆ feature_2 │ │ --- ┆ --- ┆ --- │ │ f64 ┆ f64 ┆ f64 │ ╞═══════════╪═══════════╪═══════════╡ │ 0.548814 ┆ 0.423655 ┆ 0.963663 │ │ 0.715189 ┆ 0.645894 ┆ 0.383442 │ │ 0.602763 ┆ 0.437587 ┆ 0.791725 │ │ 0.544883 ┆ 0.891773 ┆ 0.528895 │ └───────────┴───────────┴───────────┘ ``` **Shuffle `feature_1` and `feature_2`** Use a list to keep track of the features you are shuffling: `features = ["feature_0", "feature_1"]`. ```python features = ["feature_0", "feature_1"] shuffle_arr = np.array(X_train_permuted[:, features]) from sklearn.utils import check_random_state random_state = check_random_state(42) random_seed = random_state.randint(np.iinfo(np.int32).max + 1) random_state.shuffle(shuffle_arr) shuffle_arr array([[0.71518937, 0.64589411], [0.60276338, 0.43758721], [0.5488135 , 0.4236548 ], [0.54488318, 0.891773 ]]) ``` **Replace associated columns in `X_train_permuted` with `shuffle_arr` values** * Use [`pl.DataFrame.with_columns`](https://docs.pola.rs/py-polars/html/reference/dataframe/api/polars.DataFrame.with_columns.html). * Pass a list (here: `pl_series`) with a [`pl.Series`](https://docs.pola.rs/py-polars/html/reference/series/index.html) for each shuffled feature, using a list comprehension (applying [`zip`](https://docs.python.org/3.3/library/functions.html#zip)). Make sure to transpose `shuffle_arr` to access to columns (see [`.T`](https://numpy.org/doc/stable/reference/generated/numpy.ndarray.T.html#numpy.ndarray.T)). ```python pl_series = [pl.Series(name, values) for name, values in zip(features, shuffle_arr.T)] X_train_permuted = ( X_train_permuted.with_columns( pl_series ) ) X_train_permuted shape: (4, 3) ┌───────────┬───────────┬───────────┐ │ feature_0 ┆ feature_1 ┆ feature_2 │ │ --- ┆ --- ┆ --- │ │ f64 ┆ f64 ┆ f64 │ ╞═══════════╪═══════════╪═══════════╡ │ 0.715189 ┆ 0.645894 ┆ 0.963663 │ │ 0.602763 ┆ 0.437587 ┆ 0.383442 │ │ 0.548814 ┆ 0.423655 ┆ 0.791725 │ │ 0.544883 ┆ 0.891773 ┆ 0.528895 │ └───────────┴───────────┴───────────┘ ``` ---- **Alternative (unstable!)** You could also use [`pl.DataFrame.update`](https://docs.pola.rs/py-polars/html/reference/dataframe/api/polars.DataFrame.update.html). Note, however, the warning in the docs: > This functionality is considered **unstable**. It may be changed at any point without it being considered a breaking change. ```python X_train_permuted = ( X_train_permuted.update( pl.DataFrame(shuffle_arr, schema=features) ) ) ```
This class has functions for getting screen width and height, For app responsiveness design but i keep getting that error ``` import 'package:flutter/material.dart'; import 'package:get/get.dart'; /* This class has functions for getting screen width and height, For app responsiveness design */ class AppLayout { static getSize(BuildContext context) { return MediaQuery.of(context).size; } static getScreenHeight() { return Get.height; } static getScreenWidth() { return Get.width; } static getHeight(double pixels) { double x = getScreenHeight() / pixels; return getScreenHeight() / x; } static getWidth(double pixels) { double x = getScreenWidth() / pixels; return getScreenWidth() / x; } } ``` i was trying to keep my application screen responsive by using a getx package, i already installed the latest package and import it successfully but i keep getting error when i save it
|generics|rust|lambda|reflection|closures|
|javascript|reactjs|react-router-dom|
Not sure that I completely understood the problem ("cant detect scroll on separate sections") but I think I got what you are trying to achieve. Below is a generic solution that calculates the scroll percentage of each div based on its top offset and height and sets the corresponding svg path length. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> var sect1 = document.getElementById("section1Wrapper"); var sect2 = document.getElementById("section2Wrapper"); var sect3 = document.getElementById("section3Wrapper"); var path1 = document.querySelector("#vectorPath1"); var path2 = document.querySelector("#vectorPath2"); var path3 = document.querySelector("#vectorPath3"); window.addEventListener("scroll", function() { setPathLength(path1, sect1) setPathLength(path2, sect2) setPathLength(path3, sect3) }); function setPathLength(path, sect){ let scrollPercentage = getDivScrollPercent(sect) let drawLength = 2268.36 * scrollPercentage * 3; path.style.strokeDasharray = `${drawLength}, 2268.36`; } function getDivScrollPercent(sect){ let rect = sect.getBoundingClientRect() let top = rect.top let height = rect.height // start calculating the scroll percentage when rect top // is between 0 (reached viewport top and -[div height] (scrolled out of viewport) // otherwise return 0 if (top > 0 || top < -height) return 0 return -top / height } <!-- language: lang-css --> #section1Wrapper { background-color: black; } #section2Wrapper { background-color: blue; } #section3Wrapper { background-color: red; } <!-- language: lang-html --> <!-- Section 1 --> <div id="section1Wrapper" class="section-wrapper"> <svg id="vectorSvg1" viewBox="0 0 697.25 2268.36"> <defs> <style> .teamcls { fill: none; stroke: #062334; stroke-miterlimit: 10; stroke-width: 50px; } </style> </defs> <path id="vectorPath1" class="teamcls" stroke-dasharray="0, 2268.36" d="M342.83 1.82 344.13 19.65 347.34 37.48 345.89 55.3 343.33 73.13 343.85 90.96 345.03 108.79 347.09 126.62 344.45 144.44 346.41 162.27 343.96 180.1 343.2 197.93 345.92 215.76 345.9 233.59 343.27 251.42 344.04 269.25 344.72 287.07 342.87 304.9 345.91 322.73 346.47 340.56 343.31 358.39 342.84 376.22 346.05 394.05 347.09 411.88 344.31 429.72 344.18 447.55 345.36 465.39 346.38 483.23 349.02 501.39 356.64 517.96 365.48 534.55 382.07 543.39 398.47 551.62 416.8 555.01 434.47 553.01 452.14 555.47 469.81 555.28 487.48 554.78 505.15 557.22 522.82 553.21 540.49 556.4 558.17 553.08 575.84 554.72 593.52 555.81 612.38 556.55 629.48 564.64 643.34 577.11 654.07 591.98 664.41 607.94 664.85 626.93 667.68 644.21 664.2 661.5 665.75 678.79 665.8 696.09 663.49 713.38 664.57 732.42 655.48 749.15 643.69 763.55 629.93 776.44 611.8 781.61 593.52 783.13 575.22 786.3 556.93 786.81 538.63 782.92 520.33 785.01 502.04 787.05 483.74 784.69 465.44 786.81 447.14 787.1 428.85 786.72 410.55 787.47 392.25 784.29 373.95 786.59 355.65 783.57 337.35 786.04 319.06 785.03 300.76 783.54 282.46 783.19 264.16 786.56 245.86 784.34 227.56 784.26 209.26 782.96 190.96 783.35 172.66 787.45 154.36 785.96 136.06 783.88 117.75 784.03 99.44 786.87 80.85 787.7 63.01 793.98 49.09 806.73 35.65 820.25 30.65 838.65 29.43 857.08 27.11 874.39 26.95 891.71 25.24 909.02 28.55 926.33 27.89 943.65 27.72 960.96 26.32 978.28 29.84 995.6 30.23 1014.15 37.55 1031.34 48.64 1046.4 63.54 1057.79 80.56 1066.06 99.44 1068.51 117.74 1065.99 136.03 1066.93 154.33 1065.5 172.63 1069.57 190.92 1067.69 209.22 1065.98 227.52 1066.37 245.82 1069.58 264.12 1068.85 282.41 1066.61 300.71 1069.11 319.01 1069.69 337.31 1068.27 355.61 1069.21 373.91 1069.95 392.2 1068.24 410.5 1066.38 428.8 1065.83 447.1 1068.21 465.4 1067.81 483.7 1066.48 502 1068.88 520.3 1068.24 538.6 1068.14 556.91 1067.8 575.21 1068.07 593.52 1067.28 612.32 1069.13 629.3 1077.33 645.19 1087.63 657.66 1102.27 664.46 1120.3 664.54 1139.31 666.07 1157.02 667.74 1174.73 663.62 1192.44 664.23 1210.15 664.43 1227.86 663.14 1245.57 663.1 1263.29 663.76 1281.16 671.05 1298.69 666.49 1317.99 661.07 1336.01 649.02 1350.49 634.49 1363.07 615.71 1367.36 596.91 1372.99 578.62 1371.37 560.32 1370.28 542.03 1369.25 523.73 1369.98 505.43 1369.63 487.13 1371.2 468.84 1370.65 450.54 1369.87 432.24 1370.01 413.94 1372.64 395.64 1372.85 377.34 1369.37 359.05 1369.09 340.75 1371.39 322.45 1372.93 304.16 1369.27 285.86 1371.18 267.56 1369.37 249.26 1371.75 230.96 1373.29 212.66 1370.01 194.36 1369.28 176.06 1369.59 157.76 1370.43 139.45 1370.49 121.14 1371.34 102.84 1372.78 83.77 1371.59 68 1382.42 51.83 1391.76 40.08 1406.53 31.32 1423.6 31.21 1442.76 32.06 1460.08 31.78 1477.39 32.43 1494.7 33.48 1512.01 32.22 1529.33 30.3 1546.65 30.7 1563.97 32.64 1581.29 33.56 1599.85 42.09 1616.36 51.98 1632.15 67.33 1642.78 84.48 1649.79 102.84 1654.46 121.13 1652.41 139.43 1654.35 157.73 1652.35 176.02 1651.07 194.32 1652.43 212.62 1652.22 230.92 1651.34 249.21 1654.94 267.51 1651.38 285.81 1651.26 304.11 1653.57 322.41 1654.87 340.71 1652.66 359 1651.3 377.3 1654.89 395.6 1653.12 413.89 1654.83 432.19 1651.17 450.49 1653.41 468.79 1651.13 487.09 1654.28 505.39 1651.57 523.69 1652.05 542 1653.85 560.3 1655.18 578.61 1651.05 596.91 1655.61 616.06 1653.52 632.82 1662.79 648.27 1673.64 659.44 1688.89 667.65 1706.03 669.68 1724.99 667.66 1743.76 670.48 1762.53 670.9 1781.3 670.74 1800.08 671.18 1818.86 670.07 1837.64 668.39 1856.42 665.12 1874.69 659.24 1892.4 648.52 1908.02 632.03 1917.24 615.5 1925.79 596.91 1930.16 578.86 1926.99 560.81 1927.26 542.75 1929.4 524.7 1930.72 506.64 1928.66 488.59 1927.02 470.53 1929.93 452.47 1926.13 434.41 1927.31 416.35 1928.19 398.29 1929.14 380.23 1928.57 364.68 1931.24 356.22 1944.31 351.94 1958.17 348.98 1976.37 351.17 1994.57 348.52 2012.77 352.24 2030.97 350.24 2049.17 352.65 2067.36 348.88 2085.56 348.5 2103.76 349.66 2121.96 348.68 2140.16 350.51 2158.36 350.86 2176.56 349.59 2194.76 348.89 2212.97 349.76 2231.17 349.14 2249.38 349.71 2267.59" ></path> </svg> </div> <!-- Section 2 --> <div id="section2Wrapper" class="section-wrapper"> <svg id="vectorSvg2" viewBox="0 0 697.25 2268.36"> <defs> <style> .teamcls { fill: none; stroke: #062334; stroke-miterlimit: 10; stroke-width: 50px; } </style> </defs> <path id="vectorPath2" class="teamcls" stroke-dasharray="0, 2268.36" d="M342.83 1.82 344.13 19.65 347.34 37.48 345.89 55.3 343.33 73.13 343.85 90.96 345.03 108.79 347.09 126.62 344.45 144.44 346.41 162.27 343.96 180.1 343.2 197.93 345.92 215.76 345.9 233.59 343.27 251.42 344.04 269.25 344.72 287.07 342.87 304.9 345.91 322.73 346.47 340.56 343.31 358.39 342.84 376.22 346.05 394.05 347.09 411.88 344.31 429.72 344.18 447.55 345.36 465.39 346.38 483.23 349.02 501.39 356.64 517.96 365.48 534.55 382.07 543.39 398.47 551.62 416.8 555.01 434.47 553.01 452.14 555.47 469.81 555.28 487.48 554.78 505.15 557.22 522.82 553.21 540.49 556.4 558.17 553.08 575.84 554.72 593.52 555.81 612.38 556.55 629.48 564.64 643.34 577.11 654.07 591.98 664.41 607.94 664.85 626.93 667.68 644.21 664.2 661.5 665.75 678.79 665.8 696.09 663.49 713.38 664.57 732.42 655.48 749.15 643.69 763.55 629.93 776.44 611.8 781.61 593.52 783.13 575.22 786.3 556.93 786.81 538.63 782.92 520.33 785.01 502.04 787.05 483.74 784.69 465.44 786.81 447.14 787.1 428.85 786.72 410.55 787.47 392.25 784.29 373.95 786.59 355.65 783.57 337.35 786.04 319.06 785.03 300.76 783.54 282.46 783.19 264.16 786.56 245.86 784.34 227.56 784.26 209.26 782.96 190.96 783.35 172.66 787.45 154.36 785.96 136.06 783.88 117.75 784.03 99.44 786.87 80.85 787.7 63.01 793.98 49.09 806.73 35.65 820.25 30.65 838.65 29.43 857.08 27.11 874.39 26.95 891.71 25.24 909.02 28.55 926.33 27.89 943.65 27.72 960.96 26.32 978.28 29.84 995.6 30.23 1014.15 37.55 1031.34 48.64 1046.4 63.54 1057.79 80.56 1066.06 99.44 1068.51 117.74 1065.99 136.03 1066.93 154.33 1065.5 172.63 1069.57 190.92 1067.69 209.22 1065.98 227.52 1066.37 245.82 1069.58 264.12 1068.85 282.41 1066.61 300.71 1069.11 319.01 1069.69 337.31 1068.27 355.61 1069.21 373.91 1069.95 392.2 1068.24 410.5 1066.38 428.8 1065.83 447.1 1068.21 465.4 1067.81 483.7 1066.48 502 1068.88 520.3 1068.24 538.6 1068.14 556.91 1067.8 575.21 1068.07 593.52 1067.28 612.32 1069.13 629.3 1077.33 645.19 1087.63 657.66 1102.27 664.46 1120.3 664.54 1139.31 666.07 1157.02 667.74 1174.73 663.62 1192.44 664.23 1210.15 664.43 1227.86 663.14 1245.57 663.1 1263.29 663.76 1281.16 671.05 1298.69 666.49 1317.99 661.07 1336.01 649.02 1350.49 634.49 1363.07 615.71 1367.36 596.91 1372.99 578.62 1371.37 560.32 1370.28 542.03 1369.25 523.73 1369.98 505.43 1369.63 487.13 1371.2 468.84 1370.65 450.54 1369.87 432.24 1370.01 413.94 1372.64 395.64 1372.85 377.34 1369.37 359.05 1369.09 340.75 1371.39 322.45 1372.93 304.16 1369.27 285.86 1371.18 267.56 1369.37 249.26 1371.75 230.96 1373.29 212.66 1370.01 194.36 1369.28 176.06 1369.59 157.76 1370.43 139.45 1370.49 121.14 1371.34 102.84 1372.78 83.77 1371.59 68 1382.42 51.83 1391.76 40.08 1406.53 31.32 1423.6 31.21 1442.76 32.06 1460.08 31.78 1477.39 32.43 1494.7 33.48 1512.01 32.22 1529.33 30.3 1546.65 30.7 1563.97 32.64 1581.29 33.56 1599.85 42.09 1616.36 51.98 1632.15 67.33 1642.78 84.48 1649.79 102.84 1654.46 121.13 1652.41 139.43 1654.35 157.73 1652.35 176.02 1651.07 194.32 1652.43 212.62 1652.22 230.92 1651.34 249.21 1654.94 267.51 1651.38 285.81 1651.26 304.11 1653.57 322.41 1654.87 340.71 1652.66 359 1651.3 377.3 1654.89 395.6 1653.12 413.89 1654.83 432.19 1651.17 450.49 1653.41 468.79 1651.13 487.09 1654.28 505.39 1651.57 523.69 1652.05 542 1653.85 560.3 1655.18 578.61 1651.05 596.91 1655.61 616.06 1653.52 632.82 1662.79 648.27 1673.64 659.44 1688.89 667.65 1706.03 669.68 1724.99 667.66 1743.76 670.48 1762.53 670.9 1781.3 670.74 1800.08 671.18 1818.86 670.07 1837.64 668.39 1856.42 665.12 1874.69 659.24 1892.4 648.52 1908.02 632.03 1917.24 615.5 1925.79 596.91 1930.16 578.86 1926.99 560.81 1927.26 542.75 1929.4 524.7 1930.72 506.64 1928.66 488.59 1927.02 470.53 1929.93 452.47 1926.13 434.41 1927.31 416.35 1928.19 398.29 1929.14 380.23 1928.57 364.68 1931.24 356.22 1944.31 351.94 1958.17 348.98 1976.37 351.17 1994.57 348.52 2012.77 352.24 2030.97 350.24 2049.17 352.65 2067.36 348.88 2085.56 348.5 2103.76 349.66 2121.96 348.68 2140.16 350.51 2158.36 350.86 2176.56 349.59 2194.76 348.89 2212.97 349.76 2231.17 349.14 2249.38 349.71 2267.59" ></path> </svg> </div> <!-- Section 3 --> <div id="section3Wrapper" class="section-wrapper"> <svg id="vectorSvg3" viewBox="0 0 697.25 2268.36"> <defs> <style> .teamcls { fill: none; stroke: #062334; stroke-miterlimit: 10; stroke-width: 50px; } </style> </defs> <path id="vectorPath3" class="teamcls" stroke-dasharray="0, 2268.36" d="M342.83 1.82 344.13 19.65 347.34 37.48 345.89 55.3 343.33 73.13 343.85 90.96 345.03 108.79 347.09 126.62 344.45 144.44 346.41 162.27 343.96 180.1 343.2 197.93 345.92 215.76 345.9 233.59 343.27 251.42 344.04 269.25 344.72 287.07 342.87 304.9 345.91 322.73 346.47 340.56 343.31 358.39 342.84 376.22 346.05 394.05 347.09 411.88 344.31 429.72 344.18 447.55 345.36 465.39 346.38 483.23 349.02 501.39 356.64 517.96 365.48 534.55 382.07 543.39 398.47 551.62 416.8 555.01 434.47 553.01 452.14 555.47 469.81 555.28 487.48 554.78 505.15 557.22 522.82 553.21 540.49 556.4 558.17 553.08 575.84 554.72 593.52 555.81 612.38 556.55 629.48 564.64 643.34 577.11 654.07 591.98 664.41 607.94 664.85 626.93 667.68 644.21 664.2 661.5 665.75 678.79 665.8 696.09 663.49 713.38 664.57 732.42 655.48 749.15 643.69 763.55 629.93 776.44 611.8 781.61 593.52 783.13 575.22 786.3 556.93 786.81 538.63 782.92 520.33 785.01 502.04 787.05 483.74 784.69 465.44 786.81 447.14 787.1 428.85 786.72 410.55 787.47 392.25 784.29 373.95 786.59 355.65 783.57 337.35 786.04 319.06 785.03 300.76 783.54 282.46 783.19 264.16 786.56 245.86 784.34 227.56 784.26 209.26 782.96 190.96 783.35 172.66 787.45 154.36 785.96 136.06 783.88 117.75 784.03 99.44 786.87 80.85 787.7 63.01 793.98 49.09 806.73 35.65 820.25 30.65 838.65 29.43 857.08 27.11 874.39 26.95 891.71 25.24 909.02 28.55 926.33 27.89 943.65 27.72 960.96 26.32 978.28 29.84 995.6 30.23 1014.15 37.55 1031.34 48.64 1046.4 63.54 1057.79 80.56 1066.06 99.44 1068.51 117.74 1065.99 136.03 1066.93 154.33 1065.5 172.63 1069.57 190.92 1067.69 209.22 1065.98 227.52 1066.37 245.82 1069.58 264.12 1068.85 282.41 1066.61 300.71 1069.11 319.01 1069.69 337.31 1068.27 355.61 1069.21 373.91 1069.95 392.2 1068.24 410.5 1066.38 428.8 1065.83 447.1 1068.21 465.4 1067.81 483.7 1066.48 502 1068.88 520.3 1068.24 538.6 1068.14 556.91 1067.8 575.21 1068.07 593.52 1067.28 612.32 1069.13 629.3 1077.33 645.19 1087.63 657.66 1102.27 664.46 1120.3 664.54 1139.31 666.07 1157.02 667.74 1174.73 663.62 1192.44 664.23 1210.15 664.43 1227.86 663.14 1245.57 663.1 1263.29 663.76 1281.16 671.05 1298.69 666.49 1317.99 661.07 1336.01 649.02 1350.49 634.49 1363.07 615.71 1367.36 596.91 1372.99 578.62 1371.37 560.32 1370.28 542.03 1369.25 523.73 1369.98 505.43 1369.63 487.13 1371.2 468.84 1370.65 450.54 1369.87 432.24 1370.01 413.94 1372.64 395.64 1372.85 377.34 1369.37 359.05 1369.09 340.75 1371.39 322.45 1372.93 304.16 1369.27 285.86 1371.18 267.56 1369.37 249.26 1371.75 230.96 1373.29 212.66 1370.01 194.36 1369.28 176.06 1369.59 157.76 1370.43 139.45 1370.49 121.14 1371.34 102.84 1372.78 83.77 1371.59 68 1382.42 51.83 1391.76 40.08 1406.53 31.32 1423.6 31.21 1442.76 32.06 1460.08 31.78 1477.39 32.43 1494.7 33.48 1512.01 32.22 1529.33 30.3 1546.65 30.7 1563.97 32.64 1581.29 33.56 1599.85 42.09 1616.36 51.98 1632.15 67.33 1642.78 84.48 1649.79 102.84 1654.46 121.13 1652.41 139.43 1654.35 157.73 1652.35 176.02 1651.07 194.32 1652.43 212.62 1652.22 230.92 1651.34 249.21 1654.94 267.51 1651.38 285.81 1651.26 304.11 1653.57 322.41 1654.87 340.71 1652.66 359 1651.3 377.3 1654.89 395.6 1653.12 413.89 1654.83 432.19 1651.17 450.49 1653.41 468.79 1651.13 487.09 1654.28 505.39 1651.57 523.69 1652.05 542 1653.85 560.3 1655.18 578.61 1651.05 596.91 1655.61 616.06 1653.52 632.82 1662.79 648.27 1673.64 659.44 1688.89 667.65 1706.03 669.68 1724.99 667.66 1743.76 670.48 1762.53 670.9 1781.3 670.74 1800.08 671.18 1818.86 670.07 1837.64 668.39 1856.42 665.12 1874.69 659.24 1892.4 648.52 1908.02 632.03 1917.24 615.5 1925.79 596.91 1930.16 578.86 1926.99 560.81 1927.26 542.75 1929.4 524.7 1930.72 506.64 1928.66 488.59 1927.02 470.53 1929.93 452.47 1926.13 434.41 1927.31 416.35 1928.19 398.29 1929.14 380.23 1928.57 364.68 1931.24 356.22 1944.31 351.94 1958.17 348.98 1976.37 351.17 1994.57 348.52 2012.77 352.24 2030.97 350.24 2049.17 352.65 2067.36 348.88 2085.56 348.5 2103.76 349.66 2121.96 348.68 2140.16 350.51 2158.36 350.86 2176.56 349.59 2194.76 348.89 2212.97 349.76 2231.17 349.14 2249.38 349.71 2267.59" ></path> </svg> </div> <!-- end snippet -->
The existing code renders. However, when I remove `Router` from line 2 as an import, even though it's not being used, it breaks. When I compile, of course I get "Line 2:27: 'Router' is defined but never used no-unused-vars" Why is this? Or does anyone have any insight? ```jsx import React from 'react'; import { BrowserRouter as Router, Routes, Route } from 'react-router-dom'; import HomePage from './HomePage'; import PlanTripPage from './PlanTripPage'; import NavBar from './NavBar'; import ItineraryPage from './ItineraryPage'; import './App.css'; function App() { return ( <div> <NavBar /> <Routes> <Route exact path="/" element={<HomePage />} /> <Route path="/plan-trip" element={<PlanTripPage />} /> <Route path="/itinerary" element={<ItineraryPage />} /> </Routes> </div> ); } export default App; ``` Here is my index file. ```jsx import React from 'react'; import ReactDOM from 'react-dom'; import { BrowserRouter } from 'react-router-dom'; import App from './App'; import './index.css'; ReactDOM.render( <BrowserRouter> <App /> </BrowserRouter>, document.getElementById('root') ); ```
I have a frame (events) which I want to join into another frame (fr), joining on Date and Symbol. There aren't necessarily any date overlaps. The date in events would match with the first occurrence only on the same or later date in fr, so if the event date is 2010-08-29, it would join on the same date or if not present then the next available date (2010-09-01). I've tried to do this using search_sorted and join_asof but I'd like to group by the Symbol column and also this isn't a proper join. This somewhat works for a single Symbol only. fr = pl.DataFrame( { 'Symbol': ['A']*5, 'Date': ['2010-08-29', '2010-09-01', '2010-09-05', '2010-11-30', '2010-12-02'], } ).with_columns(pl.col('Date').str.strptime(pl.Date, '%Y-%m-%d')).with_row_index().set_sorted("Date") events = pl.DataFrame( { 'Symbol': ['A']*3, 'Earnings_Date': ['2010-06-01', '2010-09-01', '2010-12-01'], 'Event': [1, 4, 7], } ).with_columns(pl.col('Earnings_Date').str.strptime(pl.Date, '%Y-%m-%d')).set_sorted("Earnings_Date") idx = fr["Date"].search_sorted(events["Earnings_Date"], "left") fr = fr.with_columns( pl.when( pl.col("index").is_in(idx) ) .then(True) .otherwise(False) .alias("Earnings") ) fr = fr.join_asof(events, by="Symbol", left_on="Date", right_on="Earnings_Date") fr = fr.with_columns( pl.when( pl.col("Earnings") == True ) .then(pl.col("Event")) .otherwise(False) .alias("Event") )
After searching documents and online sources, I have came to this conclusion that the `unmanaged` constraint differs from 'unmanaged resources.' unmanaged resources refer to resources that are not collected or managed by the garbage collector, while the `unmanaged` constraint in specifies that the type parameter of a generic type should be a non-nullable unmanaged type. Additionally, types with the 'unmanaged' constraint should not contain any reference type fields at any level of nesting. So applying the `unmanaged` constraint to a generic type parameter does not exclude instances of that generic type from being managed by the garbage collector. The unmanaged constraint only specifies certain characteristics that the type argument passed to the generic type parameter must satisfy.
I'm utilizing Nginx on CentOS with the Aapanel control panel. I have installed the latest Laravel 11 on my server, but when I attempt to access it, I encounter a 403 forbidden error. I've attempted various modifications in the .htaccess files, but none have been successful. I've searched extensively online but have yet to find any useful resources. My URL rewrite configurations are as follows: ``` location / { try_files $uri $uri/ /index.html index.php; } ```
Resolving 403 Forbidden error in a fresh Laravel 11 installation
|php|laravel|nginx|laravel-11|
try ssl port https://192.168.1.227:54321 then allow exception or firefox setting -> certificate manager servers -> servers add exception site
I have started making a 3D Tile based farming game in Godot (inspired from Homegrown). I managed to make the Random Terrain and Camera systems on my own but am now struggling to make the terrain editing thing. So the world is generated in tiles of primarily Grass, Farm and Pavement. Now I need a way to edit these tiles in the game by clicking on it. Although I have a logic in my mind, I am unable to implement it. I need the access the tile by clicking on it with a mouse (I am a super beginner). I am using this code to generate the world: ``` extends Node3D var world_tile_array = [] @export var world_size = 10 var space_between_tile = 1 var generate_modes = ["Grass", "Pave", "Farm"] func world_tile_array_generate(world_size): var soil_tiles = load("res://scenes/tiles.tscn") var tiles = [] for i in range(world_size): for j in range(world_size): var tile = soil_tiles.instantiate() tile.position.x = i tile.position.z = j tile.set_mode(generate_modes.pick_random()) tiles.append(tile) return tiles func world_generate(tiles): for i in tiles: $Tiles.add_child(i) func _ready(): world_tile_array = world_tile_array_generate(world_size) world_generate(world_tile_array) ``` In the comments is the logic which I came up with and the world which is generated. Please reference the video. How can I get a similar result?
How to edit tiles in a Godot game?
this error can happen for a number of reasons but one way or another what's happening is that your PHP can't find your database to connect, here's a few suggestions on how you can troubleshoot this issue. 1 - verify the database exists ------------------------------ make sure that you have created your database before trying to reference in your .env file, sometimes we can get ahead of ourselves and end up skipping steps. 2 - verify the name of your database ------------------------------------ most likely in your .env file you are giving the wrong reference to the database and that's why you won't be able to connect, check for typos and make sure that the name on your .env is EXACTLY the same name as your database, note that this is case-sensitve. these are the most common reasons to this type of error but if this doesn't help on your case please share a little more information, specially how you're trying to connect on the .env file of your laravel project.
Chrome/Firefox plug-in for automatically opening the dev tools and executing code in the console
|plugins|devtools|
null
Why when we call a function in 'onclick' in the html document, that function is not read in a JavaScript Module file if there is an 'import'? Is there a solution to use 'onclick' again in this case? For example, 'onclick' calls the following: `<input type="button" value="-" class="dark" onclick="mathfa('-')">` This function: ``` function mathfa(ma) { if (ma == "Percent") { varable.po = false; varable.eva = false; varable.per = true; if (varable.box.value.indexOf("^") == -1 && varable.box.value.indexOf("+") == -1 && varable.box.value.indexOf("-") == -1 && varable.box.value.indexOf("*") == -1 && varable.box.value.indexOf("/") == -1 && varable.box.value.indexOf("%") == -1) { varable.box.value += "%*"; } else { varable.box.value = varable.box2.value + "%*"; } } else if (ma == 'pow') { per = false; eva = false; po = true; if (varable.box.value.indexOf("^") == -1 && varable.box.value.indexOf("+") == -1 && varable.box.value.indexOf("-") == -1 && varable.box.value.indexOf("*") == -1 && varable.box.value.indexOf("/") == -1 && varable.box.value.indexOf("%") == -1) { varable.box.value += "^"; } else { varable.box.value = varable.box2.value + "^"; } } else { varable.po = false; varable.per = false; varable.eva = true; varable.box.value += ma; } } ``` In a JavaScript Module file: ` <script type="module" src="http://localhost:8080/scripts/script.js"></script> ` I even put this function in another file and imported it in the main JavaScript file, but it didn't work. In addition, I know that if I call that function by 'addeventlistener', it works, but as I mentioned, my problem is using 'onclick'.
Not reading the function in a JavaScript Module file, by calling onclick in the html document
|javascript|html|module|onclick|