qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,125,433 | <p>I have a problem when i am trying to update in my table
it wont updated and return
data []</p>
<p><a href="https://i.stack.imgur.com/1vbXT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1vbXT.png" alt="enter image description here" /></a></p>
<p>Function update in Controller</p>
<pre><code>public function update(StorePersonRequest $request, Person $person)
{
$person->update($request->all());
return new PersonResource($person);
}
</code></pre>
<p>StorePersonRequest :</p>
<pre><code>class StorePersonRequest extends FormRequest
{
/**
* Determine if the user is authorized to make this request.
*
* @return bool
*/
public function authorize()
{
return true;
}
/**
* Get the validation rules that apply to the request.
*
* @return array<string, mixed>
*/
public function rules()
{
return [
'CoPe'=>'required',
'NaPe'=>'required',
'PhoPe1'=>'required',
'Corq'=>'required',
];
}
</code></pre>
| [
{
"answer_id": 74125576,
"author": "Divyessh",
"author_id": 13810872,
"author_profile": "https://Stackoverflow.com/users/13810872",
"pm_score": 2,
"selected": true,
"text": "if getattr(sys, 'frozen', False):\n path = os.path.dirname(sys.executable)\nelif __file__:\n path = os.path.... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125433",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20282476/"
] |
74,125,448 | <p>Is there any option to print the user name that the google sheet file belongs to him? The one that resolved the comments the author gave him?</p>
<p>Thank you very much</p>
| [
{
"answer_id": 74125576,
"author": "Divyessh",
"author_id": 13810872,
"author_profile": "https://Stackoverflow.com/users/13810872",
"pm_score": 2,
"selected": true,
"text": "if getattr(sys, 'frozen', False):\n path = os.path.dirname(sys.executable)\nelif __file__:\n path = os.path.... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20270943/"
] |
74,125,454 | <p>Hello and thank you for coming here.</p>
<p>I have to do a program that will draw a number of square choosed by the user with incremental letter.
For example, if the user choose 4 square, it will return :</p>
<p>DDDDDDD</p>
<p>DCCCCCD</p>
<p>DCBBBCD</p>
<p>DCBABCD</p>
<p>DCBBBCD</p>
<p>DCCCCCD</p>
<p>DDDDDDD</p>
<p>At the time being, my code look like this ;</p>
<pre><code>
#include <iostream>
using namespace std;
int main()
{
int size;
int nbsquareletter;
cout << " How many square ?" << endl;
cin >> nbsquareletter;
size = nbsquareletter * 2 - 1;
char squareletter = 'a';
for (int row = 1; row <= size; ++row)
{
for (int col = 0; col <= size; ++col)
{
if (row < col) {
cout << (char)(squareletter + row - 1) << " ";
}
else if (row > col)
{
cout << (char)(squareletter + col) << " ";
}
/*
cout << col << " ";
cout << row << " ";
*/
}
cout << endl;
}
}
</code></pre>
<p>If you have any ideas to help me, don't hesitate, I'm struggling. it's been 3.5 hours. Thanks you for reading and have a good day !</p>
| [
{
"answer_id": 74125772,
"author": "Arty",
"author_id": 941531,
"author_profile": "https://Stackoverflow.com/users/941531",
"pm_score": 1,
"selected": false,
"text": "#include <iostream>\n\nint main() {\n int n = 0;\n std::cin >> n;\n char const letters[] = \"ABCDEFGHIJKLMNOPQRS... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11066662/"
] |
74,125,469 | <p>I have the following code snippet:</p>
<pre><code>contract Bar{
}
contract Foo {
Bar bar = new Bar();
}
</code></pre>
<p>When I am generating the class diagram from sol2uml I get the following diagram:</p>
<p><a href="https://i.stack.imgur.com/oS46V.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oS46V.png" alt="Class Diagram" /></a></p>
<p>I want to have a composition relation between Foo and Bar class.
<a href="https://i.stack.imgur.com/Mhs3Z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Mhs3Z.png" alt="enter image description here" /></a></p>
<p>I am not sure if this code is correct for this relationship or there is some problem with sol2uml.</p>
| [
{
"answer_id": 74125772,
"author": "Arty",
"author_id": 941531,
"author_profile": "https://Stackoverflow.com/users/941531",
"pm_score": 1,
"selected": false,
"text": "#include <iostream>\n\nint main() {\n int n = 0;\n std::cin >> n;\n char const letters[] = \"ABCDEFGHIJKLMNOPQRS... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125469",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17832861/"
] |
74,125,475 | <p>I am using tokens around my ReactJS application. This is how I can get the value of the token in a page:</p>
<p><strong>pages/Profile.js</strong></p>
<pre><code>import React from 'react';
import useToken from '../useToken';
export default function Profile() {
// Get token
const { token, setToken } = useToken();
const { userObject } = useToken();
return(
<div>
<p>
<b>Name:</b> {userObject?.name}<br />
<b>Email:</b> {userObject?.email}<br />
<b>Token:</b> {token}
</p>
</div>
);
}
</code></pre>
<p>Now I want to use the token inside a component. However the same appoch did not work, as it gives me an error "<em>Unexpected token. A constructor, method, accessor, or property was expected.ts(1068)</em>".</p>
<p><strong>components/MyKnownDevices.js</strong></p>
<pre><code>import React from 'react';
import axios from 'axios';
import useToken from '../useToken';
export default class MyKnownDevices extends React.Component {
// Get token
const { token, setToken } = useToken(); // <---- THIS GIVES ERROR
const { userObject } = useToken(); // <---- THIS GIVES ERROR
// Respone handler
state = {
myKnownDevices: []
}
// Call API
componentDidMount() {
let config = {
headers: {
Accept: 'application/json',
'Access-Control-Allow-Origin': '*',
rejectUnauthorized: false,
}
}
let data = {
'HTTP_CONTENT_LANGUAGE': 'no',
rejectUnauthorized: false,
}
axios.get('https://127.0.0.1:5000/api/users/get_my_known_devices', data, config)
.then(res => {
const myKnownDevices = res.data;
this.setState({ myKnownDevices });
})
};
render() {
return (
<ul>
{
this.state.myKnownDevices
.map((device, index) => {
return (
<li key={index}>
<span>{device.known_device_updated_timestamp_saying}</span>
</li>
);
}
)
}
</ul>
)
};
};
</code></pre>
<p><strong>useToken.js</strong></p>
<pre><code>import { useState, useEffect } from 'react';
import jwt_decode from "jwt-decode"
// const userObject = null;
export default function useToken() {
// Get token
const getToken = () => {
const userToken = localStorage.getItem('token');
return userToken
};
// Consts
const [token, setToken] = useState(getToken());
const [userObject, setUserObject] = useState(null);
// Effect
useEffect(() => {
if(token && token !== "undefined" && !userObject){
setUserObject(jwt_decode(token));
}
},[token]);
// Save token
const saveToken = userToken => {
if(userToken === null){
localStorage.removeItem('token');
setToken(null);
}
else{
localStorage.setItem('token', userToken.token);
setToken(userToken.token);
}
};
// Return value
return {
setToken: saveToken,
token,
userObject,
}
}
</code></pre>
<p>How can I get the value of the token inside my component MyKnownDevices.js?</p>
| [
{
"answer_id": 74125875,
"author": "Benjamin Cavy",
"author_id": 20241091,
"author_profile": "https://Stackoverflow.com/users/20241091",
"pm_score": 2,
"selected": true,
"text": "import React, {useEffect, useState} from \"react\";\nimport axios from \"axios\";\nimport useToken from \"../... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125475",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9827719/"
] |
74,125,481 | <pre><code>def property_factory(n: int) -> property:
getter = lambda self: return n
return property(getter)
class Foo:
number: int = property_factory(1)
</code></pre>
<p>The above code gives me the errror (line 6)</p>
<blockquote>
<p>Expression of type "property" cannot be assigned to declared type int</p>
</blockquote>
<p>How do I go about type hinting dynamically created properties?</p>
| [
{
"answer_id": 74125945,
"author": "CreepyRaccoon",
"author_id": 18342123,
"author_profile": "https://Stackoverflow.com/users/18342123",
"pm_score": -1,
"selected": false,
"text": "int"
},
{
"answer_id": 74135052,
"author": "Mechanic Pig",
"author_id": 17980931,
"auth... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125481",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18266834/"
] |
74,125,487 | <p>I have a list of JSON files in a variable and I want to load the content of these files into a single object. The json files have two keys: metadata and outputs.</p>
<p>Once this is done, I want to call a function that generates a list of tables.
I am able to do this if I have only one file.
The code I use to do so is:</p>
<pre><code>jQuery.getJSON(filePath, function(data) {
jQuery.each(data, function(key, val){
if ( key === "outputs"){
new tableGenerator(val);
};
});
});
</code></pre>
<p>when I try to get the data from different files I obtain an empty variable.
To load different files I use:</p>
<pre><code>var fileList = ["dataFolder/data1.json",
"dataFolder/data2.json",
"dataFolder/data3.json"]
var jsonData = [];
jQuery.when(
fileList.forEach( file => {
jQuery.getJSON(file, function(data) {
jQuery.each(data, function(key, val){
if ( key === "outputs"){
jsonData = jsonData.concat(val);
};
});
});
})
).then(function(){
console.log(jsonData);
new tableGenerator(jsonData);
})
</code></pre>
<p>I don't work normally in javascript and I don't understand why normally the tableGenerator function is executed before the jsonData handler is filled.</p>
<p>Any comment in the code is welcome (style, deprecated...) as I am not a javascript developer and probably a lot of things will be done in an uncommon way.</p>
| [
{
"answer_id": 74125666,
"author": "epascarello",
"author_id": 14104,
"author_profile": "https://Stackoverflow.com/users/14104",
"pm_score": 2,
"selected": false,
"text": "getJSON"
},
{
"answer_id": 74125712,
"author": "Filip Zieliński",
"author_id": 11347715,
"author... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125487",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5362881/"
] |
74,125,497 | <p>I have a query like this in mongodb:</p>
<pre><code>db.Product.aggregate([
{ $addFields: { maxSku: { $max: '$ProductVariants.FullSku' } } },
{ $group: { _id: null, value: { $max: '$maxSk' } } }
])
</code></pre>
<p>but how can I execute it using mongodb driver (linq) in C#?</p>
<p>I've tried to use <code>db.RunCommandAsync</code> but that's not working</p>
<pre><code>var command = new JsonCommand<BsonDocument>("db.Product.aggregate([{ $addFields: { maxSku: { $max: '$ProductVariants.FullSku' } } },{ $group: { _id: null, value: { $max: '$maxSk' } } }])");
var result = await _productRepository.Database.RunCommandAsync<BsonDocument(command);
</code></pre>
<p>the error is</p>
<pre><code>JSON reader was expecting a value but found 'db'.
at MongoDB.Bson.IO.JsonReader.ReadBsonType()...etc
</code></pre>
| [
{
"answer_id": 74125666,
"author": "epascarello",
"author_id": 14104,
"author_profile": "https://Stackoverflow.com/users/14104",
"pm_score": 2,
"selected": false,
"text": "getJSON"
},
{
"answer_id": 74125712,
"author": "Filip Zieliński",
"author_id": 11347715,
"author... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11954502/"
] |
74,125,508 | <p>i have the random data in which i plotted graph for finding the peaks which is originated from zero i used this code</p>
<pre><code>op_col = []
for i in df['Speed ']:
op_col.append(i)
print(op_col)
</code></pre>
<p>converting 'Speed' values to 1d array using for loop
<code>[0, 7, 18, 24, 26, 27, 26, 25, 26, 16, 20, 16, 23, 33, 27, 27, 22, 26, 27, 26, 25, 24, 25, 26, 23, 25, 26, 24, 23, 12, 22, 11, 15, 24, 11, 12, 11, 27, 19, 25, 26, 21, 23, 26, 13, 9, 22, 18, 23, 26, 26, 25, 10, 22, 27, 25, 19, 10, 15, 20, 21, 13, 16, 16, 15, 19, 17, 20, 24, 26, 20, 23, 23, 25, 19, 15, 16, 27, 26, 27, 28, 24, 23, 24, 27, 28, 30, 31, 30, 9, 0, 11, 16, 25, 25, 22, 25, 25, 11, 15, 24, 24, 24, 17, 0, 23, 21, 0, 24, 26, 24, 26, 26, 26, 24, 25, 24, 24, 22, 22, 22, 23, 24, 26]</code> this are my array values for plotting graph</p>
<pre><code>import matplotlib.pyplot as plt
import numpy as np
from scipy.signal import find_peaks
from scipy import signal
peak, _ = find_peaks(x,height=0)
fig= plt.figure(figsize=(19,5))
plt.plot(x)
plt.plot(peak, x[peak], "x", color = 'r')
</code></pre>
<p>my code is detecting every peak value, but I want it to detect from 0 to max peak red marks values. how to do that?</p>
<p><a href="https://i.stack.imgur.com/JlnC2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JlnC2.png" alt="enter image description here" /></a></p>
<p>the points has to be marked above 23 unable to do how can i do that</p>
| [
{
"answer_id": 74127157,
"author": "Shankar Challa",
"author_id": 15367393,
"author_profile": "https://Stackoverflow.com/users/15367393",
"pm_score": -1,
"selected": false,
"text": "x = [0, 7, 18, 24, 26, 27, 26, 25, 26, 16, 20, 16, 23, 33, 27, 27, 22, 26, 27, 26, 25, 24, 25, 26, 23, 25,... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125508",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19908761/"
] |
74,125,528 | <p>this is my code and I think it's 100% correct</p>
<pre><code>@Serializable
@Entity(tableName = "user_table")
data class User(
@PrimaryKey(autoGenerate = true)
var userID: Int = 1,
var fullName: String = "Missing",
var email: String = "Missing",
var password: String = "Missing",
var phone: Long = -1,
var profileImage: String = "Missing",
var userType: Int = -1,
) {
constructor(
userID: Int = 1
) : this(
fullName = "Missing",
email = "Missing",
password = "Missing",
phone = -1,
profileImage = "Missing",
userType = -1,
)
}
</code></pre>
<p>also, why <code>tableName & autoGenerate</code> not showing in blue color
<a href="https://i.stack.imgur.com/JcMY4.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JcMY4.png" alt="enter image description here" /></a></p>
<p>Because the code was working for me before, but now I don't know why it doesn't work now</p>
| [
{
"answer_id": 74127157,
"author": "Shankar Challa",
"author_id": 15367393,
"author_profile": "https://Stackoverflow.com/users/15367393",
"pm_score": -1,
"selected": false,
"text": "x = [0, 7, 18, 24, 26, 27, 26, 25, 26, 16, 20, 16, 23, 33, 27, 27, 22, 26, 27, 26, 25, 24, 25, 26, 23, 25,... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18823812/"
] |
74,125,530 | <p>I am trying to migrate my redux store to RTK and RTK query - and making my RTL tests work with it</p>
<p>I am going for a gradual re-write - transforming each reducer 1 by 1.</p>
<p>I have re-created my store used in the application - replacing createStore with a configureStore - and added the middleware for api handling like this:</p>
<pre><code>import { vendorPaymentsApiSlice } from './vendorPaymentsAPISlice';
const rootReducer = combineReducers({
users: userReducer,
[vendorPaymentsApiSlice.reducerPath]: vendorPaymentsApiSlice.reducer
})
//vendorPaymentsApiSlice.reducerPath is set to "vendorpaymentsApi"
const store = configureStore({
reducer: rootReducer,
middleware: [
...getDefaultMiddleware(),
sagaMiddleware,
vendorPaymentsApiSlice.middleware,
],
});
</code></pre>
<p>This setup is working fine in the real application. The middleware linking for api is working as expected.</p>
<p>For my tests i am using a mock store - which replaces history with mockHistory but it is mostly the same code- same rootReducer and same middleware array.</p>
<p>In my tests I have written a msw interceptor for the api call -
and the interceptor is getting called:</p>
<p><a href="https://i.stack.imgur.com/B3EBv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B3EBv.png" alt="enter image description here" /></a></p>
<p>but as soon as that happens - I am getting this error message:</p>
<pre><code>Warning: Middleware for RTK-Query API at reducerPath "vendorpaymentsApi" has not been added to the store.
Features like automatic cache collection, automatic refetching etc. will not be available.
</code></pre>
<p>Because of this - the data setting in redux from the api is failing .</p>
<p>I tried many variations of adding the middleware after reading <a href="https://stackoverflow.com/questions/71249368/warning-middleware-for-rtk-query-api-at-reducerpath-api-has-not-been-added-to">this</a> and tried</p>
<pre><code>getDefaultMiddleware().concat([
sagaMiddleware,
vendorPaymentsApiSlice.middleware,
])
</code></pre>
<p>but it's still not working.</p>
<p>Wanted some help to understand why the linking of this api is not happening with the tests.</p>
<p>Thanks a lot for reading this</p>
| [
{
"answer_id": 74127157,
"author": "Shankar Challa",
"author_id": 15367393,
"author_profile": "https://Stackoverflow.com/users/15367393",
"pm_score": -1,
"selected": false,
"text": "x = [0, 7, 18, 24, 26, 27, 26, 25, 26, 16, 20, 16, 23, 33, 27, 27, 22, 26, 27, 26, 25, 24, 25, 26, 23, 25,... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2095022/"
] |
74,125,536 | <p>I'm trying to make a simple countup timer with a start/stop button. I don't understand why the while loop crashes the page even though it has a 1sec delay. Is there a easier way to keep updating the time until I press the button?</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 startButton = document.getElementById("btn-start-stop");
let timerOutput = document.getElementById("timer");
let runTimer = false;
let sec = 0;
let startTimer = false;
console.log(startTimer);
startButton.onclick = function () {
startTimer = !startTimer;
while (startTimer) {
setInterval(function () {
console.log(sec);
}, 1000);
}
};</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<meta name="description" content="an exercise to manipulate DOM-elements">
<meta name="author" content="lars berg">
<meta name="keywords" content="a template for at exercise">
<link rel="stylesheet" type="text/css" href="css/style.css">
<title>DOM | Manipulate</title>
<script src="https://kit.fontawesome.com/fa41e523cd.js" crossorigin="anonymous"></script>
<script src="scripts/script.js" defer></script>
</head>
<body>
<header>
<h1>DOM | Manipulation</h1>
</header>
<main>
<div class="flex-container">
<div class="counter-container">
<h2 class="h2-counter">How long time will it take to read this information?</h2>
<div id="timer">
00:00:00
</div>
<div class="buttons">
<button id="btn-start-stop" type="button">
<i class="fa-solid fa-play fa-2x"></i>
</button>
<button id="btn-reset" type="button">
<i class="fa-solid fa-arrow-rotate-left fa-2x"></i>
</button>
</div>
</div>
</div>
</main>
<footer>
</footer>
</body>
</html></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74125621,
"author": "0stone0",
"author_id": 5625547,
"author_profile": "https://Stackoverflow.com/users/5625547",
"pm_score": 3,
"selected": true,
"text": "while()"
},
{
"answer_id": 74125733,
"author": "Syed Arsalan Hussain",
"author_id": 14733216,
"au... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125536",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20104975/"
] |
74,125,542 | <p>I'm trying to figure out how I can set an "expiration timer" on a message sent by a Telegram bot, containing a few buttons.</p>
<p>Long story short, there's a function which selects a random picture from a folder, then sends it to a group, and in a separate message it sends an InlineKeyboard object with some buttons for the picture to be rated</p>
<pre class="lang-py prettyprint-override"><code>def send_stuff(context: CallbackContext):
job = context.job
keyboard = [
[
InlineKeyboardButton("NEVER", callback_data="NEVER"),
InlineKeyboardButton("UNLIKELY", callback_data="UNLIKELY")
],
[
InlineKeyboardButton("MEH", callback_data="MEH"),
InlineKeyboardButton("MAYBE", callback_data="MAYBE")
],
[
InlineKeyboardButton("YES", callback_data="YES"),
InlineKeyboardButton("ABSOLUTELY", callback_data="ABSOLUTELY")
],
[
InlineKeyboardButton("RATHER NOT SAY", callback_data="UNKNOWN")
]
]
reply_markup = InlineKeyboardMarkup(keyboard)
context.bot.send_photo(job.context, photo=open(PATH+thefile, 'rb'))
context.bot.send_message(job.context, text='RATE', reply_markup=reply_markup)
</code></pre>
<p>This function is being run by a run_daily job:</p>
<pre class="lang-py prettyprint-override"><code>def start(update: Update, context: CallbackContext):
job = context.job
chat_id = update.message.chat_id
context.job_queue.run_daily(
send_stuff,
datetime.time(13, 45, 00, 000000, tzinfo=pytz.timezone('Europe/Bucharest')),
days=tuple(range(7)),
context=chat_id,
name='j1'
)
</code></pre>
<p>Then there is a handler for the user input, which edits the last message sent by the bot:</p>
<pre class="lang-py prettyprint-override"><code>def main_handler(update: Update, context: CallbackContext):
update.callback_query.answer()
if update.callback_query.data is not None:
user_input = update.callback_query.data
update.effective_message.edit_text('VERDICT: ' + user_input)
</code></pre>
<p>What I'm trying to do is set some kind of "expiration" on the message containing the inline keyboard buttons, such that if there is no click by a user in say... 4 hours, it automatically edits itself into something like "NO ANSWER GIVEN".</p>
<p>I'm not super experienced with bots, and looking through the documentation of the telegram bot libraries I have not been able to find a way to do it.</p>
<p>Any suggestions are appreciated.</p>
<p>Thanks!</p>
| [
{
"answer_id": 74127615,
"author": "CallMeStag",
"author_id": 10606962,
"author_profile": "https://Stackoverflow.com/users/10606962",
"pm_score": 2,
"selected": true,
"text": "JobQueue"
},
{
"answer_id": 74152768,
"author": "lambdacore",
"author_id": 3536060,
"author_... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125542",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3536060/"
] |
74,125,550 | <p>I installed react-native and created a new project using the command
<code>npx react-native init AwesomeProject</code> (I have not added any code) and when I run the project using <code>npx react-native run-android</code>
I get an error <strong>Task :app:processDebugResources FAILED</strong></p>
<p>After using <code>--warning-mode all</code> I now get the following feedback:</p>
<blockquote>
<p>IncrementalTaskInputs has been deprecated. This is scheduled to be
removed in Gradle 8.0. On method
'IncrementalTask.taskAction$gradle_core' use
'org.gradle.work.InputChanges' instead. Consult the upgrading guide
for further information:
<a href="https://docs.gradle.org/7.5.1/userguide/upgrading_version_7.html#incremental_task_inputs_deprecation" rel="nofollow noreferrer">https://docs.gradle.org/7.5.1/userguide/upgrading_version_7.html#incremental_task_inputs_deprecation</a>
at react_umo8btiw38k009lp8jdme1yz$_run_closure8$_closure10$_closure13.doCall(C:\Windows\System32\AwesomeProject\node_modules\react-native\react.gradle:395)
(Run with --stacktrace to get the full stack trace of this deprecation warning.)</p>
</blockquote>
<p>How can I fix this? I wasted hours trying to fix it. I just want to to code a bit but I'm instead stuck at this..</p>
<p>JDK version: 11.0.16.1</p>
<p>Gradle version: 7.5.1</p>
| [
{
"answer_id": 74398655,
"author": "Top-Master",
"author_id": 8740349,
"author_profile": "https://Stackoverflow.com/users/8740349",
"pm_score": 1,
"selected": false,
"text": "IncrementalTaskInputs"
},
{
"answer_id": 74637119,
"author": "Omotayo Kuye",
"author_id": 6365204... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19818886/"
] |
74,125,579 | <p>Given an interface</p>
<pre><code>interface Foo {
value1: boolean;
value2: boolean;
}
</code></pre>
<p>how may I create an object based on this interface that has all its value set to <code>true</code> (or false)?</p>
<p>Something that might illustrate what I mean:</p>
<pre><code>const object: Foo = { [keyof Foo]: true }
</code></pre>
<p>Any help would be much appreciated.</p>
| [
{
"answer_id": 74125640,
"author": "Nir Alfasi",
"author_id": 1057429,
"author_profile": "https://Stackoverflow.com/users/1057429",
"pm_score": 1,
"selected": false,
"text": "implements"
},
{
"answer_id": 74126573,
"author": "caTS",
"author_id": 18244921,
"author_prof... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8902744/"
] |
74,125,593 | <p>I'm relatively new to programming/Python/NumPy, so I apologize if my ignorance is showing...</p>
<p>Say I have two 2d NumPy arrays:</p>
<pre><code>import numpy as np
a = np.array([[1, 5, 20],
[2, 15, float("NaN")],
[4, float("NaN"), float("NaN")]])
b = np.array([[4, float("NaN")],
[1, 13],
[5, float("NaN")]])
</code></pre>
<p>I would like to find the differences between all elements of the first row of each matrix, differences between all elements of the second row of each matrix, and so on. An example of a desired result given the above matrices is</p>
<pre><code>[[ 3. nan -1. nan -16. nan] # <-- differences between all elements b[0] and a[0]
[ -1. 11. -14. -2. nan nan] # <-- differences between all elements b[1] and a[1]
[ 1. nan nan nan nan nan]] # <-- differences between all elements b[2] and a[2]
</code></pre>
<p>A way of obtaining the above result while using a loop is</p>
<pre><code>outcome = []
for a_row, b_row in zip(a, b):
outcome.append((b_row - a_row[:,None]).flatten())
outcome = np.array(outcome)
</code></pre>
<p>However, is there a way about this without looping through the rows that would be faster?</p>
| [
{
"answer_id": 74125640,
"author": "Nir Alfasi",
"author_id": 1057429,
"author_profile": "https://Stackoverflow.com/users/1057429",
"pm_score": 1,
"selected": false,
"text": "implements"
},
{
"answer_id": 74126573,
"author": "caTS",
"author_id": 18244921,
"author_prof... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125593",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20282322/"
] |
74,125,602 | <p>I have built a libpcre2-8.dll with the help of <a href="https://github.com/kiyolee/pcre2-win-build" rel="nofollow noreferrer">this</a> Git Repo.</p>
<p>I'm now trying to access the function pcre2_compile from an ABL (Progress) program. (Progress is an old 4GL Language). I'm constantly hitting the error</p>
<pre><code>Could not find the entrypoint _pcre2_compile@40. (3260)
</code></pre>
<p>I've already tried many things but it still doesn't work.</p>
<p>The Dynamic Library is 64 bit and Progress is also running in 64 bit.</p>
<p>In ABL (Progress) you can specify the LIBRARY-CALLING-CONVENTION but whether I set it to STDCALL or CDECL or just don't specify it, the error remains the same.</p>
<p>This is a snippet of the Progress ABL I'm trying to execute the function: (code comes from <a href="https://github.com/gabsoftware/Progress-ABL-4GL-Regex" rel="nofollow noreferrer">this Git Repo</a>, which works, but only for 32 bit)</p>
<pre><code>PROCEDURE pcre2_compile :
DEFINE INPUT PARAMETER pattern AS CHARACTER. /* const char * */
DEFINE INPUT PARAMETER options AS INTEGER. /* int */
DEFINE OUTPUT PARAMETER errcodeptr AS INTEGER. /* int * */
DEFINE OUTPUT PARAMETER errptr AS MEMPTR. /* const char ** */
DEFINE OUTPUT PARAMETER erroffset AS MEMPTR. /* int * */
DEFINE INPUT PARAMETER tableptr AS INTEGER. /* const unsigned char * */
DEFINE OUTPUT PARAMETER result AS MEMPTR. /* pcre * */
DEFINE VARIABLE libName AS CHARACTER NO-UNDO.
DEFINE VARIABLE hCall AS HANDLE NO-UNDO.
libName = get-library().
CREATE CALL hCall.
ASSIGN
hCall:CALL-NAME = "pcre2_compile"
hCall:LIBRARY = "lib/libpcre2-8.dll"
//hCall:LIBRARY-CALLING-CONVENTION = "STDCALL"
hCall:CALL-TYPE = DLL-CALL-TYPE
hCall:NUM-PARAMETERS = 6
hCall:RETURN-VALUE-DLL-TYPE = "MEMPTR".
hCall:SET-PARAMETER(1, "CHARACTER", "INPUT" , pattern ).
hCall:SET-PARAMETER(2, "LONG" , "INPUT" , options ).
hCall:SET-PARAMETER(3, "HANDLE TO LONG" , "OUTPUT", errcodeptr ).
hCall:SET-PARAMETER(4, "MEMPTR" , "OUTPUT", errptr ).
hCall:SET-PARAMETER(5, "MEMPTR" , "OUTPUT", erroffset ).
hCall:SET-PARAMETER(6, "LONG" , "INPUT" , tableptr ).
hCall:INVOKE().
ASSIGN result = hCall:RETURN-VALUE.
DELETE OBJECT hCall.
END PROCEDURE.
</code></pre>
<p>What am I missing?</p>
<p>Update: Checked with Dependency Walker and the functions seem to be visible. They do have a _8 suffix... But even when trying pcre2_compile_8 it still gives me the same error.</p>
<p><a href="https://i.stack.imgur.com/SfCiF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SfCiF.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74127571,
"author": "nwahmaet",
"author_id": 18177,
"author_profile": "https://Stackoverflow.com/users/18177",
"pm_score": 0,
"selected": false,
"text": "ORDINAL"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125602",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/26521/"
] |
74,125,629 | <p>Is there a way to get a list of each of the hyperlinks created by the "publish to web" function on google sheets without selecting each tab individually and copying and pasting to a spreadsheet/word document. Ideally the output being all my tab names (circa 200 of them) and the link.</p>
<p>Any help or advice would be greatly appreciated.</p>
<p><a href="https://i.stack.imgur.com/OXFrH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OXFrH.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74127571,
"author": "nwahmaet",
"author_id": 18177,
"author_profile": "https://Stackoverflow.com/users/18177",
"pm_score": 0,
"selected": false,
"text": "ORDINAL"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13705563/"
] |
74,125,652 | <p>So I'm trying to render out my data and I want to have a filter so I could filter through them. My filter looks something like this: <a href="https://i.stack.imgur.com/60Ei3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/60Ei3.png" alt="UI Component of the filter" /></a></p>
<p>So far, I have logic that is being used to filter <code>completed</code> and <code>deleted</code> item and it is connected to the <code><Switch /></code> (toggle) as shown in the picture. The code is as follows:<br />
<strong>Note that <code>items</code> is the original array of items and <code>filteredItems</code> is what I mutate everytime I filter.</strong></p>
<pre class="lang-js prettyprint-override"><code>useEffect(() => {
if (completedSwitch && deletedSwitch) {
setFilteredItems(
items
.filter((el) => el.completed && el.deleted)
);
} else if (completedSwitch) {
setFilteredItems(
items
.filter((el) => el.completed)
);
} else if (deletedSwitch) {
setFilteredItems(
items
.filter((el) => el.deleted)
);
} else {
setFilteredItems(items);
}
// eslint-disable-next-line
}, [completedSwitch, deletedSwitch]);
</code></pre>
<p>What I do not understand is how can I integrate the rest of the filters (the multi-select from <code>username, type, variety, size</code> to the <code>useEffect</code> logic. I know I shouldn't be writing all of the conditions into an <code>if/else</code> statement which would be a little crazy. How should I approach this problem? Separate them into 2 <code>useEffect</code>? What is your take on this problem?</p>
<p>Additional info:<br />
Currently, I'm storing all of the multi-select values into a state, so I have something like:</p>
<pre class="lang-js prettyprint-override"><code>const [filteredUser, setFilteredUser] = useState<string>("");
// and so on...
// and an event handler to store the data
const handleUserSelect = (e: React.FormEvent<HTMLSelectElement>) => {
setFilteredUser(e.currentTarget.value);
}
// the multi-select component
<HTMLSelect onChange={handleUserSelect}>
<option>User</option>
<option value="A">A</option>
<option value="B">B</option>
<option value="C">C</option>
// and so on...
</HTMLSelect>
</code></pre>
| [
{
"answer_id": 74127571,
"author": "nwahmaet",
"author_id": 18177,
"author_profile": "https://Stackoverflow.com/users/18177",
"pm_score": 0,
"selected": false,
"text": "ORDINAL"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125652",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16170683/"
] |
74,125,667 | <p>I am searching for a way to easily add more character fields to the default user model from Django. This question has been asked, but I couldn't find an up to date answer.</p>
<p>I let Django handle all the authenticating and logging in, so I don't want to create a custom user model, any ideas?</p>
| [
{
"answer_id": 74127571,
"author": "nwahmaet",
"author_id": 18177,
"author_profile": "https://Stackoverflow.com/users/18177",
"pm_score": 0,
"selected": false,
"text": "ORDINAL"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125667",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18298825/"
] |
74,125,686 | <p>This problem has been haunting me for the last 24 hours, and I've been messing around with my amateur python coding skills to no avail.</p>
<p>The problem in question is this:</p>
<p>You are given the numbers 1 to 9 (inclusive). Inbetween each number is a space where you are able to insert a mathmatical operator. You are given 2 addition symbols and 2 subtraction symbols, and you have to use them all. If there is no operator between 2 numbers, for example, 1 2, then when inputted into the final equation would become 12. This would be the same with 3 numbers e.g. 1 2 3, which would become 123.</p>
<p>You cannot move or rotate the numbers nor can you rotate the symbols around (e.g. + -> x), but you can put the symbols in any slot between the numbers you desire. The idea here is to create a script whereby you are able to calculate a specific number summative of the numbers given.</p>
<p>I will list some examples below to better portray what the question actually wants you to create:</p>
<p><code>123+45-67+8-9</code></p>
<p><code>12-34+56-7+89</code></p>
<p><code>1-234+56-78+9</code></p>
<p>I would appreciate any ideas of how to script this to find all available permutations of making a certain number. There is no certain output number in particular, just something versatile to cover any number (in reason) you wanted to output.</p>
| [
{
"answer_id": 74127571,
"author": "nwahmaet",
"author_id": 18177,
"author_profile": "https://Stackoverflow.com/users/18177",
"pm_score": 0,
"selected": false,
"text": "ORDINAL"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125686",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8520162/"
] |
74,125,694 | <p>I want to store and retrieve data from a DynamoDB table.</p>
<p>My data (an item = a review a user gave on a feature of an app) have the following attributes :</p>
<pre><code>user string
feature string
appVersion string
timestamp string
rate int
description string
</code></pre>
<p>There is multiple features, on multiple versions of the app, and an user can give multiple reviews on these features. So I would like to use (<code>user</code>, <code>appVersion</code>, <code>feature</code>, <code>timestamp</code>) as a primary key.</p>
<p>But it does not seem to be possible to use that much attributes in a primary key in DynamoDB.</p>
<p>The first solution I implemented is to use <code>user</code> as a <code>Partition Key</code>, and a hash of (<code>appVersion</code>, <code>feature</code>, <code>timestamp</code>) as a <code>Sort Key</code> (in a new field named <code>reviewID</code>).</p>
<p>My problem is that, I want to retrieve an item for a given <code>user</code>, <code>feature</code>, <code>appVersion</code> without knowing the <code>timestamp</code> value (let's say I want the item with the latest <code>timestamp</code>, or the list of all items matching the 3 fields)</p>
<p>Without knowing the <code>timestamp</code>, I can't build the <code>Sort Key</code> necessary to retrieve my item. But if I remove the <code>timestamp</code> from the <code>Sort Key</code>, I will not be able to store multiple items having the same (<code>user</code>, <code>appVersion</code>, <code>feature</code>).</p>
<p>What would be the proper way to handle this usecase ?</p>
<p>I am thinking about using a hash of (<code>user</code>, <code>appVersion</code>, <code>feature</code>) as a <code>Partition Key</code>, and the <code>timestamp</code> as a <code>Sort Key</code>, would this be a correct solution ?</p>
| [
{
"answer_id": 74125928,
"author": "J-Jacques M",
"author_id": 3956263,
"author_profile": "https://Stackoverflow.com/users/3956263",
"pm_score": 0,
"selected": false,
"text": "HASH string \"modelName\": \"user\"\nRANGE string \"id\": \"b0d5be50-4fae-11ed-981f-dbffcc56c88a\"\n"
},
{
... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125694",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7766158/"
] |
74,125,722 | <p>Given the following HTML:</p>
<pre><code><div>
Ag<div class="rect"></div>
</div>
<div>
Ag<div class="rect"></div>
</div>
</code></pre>
<p>I want the size of <code>.rect</code> to be the size of the largest character box, so it should align with the ascender height (the A in this example) and go down to the descender height (the g in this example).</p>
<p>A possible solution is to set the height of <code>.rect</code> to the line height and to write an <code>&nbsp;</code> inside it:</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 {
line-height: 1.5em;
}
.rect {
height: 1.5em;
width: 10rem;
display: inline-block;
background-color: red;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>
Ag<div class="rect">&nbsp;</div>
</div></code></pre>
</div>
</div>
</p>
<p>But I'm dissatisfied with this solution because it requires me to make sure the div height is consistent with the local line height and the additional <code>&nbsp;</code> is just noise. Also, setting <code>.rect</code> to the line height, isn't strictly what I want because it could be larger or smaller than the actual characters.</p>
<p>Is there an alternative solution?</p>
| [
{
"answer_id": 74125928,
"author": "J-Jacques M",
"author_id": 3956263,
"author_profile": "https://Stackoverflow.com/users/3956263",
"pm_score": 0,
"selected": false,
"text": "HASH string \"modelName\": \"user\"\nRANGE string \"id\": \"b0d5be50-4fae-11ed-981f-dbffcc56c88a\"\n"
},
{
... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2989330/"
] |
74,125,738 | <p>Is there a way to get the name or code for the colours in <strong>Set3</strong> colour palette of ggplot2?</p>
<p><a href="https://i.stack.imgur.com/j1Oqy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/j1Oqy.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74125773,
"author": "Quinten",
"author_id": 14282714,
"author_profile": "https://Stackoverflow.com/users/14282714",
"pm_score": 3,
"selected": true,
"text": "brewer.pal"
},
{
"answer_id": 74125809,
"author": "Konrad Rudolph",
"author_id": 1968,
"author_... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125738",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3639557/"
] |
74,125,744 | <p>I have a table with what is supposed to be a list of Active directory users. In many cases they have invalid characters in the name</p>
<p>I need to have a query that will select only those that have a user name that doesn't contain</p>
<p>any of these characters.</p>
<pre><code>"\/[]:;|=,+*?<>
</code></pre>
<p>something like</p>
<p><code>select username from userlist where username not like regex</code></p>
<p>I see how I can easily filter one of those but not sure how to look for any of them.</p>
| [
{
"answer_id": 74126414,
"author": "SQLpro",
"author_id": 12659872,
"author_profile": "https://Stackoverflow.com/users/12659872",
"pm_score": 1,
"selected": false,
"text": "WHERE MyColumn LIKE '%[\"\\/:;|=,+*?<>]%' \n OR CHARINDEX('[', MyColumn) > 0\n OR CHARINDEX(']', MyColumn) > 0\... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125744",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13520940/"
] |
74,125,757 | <p>I have a table on my server where they have already pivoted the data so now I am sitting with a table that looks something like this.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: center;">Client_No</th>
<th style="text-align: center;">20200201</th>
<th style="text-align: center;">20200401</th>
<th style="text-align: center;">20220101</th>
<th style="text-align: center;">20220201</th>
<th style="text-align: center;">20220301</th>
<th style="text-align: center;">20220401</th>
<th style="text-align: center;">20220501</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">123456789</td>
<td style="text-align: center;">3</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">0</td>
</tr>
<tr>
<td style="text-align: center;">321654987</td>
<td style="text-align: center;">4</td>
<td style="text-align: center;">4</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">4</td>
<td style="text-align: center;">2</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">0</td>
</tr>
</tbody>
</table>
</div>
<p>this table gets updated monthly so to automate the script I want to be able to do something like this</p>
<pre><code>Select Client_No
, Sum(column like '2022%')
From [table_name]
</code></pre>
<p>Is this possible? Basically I want the script to sum all the columns that start with 2022, and yes I am currently running this in SSMS</p>
| [
{
"answer_id": 74126136,
"author": "tgolisch",
"author_id": 283895,
"author_profile": "https://Stackoverflow.com/users/283895",
"pm_score": 1,
"selected": false,
"text": "Sum"
},
{
"answer_id": 74126258,
"author": "Anel Hodžić",
"author_id": 4018834,
"author_profile":... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3643482/"
] |
74,125,759 | <p>Is it correct to add event to Bloc in initState or didChangeDependencies?</p>
<p>I tried to add event in initState and didChangeDependencies. But throw this exception.</p>
<p>But when this page opens again, everything work fine.</p>
<pre class="lang-bash prettyprint-override"><code>The following StateError was thrown building BlocBuilder<SlotsBloc, SlotsState>(dirty, dependencies: [_InheritedProviderScope<SlotsBloc?>], state: _BlocBuilderBaseState<SlotsBloc, SlotsState>#29045):
Bad state: No element
</code></pre>
| [
{
"answer_id": 74126136,
"author": "tgolisch",
"author_id": 283895,
"author_profile": "https://Stackoverflow.com/users/283895",
"pm_score": 1,
"selected": false,
"text": "Sum"
},
{
"answer_id": 74126258,
"author": "Anel Hodžić",
"author_id": 4018834,
"author_profile":... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13323601/"
] |
74,125,766 | <p>I would like to compare two data frames, for example</p>
<pre><code>import pandas as pd
az_df = pd.DataFrame({'name': ['CR1', 'CR2'], 'age': [1, 5], 'dr':[1, 2]})[['name', 'age']]
za_df = pd.DataFrame({'name': ['CR2', 'CR1'], 'age': [2, 1], 'dr':[2, 4]})[['name', 'age']]
</code></pre>
<p>AZ_DF table:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>name</th>
<th>age</th>
<th>dr</th>
</tr>
</thead>
<tbody>
<tr>
<td>CR1</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>CR2</td>
<td>5</td>
<td>2</td>
</tr>
</tbody>
</table>
</div>
<p>ZA_DF table:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>name</th>
<th>age</th>
<th>dr</th>
</tr>
</thead>
<tbody>
<tr>
<td>CR1</td>
<td>1</td>
<td>4</td>
</tr>
<tr>
<td>CR2</td>
<td>2</td>
<td>2</td>
</tr>
</tbody>
</table>
</div>
<p>And I want to get the summary table of different values grouped by 'name' and 'age' columns between az_df and za_df, like:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>name</th>
<th>only in AZ</th>
<th>only in ZA</th>
</tr>
</thead>
<tbody>
<tr>
<td>CR2</td>
<td>5</td>
<td>2</td>
</tr>
</tbody>
</table>
</div>
<p>So far, I did merged them,</p>
<pre><code>merge = pd.merge(az_df, za_df, how='outer', indicator=True)
</code></pre>
<p>For az_df, different values are:</p>
<pre><code>only_in_az = merge[merge['_merge'] == 'left_only']
</code></pre>
<p>And for za_df:</p>
<pre><code>only_in_za = merge[merge['_merge'] == 'right_only']
</code></pre>
<p>However, I don't know how to build the summary table, I mentioned above, showing the different names' ages for az and za data frames.</p>
<p>Thank you.</p>
| [
{
"answer_id": 74126569,
"author": "gtomer",
"author_id": 10836309,
"author_profile": "https://Stackoverflow.com/users/10836309",
"pm_score": 2,
"selected": true,
"text": "import pandas as pd\n\naz_df = pd.DataFrame({'name': ['CR1', 'CR2'], 'age': [1, 5], 'dr':[1, 2]})[['name', 'age']]\n... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2843665/"
] |
74,125,769 | <p>I am making a simple application in Django, where I want my admins to be able to go into the admin panel and create a <strong>Level</strong> object</p>
<pre><code>class Level(models.Model):
content = models.CharField(max_length = 200)
</code></pre>
<p>^^ This is my simple layout for the model, only admins can create this.</p>
<p>However, when my admins create the <strong>Level</strong> object, it shows up like this:</p>
<p><a href="https://i.stack.imgur.com/xMXBv.png" rel="nofollow noreferrer">How it shows up in admin panel</a></p>
<p>I don't want this, and I want that to be replaced with the string <em>content</em>, which is a field in my <strong>Level</strong> model</p>
<p>So instead of looking like above, I want it to just contain the <em>context</em>.</p>
<p>How can I do this?</p>
| [
{
"answer_id": 74125797,
"author": "Hemal Patel",
"author_id": 16250404,
"author_profile": "https://Stackoverflow.com/users/16250404",
"pm_score": 0,
"selected": false,
"text": "class Level(models.Model):\n content = models.CharField(max_length = 200)\n\n def __str__(self):\n ... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18739334/"
] |
74,125,774 | <p>My pandas dict looks like this:</p>
<pre><code>import pandas as pd
data = {'address': ["William J. Clare\\n290 Valley Dr.\\nCasper, WY 82604\\nUSA",
"1180 Shelard Tower\\nMinneapolis, MN 55426\\nUSA",
"William N. Barnard\\n145 S. Durbin\\nCasper, WY 82601\\nUSA",
"215 S 11th ST"]
}
df = pd.DataFrame(data)
df_dict = df.to_dict('records')
for row in df_dict:
add = row["address"]
print(add.split("\\n"), len(add.split("\\n")))
</code></pre>
<p>If you see I need to write an if statement to pop the 1st or 1st 2 elements in the dict if <code>len(add.split("\\n"))</code> is equal to 4 then pop the 1st element and if <code>len(add.split("\\n"))</code> is equal to 5 then pop the 1st two elements and save it has a pandas dataframe.</p>
<p>Your help will be greatly appreciated. I am stuck with this because when I give the if statement it says pop operation cannot be applied for str objects.</p>
<p>Thanks</p>
| [
{
"answer_id": 74125797,
"author": "Hemal Patel",
"author_id": 16250404,
"author_profile": "https://Stackoverflow.com/users/16250404",
"pm_score": 0,
"selected": false,
"text": "class Level(models.Model):\n content = models.CharField(max_length = 200)\n\n def __str__(self):\n ... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20271577/"
] |
74,125,779 | <p>I have created an API that is protected by OAuth using an app registration in Azure.
My app registration does not require assignment, but it exposes a number of roles that the underlying API verifies. To my understanding, this accomplishes almost the same thing as requiring approval.</p>
<p>So far I've only had user/group roles but now I've added an application role intended for integrators, and I want other application owners to be able to request permission to my API. I, as the API owner, would like to review these and either reject or consent to the request. E.g. I don't want <em>everyone</em> to be able to access my API within the tenant without my knowledge, just like all users/groups don't have access with me assigning them to a role.</p>
<p>The <a href="https://learn.microsoft.com/en-gb/azure/active-directory/develop/custom-rbac-for-developers" rel="nofollow noreferrer">Role-based access control for application developers</a> documentation makes it very clear who manages access:</p>
<blockquote>
<p>...an application developer defines roles rather than authorizing individual users or groups. An administrator can then assign roles to different users and groups to control who has access to content and functionality.</p>
</blockquote>
<p>However, if you create a role with allowed member types set to application, things are not quite as clear and it seems to behave more like a scope, where I give up any access management. Also from my limited understanding, a <em>scope</em> is used when the API needs to request data from the user (e.g. wanting to read their username), whereas a <em>role</em> is used for the application developer to control access to what they are developing.</p>
<p>This is what it looks like when I request access to my API from another app:
<a href="https://i.stack.imgur.com/jtAmX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jtAmX.png" alt="enter image description here" /></a></p>
<p>This same page mentions the following information:</p>
<blockquote>
<p>The "Admin consent required" column shows the default value for an organization. However, user consent can be customized per permission, user, or app. This column may not reflect the value in your organization, or in organizations where this app will be used.</p>
</blockquote>
<p>As well as:</p>
<blockquote>
<p>Applications are authorized to call APIs when they are granted permissions by users/admins as part of the consent process</p>
</blockquote>
<p>However, from my reading, it sounds like this never gives me, as the API owner, any insight into who has access to the API I own. I want to control application access the same way I'd assign a group or user to a role in the enterprise application.</p>
<p>Can this be achieved when it's an application on the other end, not a user? If not, how would I allow applications to integrate in a controlled manner?</p>
| [
{
"answer_id": 74125797,
"author": "Hemal Patel",
"author_id": 16250404,
"author_profile": "https://Stackoverflow.com/users/16250404",
"pm_score": 0,
"selected": false,
"text": "class Level(models.Model):\n content = models.CharField(max_length = 200)\n\n def __str__(self):\n ... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125779",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1688639/"
] |
74,125,780 | <p>I want to build a hash table using a linked list</p>
<p>But there is a problem during compilation</p>
<p>I have tried using an array instead of a vector, but still the same result</p>
<p>Maybe it has something to do with the template?</p>
<p>I don't understand the sample code related to template</p>
<p>Here is some code that reproduces the problem, along with the error message</p>
<pre><code>#include <iostream>
#include <vector>
using namespace std;
struct node
{
string key;
string value;
node* next;
};
class HashTable
{
private:
vector<node*> bucket;
long long int capacity;
public:
HashTable(long long int max_size = 100)
{
capacity = max_size;
bucket.reserve(capacity);
bucket.resize(capacity);
fill(bucket.begin(), bucket.end(), NULL);
}
};
</code></pre>
<pre><code>Build started...
1>------ Build started: Project: C++ Test, Configuration: Debug x64 ------
1>C++ Test.cpp
1>E:\Other\Visual Studio\VC\Tools\MSVC\14.33.31629\include\xutility(4519,24): error C2440: '=': cannot convert from 'const _Ty' to 'node *'
1> with
1> [
1> _Ty=int
1> ]
1>E:\Other\Visual Studio\VC\Tools\MSVC\14.33.31629\include\xutility(4519,24): message : Conversion from integral type to pointer type requires reinterpret_cast, C-style cast or parenthesized function-style cast
1>C:\Users\DaLaw2\source\repos\C++ Test\C++ Test.cpp(30): message : see reference to function template instantiation 'void std::fill<std::_Vector_iterator<std::_Vector_val<std::_Simple_types<_Ty>>>,int>(const _FwdIt,const _FwdIt,const int &)' being compiled
1> with
1> [
1> _Ty=node *,
1> _FwdIt=std::_Vector_iterator<std::_Vector_val<std::_Simple_types<node *>>>
1> ]
1>Done building project "C++ Test.vcxproj" -- FAILED.
========== Build: 0 succeeded, 1 failed, 0 up-to-date, 0 skipped ==========
</code></pre>
| [
{
"answer_id": 74125967,
"author": "Ted Lyngmo",
"author_id": 7582247,
"author_profile": "https://Stackoverflow.com/users/7582247",
"pm_score": 3,
"selected": false,
"text": "#include <algorithm> // fill\n#include <cstddef> // size_t\n#include <string> // string\n#include <vector... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20282241/"
] |
74,125,791 | <p>I'm working on building this SQL function that is a lot more complex than what I'm usually used to, and I could really use some community eyes to bounce this off of. It's a question that is hard to word, so please bear with me.</p>
<p>I have a data table of items in a kit. Let's say my kit has 10 items, and my kit is on back order, because 1 item doesn't have enough stock for that kit.</p>
<p>I have a report that shows all kits that can be taken off of back order if the items can fill a kit.</p>
<p>My query was returning all back ordered kits, because it's returning all of the items still with enough stock to fill the kit. So, it would return 9 of the 10 items and report that it can be taken off of back order, which is wrong.</p>
<p>With how the data is structured and linked, sadly the back order status is linked to the kit, not the item stock. So, I need some sort of SQL query that can see every item in the kit, can see if every item can fill the kit, and only return the result if all items are in stock.</p>
<p>I basically need to have two sub-queries that can compare the results.
So I was thinking in pseudo code:</p>
<pre><code>SELECT [needed fields]
FROM kits k
JOIN items i USING (k.itemid)
IF (subquery 1 results that finds properly backed ordered kits)
IS NOT IN (subquery 2 results that finds all items with enough stock for a kit)
THEN results are good to send back to report.
</code></pre>
<p>I'm trying my best to keep this all SQL, and I'm going to keep working on this after the question is posted.</p>
<p>Okay, since people wanted some sort of tangible SQL, here's the complex web I'm working with. fair warning, there is a lot of nomenclature and names that don't match up with my simplified example above.</p>
<p>This query below is returning the one material properly marked in a partial.</p>
<pre><code>SELECT DISTINCT p.jobid, p.partialid, p.quantity, p.holdstamp, fn_normalize_desc(p.description) AS pdesc, fn_normalize_desc(j.description) AS jdesc,
printdate, DATE(duedate) AS duedate, fn_get_partial_status(p.partialid) AS status, c.client, i.materialid, m.matcode, m.quantity AS mquant
FROM partials p
JOIN jobs j USING (jobid)
JOIN clients c USING (clientid)
LEFT JOIN insertion_guides i
ON p.partialid = i.partialid
LEFT JOIN materials m
ON i.materialid = m.materialid
LEFT JOIN componentdata_mailgroups g
ON p.partialid = g.partialid
LEFT JOIN componentdata_groups d
ON p.partialid = d.partialid
WHERE p.quantity > m.quantity AND p.complete_date IS NULL AND g.maildate IS NULL AND fn_get_partial_status(p.partialid) = 'Waiting for Materials' AND d.discarded IS NULL
HAVING COUNT(p.quantity < m.quantity AND p.complete_date IS NULL AND g.maildate IS NULL AND fn_get_partial_status(p.partialid) = 'Waiting for Materials' AND d.discarded IS NULL) > 0;
</code></pre>
<p>So my second step I'm trying to do, is compare the results of this query #1 above, to my query #2 that returns a list of partials that can be taken off hold, and exclude the results of query #1.</p>
| [
{
"answer_id": 74126966,
"author": "Chris Maurer",
"author_id": 5440883,
"author_profile": "https://Stackoverflow.com/users/5440883",
"pm_score": 1,
"selected": false,
"text": "Select k.kitid \nFrom kits k Left Outer Join (\n Select itemid from items\n Group By itemid\n Having s... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17626613/"
] |
74,125,792 | <p>When I use the Playwright's codegen feature it traces my clickpath into a Java file. But the created file has the wrong syntax, so I can't compile it.</p>
<p>I start the codegen with:</p>
<pre><code>mvn exec:java -e -Dexec.mainClass=com.microsoft.playwright.CLI -Dexec.args="codegen wikipedia.org"
</code></pre>
<p>And the inspector provides this code:</p>
<pre><code>public class Example {
public static void main(String[] args) {
try (Playwright playwright = Playwright.create()) {
Browser browser = playwright.chromium().launch(new BrowserType.LaunchOptions()
.setHeadless(false));
BrowserContext context = browser.newContext();
page.navigate("https://en.wikipedia.org/wiki/Main_Page");
page.getByPlaceholder("Search Wikipedia").click();
page.getByPlaceholder("Search Wikipedia").fill("stackoverflow");
page.getByRole("button", new Page.GetByRoleOptions().setName("Go")).click();
assertThat(page).hasURL("https://en.wikipedia.org/wiki/Stack_Overflow");
}
}
}
</code></pre>
<p><a href="https://i.stack.imgur.com/QIOFN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QIOFN.png" alt="enter image description here" /></a></p>
<p>But there is already the first error. The method <code>getByRole</code> requires an AriaRole as its first parameter, not a String. So it's easy to fix, but I think it's not the idea of the product to generate code and let the developer fix it.</p>
<p>In some YouTube tutorials the inspector generates only fill and click functions with powerful selectors inside.</p>
<p>Is there a way to change the generated output to a specifc "code-style"? Or is there another reason why other people get nice working code and I don't?</p>
<p>My dependency:</p>
<pre><code><dependency>
<groupId>com.microsoft.playwright</groupId>
<artifactId>playwright</artifactId>
<version>1.27.0</version>
</dependency>
</code></pre>
| [
{
"answer_id": 74126966,
"author": "Chris Maurer",
"author_id": 5440883,
"author_profile": "https://Stackoverflow.com/users/5440883",
"pm_score": 1,
"selected": false,
"text": "Select k.kitid \nFrom kits k Left Outer Join (\n Select itemid from items\n Group By itemid\n Having s... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16963686/"
] |
74,125,795 | <p>I want to write a function where any keys can be extracted to give the values. Here is the dictionary and the code that I wrote and the input:</p>
<pre><code>DNAcodon2aa = {"aaa":"K", "aac":"N", "aag":"K", "aat":"N",
"aca":"T", "acc":"T", "acg":"T", "act":"T",
"aga":"R", "agc":"S", "agg":"R", "agt":"S",
"ata":"I", "atc":"I", "atg":"M", "att":"I",
"caa":"Q", "cac":"H", "cag":"Q", "cat":"H",
"cca":"P", "ccc":"P", "ccg":"P", "cct":"P",
"cga":"R", "cgc":"R", "cgg":"R", "cgt":"R",
"cta":"L", "ctc":"L", "ctg":"L", "ctt":"L",
"gaa":"E", "gac":"D", "gag":"E", "gat":"D",
"gca":"A", "gcc":"A", "gcg":"A", "gct":"A",
"gga":"G", "ggc":"G", "ggg":"G", "ggt":"G",
"gta":"V", "gtc":"V", "gtg":"V", "gtt":"V",
"taa":"*", "tac":"Y", "tag":"*", "tat":"T",
"tca":"S", "tcc":"S", "tcg":"S", "tct":"S",
"tga":"*", "tgc":"C", "tgg":"W", "tgt":"C",
def translate(codon_list):
"""This function translates a list of codons into a primary amino acid sequence. """
codon_list = DNAcodon2aa.keys()
newcodon = ''.join(codon_list)
protein = ''
for i in range(0, len(newcodon),3):
codon = newcodon[i:i+3]
protein += DNAcodon2aa[codon]
return protein
</code></pre>
<p>input</p>
<pre><code>translate(['tct','act','gct','gcc'])
</code></pre>
<p>output wanted:</p>
<pre><code>'STAA'
</code></pre>
<p>output produced</p>
<pre><code>'KNKNTTTTRSRSIIMIQHQHPPPPRRRRLLLLEDEDAAAAGGGGVVVV*Y*TSSSS*CWCLFLF'
</code></pre>
<p>it gave me the concatenation of all values in the dict instead of the values of certain keys in the input. I have tried and researched all possible codes that I could do but failed. any help would be appreciated.</p>
| [
{
"answer_id": 74125853,
"author": "Rahul K P",
"author_id": 4407666,
"author_profile": "https://Stackoverflow.com/users/4407666",
"pm_score": 1,
"selected": false,
"text": "str.join"
},
{
"answer_id": 74125855,
"author": "Steven Rumbalski",
"author_id": 1322401,
"aut... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125795",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20282680/"
] |
74,125,818 | <p>I'm trying to implement the clone_into_box pattern in a piece of code the uses callbacks, and I'm running into an error I'm having trouble understanding.</p>
<p>Basically, I'm cloning the parameter of a lambda, but the borrow checker still complains I'm leaking a reference to said parameter.</p>
<p>My question: is this a case of the borrow checker being overly conservative (and if so, how can I re-write this in a way that would play nicely with the borrow checker), or is there something I'm missing here and a reference is indeed being leaked despite the clone?</p>
<p>Code:</p>
<pre><code>pub trait CloneIntoBox{
fn clone_into_box<'a>(&self) -> Box<dyn CloneIntoBox + 'a>;
}
impl<'a> Clone for Box<dyn CloneIntoBox + 'a> {
fn clone(&self) -> Self {
self.as_ref().clone_into_box()
}
}
#[derive(Clone)]
pub struct StructWithBox<'a> {
pub my_box: Box<dyn CloneIntoBox + 'a>,
}
#[derive(Clone)]
struct StructThatCanBeClonedIntoBox {
pub data: u32,
}
impl CloneIntoBox for StructThatCanBeClonedIntoBox {
fn clone_into_box<'a>(&self) -> Box<dyn CloneIntoBox + 'a> {
Box::new(self.clone())
}
}
pub type WalkCallback<'a> = dyn FnMut(&StructWithBox) + 'a;
pub fn walk(data: Vec<u32>, cb: &mut WalkCallback) {
for d in data{
let instance = StructWithBox{my_box: Box::new(StructThatCanBeClonedIntoBox{data:d})};
cb(&instance);
}
}
fn main() {
let data = vec![1, 2];
let mut result = vec![];
walk(data, &mut|param| result.push((*param).clone()));
}
</code></pre>
<p><a href="https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=80768178088472499d13667f577b5ec2" rel="nofollow noreferrer">[Playground link]</a></p>
<p>Gives:</p>
<pre class="lang-none prettyprint-override"><code>error[E0521]: borrowed data escapes outside of closure
--> src/main.rs:39:28
|
38 | let mut result = vec![];
| ---------- `result` declared here, outside of the closure body
39 | walk(data, &mut|param| result.push((*param).clone()));
| ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `param` escapes the closure body here
| |
| `param` is a reference that is only valid in the closure body
</code></pre>
| [
{
"answer_id": 74127767,
"author": "Chayim Friedman",
"author_id": 7884305,
"author_profile": "https://Stackoverflow.com/users/7884305",
"pm_score": 2,
"selected": true,
"text": "'a"
},
{
"answer_id": 74143924,
"author": "internet_user",
"author_id": 5770658,
"author_... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20282743/"
] |
74,125,828 | <p><a href="https://i.stack.imgur.com/STX8a.jpg" rel="nofollow noreferrer">Link to the flowchart i made</a></p>
<p>I want to make a program that accepts a string of 1’s and 0’s. It should output ‘ is valid’ if and only if the string starts with 1, the second with 0, and the last be 1. The string can be of any length. If the string does not follow the conditions and is composed of letters or special characters, the program should state that is invalid. This is my coded version of this and it prints invalid when i type 101 and when i typed 10 it is valid.</p>
<pre><code>x = str(input('Enter numbers: '))
if x == '10':
print('string is valid')
else:
print('Invalid Input')
</code></pre>
| [
{
"answer_id": 74125914,
"author": "matszwecja",
"author_id": 9296093,
"author_profile": "https://Stackoverflow.com/users/9296093",
"pm_score": 1,
"selected": false,
"text": "import re\n\npattern = \"10[01]*1$\"\n\ns = \"101101\"\n\nmatch = re.match(pattern=pattern, string=s)\n\nif match... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20137415/"
] |
74,125,835 | <p>Hi I am trying to upload an image to Linkedin via Spring RestTemplate, the steps followed are as follows
1.Initialize the upload and the upload url
2.Use the upload url to PUT the image linked in server</p>
<p>below is the method for step 2</p>
<pre><code>public String uploadImageToURL(MultipartFile file, String uploadURL) throws IOException {
HttpHeaders headers = new HttpHeaders();
headers = new HttpHeaders();
headers.setContentType(MediaType.MULTIPART_FORM_DATA);
headers.add("Authorization", "Bearer Redacted");
MultiValueMap<String, Object> body = new LinkedMultiValueMap<>();
body.add("file", file.getBytes());
HttpEntity<MultiValueMap<String, Object>> reqEntity = new HttpEntity<>(body, headers);
try {
ResponseEntity<String> resp = new RestTemplate().exchange(uploadURL, HttpMethod.PUT, reqEntity, String.class);
} catch (HttpClientErrorException e) {
e.printStackTrace();
}
}
</code></pre>
<p>the method is giving -</p>
<pre><code>org.springframework.web.client.HttpClientErrorException$BadRequest: 400 Bad Request: [no body]
</code></pre>
<p>I am not able to figure out what's wrong here also from the documentation of linkedin apis its not clear they have given a basic curl request which working fine on postman but programmatically its not working</p>
<p><a href="https://learn.microsoft.com/en-us/linkedin/marketing/integrations/community-management/shares/vector-asset-api?view=li-lms-2022-10&tabs=http#sample-curl-request" rel="nofollow noreferrer">Curl</a> for the above method as per documentation</p>
<p>Any help is appreciated, I have tried giving content-type to header as image/png but no effect.</p>
<p>PS: I have already referred this link <a href="https://stackoverflow.com/questions/64871730/linkedin-v2-api-image-upload-get-error-400-bad-request">Linkedin v2 API Image upload get error 400 Bad Request</a> but its not helping</p>
| [
{
"answer_id": 74125914,
"author": "matszwecja",
"author_id": 9296093,
"author_profile": "https://Stackoverflow.com/users/9296093",
"pm_score": 1,
"selected": false,
"text": "import re\n\npattern = \"10[01]*1$\"\n\ns = \"101101\"\n\nmatch = re.match(pattern=pattern, string=s)\n\nif match... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125835",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1132056/"
] |
74,125,836 | <p>I have the array with ids</p>
<pre><code>const [selected, setSelected] = React.useState<readonly string[]>([]);
var selectedId = props.selectedId;
</code></pre>
<p>When clicking on the clean button I have added a useState() which check the given selectedId has a value or not
If selectedId has a value then add a value in array, if not then remove all the elements from the array</p>
<pre><code>useEffect(() => {
if (selectedId != undefined) {
// Add selectedId in selectedIdsList
setSelected(selectedId)
} else {
// remove all elements from setSelected
}
}, [selectedId]);
</code></pre>
<p>How to delete all elements from array</p>
| [
{
"answer_id": 74126057,
"author": "Vishal Beep",
"author_id": 15739040,
"author_profile": "https://Stackoverflow.com/users/15739040",
"pm_score": 3,
"selected": true,
"text": "selectedIdsList = []"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125836",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20076454/"
] |
74,125,881 | <p>I am trying to pass complex list of data to .net core web api controller but values are not binding, below is the code that I am using.</p>
<pre><code>public IActionResult Add([FromForm]List<SponsorViewModel> sponsorDetailsList,
IFormFile profilePic)
</code></pre>
<p>Can anyone please help? I already checked other stack overflow questions but it is not solving the issue.</p>
| [
{
"answer_id": 74126057,
"author": "Vishal Beep",
"author_id": 15739040,
"author_profile": "https://Stackoverflow.com/users/15739040",
"pm_score": 3,
"selected": true,
"text": "selectedIdsList = []"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8537500/"
] |
74,125,910 | <p>I am on a Ubuntu OS, in a Bash shell, trying to use <code>grep</code> to find all occurrences of substring <code>engineBreakdown()</code> inside a .tra extention log file, let's say <code>my_log_16.tra</code>, and save the results inside a file, let's say <code>results_16.txt</code></p>
<p>So I run</p>
<pre><code>cat /path/to/my_log_16.tra | grep "engineBreakdown()" > results_16.txt
</code></pre>
<p>and when I run <code>less results_16.txt</code> I actually see that there inside are saved some lines containing the substring, but they are not all the lines I expected.</p>
<p>In fact, when I manually search the occurrences of <code>engineBreakdown()</code> down <code>my_log_16.tra</code>, I see that there are other lines containing the substring, but these are not saved into <code>results_16.txt</code>. So it seems that my command only saves the first occurrences of the substring.</p>
<p>I think the grep may fail because <code>my_log_16.tra</code> is a very large file ( about 100 MB ).</p>
<p>If this is the cause, is there a more reliable way to find all occurrences of a substring in a very big file?</p>
<h2>version and alias of grep</h2>
<pre><code>grep --version
</code></pre>
<blockquote>
<pre><code>grep (GNU grep) 2.25
Copyright (C) 2016 Free Software Foundation, Inc.
License GPLv3+: GNU GPL version 3 or later <http://gnu.org/licenses/gpl.html>.
This is free software: you are free to change and redistribute it.
There is NO WARRANTY, to the extent permitted by law.
Written by Mike Haertel and others, see <http://git.sv.gnu.org/cgit/grep.git/tree/AUTHORS>.
</code></pre>
</blockquote>
<pre><code>$ type -a grep
</code></pre>
<blockquote>
<pre><code>grep is aliased to `grep --color=auto'
grep is /bin/grep
</code></pre>
</blockquote>
<h2>Example of lines from my_log_16.tra</h2>
<p>lines correctly detected and saved into results_16.txt</p>
<pre><code>[I 2022-10-16 07:26:35.449 Rservice:75] engineBreakdown()
[I 2022-10-16 07:26:35.846 Rservice:75] engineBreakdown()
[I 2022-10-16 07:26:35.848 Rservice:75] engineBreakdown()
</code></pre>
<p>a piece of the file where the substring appears, but it is not saved into results_16.txt</p>
<pre><code>[I 2022-10-16 11:32:48.039 web:2064] 200 GET /static/ui-src/default/img/Customer.png?v=0.9702853857687699 (127.0.0.1) 10.49ms
[I 2022-10-16 11:32:49.778 Rservice:75] engineBreakdown()
[I 2022-10-16 11:32:50.122 websocketclient:62] Connection : url::ws://localhost:3333/ws
[I 2022-10-16 11:32:50.125 Rservice:75] engineBreakdown()
[I 2022-10-16 11:32:50.128 Rservice:75] engineBreakdown()
[I 2022-10-16 11:32:55.123 websocketclient:62] Connection : url::ws://localhost:3333/ws
[I 2022-10-16 11:32:55.128 Rservice:75] engineBreakdown()
[I 2022-10-16 11:32:55.134 Rservice:75] engineBreakdown()
</code></pre>
<p>another piece of the file where the substring appears, but it is not saved into results_16.txt</p>
<pre><code>[I 2022-10-17 04:00:35.127 Rservice:75] engineBreakdown()
[I 2022-10-17 04:00:35.138 Rservice:75] engineBreakdown()
[I 2022-10-17 04:00:39.206 websocketclient:62] Connection : url::ws://127.0.0.1:9999/request
[I 2022-10-17 04:00:39.220 websocketclient:62] Connection : url::ws://127.0.0.1:9999/auxiliary
[I 2022-10-17 04:00:39.228 channels:75] _on_connection_error, host=127.0.0.1, port=9999
[I 2022-10-17 04:00:39.233 channels:82] _on_connection_close, host=127.0.0.1, port=9999
[I 2022-10-17 04:00:39.237 channels:75] _on_connection_error, host=127.0.0.1, port=9999
[I 2022-10-17 04:00:39.243 channels:82] _on_connection_close, host=127.0.0.1, port=9999
[I 2022-10-17 04:00:40.122 websocketclient:62] Connection : url::ws://localhost:3333/ws
[I 2022-10-17 04:00:40.128 Rservice:75] engineBreakdown()
[I 2022-10-17 04:00:40.133 Rservice:75] engineBreakdown()
[I 2022-10-17 04:00:44.206 websocketclient:62] Connection : url::ws://127.0.0.1:9999/request
[I 2022-10-17 04:00:44.221 websocketclient:62] Connection : url::ws://127.0.0.1:9999/auxiliary
[I 2022-10-17 04:00:44.227 channels:75] _on_connection_error, host=127.0.0.1, port=9999
[I 2022-10-17 04:00:44.232 channels:82] _on_connection_close, host=127.0.0.1, port=9999
[I 2022-10-17 04:00:44.234 channels:75] _on_connection_error, host=127.0.0.1, port=9999
[I 2022-10-17 04:00:44.237 channels:82] _on_connection_close, host=127.0.0.1, port=9999
[I 2022-10-17 04:00:45.122 websocketclient:62] Connection : url::ws://localhost:3333/ws
[I 2022-10-17 04:00:45.126 Rservice:75] engineBreakdown()
[I 2022-10-17 04:00:45.128 Rservice:75] engineBreakdown()
</code></pre>
<h2>update 1</h2>
<p>I also tryed with</p>
<pre><code>grep "engineBreakdown()" /path/to/my_log_16.tra > results_16.txt
</code></pre>
<p>but the result is the same.</p>
<h2>update 2</h2>
<p>As suggested, double quotes might not be enough to handle the parentheses properly, so I removed the parentheses from the input substring and changed the double quotes to single ones</p>
<pre><code>grep "engineBreakdown" /path/to/my_log_16.tra > results_16.txt
grep 'engineBreakdown' /path/to/my_log_16.tra > results_16.txt
</code></pre>
<p>but the result is the same.</p>
| [
{
"answer_id": 74126057,
"author": "Vishal Beep",
"author_id": 15739040,
"author_profile": "https://Stackoverflow.com/users/15739040",
"pm_score": 3,
"selected": true,
"text": "selectedIdsList = []"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7658051/"
] |
74,125,918 | <p>Hi I could really use some help on a python project that I'm working on. Basically I have a list of banned words and I must go through a .txt file and search for these specific words and change them from their original form to a ***.</p>
<pre><code>text_file = open('filename.txt','r')
text_file_read = text_file.readlines()
banned_words = ['is','activity', 'one']
words = []
i = 0
while i < len(text_file_read):
words.append(text_file_read[i].strip().lower().split())
i += 1
i = 0
while i < len(words):
if words[i] in banned_words:
words[i] = '*'*len(words[i])
i += 1
i = 0
text_file_write = open('filename.txt', 'w')
while i < len(text_file_read):
print(' '.join(words[i]), file = text_file_write)
i += 1
</code></pre>
<p>The expected output would be:</p>
<pre><code>This **
********
***?
</code></pre>
<p>However its:</p>
<pre><code>This is
activity
one?
</code></pre>
<p>Any help is greatly appreciated! I'm also trying not to use external libraries as well</p>
| [
{
"answer_id": 74126057,
"author": "Vishal Beep",
"author_id": 15739040,
"author_profile": "https://Stackoverflow.com/users/15739040",
"pm_score": 3,
"selected": true,
"text": "selectedIdsList = []"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16369741/"
] |
74,125,932 | <p>I have created a registration form with ASP.NET Core Identity, using the default fields ("Email", "Password", "Confirm Password") and a custom field "Name". When I enter a random string value into the name field and press "Register", I always receive the below error message:</p>
<p>"User name '' is invalid, can only contain letters or digits."</p>
<p>Things I have tried:</p>
<ul>
<li>I have set an option on the 'User' object for AllowedUserNameCharacters, but this doesn't seem to make a difference:</li>
</ul>
<pre><code> services.Configure<IdentityOptions>(options =>
{
options.User.AllowedUserNameCharacters = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789-._@+";
}
</code></pre>
<p>My registration controller:</p>
<pre><code>
[HttpPost]
public async Task<IActionResult> Register(RegisterViewModel model)
{
if (ModelState.IsValid)
{
var user = new ApplicationUser
{
Name = model.Name,
Email = model.Email
};
var result = await _userManager.CreateAsync(user, model.Password);
if (result.Succeeded)
{
await _signInManager.SignInAsync(user, isPersistent: false);
return RedirectToAction("index", "Home");
}
foreach (var error in result.Errors)
{
ModelState.AddModelError("", error.Description);
}
ModelState.AddModelError(string.Empty, "Invalid Login Attempt");
}
return View(model);
}
</code></pre>
<p>Regsitration View:</p>
<pre><code> <form method="post">
<div asp-validation-summary="All" class="text-danger"></div>
<div class="form-group">
<label asp-for="Name"></label>
<input asp-for="Name" class="form-control" />
<span asp-validation-for="Name" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Email"></label>
<input asp-for="Email" class="form-control" />
<span asp-validation-for="Email" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="Password"></label>
<input asp-for="Password" class="form-control" />
<span asp-validation-for="Password" class="text-danger"></span>
</div>
<div class="form-group">
<label asp-for="ConfirmPassword"></label>
<input asp-for="ConfirmPassword" class="form-control" />
<span asp-validation-for="ConfirmPassword" class="text-danger"></span>
</div>
<button type="submit" class="btn-primary">Register</button>
</form>
</code></pre>
<pre><code>My appDBContext:
public class AppDBContext : IdentityDbContext<ApplicationUser>
{
private readonly DbContextOptions _options;
public AppDBContext()
{
}
public AppDBContext(DbContextOptions options): base(options)
{
_options = options;
}
protected override void OnConfiguring(DbContextOptionsBuilder optionsBuilder)
{
if (!optionsBuilder.IsConfigured)
{
optionsBuilder.UseSqlServer(
@"Server=(localdb)\mssqllocaldb;Database=Codefirst");
}
}
protected override void OnModelCreating(ModelBuilder modelBuilder)
{
base.OnModelCreating(modelBuilder);
modelBuilder.Entity<ApplicationUser>()
.Property(e => e.Name)
.HasMaxLength(250);
modelBuilder.Entity<ApplicationUser>()
.Property(e => e.Email)
.HasMaxLength(250);
}
}
</code></pre>
<pre><code>
My applicationuser.cs class:
</code></pre>
<pre><code>using System;
using System.Collections.Generic;
using System.Linq;
using System.Threading.Tasks;
using Microsoft.AspNetCore.Identity;
namespace SLE_System.Data
{
public class ApplicationUser : IdentityUser
{
public string Name { get; set; }
public string Email { get; set; }
public string Password { get; set; }
public string ConfirmPassword { get; set; }
}
}
</code></pre>
<pre><code>If anyone has any ideas, these would be much appreciated?
Thanks,
Robert
</code></pre>
| [
{
"answer_id": 74126526,
"author": "arjun thota",
"author_id": 19667021,
"author_profile": "https://Stackoverflow.com/users/19667021",
"pm_score": 1,
"selected": false,
"text": "public class ApplicationUser : IdentityUser\n{\n public string Name { get; set; }\n public string Email ... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125932",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2308269/"
] |
74,125,937 | <p>I have a question for my python programming.</p>
<p>I started 3 days ago and seems to have trouble creating this simple code on Replit.</p>
<p>Here it is [1]: <a href="https://i.stack.imgur.com/i4gld.jpg" rel="nofollow noreferrer">https://i.stack.imgur.com/i4gld.jpg</a></p>
<p>I have tried different things such as switching the identifier, but I get this error</p>
<p>It seems only number works, but what if I wanted to write a word? How about I define it?</p>
<p>Can anyone give me a few example of how I can do it? Thank you!</p>
| [
{
"answer_id": 74126001,
"author": "T C Molenaar",
"author_id": 8814131,
"author_profile": "https://Stackoverflow.com/users/8814131",
"pm_score": 2,
"selected": true,
"text": "e = 'hi'"
},
{
"answer_id": 74126014,
"author": "Loxley",
"author_id": 19291069,
"author_pro... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125937",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14760404/"
] |
74,125,949 | <p>I have a model for Book saved in elastic search. It has couple of attribute minimumAge and maximumAge, which determines what age the book is recommended for</p>
<p>I have couple of usecases for searching booking. First case is to search books by minimumAge. So suppose user searches for minimumAge 5, I have to get all the books which requires minimumAge to be 5 or those books which does not have minimumAge .</p>
<p>I did this using should clause and setting one minimum should clause to satisfy the query which works fine as shown below</p>
<pre><code>private void addSearchByMinimumAge(ProductsFilter filter, BoolQueryBuilder rootQuery) {
BoolQueryBuilder minAgeQuery = boolQuery();
minAgeQuery.minimumShouldMatch(1);
minAgeQuery.should(rangeQuery("minAge").lte(filter.getMinAge()));
BoolQueryBuilder minAgeNotExistsQuery = boolQuery();
minAgeNotExistsQuery.mustNot(existsQuery("minimumAge"));
minAgeQuery.should(minAgeNotExistsQuery);
rootQuery.must(minAgeQuery);
}
</code></pre>
<p>As mentioned above use case works fine.</p>
<p>Second use case that I am trying to achieve is to get books by age. For example if a person searches for age 5, I need all the books where</p>
<ul>
<li>Age 5 is between or is equal to minAge and maxAge.</li>
<li>If both minAge and maxAge is not available for a book, I should still return the book.</li>
<li>If minAge is empty for a book but maxAge is less than or equal to 5 then that book should be returned.</li>
<li>And finally if maxAge is empty then all the books with minAge greater than or equal to 5 should also be returned.</li>
</ul>
<ul>
<li></li>
</ul>
<pre><code>{ "name" : "Book1" , "minAge": 3 , "maxAge": 8 }
{ "name" : "Book2" , "minAge": 6 , "maxAge": 8 }
{ "name" : "Book3" , "minAge": 3 , "maxAge": 5 }
{ "name" : "Book4" , "minAge": 5 , "maxAge": 8 }
{ "name" : "Book5" }
{ "name" : "Book6" , "minAge": 3 }
{ "name" : "Book7" , "minAge": 6 }
{ "name" : "Book8" , "maxAge": 6 }
{ "name" : "Book9" , "maxAge": 4 }
</code></pre>
<ul>
<li></li>
</ul>
<p>In the above dataset if I pass Books 1,3,4,5,6,8 are valid book results</p>
<p>So I am stuck as to what would be a compact query to address this particular scenario.
My first thought process is similar to first query but four should clause and matching any 1.
Any pointers will be appreciated</p>
| [
{
"answer_id": 74126001,
"author": "T C Molenaar",
"author_id": 8814131,
"author_profile": "https://Stackoverflow.com/users/8814131",
"pm_score": 2,
"selected": true,
"text": "e = 'hi'"
},
{
"answer_id": 74126014,
"author": "Loxley",
"author_id": 19291069,
"author_pro... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125949",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12507002/"
] |
74,125,951 | <p>Is there a way to make unavailable for others jupyter notebook contents? I want to share notebook with others so it would perform the necessary actions but users couldn’t see the inside code.</p>
| [
{
"answer_id": 74126001,
"author": "T C Molenaar",
"author_id": 8814131,
"author_profile": "https://Stackoverflow.com/users/8814131",
"pm_score": 2,
"selected": true,
"text": "e = 'hi'"
},
{
"answer_id": 74126014,
"author": "Loxley",
"author_id": 19291069,
"author_pro... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74125951",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15573453/"
] |
74,126,003 | <p>I'm doing a project that is requiring a lot of input validation. I currently have a function defined as follows:</p>
<pre class="lang-python prettyprint-override"><code>def get_valid_float(inputMessage,errorMessage):
while True:
variableInput = input(inputMessage)
try:
variableInput = float(variableInput)
return variableInput
except ValueError:
print(errorMessage)
</code></pre>
<p>This function allows me to choose a custom message to prompt the user. It will then validate that the user input is indeed a float, and will print a custom error message in the event that it is not. It will loop until the user gives a valid input.</p>
<p>However, I would rather not create a function to validate each and every data type. It seems like it would be best to combine these into one <code>get_valid_input()</code> function, and pass a third argument allowing me to choose what data type I am attempting to verify. For example, <code>get_valid_input(complex,inputMessage,errorMessage)</code>.</p>
<p>I am obviously unable to pass a keyword as an argument. This makes me think the only way to do this would to be to do something like this:</p>
<pre class="lang-python prettyprint-override"><code>def get_valid_float(dataType,inputMessage,errorMessage):
if dataType == "float"
while True:
variableInput = input(inputMessage)
try:
variableInput = float(variableInput)
return variableInput
except ValueError:
print(errorMessage)
elif dataType == "integer"
while True:
variableInput = input(inputMessage)
try:
variableInput = int(variableInput)
return variableInput
except ValueError:
print(errorMessage)
</code></pre>
<p>And so on, with an <code>elif</code> for every data type. Surely there is an easier way to do this, that somehow allows me to execute the line <code>variableInput = {dataType}(variableInput)</code> to confirm that they input a value of data type "dataType". Any ideas?</p>
| [
{
"answer_id": 74126113,
"author": "larsks",
"author_id": 147356,
"author_profile": "https://Stackoverflow.com/users/147356",
"pm_score": 1,
"selected": false,
"text": "def get_valid_input(dataType, inputMessage, errorMessage):\n while True:\n value = input(inputMessage)\n ... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126003",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20143899/"
] |
74,126,018 | <p>I am trying to create a app using mongodb and spring-boot as backend and angular as frontend.</p>
<p>Using command to run my app:</p>
<pre><code>docker run -d -e APP_OPTIONS="--spring.data.mongodb.host=172.17.0.2" -p 8443:8443 my-webapp
</code></pre>
<p>I am able to launch my app at <code>http://localhost/api/swagger-ui.html</code> successfully(I have configured swagger for backend). Using <code>server.port=8443</code> and <code>server.servlet.context-path=/api</code>. I am also able to add/update data to mangodb from swagger APIs.</p>
<p>My frontend is in angular and using a proxy.config.json file to connect to backend:</p>
<pre><code>{
"/api": {
"target": "http://localhost:8443/",
"secure": false,
"loglevel": "debug",
"changeOrigin": true
}
}
</code></pre>
<p>Also using <code>ng serve --proxy-config proxy.config.json</code> command, I am able to launch angular UI and able to fetch data from database/backend successfully.</p>
<p>The problem arising when I am making UI component as docker container using DockerFile</p>
<pre><code>FROM nginx:alpine
COPY prod.nginx.proxy.conf /etc/nginx/conf.d/default.conf
COPY dist/my-webui /usr/share/nginx/html
EXPOSE 80
</code></pre>
<p>prod.nginx.proxy.conf</p>
<pre><code>server {
listen 80;
server_name frontend;
location / {
root /usr/share/nginx/html;
index index.html index.htm;
}
location /api/ {
proxy_pass http://localhost:8443/;
}
}
</code></pre>
<p>Command I using to build and run as docker container:</p>
<pre><code>docker build -f Dockerfile -t my-webui .
docker run -d -p 80:80 my-webui
</code></pre>
<p><code>http://localhost:80/</code> <strong>is launching the angular index pages but not able to fetch the backend data</strong> , I am guessing some issue with the nginx configuration. Please help to find equivalent <code>nginx config</code> for my <code>proxy.config.json</code></p>
<p>Error is <code>502 Bad Gateway</code> and also It is making http <code>POST</code> call to <code>http://localhost/api/user/authenticate</code> rather <code>http://localhost:8443/api/user/authenticate</code>, also for FYI in header I can see <code>Remote Address: [::1]:80</code> instead of <code>Remote Address: 127.0.0.1</code></p>
| [
{
"answer_id": 74126113,
"author": "larsks",
"author_id": 147356,
"author_profile": "https://Stackoverflow.com/users/147356",
"pm_score": 1,
"selected": false,
"text": "def get_valid_input(dataType, inputMessage, errorMessage):\n while True:\n value = input(inputMessage)\n ... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126018",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11277353/"
] |
74,126,038 | <p>I have made a vector which looks like this:</p>
<pre><code>v1 <- c("1 1","1 2","1 3",
"2 1","2 2","2 3",
"3 1","3 2","3 3",
"4 1","4 2","4 3",
"5 1","5 2","5 3",
"6 1","6 2","6 3")
</code></pre>
<p>It can be called v1.</p>
<p>The result I want is "1 1 1 1" "1 1 1 2" .... "6 6 6 6" (in total should be 6x3x6x3=360-36=324 in total into a new vector v2)</p>
<p>However, I have tried <code>apply(combn(v1, 2), 2, paste0, collapse=" ")</code> but it is not complete.</p>
<p>How can I achieve the goal?</p>
| [
{
"answer_id": 74126255,
"author": "Claudio Paladini",
"author_id": 8187191,
"author_profile": "https://Stackoverflow.com/users/8187191",
"pm_score": 1,
"selected": false,
"text": "expand.grid"
},
{
"answer_id": 74126276,
"author": "Maël",
"author_id": 13460602,
"auth... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20052676/"
] |
74,126,062 | <p>I understand this is not a FastAPI issue, but how to avoid this using FastAPI?</p>
<p>For example:</p>
<pre><code>from fastapi import FastAPI
app = FastAPI()
@app.get('/')
async def root(q: str):
return {"message": f"{q}"}
</code></pre>
<p>Issuing the following request:</p>
<pre><code>http://127.0.0.1:8000/?q=1+1
</code></pre>
<p>returns:</p>
<pre><code>{"message":"1 1"}
</code></pre>
| [
{
"answer_id": 74126106,
"author": "esqew",
"author_id": 269970,
"author_profile": "https://Stackoverflow.com/users/269970",
"pm_score": 3,
"selected": false,
"text": "+"
},
{
"answer_id": 74136659,
"author": "Chris",
"author_id": 17865804,
"author_profile": "https://... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13062922/"
] |
74,126,083 | <p>I am querying the database using findOne which will return just one document. Now, I want a few of the fields of that document in one object and the other fields in the other object, both of which are wrapped in a single object. For example I have a table called Bus with the following fields -</p>
<pre><code>_id,
busNo,
city,
agency,
date,
ticketPrice,
helper,
driver,
totalCollection
</code></pre>
<p>My find one query returns one document but I want it in the below format -</p>
<pre><code>existingAggr - {
"result": [
{
"_id": "630dcd0c652489bca1b319f7",
"busNo": "123",
"city": "32",
"agency": "58",
"date": "2022-08-29T00:00:00.000Z",
}
],
"aggregates": {
"ticketPrice": 8,
"totalCollection": 402,
"helper": 0,
"driver": 23,
}
}
</code></pre>
<p>I want this either with single access of database, or we can do some javascript calculations to further bring my result in this manner, but I cant seem to reach the solution. Currently, I am using the below code -</p>
<pre><code>const res = await Bus.findOne(
{ busNo, date },
{
_id :1,
busNo:1,
city:1,
agency:1,
date:1,
ticketPrice:1,
helper:1,
driver:1,
totalCollection:1
}
);
</code></pre>
<p>This would return all the fields in one.</p>
| [
{
"answer_id": 74126222,
"author": "Portevent",
"author_id": 8899106,
"author_profile": "https://Stackoverflow.com/users/8899106",
"pm_score": 2,
"selected": true,
"text": "const res = await BusDayWise.findOne(\n { ...filter },\n { session: mongoSession }\n );\n\nconst result = [\... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126083",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8119044/"
] |
74,126,103 | <p>I have multiple get requests with <code>axios.all</code> in my Node.js backend. I want to return the response to the function and then consume this as API in ReactJS. When I use <code>console.log</code> to output the data in the React component, I get <code>Promise { <state>: "pending" }</code>, but I want to get data from the Node.js backend.</p>
<p>Could you please help me?</p>
<p><strong>Node.js backend:</strong></p>
<pre class="lang-js prettyprint-override"><code>export async function getArrivalPorts() {
let endpoints = [
'https://api.github.com/users/ejirocodes',
'https://api.github.com/users/ejirocodes/repos',
'https://api.github.com/users/ejirocodes/followers',
'https://api.github.com/users/ejirocodes/following'];
const response = await axios.all(endpoints.map((endpoint) => axios.get(endpoint)))
.then(axios.spread((
{data: user},
{data: repos},
{data: followers},
{data: following}) => {
return ({user, repos, followers, following});
}))
.catch(errors => {
console.log(errors)
})
return(response)
}
</code></pre>
<p>Node.js router</p>
<pre><code>router.get('/arrival', getArrivalPorts)
</code></pre>
<p>ReactJS frontend</p>
<pre><code>function From ()
{
const data = axios.get('http://localhost:5000/arrival')
console.log(data)
}
</code></pre>
| [
{
"answer_id": 74126576,
"author": "Bad Dobby",
"author_id": 6661359,
"author_profile": "https://Stackoverflow.com/users/6661359",
"pm_score": 0,
"selected": false,
"text": ".then()"
},
{
"answer_id": 74139608,
"author": "maulik",
"author_id": 8289573,
"author_profile... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126103",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12880330/"
] |
74,126,159 | <p>I've recently started to learn how to build django projects with multiple apps. I have learnt that by using <code>from . import views</code> I can import the different views from the current directory that I am in. However, when using this method, the prompt would give me an error saying: <code>ImportError: cannot import name 'views' from 'birds_eye'</code></p>
<p>The following is my current directory tree of my django project:</p>
<pre><code>birds_eye
|- accounts (app folder)
|- birds_eye (actual project folder)
|- clubs (app folder)
|- events (app folder)
|- posts (app folder)
|- static
|- templates
</code></pre>
<p>And this is the actual code of what is happening:</p>
<pre><code>birds_eye
|- birds_eye (actual project folder)
|- urls.py
</code></pre>
<pre><code>from django.contrib import admin
from django.urls import path, include
from . import views
urlpatterns = [
path('', views.HomePage.as_view(), name="home"),
path("admin/", admin.site.urls),
path("test/", views.TestPage.as_view(), name="test"),
path("thanks", views.ThanksPage.as_view(), name="thanks"),
path('accounts/', include("accounts.urls", namespace="accounts")),
path("accounts/", include("django.contrib.auth.urls")),
# Events --> Calendar, Posts --> Feed | Expected to finish later on. Uncomment when done.
# path("posts/", include("posts.urls", namespace="posts")),
# path("events/", include("events.urls", namespace="events")),
path("clubs/", include("clubs.urls", namespace="clubs")),
path('surveys', include('djf_surveys.urls')),
]
</code></pre>
<p>Is there any solution to this?<br>
(I can edit the question in order to provide more resources from my project)</p>
| [
{
"answer_id": 74126576,
"author": "Bad Dobby",
"author_id": 6661359,
"author_profile": "https://Stackoverflow.com/users/6661359",
"pm_score": 0,
"selected": false,
"text": ".then()"
},
{
"answer_id": 74139608,
"author": "maulik",
"author_id": 8289573,
"author_profile... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18684480/"
] |
74,126,181 | <p>I am trying to extract part of url using bash regex
. from below mentioned URL i just want to extract 124, which will always be between two hyphens .</p>
<pre><code>http://abc-124-001.portal-ex.xyz-xyz.com:8091/
</code></pre>
<p>i tried doing following but i am looking for any better options to do this in one line</p>
<pre><code>f=http://abc-124-001.portal-ex.xyz-xyz.com:8091/
f=${f#*-}
echo ${f%%-*}
op: 124
</code></pre>
<p>can this be done in one line or in any better way??</p>
| [
{
"answer_id": 74126576,
"author": "Bad Dobby",
"author_id": 6661359,
"author_profile": "https://Stackoverflow.com/users/6661359",
"pm_score": 0,
"selected": false,
"text": ".then()"
},
{
"answer_id": 74139608,
"author": "maulik",
"author_id": 8289573,
"author_profile... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126181",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19692198/"
] |
74,126,195 | <p>I have a <code>.yml</code> file where I want to use an <code>AND</code> operant between a <code>Boolean</code> and another equal statement as below. I use this <code>.yml</code> file in <code>Java</code>.</p>
<pre><code>requires: (foo.advance) && (foo.midi == "ON_GOING_MIDI")
</code></pre>
<p><strong>How can I do it in correct way in .yml file?</strong></p>
<pre><code>menu: admin
sub:
- view: magazine
icon: "tiles"
requires:foo.advance
- view: factor
icon: "icon2"
requires:not(foo.advance)
- view: usages
requires: (foo.advance) && (foo.midi == "ON_GOING_MIDI")
- menu: user
</code></pre>
| [
{
"answer_id": 74135833,
"author": "flyx",
"author_id": 347964,
"author_profile": "https://Stackoverflow.com/users/347964",
"pm_score": 1,
"selected": false,
"text": "requires: !and [foo.advance, !eq [foo.midi, \"ON_GOING_MIDI\"] ]\n"
},
{
"answer_id": 74141579,
"author": "ls... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126195",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18528284/"
] |
74,126,228 | <p>On Databricks, it is possible to install Python packages directly from a git repo, or from the dbfs:</p>
<pre><code>%pip install git+https://github/myrepo
%pip install /dbfs/my-library-0.0.0-py3-none-any.whl
</code></pre>
<p>Is there a way to enable a live package development mode, similar to the usage of <code>pip install -e</code>, such that the databricks notebook references the library files as is, and it's possible to update the library files on the go?</p>
<p>E.g. something like</p>
<pre><code>%pip install /dbfs/my-library/ -e
</code></pre>
<p>combined with a way to keep my-library up-to-date?</p>
<p>Thanks!</p>
| [
{
"answer_id": 74153517,
"author": "Alex Ott",
"author_id": 18627,
"author_profile": "https://Stackoverflow.com/users/18627",
"pm_score": 2,
"selected": true,
"text": "%load_ext autoreload\n%autoreload 2\n"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1568760/"
] |
74,126,240 | <p>I have made an to do list with firebase. but when i click to create a new to do, i can't see anything apear on my page but in firebase it does show the string.</p>
<p>How can i fix this</p>
<p>(this is in flutter)</p>
<p>logcat:
2022-10-19 15:24:50.758 23369-23584 flutter com.example.voorbeeld I apen created</p>
<pre><code>import 'package:flutter/material.dart';
import 'package:cloud_firestore/cloud_firestore.dart';
class video_info extends StatefulWidget {
@override
_video_infoState createState() => _video_infoState();
}
class _video_infoState extends State<video_info> {
String todoTitle = "";
createTodos() {
DocumentReference documentReference =
FirebaseFirestore.instance.collection("MyTodos").doc(todoTitle);
//Map
Map<String, String> todos = {"todoTitle": todoTitle};
documentReference.set(todos).whenComplete(() {
print("$todoTitle created");
});
}
deleteTodos(item) {
DocumentReference documentReference =
FirebaseFirestore.instance.collection("MyTodos").doc(item);
documentReference.delete().whenComplete(() {
print("$item deleted");
});
}
@override
Widget build(BuildContext context) {
return Scaffold(
appBar: AppBar(
title: Text("mytodos"),
),
floatingActionButton: FloatingActionButton(
onPressed: () {
showDialog(
context: context,
builder: (BuildContext context) {
return AlertDialog(
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8)),
title: Text("Add Todolist"),
content: TextField(
onChanged: (String value) {
todoTitle = value;
},
),
actions: <Widget>[
TextButton(
onPressed:() {
createTodos();
Navigator.of(context).pop();
},
child: Text("Add"))
],
);
});
},
child: Icon(
Icons.add,
color: Colors.white,
),
),
body: StreamBuilder(
stream: FirebaseFirestore.instance.collection("Mytodos").snapshots(),
builder: (context, snapshots) {
if (snapshots.hasData) {
return ListView.builder(
shrinkWrap: true,
itemCount: snapshots.data?.docs.length,
itemBuilder: (context, index) {
DocumentSnapshot documentSnapshot =
snapshots.data!.docs[index];
return Dismissible(
onDismissed: (direction) {
deleteTodos(documentSnapshot["todoTitle"]);
},
key: Key(documentSnapshot["todoTitle"]),
child: Card(
elevation: 4,
margin: EdgeInsets.all(8),
shape: RoundedRectangleBorder(
borderRadius: BorderRadius.circular(8)),
child: ListTile(
title: Text(documentSnapshot["todoTitle"]),
trailing: IconButton(
icon: Icon(
Icons.delete,
color: Colors.red,
),
onPressed: () {
deleteTodos(documentSnapshot["todoTitle"]);
}),
),
));
});
} else {
return Align(
alignment: FractionalOffset.bottomCenter,
child: CircularProgressIndicator(),
);
}
}),
);
}}
</code></pre>
<p>also does anyone know a link to an tuturial where they explain how i can link the database to a user login.</p>
| [
{
"answer_id": 74126295,
"author": "Yeasin Sheikh",
"author_id": 10157127,
"author_profile": "https://Stackoverflow.com/users/10157127",
"pm_score": 0,
"selected": false,
"text": " late final myStream = FirebaseFirestore.instance.collection(\"MyTodos\").snapshots();\n\n @override\n W... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126240",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18400997/"
] |
74,126,253 | <p>I have the same operation from two list and want to put them in one map function rather than two.</p>
<pre><code> val messages1 = list.map {
spConverter.mapToSppmFromPs(it)
}
val messages2 = list.map {
spConverter.mapToSpFromPs(it)
}
</code></pre>
<p>Is there a way to put this two operation into one map?</p>
| [
{
"answer_id": 74126290,
"author": "TheLibrarian",
"author_id": 3434763,
"author_profile": "https://Stackoverflow.com/users/3434763",
"pm_score": 0,
"selected": false,
"text": ".map"
},
{
"answer_id": 74127297,
"author": "k314159",
"author_id": 13963086,
"author_profi... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4220784/"
] |
74,126,259 | <p>So I have added react context api to my website but the website is not re-rendering after I change the state that is in the context</p>
<p>Here is my context file</p>
<pre><code> import { createContext, useEffect, useState } from "react";
import { item } from "../Types";
interface AppContextInterface {
Addtofavorite: (item: item) => void;
Addtocart: (item: item) => void;
Items: item[];
setItems: (item: item[]) => void;
Favorite: item[];
Cart: item[];
}
export const AppContext = createContext<AppContextInterface>(
{} as AppContextInterface
);
export const AppContextProvider = ({ children }: any) => {
const [favorite, addFavorite] = useState([] as item[]);
const [cart, addCart] = useState([] as item[]);
const [items, setItems] = useState([] as item[]);
useEffect(() => {
console.log("asdasd");
}, [favorite, cart]);
const handleAddFavorite = (item: item) => {
addFavorite(AddElementToArray(item, favorite));
console.log(favorite);
};
const handleAddCart = (item: item) => {
addCart(AddElementToArray(item, cart));
console.log(cart);
};
const AddElementToArray = (item: item, array: item[]) => {
if (array.includes(item)) {
array.splice(array.indexOf(item), 1);
} else {
array.push(item);
}
return array;
};
const values = {
Addtofavorite: handleAddFavorite,
Addtocart: handleAddCart,
Items: items,
setItems: setItems,
Favorite: favorite,
Cart: cart,
};
return <AppContext.Provider value={values}>{children} </AppContext.Provider>;
};
</code></pre>
<p>this is my index.tsx file</p>
<pre><code> import React from "react";
import ReactDOM from "react-dom/client";
import App from "./Components/App";
import { AppContextProvider } from "./Context/AppContext";
const root = ReactDOM.createRoot(
document.getElementById("root") as HTMLElement
);
root.render(
<React.StrictMode>
<AppContextProvider>
<App />
</AppContextProvider>
</React.StrictMode>
);
</code></pre>
<p>am I wrong about that react context should re-render itself and its children after state changing or is it that I did something wrong ?</p>
| [
{
"answer_id": 74126348,
"author": "Nicholas Tower",
"author_id": 3794812,
"author_profile": "https://Stackoverflow.com/users/3794812",
"pm_score": 1,
"selected": true,
"text": "==="
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126259",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20282968/"
] |
74,126,319 | <p>I am using this query to get values based on a list</p>
<p>Query :</p>
<pre><code>select * from Assignment_Data_RAD where Rfid IN ( '34E59808D8400410C2048F48','3460881C004610224927D013','3C60881C00461020420FD000','3C60881C00461020420C107D','3DD00000000000103D004188','3460881C00461020420FD000' )
</code></pre>
<p>Result:</p>
<p><a href="https://i.stack.imgur.com/AHh3Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AHh3Y.png" alt="enter image description here" /></a></p>
<p>The desired result is the Qty count based on The GS_1_BARCODE and Category</p>
<pre><code>Category | Gs1 | Qty
shoppingbags 15/1000 | 62870164212311 | 1
shoppingbags 15/1000 | 628701642999 | 1
shoppingbags 15/1000 | 628701642123 | 2
Thermal Bags 16 | 628701642999 | 2
</code></pre>
<p>I also need all the other columns along with the above data.</p>
<p>What else do I need to add to my current query to get the sum of quantity based on the category and gs1 barcode column in the list of Rfid's</p>
| [
{
"answer_id": 74126772,
"author": "TheLibrarian",
"author_id": 3434763,
"author_profile": "https://Stackoverflow.com/users/3434763",
"pm_score": 0,
"selected": false,
"text": "SELECT Category, Gs1, COUNT(*) as Qty FROM Assignment_Data_RAD GROUP BY Category, Gs1;\n"
},
{
"answer_... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8528047/"
] |
74,126,335 | <p>I'm migrating from Vue 2 to Vue 3. Doing test app first.</p>
<p>I'm having trouble importing a JSON file.</p>
<p><a href="https://i.stack.imgur.com/tPOOL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tPOOL.png" alt="This error I'm getting" /></a></p>
<p>The file exists. Tried all these variants:</p>
<pre><code>import { sites } from "./data/sites.json";
import sites from "./data/sites.json";
import sites from "../data/sites.json";
import sites from "@/data/sites.json";
</code></pre>
<p><a href="https://www.koderhq.com/tutorial/vue/local-json/" rel="nofollow noreferrer">https://www.koderhq.com/tutorial/vue/local-json/</a> and <a href="https://codesandbox.io/s/z2mpz6zq23?file=/src/components/HelloWorld.vue" rel="nofollow noreferrer">https://codesandbox.io/s/z2mpz6zq23?file=/src/components/HelloWorld.vue</a></p>
<p><a href="https://i.stack.imgur.com/Qq49w.png" rel="nofollow noreferrer">Sandbox Link - dev - This doesn't work</a></p>
<p>Thanks @Tolbxela I tried that:
<a href="https://i.stack.imgur.com/Qq49w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Qq49w.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74127201,
"author": "Tolbxela",
"author_id": 2487565,
"author_profile": "https://Stackoverflow.com/users/2487565",
"pm_score": 0,
"selected": false,
"text": "import"
},
{
"answer_id": 74201562,
"author": "tony19",
"author_id": 6277151,
"author_profile":... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1882460/"
] |
74,126,344 | <pre><code> public static Throwable getCause(@Nonnull Throwable t) {
while ((t instanceof ExecutionException || t instanceof CompletionException) && t.getCause() != null) {
t = t.getCause();
}
return t;
}
</code></pre>
<p>Is this code dangerous in a sense that the while loop may never end? Just wondering if someone can cause this to go on forever.</p>
<p>If so, what might be a better way to handle this? I'm thinking maybe adding an upper bound limit.</p>
| [
{
"answer_id": 74126685,
"author": "samabcde",
"author_id": 7928721,
"author_profile": "https://Stackoverflow.com/users/7928721",
"pm_score": -1,
"selected": false,
"text": "public class ExceptionWithCauseAsItself extends ExecutionException {\n @Override\n public Throwable getCause... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19829796/"
] |
74,126,395 | <p>Is it possible to write a dictionary into Data Frame? I have created the following DataFrame with my structure:</p>
<pre><code>df =pd.DataFrame({'name': ['L1', 'L2'], 'DEF': [None, None]})
df
Out[70]:
name DEF
0 L1 None
1 L2 None
</code></pre>
<p>I also have a dictionary</p>
<pre><code>dict1={'DEF120':50}
</code></pre>
<p>If try to write dictionary into df as</p>
<pre><code>df.loc[df.name=='L2', 'DEF'] = dict1
</code></pre>
<p>I am getting NaN as</p>
<pre><code>df
Out[76]:
name DEF
0 L1 None
1 L2 NaN
</code></pre>
<p>But! If I write a random number, then it works!</p>
<pre><code>df.loc[df.name=='L2', 'DEF'] = 1323213
df
Out[78]:
name DEF
0 L1 None
1 L2 1323213
</code></pre>
<p>Can someone please explain what is the problem here? Why does writing dictionary not work?</p>
<p>Thanks!</p>
| [
{
"answer_id": 74126497,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 2,
"selected": true,
"text": "loc"
},
{
"answer_id": 74126503,
"author": "Ynjxsjmh",
"author_id": 10315163,
"author_profile": ... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126395",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17329940/"
] |
74,126,417 | <p>Step 1: I have function. This function has no return. Anyway I the async keyword to the function because I need to use an await inside this function.</p>
<p>Explanatory code example:</p>
<pre><code>const foo1 = async () => {
const a1 = await something... //For example findValueInDatabase()
}
</code></pre>
<p>Step 2:
I define another async function again using await inside its body. No return again.</p>
<p>Explanatory code example:</p>
<pre><code>const foo2 = async () => {
const a2 = await something... //For example sendEmail()
}
</code></pre>
<p>Step 2: Now I want to call the function defined in step 2 inside the function of stop one:</p>
<p>Explanatory code example:</p>
<pre><code>const foo1 = async () => {
const a1 = await something... //For example findValueInDatabase()
foo2() //or await foo2()
...some more code to be executed...
}
</code></pre>
<p>Expections and questions regarding the behaviour of foo2 within foo1:</p>
<p>Do I need to add the await keyword to foo2 in order for it to be awaited? Does it make a difference? If so, what is the difference?</p>
<p>I would expect that the answer to that question is no.
foo2 will execute and in it a2 will be awaited which means that further code will not be executed until a2 is resolved. So await would not make any difference because calling foo2 within foo1 is like if the code of foo2 was directly in foo1.</p>
<p>Are my expectations wrong?</p>
| [
{
"answer_id": 74126485,
"author": "ControlAltDel",
"author_id": 1291492,
"author_profile": "https://Stackoverflow.com/users/1291492",
"pm_score": 3,
"selected": true,
"text": "await/then"
},
{
"answer_id": 74126628,
"author": "TheZanke",
"author_id": 2957138,
"author... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126417",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14737378/"
] |
74,126,430 | <p>I have the following df:</p>
<pre><code>df = pd.DataFrame({'A': [0.0137, 0.1987, 'Decimal('NaN')', 0.7653]})
</code></pre>
<p>Output:</p>
<pre><code> A
0 0.0137
1 0.1987
2 NaN
3 0.7653
</code></pre>
<p>I am trying to format each row from column <code>A</code>, using <code>.iloc</code> (because I have many columns in my actual code) into, e.g. 1.37%.</p>
<p>However, If I perform</p>
<pre><code>df.iloc[:, 0] = (df.iloc[:, 0] * 100).astype(float).map('{:,.2f}%'.format)
</code></pre>
<p>All the NaN rows receive a trailing <code>'%'</code>, yielding <code>'NaN%'</code></p>
<p>So if I try:</p>
<pre><code>df.iloc[:, 0] = df.iloc[:, 0].apply(
lambda x: (x * 100).astype(float).map('{:,.2f}%'.format) if not istinstance(x, Decimal)
else None)
</code></pre>
<p>I get <code>IndexError: single positional indexer is out-of-bounds</code>.</p>
<p>How can I properly format every row of my <code>df</code> that is not a <code>Decimal(NaN)</code>?</p>
<p>Note: I'm specifically using df.iloc before the equal sign because I only want to inplace change those columns.</p>
| [
{
"answer_id": 74126485,
"author": "ControlAltDel",
"author_id": 1291492,
"author_profile": "https://Stackoverflow.com/users/1291492",
"pm_score": 3,
"selected": true,
"text": "await/then"
},
{
"answer_id": 74126628,
"author": "TheZanke",
"author_id": 2957138,
"author... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11147107/"
] |
74,126,442 | <p>I'm trying to implement a Dashboard where some users (those who have the role of Manager) can add, update and remove other users. Is there a way to add a new user updating not only my database but also the wso2 identity server?</p>
| [
{
"answer_id": 74126485,
"author": "ControlAltDel",
"author_id": 1291492,
"author_profile": "https://Stackoverflow.com/users/1291492",
"pm_score": 3,
"selected": true,
"text": "await/then"
},
{
"answer_id": 74126628,
"author": "TheZanke",
"author_id": 2957138,
"author... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14393912/"
] |
74,126,467 | <p>So I'm building a small front-end app which has the screen split in the middle. I have an array of objects that I want to map out on the left hand side of the screen in the form of multiple div. So if you imagine that the array is of length ten, I would want the ten items mapped out and if they filled the screen, you would have the option to scroll down. The desired effect is something like this:</p>
<p><a href="https://i.stack.imgur.com/rUE5l.png" rel="nofollow noreferrer">Desired Effect</a></p>
<p>Where the grey bar in the middle represents the scroll bar. I am able to successfully map over the array and render the divs, however they seem to be overflowing upward. What I mean by this is that first visible div is not displaying the first item in the array but some arbitrary part and I can't scroll upward anymore. This is what it currently looks like.(I can't scroll up past Div 7 in this case).</p>
<p><a href="https://i.stack.imgur.com/exm47.png" rel="nofollow noreferrer">Current Effect</a></p>
<p>I'm assuming this is a CSS problem but I'm unsure of how to fix it. I'm not looking to use SCSS or any Node/React packages. I know the solution must be fairly simple. Does anyone know where I'm going wrong?</p>
<p><strong>My CSS code:</strong></p>
<pre><code>.split {
height: 100%;
width: 50%;
position: fixed;
z-index: 1;
top: 0;
overflow-x: hidden;
padding-top: 2em;
}
.left {
left: 0;
overflow: scroll;
}
.right {
right: 0;
}
.centered {
position: absolute;
top: 50%;
left: 50%;
transform: translate(-50%, -50%);
text-align: center;
}
.block {
padding: 1em;
margin: 1em;
}
</code></pre>
<p><strong>The component that lists out the array with divs</strong> (simplified).</p>
<pre><code>import React from "react";
const LeftComponent = (props) => {
return (
<div className="split left">
<div className="centered">
{props.myArr.map(({ id, name, dob}) => (
<div
onClick={(event) => props.handleClick(event, id)}
key={id}
className="block"
>
<p className="duty_text">
{name} | {dob}
</p>
</div>
))}
</div>
</div>
);
};
export default LeftComponent;
</code></pre>
| [
{
"answer_id": 74126485,
"author": "ControlAltDel",
"author_id": 1291492,
"author_profile": "https://Stackoverflow.com/users/1291492",
"pm_score": 3,
"selected": true,
"text": "await/then"
},
{
"answer_id": 74126628,
"author": "TheZanke",
"author_id": 2957138,
"author... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126467",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6041286/"
] |
74,126,471 | <p>I have a state.</p>
<p>This state source in a file: dummy.js</p>
<p>This state contain complex data structure, this name <strong>stackedCustomSeries</strong>.</p>
<p>stackedCustomSeries is an array and contain two objects.</p>
<p>Each objects have several property: <strong>dataSource</strong>, xName, yName ...etc</p>
<p>The <strong>dataSource</strong> property contain <strong>stackedChartData[0]</strong></p>
<p>The stackedChartData[0] is also an array.</p>
<p>The stackedChartData[0] contain two array.</p>
<p>These array's contain several objects.</p>
<p>Inside these objects have several x and y property.</p>
<p>I want to change this x and y properties value when I was clicked.</p>
<p>For example I click and pass data: 120</p>
<p>and in stackedChartData[0] { x: 'Jan', <strong>y: 111.1</strong> }, would be >> { x: 'Jan', <strong>y: 120</strong> },</p>
<p>But How?</p>
<p>I import my datasource in a state in my App component</p>
<p>App.js</p>
<pre><code>import React, { useState } from "react";
import {
stackedCustomSeries,
} from "../../data/dummy";
const App = () => {
const [customSeries, setCustomSeries] = useState(stackedCustomSeries);
const handleClick = () => {
//What write here ?
};
return (
<div className="m-5">
<button type="button" onClick={handleClick}>
ChangeButton
</button>
</div>
);
};
export default App;
</code></pre>
<p>dummy.js</p>
<pre><code>export const stackedChartData = [
[
{ x: 'Jan', y: 111.1 },
{ x: 'Feb', y: 127.3 },
{ x: 'Mar', y: 143.4 },
{ x: 'Apr', y: 159.9 },
{ x: 'May', y: 159.9 },
{ x: 'Jun', y: 159.9 },
{ x: 'July', y: 159.9 },
],
[
{ x: 'Jan', y: 111.1 },
{ x: 'Feb', y: 127.3 },
{ x: 'Mar', y: 143.4 },
{ x: 'Apr', y: 159.9 },
{ x: 'May', y: 159.9 },
{ x: 'Jun', y: 159.9 },
{ x: 'July', y: 159.9 },
],
];
export const stackedCustomSeries = [
{ dataSource: stackedChartData[0],
xName: 'x',
yName: 'y',
name: 'Budget',
type: 'StackingColumn',
background: 'blue',
},
{ dataSource: stackedChartData[1],
xName: 'x',
yName: 'y',
name: 'Expense',
type: 'StackingColumn',
background: 'red',
},
];
</code></pre>
| [
{
"answer_id": 74126485,
"author": "ControlAltDel",
"author_id": 1291492,
"author_profile": "https://Stackoverflow.com/users/1291492",
"pm_score": 3,
"selected": true,
"text": "await/then"
},
{
"answer_id": 74126628,
"author": "TheZanke",
"author_id": 2957138,
"author... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10983150/"
] |
74,126,490 | <p>I have created an adaptive <a href="https://codepen.io/MaxVelichkin/pen/rNvbQjR" rel="nofollow noreferrer">card layout</a> (check the Codepen link, the code below won't work here because I use SCSS)</p>
<p>The list of cards will be dynamic, they can be added and removed. <strong>How can I make it so that if there is only one card left, it will be centered horizontally instead of sticking to the left side of the screen?</strong></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>//Root fonts and colors
$root-font-size: 16px;
html {
font-size: $root-font-size;
}
body {
background-color: #e5e5e5;
}
//breakpoints
$breakpoint-small: 576px;
$breakpoint-large: 992px;
$breakpoint-extralarge: 1200px;
.page-wrapper {
margin: 50px 250px;
}
@media only screen and (max-width: $breakpoint-extralarge) {
.page-wrapper {
margin: 50px 150px;
}
}
@media only screen and (max-width: $breakpoint-small) {
.page-wrapper {
margin: 50px 50px;
}
}
//Card
$card-title-fontsize: 2rem;
$card-subtitle-fontsize: 0.875rem;
$card-transition-speed: 0.3s;
$card-border-radius: 4px;
.cards-section {
display: flex;
flex-wrap: wrap;
width: 100%;
gap: 20px;
}
.card-main {
position: relative;
display: flex;
flex-direction: column;
flex-basis: calc(100% / 2 - 20px);
height: 200px;
border-radius: $card-border-radius;
background-color: white;
border: solid #e0e0e0 1px;
box-sizing: border-box;
overflow: hidden;
}
.card-main:hover {
transition: all $card-transition-speed;
box-shadow: 0px 2px 1px -1px rgb(0 0 0 / 20%),
0px 1px 1px 0px rgb(0 0 0 / 14%), 0px 1px 3px 0px rgb(0 0 0 / 12%);
cursor: pointer;
.card-title {
opacity: 0;
transition: all $card-transition-speed;
}
.card-icon-1 {
width: 150px;
height: 150px;
opacity: 0;
transition: all $card-transition-speed;
}
.card-icon-2 {
width: 150px;
height: 150px;
opacity: 0.3;
transition: all $card-transition-speed;
}
.card-subtitle {
height: 50%;
opacity: 1;
transition: all $card-transition-speed;
}
}
.card-icon-1 {
width: 100px;
height: 100px;
background-color: darkgrey;
border-radius: 100%;
margin: 0 auto;
position: absolute;
top: 20px;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
opacity: 1;
transition: all $card-transition-speed;
}
.card-icon-2 {
width: 100px;
height: 100px;
background-color: #00ffb9;
border-radius: 100%;
margin: 0 auto;
position: absolute;
top: 20px;
left: 0;
right: 0;
margin-left: auto;
margin-right: auto;
opacity: 0;
transition: all $card-transition-speed;
}
.card-title {
font-size: $card-title-fontsize;
line-height: 2rem;
font-weight: 500;
letter-spacing: 0.0125em;
margin: 130px auto;
opacity: 1;
transition: all $card-transition-speed;
.text-container {
display: -webkit-box;
-webkit-line-clamp: 1;
-webkit-box-orient: vertical;
//word-break: break-all;
overflow: hidden;
}
}
.card-subtitle {
position: absolute;
bottom: 0%;
//background-color: white;
background: linear-gradient(
to bottom,
rgba(255, 255, 255, 0) 0%,
rgba(0, 255, 185, 0.3) 100%
);
height: 0%;
width: 100%;
font-size: $card-subtitle-fontsize;
line-height: 1.25rem;
font-weight: 400;
letter-spacing: 0.0178571429em;
box-sizing: border-box;
padding: 0px 20px;
opacity: 0;
transition: all $card-transition-speed;
.text-container {
display: -webkit-box;
-webkit-line-clamp: 4;
-webkit-box-orient: vertical;
//word-break: break-all;
overflow: hidden;
}
}
@media only screen and (max-width: $breakpoint-extralarge) {
.card-main {
flex-basis: calc(100% / 1 - 20px);
}
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="page-wrapper">
<div class="cards-section">
<div class="card-main">
<div class="card-icon-1"></div>
<div class="card-icon-2"></div>
<div class="card-title">
<div class="text-container"> Card title </div>
</div>
<div class="card-subtitle">
<div class="text-container"> Nulla feugiat elit quis ante molestie fringilla. Donec vulputate lobortis convallis. Sed pellentesque massa nec ex semper blandit. Integer ornare dignissim velit, vel egestas nisl blandit at. Fusce eros lacus, auctor ac ligula vel, gravida pellentesque nibh. Morbi ut ante at elit pulvinar tempus. Ut dui est, aliquam ac lacus sed, pellentesque ultricies turpis. Donec non nisl volutpat, fringilla velit vel, accumsan mi. Phasellus vestibulum pulvinar facilisis. Nam auctor nisi lacus, id blandit lacus aliquet sit amet. </div>
</div>
</div>
<div class="card-main">
<div class="card-icon-1"></div>
<div class="card-icon-2"></div>
<div class="card-title">
<div class="text-container"> Card title </div>
</div>
<div class="card-subtitle">
<div class="text-container"> Vivamus a metus id massa pretium rhoncus vel eget elit. Aliquam consequat convallis nisi, id tincidunt lectus fringilla vel. Ut viverra vulputate felis. Aenean nisl lorem, commodo sit amet molestie vitae, hendrerit ut lectus. </div>
</div>
</div>
<div class="card-main">
<div class="card-icon-1"></div>
<div class="card-icon-2"></div>
<div class="card-title">
<div class="text-container"> Card title </div>
</div>
<div class="card-subtitle">
<div class="text-container"> Vivamus a metus id massa pretium rhoncus vel eget elit. Aliquam consequat convallis nisi, id tincidunt lectus fringilla vel. Ut viverra vulputate felis. Aenean nisl lorem, commodo sit amet molestie vitae, hendrerit ut lectus. </div>
</div>
</div>
<div class="card-main">
<div class="card-icon-1"></div>
<div class="card-icon-2"></div>
<div class="card-title">
<div class="text-container"> Card title </div>
</div>
<div class="card-subtitle">
<div class="text-container"> Vivamus a metus id massa pretium rhoncus vel eget elit. Aliquam consequat convallis nisi, id tincidunt lectus fringilla vel. Ut viverra vulputate felis. Aenean nisl lorem, commodo sit amet molestie vitae, hendrerit ut lectus. </div>
</div>
</div>
</div>
</div></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74126596,
"author": "Abdul Nafay",
"author_id": 18909135,
"author_profile": "https://Stackoverflow.com/users/18909135",
"pm_score": 1,
"selected": false,
"text": " .card-main{\n margin: 0 auto;\n}\n"
},
{
"answer_id": 74126601,
"author": "Asmoth",
"author... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6530539/"
] |
74,126,505 | <p><strong>Background</strong></p>
<p>In this data set, 1 corresponds to a positive (yes) response and 2 corresponds with a negative (no) response. The dataset has been truncated from a larger data set.</p>
<pre><code>data <- structure(list(col1 = c(1, 2, 2, 1, 1, 2, NA),
col2 = c(2, 2, 2, 1, 1, 2, 1),
col3 = c(1, 1, 2, 1, 1, 2, 1),
col4 = c(2, 2, 2, NA, 1, 2, NA),
col5 = c(2, 2, 2, 1, 1, 1, 1),
col6 = c(2, 1, 2, NA, 1, 1, 2),
col7 = c(2, 2, 2, 1, 2, 2, 1),
col8 = c(2, 2, 2, NA, 2, 2, 1),
col9 = c(2, 2, 2, NA, 2, 2, NA)), row.names = c(NA, -7L), class = c("tbl_df",
"tbl", "data.frame"))
</code></pre>
<p>The data set produces the following results using <code>tibble()</code>.</p>
<pre><code># A tibble: 6 x 9
col1 col2 col3 col4 col5 col6 col7 col8 col9
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1 2 1 2 2 2 2 2 2
2 2 2 1 2 2 1 2 2 2
3 2 2 2 2 2 2 2 2 2
4 1 1 1 NA 1 NA 1 NA NA
5 1 1 1 1 1 1 2 2 2
6 2 2 2 2 1 1 2 2 2
7 NA 1 1 NA 1 2 1 1 1
</code></pre>
<p><strong>My Question</strong></p>
<p>My question is that for all observation that have at least one <strong>YES (1) response</strong> and no <strong>NO (2) responses</strong>, recode any missing values to 2. So, in this case, observations 4 would be altered but not 7 as 7 would fit the condition set. This would produce the desired.</p>
<pre><code># A tibble: 6 x 9
col1 col2 col3 col4 col5 col6 col7 col8 col9
<dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl> <dbl>
1 1 2 1 2 2 2 2 2 2
2 2 2 1 2 2 1 2 2 2
3 2 2 2 2 2 2 2 2 2
4 1 1 1 2 1 2 1 2 2
5 1 1 1 1 1 1 2 2 2
6 2 2 2 2 1 1 2 2 2
7 NA 1 1 NA 1 2 1 1 1
</code></pre>
| [
{
"answer_id": 74126596,
"author": "Abdul Nafay",
"author_id": 18909135,
"author_profile": "https://Stackoverflow.com/users/18909135",
"pm_score": 1,
"selected": false,
"text": " .card-main{\n margin: 0 auto;\n}\n"
},
{
"answer_id": 74126601,
"author": "Asmoth",
"author... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126505",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20282737/"
] |
74,126,574 | <p>I have 1000 of UYC timestamps in csv file, I want to convert it into date and time but I am only interested in second like</p>
<blockquote>
<p>Timestamps= 1666181576.26295,
1666181609.54292</p>
<p>19/10/2022 15:45:25.34568</p>
</blockquote>
<p>from that I only have interest in 25.34568 seconds, also the numbers after points. How can I get this type of conversion in python? Mostly the search on the internet is interested in conversation from UTC to time and date but I also want precision in seconds.</p>
| [
{
"answer_id": 74126596,
"author": "Abdul Nafay",
"author_id": 18909135,
"author_profile": "https://Stackoverflow.com/users/18909135",
"pm_score": 1,
"selected": false,
"text": " .card-main{\n margin: 0 auto;\n}\n"
},
{
"answer_id": 74126601,
"author": "Asmoth",
"author... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17356236/"
] |
74,126,588 | <p>I have a <a href="https://learn.microsoft.com/en-us/azure/api-management/api-management-access-restriction-policies" rel="nofollow noreferrer">validate-jwt</a> instruction in my APIM API policy (<code><inbound></code> section).</p>
<p>I am sending a hopefully correct token in a header and the request still fails.</p>
<p>What would be the way to find out from the APIM which specific JWT token validation check has failed?</p>
| [
{
"answer_id": 74138341,
"author": "onkami",
"author_id": 820947,
"author_profile": "https://Stackoverflow.com/users/820947",
"pm_score": 1,
"selected": false,
"text": "exceptions\n| where type contains \"Token\"\n"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/820947/"
] |
74,126,592 | <p>When I'm applying style to my button <code>@style/Widget.Material3.Button</code> then it is making the whole layout design disappear and the layout is not visible anymore.</p>
<p>Here is my XML Code.</p>
<pre><code><Button
style="@style/Widget.Material3.Button"
android:id="@+id/button"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginStart="60dp"
android:layout_marginTop="16dp"
android:layout_marginEnd="60dp"
android:text="Text"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/textField" />
</code></pre>
<p>Is there any solution to solve this render problem?</p>
| [
{
"answer_id": 74138341,
"author": "onkami",
"author_id": 820947,
"author_profile": "https://Stackoverflow.com/users/820947",
"pm_score": 1,
"selected": false,
"text": "exceptions\n| where type contains \"Token\"\n"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126592",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12499875/"
] |
74,126,597 | <p>My header consists of only the <code><nav></code> element.</p>
<p>How can I achieve a layout like in <a href="https://ibb.co/0cBw7b9" rel="nofollow noreferrer">this picture</a> using only a flexbox layout?</p>
<p>Currently, I achieved this layout by setting the a <code>display: inline-block</code> to <code><li></code> elements and then moved the logo to the left with <code>float: left</code> and the last two menu items to the right with <code>float: right</code> CSS properties.</p>
<p>I would like to know if this is possible in flexbox layout.</p>
<p>I know that setting the <code>margin-right: auto</code> would move the Logo menu item to the left.</p>
<p>But setting <code>margin-left: auto</code> to last two menu items wouldn't work, because they would not be next to each other.</p>
<p>Here is the full code:</p>
<p>HTML:</p>
<pre><code><header>
<nav>
<ul>
<li class="left">Logo</li>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
<li class="right">Item 5</li>
<li class="right">Item 4</li>
</ul>
</nav>
</code></pre>
<p>CSS</p>
<pre><code>body {
max-width: 950px;
margin: 0 auto;
}
header {
padding: 30px 10px;
border-bottom: 1px solid grey;
}
nav ul {
list-style-type: none;
text-align: center;
}
nav ul li {
display: inline-block;
}
.left {
float: left;
}
.right {
float: right;
margin-left: 10px;
}
</code></pre>
| [
{
"answer_id": 74138341,
"author": "onkami",
"author_id": 820947,
"author_profile": "https://Stackoverflow.com/users/820947",
"pm_score": 1,
"selected": false,
"text": "exceptions\n| where type contains \"Token\"\n"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126597",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20282922/"
] |
74,126,605 | <p>I made a web page for my project, where I need to change a button background color based on value from database.Like if the value below 10 then it will be green, 10~20 then yellow, 20++ then turns into red. Is it possible to do?</p>
<p>already the button works to fetch data from data base.<a href="https://i.stack.imgur.com/VLk3k.jpg" rel="nofollow noreferrer">enter image description here</a></p>
| [
{
"answer_id": 74128086,
"author": "Koяэn",
"author_id": 19197313,
"author_profile": "https://Stackoverflow.com/users/19197313",
"pm_score": 0,
"selected": false,
"text": "<div style=\"background-color:{{ data['color_ref'] }};\">Hello World</div>\n"
},
{
"answer_id": 74136761,
... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126605",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20283245/"
] |
74,126,609 | <pre><code>vecs = np.array([[1, 2, 3],
[4, 5, 6],
[7, 8, 9]])
def find_len(vector):
return (vector[0] ** 2 + vector[1] ** 2 + vector[2] ** 2) ** 0.5
vec_len = np.vectorize(find_len)
</code></pre>
<p>I want to apply find_len to every vector in the 2d array and create a new numpy array with the values returned. How can I do this?</p>
| [
{
"answer_id": 74128086,
"author": "Koяэn",
"author_id": 19197313,
"author_profile": "https://Stackoverflow.com/users/19197313",
"pm_score": 0,
"selected": false,
"text": "<div style=\"background-color:{{ data['color_ref'] }};\">Hello World</div>\n"
},
{
"answer_id": 74136761,
... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20283143/"
] |
74,126,673 | <p>How to achieve the layout down below in picture? If i take off <code>flex:1</code> from my Text than the <code>ellipsizeMode="tail"</code> is not working, but if i add <code>flex: 1</code> yellow icon gets pushed to the end of container, but it should be next to the Text like in the picture.
<a href="https://i.stack.imgur.com/gUNyr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gUNyr.png" alt="layout preview" /></a></p>
<pre><code> <Pressable style={{paddingVertical: 18, alignItems: "center",flexDirection: "row",
backgroundColor: "grey"}>
<Text style={{flex: 1} numberOfLines={1} ellipsizeMode="tail">
{longText}
</Text>
<View>
<YellowIcon />
</View>
<RedIcon />
</Pressable>
</code></pre>
| [
{
"answer_id": 74128086,
"author": "Koяэn",
"author_id": 19197313,
"author_profile": "https://Stackoverflow.com/users/19197313",
"pm_score": 0,
"selected": false,
"text": "<div style=\"background-color:{{ data['color_ref'] }};\">Hello World</div>\n"
},
{
"answer_id": 74136761,
... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126673",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19865521/"
] |
74,126,702 | <p>In my model file I am using a macro with a regex extract any space-separated alpha-numeric words to capture an user-input sentence i.e.</p>
<pre><code>macros:
- name: "<GENERIC_INPUT>"
macro: "{//[a-zA-Z0-9 ]+//}"
</code></pre>
<p>Then I am trying to capture it as following in the element:</p>
<pre><code>elements:
- id: "prop:title"
description: Set title
synonyms:
- "{set|add} title <GENERIC_INPUT>"
</code></pre>
<p>The intent term is as following:</p>
<pre><code>intents:
- "intent=myIntent term(createStory)~{tok_id() == 'prop:createStory'} term(title)~{tok_id() == 'prop:title'}?"
</code></pre>
<p>In the Java Model I am correctly capturing the <code>title</code> property:</p>
<pre><code>public NCResult onMatch(
NCIntentMatch ctx,
@NCIntentTerm("createStory") NCToken createStory,
@NCIntentTerm("title") Optional<NCToken> titleList,
{
...
</code></pre>
<p>When I run a query against the REST API service the probe is deployed in, I only get the first word of the last element <GENERIC_INPUT> (the regular expression) of the synonym defined as <code>{set|add} title <GENERIC_INPUT></code> i.e.</p>
<pre><code>HTTP 200 [235ms]
{
"status": "API_OK",
"state": {
"resType": "json",
"mdlId": "Create Story",
"txt": "set title this is my story",
"resMeta": {},
"srvReqId": "GKDY-QLBM-B6TQ-7KYO-KMR8",
"status": "QRY_READY",
"resBody": {
"title": "set title this",
"createStory": true,
},
"usrId": 1,
"intentId": "myIntent"
}
}
</code></pre>
<p>In the <code>resBody.title</code> I get <code>set title this</code> rather than the whole string as it should be allowed by the regex i.e. <code>set title this is my story</code></p>
<p>Any idea why? How can I get it to extract the whole title?</p>
<p>Many thanks</p>
| [
{
"answer_id": 74128086,
"author": "Koяэn",
"author_id": 19197313,
"author_profile": "https://Stackoverflow.com/users/19197313",
"pm_score": 0,
"selected": false,
"text": "<div style=\"background-color:{{ data['color_ref'] }};\">Hello World</div>\n"
},
{
"answer_id": 74136761,
... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126702",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7103967/"
] |
74,126,707 | <p>I have this file (space delimited) :</p>
<pre><code>bc1 no 12
bc1 no 15
bc1 yes 4
bc2 no 8
bc3 yes 14
bc3 yes 12
bc4 no 2
</code></pre>
<p>I would like to get this output :</p>
<pre><code>bc1 3 no;no;yes 31
bc2 1 no 8
bc3 2 yes;yes 26
bc4 1 no 2
</code></pre>
<p>1st column : one occurence of the first column in the input file</p>
<p>2nd : number of this occurence in the input file</p>
<p>3rd : 3rd column translated in row with ";" delimiter</p>
<p>4th : sum of the last column</p>
<p>I can do what I want with the "no/yes" column :</p>
<pre><code>awk -F' ' 'NF>2{a[$1] = a[$1]";"$2}END{for(i in a){print i" "a[i]}}' test.txt | sort -k1,1n
</code></pre>
| [
{
"answer_id": 74126920,
"author": "RavinderSingh13",
"author_id": 5866580,
"author_profile": "https://Stackoverflow.com/users/5866580",
"pm_score": 2,
"selected": false,
"text": "awk"
},
{
"answer_id": 74126928,
"author": "markp-fuso",
"author_id": 7366100,
"author_p... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11504468/"
] |
74,126,720 | <p>I am trying to do a division of :-</p>
<pre><code>#include <bits/stdc++.h>
using namespace std;
int main(){
int A = -2147483648;
int B = -1;
int C = A/B;
// this is not working
cout<<C<<endl;
// nor this is working
cout<<A/B<<endl;
// But this is working
cout<<-2147483648/-1<<endl; // printing the result 2147483648;
}
</code></pre>
<p>I am confused why this happening. Please explain.</p>
| [
{
"answer_id": 74126920,
"author": "RavinderSingh13",
"author_id": 5866580,
"author_profile": "https://Stackoverflow.com/users/5866580",
"pm_score": 2,
"selected": false,
"text": "awk"
},
{
"answer_id": 74126928,
"author": "markp-fuso",
"author_id": 7366100,
"author_p... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126720",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14527233/"
] |
74,126,727 | <p>I'm using onPointer events in react.js
I can get the actual XY coordinates with event.pageX and event.pageY values or client and screen.
but when I'm setting margins, paddings or moving the element to another positions, my coordinates are still from XY values of the whole screen size.
How can I reference my element?
I know that useRef() is there, but how can I reference it without subtracting paddings or margins, I want them to be relative referenced because I will use them a lot in my app.
What's your solution?</p>
<pre class="lang-js prettyprint-override"><code>const App = () => {
const [coordinates, setCoordinates] = useState([]);
return <div
style={{margin: "30px"}}
onPointerDown=
{(event) => setCoordinates([...coordinates, `{event.clientX} {event.clientY}`]}
id="elementiwanttoref">{coordinates.map((cord) => <span>{cord}</span>)}</div>
}
</code></pre>
| [
{
"answer_id": 74126920,
"author": "RavinderSingh13",
"author_id": 5866580,
"author_profile": "https://Stackoverflow.com/users/5866580",
"pm_score": 2,
"selected": false,
"text": "awk"
},
{
"answer_id": 74126928,
"author": "markp-fuso",
"author_id": 7366100,
"author_p... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126727",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18848546/"
] |
74,126,774 | <p>I have a string as below</p>
<blockquote>
<p>33f04e43cc6","from":"/ABC001/data/ZZZ000_logger_v1_20221010053935242_1.zip","to":"/ABC001/data/ZZZ000_logger_v1_20221010053935242_1.zip","remove":true,"objectId":"229bea5a-c9b0-4ad0-aecc-84a63bc7dc6f"}2022-10-10
05:39:35,247 Platform.Interface: Published message to topic:
{"id":"a32e6cbe-94d4-493f-ae56-933f04e43cc6"},
"from":"/ABC001/data/ZZZ000_single_3445442_1.zip"</p>
</blockquote>
<p>I need to extract file names <em>ZZZ000_logger_v1_20221010053935242_1.zip</em>, <em>ZZZ000_single_3445442_1.zip</em> from this.</p>
<p>I have just shared a snapshot of the string. I used to get more file names in that pattern. In the above example, 'logger_v1' and 'single' strings will always be present in the mentioned format in the string</p>
<p>So the format of the filenames will be like that only as mentioned</p>
<pre><code>AnyAlphanumericCharacter_logger_v1_AnyNumeric_1.zip
AnyAlphanumericCharacter_single_AnyNumeric_1.zip
</code></pre>
<p>I tried using regex as below</p>
<pre class="lang-py prettyprint-override"><code>match = re.findall("^\W.*zip$", str)
</code></pre>
<p>It will output <em><code>/ABC001/data/ZZZ000_logger_v1_20221010053935242_1.zip</code></em></p>
<p>I am not sure how to provide dynamic and static characters search patterns in regex.</p>
<p>I will have list of file names like that and need to remove duplicates at the end.</p>
| [
{
"answer_id": 74126818,
"author": "Rahul K P",
"author_id": 4407666,
"author_profile": "https://Stackoverflow.com/users/4407666",
"pm_score": 1,
"selected": false,
"text": "In [1]: re.match(r'.*data/([^\"]+).*', s).group(1)\nOut[1]: 'ZZZ000_logger_v1_20221010053935242_1.zip'\n"
},
{... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2523635/"
] |
74,126,791 | <p>Tldr: Open two txt files, use one to search the other and then print any duplicates.</p>
<p>Hi everyone, first time posting on here and very new to coding and python, I'm searching for an answer and unable to find anything that uses .txt files like I'm trying to do. I am trying to search for a group of strings or single string in test2 using the file test. The reason for me using txt files is it would be impossible for me to have to manually input each value into a list in python as the files have thousands of different strings to search through.</p>
<pre><code>from itertools import chain
f1 = open(r"test.txt", "r")
f2 = open(r"test2.txt", "r")
file1 = f1.read().splitlines()
file2 = f2.read().splitlines()
x = [file1]
y = [file2]
z = list(chain([x,y]))
z.sort()
d = (x for x in z if z.count (x) > 1)
print (d)
f1.close()
f2.close()
</code></pre>
<p>The result I get is this:</p>
<pre><code><generator object <genexpr> at 0x7f10cc992420>
</code></pre>
<p>I understand that I should be getting a print out of any duplicates that are found from the combined list I created with list(chain()). Any help or suggestions would be greatly appreciated!</p>
| [
{
"answer_id": 74126818,
"author": "Rahul K P",
"author_id": 4407666,
"author_profile": "https://Stackoverflow.com/users/4407666",
"pm_score": 1,
"selected": false,
"text": "In [1]: re.match(r'.*data/([^\"]+).*', s).group(1)\nOut[1]: 'ZZZ000_logger_v1_20221010053935242_1.zip'\n"
},
{... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126791",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20283147/"
] |
74,126,797 | <p>I have a data frame that looks like this:</p>
<p>I want to create a new column called <code>labels</code>, which indicates the genes that have the
top2 <strong>positive</strong> <code>log2FoldChange</code> and small <code>pvalue</code> as well
as the top2 <strong>negative</strong> <code>log2FoldChange</code> and small <code>pvalue</code>.</p>
<pre class="lang-r prettyprint-override"><code>library(tidyverse)
df <- tibble(gene=c("AT1G23410","AT2G05530","AT2G26820","AT1G36240","AT5G05260","AT5G47260"),
log2FoldChange=c(14.468018,13.763999,13.708055, -13.480280,-12.166529,-11.468673),
pvalue=c(0.001,0.004,0.005,0.0041,0.0034,0.004))
df
#> # A tibble: 6 × 3
#> gene log2FoldChange pvalue
#> <chr> <dbl> <dbl>
#> 1 AT1G23410 14.5 0.001
#> 2 AT2G05530 13.8 0.004
#> 3 AT2G26820 13.7 0.005
#> 4 AT1G36240 -13.5 0.0041
#> 5 AT5G05260 -12.2 0.0034
#> 6 AT5G47260 -11.5 0.004
</code></pre>
<p><sup>Created on 2022-10-19 with <a href="https://reprex.tidyverse.org" rel="nofollow noreferrer">reprex v2.0.2</a></sup></p>
<p>I want my data to look like this.</p>
<pre><code>#> gene log2FoldChange pvalue labels
#> <chr> <dbl> <dbl>
#> 1 AT1G23410 14.5 0.001 AT1G23410
#> 2 AT2G05530 13.8 0.004 AT2G05530
#> 3 AT2G26820 13.7 0.005
#> 4 AT1G36240 -13.5 0.0041 AT1G36240
#> 5 AT5G05260 -12.2 0.0034 AT5G05260
#> 6 AT5G47260 -11.5 0.004
</code></pre>
<p><strong>EDIT:</strong>
by small pvalue I mean the smallest value in the dataset. In terms of arrange it would be: <br>
<code>arrange(log2FoldChange, pvalue)</code> for the negative ones, and for the positive <code>arrange(desc(log2FoldChange), pvalue)</code>
does it make sense</p>
| [
{
"answer_id": 74126962,
"author": "Matt",
"author_id": 12967938,
"author_profile": "https://Stackoverflow.com/users/12967938",
"pm_score": 1,
"selected": false,
"text": "library(dplyr)\nlibrary(purrr)\n\ndf <- tibble(gene=c(\"AT1G23410\",\"AT2G05530\",\"AT2G26820\",\"AT1G36240\",\"AT5G0... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126797",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7179299/"
] |
74,126,812 | <p>I am having a quite difficult time trying to <strong>import a YAML file as a JS object</strong> in my React code.</p>
<p>I made this <a href="https://codesandbox.io/s/wonderful-bogdan-ri89iz" rel="nofollow noreferrer"><strong>simple and reproductible CodeSandbox example</strong></a> built with <code>create-react-app</code> to show my problem.</p>
<p>All I am doing is:</p>
<ul>
<li>configuring Webpack in a <code>craco.config.js</code> file (as recommended in the <a href="https://github.com/dilanx/craco/tree/master/packages/craco#configuration-file" rel="nofollow noreferrer"><code>craco</code> docs</a>),</li>
<li>adding some Webpack configuration code for the YAML loader (as recommended in the <a href="https://github.com/eemeli/yaml-loader#usage" rel="nofollow noreferrer"><code>yaml-loader</code> docs</a>).</li>
<li>importing the YAML file in the <code>index.js</code> file so I can use it as a JS object.</li>
</ul>
<pre class="lang-js prettyprint-override"><code>// craco.config.js
module.exports = {
webpack: {
configure: {
module: {
rules: [
{
test: /\.yaml$/,
use: "yaml-loader"
}
],
},
},
},
};
</code></pre>
<pre class="lang-js prettyprint-override"><code>// index.js
...
import testYamlFile from "./testYamlFile.yaml"
ReactDOM.render(
<>
<p>Parsed test YAML file object: {testYamlFile}</p>
<p>Type of parsed object: {typeof testYamlFile}</p>
</>,
document.getElementById("root")
);
</code></pre>
<pre><code>// Output in CodeSandbox browser:
Parsed test YAML file object: data:application/octet-stream;base64,aGVsbG9Xb3JsZEZvck1vZGVsOiBIZWxsbywgZGVhciBtb2RlbCAhCg==
Type of parsed object: string
</code></pre>
<p>In the CodeSandbow example, I am getting a base64 string, so you would tell me that I simply need to decode it and get the content. But there are two things:</p>
<ul>
<li>first, this is not what is intended: I should get a JS object according to the yaml-loader docs</li>
<li>and second, what I get on my PC -- and I can only reproduce it on my machine, despite my best efforts to reproduce the exact same project in CodeSandox -- is even weirder. Actually, I only get the bundled file path, and that's all :</li>
</ul>
<p><a href="https://i.stack.imgur.com/pyOnr.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pyOnr.png" alt="what it does on my machine" /></a></p>
<pre><code>// Output in my own local browser:
Parsed test YAML file object: /static/media/testYamlFile.5a3cab37.yaml
Type of parsed object: string
</code></pre>
<p>I suppose that because Webpack added its unique ID to the file name, it is recognizing and bundling the yaml file. But I don't understand why I can't access its content in my code.</p>
<p>Also tried with <a href="https://github.com/wwilsman/js-yaml-loader" rel="nofollow noreferrer"><code>js-yaml-loader</code></a> instead of <code>yaml-loader</code>: same issue.
What am I doing wrong ? Thanks for your help.</p>
| [
{
"answer_id": 74126962,
"author": "Matt",
"author_id": 12967938,
"author_profile": "https://Stackoverflow.com/users/12967938",
"pm_score": 1,
"selected": false,
"text": "library(dplyr)\nlibrary(purrr)\n\ndf <- tibble(gene=c(\"AT1G23410\",\"AT2G05530\",\"AT2G26820\",\"AT1G36240\",\"AT5G0... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13976355/"
] |
74,126,876 | <p>I have a redirection model with two columns <code>to</code> and <code>from</code>. I also have a frontend UI, where the redirections can be added.</p>
<p>I need to know whether is there any solution to avoid cyclic redirect loop by creating a before_save validation or some thing else.</p>
<p>Some of the redirection test cases:</p>
<p>Cyclic redirection (<strong>will cause a redirection loop</strong>)</p>
<pre><code>1 -> 2
2 -> 3
3 -> 4
4 -> 1
</code></pre>
<p>Chained redirection (<strong>will not cause a redirection loop</strong>)</p>
<pre><code>1 -> 2
2 -> 3
4 -> 1
</code></pre>
<p>Cyclic redirection (<strong>will cause redirection loop</strong>)</p>
<pre><code>1 -> 1
</code></pre>
| [
{
"answer_id": 74126962,
"author": "Matt",
"author_id": 12967938,
"author_profile": "https://Stackoverflow.com/users/12967938",
"pm_score": 1,
"selected": false,
"text": "library(dplyr)\nlibrary(purrr)\n\ndf <- tibble(gene=c(\"AT1G23410\",\"AT2G05530\",\"AT2G26820\",\"AT1G36240\",\"AT5G0... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20184309/"
] |
74,126,936 | <p>I'm trying to write a macro in DBT to unpivot a table (I know there are macros available and I can use SQL to do this but I want to write the macro).</p>
<p>Is there a way I can get a column’s data type/mode in dbt? I’m trying to write a macro where if a column is an array it should be treated differently. Something like this:</p>
<pre><code>{%- set cols = adapter.get_columns_in_relation(table) %}
{% for col in cols %}
{{col.name}} AS 'field_name',
{% if col.mode != 'REPEATED' %}
CAST({{ col.column }} AS STRING) AS 'value'
{% else %}
ARRAY_TO_STRING({{ col.column }}) AS 'value'
{% endif %}
{% endfor %}
</code></pre>
<p>I looked at this page but I’m not sure what the return type is and there’s something wrong with the code here</p>
| [
{
"answer_id": 74126962,
"author": "Matt",
"author_id": 12967938,
"author_profile": "https://Stackoverflow.com/users/12967938",
"pm_score": 1,
"selected": false,
"text": "library(dplyr)\nlibrary(purrr)\n\ndf <- tibble(gene=c(\"AT1G23410\",\"AT2G05530\",\"AT2G26820\",\"AT1G36240\",\"AT5G0... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74126936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10149318/"
] |
74,127,034 | <p>I have a table users, I want to track their valid from and valid to dates for each profile user worked on and last valid to as null for the existing profile.</p>
<pre><code>select id,email,ROLE,PROFILE,
min_last_modified_date as valid_from, lead(min_last_modified_date) over (partition by
id order by min_last_modified_date) as valid_to
from
(
select id,email,ROLE,PROFILE,
min(last_modified_date) as min_last_modified_date,
max(last_modified_date) as max_last_modified_date
from users_table
group by 1,2,3,4
)
</code></pre>
<p>[sample table]</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>ROLE</th>
<th>EMPLOYEE_NUMBER</th>
<th>PROFILE</th>
<th>LAST_MODIFIED_DATE</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Managers</td>
<td>U001</td>
<td>General Manager</td>
<td>2020-03-24 0:10:35</td>
</tr>
<tr>
<td>1</td>
<td>Managers</td>
<td>U001</td>
<td>General Manager</td>
<td>2020-04-13 13:23:22</td>
</tr>
<tr>
<td>1</td>
<td>Managers</td>
<td>U001</td>
<td>General Manager</td>
<td>2020-04-14 23:39:53</td>
</tr>
<tr>
<td>1</td>
<td>Managers</td>
<td>U001</td>
<td>General Manager</td>
<td>2020-05-04 17:06:57</td>
</tr>
<tr>
<td>1</td>
<td>Managers</td>
<td>U001</td>
<td>General Manager</td>
<td>2020-06-30 0:21:23</td>
</tr>
<tr>
<td>1</td>
<td>Managers</td>
<td>U001</td>
<td>National Acquisition Lead</td>
<td>2020-06-30 21:13:53</td>
</tr>
<tr>
<td>1</td>
<td>Puebla Supervisor</td>
<td>U001</td>
<td>General Manager</td>
<td>2020-11-24 11:54:33</td>
</tr>
<tr>
<td>1</td>
<td>Managers</td>
<td>U001</td>
<td>General Manager</td>
<td>2020-12-03 0:32:42</td>
</tr>
<tr>
<td>1</td>
<td>Managers</td>
<td>U001</td>
<td>General Manager</td>
<td>2022-02-23 1:52:10</td>
</tr>
<tr>
<td>1</td>
<td>Managers</td>
<td>U001</td>
<td>General Manager</td>
<td>2022-04-29 19:29:49</td>
</tr>
</tbody>
</table>
</div>
<p>[sample table2]</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>EMAIL</th>
<th>ROLE</th>
<th>PROFILE</th>
<th>LAST_MODIFIED_DATE</th>
</tr>
</thead>
<tbody>
<tr>
<td>2</td>
<td>bcd</td>
<td>Puebla Supervisor</td>
<td>Vendor Team</td>
<td>2020-07-25 21:25:43</td>
</tr>
<tr>
<td>2</td>
<td>bcd</td>
<td>PueblaSupervisor</td>
<td>Vendor Team</td>
<td>2020-07-29 19:18:38</td>
</tr>
<tr>
<td>2</td>
<td>bcd</td>
<td>PueblaSupervisor</td>
<td>Vendor Team</td>
<td>2020-12-27 19:25:50</td>
</tr>
<tr>
<td>2</td>
<td>bcd</td>
<td>Puebla Supervisor</td>
<td>Vendor Team</td>
<td>2021-01-03 18:22:38</td>
</tr>
<tr>
<td>2</td>
<td>bcd</td>
<td>BelfastSupervisor</td>
<td>Vendor Team</td>
<td>2021-01-10 0:54:47</td>
</tr>
<tr>
<td>2</td>
<td>bcd</td>
<td>Belfast Supervisor</td>
<td>Vendor Team</td>
<td>2021-01-10 18:43:14</td>
</tr>
<tr>
<td>2</td>
<td>bcd</td>
<td>Belfast Supervisor</td>
<td>Vendor Team</td>
<td>2021-02-14 22:39:38</td>
</tr>
<tr>
<td>2</td>
<td>bcd</td>
<td>Belfast Supervisor</td>
<td>Vendor Team</td>
<td>2021-02-22 17:43:56</td>
</tr>
<tr>
<td>2</td>
<td>bcd</td>
<td>Alorica RTA</td>
<td>Vendor Team</td>
<td>2021-03-02 5:05:24</td>
</tr>
<tr>
<td>2</td>
<td>bcd</td>
<td>Alorica RTA</td>
<td>Vendor Team</td>
<td>2021-03-11 18:43:39</td>
</tr>
<tr>
<td>2</td>
<td>bcd</td>
<td>Alorica RTA</td>
<td>Vendor Team</td>
<td>2021-09-06 2:02:24</td>
</tr>
<tr>
<td>2</td>
<td>bcd</td>
<td>Alorica RTA</td>
<td>Vendor Team</td>
<td>2021-09-20 3:05:10</td>
</tr>
</tbody>
</table>
</div>
<p>[getting output like this for sample table 1]</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>EMAIL</th>
<th>ROLE</th>
<th>PROFILE</th>
<th>VALID_FROM</th>
<th>VALID_TO</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>abc</td>
<td>Outside Sales Managers</td>
<td>General Manager</td>
<td>2020-03-24 0:10:35</td>
<td>2021-02-25 22:20:11</td>
</tr>
<tr>
<td>1</td>
<td>abc</td>
<td>Outside Sales Managers</td>
<td>National Acquisition Lead</td>
<td>2021-02-25 22:20:11</td>
<td>Null</td>
</tr>
</tbody>
</table>
</div>
<p>[getting output like this for sample table 2]</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>EMAIL</th>
<th>ROLE</th>
<th>PROFILE</th>
<th>VALID_FROM</th>
<th>VALID_TO</th>
</tr>
</thead>
<tbody>
<tr>
<td>2</td>
<td>bcd</td>
<td>Puebla Supervisor</td>
<td>Vendor Team</td>
<td>2020-03-24 0:10:35</td>
<td>NULL</td>
</tr>
<tr>
<td>2</td>
<td>bcd</td>
<td>Belfast Supervisor</td>
<td>Vendor Team</td>
<td>2020-03-24 0:10:35</td>
<td>NULL</td>
</tr>
<tr>
<td>2</td>
<td>bcd</td>
<td>Alorica RTA</td>
<td>Vendor Team</td>
<td>2020-03-24 0:10:35</td>
<td>NULL</td>
</tr>
</tbody>
</table>
</div>
<p>[Expected output for sample table 1]</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>EMAIL</th>
<th>ROLE</th>
<th>PROFILE</th>
<th>VALID_FROM</th>
<th>VALID_TO</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>abc</td>
<td>Outside Sales Managers</td>
<td>General Manager</td>
<td>2020-03-24 0:10:35</td>
<td>2021-02-25 22:20:11</td>
</tr>
<tr>
<td>1</td>
<td>abc</td>
<td>Outside Sales Managers</td>
<td>National Acquisition Lead</td>
<td>2021-02-25</td>
<td>22:20:11 2021-03-31 22:39:50</td>
</tr>
<tr>
<td>1</td>
<td>abc</td>
<td>Outside Sales Managers</td>
<td>General Manager</td>
<td>2021-03-31 22:39:50</td>
<td>NULL</td>
</tr>
</tbody>
</table>
</div>
<p>[Expected output for sample table 2]</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>EMAIL</th>
<th>ROLE</th>
<th>PROFILE</th>
<th>VALID_FROM</th>
<th>VALID_TO</th>
</tr>
</thead>
<tbody>
<tr>
<td>2</td>
<td>bcd</td>
<td>Puebla Supervisor</td>
<td>Vendor Team</td>
<td>2020-03-24 0:10:35</td>
<td>2021-01-03 18:22:38</td>
</tr>
<tr>
<td>2</td>
<td>bcd</td>
<td>Belfast Supervisor</td>
<td>Vendor Team</td>
<td>2021-01-03 18:22:38</td>
<td>2021-02-22 17:43:56</td>
</tr>
<tr>
<td>2</td>
<td>bcd</td>
<td>Alorica RTA</td>
<td>Vendor Team</td>
<td>2021-02-22 17:43:56</td>
<td>NULL</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74132506,
"author": "Simeon",
"author_id": 3218652,
"author_profile": "https://Stackoverflow.com/users/3218652",
"pm_score": 0,
"selected": false,
"text": "with cte as (\n select\n [id]\n ,[email]\n ,[role]\n ,[profile]\n ,[last_modifi... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74127034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20281128/"
] |
74,127,038 | <p>I am trying to create a new JPA entity without generating a new row in the database.</p>
<p>I have already tried to copy an existing entity, but the problem is that the copy seems to have a connection to the original (I guess because of the ID).
Because when I try to set new values, the values are set for both (copy and original).</p>
<p>The problem is: I have a list of objects (the JPA entities) from this list, some objects need to be added together. The sum of the added objects is to be displayed in a new object - but this object must not appear in the database.</p>
<p>This is what the Entity looks like:</p>
<pre><code>@Aggregate
@Entity
@Table(name = "CUSTOMER_PORTFOLIO_UE",
indexes = {
@Index(columnList = "isin"),
@Index(columnList = "clearstreamDepotNumber"),
@Index(columnList = "validFromDate"),
@Index(columnList = "isin, clearstreamDepotNumber, validFromDate")
})
public class CustomerPortfolioUpdateEvent extends AbstractUpdateEvent implements HasLogicalKey<LogicalCustomerPortfolioKey> {
@NotEmpty
@Length(max = 7)
@Column(nullable = false, length = 7)
private String customerAccountNumber;
@NotNull
@Length(max = 3)
@Column(nullable = false, length = 3)
private String portfolioId;
@NotNull
@Length(min = 12, max = 12)
@Column(nullable = false, length = 12)
private String isin;
@NotEmpty
@Length(max = 7)
@Column(nullable = false, length = 7)
private String depotNumber;
@Nullable
@Length(max = 20)
@Column(length = 20)
private String customerAccountShortName;
@Nullable
@Length(max = 1)
@Column(length = 1)
private String customerGroupId;
@NotNull
@Column(nullable = false, length = 4)
private LegalEntity legalEntity;
@Nullable
@Length(max = 6)
@Column(length = 6)
private String customerSectorId;
@Nullable
@Length(max = 20)
@Column(length = 20)
private String customerSectorName;
@Nullable
@Length(max = 8)
@Column(length = 8)
private String customerAdvisorNumber;
@Nullable
@Length(max = 20)
@Column(length = 20)
private String customerAdvisorName;
@NotNull
@Length(min = 2, max = 3)
@Column(nullable = false, length = 3)
private String taxCountryId;
@NotNull
@Length(min = 2, max = 3)
@Column(nullable = false, length = 3)
private String countryId;
@Nullable
@Length(max = 20)
@Column(length = 20)
private String depotName;
@Nullable
@Length(max = 20)
@Column(length = 20)
private String clearstreamDepotNumber;
@NotNull
@Column(nullable = false, columnDefinition = "DATE")
private LocalDate validFromDate;
@Nullable
@Column(precision = 18, scale = 3)
private BigDecimal openPositionValue;
@Nullable
@Column(precision = 18, scale = 3)
private BigDecimal settledPositionValue;
@NotNull
@Column(nullable = false, precision = 18, scale = 3)
private BigDecimal tradingPositionValue;
@Nullable
@Length(max = 3)
@Column(length = 3)
private String isinSub;
protected CustomerPortfolioUpdateEvent() { }
public CustomerPortfolioUpdateEvent(
@NotNull Timestamp recordedAt,
@NotNull @Length(min = 7, max = 7) String customerAccountNumber,
@NotNull @Length(max = 3) String portfolioId,
@NotNull @Length(min = 12, max = 12) String isin,
@NotNull @Length(max = 7) String depotNumber,
@Nullable String customerAccountShortName,
@Nullable String customerGroupId,
@NotNull LegalEntity legalEntity,
@Nullable @Length(max = 6) String customerSectorId,
@Nullable @Length(max = 20) String customerSectorName,
@Nullable @Length(max = 8) String customerAdvisorNumber,
@Nullable @Length(max = 20) String customerAdvisorName,
@NotNull @Length(min = 2, max = 3) String taxCountryId,
@NotNull @Length(min = 2, max = 3) String countryId,
@Nullable @Length(max = 20) String depotName,
@Nullable @Length(max = 20) String clearstreamDepotNumber,
@NotNull LocalDate validFromDate,
@Nullable BigDecimal openPositionValue,
@Nullable BigDecimal settledPositionValue,
@NotNull BigDecimal tradingPositionValue,
@Nullable String isinSub
) {
super(recordedAt);
this.customerAccountNumber = customerAccountNumber;
this.portfolioId = portfolioId;
this.isin = isin;
this.depotNumber = depotNumber;
this.customerAccountShortName = customerAccountShortName;
this.customerGroupId = customerGroupId;
this.legalEntity = legalEntity;
this.customerSectorId = customerSectorId;
this.customerSectorName = customerSectorName;
this.customerAdvisorNumber = customerAdvisorNumber;
this.customerAdvisorName = customerAdvisorName;
this.taxCountryId = taxCountryId;
this.countryId = countryId;
this.depotName = depotName;
this.clearstreamDepotNumber = clearstreamDepotNumber;
this.validFromDate = validFromDate;
this.openPositionValue = openPositionValue;
this.settledPositionValue = settledPositionValue;
this.tradingPositionValue = tradingPositionValue;
this.isinSub = isinSub;
}
</code></pre>
<p>AbstractUpdateEvent:</p>
<pre><code>@MappedSuperclass
public abstract class AbstractUpdateEvent implements UpdateEvent {
public static final String SYSTEM_TRIGGERER = "SYSTEM";
@Id
@NotNull
@Length(max = IdGenerator.MAX_LENGTH)
@Column(length = IdGenerator.MAX_LENGTH)
private String id;
@NotNull
@Column(nullable= false)
private Timestamp recordedAt;
</code></pre>
| [
{
"answer_id": 74132506,
"author": "Simeon",
"author_id": 3218652,
"author_profile": "https://Stackoverflow.com/users/3218652",
"pm_score": 0,
"selected": false,
"text": "with cte as (\n select\n [id]\n ,[email]\n ,[role]\n ,[profile]\n ,[last_modifi... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74127038",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20283482/"
] |
74,127,048 | <p>Consider this code in Python</p>
<pre><code>filter_2020 = hdb_million[hdb_million["year"]==2020]
town_2020 = filter_2020["town"].unique()
results_2020 = len(town_2020)
print(town_2020)
print("in 2020 the number of towns are:", results_2020)
print("\n")
filter_2021 = hdb_million[hdb_million["year"]==2021]
town_2021 = filter_2021["town"].unique()
results_2021 = len(town_2021)
print(town_2021)
print("in 2021 the number of towns are:", results_2021)
print("\n")
filter_2022 = hdb_million[hdb_million["year"]==2022]
town_2022 = filter_2022["town"].unique()
results_2022 = len(town_2022)
print(town_2022)
</code></pre>
<p>Output</p>
<pre><code>['BUKIT MERAH' 'CLEMENTI' 'TOA PAYOH' 'KALLANG/WHAMPOA' 'QUEENSTOWN'
'BISHAN' 'CENTRAL AREA' 'ANG MO KIO' 'GEYLANG']
in 2020 the number of towns are: 9
['BISHAN' 'BUKIT MERAH' 'CENTRAL AREA' 'CLEMENTI' 'QUEENSTOWN' 'SERANGOON'
'TOA PAYOH' 'BUKIT TIMAH' 'KALLANG/WHAMPOA' 'ANG MO KIO']
in 2021 the number of towns are: 10
['ANG MO KIO' 'BISHAN' 'BUKIT TIMAH' 'CENTRAL AREA' 'CLEMENTI' 'GEYLANG'
'KALLANG/WHAMPOA' 'QUEENSTOWN' 'SERANGOON' 'TOA PAYOH' 'BUKIT MERAH'
'YISHUN' 'PASIR RIS' 'WOODLANDS' 'BUKIT BATOK' 'HOUGANG' 'MARINE PARADE'
'PUNGGOL' 'TAMPINES' 'BEDOK']
in 2022 the number of towns are: 20
</code></pre>
<p>Instead of repeating the codes, can I define a function to arrive at the same output ? I tried several def functions but am not successful. Most grateful for any insights. thank you</p>
| [
{
"answer_id": 74127082,
"author": "Rahul K P",
"author_id": 4407666,
"author_profile": "https://Stackoverflow.com/users/4407666",
"pm_score": 2,
"selected": false,
"text": "for year in [2020, 2021, 2022]:\n filter_year = hdb_million[hdb_million[\"year\"]== year]\n town = filter_ye... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74127048",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16733740/"
] |
74,127,052 | <p>DATA BELOW</p>
<pre><code>analysis<-tibble(off_race = c("hispanic", "hispanic", "white","white", "hispanic", "white", "hispanic", "white", "white", "white","hispanic"), any_black_uof = c(FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), any_black_arrest = c(TRUE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE, FALSE), prop_white_scale = c(0.866619646027524, -1.14647499712298, 1.33793539994219, 0.593565300512359, -0.712819809606193, 0.3473585867755, -1.37025501425243, 1.16596624239715, 0.104521426674564, 0.104521426674564, -1.53728347122581), prop_hisp_scale=c(-0.347382203637802, 1.54966785579018,
-0.833021026477168, -0.211470492567308, 1.48353691981021,
0.421968013870802, 2.63739845069911, -0.61002505397242, 0.66674880256898,0.66674880256898, 2.93190487813111))
</code></pre>
<p>I would like to run a series of regressions that iterate over these vectors</p>
<pre><code>officer_race = c("black", "white", "hispanic")
primary_ind<-c("prop_white_scale","prop_hisp_scale","prop_black_scale")
outcome<-c("any_black_uof","any_white_uof","any_hisp_uof","any_black_arrest","any_white_arrest","any_hisp_arrest","any_black_stop","any_white_stop","any_hisp_stop")
</code></pre>
<p>Also of note, I would like to use the fixest package
where the regressions would look like this</p>
<pre><code>feols(any_black_uof~ prop_white_scale,data=analysis[analysis$off_race =="black"])
feols(any_black_uof~ prop_white_scale,data=analysis[analysis$off_race =="white"])
feols(any_black_uof~ prop_white_scale,data=analysis[analysis$off_race=="hispanic"])
feols(any_black_uof~ prop_hisp_scale,data=analysis[analysis$off_race =="black"])
feols(any_black_uof~ prop_hisp_scale,data=analysis[analysis$off_race =="white"])
</code></pre>
<p>etc. iterating through all possible combinations and creating a list of lm objects.</p>
<p>Is this possible?</p>
| [
{
"answer_id": 74127082,
"author": "Rahul K P",
"author_id": 4407666,
"author_profile": "https://Stackoverflow.com/users/4407666",
"pm_score": 2,
"selected": false,
"text": "for year in [2020, 2021, 2022]:\n filter_year = hdb_million[hdb_million[\"year\"]== year]\n town = filter_ye... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74127052",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16365963/"
] |
74,127,056 | <p>I am learning through w3schools. I am confused mainly about the meaning of java syntax. To my understanding, both functions the same except for the String cases.
The thing I don't understand is their parameters; why is the other an Object and the other is String?</p>
<pre><code>public boolean equals(Object anotherObject)
</code></pre>
<pre><code>public boolean equalsIgnoreCase(String anotherString)
</code></pre>
| [
{
"answer_id": 74127106,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 4,
"selected": true,
"text": "equals(Object)"
},
{
"answer_id": 74127185,
"author": "Balint",
"author_id": 4417974,
"author_p... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74127056",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20237229/"
] |
74,127,059 | <p>I want to generate random ints from 4 specific numbers (1,2,5,10).
I only want the output to be one of these. How?</p>
| [
{
"answer_id": 74127106,
"author": "Joachim Sauer",
"author_id": 40342,
"author_profile": "https://Stackoverflow.com/users/40342",
"pm_score": 4,
"selected": true,
"text": "equals(Object)"
},
{
"answer_id": 74127185,
"author": "Balint",
"author_id": 4417974,
"author_p... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74127059",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17138369/"
] |
74,127,067 | <p>I want to create a registration and login with rest api using PHP mysql in my Application.</p>
<p>This is my code</p>
<pre><code><?php
header('Access-Control-Allow-Origin: *');
header('Access-Control-Allow-Credential: true');
header('Access-Control-Allow-Methods: PUT, GET, POST, DELETE, OPTIONS');
header('Access-Control-Allow-Headers: Origin, Content-Type, Authorization, Accept, X-Requested-With, x-xsrf-token');
header('Content-Type: application/json; charset=utf-8');
include'config.php';
$postjson = json_decode(file_get_contents('php://input'), true);
$today = date('Y-m-d H:i:s');
if($postjson['aksi'] == 'registration_progress'){
$emailcheck = mysqli_fetch_array(mysqli_query($mysqli, "SELECT email FROM users WHERE email = '$postjson[email]'"));
if($emailcheck['email'] == $postjson['email']){
$result = json_decode(array('success' => false, 'msg' => 'Email Sudah Terdaftar'));
}else{
$password= md5($postjson['password']);
$query = mysqli_query($mysqli, "INSERT INTO users SET
nama_user = '$postjson[nama_user],
email = '$postjson[email],
password = '$password,
createat = '$today',
");
if($query) $result = json_encode(array('success' => true, 'msg' => 'Registrasi Berhasil !!'));
else $result = json_encode(array('success' => false, 'msg' => 'Registrasi Gagal !!'));
echo $result;
}
}elseif($postjson['aksi'] == 'login_progress'){
$password = md5($postjson['password']);
$logindata = mysqli_fetch_array(mysqli_query($mysqli, "SELECT * FROM users WHERE email = '$postjson[email]' AND password = '$password'"));
$data = array(
'id_user' => $logindata['id_user'],
'nama_user' => $logindata['nama_user'],
'email' => $logindata['email']
);
if($logindata){
$result =json_encode(array('success' => true, 'result' => $data));
}else{
$result =json_encode(array('success' => false));
}
echo $result;
}
</code></pre>
<p>I don't know my error</p>
<blockquote>
<p>Notice Trying to access array offset on value of type null in <b>C:\xampp\htdocs\api-ionic\api.php</b> on line 13
<br />
Notice: Trying to access array offset on value of type null in <b>C:\xampp\htdocs\api-ionic\api.php</b> on line 31<br /></p>
</blockquote>
| [
{
"answer_id": 74127281,
"author": "Martin",
"author_id": 3536236,
"author_profile": "https://Stackoverflow.com/users/3536236",
"pm_score": 2,
"selected": false,
"text": "$postjson['aksi']"
},
{
"answer_id": 74127286,
"author": "xDiaM0nD",
"author_id": 8169525,
"autho... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74127067",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20283452/"
] |
74,127,072 | <p>There is an animation that I want to trigger every time the iot data changes, but it only works the first time.</p>
<p>Here Code:</p>
<pre><code> useEffect(async () => {
function animate(elem, style, unit, from, to, time) {
if (!elem) return;
var start = new Date().getTime(),
timer = setInterval(function () {
var step = Math.min(1, (new Date().getTime() - start) / time);
elem.style[style] = (from + step * (to - from)) + unit;
if (step == 1) clearInterval(timer);
}, 25);
elem.style[style] = from + unit;
}
animate(document.getElementById('id'), "height", "px", 0, 50, 1000);
}, [iot])
</code></pre>
| [
{
"answer_id": 74127276,
"author": "David",
"author_id": 13019276,
"author_profile": "https://Stackoverflow.com/users/13019276",
"pm_score": 1,
"selected": false,
"text": "useEffect(async () => {"
},
{
"answer_id": 74136253,
"author": "Selim Başpınar",
"author_id": 199237... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74127072",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19923784/"
] |
74,127,079 | <p>When I open a directory with <code>opendir()</code> and later call <code>readdir()</code> two times in a row, the latter returns an empty array.
<br><br><br>
minimal_example.pl:</p>
<pre><code>#!/usr/bin/perl
use strict;
use warnings;
use Data::Dumper qw(Dumper);
opendir(my $DIRH, "/home") or die "Cannot open /home: $!\n";
my @FILES = readdir($DIRH);
my @FILES2 = readdir($DIRH);
print Dumper \@FILES;
print Dumper \@FILES2;
</code></pre>
<p>output:</p>
<pre><code>$VAR1 = [
'.',
'..',
'users',
'sysadmin',
'ne'
];
$VAR1 = [];
</code></pre>
<p>Is that expected behavior?</p>
| [
{
"answer_id": 74127480,
"author": "TomW",
"author_id": 20283815,
"author_profile": "https://Stackoverflow.com/users/20283815",
"pm_score": 1,
"selected": false,
"text": "readdir()"
},
{
"answer_id": 74128526,
"author": "zdim",
"author_id": 4653379,
"author_profile": ... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74127079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19745277/"
] |
74,127,089 | <p>In IPython I can run <code>data = catalog.load('my_dataset')</code> in order to load a dataset specified as 'my_dataset' in the <code>catalog.yml</code> file. What's the equivalent command in a pthon script? What do I need to import?</p>
| [
{
"answer_id": 74127418,
"author": "emp",
"author_id": 4517871,
"author_profile": "https://Stackoverflow.com/users/4517871",
"pm_score": 1,
"selected": false,
"text": "catalog.yml"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74127089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7277506/"
] |
74,127,122 | <p>I have the following function to create heat map colors from red to green. It works well.
But now I need a rainbow color heatmap from red via yellow and green to blue.
How could this be achieved by modifiying the following code?</p>
<pre><code> public Color HeatMapColor(double value, double min, double max)
{
if (value < min)
{
return Color.LightGray;
}
else if (value > max)
{
return Color.Black;
}
else
{
try
{
double val = (value - min) / (max - min);
int r = System.Convert.ToInt32(System.Math.Floor(255 * val));
int g = System.Convert.ToInt32(System.Math.Floor(255 * (1 - val)));
int b = 0;
if (r > 255 || r < 0)
r = 255;
if (g > 255 || g < 0) g = 255;
else if (b > 255 || b < 0) b = 255;
return Color.FromArgb(255, r, g, b);
}
catch (OverflowException)
{
return Color.FromArgb(255, 255, 255, 255);
}
}
}
</code></pre>
| [
{
"answer_id": 74127488,
"author": "Jeroen van Langen",
"author_id": 2266130,
"author_profile": "https://Stackoverflow.com/users/2266130",
"pm_score": 2,
"selected": false,
"text": "// specify some colors.\nvar colors = new[] {Color.Red, Color.Yellow, Color.Green, Color.Blue};\n\n// get ... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74127122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7307194/"
] |
74,127,150 | <p>I'm trying to link a series of images together I know the basic HTML Code for linking 1 image to another would be</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-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
<head>
<body>
<!DOCTYPE html>
<html>
<head>
<title>HTML Image as link</title>
</head>
<body>
<a href="Imagelink1">
<img alt="" src="Imagelink2"
>
</a>
</body>
</html></code></pre>
</div>
</div>
</p>
<p>But I'm trying to continue the chain from Imagelink2 to Imagelink3 to Imagelink4 and so on.
How would I go about doing that?</p>
| [
{
"answer_id": 74127488,
"author": "Jeroen van Langen",
"author_id": 2266130,
"author_profile": "https://Stackoverflow.com/users/2266130",
"pm_score": 2,
"selected": false,
"text": "// specify some colors.\nvar colors = new[] {Color.Red, Color.Yellow, Color.Green, Color.Blue};\n\n// get ... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74127150",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20274005/"
] |
74,127,173 | <p>I have two tables like this:</p>
<p><code>Table1</code> with column <code>N</code></p>
<pre><code>N
---
1
2
3
4
5
</code></pre>
<p>And <code>Table2</code> with column <code>M</code>:</p>
<pre><code>M
---
5
9
1
8
1
</code></pre>
<p>Finally, I want to combine these two data sets with the same count of rows and also, save source order like this result:</p>
<pre><code>N M
------
1 5
2 9
3 1
4 8
5 1
</code></pre>
<p>Can anyone help me?</p>
| [
{
"answer_id": 74127250,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 2,
"selected": false,
"text": "ROW_NUMBER()"
},
{
"answer_id": 74161812,
"author": "Hasan Fathi",
"author_id": 3526038,
... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74127173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3526038/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.