Posts

Showing posts from July, 2023

Create web page using JavaScript with a different web address

I have created a custom element using JavaScript. This custom element has been added to my HTML page. When the user clicks on this element, the user should be directed to a new page. This page should be created dynamically using JavaScript. I understand how to create this page by clearing the current page and adding the new elements. However, I want to change the web address and redirect the user to a brand new page. I have created an Array of Objects. I want to write a single block of code and from this block, create a separate page for each object in the Array of Objects. For example: const myArray = [{object: "First Object",},{"Second Object"},{"Third Object"},{"Fourth Object"},{"Fifth Object"}]; const customElements = window.customElements; class MyElement extends HTMLElement { constructor() { super(); this.innerHTML = `<a href="page2.html">${myArray.object}</a>`; }} customElements....

ANTLR4 Python failed to install and cannot establish a connection

Hello I am trying to install the requirements of apache age python driver Whenever it comes to the installing of antlr4-python3-runtime it get struggling here: I install the packages through: pip3 install -r requirements.txt And it gets the following Collecting antlr4-python3-runtime==4.11.1 WARNING: Retrying (Retry(total=4, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f8ce27dfd90>: Failed to establish a new connection: [Errno 101] Network is unreachable')': /packages/e0/64/c548678120cccf784f555972ed37cedcf4f026abeec30ab0340c3af4ea07/antlr4-python3-runtime-4.11.1.tar.gz WARNING: Retrying (Retry(total=3, connect=None, read=None, redirect=None, status=None)) after connection broken by 'NewConnectionError('<pip._vendor.urllib3.connection.HTTPSConnection object at 0x7f8ce27df2e0>: Failed to establish a new connection: [Errno 101] N...

Tensorflow 2.0 model always predicting the same label

I am pretty new to ML and tensorflow, so I was working through the tutorials on tensorflow and copy/pasted one of their models with a custom training loop with a few modifications. Upon training it on the cifar10 dataset over 3 epochs, it achieved a 60 percent training acc and 54 percent validation acc. However, when I loaded it into another script to try and test it with images online, the logits had a nearly identical incorrect spread. 2 of the images tested were from online of a boat and airplane which looked similar to other cifar10 images while the other 2 were from the dataset itself, being a horse and boat. All produced nearly identical logits. What's really weird is that the logits always seem to peak at the fourth label (cat), no matter which model, architecture, or image I use. I've also tried switching optimizers to no avail. What am I missing (feedback regarding the problem itself or anything else about the code is greatly appreciated)? Model: import tensorflow as...

Display a stream from a server using QT

Image
So i have a project that consist of two systems an ESP32 with camera and a QT App. I built the ESP32 to stream a video on a server hosted on the ESP32 board. I want now to get this video stream and show it on a QT app but I could not find a way to show the video. I used a GraphicsView to display the video but it think this approach is false. So any suggestions on how to do that? Here is my code that I wrote to get the stream. I receive some data from the server but I could not display the streaming. #include "mainwindow.h" #include "ui_mainwindow.h" MainWindow::MainWindow(QWidget *parent):QMainWindow(parent), ui(new Ui::MainWindow) { ui->setupUi(this); // Create the QGraphicsScene and set it to the Graphics View scene = new QGraphicsScene(this); ui->VideoStreamer->setScene(scene); // Initialize the network manager networkManager = new QNetworkAccessManager(this); // Start the video streaming request QUrl videoUrl("...

How to read response data from a custom type of json in android studio

I have a group of classes in the API, and I want the results of the request to be semi-uniform, for example, I created a class that contains 3 fields as follows below : public class resultDataClass { public Boolean state { get;set; } public string message { get; set; } public object data { get; set; } //this field } The third field returns different data from all classes may be type op users class or department class or another class -- below show data json in my response type my be : { "state": true, "message": " data description", "data": [ { "id": 1, "UserName": "", "password": "", "email": "", "phone": "" }, { "id": 2, "UserName": "", "password"...

Need help! Facing issues with Open AI where I have overlapping of data

I have built a chatbot which can do a search on my data by creating an embedding solution. But if I have overlapping data then answers are not accurate. Is there any way that I can send a recommend/follow-up question back to the user through a chatbot to be more specific with the document? For example- The user query is “share scope of work”. I have 10 documents where I have scope of work then what should be in a prompt to send a recommendation to the user to be more specific with the vendor’s name to get the right answer.

How to get last non null values and aggregated non null values by timestamp from event sourcing JSONB column in PostgreSQL?

I'm working with event sourced data where all of the important fields are combined to a JSONB column and many of the keys are missing from most of the database rows. I would want to get: Aggregated combined values of included arrays in the JSONB field (see ingredients in the example) Latest non-null value according to timestamp I tried this on my own and I was able to produce a example which generates exactly what I would want to achieve here but it looks rather ugly and I'm wondering how to make following query better. Schema (PostgreSQL v15) CREATE TABLE events ( id SERIAL PRIMARY KEY, identifier VARCHAR(255), timestamp TIMESTAMP WITH TIME ZONE, event_data JSONB ); INSERT INTO events (identifier, timestamp, event_data) VALUES ('12345', '2019-01-01T00:00:00.000Z', '{"target": "99999999"}'), ('12345', '2019-01-01T12:00:00.000Z', '{"ingredients": ["Banana", "S...

How to check if one wildcard expression (AKA glob) contains another wildcard expression?

I have two wildcard expressions g1 and g2, and I would like to know whether g1 contains g2. For example: g1 = "*.txt" g2 = "hello*.txt" In this case g1 contains g2.

What are the modifications required on dts file to migrate from 5inch MIPI DSI display to 10.1 inch MIPI DSI display on imx8 board?

I am trying to bring up 10.1 inch mipi dsi display with compulab ucm-imx8mp board. The development board will work with default 5 inch mipi display. Now I wanted to change the display size to 10.1 inch. The 10.1 inch display has same pin configurations as 5 inch display. Please guide me on, what are the major changes I need to perform on my ucm-imx8m-plus.dts file to make this 10.1 inch display work? The below changes I have made so far, please review it and give your inputs. [10.1' display timing parameters][1] modified ucm-imx8m-plus.dts for 10.1' startek mipi display &mipi_dsi { status = "okay"; panel: panel@0 { compatible = "startek,kd101wxfid025"; reg = <0>; reset-gpio = <&pca9555 4 GPIO_ACTIVE_LOW>; dsi-lanes = <4>; status = "okay"; clock-frequency = <67000000>; hactive = <1280>; vactive = <800...

PyPi: twine missing METADATA, but it exists in .whl file

I was trying to upload an update to my package on PyPi but I noticed they have changed it so you have to use a pyproject.toml file. So I did follow steps on PyPi Created pyproject.toml Ran py -m build with no errors or warnings Ran twine check dist/* and both files passed Ran twine upload dist/* to upload, but got this error after the first file was uploaded: Wheel '***_Ashenguard-3.2.0-py3-none-any.whl' does not contain the required METADATA file: ***_ashenguard-3.2.0.dist-info/METADATA (*** = My package) Then I opened the .whl file (Changed its suffix to zip and opened it) and checked the files inside and I saw the METADATA file in the path specified... I tried searching but the only similar question I found was solved by adding the pyproject.toml

matMenuTrigger openMenu not showing the menu when called with *ngFor

Good evening, I have this component: HTML <button mat-menu-item #leagueMenuTrigger="matMenuTrigger" [matMenuTriggerFor]="leagueMenu" (mousedown)="onMouseDown(leagueMenuTrigger)"> </button> <mat-menu #leagueMenu="matMenu"> <button mat-menu-item> Club Home </button> <button mat-menu-item> Events </button> <button mat-menu-item> Player Roster </button> <button mat-menu-item> Results and Standings </button> <button mat-menu-item> Ledger </button> <button mat-menu-item> Club Settings </button> </mat-menu> TS import { OnInit, Component, Input, AfterViewInit } from '@angular/core'; import { MatMenuTrigger } from '@angular/material/menu'; import { Group } from 'src/app/objects/group'; @Component({ selector: 'wagl-league-menu', templateUrl: './league-menu.component.html', styleUrls: ['./...

Matrix visual result values not pulling for the data

I have three tables. Table 1 CheckNo No of Covers Table 2 Data Tabe with Check Id, Location Id, date Revenue Table 3 Liaction ID and Location name Table 1 is linked to Table 2 One to Many relationships on Checkl No Table 3 is liked to Table 2 one to many relationships on Location ID Trying to get a matrix visual with Location Name, Month, No of Covers and Sum of Revenue for each location. Tried the matrix with Location in Row , Month in Column and Sum of Revenue and Covers in Values The revenue is coming clean but on covers i am getting the total covers from Table 1 for each location for each month. I am a beginner, Any heal will be greatly appreciated. Hem

Trouble to MongoDB Single Node Replica Set in Docker Container

I am trying to run MongoDB in a Docker container and apply a Single Node Replica Set in an Oracle Cloud Ubuntu environment without using docker-compose. When I execute rs.initiate() in mongosh, members are automatically created with the container's ID (/etc/hosts). However, when trying to connect externally using Compass, I get the error message "getaddrinfo ENOTFOUND $CONTAINER_ID" and cannot establish a connection. I have tried changing the host information in rs.initiate() arguments to 'localhost', '127.0.0.1', and external IP, but none of them work. I have also tried changing Docker's ports, but the issue persists. Currently, only port 27017 is open in the cloud, and it functions properly. I am seeking assistance in identifying the problem. Just in case, I'm adding my options (nothing special) In Dockerfile mongod --bind_ip_all --replSet rs --port 27017 Container Execution docker run -d \ -p 27017:27017\ --name $NAME \ -v $VOLUM...

How to change the background color of TextEditor like TextField

Image
struct TextView: View { @State private var textInput2: String = "" var body: some View { ScrollView{ VStack(spacing: 24){ TextField("", text: $textInput2) .font(.body) .foregroundColor(.gray) .padding() .frame(height: 142) .background(Color("3")) .cornerRadius(20) .overlay( RoundedRectangle(cornerRadius: 20) .stroke(Color.gray.opacity(0.5), lineWidth: 2) ) TextEditor(text: $textInput2) .textFieldStyle(PlainTextFieldStyle()) .font(.body) .foregroundColor(.gray) .padding() .background(Color("3")) .frame(height: 142) .cornerRadi...

How to update Android UI on Firestore result?

I am trying to write a database query in Cloud Firestore in Kotlin. The request itself is working but I am having some problems with the async workflow. My goal is to make a database request that fetches a lot of data and puts this into an object. Once this is complete for all objects, the normal workflow of the app should continue. (because I need to display some of this data in my UI). My database structure: I have a collection of users -> Each user has a collection of their own recipes. -> In each recipe there is a collection of Steps to complete and a collection of ingredients My goal is to get the data and show it on my app screen (code below), but with my current code, the app starts the request and continues to show the app screen (which means there is no data loaded up to this point). Is there a way to make my database request more efficient (as I have 3 requests per recipe) and also to make it work async? So that when the data gets loaded the UI will recognize a cha...

Needed sample code for DAVE™ IDE to drive L9825 Driver IC with daisy chain connectivity

Image
Needed sample code for DAVE™ IDE to drive L9825 Driver IC with daisy chain connectivity, Outputs are not coming, unable to set register's bits of driver IC module. Anyone can help with sample code for DAVE IDE & XMC-4100 series MCU with L9825 Driver IC module. Thanks in advance

RegEx - Search for Word and Output Last Decimal Number on Line

I'm trying to use RegEx to parse the Total Hours working in a pay period from a PDF timesheet. For example: Total Overtime Hours: Total Hours: 2.2 1.0 1.0 3.5 5.0 12.7 Signature: (?<=Total Hours:*(?:.*?( )+){6}).* The Total Hours will always be the last number on the line that starts with "Total Hours:" The above RegEx code works for most employees who work 5 days a week but breaks if they work more or less than 5 days as in the example below: Total Overtime Hours: Total Hours: 2.2 1.0 1.0 3.5 5.0 6.3 19.0 Signature: regexr.com/7hci1 Any thoughts on the adjustments I can make to always grab the last decimal number of the row that starts with "Total Hours:"? Thanks!

Trouble with TTK Scrollbar

I'm working on building a GUI using ttk. One component involves dynamically adjusting the number of rows of Entry objects with a Scale / Spinbox. During the range of acceptable values, the number of fields exceeds the size of the window, so a scroll bar and canvas are used to accommodate. The issue arises with when the frame gets updated from one that had a scrollbar to another that has a scrollbar. In this version, no matter if there is a scrollbar/canvas or not, the entries are placed in an innerFrame within the entriesFrame . When the number of entries is updated, there was a scrollbar, and there still needs a scrollbar the scrolable region only ever shows 8 Entries. The current debug readouts are the objects in the innerFrame if there's a scrollbar after attempting to delete them all, the number of entries from the scale / spinbox, and the objects in the innerFrame if there's a scrollbar. from tkinter import Canvas, Tk, LEFT, BOTH, RIGHT, VERTICAL, X, Y, ALL, IntVar...

how to use send_message() in python-telegram-bot

i want to send a message to user, without waiting for user triggered my bot. using send_message(), i've been read the documentation but i'm not really understand. Here's my code from dotenv import load_dotenv from telegram.ext import * from telegram import InputFile, Bot import os import re command = ['start'] load_dotenv() tokenize = os.getenv("TELEGRAM_BOT_TOKEN") async def start_commmand(update, context): umsg = update.message await umsg.reply_text("Welcome, i'll help u with ur schedule") if __name__ == "__main__": application = Application.builder().token(tokenize).build() application.add_handler(CommandHandler(command[0], start_commmand)) # Run bot application.run_polling(1.0) i tried to send a message to bot user using send_mesage(), i hope it's send a message without waiting any message from user. because i'm not really understand after read the documentation, i don't know how to...

How to call MS Graph via sp_invoke_external_rest_endpoint with a large access token?

I'm using sp_invoke_external_rest_endpoint in T-SQL to call Microsoft Graph endpoints. This is one of the use cases that Microsoft advertises. The headers parameter of sp_invoke_external_rest_endpoint is an nvarchar(4000) so you are limited to 4000 characters. How do you call MS Graph when you have an access token that is larger than that? I've implemented sp_invoke_external_rest_endpoint in two different environments and in one of them the access token was short enough (around 3400 characters) to fit but in the other it's over 4000 characters.

Guice and MVP pattern: decouple the view from the presenter

I'm writing an application in Swing and I'd like to make use of Model–view–presenter pattern. I found a sample application using this pattern and alter it to use Guice. I was able to make it work with albeit with one problematic piece of code. Let me first show my code and later on the piece I find problematic. Application starting point : @RequiredArgsConstructor(onConstructor = @__(@Inject)) public class Main { private final View view; public static void main(final String[] args) { final Main main = Guice.createInjector().getInstance(Main.class); SwingUtilities.invokeLater(main.view::createUI); } } Model : public class Model { public String getPassword() { return "password"; } } Presenter : @RequiredArgsConstructor(onConstructor = @__(@Inject)) public class Presenter { private final View view; private final Model model; public void login(final String password) { final String result = model...

Python Function - Drawing a Triangle with a python fucntion

I've create the following program to draw two triangles in Python 3, one half the size of the other with the robot driving away with pen down. This is all good and have the solution in place Working solution However I'm obsessed in making my code shorter using a python function. Guidance notes I have added an optional variable in like the content advises: additional variable This so I can draw add an argument against the function whenever I call the function to make different sizes of the triangle easily. Can you see where I'm going wrong here? Call the function but add an argument against another variable (SIDE_LENGTH) to make smaller or larger versions of the shape

4000% Performance Decrease in SYCL when using Unified Shared Memory instead of Device Memory

In SYCL, there are three types of memory: host memory, device memory, and Unified Shared Memory (USM). For host and device memory, data exchange requires explicit copying. Meanwhile, data movement from and to USM is automatically managed by the SYCL runtime implicitly. Unfortunately, during the process of implementing GPU acceleration for a numerical kernel using SYCL, I found an up-to 4000% decrease of performance just by switching from sycl::malloc_device() to sycl::malloc_shared() - even if all I do is repeatedly resubmitting the same SYCL kernel, without any attempt to access data from the host. When building the code with sycl::malloc_device() with OpenSYCL targeting AMD HIP GFX906 (Radeon VII / Instinct MI50), the program finishes in 0.27 seconds: $ time ./fdtd.elf simulate 16974593 cells for 10 timesteps. real 0m0.271s user 0m0.253s sys 0m0.020s When building the same code with sycl::malloc_shared() , the program takes 10.6 seconds to complete: simulate 16974...

How to use agda almost without data, only with postulates?

module sets where postulate 𝕊 : Set _∈_ : 𝕊 → 𝕊 → Set infix 50 _∈_ data _and_ : Set → Set → Set where _∧_ : (x y : Set) → x and y infixl 40 _and_ infixl 40 _∧_ data _≡_ : Set → Set → Set where _eq_ : (a b : Set) → a → b and b → a → a ≡ b infixr 30 _≡_ infixr 30 _eq_ postulate _==_ : 𝕊 → 𝕊 → Set ==-def : (x y z : 𝕊) → ((z ∈ x ≡ z ∈ y) ≡ x == y) infixr 50 _==_ postulate eq_ax : (x y : 𝕊) → (x == y) → (z : 𝕊) → (x ∈ z ≡ y ∈ z) ∃ : (x : Set) → (z : x → Set) → Set ∃-def : (x : Set) → (y : x) → (z : x → Set) → (z y ≡ ∃ x z) pair_ax : (x y : 𝕊) → ∃ 𝕊 λ { z → x ∈ z and y ∈ z } ∪ : 𝕊 → 𝕊 ∪_def : (x y : 𝕊) → x ∈ ∪ y ≡ ∃ 𝕊 λ { z → x ∈ z and z ∈ y } _⊆_ : 𝕊 → 𝕊 → Set ⊆-def : (x y : 𝕊) → ((z : 𝕊) → z ∈ x → z ∈ y) ≡ x ⊆ y infixl 50 _⊆_ first-proof : (x y : 𝕊) → x ⊆ y → (∪ x) ⊆ (∪ y) first-proof x y z = {!!} I am new to Agda. I try to find something that can verify my evidence. And so far Agda seems to be the best opti...

Fixed Total Row When Sorting DataGridview

Image
I have DATAGRIDVIEW CALLED ADVANCEDDATAGRIDVIEW see this link https://www.nuget.org/packages/DG.AdvancedDataGridView okay ? now I Filled this DGV FROM DATATABLE Here the First Code : DT is A DATATABLE already has data With Form1.AdvancedDataGridView1 .DataSource = DT Form1.BindingSource1.DataSource = .DataSource : Endwith So now this DGV HAS DATA FROM DT And I added BindingSource FROM TOOLBOX into Form1 And i Filled it From DATAGRIDVIEW.DataSource The AdvancedDataGridview has already Filters Icons Like excel in Microsoft Office But to make it Work You have to Write this Code in FilteringChange Event like this Private Sub AdvancedDataGridView1_FilterStringChanged(sender As Object, e As EventArgs) Handles AdvancedDataGridView1.FilterStringChanged BindingSource1.Filter = AdvancedDataGridView1.FilterString : End SUB So now Added row in DT as like DT.rows.add() like this so this ROW i Filled it By sum Of columns ok.. Now look at the ...

Restrict overlay in android

How can I restrict any app to draw it's overlay on our app canDrawOverlays or TYPE_SYSTEM_OVERLAY || TYPE_SYSTEM_OVERLAY How can I disable any app that hacks I have a trivia quiz app . Some developers make app that uses OCR to read question from my app and give results Developer implement a Service that allows them to write overlay on our app like this I want to restrict this service or stop it from taking picture using OCR through our app.

Plot equation / clustering of a plot

Image
Is there any way to get the function or to get only the points in the top of the plot? Consider that the x variable is time (date, seconds) or samples/minute and that the amplitude of the "oscillation" is not fixed. Consider also that the period is not constant. I was wondering if there is a built-in function in numpy/matplotlib/pandas libraries. Currently I am finding a math equation that could make it work.

PHP and PHPUnit: How to invoke method (or function) with wrong parameter type and then to success?

I want to test (with PHPUnit) a method that contains a foreach loop. I want the full path coverage. The original code is little too complex, so I created a minimal example below to illustrate my problem. There are 3 cases for the foreach loop in the PHP. (I use PHP 8.2.) Empty iterable something. Not empty iterable something. Not iterable something. public function dodo(array $a) { foreach ($a as $one) { return $one; } return null; } It is easy to cover first two: a not empty array and an empty array. But how can I pass a not iterable something as the function argument? I have tried few ways, but I’ve got the TypeError. $something->dodo(null); # TypeError call_user_func([$something, 'dodo'], null); # TypeError $rClass = new ReflectionClass($something); $rMethod = $rClass->getMethod('dodo'); $rMethod->invoke($something, null); # TypeError I don’t want to remove or change the type from the method defini...

How to know if the mouse is on a image in SDL2?

What I need : I want that when the mouse is on my image, something happen. You know like in HTML, when your mouse is on a link, HTML know it and what happen is that the cursor change to pointer. But unfortunatly, I already know that it is not to easy like in HTML and it is why I am asking you this question. What I am expecting: I am expecting that when the user of my game put is mouse on my button, the function that draw the button, will check if the mouse is on the button and if it is clicked like this: void draw(SDL_Rect infoImage, SDL_Renderer* renderer) { bool isHover = 0, isClicked = 0; //This if is for the hover, or in other word, to see if the mouse is on my image if(/*I need this condition*/){ isHover = 1; //To see if the image is clicked int x, y; if(SDL_MOUSEBUTTONDOWN && SDL_BUTTON(SDL_GetMouseState(&x, &y)) == SDL_BUTTON_LEFT){ isClicked = 1; } } //To draw the image S...

how to use git diff --name-only with non ascii file names

I have a pre-commit hook that runs files=`git diff --cached --name-only --diff-filter=ACMR | grep -E "$extension_regex"` and performs some formatting on those files before committing. However, I have some files that contain non-ascii letters, and realized those files weren't being formatted. After some debugging, found that it was because git diff outputted those file names with escaped characters and surrounded with double quotes, for example: "\341\203\236\341\203\220\341\203\240\341\203\220\341\203\233\341\203\224\341\203\242\341\203\240\341\203\224\341\203\221\341\203\230.ext" I tried to modify the regex pattern to accept names surrounded with quotes, and even tried removing those quotes, but anywhere I try to access the file it can't be found, for example: $ cat $file cat: '"\341\203\236\341\203\220\341\203\240\341\203\220\341\203\233\341\203\224\341\203\242\341\203\240\341\203\224\341\203\221\341\203\230.ext"': No such file or ...

extract a dictionary from a string with keys in brace brackets

Is there a way in python to extract a dictionary from a string which includes brace brackets, having the keys of the dictionary referencing the words in the brace brackets? as an example: 'my name is {name}' the method would return the following dictionary: {'name':{}} This would be to later use the dictionary and populate the string through parameters using .format() 'my name is {name}'.format(**{'name':'salomon'}) The all objective is to read a text file, put brace brackets around words I'd like to transform in parameters, load the text file and extract a dictionary where I can input the desired values to then reinject in the text. Thank you,

Search through the entire columns in datatable

I've tried several times but it seems like there is an issue with the code, I have a table and I've applied Datatable plugin by using Server Side processing, when I search through the entire table there is no problem except the idCustomer column, for example if I search for a name which is David, there is no result but if I search the id of David for example 10 there is no problem, It seems like the problem is with the idCustomer column from the below code since idCustomer is used as a value in order to retrieve the name of customers through another table, So I want also to be able to search through their names. Here is my serverside processing code: <?php include "../views/lang/config.php"; require_once "../controllers/customers.controller.php"; require_once "../models/customers.model.php"; // DB table to use $table = 'sales'; // Table's primary key $primaryKey = 'id'; $condition = "paymentMethod <> ...

Error in prettyNum(.Internal(format(x, trim, digits, nsmall, width, 3L, : invalid 'nsmall' argument

When I run the negative binomial model with the function below, I get the above error code when I try to the following code. model<- glm.nb(upvotes ~ Answer_Rate + Score + offset(log(patient_days)) + factor(Post_ID) - 1, control = glm.control(maxit = 500), data = na.omit(mock_data)) summary(model) # Create the dataframe with NA values df <- data.frame( Post_ID = c(3, 4, 5, 6, 7, 8, 9, 10, 11, 12, 13, 14, 15, 16, 17, 18), Creation_Year = c(2002, 2003, 2004, 2005, 2008, 2009, 2012, 2013, 2015, 2016, 2021, 2022, 2023, 2027, 2030, 2037), Last_Activity_Year = c(rep(2022, 16)), Views = c(3868, 2390, 1727, 5456, 2667, 2623, 1084, 2963, 5228, 1833, 1945, 2038, 3856, 3170, 5626, 2058), Upvotes = c(364, 654, 151, 246, 341, 82, 0, 270, 569, 184, 291, 265, 366, 439, 628, 293), Downvotes = c(63, 40, 54, 44, 90, 75, 36, 105, 157, 55, 79, 79, 93, 119, 103, 94), Answer_Count = c(66, 41, 34, 27, 24, 11, 22, 35, 85, 19, 49, 108, 63, 99, 70, 74), Score = c(42064, 24958, 18124, 3...

Grails how to change a metaclass Method

I'm trying to remove the square brackets that appear in toString off all collections in Grails. These square brackets are added in the toString of the java.util.AbstractCollection class. So the goal is to replace this toString method and I'm trying to use the ExpandoMetaClass. I tried to use this code in the Bootstrap file: def init = { servletContext -> ExpandoMetaClass.enableGlobally() AbstractCollection.metaClass.toString << {-> "Test result" } } But the error occurs: Caused by: groovy.lang.GroovyRuntimeException: Cannot add new method [toString] for arguments [[]]. It already exists! I also tried with the = operator instead of <<. The error does not occur but it has no effect. Does anybody know how to solve this?

Using a cached property on a named tuple

from typing import NamedTuple from functools import cached_property class Rectangle(NamedTuple): x: int y: int @cached_property def area(self): return self.x * self.y I thought this class definition would complain something about the __slots__ on Rectangle, but apparently the class definition is valid. It doesn't fail until too late, if/when the getter is actually accessed: >>> rect = Rectangle(2, 3) >>> rect.area ... TypeError: Cannot use cached_property instance without calling __set_name__ on it. >>> Rectangle. Well, that's weird, but okay.. >>> Rectangle.area.__set_name__(Rectangle, "area") >>> rect.area ... TypeError: No '__dict__' attribute on 'Rectangle' instance to cache 'area' property. Is there a better recipe for cached properties on named tuples? Requirements: It should not appear to be a real field ( x, y, area = rect should not be possible) It should ...

How to sort table data in Angular reactive forms

I am trying to sort table data using an example from StackBlitz . I am not getting any errors in my code or console. However, the table itself is not doing any sorting at all. HTML <thead class="bg-info white"> <tr> <th scope="col" sortable="grade.ccode" (sort)="onSort($event)"> Code <i class="la la-sort float-md-end"></i> </th> <th scope="col" sortable="gradescription" (sort)="onSort($event)"> Description <i class="la la-sort float-md-end"></i> </th> <th>Delete Grade</th> </tr> </thead> <tr *ngFor="let grade of paginationService.paginatedData| gradeSort:filter" (dblclick)="openUpdateModal(editGradeModal, grade)" > <!-- <tr *ngFor="let grade of paginationService.paginatedData...

Add a gradient background line to the circle

Image
I have a block on the page where there is a background line, on the line itself there is a circle that scrolls along with the main scroll The question is, how can you make it so that, along with the circle, another line of the same color as the circle scrolls along the line, and it all would look something like this: I tried adding styles to before, but it didn't work out what I expected left: 50%; transform: translate(-50%, -50%); width: 3px; height: 40vh; background: #4f8eff; box-shadow: inset 0 20vh 10vh -10vh #f6e75e, inset 0 -20vh 10vh -10vh #f6e75e; z-index: 2; Everything should be like in the picture that I threw off, the circle should be white inside, and the blue color should completely overlap the yellow when we scrolled to the very top, and the same from the bottom. And in the center of the block, let's say the blue color should be both above the circle and below, while maintaining the gradient const circle = document.querySelector(".circle"); const...

How do I set a different font style than what is offered in the FontStyle enum?

I am creating PDF documents using SelectPdf. One of these documents needs to use a client-provided font. The font family in question is Azo Sans, and it contains several different flavors of font such as bold, italic, regular, etc. It also contains styles like "thin". I need to use this thin style, coupled with italics, in my document. How can I use a style that is not offered in the FontStyle enum? I declare my font as such var font = new Font(font: "Azo Sans", fontSize: 12, fontStyle: FontStyle.Italic | FontStyle.WhatStyleIsUsedHere?); This works for standard styles like bold, underline, etc. How can I combine Italics with the Thin style offered by the Azo Sans font?

SQL Server How to count consecutive fields across a row with a start point?

I have a table that for headers has account number, 2022 gift, 2021 gift, 2020 gift, 2019 gift, etc. through to 2004 gift (example below only shows a few columns for visual). I am looking for code that will count how many consecutive years the donor gave a gift starting with the 2022 gift column and going back from there. So for instance if they gave a gift every year between 2022 and 2016 it should set the count equal to 7. If they didn't give a gift in 2022 (regardless of giving in other years), it would return 0. If they gave a gift in 2022, 2021, 2020 and then skipped 2019 but had given in 2018, it would return 3. Sometimes a field without a gift will be null but other times it will be '0' (both of which would be considered a gap; in case that information is helpful). Any help would be greatly appreciated. Thanks in advance! Table Example Acct # 2022 Gift 2021 Gift 2020 Gift 2019 Gift 2018 Gift 2017 Gift 2016 Gift Count 546885 200 12 74 956 23 ...

Trying to filter an array of strings to return a single field which is a subset of the array with strings that contain a variable

The DB has items, and these items have a string parameter which is a comma separated string array. Im trying to pass in a search variable, and use that to return the item node, and the string array but with only the strings that match the search variable match (n:Node) return n.string returns the strings sorted by the item node as ["abc,def,abcde"] match (n:Node) where any(string in n.string where string contains "abc") return n This gets me the nodes where one of the strings contains what I'm looking for, but I can't seem to find a way to get the ones which matched and return them as a field So if a node has a string of ["abc","def","abcde"] then when I search for strings containing "bc" then it should get the node and return just the strings of ["abc","abcde"]

How to limit elevation over distance using the A search algorithm?

My application finds or constructs routes that are shortest for trekkers in a hilly/mountain terrain using the A* search algorithm. Input files are .dem (Digital Elevation Model) and a roadmap file that contains existing routes. Code is in Python, libraries used are pygdal, NumPy and PyQGIS. The routes provided by the algorithm are very steep. I want my route to follow the gradient guidelines, like say for every 30m only 1m of elevation. If I could put my objective in a more simpler way, then it is that using A* I can find the shortest route, but the problem with that it finds path from one peak of the mountain to the valley in a straight line, which is not practical. I want the output should descent from one contour line to another at less that a particular angle so that the descent is not so steep. In this case the recommended gradient descent is 1.91 degrees.

Run-time error 424 "object required" on line with ThisComponent

Image
I got a macro code from the Internet for Microsoft Word 2021 software, and when I implement it in Microsoft Word, I get an error! Does anyone know where the problem comes from? ERROR: Here's the error message: And it cccurs on the following line: CODE: Sub ChangeTashkeelColors() CrRepDesc = ThisComponent.createReplaceDescriptor CrRepDesc.searchRegularExpression = True CrRepDesc.searchString = "?" ' Unicode Character 'ARABIC FATHA' (U+064E) or Shift+q on the Arabic keyboard FnAllRepDesc = ThisComponent.findAll(CrRepDesc) For i = 0 To FnAllRepDesc.Count - 1 FoundTxt = FnAllRepDesc.getByIndex(i) FoundTxt.CharColor = 1400606 ' Dark Green Color Next i CrRepDesc = ThisComponent.createReplaceDescriptor CrRepDesc.searchRegularExpression = True CrRepDesc.searchString = "?" ' Unicode Character 'ARABIC FATHATAN' (U+064B) or Shift+w on the Arabic keyboard FnAllRepDesc = ThisComponent.findAll(CrRepDesc) For i = 0 To Fn...

Is there a way to conditionally change the background and text color for a cell in Excel/Google Sheets without using many unique conditional rules?

I'm currently creating a spreadsheet for a card collection, and I want the rows to have their background changed based on what element the card is, I also want the text color to change based on its rarity. I've so far changed the background of the row with a conditional formatting rule (=$I2="Element") for each element, but when I add another condition to change the text color based on rarity for the same cells, only one of the two can be applied at once. Idealy I'd like to have the Element types and Rarities in a table which have an associated background/text color associated with them, and look at that table when I apply the formatting, but I don't know if that's possible, or how to do it if it is. Currently making a rule for every combination would need me to make 40 conditional formatting rules, and wouldn't easily let me change colors/add new elements. I'd rather avoid that if possible. I'm currently using Google Sheets, but I do have acc...

setMinimal equivalent in QRegularExpression

I am porting some Qt5 code to Qt6, which requires switching QRegExp to QRegularExpression . The Qt5 code uses the setMinimal(bool minimal) method of QRegExp. Is there an equivalent PatternOption in Qt6? I see a QRegularExpression::InvertedGreedinessOption PatternOption, but I don't really understand if this is equivalent.

Sort List of List in Python based on days of the week

I have a list of daily temperature, shown below: weekly_temperature = [['Saturday', 100], ['Wednesday', 95], ['Friday', 80], ['Monday', 95], ['Sunday', 90], ['Tuesday', 100], ['Thursday', 85]] How do I sort this list based on days of the week, starting from Monday to Sunday? I would like the sorted output to look like below: weekly_temperature = [['Monday', 95], ['Tuesday', 100], ['Wednesday', 95], ['Thursday', 85], ['Friday', 80], ['Saturday', 100], ['Sunday', 90]]

How to use a trained yolov8 object box detection model directly in tensorflow js in pure javascript? [closed]

I'm currently trying to use a trained yolov8 object box detection model (for 13 ish classes) from ultralytics, directly in tensorflow js in pure javascript. I don't want to use roboflow js, onnx etc for running it ; or any framework like node-js implementation etc to serve it.. I want to have a fully working yolov8n model detecting custom objects in images/videos/webcam direclty on browser using only tensorflow js. In the purpose of having something quite usefull (more than 10fps in webcam), i know that i have to use a quantized model for it. So my second question : What's also the code needed to use a custom yolov8n quantized model ? I looked pretty much at hundreds of links, topics etc on the subject but i haven't found any for this particular use case. I'm also open to someone that has the full solution for an ssd-mobilenet custom training/deploying solution in pure tensorflow js for object detection with boxes. You would be very nice and serving a lot of peo...