qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,230,626 | <p>Im fairly new to knockout and we have a an observable object like this</p>
<p><code>this.deeplinkPopupModule = ko.observable({ view: [], viewModel: null });</code></p>
<p>I want to trigger a function whenever view or viewModel is changed or updated.</p>
<p>I have tried doing this, but this doesn't work, I have tried some other methods as well but those don't get triggered.</p>
<pre><code> this.deeplinkPopupModule.subscribe(function(newVal){
console.log("inside module subscribe");
if(this.deeplinkPopupModule.view.length==0)
this. addNewOpened(false);
});
</code></pre>
<p>I cant use any plugins and I have also tried <strong>sroes</strong> answer here <a href="https://stackoverflow.com/questions/27018684/knockout-subscribe-to-any-change-in-observable-complex-object">Knockout Subscribe to any change in observable complex object</a>, but it was never triggerred
Please let me know if I should include any more information on this and thank you for your help.</p>
| [
{
"answer_id": 74230657,
"author": "Amit Singh",
"author_id": 13051247,
"author_profile": "https://Stackoverflow.com/users/13051247",
"pm_score": 1,
"selected": false,
"text": " Row(\n children:[\n \n status==\"approved\"?Icon(Icons.approve)\n \n :status... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20354778/"
] |
74,230,639 | <pre class="lang-html prettyprint-override"><code><script setup lang="ts">
const props = defineProps({
px: {
type: String,
required: false,
},
bg: {
type: String,
default: 'transparent',
},
rounded: {
type: String,
default: 'none',
}
})
const classes = []
for (const [key, value] of Object.entries(props)) {
(value !== undefined) && classes.push(`${key}-${value}`)
}
</script>
<template>
<div :class="classes" class="overflow-hidden">
<slot></slot>
</div>
</template>
</code></pre>
<p>Because the props is reactive, so I think the DOM will finish rendering before script's process.
How can I let the component wait for script's process? Thanks.</p>
<p><a href="https://i.stack.imgur.com/KX753.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KX753.png" alt="enter image description here" /></a></p>
<p>the classed has been added but it's reactive so they don't effect...</p>
| [
{
"answer_id": 74230657,
"author": "Amit Singh",
"author_id": 13051247,
"author_profile": "https://Stackoverflow.com/users/13051247",
"pm_score": 1,
"selected": false,
"text": " Row(\n children:[\n \n status==\"approved\"?Icon(Icons.approve)\n \n :status... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19664827/"
] |
74,230,683 | <p>For documentation purposes I am trying to execute a shell script in a way that it looks as you typed it by hand in an interactive shell.</p>
<p>Script:</p>
<pre><code>x=123
echo $x
</code></pre>
<p>Then execute:</p>
<pre><code>PS4="$PS1"
set -x -v
. ./demo
</code></pre>
<p>Output:</p>
<pre><code>. ./demo
user@host:~/tmp$ . ./demo
x=123
user@host:~/tmp$ x=123
echo $x
user@host:~/tmp$ echo 123
123
</code></pre>
<p>Desired output:</p>
<pre><code>user@host:~/tmp$ x=123
user@host:~/tmp$ echo $x
123
</code></pre>
<p>It does not have to be bash. Any solution that simulates an interactive session is welcome.</p>
<p>How can I achieve the desired result?</p>
| [
{
"answer_id": 74250010,
"author": "Pinke Helga",
"author_id": 3741589,
"author_profile": "https://Stackoverflow.com/users/3741589",
"pm_score": 1,
"selected": true,
"text": "bash -i </path/to/script-file\n"
},
{
"answer_id": 74250040,
"author": "William Pursell",
"author... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230683",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3741589/"
] |
74,230,704 | <p>Given a table like the following</p>
<pre><code>elems
['a', 'b', 'c', 'd', 'e']
['v', 'w', 'x', 'y']
</code></pre>
<p>I'd like to transform it into something like this:</p>
<pre><code>tuple
['a', 'b', 'c']
['b', 'c', 'd']
['c', 'd', 'e']
['v', 'w', 'x']
['w', 'x', 'y']
</code></pre>
<p>I.e., I'd like to get all overlapping 3-tuples.</p>
<p>My current attempt looks as follows:</p>
<pre class="lang-sql prettyprint-override"><code>WITH foo AS (
SELECT ['a', 'b', 'c', 'd', 'e'] AS elems UNION ALL
SELECT ['v', 'w', 'x', 'y']),
single AS (
SELECT * FROM
foo,
UNNEST(elems) elem
),
tuples AS (
SELECT ARRAY_AGG(elem) OVER (ROWS BETWEEN 2 PRECEDING AND 0 FOLLOWING) AS tuple
FROM single
)
SELECT * FROM tuples
WHERE ARRAY_LENGTH(tuple) >= 3
</code></pre>
<p>But the problem is, it returns some unwanted rows too, i.e., the ones that are "between" the original rows from the <code>foo</code> table.</p>
<pre><code>tuple
['a', 'b', 'c']
['b', 'c', 'd']
['c', 'd', 'e']
['d', 'e', 'v'] <--- unwanted
['e', 'v', 'w'] <--- unwanted
['v', 'w', 'x']
['w', 'x', 'y']
</code></pre>
<p>Also, is it guaranteed, that the order of rows in <code>single</code> is correct, or does it only work in my minimal example by chance, because of the low cardinality? (I guess there may be a simple solution without this step in between.)</p>
| [
{
"answer_id": 74230760,
"author": "Mikhail Berlyant",
"author_id": 5221944,
"author_profile": "https://Stackoverflow.com/users/5221944",
"pm_score": 3,
"selected": true,
"text": "select [elems[offset(index - 1)], elems[offset(index)], elems[offset(index + 1)]] as tuple\nfrom your_table,... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1866775/"
] |
74,230,711 | <p>I am getting below error from next js app suddenly. Any solution to fix that problem?</p>
<pre><code>./pages/_app.tsx
Error: [BABEL] C:\Projects\skribeNew\app-web\pages\_app.tsx: You gave us a visitor for the node type TSSatisfiesExpression but it's not a valid type
at verify (C:\Projects\skribeNew\app-web\node_modules\next\dist\compiled\babel\bundle.js:1910:397612)
at Function.explode (C:\Projects\skribeNew\app-web\node_modules\next\dist\compiled\babel\bundle.js:1910:396515)
at C:\Projects\skribeNew\app-web\node_modules\next\dist\compiled\babel\bundle.js:1:49254
at Generator.next (<anonymous>)
at Function.<anonymous> (C:\Projects\skribeNew\app-web\node_modules\next\dist\compiled\babel\bundle.js:1:79767)
at Generator.next (<anonymous>)
at evaluateSync (C:\Projects\skribeNew\app-web\node_modules\next\dist\compiled\babel\bundle.js:1910:717268)
at Function.sync (C:\Projects\skribeNew\app-web\node_modules\next\dist\compiled\babel\bundle.js:1910:715284)
at sync (C:\Projects\skribeNew\app-web\node_modules\next\dist\compiled\babel\bundle.js:1:80263)
at sync (C:\Projects\skribeNew\app-web\node_modules\next\dist\compiled\babel\bundle.js:1910:716601)
</code></pre>
<p>I changed the babel types version to previous one, But it did not work.</p>
| [
{
"answer_id": 74231028,
"author": "Finnalandem",
"author_id": 19650619,
"author_profile": "https://Stackoverflow.com/users/19650619",
"pm_score": 0,
"selected": false,
"text": "npm install -g yarn"
},
{
"answer_id": 74236587,
"author": "Md. Nizam Uddin Mahmud",
"author_i... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7084355/"
] |
74,230,719 | <p>I want to create only one object for the same users.</p>
<pre><code>class MyModel(models.Model):
user1 = models.ForeignKey(settings.AUTH_USER_MODEL,...)
user2 = models.ForeignKey(settings.AUTH_USER_MODEL,...)
class Meta:
constraints = [
UniqueConstraint(
fields=['user1', 'user2'],
name='user_unique',
),
# UniqueConstraint(
# fields=['user2', 'user1'],
# name='user_unique2',
# ),
]
</code></pre>
<p>I can solve the problem in another way, I just want to know how to do it with <code>UniqueConstraint</code>.</p>
<p>Adding another UniqueConstraint and moving the fields didn't solve the problem.</p>
<p>For example, for users X and Y, I only need one object.</p>
| [
{
"answer_id": 74230764,
"author": "Willem Van Onsem",
"author_id": 67579,
"author_profile": "https://Stackoverflow.com/users/67579",
"pm_score": 2,
"selected": false,
"text": "user1_id"
},
{
"answer_id": 74230839,
"author": "ilyasbbu",
"author_id": 16475089,
"author_... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10149535/"
] |
74,230,745 | <p>This question is more about my understanding Powershell's objects rather than solving this practical example. I know there are other ways of separating out a page number from a string.</p>
<p>In my example I want to do this by accessing the object-match-value of the piped pattern match.</p>
<pre><code># data
$headerString = 'BARTLETT-BEDGGOOD__PAGE_5 BEECH-BEST__PAGE_6'
# require the number of page only
$regexPageNum = '([0-9]$)'
# split the header string into two separate strings to access page numbers
[string[]]$pages = $null
$pages = $headerString -split ' '
# access page numbers using regex pattern
$pages[0] | Select-String -AllMatches -Pattern $regexPageNum | Select-Object {$_.Matches.Value}
</code></pre>
<p>The output is:</p>
<pre><code>$_.Matches.Value
----------------
5
</code></pre>
<p>Okay. So far so good. I see the page number of array member <code>pages[0]</code> But how do I take this value from the object? The following does not work.</p>
<pre><code>$x = $pages[0] | Select-String -AllMatches -Pattern $regexPageNum | Select-Object {$_.Matches.Value}
Write-Host "Here it is:"$x
</code></pre>
<p>Output:</p>
<pre><code>Here it is: @{$_.Matches.Value=5}
</code></pre>
<p>Instead of assigning the value <code>5</code> to the variable <code>$x</code> Powershell assigns, what looks to me: a hash table with an object description as its only member?</p>
<p>But if I try to access my variable using "Brackets for Access" Reference: <a href="https://learn.microsoft.com/en-us/powershell/scripting/learn/deep-dives/everything-about-hashtable?view=powershell-7.2" rel="nofollow noreferrer">hashtables</a> Powershell indicates that variable $x is in fact an array.</p>
<pre><code>x = $pages[0] | Select-String -AllMatches -Pattern $regexPageNum | Select-Object {$_.Matches.Value}
Write-Host "Here it is:"$x
$y = $x[$_.Matches.Value]
Write-Host "What about now:"$y
</code></pre>
<p>Output:</p>
<pre><code>Here it is: @{$_.Matches.Value=5}
InvalidOperation:
Line |
33 | $y = $x[$_.Matches.Value]
| ~~~~~~~~~~~~~~~~~~~~~~~~~
| Index operation failed; the array index evaluated to null.
What about now:
</code></pre>
<p>Okay. At this stage I know I'm being silly. But the point I'm trying to make is: How can I retrieve the value I want when I'm done with the Powershell object?</p>
| [
{
"answer_id": 74230764,
"author": "Willem Van Onsem",
"author_id": 67579,
"author_profile": "https://Stackoverflow.com/users/67579",
"pm_score": 2,
"selected": false,
"text": "user1_id"
},
{
"answer_id": 74230839,
"author": "ilyasbbu",
"author_id": 16475089,
"author_... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15542245/"
] |
74,230,765 | <p>I want to make a work env by Dockerfile From ArchLinux</p>
<p>docker build -t xiaoduoge/workenv .</p>
<pre><code>RUN yes | pacman --sync --refresh
RUN yes | pacman --sync --needed archlinux-keyring
RUN yes | pacman-key --init
RUN yes | pacman -Syyu
</code></pre>
<p>but have the following error</p>
<p>:: Import PGP key 139B09DA5BF0D338, "David Runge dvzrv@archlinux.org"? [Y/n] y
checking package integrity...
error: expat: key "991F6E3F0765CF6295888586139B09DA5BF0D338" is unknown
:: Import PGP key 991F6E3F0765CF6295888586139B09DA5BF0D338? [Y/n] y
:: File /var/cache/pacman/pkg/expat-2.5.0-1-x86_64.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] y
:: File /var/cache/pacman/pkg/pambase-20221020-1-any.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] y
:: File /var/cache/pacman/pkg/libcap-2.66-1-x86_64.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] y
:: File /var/cache/pacman/pkg/gnupg-2.2.40-1-x86_64.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] y
:: File /var/cache/pacman/pkg/shadow-4.11.1-3-x86_64.pkg.tar.zst is corrupted (invalid or corrupted package (PGP signature)).
Do you want to delete it? [Y/n] y
error: failed to commit transaction (invalid or corrupted package)
Errors occurred, no packages were upgraded.
The command '/bin/sh -c yes | pacman -Syyu' returned a non-zero code: 1</p>
<p>so what should I do to solve the problems?</p>
| [
{
"answer_id": 74230764,
"author": "Willem Van Onsem",
"author_id": 67579,
"author_profile": "https://Stackoverflow.com/users/67579",
"pm_score": 2,
"selected": false,
"text": "user1_id"
},
{
"answer_id": 74230839,
"author": "ilyasbbu",
"author_id": 16475089,
"author_... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19268307/"
] |
74,230,768 | <p>I have to write a program that reads a file containing set of 16 numbers and creates a magic square. A magic square is one where the sum of each row, column, and diagonal is the same. I have to use the sentinel method to control your loop. The sentinel value is -999. When I run the code it shows that all are not magic square. When I run it it looks like the following.</p>
<p>1 2 3 4</p>
<p>5 6 7 8</p>
<p>9 10 11 12</p>
<p>13 14 15 16</p>
<p>NOT a magic square</p>
<p>1 15 14 4</p>
<p>12 6 7 9</p>
<p>8 10 11 5</p>
<p>13 3 2 16</p>
<p>NOT a magic square</p>
<p>30 8 20 11</p>
<p>3 10 21 35</p>
<p>24 25 13 7</p>
<p>12 26 15 16</p>
<p>NOT a magic square</p>
<p>14 8 19 92</p>
<p>37 53 16 27</p>
<p>67 10 54 2</p>
<p>15 62 44 12</p>
<p>NOT a magic square</p>
<p>2 5 6 1</p>
<p>8 5 2 9</p>
<p>4 5 6 7</p>
<p>3 2 7 5</p>
<p>NOT a magic square</p>
<p>The following is the code.</p>
<pre><code>import java.io.File;
import java.io.IOException;
import java.util.Scanner;
class square {
public static void main(String[] args) throws IOException {
File data = new File("Lab8Data.txt");
Scanner input = new Scanner(data);
int[][] array = new int[4][4];
int[] rowTotal = new int[4];
int[] columnTotal = new int[4];
for (int row = 0; row < array.length; row++)
array[0][row] = input.nextInt();
while (array[0][0] != -999) {
for (int column = 1; column < array.length; column++)
for (int row = 0; row < 4; row++)
array[column][row] = input.nextInt();
for (int column = 0; column < array.length; column++) {
for (int row = 0; row < array.length; row++)
System.out.print(array[column][row] + " ");
System.out.println();
}
for (int column = 0; column < array.length; column++)
for (int row = 0; row < array.length; row++)
rowTotal[column] += array[column][row];
for (int row = 0; row < array.length; row++)
for (int column = 0; column < array.length; column++)
columnTotal[row] += array[column][row];
int diagonalOne = 0;
for(int row = 0; row < array.length; row++)
diagonalOne = diagonalOne + array[row][row];
int otherDiagonal = 0;
for (int row = 0; row < array.length; row++) {
otherDiagonal = otherDiagonal + array[row][Math.abs(3 - row)];
int rows = rowTotal[0];
boolean rowEqual = true;
for (int r = 0; r < array.length; r++)
if (rowTotal[r] != r)
rowEqual = false;
int col = columnTotal[0];
boolean columnEqual = true;
for (int column = 0; column < array.length; column++)
if (rowTotal[column] != col)
columnEqual = false;
int diagonal = diagonalOne;
boolean diagonalEqual = true;
if (otherDiagonal != diagonal)
diagonalEqual = false;
boolean isMagic = false;
if (rowEqual && columnEqual && diagonalEqual)
if (rows == col && col == diagonal)
isMagic = true;
if (isMagic)
System.out.println("Is a magic square");
else
System.out.println("NOT a magic square");
for (int r = 0; r < 4; r++)
array[0][r] = input.nextInt();
}
}
}
}
</code></pre>
<p>This should be a magic square.</p>
<p>1 15 14 4</p>
<p>12 6 7 9</p>
<p>8 10 11 5</p>
<p>13 3 2 16</p>
<p>What should I do to make it print if the square is magic correctly.</p>
| [
{
"answer_id": 74230764,
"author": "Willem Van Onsem",
"author_id": 67579,
"author_profile": "https://Stackoverflow.com/users/67579",
"pm_score": 2,
"selected": false,
"text": "user1_id"
},
{
"answer_id": 74230839,
"author": "ilyasbbu",
"author_id": 16475089,
"author_... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230768",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20345094/"
] |
74,230,793 | <p>I have made a graph but I don't know how to view the exact values of the bars on the graph. Here is my code in case it is needed. I also have a picture of my graph.</p>
<pre><code>Step 1: Load the tidyverse and tidyquant:
install.packages("tidyverse")
install.packages("tidyquant")
library("tidyverse")
library("tidyquant")
#STEP 2: Getting stocks data:
stocks <- c("TSLA", "UPST", "PLTR", "SPOT", "SHOP", "SPY", "BND")
stocks_df <- tq_get(stocks, from = '2017-01-01')
#Step 3: Group data:
port <- tq_get(c("TSLA", "UPST", "PLTR", "SPOT", "SHOP", "SPY", "BND"),
from = '2017-01-01')%>%
group_by(symbol) %>%
tq_transmute(select = adjusted,
mutate_fun = periodReturn,
period = "daily",
col_rename = "ret")
#Step 4: Computing portfolio returns:
myport <- port %>% tq_portfolio(symbol,ret, c(0.2, 0.2, 0.2, 0.2, 0.2, 0, 0))
benchmark <- port %>% tq_portfolio(symbol, ret, c(0, 0, 0, 0, 0, 0.6, 0.4))
#Step 5: Computing portfolio measure:
mVaR <- myport %>% tq_performance(portfolio.returns,
performance_fun = VaR,
p = 0.95,
method = "historical",
portfolio_method = "single") %>%
add_column(symbol = "MyPort", .before = 1)
bVaR <- benchmark %>% tq_performance(portfolio.returns,
performance_fun = VaR,
p = 0.95,
method = "gaussian",
portfolio_method = "single") %>%
add_column(symbol = "Benchmark", .before = 1)
#Step 6: Computing portfolio measure: Expected Shortfall (ES):
mES <- myport %>% tq_performance(portfolio.returns,
performance_fun = ES,
p = 0.95,
method = "historical",
portfolio_method = "single") %>%
add_column(symbol = "MyPort", .before = 1)
bES <- benchmark %>% tq_performance(portfolio.returns,
performance_fun = ES,
p = 0.95,
method = "gaussian",
portfolio_method = "single") %>%
add_column(symbol = "Benchmark", .before = 1)
#Step 7: Combining the results into a single table using rbind (row bind):
bothVaR <- rbind(mVaR, bVaR)
bothES <- rbind(mES, bES)
results <- inner_join(bothVaR, bothES)
#Step 8: Re-shaping the table into a data frame suitable for plotting:
results <- results %>%
pivot_longer(!symbol, names_to = "measure", values_to = "value")
#Step 9: Plot the results:
results %>% ggplot(aes(x = measure, y = abs(value), fill = symbol)) +
geom_bar(stat = "identity", position = "dodge") +
labs(title = "Value at Risk Approach to Measure a Diversified Portfolio",
x = "Risk Measure", y = " ", fill = " ") + theme_minimal() +
theme(plot.title = element_text(hjust = 0.5), legend.position = "top")
</code></pre>
<p><a href="https://i.stack.imgur.com/ZXIHr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZXIHr.png" alt="enter image description here" /></a></p>
<p>I tried looking up on Google but the examples they give is for a specific set of data with different names and values. I don't know to implement it into my code for my specific script and graph.</p>
| [
{
"answer_id": 74231250,
"author": "RRDK",
"author_id": 8363345,
"author_profile": "https://Stackoverflow.com/users/8363345",
"pm_score": 1,
"selected": false,
"text": "library(ggrepel)\nresults %>% ggplot(aes(x = measure, y = abs(value), fill = symbol)) +\n geom_bar(stat = \"identity\"... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20179743/"
] |
74,230,847 | <p>I am trying to find a way to create a generic "car" class, with children that overload the parent's methods. Subsequently, I would like to have a user class that has as a member any class in the "car" family. Is there a way to achieve the desired functionality? Thank you!</p>
<p>The pseudocode below shows what my intial attempt was, but the compiler obviously complains that User wants a Car object, not a Toyota.</p>
<pre><code>class Car
{
public:
Car();
void method1();
};
class Toyota : public Car
{
public:
Toyota();
void method1();
};
class Lada : public Car
{
public:
Lada();
void method1();
};
class User
{
public:
User();
Car car;
};
int main()
{
User user;
Toyota toyota;
user.car = toyota;
}
</code></pre>
| [
{
"answer_id": 74231184,
"author": "sameraze agvvl",
"author_id": 18295420,
"author_profile": "https://Stackoverflow.com/users/18295420",
"pm_score": 1,
"selected": true,
"text": "#include <iostream>\nusing std::cout;\n\n class Car\n{\n public:\n Car(){cout << \"A car\";};\n ... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15130478/"
] |
74,230,856 | <p><a href="https://i.stack.imgur.com/uZhw8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uZhw8.png" alt="This is the Column, how can we get it the same way as some other Columns are in the format of Month-Year" /></a></p>
<p>I am thinking of trying if condition, but is there any library or method which I don't know about can solve this?</p>
| [
{
"answer_id": 74230904,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 1,
"selected": false,
"text": "month(s)"
},
{
"answer_id": 74230930,
"author": "mozway",
"author_id": 16343464,
"author_profile... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16142496/"
] |
74,230,878 | <pre><code>file = 'file1 data ut.pdf'
print(file)
print(type(file))
'file1 data ut.pdf'
<class 'str'>
file.replace(" ","_")
'_f_i_l_e_1_ _d_a_t_a_ _u_t_._p_d_f'
file.replace("","_")
</code></pre>
<p>Expected output:</p>
<pre><code>file1_data_ut.pdf
</code></pre>
| [
{
"answer_id": 74230908,
"author": "Amit Singh Tomar",
"author_id": 20344757,
"author_profile": "https://Stackoverflow.com/users/20344757",
"pm_score": -1,
"selected": false,
"text": "file = 'file1 data ut.pdf'\n\nprint(file)\nprint(type(file))\n\nfile=file.replace(\" \",\"_\")\n"
},
... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230878",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3380902/"
] |
74,230,898 | <p>Line 4 counts number of lines from response. Trying to exclude lines that start with # from the count.Possible?</p>
<pre><code>def fetch_block_count(session: requests.Session, url: str, timeout: int):
try:
with session.get(url, timeout=10) as response:
dooct = {url: len(resp.text.splitlines())}
return dooct
except requests.exceptions.RequestException as e:
return 'booger'
</code></pre>
<p>Pasted code incorrectly and fixed it.</p>
| [
{
"answer_id": 74230908,
"author": "Amit Singh Tomar",
"author_id": 20344757,
"author_profile": "https://Stackoverflow.com/users/20344757",
"pm_score": -1,
"selected": false,
"text": "file = 'file1 data ut.pdf'\n\nprint(file)\nprint(type(file))\n\nfile=file.replace(\" \",\"_\")\n"
},
... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20334665/"
] |
74,230,926 | <p>I have data in the form of key value pair (Not Json) as shown below</p>
<pre><code>id | Attributes
---|---------------------------------------------------
12 | Country:US, Eligibility:Yes, startDate:2022-08-04
33 | Country:CA, Eligibility:Yes, startDate:2021-12-01
11 | Country:IN, Eligibility:No, startDate:2019-11-07
</code></pre>
<p>I would like to extract only startDate from Attributes section</p>
<p>Expected Output:</p>
<pre><code>id | Attributes_startDate
---|----------------------
12 | 2022-08-04
33 | 2021-12-01
11 | 2019-11-07
</code></pre>
<p>One way that I tried was, I tired converting the Attributes column in the Input data into JSON by appending {, } at start and end positions respectively. Also some how tried adding double quotes on the Key values and tried extracting startDate. But, is there any other effective solution to extract startDate as I don't want to rely on Regex.</p>
| [
{
"answer_id": 74230963,
"author": "Mikhail Berlyant",
"author_id": 5221944,
"author_profile": "https://Stackoverflow.com/users/5221944",
"pm_score": 0,
"selected": false,
"text": "select id, regexp_extract(Attributes, r'startDate:(\\d{4}-\\d{2}-\\d{2})') Attributes_startDate\nfrom your_... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6698715/"
] |
74,230,931 | <p>I am looking forward to creating controller on demand with a different tag which binds with the Bindings defined. Is there any way to do this in Getx?</p>
| [
{
"answer_id": 74230963,
"author": "Mikhail Berlyant",
"author_id": 5221944,
"author_profile": "https://Stackoverflow.com/users/5221944",
"pm_score": 0,
"selected": false,
"text": "select id, regexp_extract(Attributes, r'startDate:(\\d{4}-\\d{2}-\\d{2})') Attributes_startDate\nfrom your_... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230931",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20272019/"
] |
74,230,951 | <p><a href="https://i.stack.imgur.com/fjuGN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fjuGN.png" alt="enter image description here" /></a></p>
<p>I'm trying to get Device orientation but defaultDisplay.orinentation is deprecated, What are the alternatives for this?</p>
<p>Please note I do not need to use orientationEventListener for this because that will trigger only when device orientation changes.</p>
| [
{
"answer_id": 74230963,
"author": "Mikhail Berlyant",
"author_id": 5221944,
"author_profile": "https://Stackoverflow.com/users/5221944",
"pm_score": 0,
"selected": false,
"text": "select id, regexp_extract(Attributes, r'startDate:(\\d{4}-\\d{2}-\\d{2})') Attributes_startDate\nfrom your_... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13060895/"
] |
74,230,975 | <p>I have a function called <strong>getTableData()</strong> which runs another function <strong>get_table()</strong> and based on that <strong>get_table()</strong> output final function is called which renders a template and also routes to a different page.<br><br>
So the problem is its not routing to a different url (<strong>/tabdata</strong>) from <strong>get_final()</strong> function</p>
<p><strong>Flask code:</strong></p>
<pre><code>@app.route('/api/getTableData', methods=['POST'])
def getTableData():
value = request.json['value']
value=value[:8]
url="https://some.com"+value
df_time=get_table(url)
return get_final(df_time)
def get_table(url):
driver = webdriver.Chrome(options=options)
driver.get(url)
abv = pd.read_html(driver.find_element(By.ID,"frm_hist").get_attribute('outerHTML'))[0]
df_time = pd.DataFrame(abv)
return df_time
@app.route("/tabdata")
def get_final(df_time):
return render_template("new.html",df_time = df_time)
</code></pre>
<p><strong>Code Explanation:</strong></p>
<p>I am using the <strong>value</strong> from <strong>value</strong> variable then concat 2 strings to make the url and then passing the url to another function named <strong>get_table()</strong> which goes to that url and webscrapes the table and converts it into python dataframe. <br><br>
So using the returned python dataframe <strong>get_final()</strong> is called to render the template in a html file and also route to the <strong>/tabdata</strong> url. Everything is working well except the page is not routing to that url</p>
| [
{
"answer_id": 74230963,
"author": "Mikhail Berlyant",
"author_id": 5221944,
"author_profile": "https://Stackoverflow.com/users/5221944",
"pm_score": 0,
"selected": false,
"text": "select id, regexp_extract(Attributes, r'startDate:(\\d{4}-\\d{2}-\\d{2})') Attributes_startDate\nfrom your_... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230975",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20089685/"
] |
74,230,981 | <p>Hello I am trying to build an image which can compile and run a c++ program securely.</p>
<pre><code>FROM golang:latest as builder
WORKDIR /app
COPY . .
RUN go mod download
RUN env CGO_ENABLED=0 go build -o /worker
FROM alpine:latest
RUN apk update && apk add --no-cache g++ && apk add --no-cache tzdata
ENV TZ=Asia/Kolkata
WORKDIR /
COPY --from=builder worker /bin
ARG USER=default
RUN addgroup -S $USER && adduser -S $USER -G $USER
USER $USER
ENTRYPOINT [ "worker" ]
</code></pre>
<pre class="lang-yaml prettyprint-override"><code>version: "3.9"
services:
gpp:
build: .
environment:
- token=test_token
- code=#include <iostream>\r\n\r\nusing namespace std;\r\n\r\nint main() {\r\n int a = 10;\r\n int b = 20;\r\n cout << a << \" \" << b << endl;\r\n int temp = a;\r\n a = b;\r\n b = temp;\r\n cout << a << \" \" << b << endl;\r\n return 0;\r\n}
network_mode: bridge
privileged: false
read_only: true
tmpfs: /tmp
security_opt:
- "no-new-privileges"
cap_drop:
- "all"
</code></pre>
<p>Here <strong>worker</strong> is a golang binary which reads <strong>code</strong> from environment variable and stores it in <strong>/tmp</strong> folder as <strong>main.cpp</strong>, and then tries to compile and run it using <code>g++ /tmp/main.cpp</code> && <code>./tmp/a.out</code> (using golang exec)</p>
<p>I am getting this error <code>scratch_4-gpp-1 | Error : fork/exec /tmp/a.out: permission denied</code>, from which what I can understand / know that executing anything from tmp directory is restricted.</p>
<p>Since, I am using read_only root file system, I can only work on tmp directory, Please guide me how I can achieve above task keeping my container secured.</p>
| [
{
"answer_id": 74234692,
"author": "David Maze",
"author_id": 10008173,
"author_profile": "https://Stackoverflow.com/users/10008173",
"pm_score": 2,
"selected": true,
"text": "noexec"
},
{
"answer_id": 74243217,
"author": "50_Seconds _Of_Coding",
"author_id": 13233657,
... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13233657/"
] |
74,230,995 | <p>In my service, I have integrated the sharereplay from RXJS. but navigating between pages, share replay not considered. each time my api updated from remote. any one help me to understand the issue? show me the correct way to implement the same?</p>
<p>service code:</p>
<pre><code>import { HttpClient } from '@angular/common/http';
import { Injectable } from '@angular/core';
import { Observable, throwError } from 'rxjs';
import { catchError, map, shareReplay } from 'rxjs/operators';
export interface PostProps {
userId: number;
id: number;
title: string;
body: string;
processed: string;
}
@Injectable()
export class PersonnelDataService {
list$: Observable<PostProps[]>;
private URL = 'https://jsonplaceholder.typicode.com/posts';
constructor(private http: HttpClient) {}
fetchPersonnelList() {
if (!this.list$) {
this.list$ = this.http.get<PostProps[]>(this.URL).pipe(
map((response: PostProps[]) => response),
shareReplay(1),//not works
catchError(async (error) => this.handleError(error))
);
}
return this.list$;
}
handleError(error) {
throwError(error);
}
}
</code></pre>
<p>component:</p>
<pre><code>ngOninit(){
this.personalDataService.fetchPersonneList();
this.personnelList$ = this.personnelDataService.list$
}
</code></pre>
<p><strong>I updated the code like this:</strong></p>
<pre><code>this.list$ = this.http.get<PostProps[]>(this.URL).pipe( shareReplay(1));
</code></pre>
<p>I am getting data. but still when I navigate to child page, getting new api call.?!</p>
<p><a href="https://stackblitz.com/edit/angular-9-starter-ajnttn?file=src/app/postService.ts" rel="nofollow noreferrer">Live Demo</a></p>
| [
{
"answer_id": 74232572,
"author": "MGX",
"author_id": 20059754,
"author_profile": "https://Stackoverflow.com/users/20059754",
"pm_score": 0,
"selected": false,
"text": "private _list = new BehaviorSubject<PostProps[]>([]);\npublic list$ = this._list.asObservable();\n\n// ...\n\nfetchPer... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74230995",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2024080/"
] |
74,231,040 | <p>I am trying to VStack an Image and a Text inside a NavigationLink.</p>
<p>This is my code:</p>
<pre><code>NavigationLink(destination: ContentView()){
Circle()
.fill(Color.green)
.frame(width: 50, height:50)
.overlay(Image(systemName: "arrow.up"))
Text("Send")
.foregroundColor(Color.white)
}
</code></pre>
<pre><code>VStack {
if item.title == "Send"{
NavigationLink(destination: ContentView()) {
VStack {
Circle()
.fill(Color.green)
.frame(width: 50, height:50)
.overlay(Image(systemName: "arrow.up"))
Text("Send")
.foregroundColor(Color.black)
}
}
}}
</code></pre>
<p>If I try to VStack inside the NavigationLink then nothing would compile.<br> If I try to VStack everything, then the image and the text would still show next to each other.<br>
I am trying to achieve the right example:</p>
<p><a href="https://i.stack.imgur.com/HtbQf.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HtbQf.png" alt="" /></a></p>
| [
{
"answer_id": 74231118,
"author": "Khoi Nguyen",
"author_id": 18489845,
"author_profile": "https://Stackoverflow.com/users/18489845",
"pm_score": 0,
"selected": false,
"text": "VStack {\n NavigationLink(destination: ContentView()) {\n VStack {\n Circle()\n ... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231040",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4876250/"
] |
74,231,073 | <p>The find() function gives you index of first char of substring in string, I need last char.</p>
<p>I tried to get length of substring and sum it to first index but it is going out of bound.</p>
<pre><code> // if( str2.substr(last char index, str2.find(part3)))
int sizeOfPart2 = part2.length();
int sizeOfPart3 = part3.length();
if(sizeOfPart2 == 1){
sizeOfPart2 = 0;
}
else if(sizeOfPart3 == 1){
sizeOfPart3 = 0;
}
cout<<str2.substr(str2[str2.find(part2) + sizeOfPart2],
str2.find(part3));
</code></pre>
| [
{
"answer_id": 74231177,
"author": "FutureJJ",
"author_id": 7040601,
"author_profile": "https://Stackoverflow.com/users/7040601",
"pm_score": 2,
"selected": false,
"text": "int findLastCharSubstring(std::string text, std::string substring){\n int index = text.find(substring);\n if(... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20036903/"
] |
74,231,080 | <p>I store all my secrets and database params in the dev.env file.
I have 3 different settings files - base, dev and prod.
There is an SQLite database in base, and I want to connect to Postgres in dev.</p>
<p>So I upload my secrets with the environment variable in my dev setting file like this:</p>
<pre><code>from dotenv import load_dotenv
load_dotenv(os.environ.get('ENV_CONFIG', ''))
</code></pre>
<p>And I override my database settings in dev settings file:</p>
<pre><code> DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql',
'NAME': os.environ['DB_NAME'],
'USER': os.environ['DB_USER'],
'PASSWORD': os.environ['DB_PASS'],
'HOST': os.environ['DB_HOST'],
'PORT': os.environ['DB_PORT'],
}
}
</code></pre>
<p>But when I run <code>makemigrations</code> with dev settings file:</p>
<pre><code>./manage.py makemigrations --settings=app.settings.dev
</code></pre>
<p>I get an error:</p>
<pre><code>File "/Users/admin/Desktop/Programming/Python/UkranianFunds/src/app/settings/dev.py", line 35, in <module>
'NAME': os.environ['DB_NAME'],
File "/Library/Frameworks/Python.framework/Versions/3.9/lib/python3.9/os.py", line 679, in __getitem__
raise KeyError(key) from None
KeyError: 'DB_NAME'
</code></pre>
<p>I checked and my secret with the key DB_NAME clearly appears in the settings file - I printed it successfully. The name of the database is correct.</p>
<p>What are other reasons that cause that?</p>
| [
{
"answer_id": 74231177,
"author": "FutureJJ",
"author_id": 7040601,
"author_profile": "https://Stackoverflow.com/users/7040601",
"pm_score": 2,
"selected": false,
"text": "int findLastCharSubstring(std::string text, std::string substring){\n int index = text.find(substring);\n if(... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512250/"
] |
74,231,082 | <p>I have three different sections for filter and a button and i want to use filter on these sections, I just want to know that
how can i get value of these sections ( inside ul li)</p>
<pre><code><div id="new-items" class="dropdown">
<a href="#" class="btn-selector nolink">New Items</a>
<ul class="">
<li><span>New bestsellers</span></li>
<li><span>New releases</span></li>
</ul>
</div>
<div id="buy" class="dropdown">
<a href="#" class="btn-selector nolink">Buy Now</a>
<ul class="">
<li><span>Wallet</span></li>
<li><span>Website</span></li>
</ul>
</div>
<div id="sort-by" class="dropdown">
<a href="#" class="btn-selector nolink">Sort By</a>
<ul class="">
<li><span>Low To High Price</span></li>
<li><span>High To Low Price</span></li>
<li><span>View</span></li>
<li><span>View</span></li>
<li><span>Rating</span></li>
<li><span>Sale</span></li>
<li><span>Date</span></li>
</ul>
</div>
<button class="sc-button style letter style-2 filter"><span>Filter</span> </button>
</code></pre>
| [
{
"answer_id": 74231300,
"author": "Misunderstood",
"author_id": 3813605,
"author_profile": "https://Stackoverflow.com/users/3813605",
"pm_score": 1,
"selected": false,
"text": "<li>"
},
{
"answer_id": 74231411,
"author": "Professor Abronsius",
"author_id": 3603681,
"... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231082",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20259827/"
] |
74,231,091 | <p>I have a dataframe with specific columns that looks like this:</p>
<pre><code>colA
['work', 'time', 'money', 'home', 'good', 'financial']
['school', 'lazy', 'good', 'math', 'sad', 'important', 'dizzy', 'go']
['frame', 'happy', 'feel', 'youth', 'change', 'home', 'past']
['first', 'eat', 'good', 'hungry', 'empty', 'fool']
['meet', 'risk', 'fire', 'angry', 'go']
</code></pre>
<p>ColA is string NOT list. And I have list like this:</p>
<pre><code>word = ['good', 'sad', 'angry', 'feel', 'empty', 'dizzy', 'go', 'happy', 'fool', 'eat', 'past', 'lazy', 'youth', 'old', 'enjoy', 'free', 'time', 'hungry']
</code></pre>
<p>I want to keep the words in the list. So it should be look like this:</p>
<pre><code>colA
['time', 'good']
['lazy', 'good', 'sad', 'dizzy', 'go']
['happy', 'feel', 'youth', 'past']
['eat', 'good', 'hungry', 'empty', 'fool']
['angry, 'go']
</code></pre>
<p>I've tried using str.contains but getting an error:</p>
<pre><code>contains() takes from 2 to 6 positional arguments but 18 were given
</code></pre>
<p>I'm just begginer, so sorry.</p>
| [
{
"answer_id": 74231107,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 1,
"selected": false,
"text": "ast.literal_eval"
},
{
"answer_id": 74231109,
"author": "mozway",
"author_id": 16343464,
"author... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231091",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20347129/"
] |
74,231,119 | <p>I have a TAB separated txt file looking like this;</p>
<pre><code>Serving Sector Target Sector HO Attempts HO Successful Attempts
1002080 1002081 8 8
1002080 1002084 0 0
1002080 1002974 2 2
1002080 2104-2975 5 5
1002080 1002976 2 2
1002080 1012237 10 10
1002080 1012281 0 0
</code></pre>
<p>In some situations the Target Sector(column 2) might be on this format 2104-2975( ABCD-YYYY).
In those cases I wish to update this string of column 2 to the correct format (BC0YYYY = 1002975)</p>
<p>This is what I have written so far;</p>
<pre><code>while read -r line;
do
if echo $line | grep -E '([0-9])-([0-9])' # If line matches criteria
then
string=`echo "$line" | awk -F '\t' '{{print $2}}'` #fetch column 2
LAC=${string%-*} #LAC= ABCD
CI=${string##*-} #CI = YYYY
if [ ${#CI} -lt 5 ]; then CI="0"$CI; #IF stringlength of CI is less than 5, add 0
fi
LAC2=`echo $LAC | cut -c2-3` #LAC2 = BC
GERANCELL=$LAC2$CI
fi
done < input.txt
</code></pre>
<p>Anyone know how to update the 2nd column of the line with the new value $GERANCELL?</p>
| [
{
"answer_id": 74231107,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 1,
"selected": false,
"text": "ast.literal_eval"
},
{
"answer_id": 74231109,
"author": "mozway",
"author_id": 16343464,
"author... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6237327/"
] |
74,231,128 | <p>I want to use sequelize seeders and migrations on my express api and currently all the models are written in typescript using <a href="https://github.com/sequelize/sequelize-typescript/" rel="nofollow noreferrer">sequelize-typescript</a></p>
<p>I tried adding my first seeder file using typescript and I get an error when running it</p>
<p><strong>20221028050116-feeds.ts</strong> seeder file</p>
<pre><code>'use strict';
import { QueryInterface } from 'sequelize';
const feedTypes = [
{ id: 'b871a455-fddb-414c-ac02-2cdee07fa671', name: 'crypto' },
{ id: '68b15f90-19ca-4971-a2c6-67e66dc88f77', name: 'general' },
];
const feeds = [
{
id: 1,
name: 'cointelegraph',
url: 'https://cointelegraph.com/rss',
feed_type_id: 'b871a455-fddb-414c-ac02-2cdee07fa671',
},
];
module.exports = {
up: (queryInterface: QueryInterface): Promise<number | object> =>
queryInterface.sequelize.transaction(async (transaction) => {
// here go all migration changes
return Promise.all([
queryInterface.bulkInsert('feed_types', feedTypes, { transaction }),
queryInterface.bulkInsert('feeds', feeds, { transaction }),
]);
}),
down: (queryInterface: QueryInterface): Promise<object | object> =>
queryInterface.sequelize.transaction(async (transaction) => {
// here go all migration undo changes
return Promise.all([
queryInterface.bulkDelete('feed_types', null, { transaction }),
queryInterface.bulkDelete('feeds', null, { transaction }),
]);
}),
};
</code></pre>
<p>I added 2 commands in my package.json file to seed</p>
<pre><code>"apply-seeders": "sequelize-cli db:seed:all",
"revert-seeders": "sequelize-cli db:seed:undo:all",
</code></pre>
<p>When I execute 'npm run apply-seeders', it gives me the following error</p>
<pre><code>Sequelize CLI [Node: 16.17.0, CLI: 6.5.1, ORM: 6.23.2]
ERROR: Cannot find "/Users/vr/Desktop/code/ch/api/src/config/index.js". Have you run "sequelize init"?
ERROR: Cannot read properties of undefined (reading 'detail')
sequelize-cli db:seed:all
Run every seeder
Options:
--version Show version number [boolean]
--help Show help [boolean]
--env The environment to run the command in [string] [default: "development"]
--config The path to the config file [string]
--options-path The path to a JSON file with additional options [string]
--migrations-path The path to the migrations folder [string] [default: "migrations"]
--seeders-path The path to the seeders folder [string] [default: "seeders"]
--models-path The path to the models folder [string] [default: "models"]
--url The database connection string to use. Alternative to using --config files [string]
--debug When available show various debug information [boolean] [default: false]
TypeError: Cannot read properties of undefined (reading 'detail')
at Object.error (/Users/vr/Desktop/code/ch/api/node_modules/sequelize-cli/lib/helpers/view-helper.js:43:24)
at /Users/vr/Desktop/code/ch/api/node_modules/sequelize-cli/lib/commands/seed.js:48:39
at async Object.exports.handler (/Users/vr/Desktop/code/ch/api/node_modules/sequelize-cli/lib/commands/seed.js:24:7)
vr@vivz api %
</code></pre>
<p>I did some digging into it and it turns out that you cannot directly run typescript files with sequelize as per <a href="https://stackoverflow.com/questions/65765429/using-sequelize-cli-with-typescript">THIS ANSWER</a> here</p>
<p>I modified my .sequelizerc file to run stuff from dist folder instead of src</p>
<p><strong>.sequelizerc</strong> file</p>
<pre><code>require("@babel/register");
const path = require('path');
module.exports = {
config: path.resolve('dist', 'config', 'index.js'),
'migrations-path': path.resolve('dist', 'data', 'migrations'),
'models-path': path.resolve('dist', 'data', 'models'),
'seeders-path': path.resolve('dist', 'data', 'seeders'),
};
</code></pre>
<p>Running this now gives me a different type of error</p>
<pre><code>Sequelize CLI [Node: 16.17.0, CLI: 6.5.1, ORM: 6.23.2]
ERROR: Error reading "dist/config/index.js". Error: Error: Cannot find module 'babel-plugin-module-resolver'
Require stack:
- /Users/vr/Desktop/code/ch/api/node_modules/@babel/core/lib/config/files/plugins.js
- /Users/vr/Desktop/code/ch/api/node_modules/@babel/core/lib/config/files/index.js
- /Users/vr/Desktop/code/ch/api/node_modules/@babel/core/lib/index.js
- /Users/vr/Desktop/code/ch/api/node_modules/@babel/register/lib/worker/babel-core.js
- /Users/vr/Desktop/code/ch/api/node_modules/@babel/register/lib/worker/handle-message.js
- /Users/vr/Desktop/code/ch/api/node_modules/@babel/register/lib/worker-client.js
- /Users/vr/Desktop/code/ch/api/node_modules/@babel/register/lib/node.js
- /Users/vr/Desktop/code/ch/api/node_modules/@babel/register/lib/nodeWrapper.js
- /Users/vr/Desktop/code/ch/api/node_modules/@babel/register/lib/index.js
- /Users/vr/Desktop/code/ch/api/.sequelizerc
- /Users/vr/Desktop/code/ch/api/node_modules/sequelize-cli/lib/core/yargs.js
- /Users/vr/Desktop/code/ch/api/node_modules/sequelize-cli/lib/sequelize
ERROR: Cannot read properties of undefined (reading 'detail')
sequelize-cli db:seed:all
Run every seeder
Options:
--version Show version number [boolean]
--help Show help [boolean]
--env The environment to run the command in [string] [default: "development"]
--config The path to the config file [string]
--options-path The path to a JSON file with additional options [string]
--migrations-path The path to the migrations folder [string] [default: "migrations"]
--seeders-path The path to the seeders folder [string] [default: "seeders"]
--models-path The path to the models folder [string] [default: "models"]
--url The database connection string to use. Alternative to using --config files [string]
--debug When available show various debug information [boolean] [default: false]
TypeError: Cannot read properties of undefined (reading 'detail')
at Object.error (/Users/vr/Desktop/code/ch/api/node_modules/sequelize-cli/lib/helpers/view-helper.js:43:24)
at /Users/vr/Desktop/code/ch/api/node_modules/sequelize-cli/lib/commands/seed.js:48:39
at async Object.exports.handler (/Users/vr/Desktop/code/ch/api/node_modules/sequelize-cli/lib/commands/seed.js:24:7)
</code></pre>
<p>This would be my <strong>tsconfig.json</strong> file</p>
<pre><code>{
"compilerOptions": {
"lib": ["es2020"],
"module": "commonjs",
"moduleResolution": "node",
"target": "es2020",
"esModuleInterop": true,
"skipLibCheck": true,
"forceConsistentCasingInFileNames": true,
"noImplicitAny": false,
"outDir": "dist",
"experimentalDecorators": true,
"emitDecoratorMetadata": true,
"baseUrl": ".",
"paths": {
"server/*": ["src/server/*"],
"tests/*": ["src/tests/*"],
"data/*": ["src/data/*"],
"config": ["src/config"],
}
}
}
</code></pre>
<p>Can someone kindly tell me how I can run my seeder and migration files using typescript</p>
<p><strong>UPDATE 1</strong></p>
<p>I installed the babel-plugin-module-resolver. Now it gives me a new error. This error doesnt show up if you run the ts files normally. When I console.log I can see all the values but when the program is run, that dialect simply doesnt load it seems from the env file</p>
<pre><code>Loaded configuration file "dist/config/index.js".
ERROR: Dialect needs to be explicitly supplied as of v4.0.0
ERROR: Cannot read properties of undefined (reading 'detail')
</code></pre>
<p><strong>UPDATE 2</strong></p>
<p>I hardcoded the dialect postgres into the config file and it still gives me the error. I even verified that the transpiled js file has the postgres dialect specified</p>
| [
{
"answer_id": 74231107,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 1,
"selected": false,
"text": "ast.literal_eval"
},
{
"answer_id": 74231109,
"author": "mozway",
"author_id": 16343464,
"author... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231128",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5371505/"
] |
74,231,145 | <p>I have done online research on this and also searched for the solution on SO but still didn't got any.
Need a simple, efficient, time and space saving way to call all the functions in a <code>class</code></p>
<p>Here i have a <code>class</code> with many <code>methods</code> defined inside. after the end of the <code>class</code>, i have to call all the defined <code>methods</code> to execute the block of code inside each <code>methods</code>.</p>
<pre><code>class Sample
def initialize(arg1, arg2)
@arg1 = arg1
@arg2 = arg2
end
def method1
puts @arg1
end
def method2
puts @arg2
end
def method3
puts "This is method3"
end
def method4
puts "This is method4"
end
.............
.............
............. etc...
end
</code></pre>
<p>Now creating an <code>object</code> for calling the <code>class</code> and <code>method</code></p>
<pre><code>object = Sample.new(par1, par2)
object.method1
object.method2
object.method3
object.method4
.............
............. etc...
</code></pre>
<p>calling the <code>methods</code> one by one using the <code>object.method_name(parameter)</code> is really hard and taking very long space and time.
is it possible to call all the <code>methods</code> by a single line code (or) with any other efficient way?</p>
| [
{
"answer_id": 74231341,
"author": "Ritesh Choudhary",
"author_id": 386540,
"author_profile": "https://Stackoverflow.com/users/386540",
"pm_score": 0,
"selected": false,
"text": "auto __call__"
},
{
"answer_id": 74231354,
"author": "Jörg W Mittag",
"author_id": 2988,
... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231145",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19611403/"
] |
74,231,170 | <p>I've mysql database where data is column:</p>
<pre><code>+----+-------+--------+--+
| ID | refID | data | |
+----+-------+--------+--+
| 1 | 1023 | aaaaaa | |
| 2 | 1024 | bbbbbb | |
| 3 | 1025 | cccccc | |
| 4 | 1023 | ffffff | |
| 5 | 1025 | gggggg | |
| 6 | 1022 | rrrrrr | |
+----+-------+--------+--+
</code></pre>
<p>I want this data to be shown in rows with duplicate values:</p>
<pre><code>+----+-------+--------+--------+
| ID | refID | data | data2 |
+----+-------+--------+--------+
| 1 | 1023 | aaaaaa | ffffff |
| 2 | 1024 | bbbbbb | |
| 3 | 1025 | cccccc | gggggg |
| 4 | 1022 | rrrrrr | |
+----+-------+--------+--------+
</code></pre>
<p>Is it possible with PHP & MYSQL?</p>
<p>I tried mysql query group by refID but it's not working.</p>
| [
{
"answer_id": 74231341,
"author": "Ritesh Choudhary",
"author_id": 386540,
"author_profile": "https://Stackoverflow.com/users/386540",
"pm_score": 0,
"selected": false,
"text": "auto __call__"
},
{
"answer_id": 74231354,
"author": "Jörg W Mittag",
"author_id": 2988,
... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20195856/"
] |
74,231,171 | <p>I have a <code>constexpr</code> function and I'm trying to strip the file name from the <code>__FILE__</code> macro, that is, remove everything but the path. I sketched up this basic function to do so, and I made it <code>constexpr</code> in hopes that the compiler can deduce the result and just place that calculated result as a string in the final binary. The function isn't perfect, just a simple mock-up.</p>
<pre><code>constexpr const char* const get_filename()
{
auto file{ __FILE__ };
auto count{ sizeof(__FILE__) - 2 };
while (file[count - 1] != '\\')
--count;
return &file[count];
}
int main()
{
std::cout << get_filename() << std::endl;
return 0;
}
</code></pre>
<p>The problem is that this is not being evaluated at compile time (build: MSVC x64 Release Maximum Speed optimization). I'm assuming this is because of returning a pointer to something inside a constant string in the binary, which is essentially what the function is doing. However, what I want the compiler to do is parse the <code>get_filename</code> function and somehow return the string literal <code>"main.cpp"</code>, for example, instead of returning a pointer of that substring. Essentially, I want this to compile down so that the final binary just has <code>main.cpp</code> in it, and nothing else part of the <code>__FILE__</code> macro. Is this possible?</p>
| [
{
"answer_id": 74231344,
"author": "Pepijn Kramer",
"author_id": 16649550,
"author_profile": "https://Stackoverflow.com/users/16649550",
"pm_score": 0,
"selected": false,
"text": "#include <string_view>\n#include <iostream>\n\nstatic constexpr std::string_view get_filename()\n{\n std:... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10504230/"
] |
74,231,188 | <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const strs = ["eat", "tea", "tan", "ate", "nat", "bat"]
var sortAlphabets = function(text) {
return text.split('').sort().join('');
};
let map = new Map();
for (let str of strs) {
let key = sortAlphabets(str);
map[key] = [...map[key] || "", str];
}
console.log(
Object.values(map)
)</code></pre>
</div>
</div>
</p>
<p>if I add any string lets say "te" the map looks like this</p>
<p><code>map[key]=[...map[key] || "te" , str];</code></p>
<pre><code>Map(0) {
aet: [ 't', 'e', 'eat', 'tea', 'ate' ],
ant: [ 't', 'e', 'tan', 'nat' ],
abt: [ 't', 'e', 'bat' ]
}
</code></pre>
<p>and when it is empty map[key]=[...map[key] || "" , str];</p>
<pre><code>Map(0) {
aet: [ 'eat', 'tea', 'ate' ],
ant: [ 'tan', 'nat' ],
abt: [ 'bat' ]}
</code></pre>
<p>So why is empty string not getting added in the map?</p>
| [
{
"answer_id": 74231344,
"author": "Pepijn Kramer",
"author_id": 16649550,
"author_profile": "https://Stackoverflow.com/users/16649550",
"pm_score": 0,
"selected": false,
"text": "#include <string_view>\n#include <iostream>\n\nstatic constexpr std::string_view get_filename()\n{\n std:... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231188",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18522337/"
] |
74,231,205 | <p>I'm trying to install <a href="/questions/tagged/r" class="post-tag" title="show questions tagged 'r'" aria-label="show questions tagged 'r'" rel="tag" aria-labelledby="r-container">r</a> package <a href="/questions/tagged/rsvg" class="post-tag" title="show questions tagged 'rsvg'" aria-label="show questions tagged 'rsvg'" rel="tag" aria-labelledby="rsvg-container">rsvg</a> without any success. Tried the following two methods:</p>
<p><strong>1</strong>. <strong>install.packages("rsvg")</strong></p>
<pre><code>install.packages("rsvg")
Installing package into ‘C:/Users/hp/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
There is a binary version available but the source version is
later:
binary source needs_compilation
rsvg 2.3.1 2.3.2 TRUE
installing the source package ‘rsvg’
trying URL 'https://cloud.r-project.org/src/contrib/rsvg_2.3.2.tar.gz'
Content type 'application/x-gzip' length 183798 bytes (179 KB)
downloaded 179 KB
* installing *source* package 'rsvg' ...
** package 'rsvg' successfully unpacked and MD5 sums checked
** using staged installation
** libs
rm -f rsvg.dll rsvg.o
"C:/PROGRA~1/R/R-42~1.1/bin/x64/Rscript.exe" "../tools/winlibs.R" 2.48.8
Error in download.file(sprintf("https://github.com/rwinlib/rsvg/archive/v%s.zip", :
download from 'https://github.com/rwinlib/rsvg/archive/v2.48.8.zip' failed
In addition: Warning message:
In download.file(sprintf("https://github.com/rwinlib/rsvg/archive/v%s.zip", :
URL 'https://codeload.github.com/rwinlib/rsvg/zip/refs/tags/v2.48.8': Timeout of 60 seconds was reached
Execution halted
make: *** [Makevars.win:7: winlibs] Error 1
ERROR: compilation failed for package 'rsvg'
* removing 'C:/Users/hp/AppData/Local/R/win-library/4.2/rsvg'
The downloaded source packages are in
‘C:\Users\hp\AppData\Local\Temp\RtmpmG8xM2\downloaded_packages’
Warning message:
In install.packages("rsvg") :
installation of package ‘rsvg’ had non-zero exit status
</code></pre>
<p><strong>2</strong>. <strong>remotes::install_github("ropensci/rsvg")</strong></p>
<pre><code>library(remotes)
install_github("ropensci/rsvg")
Downloading GitHub repo ropensci/rsvg@HEAD
✔ checking for file 'C:\Users\hp\AppData\Local\Temp\RtmpmG8xM2\remotes5a645f9057ed\ropensci-rsvg-6d9840f/DESCRIPTION'
─ preparing 'rsvg':
checking DESCRIPTION meta-information ...
checking DESCRIPTION meta-information ...
✔ checking DESCRIPTION meta-information
─ cleaning src
─ checking for LF line-endings in source and make files and shell scripts
─ checking for empty or unneeded directories
─ building 'rsvg_2.3.2.tar.gz'
Warning:
Warning: file 'rsvg/cleanup' did not have execute permissions: corrected
Warning: file 'rsvg/configure' did not have execute permissions: corrected
Installing package into ‘C:/Users/hp/AppData/Local/R/win-library/4.2’
(as ‘lib’ is unspecified)
* installing *source* package 'rsvg' ...
** using staged installation
** libs
rm -f rsvg.dll rsvg.o
"C:/PROGRA~1/R/R-42~1.1/bin/x64/Rscript.exe" "../tools/winlibs.R" 2.48.8
Error in download.file(sprintf("https://github.com/rwinlib/rsvg/archive/v%s.zip", :
download from 'https://github.com/rwinlib/rsvg/archive/v2.48.8.zip' failed
In addition: Warning messages:
1: In download.file(sprintf("https://github.com/rwinlib/rsvg/archive/v%s.zip", :
downloaded length 35551249 != reported length 43111940
2: In download.file(sprintf("https://github.com/rwinlib/rsvg/archive/v%s.zip", :
URL 'https://codeload.github.com/rwinlib/rsvg/zip/refs/tags/v2.48.8': Timeout of 60 seconds was reached
Execution halted
make: *** [Makevars.win:7: winlibs] Error 1
ERROR: compilation failed for package 'rsvg'
* removing 'C:/Users/hp/AppData/Local/R/win-library/4.2/rsvg'
Warning message:
In i.p(...) :
installation of package ‘C:/Users/hp/AppData/Local/Temp/RtmpmG8xM2/file5a645596780/rsvg_2.3.2.tar.gz’ had non-zero exit status
</code></pre>
<p><strong>sessionInfo()</strong></p>
<pre><code>sessionInfo()
R version 4.2.1 (2022-06-23 ucrt)
Platform: x86_64-w64-mingw32/x64 (64-bit)
Running under: Windows 10 x64 (build 22000)
Matrix products: default
locale:
[1] LC_COLLATE=English_United States.utf8 LC_CTYPE=English_United States.utf8 LC_MONETARY=English_United States.utf8
[4] LC_NUMERIC=C LC_TIME=English_United States.utf8
attached base packages:
[1] stats graphics grDevices utils datasets methods base
other attached packages:
[1] remotes_2.4.2
loaded via a namespace (and not attached):
[1] processx_3.8.0 compiler_4.2.1 R6_2.5.1 rprojroot_2.0.3 cli_3.4.1 prettyunits_1.1.1 tools_4.2.1 withr_2.5.0
[9] curl_4.3.3 crayon_1.5.2 callr_3.7.2 ps_1.7.2 pkgbuild_1.3.1
</code></pre>
| [
{
"answer_id": 74231494,
"author": "RRDK",
"author_id": 8363345,
"author_profile": "https://Stackoverflow.com/users/8363345",
"pm_score": 0,
"selected": false,
"text": "remotes::install_github(\"rwinlib/rsvg\")"
},
{
"answer_id": 74231972,
"author": "Quinten",
"author_id"... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231205",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/707145/"
] |
74,231,209 | <p>I'm writing a program to analyse a frequency table with different functions (mean, median, mode, range, etc) and I have the user inputting their data in two lists and then converting those answers into lists of integers</p>
<pre><code>values_input = input('First, enter or paste the VALUES, separated by spaces (not commas): ')
freq_input = input('Now enter the corresponding FREQUENCIES, separated by spaces: ')
values = values_input.split()
freq = freq_input.split()
data_list = []
</code></pre>
<p>For every value, I want the program to append it to data_input by the corresponding frequency.</p>
<p>For example (desired result):</p>
<p>If values was: 1 2 3 4
and frequency was: 2 5 7 1</p>
<p>I want data_list to be:
[1, 1, 2, 2, 2, 2, 2, 3, 3, 3, 3, 3, 3, 3, 4]</p>
<p>At the moment I have this:</p>
<pre><code>for i in range(len(values)):
j = 3
while j != 0:
data_input.append(values[i])
j -= 1
</code></pre>
<p>But that only appends the values to data_input 3 times instead of the frequency</p>
| [
{
"answer_id": 74231494,
"author": "RRDK",
"author_id": 8363345,
"author_profile": "https://Stackoverflow.com/users/8363345",
"pm_score": 0,
"selected": false,
"text": "remotes::install_github(\"rwinlib/rsvg\")"
},
{
"answer_id": 74231972,
"author": "Quinten",
"author_id"... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231209",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20355358/"
] |
74,231,211 | <p>I have below tables</p>
<p><a href="https://i.stack.imgur.com/sTR86.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sTR86.png" alt="enter image description here" /></a></p>
<p><strong><a href="https://dbfiddle.uk/M9i-Qd6U" rel="nofollow noreferrer">DEMO fiddle</a></strong></p>
<p>In <code>x_table</code>, I have different records. I want to fetch all currencies from <code>x_table</code> where continent is <code>Asia</code> which is straight forward as below,</p>
<blockquote>
<ol>
<li>SELECT currency from x_table where continent='Asia'</li>
</ol>
</blockquote>
<p>and it should return <code>Rupee</code> and <code>Yen</code> rows which is also fine.</p>
<p>Now look at <code>type</code> columns in <code>x_table</code> and then another <code>y_table</code> table. <code>type</code> value represents different columns in <code>y_table</code></p>
<p>Now query should be (considering two tables)</p>
<p>Fetch all currencies from <code>x_table</code> where <code>continent</code> is <code>something</code> BUT check relative <code>type</code> column in <code>y_table</code>. If respective <code>type</code> column value is 1 then and then fetch the record otherwise ignore it.</p>
<p>something like</p>
<blockquote>
<p>SELECT continent, currency FROM x_table as X inner join y_table as Y on X.continent = Y.continent (BUT check if matching "type" column value is 1) if it is 0 ignore it.</p>
</blockquote>
<p>With this logic, if you consider <strong>1.</strong> query again, it should return only <code>Rupee</code> row because <code>Rupee_Dual</code> in <code>y_table</code> for <code>Asia</code> cotinent is <code>1</code>.
But <code>Yen</code> row should not return because <code>Yen_Single</code> in <code>y_table</code> for <code>Asia</code> continent is <code>0</code>.</p>
| [
{
"answer_id": 74231391,
"author": "Joop Eggen",
"author_id": 984823,
"author_profile": "https://Stackoverflow.com/users/984823",
"pm_score": 2,
"selected": false,
"text": "value"
},
{
"answer_id": 74231476,
"author": "Akina",
"author_id": 10138734,
"author_profile": ... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3751711/"
] |
74,231,225 | <p>I have been trying to implement a search filter query for my table of vfis using React and Laravel with an API. The below code is where the search form resides.</p>
<p>Navbar.js</p>
<pre><code>import React, {useState} from 'react';
import {Link, useHistory} from 'react-router-dom';
import swal from 'sweetalert';
import axios from 'axios';
// import Vfi from '../../components/admin/vfi/Vfi';
function Navbar() {
const history = useHistory();
const logoutSubmit = (e) => {
e.preventDefault();
axios.post(`/api/logout`).then(res => {
if(res.data.status === 200)
{
localStorage.removeItem('auth_token');
localStorage.removeItem('auth_name');
swal("Success",res.data.message,"success");
history.push('/');
}
});
}
var AuthButtons = '';
if(!localStorage.getItem('auth_token'))
{
AuthButtons = (
<ul className="navbar-nav">
<li className="nav-item">
<Link className="nav-link" to="/login">Login</Link>
</li>
<li className="nav-item">
<Link className="nav-link" to="/register">Register</Link>
</li>
<li className="nav-item">
<Link className="nav-link" to="/contact">Contact</Link>
</li>
</ul>
);
}
else
{
AuthButtons = (
<li className="nav-item">
<li><Link className="dropdown-item" onClick={logoutSubmit}>Logout</Link></li>
</li>
);
}
return (
<nav className="sb-topnav navbar navbar-expand navbar-dark bg-mycolor">
<Link className="navbar-brand ps-3" to="/admin">VFI Kenya</Link>
<button className="btn btn-link btn-sm order-1 order-lg-0 me-4 me-lg-0" id="sidebarToggle" href="#!"><i className="fas fa-bars"></i></button>
<form className="d-none d-md-inline-block form-inline ms-auto me-0 me-md-3 my-2 my-md-0">
<div className="input-group">
<input className="form-control" type="text" placeholder="Search for..." aria-label="Search for..." aria-describedby="btnNavbarSearch" />
<button className="btn btn-primary" id="btnNavbarSearch" type="button"><i className="fas fa-search"></i></button>
</div>
</form>
<ul className="navbar-nav ms-auto ms-md-0 me-3 me-lg-4">
<li className="nav-item dropdown">
<Link to="#" className="nav-link dropdown-toggle" id="navbarDropdown" role="button" data-bs-toggle="dropdown" aria-expanded="false">
<i className="fas fa-user fa-fw"></i>
</Link>
<ul className="dropdown-menu dropdown-menu-end" aria-labelledby="navbarDropdown">
<li><Link className="dropdown-item" to="#!">Settings</Link></li>
<li><Link className="dropdown-item" to="#!">Activity Log</Link></li>
<li><hr className="dropdown-divider" /></li>
{AuthButtons}
</ul>
</li>
</ul>
</nav>
);
}
export default Navbar;
</code></pre>
<p>This is my laravel code for the controller am using...</p>
<p>VFiController.php</p>
<pre><code><?php
namespace App\Http\Controllers\API;
use App\Models\Vfi;
use Illuminate\Http\Request;
use App\Http\Controllers\Controller;
use Illuminate\Support\Facades\Validator;
class VFiController extends Controller
{
public function index()
{
$vfis = Vfi::all();
return response()->json([
'status'=> 200,
'vfis'=>$vfis,
]);
}
public function store(Request $request)
{
$validator = Validator::make($request->all(),[
// 'TelNo' => 'required|regex:/(0)[0-9]{9}/',
'LengthofMembershipinVFi'=> 'required|integer',
'firstName'=> 'required|unique:vfis| |min:2',
'secondName'=> 'required|unique:vfis| |min:2',
'Email'=> 'required|unique:vfis| |email',
]);
if($validator->fails())
{
return response()->json([
'status'=> 422,
'validate_err'=> $validator->messages(),
]);
}
else
{
$vfi = new Vfi() ;
$vfi->Gender = $request->input('Gender') ;
$vfi->firstName = $request->input('firstName') ;
$vfi->secondName = $request->input('secondName') ;
$vfi->MaritalStatus = $request->input('MaritalStatus') ;
$vfi->TelNo= $request->input('TelNo') ;
$vfi->TownofResidence = $request->input('TownofResidence') ;
$vfi->Fellowshipifattendingany = $request->input('Fellowshipifattendingany') ;
$vfi->MinistryInvolvedin= $request->input('MinistryInvolvedin') ;
$vfi->ChurchYouattend = $request->input('ChurchYouattend') ;
$vfi->Profession = $request->input('Profession') ;
$vfi->LengthofMembershipinVFi = $request->input('LengthofMembershipinVFi') ;
$vfi->Email = $request->input('Email') ;
$vfi->save();
return response()->json([
'status'=> 200,
'message'=>'Thank you for your response!',
]);
}
}
public function edit($id)
{
$vfi = Vfi::find($id);
if($vfi)
{
return response()->json([
'status'=> 200,
'vfi' => $vfi,
]);
}
else
{
return response()->json([
'status'=> 404,
'message' => 'No vfi ID Found',
]);
}
}
public function update(Request $request, $id)
{
$validator = Validator::make($request->all(),[
// 'TelNo' => 'required|regex:/(0)[0-9]{9}/',
//'LengthofMembershipinVFi'=> 'required|integer',
//'firstName'=> 'required|unique:vfis| |min:2',
//'secondName'=> 'required|unique:vfis| |min:2',
//'Email'=> 'required|unique:vfis| |email',
]);
if($validator->fails())
{
return response()->json([
'status'=> 422,
'validationErrors'=> $validator->messages(),
]);
}
else
{
$vfi = Vfi::find($id);
if($vfi)
{
$vfi = Vfi::find($id);
$vfi->Gender = $request->input('Gender') ;
$vfi->firstName = $request->input('firstName') ;
$vfi->secondName = $request->input('secondName') ;
$vfi->MaritalStatus = $request->input('MaritalStatus') ;
$vfi->TelNo= $request->input('TelNo') ;
$vfi->TownofResidence = $request->input('TownofResidence') ;
$vfi->Fellowshipifattendingany = $request->input('Fellowshipifattendingany') ;
$vfi->MinistryInvolvedin= $request->input('MinistryInvolvedin') ;
$vfi->ChurchYouattend = $request->input('ChurchYouattend') ;
$vfi->Profession = $request->input('Profession') ;
$vfi->LengthofMembershipinVFi = $request->input('LengthofMembershipinVFi') ;
$vfi->Email = $request->input('Email') ;
$vfi->save();
return response()->json([
'status'=> 200,
'message'=>'Updated Successfully',
]);
}
else
{
return response()->json([
'status'=> 404,
'message' => 'No Vfi ID Found',
]);
}
}
}
public function destroy($id)
{
$vfi = Vfi::find($id);
if($vfi)
{
$vfi->delete();
return response()->json([
'status'=> 200,
'message'=>'Vfi Deleted Successfully',
]);
}
else
{
return response()->json([
'status'=> 404,
'message' => 'No Vfi ID Found',
]);
}
}
}
</code></pre>
<p>And my api.php from laravel</p>
<pre><code>Route::get('vfis', [VFiController::class, 'index']);
Route::post('/add-vfi', [VFiController::class, 'store']);
Route::get('/edit-vfi/{id}', [VFiController::class, 'edit']);
Route::put('update-vfi/{id}', [VFiController::class, 'update']);
Route::delete('delete-vfi/{id}', [VFiController::class, 'destroy']);
</code></pre>
<p><a href="https://i.stack.imgur.com/8foYu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8foYu.png" alt="The table vfis with the search form" /></a></p>
<p>Could someone show me how I can make the search form query and filter data from my table vfis where the data is already presented on the React end using an API</p>
| [
{
"answer_id": 74231391,
"author": "Joop Eggen",
"author_id": 984823,
"author_profile": "https://Stackoverflow.com/users/984823",
"pm_score": 2,
"selected": false,
"text": "value"
},
{
"answer_id": 74231476,
"author": "Akina",
"author_id": 10138734,
"author_profile": ... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231225",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7952974/"
] |
74,231,227 | <p>I would like to save a file name (at most 32 bytes) in a byte array, and then convert bytes back to <code>String</code>. Since there are a sequence of file names, the underlying array is designed to be fixed size (i.e, 32 bytes).</p>
<pre class="lang-rust prettyprint-override"><code>// name is the file name `&str`
let mut arr = [0u8; 32];
arr[..name.len()].copy_from_slice(name.as_bytes());
</code></pre>
<p>But the problem is: it is possible to get the file name the 32-byte long array (<code>arr</code>) without storing the length?</p>
<p>In C/C++, many built-in functions are offered due to the fact that the raw string is terminated with 0:</p>
<pre class="lang-cpp prettyprint-override"><code>// store
memcpy(arr, name.c_str(), name.length() + 1);
// convert it back
char *raw_name = reinterpret_cast<char*>(arr);
</code></pre>
<p>So, what is the idiomatic way to do it in Rust? A possible way is to explicitly store the size using an extra 5 bits, but it seems that it is not the best method.</p>
| [
{
"answer_id": 74231391,
"author": "Joop Eggen",
"author_id": 984823,
"author_profile": "https://Stackoverflow.com/users/984823",
"pm_score": 2,
"selected": false,
"text": "value"
},
{
"answer_id": 74231476,
"author": "Akina",
"author_id": 10138734,
"author_profile": ... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231227",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3741571/"
] |
74,231,232 | <p>I have an array like this:</p>
<pre><code> ['', 'Monday', '', '', 'Thursday', '', 'Saturday']
OR,
Monday,Thursday,saturday
</code></pre>
<p>I want output like;</p>
<pre><code> ['Monday', 'Thursday','Saturday']
</code></pre>
<p>AND,When i map this array I want to print only first 3 letters of the strings of the array like below;</p>
<pre><code> Mon,Thu,Sat
</code></pre>
<p>How to achive this????</p>
<p>Thanks in advance.....</p>
| [
{
"answer_id": 74231391,
"author": "Joop Eggen",
"author_id": 984823,
"author_profile": "https://Stackoverflow.com/users/984823",
"pm_score": 2,
"selected": false,
"text": "value"
},
{
"answer_id": 74231476,
"author": "Akina",
"author_id": 10138734,
"author_profile": ... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20290421/"
] |
74,231,254 | <p>I have a python polars dataframe as-</p>
<pre><code>df_pol = pl.DataFrame({'test_names':[['Mallesham','','Bhavik','Jagarini','Jose','Fernando'],
['','','','ABC','','XYZ']]})
</code></pre>
<p>I would like to get a count of elements from each list in test_names field not considering the empty values.</p>
<pre><code>df_pol.with_column(pl.col('test_names').arr.lengths().alias('tot_names'))
</code></pre>
<p><a href="https://i.stack.imgur.com/kfEtG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kfEtG.png" alt="enter image description here" /></a></p>
<p>Here it is considering empty strings into count, this is why we can see 6 names in list-2. actually it has only two names.</p>
<p>required output as:</p>
<p><a href="https://i.stack.imgur.com/C1lFV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C1lFV.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74231674,
"author": "ritchie46",
"author_id": 6717054,
"author_profile": "https://Stackoverflow.com/users/6717054",
"pm_score": 2,
"selected": true,
"text": "arr.eval"
},
{
"answer_id": 74232926,
"author": "braaannigan",
"author_id": 5387991,
"author_pr... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231254",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9479925/"
] |
74,231,261 | <p>I have a table with the following data, where I need to calculate a sort index (integer) for each row in TSQL</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>type</th>
<th>code</th>
</tr>
</thead>
<tbody>
<tr>
<td>Fruit</td>
<td>030</td>
</tr>
<tr>
<td>Fruit</td>
<td>040</td>
</tr>
<tr>
<td>Fruit</td>
<td>Banana</td>
</tr>
<tr>
<td>Fruit</td>
<td>Apple 1</td>
</tr>
<tr>
<td>Fruit</td>
<td>Apple 2</td>
</tr>
<tr>
<td>Soda</td>
<td>050</td>
</tr>
<tr>
<td>Soda</td>
<td>1</td>
</tr>
<tr>
<td>Soda</td>
<td>054</td>
</tr>
<tr>
<td>Soda</td>
<td>Sprite</td>
</tr>
<tr>
<td>Soda</td>
<td>Fanta</td>
</tr>
</tbody>
</table>
</div>
<p>The sort_index column below should be calculated by type (starting from 1 for each type) and code where parsable integer codes always takes precedence over alphanumeric codes:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>type</th>
<th>code</th>
<th>sort_index</th>
</tr>
</thead>
<tbody>
<tr>
<td>Fruit</td>
<td>030</td>
<td>1</td>
</tr>
<tr>
<td>Fruit</td>
<td>040</td>
<td>2</td>
</tr>
<tr>
<td>Fruit</td>
<td>Apple 1</td>
<td>3</td>
</tr>
<tr>
<td>Fruit</td>
<td>Apple 2</td>
<td>4</td>
</tr>
<tr>
<td>Fruit</td>
<td>Banana</td>
<td>5</td>
</tr>
<tr>
<td>Soda</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>Soda</td>
<td>050</td>
<td>2</td>
</tr>
<tr>
<td>Soda</td>
<td>054</td>
<td>3</td>
</tr>
<tr>
<td>Soda</td>
<td>Fanta</td>
<td>4</td>
</tr>
<tr>
<td>Soda</td>
<td>Sprite</td>
<td>5</td>
</tr>
</tbody>
</table>
</div>
<p>Any help would be highly appreciated.</p>
| [
{
"answer_id": 74231674,
"author": "ritchie46",
"author_id": 6717054,
"author_profile": "https://Stackoverflow.com/users/6717054",
"pm_score": 2,
"selected": true,
"text": "arr.eval"
},
{
"answer_id": 74232926,
"author": "braaannigan",
"author_id": 5387991,
"author_pr... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231261",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5964304/"
] |
74,231,280 | <p>I have an SP which has a parameter @itemCode. If value of parameter is NULL, the SP should return all items records in the table and if the parameter has value then the SP should only return the respective itemcode record. This is what I have written:</p>
<pre><code>SELECT
itemCode
, itemName
FROM itemTable
WHERE itemCode IN (ISNULL(@itemCode, (SELECT itemCode FROM itemTable)))
</code></pre>
<p>The query is returning below error message not sure why because I am already using itemCode IN and not itemCode = in WHERE clause. I am using SQL Server.</p>
<p>Can anyone please suggest the problem or give any alternate solution? Thanks.</p>
| [
{
"answer_id": 74231674,
"author": "ritchie46",
"author_id": 6717054,
"author_profile": "https://Stackoverflow.com/users/6717054",
"pm_score": 2,
"selected": true,
"text": "arr.eval"
},
{
"answer_id": 74232926,
"author": "braaannigan",
"author_id": 5387991,
"author_pr... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9708033/"
] |
74,231,289 | <p>I am using the react-native-confirmation-code-field <a href="https://i.stack.imgur.com/yxnRm.png" rel="nofollow noreferrer">package</a>. I want the keyboard to be showing as soon as the screen renders and the first cell in focus. Any ideas how to do this?</p>
<p><a href="https://i.stack.imgur.com/yxnRm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yxnRm.png" alt="enter image description here" /></a></p>
<p><strong>Edit</strong>: Including my code below:</p>
<pre><code>export default function ConfirmationCode({ route, navigation }) {
const [value, setValue] = useState("")
const ref = useBlurOnFulfill({ value, cellCount: CELL_COUNT })
const [props, getCellOnLayoutHandler] = useClearByFocusCell({value, setValue})
return (
<CodeField
ref={ref}
{...props}
value={value}
onChangeText={setValue}
cellCount={CELL_COUNT}
rootStyle={styles.codeFieldRoot}
keyboardType="number-pad"
textContentType="oneTimeCode"
renderCell={({ index, symbol, isFocused }) => (
<Text
key={index}
style={[styles.cell, isFocused && styles.focusCell]}>
{symbol || (isFocused ? <Cursor /> : null)}
</Text>
)
}
/>
)
}
</code></pre>
| [
{
"answer_id": 74231674,
"author": "ritchie46",
"author_id": 6717054,
"author_profile": "https://Stackoverflow.com/users/6717054",
"pm_score": 2,
"selected": true,
"text": "arr.eval"
},
{
"answer_id": 74232926,
"author": "braaannigan",
"author_id": 5387991,
"author_pr... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231289",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2351674/"
] |
74,231,290 | <p>I'm looking to push this ObjectId from the Notes Schema: <code>635b70c1121186eefbbc5718</code></p>
<p>into the 'notesId' of this other Category Schema:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>{
_id: new ObjectId("635b70c0121186eefbbc5714"),
name: 'frenchLessons',
creator: new ObjectId("635aa97815faaa052ae9cfce"),
notesId: [],
__v: 0
}</code></pre>
</div>
</div>
</p>
<p>What I did was that I found the Category which holds both the name of the category in question and the Id of the current signed in user and tried push method but its not working:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>.then(() => {
return Category.find({ name: categoryName, creator: creator });
})
.then((category) => {
category.notesId.push(note._id); //returns TypeError: Cannot read properties of undefined (reading 'push')
return category.save();
});</code></pre>
</div>
</div>
</p>
<p><code>console.log(category)</code> returns me the correct document</p>
| [
{
"answer_id": 74231674,
"author": "ritchie46",
"author_id": 6717054,
"author_profile": "https://Stackoverflow.com/users/6717054",
"pm_score": 2,
"selected": true,
"text": "arr.eval"
},
{
"answer_id": 74232926,
"author": "braaannigan",
"author_id": 5387991,
"author_pr... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19577126/"
] |
74,231,365 | <p>thanks for looking into this. So I am trying to migrate my Apollo Server from V3 to V4, I have a resolver that type checks for an Access Token and returns it like so</p>
<pre><code>export class LoginResolver {
@Mutation(() => AccessToken)
async login(
@Arg("email") email: string,
@Arg("password") password: string,
@Ctx() { prisma, res }: ProjectContext
): Promise<AccessToken> {
// check if user exists
const user = await prisma.user.findFirst({
where: {
email,
},
});
if (!user) {
throw new GraphQLError("No user found");
}
const valid = await verify(user.password, password);
if (!valid) {
throw new GraphQLError("Invalid Password");
}
// the user logged in successully
res.cookie("*****", createRefreshToken(user), { httpOnly: true });
const accessToken = createAccessToken(user);
return {
accessToken,
};
}
}
</code></pre>
<p>It returns the following error if the validation fails.</p>
<pre><code>{
"data": {},
"error": {
"message": "JSON.parse: unexpected character at line 1 column 1 of the JSON data"
}
}
</code></pre>
<p>But however, if the right credentials were provided the API works just fine returning me a access token</p>
<pre><code>{
"data": {
"login": {
"accessToken": "..."
}
}
}
</code></pre>
<p>Correct Input:
email : email@gmail.com
password : password</p>
<p>Initially in Apollo V3 I had standard throw statements that worked just fine</p>
<pre><code> const user = await prisma.user.findFirst({
where: {
email,
},
});
if (!user) {
throw new Error("No user found");
}
const valid = await verify(user.password, password);
if (!valid) {
throw new Error("Invalid Password");
}
</code></pre>
<p>digging into Apollo server's docs I found that in V4 Apollo Error was removed and GraphQLError from graphql took it's place, I gave that a shot but that does not seem to fix it.</p>
<p>Error Message from the console :</p>
<pre><code>Unexpected error processing request: TypeError: graphqlError.toJSON is not a function
TypeError: graphqlError.toJSON is not a function
at enrichError (D:\Projects\PlacementHub\backend\node_modules\@apollo\server\src\errorNormalize.ts:84:30)
at D:\Projects\PlacementHub\backend\node_modules\@apollo\server\src\errorNormalize.ts:46:18
at Array.map (<anonymous>)
at normalizeAndFormatErrors (D:\Projects\PlacementHub\backend\node_modules\@apollo\server\src\errorNormalize.ts:39:29)
at ApolloServer.errorResponse (D:\Projects\PlacementHub\backend\node_modules\@apollo\server\src\ApolloServer.ts:1028:73)
at ApolloServer.executeHTTPGraphQLRequest (D:\Projects\PlacementHub\backend\node_modules\@apollo\server\src\ApolloServer.ts:1020:19)
</code></pre>
| [
{
"answer_id": 74231567,
"author": "Furkan Gulsen",
"author_id": 11941084,
"author_profile": "https://Stackoverflow.com/users/11941084",
"pm_score": -1,
"selected": false,
"text": "\nimport { ApolloError } from 'apollo-server-express';\n\nthrow new ApolloError(\"there is a big problem\")... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231365",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20027038/"
] |
74,231,415 | <p>I have more xml file. I need to get the MC machine lines values. What is the simples way to get these values in vb.net?
These vaues are all times in "Attr num="123"" block.</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<RadanCompoundDocument xmlns="http://www.radan.com/ns/rcd">
<RadanAttributes>
<Group class="system" name="System" desc="These attributes describe the RADAN system used to create this file."
ord="8">
<Attr num="13" name="Language" desc="RADAN language code." type="i" ord="1" value="19">
<Valid perm="r"/>
</Attr>
</Attr>
<Attr num="15" name="Build" desc="RADAN software build." type="s" ord="3" value="2022.1.2228">
<Valid perm="r"/>
</Attr>
</Group>
<Group class="custom" name="Manufacturing" desc="These attributes are the manufacturing properties of the file."
ord="6">
<Attr num="119" name="Material" desc="Material." type="s" ord="1" value="Mild Steel">
<Valid perm="e" max="100"/>
</Attr>
<Attr num="120" name="Thickness" desc="Thickness." type="r" ord="2" value="1">
<Valid perm="e" min="0" max="99999"/>
</Attr>
<Attr num="121" name="Thickness units" desc="Thickness units." type="s" ord="4" value="mm">
<Valid perm="e" expr="mm|in|swg" max="80"/>
</Attr>
<Attr num="123" name="Cycle time" desc="Cycle time in minutes." type="r" ord="26" value="0">
<Valid perm="e" min="0"/>
<MC machine="psys_CAA001_1" value="10"/>
<MC machine="psys_CAA001_2" value="20"/>
<MC machine="psys_CAA001_3" value="30"/>
<MC machine="psys_CAA001_4" value="40"/>
</Attr>
<Attr num="124" name="Sheet X" desc="Sheet length in the X direction." type="r" ord="12" value="2500">
<Valid perm="e" min="0"/>
</Attr>
<Attr num="125" name="Sheet Y" desc="Sheet length in the Y direction." type="r" ord="13" value="1250">
<Valid perm="e" min="0"/>
</Attr>
</Group>
</Group>
</RadanAttributes>
</RadanCompoundDocument>
</code></pre>
<p>Thanks!
Tibi</p>
<p>I not work similar xml before.</p>
| [
{
"answer_id": 74231567,
"author": "Furkan Gulsen",
"author_id": 11941084,
"author_profile": "https://Stackoverflow.com/users/11941084",
"pm_score": -1,
"selected": false,
"text": "\nimport { ApolloError } from 'apollo-server-express';\n\nthrow new ApolloError(\"there is a big problem\")... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19904358/"
] |
74,231,431 | <p>i'm use this code. Me need to join to one report separated data. I'm use WITH.</p>
<p>First row for choose one day before.
Next rows for choosing different errors by user.</p>
<pre><code> WITH
evt as (select * from evt_t where to_char(dzins, 'DD.MM') = to_char((sysdate - 1), 'DD.MM')),
EvaNamP as (select count(*), substr(AnwNamMld, instr(AnwNamMld, '/') + 1, LENGTH(AnwNamMld)) as "UserName", evanam from evt where evt.evanam = 'EvaNamP' group by AnwNamMld, evanam),
EvaNamE as (select count(*), substr(AnwNamMld, instr(AnwNamMld, '/') + 1, LENGTH(AnwNamMld)) as "UserName", evanam from evt where evt.evanam = 'EvaNamE' group by AnwNamMld, evanam),
LvsSrvE as (SELECT count(*), substr(AnwNamMld, instr(AnwNamMld, '/') + 1, LENGTH(AnwNamMld)) as "UserName", evanam from evt where evt.evanam = 'LvsSrvE' group by AnwNamMld, evanam)
select * from EvaNamP, EvaNamE, LvsSrvE
</code></pre>
<p>But in results group function not works. I'm seen more than 3000+ results, but in table result 240 rows. why is that?</p>
<p>Or maybe i'm choosing wrong way to make report?</p>
<p>Me need seen for example:</p>
<pre><code>UserName | EvaNamP | EvaNamE | LvsSrvE
User 23 1 9
</code></pre>
| [
{
"answer_id": 74231458,
"author": "Littlefoot",
"author_id": 9097906,
"author_profile": "https://Stackoverflow.com/users/9097906",
"pm_score": 1,
"selected": false,
"text": "evanam"
},
{
"answer_id": 74236099,
"author": "Boneist",
"author_id": 4479309,
"author_profil... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15454490/"
] |
74,231,432 | <p>I'm trying to implement a search function which returns multiple tables from a database into multiple datagridviews.</p>
<p>This is my form: <a href="https://i.stack.imgur.com/SI5QN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SI5QN.png" alt="Form image" /></a></p>
<p>I'm using each stored procedure to access each table
Each database table will correspond to one datagridview</p>
<p><strong>Stored procedure to get the Style table</strong></p>
<pre><code>CREATE PROCEDURE [dbo].[FetchCS_V2] @Keyword nvarchar(30)
AS
SELECT [RID]
,[CustomerBrand]
,[CustomerStyle]
,[ProductName]
,[ProductType]
,[ValidityDateFrom]
,[ValidityDateTo]
,[Colorway]
,[Season]
,[Factory]
FROM [dbo].[CostSheet_Mst]
WHERE RID Like '%' + @Keyword + '%'
OR CustomerStyle Like + '%'+ @Keyword + '%'
OR ProductName Like + '%'+ @Keyword + '%'
OR ProductType Like + '%'+ @Keyword + '%'
OR ValidityDateFrom Like + '%'+ @Keyword + '%'
OR ValidityDateTo Like + '%'+ @Keyword + '%'
OR Colorway Like + '%'+ @Keyword + '%'
OR Season Like + '%'+ @Keyword + '%'
OR Factory Like + '%'+ @Keyword + '%'
GO
</code></pre>
<p><strong>Stored procedure to get the FOB table</strong></p>
<pre><code>CREATE PROCEDURE [dbo].[FetchCS_FOB_V2] @Keyword nvarchar(30)
AS
SELECT [FobRID]
,[RID]
,[FOBType]
,[Amount]
,[Currency]
FROM [dbo].[CostSheet_FOB]
WHERE RID IN
(SELECT
[RID]
FROM CostSheet_Mst
where [RID] LIKE + '%' + @Keyword + '%')
OR [FOBType] LIKE + '%' + @Keyword + '%'
OR [Amount] LIKE + '%' + @Keyword + '%'
OR [Currency] LIKE + '%' + @Keyword + '%'
GO
</code></pre>
<p><strong>This is the function that searches from the database</strong></p>
<pre><code> private void searchFromDB()
{
try
{
string mainconn1 = ConfigurationManager.ConnectionStrings["MyConnection"].ConnectionString;
SqlConnection sqlconn = new SqlConnection(mainconn1);
SqlCommand sqlcomm1 = new SqlCommand("exec [dbo].[FetchCS_V2] '"+searchTextBox.Text+"'", sqlconn); //stored procedure for master database table
SqlCommand sqlcomm2 = new SqlCommand("exec [dbo].[FetchCS_FOB_V2] '" + searchTextBox.Text + "'", sqlconn); //stored procedure for FOB tablew
//sqlcomm1.CommandType = CommandType.StoredProcedure;
SqlDataAdapter da1 = new SqlDataAdapter();
SqlDataAdapter da2 = new SqlDataAdapter();
da1.SelectCommand = sqlcomm1;
da2.SelectCommand = sqlcomm2;
DataTable dt1 = new DataTable();
DataTable dt2 = new DataTable();
da1.Fill(dt1);
da2.Fill(dt2);
dataGridViewStyleSearch.DataSource = dt1;
dataGridViewFOBSearch.DataSource = dt2;
sqlconn.Close();
}
catch (Exception ex)
{
MessageBox.Show(string.Format("There's an error: {0}", ex.Message), "Error", MessageBoxButtons.OK, MessageBoxIcon.Error);
}
}<br>
</code></pre>
<p>`</p>
<p>Currently, the search function can return rows in multiple datagridviews if the search keyword is the RID
<img src="https://i.stack.imgur.com/yAxr1.png" alt="enter image description here" />]</p>
<p>However, if I search a field only present in the FOB table, then it'll only return the rows in that datagridview
<a href="https://i.stack.imgur.com/gAgOT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gAgOT.png" alt="enter image description here" /></a></p>
<p><br><br></p>
<p>Also, I wonder if using one stored procedure to select fields from all tables would be better?</p>
<p>Then I can put that into one datatable and split it (not sure how to implement that tho)</p>
| [
{
"answer_id": 74231458,
"author": "Littlefoot",
"author_id": 9097906,
"author_profile": "https://Stackoverflow.com/users/9097906",
"pm_score": 1,
"selected": false,
"text": "evanam"
},
{
"answer_id": 74236099,
"author": "Boneist",
"author_id": 4479309,
"author_profil... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14655520/"
] |
74,231,455 | <p>I have to generate 13 objects in random the output must in ascending order or from highest in ranking, it is as follows</p>
<p>Order of suits from lowest to highest is Clubs, Diamonds, Hearts, Spades
order of values from lowest to highest is 2, 3, 4, 5, 6, 7, 8, 9, 10, J, Q, K, A</p>
<p>My code prints 13 random cards but there is no order. How can I sort it according to the ranking above?</p>
<p>This is my code:</p>
<pre><code>import itertools
import random
value = ['A','2','3','4','5','6','7','8','9','10','J','Q','K']
suits = ['C','D','H','S']
deck = list(itertools.product(vals, suits))
random.shuffle(deck)
for val, suit in deck:
print('%s-%s' % (val, suit))
</code></pre>
<p>The output should look like this:</p>
<pre><code>A-C,2-C,3-C,4-C,5-C,6-C,7-C,8-C,9-C,10-C,J-C,Q-C,K-C
</code></pre>
| [
{
"answer_id": 74231574,
"author": "Chris",
"author_id": 15261315,
"author_profile": "https://Stackoverflow.com/users/15261315",
"pm_score": 1,
"selected": false,
"text": "sep"
},
{
"answer_id": 74231608,
"author": "Joshua",
"author_id": 17608766,
"author_profile": "h... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231455",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20143499/"
] |
74,231,456 | <p>Let's say I have two tables called <code>schools</code> and <code>students</code> which have a one-to-many relationship. Each student can only be in one school but each school can have many students.</p>
<pre><code>school
-----------
id
name
student
-----------
id
name
school_id
</code></pre>
<p>I need to find the 90th percentile of the number of students each school has.</p>
<p>I can already sort the schools based on the student count, but I don't know how to get the percentile.</p>
<pre class="lang-sql prettyprint-override"><code>select school_id, count(id) as count from students
group by school_id
order by count desc
</code></pre>
| [
{
"answer_id": 74231574,
"author": "Chris",
"author_id": 15261315,
"author_profile": "https://Stackoverflow.com/users/15261315",
"pm_score": 1,
"selected": false,
"text": "sep"
},
{
"answer_id": 74231608,
"author": "Joshua",
"author_id": 17608766,
"author_profile": "h... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5519314/"
] |
74,231,459 | <p>I'm producing a text file (in zsh on MacOS) containing pathnames and their associated checksums.</p>
<pre><code># finding all the files in a directory and checksumming them
find . -type f -exec md5 -r {} \; > file1.txt
# sorting the file by the first field (checksum)
LC_ALL=C sort -k 1,1 file1.txt > file2.txt
# using awk to keep all/only lines with duplicated first/checksum fields
# (i.e., duplicate files in the directory)
# I found this awk on the net and it works
# yes, the input file is read twice
awk 'FNR==NR{a[$1]++;next}(a[$1] > 1)' file2.txt file2.txt > file3.txt
</code></pre>
<p>You can produce a sample file by executing the three commands above on the directory of your choice. Here's a short sample:</p>
<pre class="lang-none prettyprint-override"><code>0c1fe4bd35f263f1eb3944c3bd6036e7 ./photoshop-conversion/pano-work-02.psb
0c1fe4bd35f263f1eb3944c3bd6036e7 ./photoshop-conversion1/pano-work-02.psb
0d47004b36229ed68a7c1d820bc7bfa3 ./photoshop-conversion3/pano-03.psb
0d47004b36229ed68a7c1d820bc7bfa3 ./photoshop-conversion4/pano-03.psb
0d47004b36229ed68a7c1d820bc7bfa3 ./photoshop-conversion5/pano-03.psb
0d47004b36229ed68a7c1d820bc7bfa3 ./photoshop-conversion6/pano-03.psb
101e5579acc8389796d0155461ef5183 ./photoshop-conversion5/pano-01.psb
101e5579acc8389796d0155461ef5183 ./photoshop-conversion6/pano-01.psb
</code></pre>
<p>At this point, file3.txt lists all the checksum & pathnames (that have duplicated checksums), but there is no white-space (blank lines). I want to add blank lines between the groupings of 2 or more lines with duplicate first fields (in order to make the listing human-readable). This can be done either by another discreet stage (producing file4.txt from file3.txt) or by modifying the prior awk stage to insert new-lines between lines that have different first fields (as file3.txt is produced).</p>
<p>This would do something like:</p>
<pre><code>if (first-field-of-current-line ^= first-field-of-next-line)
then insert new-line after end-of-current-line
</code></pre>
<p>This would result (in the sample above) inserting a blank line between the 2nd and 3rd lines and between the 6th and 7th lines.</p>
<p>I don't care how it's done -- awk, sed, grep -- so long as it's available for zsh in MacOS.</p>
<p>Extra points if you can count how many groups there are (i.e., how many new-lines get inserted).</p>
<p>I've tried to change the awk line herein, but I don't understand it well enough not to break it.</p>
| [
{
"answer_id": 74233992,
"author": "Gairfowl",
"author_id": 9307265,
"author_profile": "https://Stackoverflow.com/users/9307265",
"pm_score": 0,
"selected": false,
"text": "zsh"
},
{
"answer_id": 74234098,
"author": "tripleee",
"author_id": 874188,
"author_profile": "... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20355311/"
] |
74,231,561 | <p>i defined two separate functions for opening url with selenium, and fetching data with selenium.
In my second function <code>driver</code> variable is unassignable because it stays local inside first function.
I do not know if it s logical to separate selenium activity in two separate ways, I use this method first time.
Any suggestions to take instance of webdriver and use it inside second function?</p>
<pre><code>import pandas as pd
from selenium.webdriver.chrome.service import Service
from selenium.webdriver.chrome.options import Options
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
#reading from csv file url-s
def readCSV(path_csv):
df=pd.read_csv(path_csv)
return df
fileCSV=readCSV(r'C:\Users\Admin\Downloads\urls.csv')
length_of_column_urls=fileCSV['linkamazon'].last_valid_index()
#going to urls 1-by-1
def goToUrl_Se():
for i in range(0, length_of_column_urls + 1):
xUrl = fileCSV.iloc[i, 1]
print(xUrl,i)
# going to url(a,amazn) via Selenium WebDriver
chrome_options = Options()
chrome_options.headless = False
chrome_options.add_argument("start-maximized")
# options.add_experimental_option("detach", True)
chrome_options.add_argument("--no-sandbox")
chrome_options.add_experimental_option("excludeSwitches", ["enable-automation"])
chrome_options.add_experimental_option('excludeSwitches', ['enable-logging'])
chrome_options.add_experimental_option('useAutomationExtension', False)
chrome_options.add_argument('--disable-blink-features=AutomationControlled')
webdriver_service = Service(r'C:\pythonPro\w_crawl\AmznScrpBot\chromedriver.exe')
driver = webdriver.Chrome(service=webdriver_service, options=chrome_options)
driver.get(xUrl)
driver.quit()
#fetch-parse the data from url page
def parse_data():
x_title=driver.find_element(By.XPATH,'//*[@id="search"]/div[1]/div[1]/div/span[3]/div[2]/div[2]/div/div/div/div/div/div[2]/div/div/div[1]/h2/a/span')
goToUrl_Se()
</code></pre>
| [
{
"answer_id": 74231613,
"author": "Dmitriy Neledva",
"author_id": 16786350,
"author_profile": "https://Stackoverflow.com/users/16786350",
"pm_score": 0,
"selected": false,
"text": "parse_data"
},
{
"answer_id": 74231833,
"author": "Prophet",
"author_id": 3485434,
"au... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17917443/"
] |
74,231,562 | <p>We are getting the below error while fetching the orders on opencart.</p>
<p>error:</p>
<pre><code>{"status":200,"data":"\"Error: You have an error in your SQL syntax; check the manual that corresponds to your MariaDBserver version for the right syntax to use near 'order ORDER BY order_id DESC' at line 1<br \\\/>Error No: 1064<br \\\/>SELECT * FROM order ORDER BY order_id DESC\""}
</code></pre>
<p>please help</p>
<p>I am using opencart 3.0.3.8</p>
<p>I am new to opencart, still learning it so I didn't find a solution for the same. I need help here.</p>
| [
{
"answer_id": 74231613,
"author": "Dmitriy Neledva",
"author_id": 16786350,
"author_profile": "https://Stackoverflow.com/users/16786350",
"pm_score": 0,
"selected": false,
"text": "parse_data"
},
{
"answer_id": 74231833,
"author": "Prophet",
"author_id": 3485434,
"au... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231562",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18289949/"
] |
74,231,580 | <p>When I submit the info, the console.log gives me back a user.user.uid value. But when setting the value to a variable using useState, it sets the value as null and passes null value to userInfo function. userInfo is also an async function. Why is that?</p>
<pre><code> const handleSubmit = async (e, email, password) => {
e.preventDefault();
try {
const user = await createUserWithEmailAndPassword(auth, email, password);
console.log(user.user.uid);
await setUserId(user.user.uid);
} catch (e) {
console.log(e);
}
await userInfo(email, password, userId);
};
</code></pre>
| [
{
"answer_id": 74231630,
"author": "m4china",
"author_id": 15814542,
"author_profile": "https://Stackoverflow.com/users/15814542",
"pm_score": 1,
"selected": false,
"text": "setUserId"
},
{
"answer_id": 74231708,
"author": "KcH",
"author_id": 11737596,
"author_profile... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16261114/"
] |
74,231,595 | <p>The following basic code is used to handle requests from Angular client:</p>
<pre class="lang-js prettyprint-override"><code>/************************************************************************/
/* Launch HTTP server
/************************************************************************/
http.createServer (function(req,res) {
let data='';
req.on ('data', chunk => {
//console.log (`Data chunk: ${chunk}`);
//append chunk to data (can be multiple chuncks for 1 request)
data += chunk;
});
req.on ('end', chunks => {
//console.log (`End chunks: ${data}`);
//Do something with request
});
}).listen (8000);
</code></pre>
<p>The HTTP request is converted to TCP raw message and sent to 3rd party server. This external server sends back TCP response which is sent to the Angular client.</p>
<p>The response sent back from Node.js to the client is not according to the order of original requests.
So an HTTP request in the client is getting a wrong response.
The client has multiple timers each sending a request every 1 second.</p>
<p>I want that while a client request is handled, Node.js will not accept any other new messages.</p>
| [
{
"answer_id": 74231630,
"author": "m4china",
"author_id": 15814542,
"author_profile": "https://Stackoverflow.com/users/15814542",
"pm_score": 1,
"selected": false,
"text": "setUserId"
},
{
"answer_id": 74231708,
"author": "KcH",
"author_id": 11737596,
"author_profile... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6431715/"
] |
74,231,599 | <pre><code>list_of_dict = [
{
'@id': '54',
'@name': '009de580ae2a20ad.jpg',
'@width': '1080',
'@height': '720',
'box': {
'@label': 'Television',
'@occluded': '0',
'@source': 'manual',
'@xtl': '130.40833715734814',
'@ytl': '148.36237211407877',
'@xbr': '171.88589300809082',
'@ybr': '225.55914893617017',
'@z_order': '0'
}
},
{
'@id': '53',
'@name': '008f7096b1917873.jpg',
'@width': '1080',
'@height': '720',
'box': [
{
'@label': 'Ball',
'@occluded': '0',
'@source': 'manual',
'@xtl': '142.5709551986475',
'@ytl': '340.4156088727931',
'@xbr': '160.269078613694',
'@ybr': '369.9085559076505',
'@z_order': '0'
},
{
'@label': 'Ball',
'@occluded': '0',
'@source': 'manual',
'@xtl': '128.40823088998914',
'@ytl': '55.6182888184699',
'@xbr': '149.14524815843498',
'@ybr': '100.27719330013579',
'@z_order': '0'
},
{
'@label': 'Ball',
'@occluded': '0',
'@source': 'manual',
'@xtl': '82.38818017147688',
'@ytl': '0.005866908103214124',
'@xbr': '112.22427243086584',
'@ybr': '43.825803531009505',
'@z_order': '0'
}
]
},
{
'@id': '52',
'@name': '008d4f07e70a3a71.jpg',
'@width': '1080',
'@height': '720',
'box': {
'@label': 'Ball',
'@occluded': '0',
'@source': 'manual',
'@xtl': '68.81703658978385',
'@ytl': '22.3059846084201',
'@xbr': '85.00099504890713',
'@ybr': '46.741656858306925',
'@z_order': '0'
}
}
]
</code></pre>
<p>convert this list of dicts to dataframe?
can anyone send the possible answers</p>
<pre class="lang-none prettyprint-override"><code> @id @name @width @height box.@label box.@occluded \
0 59 00a3c8ba34448111.jpg 1080 720 Bird 0
1 58 00a2fa166f338907.jpg 1080 720 Bird 0
2 57 00a0793a49ea232b.jpg 1080 720 Bird 0
3 56 00a00bb929a41617.jpg 1080 720 Bird 0
4 55 009e6695349f0ca6.jpg 1080 720 Ball 0
5 54 009de580ae2a20ad.jpg 1080 720 Television 0
6 53 008f7096b1917873.jpg 1080 720 NaN NaN
box.@source box.@xtl box.@ytl box.@xbr \
0 manual 76.87732399468662 182.8539248528746 221.00822122932013
1 manual 69.87695205893009 24.095391579900408 316.86542688081147
2 manual 22.649090689530247 88.50817564508829 247.66808839512137
3 manual 19.677101799299603 37.27246717971933 359.52614418548484
4 manual 236.25551020408162 384.8457039384337 260.53144789276655
5 manual 130.40833715734814 148.36237211407877 171.88589300809082
6 NaN NaN NaN NaN
</code></pre>
| [
{
"answer_id": 74231630,
"author": "m4china",
"author_id": 15814542,
"author_profile": "https://Stackoverflow.com/users/15814542",
"pm_score": 1,
"selected": false,
"text": "setUserId"
},
{
"answer_id": 74231708,
"author": "KcH",
"author_id": 11737596,
"author_profile... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20355439/"
] |
74,231,626 | <p><img src="https://i.stack.imgur.com/0WXaV.png" alt="img1" /></p>
<p><img src="https://i.stack.imgur.com/0WXaV.png" alt="img2" /></p>
<p>I am trying to get that text box at the bottom of the page to align with the second image down so that it is in the bottom right corner. I have made a big div containing the images and text.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>body {
background-color:rgb(white);
margin: 0px;
padding: 0px;
}
p {
margin-left: 200px;
margin-right: 200px;
text-align: left;
font-size: 22px;
}
.centre {
display: block;
margin-left: auto;
margin-right: auto;
width: 70%;
border-radius: 5px;
margin-bottom: 20px;
}
h1 {
margin-top:10px;
text-align:center;
}
nav{
margin-top:0px;
width:100%;
background:rgb(97, 157, 255);
overflow:auto;
}
nav a{
display: block;
padding:20px 15px;
text-decoration: none;
font-family: arial;
color:white;
text-align:center;
}
nav a:hover{
background-color:rgb(203, 204, 212);
transition:0.4s;
}
ul{
padding:0;
margin:0 250px;
list-style:none;
margin-left: 200px;
position: fixed top;
}
li{
margin-bottom:-4px;
margin-top:-2.5px;
font-size: 24px;
float:left;
}
.logo1 img{
position:absolute;
margin-top:0px;
margin-right: 100px;
width:16%;
}
.collage{
display: block;
margin:auto;
width:70%;
border:1.5px solid rgba(112, 128, 144, 0.5);
}
.collage img{
width:40%;
height:300px;
display: inline-block;
}
.collage p{
border:1.5px solid rgba(112, 128, 144, 0.5);
display: inline-block;
vertical-align: bottom;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPEhtml>
<html>
<head>
<title>Home</title>
<link rel="stylesheet" href="layout_91893.css">
</head>
<body>
<div class="logo1">
<a href = "index_91893.html"><img src="Maunga_Club_white.png"></a>
</div>
<nav>
<ul>
<li><a href = "page1_91893.html">Available Cabins</a></li>
<li><a href = "membership_91893.html">Club Membership</a></li>
<li><a href = "#">Bookings</a></li>
<li><a href = "#">About Us</a></li>
<li><a href = "#">FAQ</a></li>
</ul>
</nav>
<p style="text-align:center;"> Enjoy the winter season with your family and friends in our premium cabins and chalets based on the Maunga Summit.</p>
<h1>The Kakapo Chalet</h1>
<img src="cabin_exterior.jpg" alt="picture" class="centre">
<div class="collage">
<img src="bunk_room.jpg" alt="picture">
<img src="cabin_view.jpg"alt="picture">
<img src="hallway.jpg">
<p> The Kakapo Chalet is a great choice for a medium to large number of guests.</p>
</div>
</html></code></pre>
</div>
</div>
</p>
<p>not too sure if a lot of the code in my CSS is relevant either but I've just been experimenting with inline blocks and stuff like that. Can someone please show me how I can align the text with the image?</p>
<p>expected the text box to align with bottom left image.</p>
| [
{
"answer_id": 74231801,
"author": "Professor Abronsius",
"author_id": 3603681,
"author_profile": "https://Stackoverflow.com/users/3603681",
"pm_score": 1,
"selected": false,
"text": "Flexbox"
},
{
"answer_id": 74231897,
"author": "vee",
"author_id": 128761,
"author_p... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17891006/"
] |
74,231,642 | <p>I have case in which I want same autoincrement value in new created column for same business code
I have tried below but I am not getting expected result</p>
<pre><code>select *
, rank() over (partition by business_code order by ID)
from table
</code></pre>
<p>I am getting same same value in ID column for all business code which is not desired result.</p>
<p>My Output</p>
<p><a href="https://i.stack.imgur.com/BYV4I.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BYV4I.png" alt="Id businesscode NewColumn
1 eng 1
2 mkr 1
3 eng 2
4 fin 1
5 mkr 2" /></a></p>
<p>Expected Output</p>
<p><a href="https://i.stack.imgur.com/dzdyP.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dzdyP.png" alt="Id businesscode NewColumn
1 eng 1
2 mkr 2
3 eng 1
4 fin 3
5 mkr 2" /></a></p>
| [
{
"answer_id": 74231682,
"author": "HarshP",
"author_id": 20248555,
"author_profile": "https://Stackoverflow.com/users/20248555",
"pm_score": -1,
"selected": false,
"text": "select row_number() over (order by (select null)), a.*\nfrom Table a;\n"
},
{
"answer_id": 74231935,
"... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231642",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13060536/"
] |
74,231,652 | <p>I just start to explore <code>redis</code>. I want to cache some data using redis. I set up redis connection in the <code>server.ts</code> file and export it from there. Import it in my controller function and try to use set and get but this error comes for both get and set.</p>
<pre><code>TypeError: Cannot read properties of undefined (reading 'get')
</code></pre>
<pre><code>//sever.js---> redis connection part
export const client = redis.createClient({
url: "redis://127.0.0.1:6379",
});
client.connect();
client.on("error", (err) => console.log("Redis Client Error", err));
const app: Application = express();
</code></pre>
<pre><code>//controller
import { client } from "../server";
const allProjects = async (req: Request, res: Response): Promise<void> => {
const cachedProjects = await client.get("projects");
if (cachedProjects) {
res.status(200).json(JSON.parse(cachedProjects));
}
const projects = await Projects.find({});
if (!projects) {
res.status(400).send("No projects found");
throw new Error("No projects found");
}
await client.set("projects", JSON.stringify(projects));
res.status(200).json(projects);
};
</code></pre>
<p>My Redis server is running and I can use set/get using <code>redis cli</code>. I make a mistake somewhere but can't find it.</p>
<p>I am using Node.js, Express.js and Typescript</p>
| [
{
"answer_id": 74232074,
"author": "Alexey Khachatryan",
"author_id": 8913631,
"author_profile": "https://Stackoverflow.com/users/8913631",
"pm_score": 0,
"selected": false,
"text": "//sever.js---> redis connection part\nconst client = await redis.createClient({\n url: \"redis://127.0.0... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12874095/"
] |
74,231,655 | <p>I have a userform with a lot of controls (Checkboxes , OptionButtons ,…).<br>
But my concern here about only 3 checkboxes combined in one frame. <br>
The names of the respective checkboxes are <strong>A1_CB</strong> , <strong>B2_CB</strong> , <strong>C3_CB</strong> <br>
The cited checkboxes have a click event code either value of each CB is True or False. <br>
I need at most only one check from them to be true on a time, <br>
<strong>Meaning</strong> if A1_CB = True and I clicked B2_CB then both (A1_CB & C3_CB) = false , <br>
and If possible <strong>suppress</strong> codes of (A1_CB & C3_CB) when they are unchecked. <br></p>
<p>I tried this code but it has no effect and loop itself: <br></p>
<pre><code>Private Sub A1_CB_Click()
Me.B2_CB.Value = False
End Sub
Private Sub B1_CB_Click()
Me.A1_CB.Value = False
End Sub
</code></pre>
<p>As always, grateful for all your help. <br></p>
| [
{
"answer_id": 74232092,
"author": "FaneDuru",
"author_id": 2233308,
"author_profile": "https://Stackoverflow.com/users/2233308",
"pm_score": 3,
"selected": true,
"text": "Option Explicit\n\nPrivate boolNoEvents As Boolean\n\nPrivate Sub A1_CB_Click()\n If Not boolNoEvents Then\n ... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231655",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17797849/"
] |
74,231,663 | <h3>Question</h3>
<p>How can I have the text color change dynamically when the theme changes?</p>
<h3>Problem</h3>
<p><a href="https://i.stack.imgur.com/zUf8Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zUf8Y.png" alt="TextView" /></a></p>
<p>Text color dynamically changes when the theme is changed</p>
| [
{
"answer_id": 74232092,
"author": "FaneDuru",
"author_id": 2233308,
"author_profile": "https://Stackoverflow.com/users/2233308",
"pm_score": 3,
"selected": true,
"text": "Option Explicit\n\nPrivate boolNoEvents As Boolean\n\nPrivate Sub A1_CB_Click()\n If Not boolNoEvents Then\n ... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,231,698 | <p>So I have a problem that is ,I have an integer array and first I define an interval as a good interval iff, within the interval every integer appears an even (including zero) number of times. I want to find the number of good intervals in a given integer array. For example, if array = [7, 7, 1, 5, 5, 1], the good intervals are [1, 2], [3, 6], [4, 5], [1, 6] corresponding to the contiguous subarrays [7, 7], [1, 5, 5, 1], [5, 5], [7, 7, 1, 5, 5, 1]. If array = [4, 5, 6, 5, 4], then there are no good intervals.</p>
<p>I have a naive solution which would be to use 2 for loops and check for every possible interval whether there is a good interval but this takes O(n^2) time. I want to find a better solution that runs in O(nlogn) time and I feel that using hashing may give me a faster solution, the problem is I do not know how to incorporate it into my answer. I have been reading up on the rolling robin-karp hashing algorithm to give me some ideas but I think that this algorithm is not applicable to what I seek. Do you guys have any ideas for an algorithm to solve this in O(nlogn) time that uses hashing?</p>
| [
{
"answer_id": 74234179,
"author": "Paul Hankin",
"author_id": 1400793,
"author_profile": "https://Stackoverflow.com/users/1400793",
"pm_score": 3,
"selected": true,
"text": "B[0] = 0\nB[i+1] = HASH(A[i]) XOR B[i]\n"
},
{
"answer_id": 74241501,
"author": "Dave",
"author_i... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231698",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20355806/"
] |
74,231,774 | <pre><code>$arr = ['Governance->Policies->Prescriptions->CAS Alerts',
'Users->User Departments->Department Hierarchy',
'Settings->Registrar->Finance',
'Logs->Second Opinion Log'];
</code></pre>
<p>This is array and I want to convert it into string like below
The string should be one it just concate in one string.</p>
<pre><code>Governance->Policies
Governance->Prescriptions
Governance->CAS Alerts
Users->User Departments
Users->Department Hierarchy
Settings->Registrar
Settings->Finance
Logs->Second Opinion Log
</code></pre>
<pre><code>$arr = ['Governance->Policies->Prescriptions->CAS Alerts',
'Users->User Departments->Department Hierarchy',
'Settings->Registrar->Finance',
'Logs->Second Opinion Log'];
$temp = '';
for($i = 0; $i < count($arr); $i++){
$arrVal = [];
$arrVal = explode('->',$arr[$i]);
if(count($arrVal) > 1){
for($j=0; $j < count($arrVal); $j++){
if($j == 0){
$temp .= $arrVal[$j];
}else{
$temp .='->'.$arrVal[$j]."\n";
if($j == count($arrVal) - 1){
$temp .= "\n";
}else{
$temp .= substr($temp, 0, strpos($temp, "->"));
}
}
}
}
}
echo $temp;
</code></pre>
| [
{
"answer_id": 74232200,
"author": "Naveen",
"author_id": 20306839,
"author_profile": "https://Stackoverflow.com/users/20306839",
"pm_score": 1,
"selected": true,
"text": "<?php\n//This might help full\n$arr = ['Governance->Policies->Prescriptions->CAS Alerts',\n 'Users->User Depa... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19487804/"
] |
74,231,775 | <p>I am getting null value from api with variable of storeUserID, in this variable i stored user id at the time of register but when i run app it shows null value.
But when i manully type id like this <strong><a href="https://aeliya.000webhostapp.com/demo.php?id=106764933065187174744" rel="nofollow noreferrer">https://aeliya.000webhostapp.com/demo.php?id=106764933065187174744</a></strong> is shows me data.</p>
<pre><code>//get users details
Future<GetUserData> getUserDetail() async {
var url = "https://aeliya.000webhostapp.com/demo.php?id=$storeUserID";
var response = await http.get(Uri.parse(url));
var data = jsonDecode(response.body.toString());
if (response.statusCode == 200) {
print(data);
print(storeUserID);
//print(data[0]['isAdmin']);
return GetUserData.fromJson(data);
} else {
return GetUserData.fromJson(data);
}
}
</code></pre>
<p>at the same time i am getting following error.</p>
<blockquote>
<p>E/flutter (13406): [ERROR:flutter/runtime/dart_vm_initializer.cc(41)]
Unhandled Exception: type 'String' is not a subtype of type 'int' of
'index' E/flutter (13406): #0 new GetUserData.fromJson
(package:mahuva_azadari/Models/GetUserData.dart:19:17) E/flutter
(13406): #1 _AdminReqState.getUserDetail
(package:mahuva_azadari/Screens/Admin%20Request.dart:352:26) E/flutter
(13406): </p>
</blockquote>
<p>Following is my response:</p>
<pre><code> [{"name":"Taki Rajani","email":"mohammadtaki.rajani@gmail.com","isAdmin":"0","description":"testing "}]
</code></pre>
<p><strong>GetUserData</strong></p>
<pre><code>/// name : "Taki Rajani"
/// email : "mohammadtaki.rajani@gmail.com"
/// isAdmin : "0"
/// description : "testing "
class GetUserData {
GetUserData({
String? name,
String? email,
String? isAdmin,
String? description,}){
_name = name;
_email = email;
_isAdmin = isAdmin;
_description = description;
}
GetUserData.fromJson(dynamic json) {
_name = json['name'];
_email = json['email'];
_isAdmin = json['isAdmin'];
_description = json['description'];
}
String? _name;
String? _email;
String? _isAdmin;
String? _description;
GetUserData copyWith({ String? name,
String? email,
String? isAdmin,
String? description,
}) => GetUserData( name: name ?? _name,
email: email ?? _email,
isAdmin: isAdmin ?? _isAdmin,
description: description ?? _description,
);
String? get name => _name;
String? get email => _email;
String? get isAdmin => _isAdmin;
String? get description => _description;
Map<String, dynamic> toJson() {
final map = <String, dynamic>{};
map['name'] = _name;
map['email'] = _email;
map['isAdmin'] = _isAdmin;
map['description'] = _description;
return map;
}
}
</code></pre>
| [
{
"answer_id": 74232200,
"author": "Naveen",
"author_id": 20306839,
"author_profile": "https://Stackoverflow.com/users/20306839",
"pm_score": 1,
"selected": true,
"text": "<?php\n//This might help full\n$arr = ['Governance->Policies->Prescriptions->CAS Alerts',\n 'Users->User Depa... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231775",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19458028/"
] |
74,231,794 | <p>I'm coding a webpage that needs to read some data from different csv on a path depending on the country of the user.</p>
<p>the path is something like this:</p>
<pre><code>./csv/m2-2022-10-25_13_45_55_es.csv
m2-2022-10-25_13_45_56_fr.csv
m2-2022-10-25_13_46_04_it.csv
etc
</code></pre>
<p>And those files will be replaced regularly, the only that we'll always have is the country code (es, fr, it, etc).</p>
<p>So, what I need is to list all the files on the path to an array, and loop through the array to find if the last characters of the filename are $countryCode + ".csv", and there run some code.</p>
<p>But I can't find how, all the solutions I find are using Node.js, but are there a solution using only Javascript (or jQuery)?</p>
<p>Regards!</p>
| [
{
"answer_id": 74232200,
"author": "Naveen",
"author_id": 20306839,
"author_profile": "https://Stackoverflow.com/users/20306839",
"pm_score": 1,
"selected": true,
"text": "<?php\n//This might help full\n$arr = ['Governance->Policies->Prescriptions->CAS Alerts',\n 'Users->User Depa... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231794",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17823910/"
] |
74,231,810 | <p>I'm trying to create photo and description shown below.</p>
<p>How to replace the "read more" and "read less" with arrow icon(up and down)?</p>
<pre class="lang-html prettyprint-override"><code><template>
<v-col cols="6" >
<row align="center" justify="center">
<div id="app" class="container">
<p>A simple Read More, Read Less pen in Vue.js</p>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Venenatis lectus magna
fringilla urna. Etiam tempor orci eu lobortis. Integer quis auctor elit sed vulputate mi sit. Lacinia
at quis risus sed vulputate odio ut enim blandit. Nibh praesent tristique magna sit amet purus. Eleifend donec pretium vulputate sapien nec
sagittis. Facilisi morbi tempus iaculis urna id volutpat. Ultrices neque ornare aenean euismod.<span v-if="readMore"></span>
<span v-else>...</span>
</p>
<p v-show="readMore">Ligula ullamcorper malesuada proin libero nunc consequat interdum varius. Turpis egestas pretium aenean pharetra magna ac
placerat. Sed egestas egestas fringilla phasellus faucibus scelerisque eleifend donec. Sed cras ornare arcu dui. Aliquam vestibulum
morbi blandit cursus. Adipiscing elit ut aliquam purus sit amet. Aenean sed adipiscing diam donec adipiscing tristique risus nec. Ut etiam sit amet
nisl purus in mollis. Eu mi bibendum neque egestas congue quisque egestas diam in. Pellentesque adipiscing
commodo elit at imperdiet dui accumsan sit.
</p>
<button class="btn btn-success" @click="readMore =! readMore">
<span v-if="readMore">Read Less</span>
<span v-else>Read More</span>
</button>
</div>
</row>
</v-col>
</v-col>
</code></pre>
<p>Here is the boolean</p>
<pre class="lang-html prettyprint-override"><code><script>
data() {
readMore: false
}
</script>
</code></pre>
| [
{
"answer_id": 74232125,
"author": "Boussadjra Brahim",
"author_id": 8172857,
"author_profile": "https://Stackoverflow.com/users/8172857",
"pm_score": 2,
"selected": true,
"text": "v-icon"
},
{
"answer_id": 74248200,
"author": "Russ Deneychuk",
"author_id": 14580524,
... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19664882/"
] |
74,231,828 | <p>I have 3 services that are based on the same image, they're basically running the same app in 3 different configurations. 1 service is responsible for running migrations and data updates which the other 2 services will need. So I need this 1 service to be deployed first before the other 2 will be deployed. Is there any way to do this?</p>
| [
{
"answer_id": 74232125,
"author": "Boussadjra Brahim",
"author_id": 8172857,
"author_profile": "https://Stackoverflow.com/users/8172857",
"pm_score": 2,
"selected": true,
"text": "v-icon"
},
{
"answer_id": 74248200,
"author": "Russ Deneychuk",
"author_id": 14580524,
... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6462678/"
] |
74,231,834 | <p>Write a Python program that takes an English phrasing of a <code>number</code> as a string <code>s</code> and outputs
the corresponding integer <code>x</code>. You can assume the <code>number</code> is positive and less than <code>1,000,000</code>. You can also
assume that the <code>s</code> is always correct. <code>s</code> does not contain any spaces.</p>
<p>So far, I have my dictionary</p>
<pre><code>'# ones
num2words = {'one': '1', 'two':2, 'three':3, 'four':4, 'five':5, 'six':6, 'seven':'7', 'eight':8, 'nine':9}
'# tens
num2words.update ({'ten':10, 'eleven':11, 'twelve':12, 'thirteen':13, 'fourteen':14, 'fifteen':15, 'sixteen':16,
'seventeen':17, 'eighteen':18, 'nineteen':19})
'# twenty-ninety
num2words.update ({'twenty':'20', 'thirty': '30', 'fourty':40, 'fifty':50, 'sixty':60, 'seventy':70, 'eighty':80,
'ninety':90})
'# hundred, thousand, million, zero
num2words.update ({'hundred':'100', 'thousand':1000, 'million':1000000, 'zero':0})
</code></pre>
<p>and I don't know how to get started with writing this program. I've looked up examples, but the strings usually have a space or dash separating them for example (twenty-seven or twenty seven) instead of (twentyseven or onehundredfiftysixthousandthreehundredtwentyseven) just some guidance in how to start my program would be greatly appreciated.</p>
| [
{
"answer_id": 74231903,
"author": "user13322060",
"author_id": 13322060,
"author_profile": "https://Stackoverflow.com/users/13322060",
"pm_score": 1,
"selected": false,
"text": "import re\n\ntxt = \"twenty seven\"\ntxt = \"twenty-seven\"\nx = re.search(\"twenty.*seven\", txt)\nprint(x)\... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231834",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18574542/"
] |
74,231,879 | <p>I try to split url with '?' and use the second element on html</p>
<p>example:</p>
<pre><code>https://url/page?google.com
</code></pre>
<p>the output I want to receive is: <code>google.com</code></p>
<p>and redirect the page to the output, I'm using webflow so if anyone can help with a full script it will be amazing.</p>
<p>I tried:</p>
<pre><code>window.location.replace(id="new_url");
let url = window.location;
const array = url.split("?");
document.getElementById("new_url").innerHTML = array[1];
</code></pre>
<p>but it doesn't work :(</p>
| [
{
"answer_id": 74231980,
"author": "Marcel Weber",
"author_id": 15121850,
"author_profile": "https://Stackoverflow.com/users/15121850",
"pm_score": -1,
"selected": false,
"text": "const inputUrl = window.location.href // ex. https://url/page?google.com\nconst splitUrl = inputUrl.split(\"... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231879",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14443190/"
] |
74,231,883 | <p>Below is the HTML, I am working on and I am trying to get "Gardroplar" text but it return me empty</p>
<p>start with <code><ol class="nav align-items-center flex-nowrap text-nowrap overflow-auto hide-scrollbar></code></p>
<pre><code><li>
<a href="/">
<svg class="icon-home m-0">
<use
xlink:href="/_ui/responsive/theme-alpha/images/icons.svg#icon-home"
></use>
</svg>
</a>
</li>
<li>
<svg class="icon-arrow2 m-0">
<use
xlink:href="/_ui/responsive/theme-alpha/images/icons.svg#icon-arrow1"
></use>
</svg>
<a href="/mobilya/c/109">Mobilya</a>
</li>
<li>
<svg class="icon-arrow1 m-0">
<use
xlink:href="/_ui/responsive/theme-alpha/images/icons.svg#icon-arrow1"
></use>
</svg>
<span class="top-breadcrumb">
<a
class="d-inline-flex align-items-center border pl-10 rounded-sm"
href="/mobilya/gardiroplar/c/109011"
data-toggle="dropdown"
aria-expanded="false"
>Gardıroplar<svg class="icon-arrow7 m-0 rotate-top">
<use
xlink:href="/_ui/responsive/theme-alpha/images/icons.svg#icon-arrow7"
></use>
</svg>
</a>
<ul class="dropdown-menu px-15 py-0 border-0 text-c2">
<li class="border-bottom py-10">
<a
class="d-flex align-items-center justify-content-between pl-5 py-5 reverse font-weight-bold"
href="/mobilya/gardiroplar/c/109011"
>Gardıroplar</a
>
</li>
<li class="px-10 border-bottom">
<a
class="d-flex align-items-center justify-content-between pl-5 py-5 reverse"
href="/gardiroplar/kapakli-gardiroplar/c/109011002"
>Kapaklı Gardıroplar<svg class="icon-arrow1 ml-5">
<use
xlink:href="/_ui/responsive/theme-alpha/images/icons.svg#icon-arrow1"
></use>
</svg>
</a>
</li>
<li class="px-10 border-bottom">
<a
class="d-flex align-items-center justify-content-between pl-5 py-5 reverse"
href="/gardiroplar/surgulu-gardiroplar/c/109011003"
>Sürgülü Gardıroplar<svg class="icon-arrow1 ml-5">
<use
xlink:href="/_ui/responsive/theme-alpha/images/icons.svg#icon-arrow1"
></use>
</svg>
</a>
</li>
<li class="px-10 border-bottom">
<a
class="d-flex align-items-center justify-content-between pl-5 py-5 reverse"
href="/gardiroplar/bez-dolaplar/c/109011001"
>Bez Dolaplar<svg class="icon-arrow1 ml-5">
<use
xlink:href="/_ui/responsive/theme-alpha/images/icons.svg#icon-arrow1"
></use>
</svg>
</a>
</li>
</ul>
</span>
</li>
<li>
<svg class="icon-arrow1 m-0">
<use
xlink:href="/_ui/responsive/theme-alpha/images/icons.svg#icon-arrow1"
></use>
</svg>
<a href="/gardiroplar/kapakli-gardiroplar/c/109011002">Kapaklı Gardıroplar</a>
</li>
</ol>
</code></pre>
<p>My code:</p>
<pre><code>response.xpath('//ol[@class="nav.align-items-center.flex-nowrap.text-nowrap.overflow-auto.hide-scrollbar.tab-title"]//li[svg[contains(@class,"icon-arrow2")]]/text()').getall()
</code></pre>
| [
{
"answer_id": 74232010,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 3,
"selected": true,
"text": "icon-arrow2"
},
{
"answer_id": 74232103,
"author": "Alexander",
"author_id": 17829451,
"author_pr... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17169588/"
] |
74,231,889 | <p>I'm trying to use the PokeApi graphQL console here <a href="https://beta.pokeapi.co/graphql/console/" rel="nofollow noreferrer">https://beta.pokeapi.co/graphql/console/</a> to get Pokemon with types and sprites, I've figured out types easy enough but I cant seem to figure out how to limit the sprites to only return the front_default sprite, can anyone help?</p>
<p><strong>Current Query</strong></p>
<pre><code>query samplePokeAPIquery {
pokemon_v2_pokemon(
where: {
pokemon_v2_pokemontypes: {
type_id: {_in: [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11]},
pokemon_v2_pokemon: {name: {_like: "%%"}}
}
},
order_by: {id: asc},
limit: 10, offset: 0) {
id
name
pokemon_v2_pokemonsprites {
sprites
}
}
}
</code></pre>
<p><strong>Response</strong></p>
<pre><code>"pokemon_v2_pokemon": [
{
"id": 1,
"name": "bulbasaur",
"pokemon_v2_pokemonsprites": [
{
"sprites": "{\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/1.png\", \"front_female\": null, \"front_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/shiny/1.png\", \"front_shiny_female\": null, \"back_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/1.png\", \"back_female\": null, \"back_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/back/shiny/1.png\", \"back_shiny_female\": null, \"other\": {\"dream_world\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/dream-world/1.svg\", \"front_female\": null}, \"home\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/home/1.png\", \"front_female\": null, \"front_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/home/shiny/1.png\", \"front_shiny_female\": null}, \"official-artwork\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/other/official-artwork/1.png\"}}, \"versions\": {\"generation-i\": {\"red-blue\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-i/red-blue/1.png\", \"front_gray\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-i/red-blue/gray/1.png\", \"back_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-i/red-blue/back/1.png\", \"back_gray\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-i/red-blue/back/gray/1.png\", \"front_transparent\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-i/red-blue/transparent/1.png\", \"back_transparent\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-i/red-blue/transparent/back/1.png\"}, \"yellow\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-i/yellow/1.png\", \"front_gray\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-i/yellow/gray/1.png\", \"back_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-i/yellow/back/1.png\", \"back_gray\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-i/yellow/back/gray/1.png\", \"front_transparent\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-i/yellow/transparent/1.png\", \"back_transparent\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-i/yellow/transparent/back/1.png\"}}, \"generation-ii\": {\"crystal\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/crystal/1.png\", \"front_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/crystal/shiny/1.png\", \"back_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/crystal/back/1.png\", \"back_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/crystal/back/shiny/1.png\", \"front_transparent\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/crystal/transparent/1.png\", \"front_shiny_transparent\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/crystal/transparent/shiny/1.png\", \"back_transparent\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/crystal/transparent/back/1.png\", \"back_shiny_transparent\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/crystal/transparent/back/shiny/1.png\"}, \"gold\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/gold/1.png\", \"front_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/gold/shiny/1.png\", \"back_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/gold/back/1.png\", \"back_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/gold/back/shiny/1.png\", \"front_transparent\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/gold/transparent/1.png\"}, \"silver\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/silver/1.png\", \"front_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/silver/shiny/1.png\", \"back_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/silver/back/1.png\", \"back_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/silver/back/shiny/1.png\", \"front_transparent\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-ii/silver/transparent/1.png\"}}, \"generation-iii\": {\"emerald\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iii/emerald/1.png\", \"front_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iii/emerald/shiny/1.png\"}, \"firered-leafgreen\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iii/firered-leafgreen/1.png\", \"front_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iii/firered-leafgreen/shiny/1.png\", \"back_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iii/firered-leafgreen/back/1.png\", \"back_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iii/firered-leafgreen/back/shiny/1.png\"}, \"ruby-sapphire\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iii/ruby-sapphire/1.png\", \"front_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iii/ruby-sapphire/shiny/1.png\", \"back_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iii/ruby-sapphire/back/1.png\", \"back_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iii/ruby-sapphire/back/shiny/1.png\"}}, \"generation-iv\": {\"diamond-pearl\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iv/diamond-pearl/1.png\", \"front_female\": null, \"front_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iv/diamond-pearl/shiny/1.png\", \"front_shiny_female\": null, \"back_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iv/diamond-pearl/back/1.png\", \"back_female\": null, \"back_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iv/diamond-pearl/back/shiny/1.png\", \"back_shiny_female\": null}, \"heartgold-soulsilver\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iv/heartgold-soulsilver/1.png\", \"front_female\": null, \"front_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iv/heartgold-soulsilver/shiny/1.png\", \"front_shiny_female\": null, \"back_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iv/heartgold-soulsilver/back/1.png\", \"back_female\": null, \"back_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iv/heartgold-soulsilver/back/shiny/1.png\", \"back_shiny_female\": null}, \"platinum\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iv/platinum/1.png\", \"front_female\": null, \"front_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iv/platinum/shiny/1.png\", \"front_shiny_female\": null, \"back_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iv/platinum/back/1.png\", \"back_female\": null, \"back_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-iv/platinum/back/shiny/1.png\", \"back_shiny_female\": null}}, \"generation-v\": {\"black-white\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-v/black-white/1.png\", \"front_female\": null, \"front_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-v/black-white/shiny/1.png\", \"front_shiny_female\": null, \"back_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-v/black-white/back/1.png\", \"back_female\": null, \"back_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-v/black-white/back/shiny/1.png\", \"back_shiny_female\": null, \"animated\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-v/black-white/animated/1.gif\", \"front_female\": null, \"front_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-v/black-white/animated/shiny/1.gif\", \"front_shiny_female\": null, \"back_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-v/black-white/animated/back/1.gif\", \"back_female\": null, \"back_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-v/black-white/animated/back/shiny/1.gif\", \"back_shiny_female\": null}}}, \"generation-vi\": {\"omegaruby-alphasapphire\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-vi/omegaruby-alphasapphire/1.png\", \"front_female\": null, \"front_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-vi/omegaruby-alphasapphire/shiny/1.png\", \"front_shiny_female\": null}, \"x-y\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-vi/x-y/1.png\", \"front_female\": null, \"front_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-vi/x-y/shiny/1.png\", \"front_shiny_female\": null}}, \"generation-vii\": {\"ultra-sun-ultra-moon\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-vii/ultra-sun-ultra-moon/1.png\", \"front_female\": null, \"front_shiny\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-vii/ultra-sun-ultra-moon/shiny/1.png\", \"front_shiny_female\": null}, \"icons\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-vii/icons/1.png\", \"front_female\": null}}, \"generation-viii\": {\"icons\": {\"front_default\": \"https://raw.githubusercontent.com/PokeAPI/sprites/master/sprites/pokemon/versions/generation-viii/icons/1.png\", \"front_female\": null}}}}"
}
]
},
</code></pre>
| [
{
"answer_id": 74232010,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 3,
"selected": true,
"text": "icon-arrow2"
},
{
"answer_id": 74232103,
"author": "Alexander",
"author_id": 17829451,
"author_pr... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231889",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2745944/"
] |
74,231,908 | <p>I am studying react and following the guide: event handling section, and watching binding of an event handler to a class in a constructor.
There's a thing I want to understand.
Why is it's okay to bind yet <strong>undefined</strong> method of a class in the <code>constructor</code>? or are methods of a class initialized before the <code>constructor</code>? or algoritm of class intialization starts with the constructor but it's possible to define already binded function later?</p>
<pre><code> constructor(props) {
super(props);
this.state = {isToggleOn: true};
// This binding is necessary to make `this` work in the callback
this.handleClick = this.handleClick.bind(this);
}
handleClick() {
...
</code></pre>
| [
{
"answer_id": 74232010,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 3,
"selected": true,
"text": "icon-arrow2"
},
{
"answer_id": 74232103,
"author": "Alexander",
"author_id": 17829451,
"author_pr... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231908",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15803233/"
] |
74,231,920 | <p>I have a SELECT based on a IN</p>
<p>I want to order the extraction in the same order I made the IN. How can I make it?</p>
<pre><code>SELECT * FROM BOLLER1 WHERE BOLR1_KT1 IN ('TM2019000026000010',
'TM2019000024700010',
'TM2019000024700070',
'TM2019000024700080',
'Mr2019000000400010',
'TM2019000024700110',
'TM2019000024700100',
'TM2019000024700120',
'TM2019000026000020',
'TM2019000024700040',
'TM2019000024700090',
'Mj2019000000100010',
'Ma2019000003200020',
'Ma2019000000100020',
'TM2019000025700010',
'Mj2019000000400010',
'Mj2019000001000010',
'Mj2019000002000010',
'Ma2020000005000010',
'Mj2019000004800010',
'TM2019000026000010',
'TM2019000024700010',
'TM2019000024700110',
'TM2019000024700100',
'TM2019000026000020',
'TM2019000024700040',
'TM2019000024700090',
'TM2019000024700120',
'TM2019000024700080',
'TM2019000026300010',
'TM2019000024700050',
'Mj2019000005400010',
'Mj2019000005400010',
'Mg2019000008700020',
'MB2020000006800120',
'Ma2020000001200020',
'Mj2019000023300040',
'Mj2019000006900010',
'Mj2019000007100010',
'TM2019000004500010',
'Mj2019000007400010',
'Mj2019000007000010',
'Mf2019000004700060',
'Mf2019000004700110',
'Ma2020000001200020',
'Mj2019000023300040',
'Mj2019000007200010',
'Mj2019000007200090',
'Mj2019000010100010',
'Mf2019000004700060',
'Mf2019000004700110',
'Mj2019000007400010',
'Mj2019000007000010',
'Ma2020000001200020',
'Mj2019000023300040',
'Mj2019000006400010',
'Mj2019000002600010',
'Mj2019000004600010',
'Mj2019000007700010',
'Mj2019000006500010',
'Mg2019000000200140',
'TM2019000026000010',
'TM2019000024700010',
'TM2019000024700110',
'TM2019000024700100',
'Mg2018000001600020',
'MB2018000000300020',
'TM2019000026000020',
'TM2019000024700040',
'TM2019000024700090',
'Mj2019000012000010',
'Mg2018000001600020',
'MB2019000010700020',
'TM2019000024700050',
'Mj2019000005400010',
'MB2020000006800120',
'Mg2019000022700040',
'Mj2019000000400010',
'Mj2019000023300040',
'Ma2020000001200020',
'Mg2019000016600260',
'Mf2019000004700060',
'Mf2019000004700110',
'Mg2019000018600170',
'Mj2019000011800010',
'Mj2019000007100010',
'Mg2019000013200020',
'Mj2019000006100010',
'Ma2019000001500020',
'Mg2018000000700020',
'Mj2019000013600010',
'Mj2019000010300010',
'Mg2018000001600020',
'Mf2019000004700020',
'Mj2019000002600010',
'Mg2019000000200140',
'Mj2019000023300040',
'Ma2020000001200020',
'Mf2019000004700060',
'Mf2019000004700110',
'Mj2019000013100010',
'Mg2019000008300020',
'Mj2019000010300010',
'Mg2019000002600040',
'Mg2019000025900020',
'Mj2019000013000010',
'Mg2018000001600020',
'Mg2018000001600020',
'Mg2019000000200140',
'Mv2020000001500010',
'Mj2019000010300010',
'Mg2018000001600020',
'Mf2019000003600020',
'Ma2020000001200020',
'Mf2019000004700060',
'Mf2019000004700110',
'Ma2019000000300020',
'TM2019000026300010',
'Mv2019000000100010',
'Mj2019000007100010',
'Mj2019000014100010',
'Mj2019000006500010',
'Mf2019000004700020',
'Mv2020000001500010',
'Ma2019000001800020',
'TM2019000026000010',
'MB2019000010700020',
'Mg2019000022700040',
'TM2019000024700110',
'TM2019000024700100',
'TM2019000024700050',
'Mj2019000005400010',
'TM2019000024700120',
'TM2019000026000020',
'TM2019000024700040',
'TM2019000024700090',
'Mg2019000000200140',
'TM2019000024700010',
'TM2019000025700010',
'Ma2019000000600020',
'Ma2019000000600020',
'Mf2019000003600020',
'Ma2020000001200020',
'Mf2019000004700060',
'Mf2019000004700110',
'Mj2019000014100010',
'Mv2020000001500010',
'Ma2019000001400020',
'Mf2019000004700020',
'Mv2020000001500010',
'Mg2018000001600020',
'Ma2019000002700020',
'Ma2020000000800020',
'Mv2019000000100010',
'Mg2019000018600170',
'Mg2019000016600260',
'Mg2019000000200140',
'Ma2019000002600020',
'Mj2020000001600010',
'Mv2020000001100010',
'Mj2019000001700010',
'Ma2019000003300020',
'TM2019000026300010',
'TM2019000025700010',
'Mg2019000008700020',
'TM2019000026300010',
'Mg2018000001600020',
'TM2019000024700010',
'Mj2020000012700010',
'PN2019000004900010',
'TM2019000024700110',
'TM2019000024700100',
'TM2019000024700050',
'PN2019000003700010',
'Ml2018000000300010',
'Mw2019000000100010',
'Mj2019000004700010',
'TM2019000026000020',
'TM2019000024700040',
'TM2019000024700090',
'Ma2020000000400020',
'Ma2020000004300010',
'Ma2020000004300010',
'Ma2019000003400020',
'TM2019000026300010',
'Ml2020000007500010',
'Ma2020000000400020',
'MB2019000037000020',
'Ma2020000000600020',
'Ma2020000005100010',
'Ma2020000005100010',
'Ma2020000000100020',
'Ma2020000000800020',
'TM2019000024700010',
'MB2019000037000020',
'TM2019000025200010',
'TM2019000024700110',
'TM2019000024700050',
'Ml2018000000300010',
'PN2019000003700010',
'TM2019000026000020',
'TM2019000024700040',
'TM2019000024700090',
'Mr2020000000400010',
'TM2019000024700100',
'PN2019000002400010',
'Mv2020000003100010',
'TM2019000025000010',
'Ma2020000000700020',
'Mv2020000000900010',
'Mv2020000000500010',
'Mv2020000000800010',
'Mv2020000000400010',
'Mv2020000000700010',
'Mb2020000001100010',
'Mw2020000001100010',
'Ma2020000001600020',
'Mw2020000001000010',
'TM2019000026300010',
'Mv2020000001100010',
'Ma2020000001200020',
'Mj2020000006800010',
'Ma2020000002100020',
'Mb2020000001400010',
'Ma2020000002000020',
'Mb2020000001300010',
'Ma2020000000700020',
'Mw2020000001200010',
'Ma2020000001600020',
'Mj2020000006800010',
'Mv2020000001100010',
'Mv2020000001100010',
'Ma2020000001200020',
'Mj2019000023300040',
'Ma2020000002300020',
'Ma2020000002300020',
'Mf2019000004700060',
'Ma2020000002500040',
'Mv2020000001500010',
'Mv2020000001500010',
'Mj2020000001200010',
'Mr2020000000100010',
'Mw2020000001500010',
'Ma2020000002000020',
'Ma2020000002000100',
'Mb2020000001500010',
'Ma2019000003600020',
'Mg2019000006000020',
'Ma2020000000900080',
'Mw2020000001600010',
'Mw2020000001600010',
'Mj2020000001200010',
'Ma2020000002300020',
'Mj2019000023300040',
'Ma2020000002400020',
'Ma2020000002500040',
'Ma2020000001200020',
'Mj2020000006800010',
'Ma2020000002100020',
'Mw2020000001700010',
'Ml2020000003300010',
'TM2019000024700100',
'TM2019000024700010',
'Mj2019000012400010',
'Ma2020000001600020',
'TM2019000024700110',
'TM2019000024700100',
'TM2019000024700050',
'Ma2020000001900020',
'Mj2019000005400010',
'Mv2019000000100010',
'Mr2019000000200010',
'Mr2020000000100010',
'TM2019000026000020',
'TM2019000024700040',
'TM2019000024700090',
'Mw2020000001800010',
'Mb2020000002000010',
'Mg2019000006000020',
'Mg2020000011900020',
'Ma2020000002000100',
'Ma2020000002000020',
'Ma2019000003600020',
'Ma2020000002300020',
'TM2020000002600010',
'Ma2020000002400020',
'Ma2020000002500040',
'Mv2020000001500010',
'Ma2020000003200010',
'Ma2020000002000020',
'Ma2020000002000100',
'Mr2020000000100010',
'Ma2019000003600020',
'Ma2020000002700020',
'Mv2020000001300010',
'Ma2020000001200020',
'Ma2020000001200020',
'Ma2020000002400020',
'Ma2020000002400020',
'Ma2020000002400020',
'Mv2020000001500010',
'Mv2020000002500010',
'Ma2020000002000020',
'Ma2020000002000100',
'Ma2020000003400010',
'Ma2020000003600010',
'Mv2020000002600010',
'Mv2020000002800010',
'Mv2020000003000010',
'Mv2020000002300010',
'Ma2020000002000020',
'Ma2020000002000100',
'Ma2020000003600010',
'Mv2020000002700010',
'TM2019000024700010',
'TM2019000024700100',
'Mg2019000022700040',
'Mr2020000000600010',
'TM2019000024700110',
'Mr2020000000400010',
'TM2019000024700050',
'Mj2019000005400010',
'Mv2019000000100010',
'Ma2020000001200020',
'Ma2020000001200020',
'Ma2020000002300020',
'Ma2020000002300020',
'Ma2020000002300020',
'Ma2020000004400040',
'Ma2020000004400040',
'TM2019000026000020',
'TM2019000024700040',
'TM2019000024700090',
'Mr2020000000300010',
'Ma2020000004600010',
'Mv2020000003300010',
'Mv2020000003200010',
'Ma2020000003900010',
'Ma2020000002000020',
'Ma2020000002000100',
'Ma2020000003600010',
'Mv2020000001500010',
'Mv2020000001500010',
'Ma2022000004200010',
'Ma2020000004400040',
'Ma2020000004400040',
'Ma2020000001200020',
'Ma2020000001200020',
'Ml2020000002700040',
'Ml2020000002700040',
'Ml2020000002700040',
'Ma2020000004700010',
'Ma2019000003600020',
'Mv2020000003700010',
'Mv2020000003600010',
'Ma2020000004100010',
'Mv2020000003800010',
'Mv2020000001500010',
'Mj2019000023300040',
'Ma2020000002300020',
'Mf2019000004700060',
'Ma2020000002500040',
'Ma2020000004800010',
'Mr2020000001200010',
'Ma2020000004300010',
'Mj2020000007400010',
'Mr2020000000900010',
'Ma2020000005100010',
'Mf2020000010700020',
'Ma2020000005200010',
'Ma2020000005000010',
'Ma2020000005500010',
'Ms2020000000600010',
'Ma2020000002000020',
'Ma2020000002000100',
'Mv2020000001500010',
'Ma2020000005700010',
'Mr2020000000700010',
'Ma2020000005600010',
'Ma2020000005500010',
'Ma2021000000100010',
'Ma2019000003600020',
'Ma2020000002000020',
'Ma2020000002000100',
'Ms2020000000600010',
'Ma2021000000300010',
'Ma2021000000500010',
'Mv2021000000200010',
'Ma2021000000800010',
'Ma2019000003600020',
'Ms2020000000600010',
'Ma2021000000900010',
'Mv2021000000700010',
'TM2019000026300010',
'Ma2019000003600020',
'Mv2020000001100010',
'Mv2021000000500010',
'Ma2021000001500010',
'Ma2021000001400010',
'Mr2020000000700010',
'Mr2021000000100010',
'Mj2019000012400010',
'Mr2020000000600010',
'Mr2020000000400010',
'Mv2019000000100010',
'Mr2019000000200010',
'Mr2020000000300010',
'Mr2020000000300010',
'Ms2020000000600010',
'Mj2021000005100010',
'Mr2021000000500010',
'Ma2019000003600020',
'Mv2020000002500010',
'Mg2020000035400020',
'Ms2020000000600010',
'Ma2019000003600020',
'Mv2020000002900010',
'Mv2021000001100010',
'Ma2021000002000010',
'Ma2021000001900010',
'TM2020000002600010',
'Ma2020000002300020',
'Ma2020000002500040',
'Ma2020000002400020',
'Ma2021000002200010',
'Ma2021000002300010',
'Ma2021000002500010',
'Ma2019000000100020',
'Mv2021000000700010',
'Mv2021000001100010',
'TM2020000002600010',
'Ma2020000002400020',
'Ma2020000002500040',
'Mv2020000002900010',
'Ma2021000002300010',
'Ma2021000002600010',
'Mr2020000000700010',
'Mr2021000000100010',
'Mj2019000012400010',
'Mr2020000001100010',
'TM2020000003400010',
'Mj2021000005400010',
'Mv2019000000100010',
'Mr2019000000200010',
'Mv2021000001100010',
'TM2020000002600010',
'Ma2020000002400020',
'Ma2020000002500040',
'Mv2020000002900010',
'Ma2021000002200010',
'Ma2021000002300010',
'Ma2021000002600010',
'Mr2020000001200010',
'Ma2021000001200010',
'Ma2021000001200010',
'Mr2021000000500010',
'Ma2021000001800010',
'Ma2021000003600010',
'Mv2020000001100010',
'Ma2021000002200010',
'TM2020000002600010',
'Mj2019000023300010',
'Mj2019000023300020',
'Ma2021000002400010',
'Ma2021000002300010',
'Ma2020000002300020',
'Ma2021000001800010',
'Ma2021000003900010',
'Ma2021000003100010',
'Ma2021000003300010',
'Ma2021000003800010',
'Ma2021000003200010',
'Ma2021000002100010',
'Ma2021000002100010',
'Mv2021000001400010',
'Ma2021000002500010',
'Mv2021000001300010',
'Ma2021000003900010',
'Ma2021000001800010',
'Ma2021000003200010',
'Ma2021000003100010',
'Ma2021000002400010',
'Ma2021000003300010',
'Ms2020000000600010',
'Mv2021000001100010',
'Mv2021000001100010',
'Mv2020000001100010',
'Ma2021000002200010',
'Mj2019000023300040',
'Ma2020000002400020',
'Ma2020000002500040',
'Ma2021000002300010',
'Ma2020000002300020',
'Mr2021000000500010',
'Mr2020000000700010',
'TM2020000003400010',
'Ma2021000003300010',
'Ma2021000003100010',
'Ma2021000003900010',
'Ma2021000001800010',
'Ma2021000003200010',
'Ma2021000002300010',
'Ma2021000002400010',
'TM2020000002600010',
'Ma2021000002200010',
'Mv2021000001100010',
'Mv2020000001100010',
'Ms2020000000600010',
'Ma2021000004100010',
'Mv2020000001100010',
'Ma2021000002400010',
'Ma2021000001800010',
'Ma2021000004600010',
'Mf2019000006600020',
'Ma2021000004300010',
'Ma2021000001800010',
'Ma2021000002400010',
'Mv2021000001100010',
'Mj2021000005200010',
'Mr2021000000400010',
'Mj2019000005400010',
'Mr2020000000700010',
'Mr2021000000100010',
'Mj2019000012400010',
'TM2020000003200010',
'TM2020000003400010',
'Mv2019000000100010',
'Mr2019000000200010',
'TM2020000003300010',
'Ma2021000001800010',
'Ma2021000002400010',
'Mv2021000001000010',
'Mv2020000001100010',
'TM2019000026300010',
'Ma2021000004500010',
'Mv2020000001100010',
'Ma2021000002400010',
'Ma2021000001800010',
'Mj2021000016300010',
'Ma2022000000200010',
'Ma2022000000400010',
'Ma2022000000100010',
'Ma2022000001100010',
'Mv2022000000200010',
'Ma2022000001300010',
'TM2022000009400010',
'Mv2021000000900010',
'Mv2022000000100010',
'Ma2022000000500010',
'Ma2022000001100080',
'Ma2021000002400010',
'Ma2021000001800010',
'Mv2022000000300010',
'Mv2022000000400010',
'Mv2021000001000010',
'Ma2020000003000020',
'Ma2021000002500010',
'Ma2021000002400010',
'Mj2022000001400010',
'Mv2022000000400010',
'Mv2021000001000010',
'Ma2021000002400010',
'Ma2022000001500010',
'Ma2021000001800010',
'Ma2022000002200010',
'Ms2020000000600010',
'Ma2021000002300010',
'Ma2022000003200010',
'Ma2022000002800010',
'Mj2019000005400010',
'Mr2020000000700010',
'Mv2021000001000010',
'Ma2021000001800010',
'Mj2021000016300010',
'Mv2021000001000010',
'Ma2021000002400010',
'Ma2021000002500010',
'Ma2021000002300010',
'Ma2022000003200010',
'Ma2021000002300010',
'Mv2022000000400010',
'Mv2021000001000010',
'Ma2021000002400010',
'Ma2021000002500010',
'Ma2021000004800010',
'Ma2022000004100010',
'Mv2022000000400010',
'Mv2021000001000010',
'Ma2021000002400010',
'Ma2022000004100010',
'Ma2022000004200010',
'Ma2021000001800010',
'Ma2022000002700010',
'Ma2022000004000010',
'Ma2021000002300010',
'Ma2021000004800010',
'Mb2022000003000010',
'Mb2022000002900010',
'Ma2021000002500010',
'Ma2022000002900010',
'Mj2019000005400010',
'Mr2021000000100010',
'Mr2020000000700010',
'Mr2021000000500010',
'Mb2022000003200010',
'Mv2022000000400010',
'Mv2021000001000010',
'Mw2022000001000010',
'Ma2022000004300010',
'Ma2021000002500010',
'Mw2022000001100010',
'Mv2022000001200010',
'Mb2022000003400010',
'Mb2022000003500010')
</code></pre>
<p>I tried using ORDER BY statement but with no effects I'd like to obtain.</p>
| [
{
"answer_id": 74232010,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 3,
"selected": true,
"text": "icon-arrow2"
},
{
"answer_id": 74232103,
"author": "Alexander",
"author_id": 17829451,
"author_pr... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7019439/"
] |
74,231,921 | <p>I've been writing this code, but it seem to work.</p>
<pre><code>This function takes two parameters, the entire list of students and an integer
indicating which assignment (0, 1, 2 or 3) you wish to find the average for.
You will need to add the two parameters to the function
declaration.
The function will calculate the average for the given assignment and will return the
average.
</code></pre>
<p>this is my code:</p>
<pre><code>
def AverageAssignment(students, assignement_number):
if assignement_number != range(0,3):
return -999
assignement_number= students[0][1]
deno=0
average=0
n=len(students[0][1])
for i in students:
deno+=1
average = sum(i[1][assignement_number])
students = [('Jane',[70,80,90,100]),('xinrong',[60,50,30,40]),('sima',[100,70,30,100])]
#AverageAssignment(students,0)
</code></pre>
<p>thank you</p>
<p>I was expecting the average of the assignment number( just the formula)</p>
| [
{
"answer_id": 74232010,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 3,
"selected": true,
"text": "icon-arrow2"
},
{
"answer_id": 74232103,
"author": "Alexander",
"author_id": 17829451,
"author_pr... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231921",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20133439/"
] |
74,231,986 | <p>I want to import modules in a single line with ES6 modules, like it was done with the require syntax shown in the example.</p>
<pre><code>var configApi = require('somemodule').config.get('services').api;
</code></pre>
<p>I've tried</p>
<pre><code>import configApi from 'somemodule'.config.get('services').api;
</code></pre>
<p>and</p>
<pre><code>import configApi from 'somemodule';
const api = confiApi.config.get('services').api;
</code></pre>
<p>but none of them have work.</p>
| [
{
"answer_id": 74232145,
"author": "Harshal Limaye",
"author_id": 7148982,
"author_profile": "https://Stackoverflow.com/users/7148982",
"pm_score": -1,
"selected": false,
"text": "import(\"/modules/my-module.js\")\n .then((module) => {\n // do something \n })\n .catch((err) => {\n ... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74231986",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18126707/"
] |
74,232,002 | <p>How do I convert multiple rows to different columns? <br>
I have a dataframe like this:</p>
<pre><code>Brand Key Col_Name1 Percentage Col_Name2 Dollar_Value
A 1 Percentage_High 90 Dollar_Value_High 30000
A 1 Percentage_Low 70 Dollar_Value_Low 20000
B 2 Percentage_High 80 Dollar_Value_High 25000
B 2 Percentage_Low 60 Dollar_Value_Low 15000
C 3 Percentage_High Nan Dollar_Value_High Nan
C 3 Percentage_Low Nan Dollar_Value_Low Nan
</code></pre>
<p>I want to convert it to this way:</p>
<pre><code>Brand Key Percentage_High Percentage_Low Dollar_Value_High Dollar_Value_Low
A 1 90 70 30000 20000
B 2 80 60 25000 15000
C 3 Nan Nan Nan Nan
</code></pre>
<p>I'm only able to do a single column currently:</p>
<pre><code>df_pivot = df.pivot_table('Percentage', ['Brand', 'Key'], 'Col_Name1')
df_pivot.reset_index(drop=False, inplace=True)
</code></pre>
<p>But this only gives me one column and it also ignores Brand C where the values are Nan.
<br>How do I do it for multiple columns and retain Nan values?</p>
| [
{
"answer_id": 74232145,
"author": "Harshal Limaye",
"author_id": 7148982,
"author_profile": "https://Stackoverflow.com/users/7148982",
"pm_score": -1,
"selected": false,
"text": "import(\"/modules/my-module.js\")\n .then((module) => {\n // do something \n })\n .catch((err) => {\n ... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10632366/"
] |
74,232,009 | <p>I have a task to add an extension to Webapp as in the picture below, but I want it will be auto-add, I found it can't not auto by CI/CD but I will be running on Azure ARM Template, so I viewed the template of a web app and see the config Extensions, Can I put that config to Azure ARM Template when we deploy? Because another team will handle deploying Azure ARM Template so I need to make sure about technical before requesting them to do that.
<a href="https://i.stack.imgur.com/cGxd4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cGxd4.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/bwpij.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bwpij.png" alt="enter image description here" /></a></p>
<p>Thanks for your advice!</p>
| [
{
"answer_id": 74232145,
"author": "Harshal Limaye",
"author_id": 7148982,
"author_profile": "https://Stackoverflow.com/users/7148982",
"pm_score": -1,
"selected": false,
"text": "import(\"/modules/my-module.js\")\n .then((module) => {\n // do something \n })\n .catch((err) => {\n ... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17801609/"
] |
74,232,020 | <p>I have the following code:</p>
<pre><code>set.seed(12345)
a <- rnorm(852)
b <- rnorm(852)
abc <- lm(a ~ b)
summary(abc)
</code></pre>
<p>Now I want to determine different coefficients using lm-function with the following values:</p>
<pre><code>lm1 <- lm(a[1:52] ~ b[1:52])
lm2 <- lm(a[2:53] ~ b[2:53])
lm3 <- lm(a[3:54] ~ b[3:54])
.....
lm801 <- lm(a[801:852] ~ b[801:852])
</code></pre>
<p>I looking for a reproducible solution so I don't have to enter all values individually. A vector with all 801 coefficients would be optimal as a solution.</p>
<p>If anyone knows what this type of "partial regression" is called in mathematics, they are welcome to share the technical term. Many Thanks.</p>
| [
{
"answer_id": 74232145,
"author": "Harshal Limaye",
"author_id": 7148982,
"author_profile": "https://Stackoverflow.com/users/7148982",
"pm_score": -1,
"selected": false,
"text": "import(\"/modules/my-module.js\")\n .then((module) => {\n // do something \n })\n .catch((err) => {\n ... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20241827/"
] |
74,232,023 | <p>I have a string:</p>
<pre class="lang-none prettyprint-override"><code>CLAIM NUMBER 1234563 AND INCIDENT DATE 12/12/2020 12:00:00
</code></pre>
<p>I would like to extract <code>1234563</code> and <code>12/12/2020 12:00:00</code> from this, i.e. the substring after the NUMBER and DATE.</p>
<p>Could someone please provide some help?</p>
<p>I tried though the the substring and index but it's not giving expected answer.</p>
| [
{
"answer_id": 74232304,
"author": "Christoph S.",
"author_id": 5002324,
"author_profile": "https://Stackoverflow.com/users/5002324",
"pm_score": -1,
"selected": false,
"text": "String#substring()"
},
{
"answer_id": 74232445,
"author": "oleg.cherednik",
"author_id": 34613... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11390964/"
] |
74,232,039 | <p>Sorry to bother you, but I'm at an impasse :(</p>
<p>To summarize my situation, I need to recover an entire sheet of all files in a folder. My macro goes through them one by one and picks it up.</p>
<p>The problem is that I can have "xlsm" files that show me a warning pop up because there are macros and "trust" etc... Pop up that I can't remove because it doesn't cannot be disabled.
(I also can't change my excel options for X reasons because I'm not the only one using the macro).</p>
<p>I would therefore like to convert my "xlsm" to "xlsx" without having to open it to avoid the pop up. A simple change of extension damages the file (obvious)</p>
<p>Do you have a solution for saveas without opening the file or opening it without having the pop-up?</p>
<p>Thanks in advance !</p>
| [
{
"answer_id": 74232304,
"author": "Christoph S.",
"author_id": 5002324,
"author_profile": "https://Stackoverflow.com/users/5002324",
"pm_score": -1,
"selected": false,
"text": "String#substring()"
},
{
"answer_id": 74232445,
"author": "oleg.cherednik",
"author_id": 34613... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232039",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13832917/"
] |
74,232,041 | <p>Given an object type, one can access the type of one of the fields using the bracket-string notation. Why isn’t it possible to use the dot notation as well, like in Javascript? Does it conflict with something else? I feel like I am missing something obvious.</p>
<pre class="lang-js prettyprint-override"><code>type Foo = {value: number | string};
type Bar = Foo["value"]; // Works, Bar is number | string
type Baz = Foo.value; // Error
</code></pre>
<p>The error message says something about namespaces, but even if there is a namespace named <code>Foo</code>, then <code>Foo.value</code> refers to a value and not a type, so it still doesn’t seem ambiguous.</p>
| [
{
"answer_id": 74232245,
"author": "Quyen Nguyen",
"author_id": 17655529,
"author_profile": "https://Stackoverflow.com/users/17655529",
"pm_score": -1,
"selected": false,
"text": "type Baz = Foo.value;\n"
},
{
"answer_id": 74232465,
"author": "Garuno",
"author_id": 562508... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232041",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/521624/"
] |
74,232,064 | <p>The use of parentheses for 'if' loop results in two different output for a palindrome program!</p>
<p>1.) () this gives the accurate result
2.) [] this only gives you the result of 'if' statement even if the "String" is not a palindrome</p>
<pre><code>def isapalindrome(String):
if(String == String[::-1]):
return("is a palindrome!")
else:
return("is not a palindrome!")
String = input("Enter the String of your choice: ")
isapalindrome(String)
</code></pre>
<p>this code executes properly!</p>
<pre><code>def isapalindrome(String):
if[String == String[::-1]]:
return("is a palindrome!")
else:
return("is not a palindrome!")
String = input("Enter the String of your choice: ")
isapalindrome(String)
</code></pre>
<p>this code executes only the 'if' statement!</p>
| [
{
"answer_id": 74232126,
"author": "Lukas Schmid",
"author_id": 11437648,
"author_profile": "https://Stackoverflow.com/users/11437648",
"pm_score": 2,
"selected": false,
"text": "()"
},
{
"answer_id": 74232403,
"author": "Dan",
"author_id": 16698885,
"author_profile":... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232064",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20356035/"
] |
74,232,101 | <p>I have <strong>php 7.4</strong> by default in my xampp (in the path <code>c:\xampp\php</code>) and my most projects are running on it.Now, I've a php 8 project & so need to run xampp with <strong>php 8.1</strong> on a different port(8056).I tried doing it with the answer mentioned in this link:</p>
<p><a href="https://stackoverflow.com/questions/72864418/how-to-use-multiple-xampp-like-xampp-php-version-5-xampp-php-version-7-version">How to use Multiple xampp Like xampp php version 5, xampp php version 7, version 8. I also install it but problem new laravel project npm not install</a></p>
<p>Although the new port (8056) is also getting listed under <code>ports</code> in Xampp control panel, not able to load xampp with it.When running <code>http://localhost:8056/</code> , am getting the error:</p>
<pre><code>Internal Server Error
The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator at postmaster@localhost to inform them of the time this error occurred, and the actions you performed just before this error.
More information about this error may be available in the server error log.
Apache/2.4.52 (Win64) OpenSSL/1.1.1m PHP/7.4.27 Server at localhost Port 8056
</code></pre>
<p>In the last line of this error,it seems it is still running on <strong>php.7.4</strong> . I wanted only <strong>php 8.1</strong> to listen on this port. How can I fix this? Any help is much appreciated.</p>
<p>Steps I did:</p>
<p>1.downloaded php 8(non thread safe version) & extracted file to the path <code>c:\xampp\php8</code></p>
<p>2.As the <code>php.ini</code> file does not exists in the path <code>c:\xampp\php8</code>, created a new text file & named it <code>php.ini</code>.Copied the contents in <code>php.ini-development</code> to <code>php.ini</code> and uncommented the line</p>
<pre><code>extension_dir = "ext"
</code></pre>
<p>3.Added content mentioned in step 3 & step 4- option 2 with only modifications for the php version name as below.Below given is the full content of my current xampp - Apache config file (<code>httpd-xampp.conf</code>)</p>
<pre><code>#
# XAMPP settings
#
<IfModule env_module>
SetEnv MIBDIRS "C:/xampp/php/extras/mibs"
SetEnv MYSQL_HOME "\\xampp\\mysql\\bin"
SetEnv OPENSSL_CONF "C:/xampp/apache/bin/openssl.cnf"
SetEnv PHP_PEAR_SYSCONF_DIR "\\xampp\\php"
SetEnv PHPRC "\\xampp\\php"
SetEnv TMP "\\xampp\\tmp"
</IfModule>
#
# PHP-Module setup
#
LoadFile "C:/xampp/php/php7ts.dll"
LoadFile "C:/xampp/php/libpq.dll"
LoadFile "C:/xampp/php/libsqlite3.dll"
LoadModule php7_module "C:/xampp/php/php7apache2_4.dll"
<FilesMatch "\.php$">
SetHandler application/x-httpd-php
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler application/x-httpd-php-source
</FilesMatch>
#
# PHP-CGI setup
#
#<FilesMatch "\.php$">
# SetHandler application/x-httpd-php-cgi
#</FilesMatch>
#<IfModule actions_module>
# Action application/x-httpd-php-cgi "/php-cgi/php-cgi.exe"
#</IfModule>
<IfModule php7_module>
PHPINIDir "C:/xampp/php"
</IfModule>
<IfModule mime_module>
AddType text/html .php .phps
</IfModule>
ScriptAlias /php-cgi/ "C:/xampp/php/"
<Directory "C:/xampp/php">
AllowOverride None
Options None
Require all denied
<Files "php-cgi.exe">
Require all granted
</Files>
</Directory>
<Directory "C:/xampp/cgi-bin">
<FilesMatch "\.php$">
SetHandler cgi-script
</FilesMatch>
<FilesMatch "\.phps$">
SetHandler None
</FilesMatch>
</Directory>
<Directory "C:/xampp/htdocs/xampp">
<IfModule php7_module>
<Files "status.php">
php_admin_flag safe_mode off
</Files>
</IfModule>
AllowOverride AuthConfig
</Directory>
<IfModule alias_module>
Alias /licenses "C:/xampp/licenses/"
<Directory "C:/xampp/licenses">
Options +Indexes
<IfModule autoindex_color_module>
DirectoryIndexTextColor "#000000"
DirectoryIndexBGColor "#f8e8a0"
DirectoryIndexLinkColor "#bb3902"
DirectoryIndexVLinkColor "#bb3902"
DirectoryIndexALinkColor "#bb3902"
</IfModule>
Require local
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
Alias /phpmyadmin "C:/xampp/phpMyAdmin/"
<Directory "C:/xampp/phpMyAdmin">
AllowOverride AuthConfig
Require local
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
Alias /webalizer "C:/xampp/webalizer/"
<Directory "C:/xampp/webalizer">
<IfModule php7_module>
<Files "webalizer.php">
php_admin_flag safe_mode off
</Files>
</IfModule>
AllowOverride AuthConfig
Require local
ErrorDocument 403 /error/XAMPP_FORBIDDEN.html.var
</Directory>
</IfModule>
ScriptAlias /php8 "C:/xampp/php8"
Action application/x-httpd-php8-cgi /php8/php-cgi.exe
<Directory "C:/xampp/php8">
AllowOverride None
Options None
Require all denied
<Files "php-cgi.exe">
Require all granted
</Files>
</Directory>
Listen 8056
<VirtualHost *:8056>
<FilesMatch "\.php$">
SetHandler application/x-httpd-php8-cgi
</FilesMatch>
</VirtualHost>
</code></pre>
<ol start="4">
<li>saved its contents & restarted xampp & apache.</li>
</ol>
| [
{
"answer_id": 74232126,
"author": "Lukas Schmid",
"author_id": 11437648,
"author_profile": "https://Stackoverflow.com/users/11437648",
"pm_score": 2,
"selected": false,
"text": "()"
},
{
"answer_id": 74232403,
"author": "Dan",
"author_id": 16698885,
"author_profile":... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19946272/"
] |
74,232,156 | <p>I have the following table:</p>
<pre><code>CREATE TABLE table_one( person varchar(55), date_value date, proj varchar(2), value int, time varchar(2 );
INSERT INTO table_one VALUES
('A1',2020-10-01'W',10,'T1')
('A1',2020-10-01'A',5,'T2')
('A1',2020-10-01'P',6,'T3')
('A1',2020-10-01'A',9,'T4')
('A1',2020-10-01'P',11,'T5')
('A1',2020-10-01'A',4,'T6')
('A1',2020-10-01'P',2,'T7')
('A1',2020-10-01'A',1,'T8')
('A1',2020-10-01'P',10,'T9')
('A1',2020-10-01'A',8,'T10')
</code></pre>
<p>I want an SQL query which creates a new column 'new_value'. The following are the conditions to fill that new column:</p>
<p>Case-1 When proj = A and next row proj = P , then take value of Proj=a in new_value column corresponding to proj=p.</p>
<p>For example, for row 2 the proj value is A and row 3 proj value is P. So the new column value correspoding to row-3 should be 5.</p>
<p>Case-2 When last row = A and the first row is W, then allocate value of last row in new_value column.</p>
<p>For example, row-10 has proj value A and row-1 has proj value W. So the new_value column correspoding to row-1 should be 8.</p>
<p>CASE-3 New_val should be NULL when proj = A.</p>
<p>Refer to the following picture for visual help</p>
<p><a href="https://i.stack.imgur.com/S5KEJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S5KEJ.png" alt="enter image description here" /></a></p>
<p>the above query needs to be aggregated at person,date_value column.</p>
| [
{
"answer_id": 74232126,
"author": "Lukas Schmid",
"author_id": 11437648,
"author_profile": "https://Stackoverflow.com/users/11437648",
"pm_score": 2,
"selected": false,
"text": "()"
},
{
"answer_id": 74232403,
"author": "Dan",
"author_id": 16698885,
"author_profile":... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232156",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11455017/"
] |
74,232,163 | <p>I want to update my application to use Angular's <a href="https://angular.io/guide/template-typecheck#strict-mode" rel="nofollow noreferrer">template Strict mode</a> by setting <code>"strictTemplates": true</code> inside <code>tsconfig.json</code>. After running <code>ng serve</code> with the new config, I got a weird error.</p>
<p>I have a shared component that is used in a lot of places</p>
<pre><code>@Component({
selector: 'my-shared-component',
...
})
export class SharedComponent {
@Input() selectedId: string | number;
@Output() selectedIdChange = new EventEmitter<string | number>()
@Input() disabled: boolean;
...
}
</code></pre>
<p>and passing <code><my-shared-component disabled="true"></code> throws an error, which is fine.</p>
<p>The problem comes into play when I try to pass a <code>number</code> into the <code>@Input() selectedId: string | number;</code>, i.e.:</p>
<pre><code>export class OtherComponent {
myNumberId: number;
...
}
<my-shared-component [(selectedId)]="myNumberId">
</code></pre>
<p>And an error is thrown:</p>
<blockquote>
<p>TS2322: Type 'string | number' is not assignable to type 'number'</p>
</blockquote>
<p>I don't want to replace the type of <code>myNumberId</code> with <code>string | number</code> because it's also used in another component that has an <code>@Input id: number</code> (and must be a number). Also, <code>myNumberId</code> comes from the server and I know that is a number, so I think it will lead to poor design if I replace it with <code>string | number</code>.</p>
<p>I also don't want to use the <a href="https://angular.io/guide/template-typecheck#troubleshooting-template-errors" rel="nofollow noreferrer">strictAttributeTypes</a> config to false because afterwards <code><my-shared-component disabled="true"></code> will no longer throw an error.</p>
<p>I was wondering if there exists some typescript utility type (or something similar) to make <code>@Input() selectedId: string | number</code> accept only strings or numbers, without forcing the variables from the parent to be <code>string | number</code>. Or can I do something else to fix the problem?</p>
| [
{
"answer_id": 74232511,
"author": "MGX",
"author_id": 20059754,
"author_profile": "https://Stackoverflow.com/users/20059754",
"pm_score": -1,
"selected": false,
"text": "string | number"
},
{
"answer_id": 74233957,
"author": "TotallyNewb",
"author_id": 4550158,
"auth... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7646358/"
] |
74,232,180 | <p>Hello i am doing a proyect in pyhton with flask an i pretend to introduce a txt and read it.</p>
<p>This code is part of home.html:</p>
<pre><code><input type="file" id="gameTXT" name="gameTXT" accept="txt">
<input type="submit" id="submitTXT" value="Submit">
</code></pre>
<p>and this one is the part of python:</p>
<pre><code>@app.route("/")
def home():
return render_template('home.html')
</code></pre>
<p>How can i get the file? I read that i need to put methods=['GET'] but i don't know where to put it</p>
<p>I try to put methods=['GET'] in the app.route("/") but it doesn't work and it's understandable. I expect to get the file</p>
| [
{
"answer_id": 74232247,
"author": "sachin",
"author_id": 12681984,
"author_profile": "https://Stackoverflow.com/users/12681984",
"pm_score": -1,
"selected": false,
"text": "@app.route(\"/\", methods=[\"GET\"])\ndef home():\n return render_template('home.html')\n"
},
{
"answer... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232180",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19272736/"
] |
74,232,185 | <p>While going through the Android developer docs for TableLayout , I saw a line mentioning</p>
<blockquote>
<p>The children of a TableLayout cannot specify the layout_width
attribute."</p>
</blockquote>
<p>But in code if I use the layout_width attribute with TextView, the width gets increased accordingly.</p>
<p>Am I missing something?</p>
<pre><code><TableLayout xmlns:android="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#000"
android:orientation="vertical"
android:stretchColumns="*"
>
<TableRow android:padding="5dip">
<TextView
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:gravity="center"
android:text="loginForm"
android:textColor="#0ff"
android:textSize="25sp"
android:textStyle="bold" />
</TableRow>
<TableRow>
<TextView
android:layout_height="wrap_content"
android:layout_width="200dp"
android:layout_marginLeft="10dp"
android:text="User Name"
android:textColor="#fff"
android:textSize="16sp" />
<EditText
android:id="@+id/userName"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:background="#fff"
android:padding="5dp"
android:textColor="#000" />
</TableRow>
<TableRow>
<TextView
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:text="password"
android:textColor="#fff"
android:textSize="16sp" />
<EditText
android:id="@+id/password"
android:layout_height="wrap_content"
android:layout_marginLeft="10dp"
android:layout_marginTop="20dp"
android:background="#fff"
android:padding="5dp"
android:textColor="#000" />
</TableRow>
</TableLayout>
</code></pre>
| [
{
"answer_id": 74232247,
"author": "sachin",
"author_id": 12681984,
"author_profile": "https://Stackoverflow.com/users/12681984",
"pm_score": -1,
"selected": false,
"text": "@app.route(\"/\", methods=[\"GET\"])\ndef home():\n return render_template('home.html')\n"
},
{
"answer... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232185",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4264590/"
] |
74,232,186 | <p>Not sure if that is the correct terminology. Basically trying to take a black and white image and first transform it such that all the white pixels that border black-pixels remain white, else turn black. That part of the program works fine, and is done in find_edges. Next I need to calculate the distance from each element in the image to the closest white-pixel. Right now I am doing it by using a for-loop that is insanely slow. Is there a way to make the find_nearest_edge function written solely with numpy without the need for a for-loop to call it on each element? Thanks.</p>
<pre><code>####
from PIL import Image
import numpy as np
from scipy.ndimage import binary_erosion
####
def find_nearest_edge(arr, point):
w, h = arr.shape
x, y = point
xcoords, ycoords = np.meshgrid(np.arange(w), np.arange(h))
target = np.sqrt((xcoords - x)**2 + (ycoords - y)**2)
target[arr == 0] = np.inf
shortest_distance = np.min(target[target > 0.0])
return shortest_distance
def find_edges(img):
img = img.convert('L')
img_np = np.array(img)
kernel = np.ones((3,3))
edges = img_np - binary_erosion(img_np, kernel)*255
return edges
a = Image.open('a.png')
x, y = a.size
edges = find_edges(a)
out = Image.fromarray(edges.astype('uint8'), 'L')
out.save('b.png')
dists =[]
for _x in range(x):
for _y in range(y):
dist = find_nearest_edge(edges,(_x,_y))
dists.append(dist)
print(dists)
</code></pre>
<p>Images:</p>
<p><a href="https://i.stack.imgur.com/k5bQQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/k5bQQ.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/4KpSv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4KpSv.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74233017,
"author": "dankal444",
"author_id": 4601890,
"author_profile": "https://Stackoverflow.com/users/4601890",
"pm_score": 2,
"selected": true,
"text": "import numpy as np\nimport matplotlib.pyplot as plt\n\nfrom scipy.ndimage import binary_erosion\nfrom scipy.spatial... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232186",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18615293/"
] |
74,232,273 | <p>I have an endpoint as follows:</p>
<pre><code>https://myapi/user/1234
</code></pre>
<p>the body is</p>
<pre><code>{
"ExpiryDays": "50",
"Access1": "False",
"Access2": "True",
"Access3": "False",
"Address": "500",
}
</code></pre>
<p>In the database the columns and datatype are</p>
<pre><code> ExpiryDays int
Access1 bit, not null
Access2 bit, not null
Access3 bit, not null
Address nvarchar(max)
</code></pre>
<p>I would have though the False would be converted to a 0 and True to 1 when inserted in the db.</p>
<p>In my model in MVC I have defined the fields as bool.
But i get the error</p>
<blockquote>
<p>The JSON value could not be converted to System.Nullable`1[System.Boolean]. Path: $.Access1 .</p>
</blockquote>
<p>Any ideas as on this ?</p>
| [
{
"answer_id": 74232543,
"author": "tappetyclick",
"author_id": 1540766,
"author_profile": "https://Stackoverflow.com/users/1540766",
"pm_score": 2,
"selected": true,
"text": "{\n \"ExpiryDays\": 50, \n \"Access1\": False,\n \"Access2\": True,\n \"Access3\": False,\n \"Address\":... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232273",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19592688/"
] |
74,232,291 | <p>This is the code,</p>
<pre><code>import "./styles.css";
import Ank from "./Ank";
import { useState, useRef, useEffect } from "react";
export default function App() {
const [array, setArray] = useState(
JSON.parse(localStorage.getItem("notes")) ?? []
);
useEffect(() => {
localStorage.setItem("notes", JSON.stringify(array));
}, [array]);
const Add = () => {
setArray((e) => {
return [...e, one.current.value];
});
};
const deleting = (e) => {
setArray((e1) => {
return e1.filter((e2, index) => {
return index !== e - 1;
});
});
};
const one = useRef(null);
return (
<>
<div className="App">
<h1>Hello CodeSandbox</h1>
<div className="align">
<input ref={one} />
<br />
<br />
<button onClick={Add}>Add</button>
</div>
<div className="align">
{array.map((e, index) => {
return (
<Ank key={index} onSelect={deleting} index={index + 1} name={e} />
);
})}
</div>
</div>
</>
);
}
</code></pre>
<p>Please check the function <code>deleting</code> in the filter section I am trying to delete the elemt from the <code>array</code> using <code>setarray</code>.</p>
<p>This is the codesandbox link</p>
<p><a href="https://codesandbox.io/s/silly-neumann-b0foos?file=/src/App.js:0-1072" rel="nofollow noreferrer">https://codesandbox.io/s/silly-neumann-b0foos?file=/src/App.js:0-1072</a></p>
| [
{
"answer_id": 74232336,
"author": "KcH",
"author_id": 11737596,
"author_profile": "https://Stackoverflow.com/users/11737596",
"pm_score": 2,
"selected": true,
"text": "e"
},
{
"answer_id": 74232536,
"author": "Gyroscope",
"author_id": 20313154,
"author_profile": "htt... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232291",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19757319/"
] |
74,232,299 | <p>the problem with this code is that it will come to a point, in line 9 (<strong>if a[c+1] != 0:</strong>), it will recall an index +3 that does not exist and it will give me the error "list index out of range".</p>
<pre><code>a= '555101'
a= list(map(int,a))
c= 0
seq= []
for i in a:
if a[c] == 1:
if a[c+1] != 0:
seq.append(i)
c += 1
elif a[c+3] == 0: #error
if a[c+2] == 0:
seq.append(1000)
c += 1
elif a[c+2] != 0:
seq.append(10)
c += 1
elif a[c+2] == 0:
if a[c+1] == 0:
seq.append(100)
c += 1
elif a[c+1] != 0:
seq.append(1)
c += 1
elif a[c] == 0:
c += 1
elif a[c] == 5:
seq.append(i)
c += 1
print(seq)
</code></pre>
| [
{
"answer_id": 74232352,
"author": "ONG JIA YUAN",
"author_id": 20356281,
"author_profile": "https://Stackoverflow.com/users/20356281",
"pm_score": 0,
"selected": false,
"text": "a[c+2]"
},
{
"answer_id": 74232368,
"author": "bn_ln",
"author_id": 10535824,
"author_pro... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232299",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20338017/"
] |
74,232,316 | <pre><code>@Transactional
mymethod(){
repo.saveAll(Large data);
repo.save(small data); //updates db that the large data is written
}
</code></pre>
<p><strong>What I'm experiencing:</strong><br />
After the transactional method's successful execution the two datas are flushed async. That is the small data is written before the large data.</p>
<p><strong>What I want:</strong><br />
After the transactional method's successful execution the saveAll's data should be flushed first then the save's data should be flushed.</p>
<p>Is my understanding of, flush() of saveAll and save happening in async is correct? If yes, then how can I order the execution of flush of saveAll and save.</p>
| [
{
"answer_id": 74232352,
"author": "ONG JIA YUAN",
"author_id": 20356281,
"author_profile": "https://Stackoverflow.com/users/20356281",
"pm_score": 0,
"selected": false,
"text": "a[c+2]"
},
{
"answer_id": 74232368,
"author": "bn_ln",
"author_id": 10535824,
"author_pro... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232316",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12131806/"
] |
74,232,370 | <p>I want to have a smooth transition of the second-hand from sec==59 to sec==0.</p>
<p>It's going well from 0 to 59 seconds but on sec==59 it doesn't go forward instead it rolls back to 0 position. I'm trying to have a smooth transition from 59 to 0 in clockwise direction (same in second, minute and hour hands). Here's is the full code of the clock -</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let secHand = document.querySelector(".sec-hand")
let minHand = document.querySelector(".min-hand")
let hourHand = document.querySelector(".hour-hand")
let hands = document.querySelectorAll(".hand")
function setTime() {
const now = new Date();
const sec = now.getSeconds();
const secDegrees = ((sec / 60) * 360) + 90;
secHand.style.transform = `rotate(${secDegrees}deg)`;
const mint = now.getMinutes();
const mintDegrees = ((mint / 60) * 360) + 90;
minHand.style.transform = `rotate(${mintDegrees}deg)`;
const hour = now.getHours();
const hourDegrees = ((hour / 12) * 360) + 90;
hourHand.style.transform = `rotate(${hourDegrees}deg)`;
//console.log(`${hour} : ${mint} : ${sec}`)
}
setInterval(setTime, 1000)</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>* {
margin: 0;
padding: 0;
box-sizing: border-box;
}
.clock {
background: transparent;
width: 400px;
height: 400px;
margin: auto;
margin-top: 100px;
border-radius: 50%;
border: 20px solid blue;
position: absolute;
left: 200px;
}
.center-dot {
width: 50px;
height: 50px;
border-radius: 50%;
background: rgb(195, 4, 4);
position: absolute;
top: calc(50% - 25px);
left: calc(50% - 25px);
z-index: 5;
}
.hand {
width: 45%;
height: 10px;
background: black;
position: absolute;
top: calc(50% - 5px);
left: 5%;
border-radius: 10px;
transform-origin: right;
transition: all 0.5s;
transform: rotate(90deg)
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="clock">
<div class="center-dot"></div>
<div class="hour-hand hand"></div>
<div class="min-hand hand"></div>
<div class="sec-hand hand"></div>
</div></code></pre>
</div>
</div>
</p>
<p>I was following a video on this and in that, tutor mentioned two solutions-
first was keep counting continuously after sec=59 and not going back to sec=0 (but I didn't like this solution).
Second was temporarily remove transition when on sec==59 through JS. I don't know how to do that. I tried this in <code>setTime()</code> but didn't work -</p>
<pre><code>if(sec == 59) {
hands[2].setAttribute("transition", "");
}
</code></pre>
<p>Please help.
Thank you!</p>
| [
{
"answer_id": 74232805,
"author": "Harrison",
"author_id": 15291770,
"author_profile": "https://Stackoverflow.com/users/15291770",
"pm_score": 1,
"selected": false,
"text": "CSS"
},
{
"answer_id": 74232974,
"author": "lisonge",
"author_id": 10717907,
"author_profile"... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18727671/"
] |
74,232,384 | <p>I need to reproduce a scenario within the order confirmation email template where the billing address is missing.</p>
<p>It's an individual case which I can't reproduce by placing an order myself.</p>
<p>To reproduce that scenario I deleted all following orders until the one with the missing address in the mail were the latest.
I was thinking the template gets the information from the latest order but that wasn't the case.</p>
<p>So I am wondering where the mail templates get their values from.</p>
<p>Does anyone know the answer?</p>
| [
{
"answer_id": 74232734,
"author": "newgennerd",
"author_id": 12553209,
"author_profile": "https://Stackoverflow.com/users/12553209",
"pm_score": 1,
"selected": false,
"text": "mail_template_type"
},
{
"answer_id": 74243539,
"author": "Alex",
"author_id": 288568,
"aut... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232384",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18221536/"
] |
74,232,395 | <p>I want my script to perform the product of all its integer arguments. Instead of performing a loop I tried to replace blanks with <code>*</code> and then compute the operation. But I got the following result which I don't understand:</p>
<pre class="lang-bash prettyprint-override"><code>#!/bin/bash
# product.sh
echo $(( ${*// /*} )) # syntax error with ./product.sh 2 3 4
args=$*
echo $(( ${args// /*} )) # ./product.sh 2 3 4 => outputs 24
</code></pre>
<p>How is it that the first one produces an error while using an intermediate variable works fine?</p>
| [
{
"answer_id": 74232452,
"author": "anubhava",
"author_id": 548225,
"author_profile": "https://Stackoverflow.com/users/548225",
"pm_score": 3,
"selected": false,
"text": "IFS"
},
{
"answer_id": 74232639,
"author": "M. Nejat Aydin",
"author_id": 13809001,
"author_profi... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2074831/"
] |
74,232,407 | <p>As the title says, I clones a rails API. I tried to follow the steps in this article from point 2 onwards <a href="https://dev.to/w3ndo/a-checklist-for-setting-up-a-cloned-rails-application-locally-5468" rel="nofollow noreferrer">https://dev.to/w3ndo/a-checklist-for-setting-up-a-cloned-rails-application-locally-5468</a> but I keep getting the same error from db:setup onwards.</p>
<p><a href="https://i.stack.imgur.com/5KUUn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5KUUn.png" alt="enter image description here" /></a></p>
<p>Please help!</p>
<p>I have tried googling the answer and phoning a friend.</p>
<p>I have tried rails db:setup, rails db:seed, rails db:create, rails db:migrate.</p>
| [
{
"answer_id": 74232452,
"author": "anubhava",
"author_id": 548225,
"author_profile": "https://Stackoverflow.com/users/548225",
"pm_score": 3,
"selected": false,
"text": "IFS"
},
{
"answer_id": 74232639,
"author": "M. Nejat Aydin",
"author_id": 13809001,
"author_profi... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232407",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18359675/"
] |
74,232,417 | <p>Is there a difference between these two in Swift?</p>
<ul>
<li><code>protocol ABProtocol: AProtocol, BProtocol {}</code></li>
<li><code>typealias ABProtocol = AProtocol&BProtocol</code></li>
</ul>
| [
{
"answer_id": 74232570,
"author": "JeremyP",
"author_id": 169346,
"author_profile": "https://Stackoverflow.com/users/169346",
"pm_score": 2,
"selected": false,
"text": "AProtocol&BProtocol"
},
{
"answer_id": 74232576,
"author": "Sweeper",
"author_id": 5133585,
"autho... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2064473/"
] |
74,232,432 | <p>I've implemented an application that redirects to the wso2 identity server login page. If the login is successfull the user is redirected to a page where he can read his profile details.
Based on his role he can perform certain action, like create a new user.</p>
<p>I've implemented an API (http://localhost:8080/add-user) that calls this URL ( https://localhost:9443/t/carbon.super/oauth2/token) to generate the access token with the desired scope (for example internal_user_mgt_create) that I need in order to call
the wso2 SCIM2.0 API (<a href="https://is.docs.wso2.com/en/latest/apis/scim2-rest-apis/#/Users%20Endpoint/createUser" rel="nofollow noreferrer">https://is.docs.wso2.com/en/latest/apis/scim2-rest-apis/#/Users%20Endpoint/createUser</a>).</p>
<p>Everything works if I use grant_type=password and I use the user credentials to generate the access token to call the wso2 SCIM2.0 API, but I want to use "authorization_code" as grant_type to avoid sending user credentials in my application.</p>
<p>How can I do that? And I know that one of the parameters that I need to use this flow is "code", where can I get its value?</p>
| [
{
"answer_id": 74232570,
"author": "JeremyP",
"author_id": 169346,
"author_profile": "https://Stackoverflow.com/users/169346",
"pm_score": 2,
"selected": false,
"text": "AProtocol&BProtocol"
},
{
"answer_id": 74232576,
"author": "Sweeper",
"author_id": 5133585,
"autho... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232432",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14742326/"
] |
74,232,459 | <p>I have an <code>index.php</code> and <code>upload.php</code>. In <code>index.php</code> is a <code>form action="upload.php"</code> with <code>input type="file" id="file" name="file"</code> tag in it. PHP code is:</p>
<pre><code><?php
$file = $_FILES['file'];
print_r($file);
echo "test";
?>
</code></pre>
<p>For some reason it shows <code>echo</code> but <code>print_r()</code> doesn't work.</p>
<p>I've tried rewriting the code. Adding other identificators for the <code>input</code> tag inside <code>index.php</code> but it still doesn't work. What am I doing wrong?</p>
| [
{
"answer_id": 74232545,
"author": "Ramil Huseynov",
"author_id": 6711823,
"author_profile": "https://Stackoverflow.com/users/6711823",
"pm_score": 3,
"selected": true,
"text": "\n<form action=\"upload.php\" method=\"post\" enctype=\"multipart/form-data\">\n <p><input type=\"file\" name... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20241623/"
] |
74,232,487 | <p>I have an obj that looks like this.</p>
<pre><code>let obj= {
title:"my form",
endTIme:"2/20/22",
mainList:[
{
type:"multiple",
checked:false,
multiple:[
{
optionCheck: false,
optionAnswer:""
}
]
}
]
}
</code></pre>
<p>I also have a button that every time I click, I want the obj fields to retain all its values only that the multiple array field should append a new object . But I cant seem to figure it out. Please I really need help</p>
<p>I tried cloning using spread operator and I wasn't getting the result I want as I learnt that spread operator is best used for shallow cloning</p>
<pre><code>let newObj= {
...obj
mainList:[
...obj.mainList,
{
multiple:[
{
optionCheck: false,
optionAnswer:""
}
]
}
]
}
</code></pre>
<p>And this ends up duplicating the mainList instead.</p>
<p>What I want my result to like is this when I click the button once.</p>
<pre><code>let obj = {
title: "my form",
endTIme: "2/20/22",
mainList: [{
type: "multiple",
checked: false,
multiple: [
{
optionCheck: false,
optionAnswer: ""
},
{
optionCheck: false,
optionAnswer: ""
}]
}]
};
</code></pre>
| [
{
"answer_id": 74232545,
"author": "Ramil Huseynov",
"author_id": 6711823,
"author_profile": "https://Stackoverflow.com/users/6711823",
"pm_score": 3,
"selected": true,
"text": "\n<form action=\"upload.php\" method=\"post\" enctype=\"multipart/form-data\">\n <p><input type=\"file\" name... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20356092/"
] |
74,232,523 | <p>I'm encountering issue with emojis when trying to generate html output using xsl transformation under certain circumstances.</p>
<p>For instance, I've tested following xsl with different transformation engines:</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<xsl:stylesheet version="1.0" xmlns:xsl="http://www.w3.org/1999/XSL/Transform">
<xsl:output method="html" encoding="UTF-8"/>
<xsl:template match="/">
<xsl:text disable-output-escaping="yes">&lt;!doctype html&gt;</xsl:text>
<html>
<head>
<meta charset="UTF-8"/>
<meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
</head>
<body>
<textarea></textarea><br/>
<input type="text" value=""/>
</body>
</html>
</xsl:template>
</xsl:stylesheet>
</code></pre>
<p>I tested with exact same code (based on JAXP definition) for all transformers. I only changed the transformer instance class reference.</p>
<p>Saxon gives correct result:</p>
<p><a href="https://i.stack.imgur.com/MOYcC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MOYcC.png" alt="enter image description here" /></a></p>
<p>Java internal repackaged transformer based on xalan (aka com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl) is correct when emoji is put as text in textarea body, but generates wrong result for <code><input></code> field: it seems that emoji is wrong encoded when put in <code>value</code> attribute:</p>
<p><a href="https://i.stack.imgur.com/gefsp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gefsp.png" alt="enter image description here" /></a></p>
<p>Xalan 2.7.2 gives even worse result:</p>
<p><a href="https://i.stack.imgur.com/14KQx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/14KQx.png" alt="enter image description here" /></a></p>
<p>For different reasons (mainly license one), I would prefer using Xalan transformer. Any idea how I can make xalan manage emoji correctly ?</p>
<p>EDIT</p>
<p>The transformation is performed with following code:</p>
<pre><code>TransformerFactory factory = TransformerFactory.newInstance(
"com.sun.org.apache.xalan.internal.xsltc.trax.TransformerFactoryImpl",
null);
Transformer transformer = factory.newTransformer(new StreamSource(xsl));
DocumentSource domSource = new DocumentSource(doc);
OutputStream stream = response.getOutputStream();
transformer.transform(domSource, new StreamResult(stream));
stream.flush();
stream.close();
</code></pre>
<p>where <code>doc</code> is a dom4j document, <code>xsl</code> is the inputstream containing above stylesheet and <code>response</code> is a HttpServletResponse object which will receive the transformation result.</p>
| [
{
"answer_id": 74232793,
"author": "Martin Honnen",
"author_id": 252228,
"author_profile": "https://Stackoverflow.com/users/252228",
"pm_score": 1,
"selected": false,
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/X... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232523",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1585114/"
] |
74,232,537 | <p>I want to create a dictionary base SingleTon. Some simple example like:</p>
<pre><code>singleton = SingleTon()
singleton['a'] = 5
print(singleton['a']) #5
</code></pre>
<p>I have written a basic class:</p>
<pre><code>class SingleTonNew():
_instance = None
def __new__(cls, *args, **kwargs):
id = threading.get_ident()
if cls._instance is None:
cls._instance = super(SingleTonNew, cls).__new__({})
return cls._instance
def __setattr__(self, key, value):
id = threading.get_ident()
if id in self._instance:
self._instance[id][key] = value
else:
self._instance[id] = {key:value}
def __getattr__(self, item):
id = threading.get_ident()
return self._instance[id][item]
</code></pre>
<p>but it didn't work, how can I implement it. Thanks to everyone who answered the question.</p>
| [
{
"answer_id": 74232793,
"author": "Martin Honnen",
"author_id": 252228,
"author_profile": "https://Stackoverflow.com/users/252228",
"pm_score": 1,
"selected": false,
"text": "<?xml version=\"1.0\" encoding=\"UTF-8\"?>\n<xsl:stylesheet version=\"1.0\" xmlns:xsl=\"http://www.w3.org/1999/X... | 2022/10/28 | [
"https://Stackoverflow.com/questions/74232537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18859252/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.