qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,330,556 | <p>I created an extension, where I placed a script into a page markup and performs some actions according to the following <a href="https://stackoverflow.com/questions/9515704/access-variables-and-functions-defined-in-page-context-using-a-content-script/9517879#9517879">article</a>:</p>
<pre><code>var s = document.createElement('script');
s.src = chrome.runtime.getURL('code.js');
s.onload = function() {
this.remove();
};
(document.head || document.documentElement).appendChild(s);
</code></pre>
<p>I also displayed a checkbox in "default_popup" which should indicate whether to execute a part of methods in script from "code.js" <em>(web_accessible_resources)</em> or not.</p>
<p>However, I have no idea how to interact between the script from "content_scripts" <em>(which has access to "default_popup")</em> and the script from "web_accessible_resources".</p>
<p>Could you suggest something?</p>
<p>I understand that I can completely replace the "web_accessible_resources" script, but this does not seem to be the best practice.</p>
<p>Thank you.</p>
| [
{
"answer_id": 74330748,
"author": "Melron",
"author_id": 8920328,
"author_profile": "https://Stackoverflow.com/users/8920328",
"pm_score": 1,
"selected": false,
"text": "public static void main(String[] args) {\n int[] CarSales= {1234,2343,1456,4567,8768,2346,9876,4987,7592,9658,7851,2538};\n\n String [] Months = {\"January\",\"February\",\"March\",\"April\",\"May\",\"June\"\n ,\"July \",\"August\",\"September\",\"October\",\"November\",\"December\" };\n\n int HighNum = CarSales[0];\n String month = Months[0];\n\n for(int i = 0; i < CarSales.length; i++)\n {\n if(CarSales[i] > HighNum)\n {\n HighNum = CarSales[i];\n month = Months[i];\n }\n }\n JOptionPane.showMessageDialog(null,\"The highest car sales value is :\"+HighNum +\n \"-which happened in the month of \" + month);\n}\n"
},
{
"answer_id": 74330779,
"author": "Old Dog Programmer",
"author_id": 5103317,
"author_profile": "https://Stackoverflow.com/users/5103317",
"pm_score": 0,
"selected": false,
"text": "public static void main(String[] args) {\n int[] CarSales= {1234,2343,1456,4567,8768,2346,\n 9876,4987,7592,9658,7851,2538};\n\n String [] Months = {\"January\",\"February\",\"March\",\"April\",\"May\",\"June\"\n ,\"July \",\"August\",\"September\",\"October\",\"November\",\"December\" };\n\n int HighNum = CarSales[0];\n int highMonth = 0;\n\n for(int i = 0; i < CarSales.length; i++)\n {\n if(CarSales[i] > HighNum)\n {\n HighNum = CarSales[i];\n highMonth = i;\n }\n }\n JOptionPane.showMessageDialog\n (null,\"The highest car sales value is :\"+HighNum +\n \"-which happened in the month of \" + Months[highMonth]);\n}\n"
},
{
"answer_id": 74331177,
"author": "Alexander Ivanchenko",
"author_id": 17949945,
"author_profile": "https://Stackoverflow.com/users/17949945",
"pm_score": 2,
"selected": false,
"text": "CarSale"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19435750/"
] |
74,330,569 | <p>How would you split a column based on name and take the confidence Intervals split by specific names?</p>
<p>Can't Index because importing a file a range, because importing different files. Can't hardcode names</p>
<p>Data Looks like:</p>
<pre><code>Name | Score
Anna 90
Anna 90
Anna 30
Anna 60
Anna 60
Anna 60
Anna 60
Bob 80
Bob 70
Bob 10
Bob 80
Chad 10
Chad 10
Chad 40
Chad 30
Chad 90
</code></pre>
<p>How would you take the confidence intervals for</p>
<pre><code>Anna | Bob | Chad
</code></pre>
<p>Tried splitting</p>
<pre><code>#df[c('Name')] <- str_split_fixed(df, ' ', 1)
</code></pre>
<p>Tried <code>tapply</code></p>
| [
{
"answer_id": 74330824,
"author": "jay.sf",
"author_id": 6574038,
"author_profile": "https://Stackoverflow.com/users/6574038",
"pm_score": 1,
"selected": false,
"text": "tapply"
},
{
"answer_id": 74330832,
"author": "Andre Wildberg",
"author_id": 9462095,
"author_profile": "https://Stackoverflow.com/users/9462095",
"pm_score": 0,
"selected": false,
"text": "split"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330569",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6063433/"
] |
74,330,590 | <p>I'm trying to use the <code>.find()</code> method in mongodb. The output yeilds a <code>mongodb::Cursor</code>. I'm unable to convert the cursor into a vector so that I can wrap them in a json and send it to my front-end. This is the following idea I've tried</p>
<p><a href="https://i.stack.imgur.com/LE6Fj.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/LE6Fj.jpg" alt="enter image description here" /></a></p>
<p>The following error message is:</p>
<pre><code>the trait bound `Vec<user_model::User>: Extend<Result<user_model::User, mongodb::error::Error>>` is not satisfied\nthe following other types implement trait `Extend<A>`
</code></pre>
<p>I've already included and <code>use futures::StreamExt;</code> and <code>use futures::TryFutureExt;</code> and tried out <code>.try_next()</code> and <code>.map()</code> instead of <code>.collect()</code>, still cant parse it</p>
| [
{
"answer_id": 74331020,
"author": "Peterrabbit",
"author_id": 18242865,
"author_profile": "https://Stackoverflow.com/users/18242865",
"pm_score": 1,
"selected": false,
"text": "next"
},
{
"answer_id": 74331032,
"author": "Tobias S.",
"author_id": 8613630,
"author_profile": "https://Stackoverflow.com/users/8613630",
"pm_score": 3,
"selected": true,
"text": "User"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11750308/"
] |
74,330,630 | <p>I have an app that uses expo-camera to take a picture. I would like to implement a function that would let user to draw over a taken picture. What is the best way to achieve this?</p>
<p>What have I tried?</p>
<ul>
<li>react-native-sketch-canvas (looks like this component is no longer supported)</li>
</ul>
| [
{
"answer_id": 74331020,
"author": "Peterrabbit",
"author_id": 18242865,
"author_profile": "https://Stackoverflow.com/users/18242865",
"pm_score": 1,
"selected": false,
"text": "next"
},
{
"answer_id": 74331032,
"author": "Tobias S.",
"author_id": 8613630,
"author_profile": "https://Stackoverflow.com/users/8613630",
"pm_score": 3,
"selected": true,
"text": "User"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20184613/"
] |
74,330,632 | <p>I'm using the version 2 searchtweets api for learning proposes.</p>
<p>Following the documentation available here: <a href="https://pypi.org/project/searchtweets-v2/" rel="nofollow noreferrer">https://pypi.org/project/searchtweets-v2/</a>, I'm trying to run the following code:</p>
<pre><code> import json
from datetime import date
import os
from searchtweets import gen_request_parameters, load_credentials, collect_results
def query_data_from_twitter():
query = gen_request_parameters("#Messi", None, results_per_call=100)
print("We are getting data from Twitter ...", query)
search_args = load_credentials("~/.twitter_keys.yaml", yaml_key="search_tweets_v2", env_overwrite=False)
return collect_results(query, max_tweets=100, result_stream_args=search_args)
</code></pre>
<p>I'm getting this error:</p>
<pre><code>ImportError: cannot import name 'gen_request_parameters' from 'searchtweets'
</code></pre>
<p>What I've tried so far: uninstalling the previous version of the library and using "from searchtweets.utils import gen_request_parameters.
Do you have any suggestions to use this solve this importing issue?
Thanks !</p>
| [
{
"answer_id": 74331020,
"author": "Peterrabbit",
"author_id": 18242865,
"author_profile": "https://Stackoverflow.com/users/18242865",
"pm_score": 1,
"selected": false,
"text": "next"
},
{
"answer_id": 74331032,
"author": "Tobias S.",
"author_id": 8613630,
"author_profile": "https://Stackoverflow.com/users/8613630",
"pm_score": 3,
"selected": true,
"text": "User"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330632",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15740505/"
] |
74,330,682 | <p>Most factory patterns I've seen in typescript are based on some named mapping between a name and the Class type.</p>
<p>A naive summary implementation:</p>
<pre><code>const myMap = {
classOne: ExampleClass,
classTwo: AnotherClass
}
(k: string) => { return new myMap[k] }
</code></pre>
<p>I wanted to take this mapping idea up a notch - as my classes are of the form ExampleClass implements iGenericInterface<T></p>
<p>However, I can't seem to specify that Record Value types should be limited to those that implement the iGenericInterface<T> In the example I am trying below the problem area is marked with ***</p>
<pre><code>export interface iGenericInterface<K> {
process(input: K): void
}
class ExampleClass implements iGenericInterface<string> {
process(input: string): void {
console.log(input);
}
}
class AnotherClass implements iGenericInterface<number> {
process(input: number): void {
console.log(input);
}
}
class UnsupportedClass {
otherMethod(input: boolean): void {
console.log(input);
}
}
enum instantiableClassesEnum { class1, class2, class3 };
type enumValues = keyof typeof instantiableClassesEnum;
type logicStore<T> = Record<enumValues, ***iGenericInterface<T>***>
const classMap: logicStore<any> = {
class1: ExampleClass,
class2: AnotherClass,
class3: UnsupportedClass,
};
</code></pre>
<p>I would expect the UnsupportedClass to be an error, but would like to have the others accepted by the compiler.</p>
<p>If I change the <code>ExampleClass</code> to an instance i.e. <code>class1: new ExampleClass</code> the compiler is happy - however, I am then not sure how to use the mapping in the factory method - <code>return new myMap[k]</code></p>
<p><strong>EDIT - (@Adriaan This is NOT an answer, just a clarification of the end goal)</strong>
Ability to create classes based on Enumeration input - using mapped structure above.</p>
<pre><code>class LogicFactory {
static createLogic<T>(logicClass: enumValues):
iGenericInterface<T> {
return new classMap[logicClass]();
}
</code></pre>
<p>}</p>
| [
{
"answer_id": 74335628,
"author": "Dimava",
"author_id": 5734961,
"author_profile": "https://Stackoverflow.com/users/5734961",
"pm_score": 1,
"selected": false,
"text": "Constructor<T>"
},
{
"answer_id": 74348422,
"author": "redevill",
"author_id": 452928,
"author_profile": "https://Stackoverflow.com/users/452928",
"pm_score": 0,
"selected": false,
"text": "type Constructor<T> = new (...args: any) => T\nenum instantiableClassesEnum { class1, class2, class3 };\ntype enumValues = keyof typeof instantiableClassesEnum;\ntype logicStore<T> = Record<enumValues, \nConstructor<iGenericInterface<T>>>\n\nconst classMap: logicStore<any> = {\n class1: ExampleClass,\n class2: AnotherClass,\n class3: UnsupportedClass,\n};\n\n\nclass LogicFactory {\n static createLogic<T>(logicClass: enumValues): iGenericInterface<T> {\n return new classMap[logicClass]();\n }\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330682",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/452928/"
] |
74,330,707 | <p>I'm trying to read a file which contains the structure PointID CoordX CoordY, like this:</p>
<pre><code>1 565.0 575.0
2 25.0 185.0
3 345.0 750.0
4 945.0 685.0
5 845.0 655.0
</code></pre>
<p>Where PointID should be the ID of that dot.</p>
<p>Then, I have to create a Punto object following this structure:</p>
<pre><code>Punto p1 = new Punto(16.47, 36.10);
Punto p2 = new Punto(16.47, 280.44);
Punto p3 = new Punto(115.09, 92.54);
Punto p4 = new Punto(364.39, 197.37);
</code></pre>
<p>I came to this solution:</p>
<pre><code>public ArrayList<Punto> puntosFichero(File fich) throws Exception {
String numPunto = "";
String cordX = "";
String cordY = "";
String tmp = "";
ArrayList<Punto> mapa = new ArrayList();
//Opens the file
try {
scannerLectura = new Scanner(fich);
} catch (Exception e) {
throw new Exception("Error: Abrir fichero");
}
//Reads the file and sets the ArrayList
while(scannerLectura.hasNext()){
tmp = scannerLectura.next();
if (tmp.contentEquals("NODE_COORD_SECTION")){
while(!tmp.contentEquals("EOF")){
numPunto = scannerLectura.next(); //P(numPunto)
cordX = scannerLectura.next(); //CordX
cordY = scannerLectura.next(); //CordY
System.out.println("Punto " + numPunto + ": [" + cordX + " , " + cordY + "]");
Punto (Object)numPunto = new Punto (Double.parseDouble(cordX), Double.parseDouble(cordY));
mapa.add(Integer.parseInt(numPunto));
}
}
}
//Closes the file
scannerLectura.close();
return mapa;
}
</code></pre>
<p>But when I try to create a new Punto here:</p>
<blockquote>
<pre><code>Punto (Object)numPunto = new Punto (Double.parseDouble(cordX), Double.parseDouble(cordY));
</code></pre>
</blockquote>
<p>I can't use the string "numPunto" as its name. Is there a way to do that?</p>
| [
{
"answer_id": 74335628,
"author": "Dimava",
"author_id": 5734961,
"author_profile": "https://Stackoverflow.com/users/5734961",
"pm_score": 1,
"selected": false,
"text": "Constructor<T>"
},
{
"answer_id": 74348422,
"author": "redevill",
"author_id": 452928,
"author_profile": "https://Stackoverflow.com/users/452928",
"pm_score": 0,
"selected": false,
"text": "type Constructor<T> = new (...args: any) => T\nenum instantiableClassesEnum { class1, class2, class3 };\ntype enumValues = keyof typeof instantiableClassesEnum;\ntype logicStore<T> = Record<enumValues, \nConstructor<iGenericInterface<T>>>\n\nconst classMap: logicStore<any> = {\n class1: ExampleClass,\n class2: AnotherClass,\n class3: UnsupportedClass,\n};\n\n\nclass LogicFactory {\n static createLogic<T>(logicClass: enumValues): iGenericInterface<T> {\n return new classMap[logicClass]();\n }\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330707",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10734814/"
] |
74,330,721 | <p>I am trying to perform a sort of aggregation, but with the creation of new columns.</p>
<p>Let's take the example of the dataframe below:</p>
<pre><code>df = pd.DataFrame({'City':['Los Angeles', 'Denver','Denver','Los Angeles'],
'Car Maker': ['Ford','Toyota','Ford','Toyota'],
'Qty': [50000,100000,80000,70000]})
</code></pre>
<p>That generates this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: right;"></th>
<th style="text-align: left;">City</th>
<th style="text-align: left;">Car Maker</th>
<th style="text-align: right;">Qty</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: right;">0</td>
<td style="text-align: left;">Los Angeles</td>
<td style="text-align: left;">Ford</td>
<td style="text-align: right;">50000</td>
</tr>
<tr>
<td style="text-align: right;">1</td>
<td style="text-align: left;">Denver</td>
<td style="text-align: left;">Toyota</td>
<td style="text-align: right;">100000</td>
</tr>
<tr>
<td style="text-align: right;">2</td>
<td style="text-align: left;">Denver</td>
<td style="text-align: left;">Ford</td>
<td style="text-align: right;">80000</td>
</tr>
<tr>
<td style="text-align: right;">3</td>
<td style="text-align: left;">Los Angeles</td>
<td style="text-align: left;">Toyota</td>
<td style="text-align: right;">70000</td>
</tr>
</tbody>
</table>
</div>
<p>I would like to have one line per city and the Car Maker as a new column with the Qty related to that City:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: right;"></th>
<th style="text-align: left;">City</th>
<th style="text-align: left;">Car Maker</th>
<th style="text-align: left;">Ford</th>
<th style="text-align: right;">Toyota</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: right;">0</td>
<td style="text-align: left;">Los Angeles</td>
<td style="text-align: left;">Ford</td>
<td style="text-align: left;">50000</td>
<td style="text-align: right;">70000</td>
</tr>
<tr>
<td style="text-align: right;">1</td>
<td style="text-align: left;">Denver</td>
<td style="text-align: left;">Toyota</td>
<td style="text-align: left;">80000</td>
<td style="text-align: right;">100000</td>
</tr>
</tbody>
</table>
</div>
<p>Any hints on how to achieve that?</p>
<p>I've tried some options with transforming it on a dictionary and compressing on a function, but I am looking for a more pandas' like solution.</p>
| [
{
"answer_id": 74335628,
"author": "Dimava",
"author_id": 5734961,
"author_profile": "https://Stackoverflow.com/users/5734961",
"pm_score": 1,
"selected": false,
"text": "Constructor<T>"
},
{
"answer_id": 74348422,
"author": "redevill",
"author_id": 452928,
"author_profile": "https://Stackoverflow.com/users/452928",
"pm_score": 0,
"selected": false,
"text": "type Constructor<T> = new (...args: any) => T\nenum instantiableClassesEnum { class1, class2, class3 };\ntype enumValues = keyof typeof instantiableClassesEnum;\ntype logicStore<T> = Record<enumValues, \nConstructor<iGenericInterface<T>>>\n\nconst classMap: logicStore<any> = {\n class1: ExampleClass,\n class2: AnotherClass,\n class3: UnsupportedClass,\n};\n\n\nclass LogicFactory {\n static createLogic<T>(logicClass: enumValues): iGenericInterface<T> {\n return new classMap[logicClass]();\n }\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330721",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10033990/"
] |
74,330,739 | <p>I have this dataset-</p>
<pre><code> group sub_group value date
0 Animal Cats 12 today
1 Animal Dogs 32 today
2 Animal Goats 38 today
3 Animal Fish 1 today
4 Plant Tree 48 today
5 Object Car 55 today
6 Object Garage 61 today
7 Object Instrument 57 today
8 Animal Cats 44 yesterday
9 Animal Dogs 12 yesterday
10 Animal Goats 18 yesterday
11 Animal Fish 9 yesterday
12 Plant Tree 8 yesterday
13 Object Car 12 yesterday
14 Object Garage 37 yesterday
15 Object Instrument 77 yesterday
</code></pre>
<p>I want to have two series in a barchart. I want to have one series for today and I want to have another series for yesterday. Within each series, I want the bars to be split up by their sub-groups. For example, there would be one bar called "Animal - today" and it would sum up to 83 and, within that bar, there would be cats, dogs, etc.</p>
<p>I want to make a chart that is very similar to chart shown under "Bar charts with Long Format Data" on the <a href="https://plotly.com/python/bar-charts/" rel="nofollow noreferrer">docs</a>, except that I have two series.</p>
<p>This is what I tried-</p>
<pre><code>fig = make_subplots(rows = 1, cols = 1)
fig.add_trace(go.Bar(
y = df[df['date'] == 'today']['amount'],
x = df[df['date'] == 'today']['group'],
color = df[df['date'] == 'today']['sub_group']
),
row = 1, col = 1
)
fig.add_trace(go.Bar(
y = df[df['date'] == 'yesterday']['amount'],
x = df[df['date'] == 'yesterday']['group'],
color = df[df['date'] == 'yesterday']['sub_group']
),
row = 1, col = 1
)
fig.show()
</code></pre>
<p>I added a bounty because I want to be able to add the chart as a trace in my subplot.</p>
| [
{
"answer_id": 74333897,
"author": "r-beginners",
"author_id": 13107804,
"author_profile": "https://Stackoverflow.com/users/13107804",
"pm_score": 3,
"selected": true,
"text": "[0.25,1.25,2.25]"
},
{
"answer_id": 74354699,
"author": "hoa tran",
"author_id": 16405935,
"author_profile": "https://Stackoverflow.com/users/16405935",
"pm_score": -1,
"selected": false,
"text": "import plotly.graph_objects as go\nfrom plotly.subplots import make_subplots\nfig = make_subplots(rows = 1, cols = 2)\n\nfig.add_trace(go.Bar(x=[tuple(df[df['date'] == 'today']['group']),\n tuple(df[df['date'] == 'today']['sub_group'])],\n y=list(df[df['date'] == 'today']['value']),\n name='today'),\n row = 1, col = 1)\n\nfig.add_trace(go.Bar(x=[tuple(df[df['date'] == 'yesterday']['group']),\n tuple(df[df['date'] == 'yesterday']['sub_group'])],\n y=list(df[df['date'] == 'yesterday']['value']),\n name='yesterday'),\n row = 1, col = 2) \n \nfig.show()\n"
},
{
"answer_id": 74437437,
"author": "amance",
"author_id": 17142551,
"author_profile": "https://Stackoverflow.com/users/17142551",
"pm_score": -1,
"selected": false,
"text": "fig = make_subplots(rows = 1, cols = 1)\n\nfor sg in df['sub_group'].unique():\n fig.append_trace(go.Bar(x=[df['date'][df['sub_group']==sg], df['group'][df['sub_group']==sg]],\n y=df['value'][df['sub_group']==sg],\n name=sg,\n text=sg),\n col=1,\n row=1\n )\nfig.update_layout(barmode='stack')\n\nfig.show()\n"
},
{
"answer_id": 74493635,
"author": "TheCableGUI",
"author_id": 16614773,
"author_profile": "https://Stackoverflow.com/users/16614773",
"pm_score": 1,
"selected": false,
"text": "from dataclasses import dataclass\n\n@dataclass\nclass DataObject:\n value: str\n index: int\n\n@dataclass\nclass TwoDayData:\n\n today: DataObject\n yesterday: DataObject\n \n\ndata = DataObject(value=\"hello\", index=1)\ndata_yesterday = DataObject(value=\"Mom\", index=1)\n\ntwo_day_point = TwoDayData(today=data, yesterday=data_yesterday)\n\nprint(two_day_point.yesterday, two_day_point.today)\nprint(two_day_point.yesterday.index, two_day_point.today.index)\n\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330739",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11117255/"
] |
74,330,750 | <p>I need to build a query which performs subtraction on basis of client name here is my query I built for getting data</p>
<pre><code>SELECT invoice.client_name, (Sum(invoice.freight_rate)+Sum(invoice.total_basic_amount)+Sum(invoice.delivery_rate))
FROM invoice GROUP BY invoice.client_name
UNION SELECT client_name,(Sum(payments.payment_received))
FROM payments GROUP BY client_name
</code></pre>
<p>And here is what I get as an output</p>
<pre><code>client_name | Expr1001
John | 2500
John | 3630
MAc | 12000
MAc | 15300
</code></pre>
<p>What I need is</p>
<pre><code>client_name | Expr1001
John | 1130
MAc | 3300
</code></pre>
<p>Which is simple subtraction of both query.
I already asked this question before and I got some good responses but they aren't working and now nobody replies to it. Here is what I got from them.</p>
<pre><code>SELECT invoice.client_name, (Sum(invoice.freight_rate)+Sum(invoice.total_basic_amount)+Sum(invoice.delivery_rate)-Sum(payments.payment_received)) AS Expr1
FROM invoice, payments
WHERE (([invoice].[client_name]=[payments].[client_name]))
GROUP BY invoice.client_name;
</code></pre>
<p>This query returns some very strange output which is</p>
<pre><code>client_name | Expr1001
John | 2260
MAc | 18600
</code></pre>
<p>I'm Attaching the db file here is the link.</p>
<p><a href="https://drive.google.com/file/d/1dbxHzXDbfe8l1ZDN9ZxZo7Rs1UImhV8r/view?usp=share_link" rel="nofollow noreferrer">https://drive.google.com/file/d/1dbxHzXDbfe8l1ZDN9ZxZo7Rs1UImhV8r/view?usp=share_link</a></p>
| [
{
"answer_id": 74333897,
"author": "r-beginners",
"author_id": 13107804,
"author_profile": "https://Stackoverflow.com/users/13107804",
"pm_score": 3,
"selected": true,
"text": "[0.25,1.25,2.25]"
},
{
"answer_id": 74354699,
"author": "hoa tran",
"author_id": 16405935,
"author_profile": "https://Stackoverflow.com/users/16405935",
"pm_score": -1,
"selected": false,
"text": "import plotly.graph_objects as go\nfrom plotly.subplots import make_subplots\nfig = make_subplots(rows = 1, cols = 2)\n\nfig.add_trace(go.Bar(x=[tuple(df[df['date'] == 'today']['group']),\n tuple(df[df['date'] == 'today']['sub_group'])],\n y=list(df[df['date'] == 'today']['value']),\n name='today'),\n row = 1, col = 1)\n\nfig.add_trace(go.Bar(x=[tuple(df[df['date'] == 'yesterday']['group']),\n tuple(df[df['date'] == 'yesterday']['sub_group'])],\n y=list(df[df['date'] == 'yesterday']['value']),\n name='yesterday'),\n row = 1, col = 2) \n \nfig.show()\n"
},
{
"answer_id": 74437437,
"author": "amance",
"author_id": 17142551,
"author_profile": "https://Stackoverflow.com/users/17142551",
"pm_score": -1,
"selected": false,
"text": "fig = make_subplots(rows = 1, cols = 1)\n\nfor sg in df['sub_group'].unique():\n fig.append_trace(go.Bar(x=[df['date'][df['sub_group']==sg], df['group'][df['sub_group']==sg]],\n y=df['value'][df['sub_group']==sg],\n name=sg,\n text=sg),\n col=1,\n row=1\n )\nfig.update_layout(barmode='stack')\n\nfig.show()\n"
},
{
"answer_id": 74493635,
"author": "TheCableGUI",
"author_id": 16614773,
"author_profile": "https://Stackoverflow.com/users/16614773",
"pm_score": 1,
"selected": false,
"text": "from dataclasses import dataclass\n\n@dataclass\nclass DataObject:\n value: str\n index: int\n\n@dataclass\nclass TwoDayData:\n\n today: DataObject\n yesterday: DataObject\n \n\ndata = DataObject(value=\"hello\", index=1)\ndata_yesterday = DataObject(value=\"Mom\", index=1)\n\ntwo_day_point = TwoDayData(today=data, yesterday=data_yesterday)\n\nprint(two_day_point.yesterday, two_day_point.today)\nprint(two_day_point.yesterday.index, two_day_point.today.index)\n\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20269333/"
] |
74,330,776 | <p>For an assignment, I had to make a program to see if the user input contained any of the three letters: r, c or p. If it was wrong, I had to keep asking the user to retype the input until the user typed the correct answer.[<img src="https://i.stack.imgur.com/NKxxl.jpg" alt="Please ignore the code in the comments" />]</p>
<p>I tried using a do while loop to do the validation and I tested it myself, but instead of the invalid error message being returned only as long as the conditions were met, it returns it no matter what the user input was. The do statement ignored even the "valid inputs" and prints an invalid message regardless.[<img src="https://i.stack.imgur.com/5IYAW.jpg" alt="enter image description here" />]</p>
| [
{
"answer_id": 74330796,
"author": "HKTE",
"author_id": 12412262,
"author_profile": "https://Stackoverflow.com/users/12412262",
"pm_score": 1,
"selected": false,
"text": "while (input does not contain r, c or p) {\n // Show error, ask for new input\n}\n// Input is now valid\n"
},
{
"answer_id": 74330923,
"author": "Frederik Tobner",
"author_id": 20427794,
"author_profile": "https://Stackoverflow.com/users/20427794",
"pm_score": 3,
"selected": true,
"text": "and"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20427784/"
] |
74,330,792 | <p>I do have python data frame as below. I am trying to slice the data frame where ever "slice" column value is 10 and then find the min of "low" column between 10 and previous non 0 value column</p>
<pre><code> date open high low close slice
0 2022-05-19 09:15:00 33461.00 33624.90 33403.20 33412.45 0
1 2022-05-19 09:20:00 33413.10 33450.65 33393.90 33429.10 0
2 2022-05-19 09:25:00 33433.20 33490.05 33421.95 33460.25 0
3 2022-05-19 09:30:00 33460.55 33509.40 33419.05 33489.80 0
4 2022-05-19 09:35:00 33492.20 33506.40 33450.30 33454.70 20
5 2022-05-19 09:40:00 33452.25 33452.95 33396.40 33436.15 0
6 2022-05-19 09:45:00 33434.30 33454.80 33401.35 33439.05 0
7 2022-05-19 09:50:00 33438.30 33482.85 33423.50 33477.30 10
8 2022-05-19 09:55:00 33480.60 33535.85 33462.40 33523.65 30
9 2022-05-19 10:00:00 33527.65 33527.65 33484.10 33521.40 0
10 2022-05-19 10:05:00 33519.35 33599.25 33505.95 33530.55 0
11 2022-05-19 10:10:00 33527.50 33544.20 33496.60 33538.65 0
12 2022-05-19 10:15:00 33540.15 33565.85 33522.75 33563.25 0
13 2022-05-19 10:20:00 33563.50 33582.45 33525.95 33539.25 0
14 2022-05-19 10:25:00 33537.25 33537.50 33511.80 33516.35 20
15 2022-05-19 10:30:00 33518.00 33561.80 33513.60 33528.55 0
16 2022-05-19 10:35:00 33527.80 33551.00 33527.55 33550.50 10
17 2022-05-19 10:40:00 33551.50 33573.60 33525.85 33537.45 0
18 2022-05-19 10:45:00 33534.80 33563.10 33510.75 33555.95 0
19 2022-05-19 10:50:00 33555.55 33573.45 33540.45 33541.00 0
20 2022-05-19 10:55:00 33545.40 33586.80 33542.75 33586.80 10
</code></pre>
<pre><code>def buy_sell(data):
Time = []
SignalBuy = []
BuySL = []
BuyTgt = []
for i in range(len(data)):
if data["slice"][i] == 10:
Time.append(data["date"][i])
entry = data["open"][i]
sl = data["low"][i] - 10
SignalBuy.append(entry)
BuySL.append(sl)
BuyTgt.append(entry + (entry - sl) * 2)
return pd.Series([Time, SignalBuy, BuyTgt, BuySL])
SignalDemand = pd.DataFrame()
SignalDemand["Time"], SignalDemand["Entry Price"], SignalDemand["Target"], SignalDemand["Stop Loss"] = buy_sell(data)
print(SignalDemand.head())
</code></pre>
<p>This code gives me output as below.</p>
<pre><code> Time Entry Price Target Stop Loss
0 2022-05-19 09:50:00 33438.30 33487.90 33413.50
1 2022-05-19 10:35:00 33527.80 33548.30 33517.55
2 2022-05-19 10:55:00 33545.40 33570.70 33532.75
</code></pre>
<p>Expected output is</p>
<p>slice 1 - "Entry price" ( min of "open" or "close") ie 33434.30, "Stop loss" ( min of "low" - 10 ) ie ( 33396.40 - 10 = ) 33386.40</p>
<pre><code> date open high low close slice
4 2022-05-19 09:35:00 33492.20 33506.40 33450.30 33454.70 20
5 2022-05-19 09:40:00 33452.25 33452.95 33396.40 33436.15 0
6 2022-05-19 09:45:00 33434.30 33454.80 33401.35 33439.05 0
7 2022-05-19 09:50:00 33438.30 33482.85 33423.50 33477.30 10
</code></pre>
<p>Slice 2 - "Entry price" ( min of "open" or "close") ie 33516.35, "Stop loss" ( min of "low" - 10 ) ie ( 33511.80 - 10 = ) 33501.80</p>
<pre><code> date open high low close slice
14 2022-05-19 10:25:00 33537.25 33537.50 33511.80 33516.35 20
15 2022-05-19 10:30:00 33518.00 33561.80 33513.60 33528.55 0
16 2022-05-19 10:35:00 33527.80 33551.00 33527.55 33550.50 10
</code></pre>
<p>slice 3 - If previous value is same, i need to exclude the first row, ie row now 16 should be excluded.</p>
<p>"Entry price" ( min of "open" or "close") ie 33534.80, "Stop loss" ( min of "low" - 10 ) ie ( 33510.75 - 10 = ) 33500.75</p>
<pre><code> date open high low close slice
16 2022-05-19 10:35:00 33527.80 33551.00 33527.55 33550.50 10
17 2022-05-19 10:40:00 33551.50 33573.60 33525.85 33537.45 0
18 2022-05-19 10:45:00 33534.80 33563.10 33510.75 33555.95 0
19 2022-05-19 10:50:00 33555.55 33573.45 33540.45 33541.00 0
20 2022-05-19 10:55:00 33545.40 33586.80 33542.75 33586.80 10
</code></pre>
<p>Final output should be</p>
<pre><code> Time Entry Price Target Stop Loss
0 2022-05-19 09:50:00 33434.30 33530.10 33386.40
1 2022-05-19 10:35:00 33516.35 33545.45 33501.80
2 2022-05-19 10:55:00 33534.80 33602.90 33500.75
</code></pre>
| [
{
"answer_id": 74331806,
"author": "that_data_guy",
"author_id": 17129357,
"author_profile": "https://Stackoverflow.com/users/17129357",
"pm_score": 1,
"selected": false,
"text": "data['slice_min'] = None\ndata['slice_min_index_ref'] = None\n\ndef get_mins(data):\n\n min = None\n index_ref = None\n for i in range(len(data)):\n low = data.iloc[i]['low']\n if min == None: # Just setting up the first low\n min = low\n else:\n if low < min:\n #print('new low {}'.format(low))\n min = low # Setting new low\n index_ref = i+1 # in case you want to refer to the index. +1 because you used range\n if data.iloc[i]['slice'] > 0: # start over \n data.at[i+1, 'slice_min'] = min # Set the min value only one values where a slice isn't 0. \n data.at[i+1, 'slice_min_index_ref'] = index_ref\n index_ref = i+1\n min = low\n return data\n\n\ndf = get_mins(data)\n\ndf_slices = df[df['slice'] == 10] ## Just select the rows with slice 10\ndf_slices\n"
},
{
"answer_id": 74332073,
"author": "that_data_guy",
"author_id": 17129357,
"author_profile": "https://Stackoverflow.com/users/17129357",
"pm_score": 3,
"selected": true,
"text": "import pandas as pd\nimport sys\n\nif sys.version_info[0] < 3: \n from StringIO import StringIO\nelse:\n from io import StringIO\n\ntable = StringIO(\"\"\"date open high low close slice\n0 2022-05-19 09:15:00 33461.00 33624.90 33403.20 33412.45 0\n1 2022-05-19 09:20:00 33413.10 33450.65 33393.90 33429.10 0\n2 2022-05-19 09:25:00 33433.20 33490.05 33421.95 33460.25 0\n3 2022-05-19 09:30:00 33460.55 33509.40 33419.05 33489.80 0\n4 2022-05-19 09:35:00 33492.20 33506.40 33450.30 33454.70 20\n5 2022-05-19 09:40:00 33452.25 33452.95 33396.40 33436.15 0\n6 2022-05-19 09:45:00 33434.30 33454.80 33401.35 33439.05 0\n7 2022-05-19 09:50:00 33438.30 33482.85 33423.50 33477.30 10\n8 2022-05-19 09:55:00 33480.60 33535.85 33462.40 33523.65 30\n9 2022-05-19 10:00:00 33527.65 33527.65 33484.10 33521.40 0\n10 2022-05-19 10:05:00 33519.35 33599.25 33505.95 33530.55 0\n11 2022-05-19 10:10:00 33527.50 33544.20 33496.60 33538.65 0\n12 2022-05-19 10:15:00 33540.15 33565.85 33522.75 33563.25 0\n13 2022-05-19 10:20:00 33563.50 33582.45 33525.95 33539.25 0\n14 2022-05-19 10:25:00 33537.25 33537.50 33511.80 33516.35 20\n15 2022-05-19 10:30:00 33518.00 33561.80 33513.60 33528.55 0\n16 2022-05-19 10:35:00 33527.80 33551.00 33527.55 33550.50 10\n17 2022-05-19 10:40:00 33551.50 33573.60 33525.85 33537.45 0\n18 2022-05-19 10:45:00 33534.80 33563.10 33510.75 33555.95 0\n19 2022-05-19 10:50:00 33555.55 33573.45 33540.45 33541.00 0\n20 2022-05-19 10:55:00 33545.40 33586.80 33542.75 33586.80 10\"\"\")\n\n\ndata = pd.read_csv(table, sep='\\t')\n\ndef formatRow(rows):\n tmp_list = []\n for i in rows.index:\n time = rows['date'][i]\n entry = rows['open'][i]\n sl = rows['low'][i] - 10\n target = entry + (entry - sl) * 2 \n tmp_list.append([time, entry, target, sl, i])\n return tmp_list \n\n\ndata.columns = ['date', 'open', 'high', 'low', 'close', 'slice']\ndata['group_min'] = False\n\n# Filtering data by slice value\ndf = data[data['slice'] > 0]\nbuysell_list = []\nfor i in range(len(df)): #\n print('Processing: ', i)\n if df.iloc[i]['slice'] == 10:\n group = group + 1\n if i != 0:\n start_index = df.iloc[i-1].name\n end_index = df.iloc[i].name\n\n while data.loc[start_index]['slice'] == 10:\n print('previous slice > 0 is a 10!')\n start_index = start_index + 1\n\n if start_index < end_index: \n rows = data.loc[start_index:end_index]\n print('range {}-{}'.format(start_index, end_index))\n data.loc[rows.index, 'group'] = group\n min_row_index = rows['low'].idxmin()\n # In case there are two lows that are somehow equal\n min_rows = rows[rows['low'] == rows.loc[min_row_index]['low']] \n data.loc[min_rows.index, 'group_min'] = True\n\n rows_formatted = formatRow(min_rows)\n else:\n print('Somehow slices are next to each other')\n rows_formatted = formatRow(df.iloc[i])\n else:\n print('First non zero is a 10')\n # This isn't complete, you would need to calc from the index here to index 0\n rows_formatted = formatRow(df.iloc[i])\n for row_f in rows_formatted:\n buysell_list.append(row_f)\n\ndf2 = pd.DataFrame(buysell_list, columns=['Time', 'Entry Price', 'Target', 'Stop Loss', 'Orig_Index'])\ndf2\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10695736/"
] |
74,330,801 | <p><strong>Background:</strong> Trying to use ckeditor5 as a replacement for my homegrown editor in a non-invasive way - meaning without changing my edited content or its class definitions. Would like to have WYSIWYG in the editor. Using django_ckeditor_5 as a base with my own ckeditor5 build that includes ckedito5-inspector and my extraPlugins and custom CSS. This works nicely.</p>
<p><strong>Problem</strong>: When I load the following HTML into ClassicEditor (edited textarea.value):</p>
<pre><code><p>Text with inline image: <img class="someclass" src="/media/uploads/some.jpeg"></p>
</code></pre>
<p>in the editor view area, browser-inspection of the DOM shows:</p>
<pre><code>...
<p>Text with an inline image:
<span class="image-inline ck-widget someclass ck-widget_with-resizer" contenteditable="false">
<img src="/media/uploads/some.jpeg">
<div class="ck ck-reset_all ck-widget__resizer ck-hidden">
<div ...></div></span></p>
...
</code></pre>
<p>Because the "someclass" class has been removed from and moved to the enclosing class attributes, my stylesheets are not able to size this image element as they would appear before editing.</p>
<p>If, within the ckeditor5 view, I edit the element using the browser inspector 'by hand' and add back <code>class="someclass"</code> to the image, ckeditor5 displays my page as I'd expect it with "someclass" and with the editing frame/tools also there. Switching to source-editing and back shows the class="someclass" on the and keeps it there after switching back to document editing mode.</p>
<p>(To get all this, I enabled the GeneralHtmlSupport plugin in the editor config with all allowed per instructions, and that seems to work fine.) I also added the following simple plugin:</p>
<pre><code>export default class Extend extends Plugin {
static get pluginName() {
return 'Extend';
}
#updateSchema() {
const schema = this.editor.model.schema;
schema.extend('imageInline', {
allowAttributes: ['class']
});
}
init() {
const editor = this.editor;
this.#updateSchema();
}
}
</code></pre>
<p>to extend the imageInline model hoping that would make the Image plugin keep this class attribute.</p>
<p>This is the part where I need some direction on how to proceed - what should be added/modified in the Image Plugin or in my Extend plugin to keep the class attribute with the element while editing - basically to fulfill the WYSIWYG desire?</p>
| [
{
"answer_id": 74331806,
"author": "that_data_guy",
"author_id": 17129357,
"author_profile": "https://Stackoverflow.com/users/17129357",
"pm_score": 1,
"selected": false,
"text": "data['slice_min'] = None\ndata['slice_min_index_ref'] = None\n\ndef get_mins(data):\n\n min = None\n index_ref = None\n for i in range(len(data)):\n low = data.iloc[i]['low']\n if min == None: # Just setting up the first low\n min = low\n else:\n if low < min:\n #print('new low {}'.format(low))\n min = low # Setting new low\n index_ref = i+1 # in case you want to refer to the index. +1 because you used range\n if data.iloc[i]['slice'] > 0: # start over \n data.at[i+1, 'slice_min'] = min # Set the min value only one values where a slice isn't 0. \n data.at[i+1, 'slice_min_index_ref'] = index_ref\n index_ref = i+1\n min = low\n return data\n\n\ndf = get_mins(data)\n\ndf_slices = df[df['slice'] == 10] ## Just select the rows with slice 10\ndf_slices\n"
},
{
"answer_id": 74332073,
"author": "that_data_guy",
"author_id": 17129357,
"author_profile": "https://Stackoverflow.com/users/17129357",
"pm_score": 3,
"selected": true,
"text": "import pandas as pd\nimport sys\n\nif sys.version_info[0] < 3: \n from StringIO import StringIO\nelse:\n from io import StringIO\n\ntable = StringIO(\"\"\"date open high low close slice\n0 2022-05-19 09:15:00 33461.00 33624.90 33403.20 33412.45 0\n1 2022-05-19 09:20:00 33413.10 33450.65 33393.90 33429.10 0\n2 2022-05-19 09:25:00 33433.20 33490.05 33421.95 33460.25 0\n3 2022-05-19 09:30:00 33460.55 33509.40 33419.05 33489.80 0\n4 2022-05-19 09:35:00 33492.20 33506.40 33450.30 33454.70 20\n5 2022-05-19 09:40:00 33452.25 33452.95 33396.40 33436.15 0\n6 2022-05-19 09:45:00 33434.30 33454.80 33401.35 33439.05 0\n7 2022-05-19 09:50:00 33438.30 33482.85 33423.50 33477.30 10\n8 2022-05-19 09:55:00 33480.60 33535.85 33462.40 33523.65 30\n9 2022-05-19 10:00:00 33527.65 33527.65 33484.10 33521.40 0\n10 2022-05-19 10:05:00 33519.35 33599.25 33505.95 33530.55 0\n11 2022-05-19 10:10:00 33527.50 33544.20 33496.60 33538.65 0\n12 2022-05-19 10:15:00 33540.15 33565.85 33522.75 33563.25 0\n13 2022-05-19 10:20:00 33563.50 33582.45 33525.95 33539.25 0\n14 2022-05-19 10:25:00 33537.25 33537.50 33511.80 33516.35 20\n15 2022-05-19 10:30:00 33518.00 33561.80 33513.60 33528.55 0\n16 2022-05-19 10:35:00 33527.80 33551.00 33527.55 33550.50 10\n17 2022-05-19 10:40:00 33551.50 33573.60 33525.85 33537.45 0\n18 2022-05-19 10:45:00 33534.80 33563.10 33510.75 33555.95 0\n19 2022-05-19 10:50:00 33555.55 33573.45 33540.45 33541.00 0\n20 2022-05-19 10:55:00 33545.40 33586.80 33542.75 33586.80 10\"\"\")\n\n\ndata = pd.read_csv(table, sep='\\t')\n\ndef formatRow(rows):\n tmp_list = []\n for i in rows.index:\n time = rows['date'][i]\n entry = rows['open'][i]\n sl = rows['low'][i] - 10\n target = entry + (entry - sl) * 2 \n tmp_list.append([time, entry, target, sl, i])\n return tmp_list \n\n\ndata.columns = ['date', 'open', 'high', 'low', 'close', 'slice']\ndata['group_min'] = False\n\n# Filtering data by slice value\ndf = data[data['slice'] > 0]\nbuysell_list = []\nfor i in range(len(df)): #\n print('Processing: ', i)\n if df.iloc[i]['slice'] == 10:\n group = group + 1\n if i != 0:\n start_index = df.iloc[i-1].name\n end_index = df.iloc[i].name\n\n while data.loc[start_index]['slice'] == 10:\n print('previous slice > 0 is a 10!')\n start_index = start_index + 1\n\n if start_index < end_index: \n rows = data.loc[start_index:end_index]\n print('range {}-{}'.format(start_index, end_index))\n data.loc[rows.index, 'group'] = group\n min_row_index = rows['low'].idxmin()\n # In case there are two lows that are somehow equal\n min_rows = rows[rows['low'] == rows.loc[min_row_index]['low']] \n data.loc[min_rows.index, 'group_min'] = True\n\n rows_formatted = formatRow(min_rows)\n else:\n print('Somehow slices are next to each other')\n rows_formatted = formatRow(df.iloc[i])\n else:\n print('First non zero is a 10')\n # This isn't complete, you would need to calc from the index here to index 0\n rows_formatted = formatRow(df.iloc[i])\n for row_f in rows_formatted:\n buysell_list.append(row_f)\n\ndf2 = pd.DataFrame(buysell_list, columns=['Time', 'Entry Price', 'Target', 'Stop Loss', 'Orig_Index'])\ndf2\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330801",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20427640/"
] |
74,330,865 | <p>In a Spring Boot app, I am using Hibernate and 2 tables is created properly. However, I also need to insert data one of these tables and for this purpose I thought I should use Flyway.</p>
<p>Then I just added insert clauses to the Flyway and use the following parameters for Hibernate and Flyway in application.properties:v</p>
<pre><code>spring.jpa.properties.hibernate.dialect=org.hibernate.dialect.MySQL5InnoDBDialect
spring.jpa.hibernate.ddl-auto= update # also tried none
spring.flyway.url=jdbc:mysql://localhost:3306
spring.flyway.schemas=demo-db
spring.flyway.user=root
spring.flyway.password=******
</code></pre>
<p>I have not used Flyway for initializing database and I am not sure if I can use Flyway with Hibernate as I mentioned above. Or, should I disable Hibernate table creation and create another migration script for table creation?</p>
| [
{
"answer_id": 74337685,
"author": "Duc Vo",
"author_id": 9543676,
"author_profile": "https://Stackoverflow.com/users/9543676",
"pm_score": 2,
"selected": false,
"text": "insert data"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330865",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20416459/"
] |
74,330,877 | <p>i have an simple rest api that have a h2 database so my plan is when i run multiple instances of the same app they will have different in memory databases.Now i want to syncronize these databases beetwen them.I thought kafka to be a good solution , so for example when i get an POST for instance with port 8080 , i should post also for all other instances. Now my app acts as a producer/consumer at the same time and i do not know why only one instance receive the message.
The code:</p>
<pre><code> @EnableKafka
@Configuration
public class KafkaProducerConfigForDepartment {
@Value(value = "${kafka.bootstrapAddress}")
private String bootstrapAddress;
@Bean
public ProducerFactory<String, MessageEventForDepartment> producerFactoryForDepartment() {
Map<String, Object> configProps = new HashMap<>();
configProps.put(ProducerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress);
configProps.put(ProducerConfig.KEY_SERIALIZER_CLASS_CONFIG, StringSerializer.class);
configProps.put(ProducerConfig.VALUE_SERIALIZER_CLASS_CONFIG, JsonSerializer.class);
return new DefaultKafkaProducerFactory<>(configProps);
}
@Bean
public KafkaTemplate<String, MessageEventForDepartment> kafkaTemplate() {
return new KafkaTemplate<>(producerFactoryForDepartment());
}
}
</code></pre>
<pre><code> @Configuration
public class KafkaTopicConfig {
@Value(value = "${kafka.bootstrapAddress}")
private String bootstrapAddress;
@Bean
public ConsumerFactory<String, MessageEventForDepartment> consumerFactoryForDepartments() {
Map<String, Object> props = new HashMap<>();
props.put(JsonDeserializer.TRUSTED_PACKAGES, "*");
props.put(ConsumerConfig.BOOTSTRAP_SERVERS_CONFIG, bootstrapAddress);
props.put(ConsumerConfig.GROUP_ID_CONFIG, "groupId");
return new DefaultKafkaConsumerFactory<>(props, new StringDeserializer(), new JsonDeserializer<>(MessageEventForDepartment.class));
}
@Bean
public NewTopic topic1() {
return TopicBuilder.name("topic12")
.partitions(10)
.replicas(10)
.build();
}
@Bean
public ConcurrentKafkaListenerContainerFactory<String, MessageEventForDepartment>
kafkaListenerContainerFactoryForDepartments() {
ConcurrentKafkaListenerContainerFactory<String, MessageEventForDepartment> factory =
new ConcurrentKafkaListenerContainerFactory<>();
factory.setConsumerFactory(consumerFactoryForDepartments());
return factory;
}
}
</code></pre>
<pre><code> @Component
@Slf4j
public class DepartmentKafkaService {
@Autowired
private DepartmentService departmentService;
@KafkaListener(topics = "topic12" , groupId = "groupId",containerFactory = "kafkaListenerContainerFactoryForDepartments")
public void listenGroupFoo(MessageEventForDepartment message) {
log.info(message.toString());
}
}
</code></pre>
<p>Why is this happening ? or maybe my approach is not very good , what are your thoughts ,guys?</p>
| [
{
"answer_id": 74331229,
"author": "Paweł Szymczyk",
"author_id": 4203773,
"author_profile": "https://Stackoverflow.com/users/4203773",
"pm_score": 2,
"selected": false,
"text": "@RestController\nclass MessageEventForDepartmentController {\n \n @Autowired\n KafkaTemplate<String, MessageEventForDepartment> kafkaTemplate;\n\n @PostMapping(path = \"/departments\", consumes = \"application/json\")\n @ResponseStatus(HttpStatus.ACCEPTED)\n void(@RequestBody MessageEventForDepartment event) {\n kafkaTemplate.send(\"topic-a\", event.getId(), event);\n }\n}\n"
},
{
"answer_id": 74331360,
"author": "cmcnealy",
"author_id": 19473610,
"author_profile": "https://Stackoverflow.com/users/19473610",
"pm_score": 2,
"selected": true,
"text": "ConsumerConfig.GROUP_ID_CONFIG"
},
{
"answer_id": 74331490,
"author": "Jeevananthan S",
"author_id": 14350340,
"author_profile": "https://Stackoverflow.com/users/14350340",
"pm_score": 0,
"selected": false,
"text": "IN-MEMEORY"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17063310/"
] |
74,330,881 | <p>Good evening!
I have a task: implement any function to sort array and then check if two arrays(the input and the output) are the same(meaning that the values are the same). Values in array are random, so there my be something like [5,2,5,5,6,-1,3,0,84305]</p>
<p>I was thinking about checking if elements are in both arrays, then if yes - assign them to some rubbish value(I was hoping to go for NULL, but apparently it works only in Python), and then if any array has something that is not our rubbish value return false, but I am not sure about this variant, maybe someone has better ideas? That would be very helpful</p>
| [
{
"answer_id": 74331229,
"author": "Paweł Szymczyk",
"author_id": 4203773,
"author_profile": "https://Stackoverflow.com/users/4203773",
"pm_score": 2,
"selected": false,
"text": "@RestController\nclass MessageEventForDepartmentController {\n \n @Autowired\n KafkaTemplate<String, MessageEventForDepartment> kafkaTemplate;\n\n @PostMapping(path = \"/departments\", consumes = \"application/json\")\n @ResponseStatus(HttpStatus.ACCEPTED)\n void(@RequestBody MessageEventForDepartment event) {\n kafkaTemplate.send(\"topic-a\", event.getId(), event);\n }\n}\n"
},
{
"answer_id": 74331360,
"author": "cmcnealy",
"author_id": 19473610,
"author_profile": "https://Stackoverflow.com/users/19473610",
"pm_score": 2,
"selected": true,
"text": "ConsumerConfig.GROUP_ID_CONFIG"
},
{
"answer_id": 74331490,
"author": "Jeevananthan S",
"author_id": 14350340,
"author_profile": "https://Stackoverflow.com/users/14350340",
"pm_score": 0,
"selected": false,
"text": "IN-MEMEORY"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20427956/"
] |
74,330,920 | <p>Parsed Message
{
"date": "2022-02-04",
"customerID": 123,
"customerInfo": {
"id": 123,
"lastname": "Smith",
"firstname": "David",
"email": "testing@email.com",
},
"currency": "EUR"
}</p>
<p>I would like to remove the customerInfo section so the JSON looks like.
{
"date": "2022-02-04",
"customerID": 123,
"currency": "EUR"
}</p>
<p>How would one do this in the LogicApp. I tried remove property but could not get that working. Any suggestions would be appreciated.</p>
| [
{
"answer_id": 74332046,
"author": "Mocas",
"author_id": 2410199,
"author_profile": "https://Stackoverflow.com/users/2410199",
"pm_score": 0,
"selected": false,
"text": "\"Initialize_variable\": {\n \"type\": \"InitializeVariable\",\n \"inputs\": {\n \"variables\": [ {\n \"name\": \"sensitisedMessage\",\n \"type\": \"Object\",\n \"value\": { \"date\": @message['date'], \"customerID\": @message['customerID'], \"currency\": \"@message['currency']\" }\n } ]\n },\n \"runAfter\": {}\n }\n"
},
{
"answer_id": 74342172,
"author": "RithwikBojja",
"author_id": 17623802,
"author_profile": "https://Stackoverflow.com/users/17623802",
"pm_score": 3,
"selected": true,
"text": "removeProperty(variables('emo'),'customerInfo')"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74330920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7581658/"
] |
74,331,014 | <p>I have a simple problem, for which I have to find how many numbers in a specified interval where the digits of one number are all different. I wrote the code to find these numbers but can't count how many outputs?
for example, 244 is not acceptable as two digits are similar, 243 is acceptable because all digits are different. I just want to count how many outputs I have.</p>
<pre><code>list = []
for i in range(234,567):
list.append (i)
for n in list:
x=[int(a) for a in str(n)]
if x[0] != x[1] !=x[2] and x[0]!= x[2]:
strings = [str(number) for number in x]
a_string="".join (strings)
finalrz=int(a_string)
print (finalrz)
</code></pre>
| [
{
"answer_id": 74331104,
"author": "OliDev",
"author_id": 17194494,
"author_profile": "https://Stackoverflow.com/users/17194494",
"pm_score": 2,
"selected": true,
"text": "#NEW CODE\ncount = 0\n#END OF NEW CODE\nlist = []\nfor i in range(234,567):\n list.append (i)\nfor n in list:\n x=[int(a) for a in str(n)]\n if x[0] != x[1] !=x[2] and x[0]!= x[2]:\n strings = [str(number) for number in x]\n a_string=\"\".join (strings)\n finalrz=int(a_string)\n print (finalrz)\n #NEW CODE\n count = count + 1\n print(count, \"outputs\")\n"
},
{
"answer_id": 74331738,
"author": "user3435121",
"author_id": 3435121,
"author_profile": "https://Stackoverflow.com/users/3435121",
"pm_score": 0,
"selected": false,
"text": "counter = 0\nfor i in range( 234, 567):\n letters = str(i) # convert integer to letters\n seen = [] # list of previously seen letters\n for letter in letters:\n if letter in seen: break # check if already seen\n seen.append( letter) # update list of seen letters\n else:\n #print( letters)\n counter += 1\nprint( counter, \"numbers without duplicate digits.\")\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20428091/"
] |
74,331,061 | <p>I have a .txt file which contains an invitation template, where certain values have to be replaced by strings in a given vector.</p>
<p>The text looks like this:</p>
<p>Dear ,''''we are happy to invite you to our annual showroom . The event starts on at in , .''We look forward to your visist.'</p>
<p>Now I need to write a function with the template text and the vector which replaces these placeholders with given values and return the new invitation. the result should look like this</p>
<pre><code>Dear Mr. George Clooney , we are happy to invite you to our annual showroom 2022. The event starts on 01.04 at 10.00h in Headquarter Office, Mainroad 26, 4711 Ytown.
</code></pre>
<p>As of now i opened the textfile and initiated the function and declared. The head of the function looks like this:</p>
<pre><code>createLetter <- function(fieldsdata, templateText){
x <- c(fieldsdata)
}
</code></pre>
| [
{
"answer_id": 74331104,
"author": "OliDev",
"author_id": 17194494,
"author_profile": "https://Stackoverflow.com/users/17194494",
"pm_score": 2,
"selected": true,
"text": "#NEW CODE\ncount = 0\n#END OF NEW CODE\nlist = []\nfor i in range(234,567):\n list.append (i)\nfor n in list:\n x=[int(a) for a in str(n)]\n if x[0] != x[1] !=x[2] and x[0]!= x[2]:\n strings = [str(number) for number in x]\n a_string=\"\".join (strings)\n finalrz=int(a_string)\n print (finalrz)\n #NEW CODE\n count = count + 1\n print(count, \"outputs\")\n"
},
{
"answer_id": 74331738,
"author": "user3435121",
"author_id": 3435121,
"author_profile": "https://Stackoverflow.com/users/3435121",
"pm_score": 0,
"selected": false,
"text": "counter = 0\nfor i in range( 234, 567):\n letters = str(i) # convert integer to letters\n seen = [] # list of previously seen letters\n for letter in letters:\n if letter in seen: break # check if already seen\n seen.append( letter) # update list of seen letters\n else:\n #print( letters)\n counter += 1\nprint( counter, \"numbers without duplicate digits.\")\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19407340/"
] |
74,331,074 | <p>Is it possible to create a formula in Excel or Google Sheets that compares two cells with text values and returns the number of words that match.</p>
<p>Example:
Cell A2 = This is an apple
Cell B2 = This was a rotten apple
Value returned: 2</p>
| [
{
"answer_id": 74331257,
"author": "Nabnub",
"author_id": 9538684,
"author_profile": "https://Stackoverflow.com/users/9538684",
"pm_score": 1,
"selected": false,
"text": "= query(query(transpose(split(A2 & \" \" & B2, \" \")),\n \"Select count(Col1) group by Col1 label count(Col1) '' \"),\n \"Select count(Col1) where Col1 != 1 group by Col1 label count(Col1) 'Total matching' \")\n"
},
{
"answer_id": 74334515,
"author": "mark fitzpatrick",
"author_id": 4617121,
"author_profile": "https://Stackoverflow.com/users/4617121",
"pm_score": 3,
"selected": true,
"text": "=SUM( --ISNUMBER( MATCH( UNIQUE( TEXTSPLIT( A2, \" \"), 1 ),\n UNIQUE( TEXTSPLIT( B2, \" \"), 1 ),\n 0 ) ) )\n"
},
{
"answer_id": 74335140,
"author": "Ping",
"author_id": 20288037,
"author_profile": "https://Stackoverflow.com/users/20288037",
"pm_score": 2,
"selected": false,
"text": "// sample_1:\n=ArrayFormula(SUM(INT(\n LAMBDA(COL,ROW,\n REGEXREPLACE(SEQUENCE(COUNTA(ROW))&\"\",\"[0-9]+\",COL)=ROW\n )(SPLIT($A$2,\" \"),TRANSPOSE(SPLIT($B$2,\" \")))\n)))\n\n// sample_2:\n=ArrayFormula(SUM(INT(\n LAMBDA(COL,ROW,\n REGEXREPLACE(SEQUENCE(COUNTA(ROW))&\"\",\"[0-9]+\",COL)=ROW\n )(UNIQUE(SPLIT($A$2,\" \")),TRANSPOSE(UNIQUE(SPLIT($B$2,\" \"))))\n)))\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4574597/"
] |
74,331,089 | <p>Here I have a code containing a simple class printing something. I want to multithread it.</p>
<pre><code>import threading
import time
import random
class Useless:
def __init__(self, numb):
self.numb = numb
def printing(self):
time.sleep(random.uniform(0.05, 0.09))
print(f'number {self.numb} is being printed God knows what for...')
def main_loop(self):
for _ in range(5):
self.printing()
obj_1 = Useless(1)
obj_2 = Useless(2)
proc_1 = threading.Thread(target=obj_1.main_loop, args=())
proc_2 = threading.Thread(target=obj_2.main_loop, args=())
proc_1.start()
proc_2.start()
</code></pre>
<p><strong>The number of threads is arbitrary, so I can create more proc_. This is a key requirement!</strong></p>
<p>But sometimes I receive a weird printing results like this:</p>
<pre><code>number 2 is being printed God knows what for...number 1 is being printed God knows what for...
number 1 is being printed God knows what for...
number 2 is being printed God knows what for...
number 1 is being printed God knows what for...
number 2 is being printed God knows what for...
number 1 is being printed God knows what for...
number 2 is being printed God knows what for...
number 1 is being printed God knows what for...
number 2 is being printed God knows what for...
Process finished with exit code 0
</code></pre>
<p>You see sometimes some printed messages mix together and printed in one line but I would like them to be separate.</p>
<p>Probably subprocess pipe can help with it but I don't know how to implement it here. Probably Asyncio can solve it. So I want threads to be executed simultaneously (almost simultaneously within one core) but to have printed messages separated.</p>
| [
{
"answer_id": 74331157,
"author": "sudden_appearance",
"author_id": 14882395,
"author_profile": "https://Stackoverflow.com/users/14882395",
"pm_score": 1,
"selected": false,
"text": "def printing(self):\n print(f'number {self.numb} is being printed God knows what for...\\n', end='')\n"
},
{
"answer_id": 74356877,
"author": "danangjoyoo",
"author_id": 17292547,
"author_profile": "https://Stackoverflow.com/users/17292547",
"pm_score": 0,
"selected": false,
"text": "flush"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20426821/"
] |
74,331,109 | <p>The string fileString contains multiple lines of characters, like this:</p>
<pre><code>1234a6b4ba21ba54f6bde411930b0b1ec6df
3124a6b4ba21ba54f6bde411930b0b1ef248
2134a6b4ba21ba54f6bde411900b89f7dcf3
4123a6b4ba21ba54f6bde411920bbf835b60
</code></pre>
<p>I'd like to move the first 4 characters of every line to the end of its respective line, like this:</p>
<pre><code>a6b4ba21ba54f6bde411930b0b1ec6df1234
a6b4ba21ba54f6bde411930b0b1ef2483124
a6b4ba21ba54f6bde411900b89f7dcf32134
a6b4ba21ba54f6bde411920bbf835b604123
</code></pre>
<p>I saw <a href="https://stackoverflow.com/questions/10841868/move-n-characters-from-front-of-string-to-the-end">another post</a> with a proposed solution, but that code moves the first 4 characters of the string to the end of the string, which is not what I'm trying to do.</p>
<p>So with this code:</p>
<pre><code>var num = 4
fileString = fileString.substring(num) + fileString.substring(0, num)
</code></pre>
<p>The initial string stated above turns into this:</p>
<pre><code>a6b4ba21ba54f6bde411930b0b1ec6df
3124a6b4ba21ba54f6bde411930b0b1ef248
2134a6b4ba21ba54f6bde411900b89f7dcf3
4123a6b4ba21ba54f6bde411920bbf835b60
1234
</code></pre>
| [
{
"answer_id": 74331157,
"author": "sudden_appearance",
"author_id": 14882395,
"author_profile": "https://Stackoverflow.com/users/14882395",
"pm_score": 1,
"selected": false,
"text": "def printing(self):\n print(f'number {self.numb} is being printed God knows what for...\\n', end='')\n"
},
{
"answer_id": 74356877,
"author": "danangjoyoo",
"author_id": 17292547,
"author_profile": "https://Stackoverflow.com/users/17292547",
"pm_score": 0,
"selected": false,
"text": "flush"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,331,139 | <p>For this problem, I have a separate txt file which contains a list of values down below:</p>
<pre><code>Years+1900 Populationx106
0 1650
10 1750
20 1860
30 2070
40 2300
50 2560
60 3040
70 3710
80 4450
90 5280
100 6080
110 6870
</code></pre>
<p>For the problem I'm working on, I'm supposed to obtain that file and path name to then use to do calculations on with some functions I created. I have finished the functions I need to do, however I'm having an issue running it because I believe when doing the function it reads the "Years+1900 Populationx106" part first instead of the numbers below it.</p>
<p>Here's the code for my functions:</p>
<p>Input: year
Output: estimate of population for that year</p>
<pre><code>def pop(year):
return 1436.53*((1.01395)**year)
</code></pre>
<pre><code># Input: data
# Return: the average error as per equation 18.
def error(data):
error=0
for i in data:
error +=(abs(i[1]-pop(i[0]))/i[1])
return 100*error/12
</code></pre>
<p>Here is the code I created to retrieve the data from my separate txt file:</p>
<pre><code>def get_data(path,name):
with open("Assignment7/pop.txt", "r") as path:
path = open("Assignment7/pop.txt", "r")
name = path.read()
return name
</code></pre>
<p>The error I'm receiving is for the part below. It is an index error and it says the string index is out of range. I believe this is because it is reading the first part of the data in the pop.txt, how can I remove te first line in the pop.txt so that it only reads the numerical values I have?</p>
<pre><code> error +=(abs(i[1]-pop(i[0]))/i[1])
</code></pre>
<p>I have tried changing the index values already, however it still says that my string index is out of range.</p>
| [
{
"answer_id": 74331157,
"author": "sudden_appearance",
"author_id": 14882395,
"author_profile": "https://Stackoverflow.com/users/14882395",
"pm_score": 1,
"selected": false,
"text": "def printing(self):\n print(f'number {self.numb} is being printed God knows what for...\\n', end='')\n"
},
{
"answer_id": 74356877,
"author": "danangjoyoo",
"author_id": 17292547,
"author_profile": "https://Stackoverflow.com/users/17292547",
"pm_score": 0,
"selected": false,
"text": "flush"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20427936/"
] |
74,331,141 | <pre><code>name = input(enter name)
age = input(age)
print(“My name is print(name). I’m print(age) years old.”)
</code></pre>
<p>Nobbie experiment.
Beginner level task.
And the above query came to my mind.</p>
| [
{
"answer_id": 74331167,
"author": "Keshav V.",
"author_id": 18131236,
"author_profile": "https://Stackoverflow.com/users/18131236",
"pm_score": 0,
"selected": false,
"text": "name = input('Enter your name ')\nage = input ('Enter your age ')\n\nprint(f'My name is {name}. I\\'m {age} years old.')\n"
},
{
"answer_id": 74331203,
"author": "Laura Uzcategui",
"author_id": 4483470,
"author_profile": "https://Stackoverflow.com/users/4483470",
"pm_score": 0,
"selected": false,
"text": "print(f\"My name is {name}. I'm {age} years old\")\nMy name is laura. I'm 18 years old\n"
},
{
"answer_id": 74331207,
"author": "GRIGORII",
"author_id": 19649783,
"author_profile": "https://Stackoverflow.com/users/19649783",
"pm_score": 0,
"selected": false,
"text": "name = input('Enter your name ')\nage = input ('Enter your age ')\nprint('some text' + name + 'also some text') \n"
},
{
"answer_id": 74331228,
"author": "Dawar",
"author_id": 14431186,
"author_profile": "https://Stackoverflow.com/users/14431186",
"pm_score": 0,
"selected": false,
"text": "def name_and_age(name, age):\n return f\"My name is {name} and I'am {age} years old\"\nprint(name_and_age('Max', 35))\n#output: My name is Max and I'am 35 years old\n"
},
{
"answer_id": 74331252,
"author": "Paul Wang",
"author_id": 1781986,
"author_profile": "https://Stackoverflow.com/users/1781986",
"pm_score": 1,
"selected": false,
"text": "name = input(\"enter name: \")\nage = input(\"age: \")\nprint(f\"My name is {name}. I am {age} years old\")\n"
},
{
"answer_id": 74331255,
"author": "Semil Shah",
"author_id": 15610755,
"author_profile": "https://Stackoverflow.com/users/15610755",
"pm_score": 0,
"selected": false,
"text": "name = input('Enter your name ')\nage = input ('Enter your age ')\n\nprint('My name is {}. I\\'m {} years old.').format(name,age)\n"
},
{
"answer_id": 74331271,
"author": "user3435121",
"author_id": 3435121,
"author_profile": "https://Stackoverflow.com/users/3435121",
"pm_score": 0,
"selected": false,
"text": "name = input(\"enter name\")\nage = input(\"age\")\n\nprint( f\"My name is {name}. I'm {age} years old.\")\n"
},
{
"answer_id": 74331327,
"author": "Richard Plester",
"author_id": 15474105,
"author_profile": "https://Stackoverflow.com/users/15474105",
"pm_score": 1,
"selected": false,
"text": "name = input(\"enter name \")\nage = input(\"age \")\n\nprint(\"My name is\", name, \"I’m\", age, \"years old.\")\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331141",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20428158/"
] |
74,331,146 | <p>I'm having trouble getting hyperlinks for tennis matches listed on a webpage, how do I go about fixing the code below so that it can obtain it through print?</p>
<p>To note: I'm applying this code in Visual Studio 2022.</p>
<pre><code>import requests
from bs4 import BeautifulSoup
response = requests.get("https://www.betexplorer.com/results/tennis/?year=2022&month=11&day=02")
webpage = response.content
soup = BeautifulSoup(webpage, "html.parser")
print(soup.findAll('a href'))
</code></pre>
<p>Edit: solution found in the comments</p>
<pre><code>import requests
from bs4 import BeautifulSoup
r = requests.get('https://www.betexplorer.com/results/tennis/?year=2022&month=11&day=02')
soup = BeautifulSoup(r.text, "html.parser")
print(set('https://www.betexplorer.com'+a.get('href') for a in soup.select('a[href^="/tennis"]:has(strong)')))
</code></pre>
| [
{
"answer_id": 74331167,
"author": "Keshav V.",
"author_id": 18131236,
"author_profile": "https://Stackoverflow.com/users/18131236",
"pm_score": 0,
"selected": false,
"text": "name = input('Enter your name ')\nage = input ('Enter your age ')\n\nprint(f'My name is {name}. I\\'m {age} years old.')\n"
},
{
"answer_id": 74331203,
"author": "Laura Uzcategui",
"author_id": 4483470,
"author_profile": "https://Stackoverflow.com/users/4483470",
"pm_score": 0,
"selected": false,
"text": "print(f\"My name is {name}. I'm {age} years old\")\nMy name is laura. I'm 18 years old\n"
},
{
"answer_id": 74331207,
"author": "GRIGORII",
"author_id": 19649783,
"author_profile": "https://Stackoverflow.com/users/19649783",
"pm_score": 0,
"selected": false,
"text": "name = input('Enter your name ')\nage = input ('Enter your age ')\nprint('some text' + name + 'also some text') \n"
},
{
"answer_id": 74331228,
"author": "Dawar",
"author_id": 14431186,
"author_profile": "https://Stackoverflow.com/users/14431186",
"pm_score": 0,
"selected": false,
"text": "def name_and_age(name, age):\n return f\"My name is {name} and I'am {age} years old\"\nprint(name_and_age('Max', 35))\n#output: My name is Max and I'am 35 years old\n"
},
{
"answer_id": 74331252,
"author": "Paul Wang",
"author_id": 1781986,
"author_profile": "https://Stackoverflow.com/users/1781986",
"pm_score": 1,
"selected": false,
"text": "name = input(\"enter name: \")\nage = input(\"age: \")\nprint(f\"My name is {name}. I am {age} years old\")\n"
},
{
"answer_id": 74331255,
"author": "Semil Shah",
"author_id": 15610755,
"author_profile": "https://Stackoverflow.com/users/15610755",
"pm_score": 0,
"selected": false,
"text": "name = input('Enter your name ')\nage = input ('Enter your age ')\n\nprint('My name is {}. I\\'m {} years old.').format(name,age)\n"
},
{
"answer_id": 74331271,
"author": "user3435121",
"author_id": 3435121,
"author_profile": "https://Stackoverflow.com/users/3435121",
"pm_score": 0,
"selected": false,
"text": "name = input(\"enter name\")\nage = input(\"age\")\n\nprint( f\"My name is {name}. I'm {age} years old.\")\n"
},
{
"answer_id": 74331327,
"author": "Richard Plester",
"author_id": 15474105,
"author_profile": "https://Stackoverflow.com/users/15474105",
"pm_score": 1,
"selected": false,
"text": "name = input(\"enter name \")\nage = input(\"age \")\n\nprint(\"My name is\", name, \"I’m\", age, \"years old.\")\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331146",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14745788/"
] |
74,331,147 | <pre><code>const [userInfo, setUserInfo] = useState([]);
const handleUserInfo = (id) => {
fetch(`https://602e7c2c4410730017c50b9d.mockapi.io/users/${id}`)
.then(res => res.json())
.then(data => setUserInfo(data))
}
</code></pre>
<pre><code><input type="text" defaultValue={userInfo?.profile?.firstName + userInfo?.profile?.lastName} className="form-control bg-light" id="exampleInputName" aria-describedby="name"></input>
</code></pre>
<p>I am expecting to see both firstname and last name in that input field with a gap between first name and last name. But I see NAN because I tried to add firstname and lastname using plus (+)
The NAN doesn't show up if I only want to see the first name when the default value is defaultValue={userInfo?.profile?.firstName}</p>
| [
{
"answer_id": 74331167,
"author": "Keshav V.",
"author_id": 18131236,
"author_profile": "https://Stackoverflow.com/users/18131236",
"pm_score": 0,
"selected": false,
"text": "name = input('Enter your name ')\nage = input ('Enter your age ')\n\nprint(f'My name is {name}. I\\'m {age} years old.')\n"
},
{
"answer_id": 74331203,
"author": "Laura Uzcategui",
"author_id": 4483470,
"author_profile": "https://Stackoverflow.com/users/4483470",
"pm_score": 0,
"selected": false,
"text": "print(f\"My name is {name}. I'm {age} years old\")\nMy name is laura. I'm 18 years old\n"
},
{
"answer_id": 74331207,
"author": "GRIGORII",
"author_id": 19649783,
"author_profile": "https://Stackoverflow.com/users/19649783",
"pm_score": 0,
"selected": false,
"text": "name = input('Enter your name ')\nage = input ('Enter your age ')\nprint('some text' + name + 'also some text') \n"
},
{
"answer_id": 74331228,
"author": "Dawar",
"author_id": 14431186,
"author_profile": "https://Stackoverflow.com/users/14431186",
"pm_score": 0,
"selected": false,
"text": "def name_and_age(name, age):\n return f\"My name is {name} and I'am {age} years old\"\nprint(name_and_age('Max', 35))\n#output: My name is Max and I'am 35 years old\n"
},
{
"answer_id": 74331252,
"author": "Paul Wang",
"author_id": 1781986,
"author_profile": "https://Stackoverflow.com/users/1781986",
"pm_score": 1,
"selected": false,
"text": "name = input(\"enter name: \")\nage = input(\"age: \")\nprint(f\"My name is {name}. I am {age} years old\")\n"
},
{
"answer_id": 74331255,
"author": "Semil Shah",
"author_id": 15610755,
"author_profile": "https://Stackoverflow.com/users/15610755",
"pm_score": 0,
"selected": false,
"text": "name = input('Enter your name ')\nage = input ('Enter your age ')\n\nprint('My name is {}. I\\'m {} years old.').format(name,age)\n"
},
{
"answer_id": 74331271,
"author": "user3435121",
"author_id": 3435121,
"author_profile": "https://Stackoverflow.com/users/3435121",
"pm_score": 0,
"selected": false,
"text": "name = input(\"enter name\")\nage = input(\"age\")\n\nprint( f\"My name is {name}. I'm {age} years old.\")\n"
},
{
"answer_id": 74331327,
"author": "Richard Plester",
"author_id": 15474105,
"author_profile": "https://Stackoverflow.com/users/15474105",
"pm_score": 1,
"selected": false,
"text": "name = input(\"enter name \")\nage = input(\"age \")\n\nprint(\"My name is\", name, \"I’m\", age, \"years old.\")\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18401394/"
] |
74,331,175 | <p>so basically I have created the bins and the have the means of each bin, having these two columns in a dataframe. Now I am plotting these two columns, but I want the exact number as x lable instead of bins. I am considering renaming each bin by its mid-point. please look at the pictures. The first one is my current plot and the second is the plot I want to acheive.</p>
<p>my current plot:
<a href="https://i.stack.imgur.com/tfeLR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tfeLR.png" alt="enter image description here" /></a>
what I want to have:
<a href="https://i.stack.imgur.com/JjyMD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JjyMD.png" alt="enter image description here" /></a>
my data frame is like this:
<a href="https://i.stack.imgur.com/Pl9JB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Pl9JB.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74331167,
"author": "Keshav V.",
"author_id": 18131236,
"author_profile": "https://Stackoverflow.com/users/18131236",
"pm_score": 0,
"selected": false,
"text": "name = input('Enter your name ')\nage = input ('Enter your age ')\n\nprint(f'My name is {name}. I\\'m {age} years old.')\n"
},
{
"answer_id": 74331203,
"author": "Laura Uzcategui",
"author_id": 4483470,
"author_profile": "https://Stackoverflow.com/users/4483470",
"pm_score": 0,
"selected": false,
"text": "print(f\"My name is {name}. I'm {age} years old\")\nMy name is laura. I'm 18 years old\n"
},
{
"answer_id": 74331207,
"author": "GRIGORII",
"author_id": 19649783,
"author_profile": "https://Stackoverflow.com/users/19649783",
"pm_score": 0,
"selected": false,
"text": "name = input('Enter your name ')\nage = input ('Enter your age ')\nprint('some text' + name + 'also some text') \n"
},
{
"answer_id": 74331228,
"author": "Dawar",
"author_id": 14431186,
"author_profile": "https://Stackoverflow.com/users/14431186",
"pm_score": 0,
"selected": false,
"text": "def name_and_age(name, age):\n return f\"My name is {name} and I'am {age} years old\"\nprint(name_and_age('Max', 35))\n#output: My name is Max and I'am 35 years old\n"
},
{
"answer_id": 74331252,
"author": "Paul Wang",
"author_id": 1781986,
"author_profile": "https://Stackoverflow.com/users/1781986",
"pm_score": 1,
"selected": false,
"text": "name = input(\"enter name: \")\nage = input(\"age: \")\nprint(f\"My name is {name}. I am {age} years old\")\n"
},
{
"answer_id": 74331255,
"author": "Semil Shah",
"author_id": 15610755,
"author_profile": "https://Stackoverflow.com/users/15610755",
"pm_score": 0,
"selected": false,
"text": "name = input('Enter your name ')\nage = input ('Enter your age ')\n\nprint('My name is {}. I\\'m {} years old.').format(name,age)\n"
},
{
"answer_id": 74331271,
"author": "user3435121",
"author_id": 3435121,
"author_profile": "https://Stackoverflow.com/users/3435121",
"pm_score": 0,
"selected": false,
"text": "name = input(\"enter name\")\nage = input(\"age\")\n\nprint( f\"My name is {name}. I'm {age} years old.\")\n"
},
{
"answer_id": 74331327,
"author": "Richard Plester",
"author_id": 15474105,
"author_profile": "https://Stackoverflow.com/users/15474105",
"pm_score": 1,
"selected": false,
"text": "name = input(\"enter name \")\nage = input(\"age \")\n\nprint(\"My name is\", name, \"I’m\", age, \"years old.\")\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20318210/"
] |
74,331,197 | <p>c-programming output printf()</p>
<p>Hi guys,</p>
<p>I have a question to following code:
`</p>
<pre><code>#include <stdio.h>
int main() {
printf("%f\n", (8/5)/2);
printf("%f\n", (float) 5/2);
printf("%f\n", (8/5)/2);
return 0;
}
</code></pre>
<p>Line 3 and five are the same. But output isn´t it. Why is that? I have no declaration of variables just <code>printf()</code>
Output:</p>
<pre><code>0.000000
2.500000
2.500000
</code></pre>
<p>But if I invert line 4 and 5 then output is same to line 3 as it should be.</p>
<pre><code>#include <stdio.h>
int main() {
printf("%f\n", (8/5)/2);
printf("%f\n", (8/5)/2);
printf("%f\n", (float) 5/2);
return 0;
}
</code></pre>
<pre><code>0.000000
0.000000
2.500000
</code></pre>
<p>Can anybody explain the output of this code?</p>
| [
{
"answer_id": 74331276,
"author": "Chris",
"author_id": 15261315,
"author_profile": "https://Stackoverflow.com/users/15261315",
"pm_score": 1,
"selected": false,
"text": "int"
},
{
"answer_id": 74337830,
"author": "Jonathan Leffler",
"author_id": 15168,
"author_profile": "https://Stackoverflow.com/users/15168",
"pm_score": 3,
"selected": true,
"text": "printf(\"%f %d\\n\", 355.0/113.0, 355/113);\nprintf(\"%f %d\\n\", 355/113, 355.0/113.0);\n"
},
{
"answer_id": 74337892,
"author": "0___________",
"author_id": 6110094,
"author_profile": "https://Stackoverflow.com/users/6110094",
"pm_score": 1,
"selected": false,
"text": "printf"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20428108/"
] |
74,331,208 | <p>I am trying to parse song titles from a website, but can't figure out how to grab the specific div that has them. I've tried about a dozen different methods but always get back an empty list.</p>
<p>If you go to the url and inspect one of the youtube videos there, you will find a div with a class of <code>single-post-oembed-youtube-wrapper</code>. That element also contains the artist and title of the song.</p>
<p>This is my first time attempting to scrape data from a webpage, can someone help me out?</p>
<pre><code>import json
from bs4 import BeautifulSoup
from selenium import webdriver
from selenium.webdriver.support.ui import WebDriverWait
from selenium.webdriver.support import expected_conditions as EC
from selenium.webdriver.common.by import By
from selenium.common.exceptions import TimeoutException
import pprint
from webdriver_manager.chrome import ChromeDriverManager
import sys
html = None
url = 'https://ultimateclassicrock.com/best-rock-songs-2018/'
browser = webdriver.Chrome(executable_path="/usr/bin/chromedriver")
browser.get(url)
soup = BeautifulSoup(browser.page_source, 'html.parser')
divs = soup.find_all("div", {"class":"single-post-oembed-youtube-wrapper'"})
#all_songs = browser.find_elements(By.CLASS_NAME, 'single-post-oembed-youtube-wrapper')
#html = all_songs.get_attribute("outerHTML")
pprint.pprint(divs)
browser.close()
</code></pre>
| [
{
"answer_id": 74331450,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 2,
"selected": false,
"text": "soup = BeautifulSoup(browser.page_source, 'html.parser')\ntitles = soup.find_all(\".single-post-oembed-youtube-wrapper+div p strong\")\n"
},
{
"answer_id": 74331466,
"author": "petezurich",
"author_id": 7117003,
"author_profile": "https://Stackoverflow.com/users/7117003",
"pm_score": 3,
"selected": true,
"text": "import requests\nfrom bs4 import BeautifulSoup\nimport pandas\n\nurl = \"https://ultimateclassicrock.com/best-rock-songs-2018/\"\nres = requests.get(url)\nsoup = BeautifulSoup(res.content)\n\nresults = []\nfor elem in soup.find_all(\"strong\"):\n if \",\" in elem.text:\n results.append(elem.text.split(\", \"))\n\ndf = pd.DataFrame(results, columns=[\"artist\", \"song\"])\ndf\n"
},
{
"answer_id": 74331533,
"author": "Fazlul",
"author_id": 12848411,
"author_profile": "https://Stackoverflow.com/users/12848411",
"pm_score": 2,
"selected": false,
"text": "API"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331208",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2176186/"
] |
74,331,210 | <p>I have a simple custom function on Google Apps script, returning two lines of text:</p>
<pre><code>function RPE_MAX() {
const values = ['one', 'two']
const first = values[0]
const second = values[1]
const formatted = `${first} \n ${second}`
return formatted
}
</code></pre>
<p>How can I return the first line in one font color and the second one in another font color?</p>
| [
{
"answer_id": 74331642,
"author": "Cooper",
"author_id": 7215091,
"author_profile": "https://Stackoverflow.com/users/7215091",
"pm_score": 1,
"selected": false,
"text": "function RPE_MAX() {\n const red = SpreadsheetApp.newTextStyle().setForegroundColor(\"red\").build();\n const blu = SpreadsheetApp.newTextStyle().setForegroundColor(\"blue\").build();\n const ss = SpreadsheetApp.getActive();\n const sh = ss.getSheetByName(\"Sheet0\");\n const values =[['one', 'two','three','four'],['five','six','seven','eight']]; \n sh.getRange(\"A1\").setValue(`${values[0].join(' ')}\\n${values[1].join(' ')}`);\n SpreadsheetApp.flush();\n const txt = sh.getRange(\"A1\").getDisplayValue();\n const v = SpreadsheetApp.newRichTextValue()\n .setText(txt)\n .setTextStyle(0,txt.indexOf('\\n'),red)\n .setTextStyle(txt.indexOf('\\n')+1, txt.length,blu)\n .build();\n sh.getRange('A1').setRichTextValue(v)\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3259922/"
] |
74,331,222 | <p>I am generating tables in latex. But the text's font is way too small compared to the main text size, which is 12 pt.
Here is the Latex code</p>
<pre><code>\begin{table}[htp]
\renewcommand{\arraystretch}{2}
\large
\resizebox{1\textwidth}{!}{%
\begin{tabular}{|c|c|c|c|c|c|}
\hline
\textbf{Air pollutant} & \textbf{Detection limit} & \textbf{Concentration range to expect
by EPA} & \textbf{Concentration range in Bristol, UK} & \textbf{Range in Bristol, UK} \\[3ex]
\hline
\textbf{Ozone (O$_{3}$) } & \textbf{10 ppb} & \textbf{0--150 ppb }
& \textbf{0--100 ppb} & \\[3ex] \hline
\textbf{Nitrogen dioxide} & \textbf{10 ppb} & \textbf{0--50 ppb}
& \textbf{20--55 ppb} & \\[3ex] \hline
\textbf{PM$_{2.5}$} & \textbf{5 } & \textbf{0--40 \SI{}
{\micro\gram/m^3}} & \textbf{0--40 \SI{}{\micro\gram/m^3} }
& \\[3ex] \hline
\textbf{PM$_{10}$} & \textbf{10} & \textbf{0--100 \SI{}
{\micro\gram/m^3} } & \textbf{0--100 \SI{}{\micro\gram/m^3}}
& \\[3ex] \hline
\textbf{Temperature range} & ----- & ------ & ----
-- & \textbf{3--$ 21 ^\circ C $} \\[3ex]
\hline
\textbf{Humidity } & ----- & ----- & -----
-- & \textbf{50\%--75\% } \\[3ex] \hline
\end{tabular}%
}
\end{table}
</code></pre>
<p>and here is a screenshot of part of PDF to compare the main text and table font</p>
<p><a href="https://i.stack.imgur.com/FhO5a.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FhO5a.jpg" alt="enter image description here" /></a></p>
<p>I have this issue for several tables, so any help would be greatly appreciated.</p>
| [
{
"answer_id": 74331642,
"author": "Cooper",
"author_id": 7215091,
"author_profile": "https://Stackoverflow.com/users/7215091",
"pm_score": 1,
"selected": false,
"text": "function RPE_MAX() {\n const red = SpreadsheetApp.newTextStyle().setForegroundColor(\"red\").build();\n const blu = SpreadsheetApp.newTextStyle().setForegroundColor(\"blue\").build();\n const ss = SpreadsheetApp.getActive();\n const sh = ss.getSheetByName(\"Sheet0\");\n const values =[['one', 'two','three','four'],['five','six','seven','eight']]; \n sh.getRange(\"A1\").setValue(`${values[0].join(' ')}\\n${values[1].join(' ')}`);\n SpreadsheetApp.flush();\n const txt = sh.getRange(\"A1\").getDisplayValue();\n const v = SpreadsheetApp.newRichTextValue()\n .setText(txt)\n .setTextStyle(0,txt.indexOf('\\n'),red)\n .setTextStyle(txt.indexOf('\\n')+1, txt.length,blu)\n .build();\n sh.getRange('A1').setRichTextValue(v)\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9783140/"
] |
74,331,235 | <p>I am facing while opening my android app. I tried with below steps but I am getting this below error. Kindly help me. my Android app builds fine but when I run it I get the below error. It references a class which is not something that I use. Any ideas?</p>
<pre><code>com.qa.android E/unknown:NativeModuleInitError: Failed to create NativeModule "UIManager"
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/facebook/react/uimanager/UIImplementationProvider;
at com.swmansion.reanimated.ReanimatedPackage.createUIManager(ReanimatedPackage.java:73)
at com.swmansion.reanimated.ReanimatedPackage.getModule(ReanimatedPackage.java:31)
at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:161)
at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:149)
at com.facebook.react.bridge.ModuleHolder.create(ModuleHolder.java:191)
at com.facebook.react.bridge.ModuleHolder.getModule(ModuleHolder.java:156)
at com.facebook.react.bridge.NativeModuleRegistry.getModule(NativeModuleRegistry.java:170)
at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:493)
at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:469)
at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:89)
at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:47)
at com.facebook.react.ReactInstanceManager.attachRootViewToInstance(ReactInstanceManager.java:1241)
at com.facebook.react.ReactInstanceManager.setupReactContext(ReactInstanceManager.java:1183)
at com.facebook.react.ReactInstanceManager.access$1600(ReactInstanceManager.java:135)
at com.facebook.react.ReactInstanceManager$5$2.run(ReactInstanceManager.java:1137)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:223)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
at java.lang.Thread.run(Thread.java:923)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.react.uimanager.UIImplementationProvider" on path: DexPathList[[zip file "/data/app/~~7b9OfUY0mLPaHfZSYMHhqQ==/com.qa.android-4UNR7KbO89A4FSaahSgIvw==/base.apk"],nativeLibraryDirectories=[/data/app/~~7b9OfUY0mLPaHfZSYMHhqQ==/com.qa.android-4UNR7KbO89A4FSaahSgIvw==/lib/arm64, /data/app/~~7b9OfUY0mLPaHfZSYMHhqQ==/com.qa.android-4UNR7KbO89A4FSaahSgIvw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.swmansion.reanimated.ReanimatedPackage.createUIManager(ReanimatedPackage.java:73)
at com.swmansion.reanimated.ReanimatedPackage.getModule(ReanimatedPackage.java:31)
at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:161)
at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:149)
at com.facebook.react.bridge.ModuleHolder.create(ModuleHolder.java:191)
at com.facebook.react.bridge.ModuleHolder.getModule(ModuleHolder.java:156)
at com.facebook.react.bridge.NativeModuleRegistry.getModule(NativeModuleRegistry.java:170)
at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:493)
at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:469)
at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:89)
at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:47)
at com.facebook.react.ReactInstanceManager.attachRootViewToInstance(ReactInstanceManager.java:1241)
at com.facebook.react.ReactInstanceManager.setupReactContext(ReactInstanceManager.java:1183)
at com.facebook.react.ReactInstanceManager.access$1600(ReactInstanceManager.java:135)
at com.facebook.react.ReactInstanceManager$5$2.run(ReactInstanceManager.java:1137)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:223)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
at java.lang.Thread.run(Thread.java:923)
--------- beginning of crash
2022-11-06 01:30:47.279 20077-20173/com.qa.android E/AndroidRuntime: FATAL EXCEPTION: mqt_native_modules
Process: com.qa.android, PID: 20077
java.lang.NoClassDefFoundError: Failed resolution of: Lcom/facebook/react/uimanager/UIImplementationProvider;
at com.swmansion.reanimated.ReanimatedPackage.createUIManager(ReanimatedPackage.java:73)
at com.swmansion.reanimated.ReanimatedPackage.getModule(ReanimatedPackage.java:31)
at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:161)
at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:149)
at com.facebook.react.bridge.ModuleHolder.create(ModuleHolder.java:191)
at com.facebook.react.bridge.ModuleHolder.getModule(ModuleHolder.java:156)
at com.facebook.react.bridge.NativeModuleRegistry.getModule(NativeModuleRegistry.java:170)
at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:493)
at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:469)
at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:89)
at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:47)
at com.facebook.react.ReactInstanceManager.attachRootViewToInstance(ReactInstanceManager.java:1241)
at com.facebook.react.ReactInstanceManager.setupReactContext(ReactInstanceManager.java:1183)
at com.facebook.react.ReactInstanceManager.access$1600(ReactInstanceManager.java:135)
at com.facebook.react.ReactInstanceManager$5$2.run(ReactInstanceManager.java:1137)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:223)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
at java.lang.Thread.run(Thread.java:923)
Caused by: java.lang.ClassNotFoundException: Didn't find class "com.facebook.react.uimanager.UIImplementationProvider" on path: DexPathList[[zip file "/data/app/~~7b9OfUY0mLPaHfZSYMHhqQ==/com.qa.android-4UNR7KbO89A4FSaahSgIvw==/base.apk"],nativeLibraryDirectories=[/data/app/~~7b9OfUY0mLPaHfZSYMHhqQ==/com.qa.android-4UNR7KbO89A4FSaahSgIvw==/lib/arm64, /data/app/~~7b9OfUY0mLPaHfZSYMHhqQ==/com.qa.android-4UNR7KbO89A4FSaahSgIvw==/base.apk!/lib/arm64-v8a, /system/lib64, /system_ext/lib64]]
at dalvik.system.BaseDexClassLoader.findClass(BaseDexClassLoader.java:207)
at java.lang.ClassLoader.loadClass(ClassLoader.java:379)
at java.lang.ClassLoader.loadClass(ClassLoader.java:312)
at com.swmansion.reanimated.ReanimatedPackage.createUIManager(ReanimatedPackage.java:73)
at com.swmansion.reanimated.ReanimatedPackage.getModule(ReanimatedPackage.java:31)
at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:161)
at com.facebook.react.TurboReactPackage$ModuleHolderProvider.get(TurboReactPackage.java:149)
at com.facebook.react.bridge.ModuleHolder.create(ModuleHolder.java:191)
at com.facebook.react.bridge.ModuleHolder.getModule(ModuleHolder.java:156)
at com.facebook.react.bridge.NativeModuleRegistry.getModule(NativeModuleRegistry.java:170)
at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:493)
at com.facebook.react.bridge.CatalystInstanceImpl.getNativeModule(CatalystInstanceImpl.java:469)
at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:89)
at com.facebook.react.uimanager.UIManagerHelper.getUIManager(UIManagerHelper.java:47)
at com.facebook.react.ReactInstanceManager.attachRootViewToInstance(ReactInstanceManager.java:1241)
at com.facebook.react.ReactInstanceManager.setupReactContext(ReactInstanceManager.java:1183)
at com.facebook.react.ReactInstanceManager.access$1600(ReactInstanceManager.java:135)
at com.facebook.react.ReactInstanceManager$5$2.run(ReactInstanceManager.java:1137)
at android.os.Handler.handleCallback(Handler.java:938)
at android.os.Handler.dispatchMessage(Handler.java:99)
at com.facebook.react.bridge.queue.MessageQueueThreadHandler.dispatchMessage(MessageQueueThreadHandler.java:27)
at android.os.Looper.loop(Looper.java:223)
at com.facebook.react.bridge.queue.MessageQueueThreadImpl$4.run(MessageQueueThreadImpl.java:228)
at java.lang.Thread.run(Thread.java:923)
</code></pre>
<p>I implemented in this below way</p>
<pre><code> if (enableHermes) {
implementation("com.facebook.react:hermes-engine:+") {
exclude group:'com.facebook.fbjni'
}
// def hermesPath = "../../node_modules/hermes-engine/android/";
// debugImplementation files(hermesPath + "hermes-debug.aar")
// releaseImplementation files(hermesPath + "hermes-release.aar")
} else {
implementation jscFlavor
}
</code></pre>
<p>I am getting crash on startup . Please kindly help me,.</p>
| [
{
"answer_id": 74334272,
"author": "Ammar Halbouni",
"author_id": 10028543,
"author_profile": "https://Stackoverflow.com/users/10028543",
"pm_score": 3,
"selected": false,
"text": "android/buld.gradle"
},
{
"answer_id": 74343794,
"author": "Dumi Jay",
"author_id": 1897885,
"author_profile": "https://Stackoverflow.com/users/1897885",
"pm_score": 0,
"selected": false,
"text": "import groovy.json.JsonSlurper\n\ndef REACT_NATIVE_VERSION = {\n def inputFile = new File(\"$rootDir/../package.json\")\n def packageJson = new JsonSlurper().parseText(inputFile.text)\n\n return packageJson[\"dependencies\"][\"react-native\"]\n}()\n\nallprojects {\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n }\n}\n"
},
{
"answer_id": 74369974,
"author": "Muhammad Asif",
"author_id": 11782684,
"author_profile": "https://Stackoverflow.com/users/11782684",
"pm_score": 0,
"selected": false,
"text": "def REACT_NATIVE_VERSION = new File(['node', '--print',\"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version\"].execute(null, rootDir).text.trim());\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331235",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17916341/"
] |
74,331,244 | <p>I have some doubts about my insert method. it is compiling, but with no result. I presume that it is containing some coding errors. Can you help me resolving this? Thanks in advance.</p>
<pre><code>private:
T* elements;
int capacity;
int nbElements;
template <class T>
void TableDynamic<T>::insert(const T& element, int index)
{
int *temp = new int[capacity] ;
for(int i =0; i<nbElements; i++)
{
temp[i] = element;
}
delete[] elements;
int *elem = new int[capacite];
}
</code></pre>
| [
{
"answer_id": 74334272,
"author": "Ammar Halbouni",
"author_id": 10028543,
"author_profile": "https://Stackoverflow.com/users/10028543",
"pm_score": 3,
"selected": false,
"text": "android/buld.gradle"
},
{
"answer_id": 74343794,
"author": "Dumi Jay",
"author_id": 1897885,
"author_profile": "https://Stackoverflow.com/users/1897885",
"pm_score": 0,
"selected": false,
"text": "import groovy.json.JsonSlurper\n\ndef REACT_NATIVE_VERSION = {\n def inputFile = new File(\"$rootDir/../package.json\")\n def packageJson = new JsonSlurper().parseText(inputFile.text)\n\n return packageJson[\"dependencies\"][\"react-native\"]\n}()\n\nallprojects {\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n }\n}\n"
},
{
"answer_id": 74369974,
"author": "Muhammad Asif",
"author_id": 11782684,
"author_profile": "https://Stackoverflow.com/users/11782684",
"pm_score": 0,
"selected": false,
"text": "def REACT_NATIVE_VERSION = new File(['node', '--print',\"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version\"].execute(null, rootDir).text.trim());\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20342311/"
] |
74,331,287 | <p>I am trying to make a function in C that takes the contents of a file and returns the contents as a string. I got it to works except for one odd detail. This is the current code:</p>
<pre><code>char *getFileContents(const char *filePath) {
if (filePath == NULL) return NULL;
char buffer[1000];
char character;
int count = 0;
FILE *f = fopen(filePath, "r");
while (character != EOF) {
count++;
character = fgetc(f);
printf("%c\n", character);
}
count--;
fclose(f);
FILE *F = fopen(filePath, "r");
char *str = (char*) malloc ( sizeof(char) * (count + 1 ) );
char *line = fgets(buffer, 1000, F);
while (line != NULL) {
strcat(str, line);
line = fgets(buffer, 1000, F);
}
fclose(F);
return str;
}
</code></pre>
<p>In the first while loop, I added a printf statement for error checking that I do not need anymore. The function works fine with the printf statement but whenever I comment it out or remove it I get a segmentation fault. I've used gdb to debug and try to find the issue.
I can step through the whole function but the moment it reaches the <code>return str</code> at the end I get a segmentation fault. I'm not sure why I'm experiencing this problem.</p>
| [
{
"answer_id": 74334272,
"author": "Ammar Halbouni",
"author_id": 10028543,
"author_profile": "https://Stackoverflow.com/users/10028543",
"pm_score": 3,
"selected": false,
"text": "android/buld.gradle"
},
{
"answer_id": 74343794,
"author": "Dumi Jay",
"author_id": 1897885,
"author_profile": "https://Stackoverflow.com/users/1897885",
"pm_score": 0,
"selected": false,
"text": "import groovy.json.JsonSlurper\n\ndef REACT_NATIVE_VERSION = {\n def inputFile = new File(\"$rootDir/../package.json\")\n def packageJson = new JsonSlurper().parseText(inputFile.text)\n\n return packageJson[\"dependencies\"][\"react-native\"]\n}()\n\nallprojects {\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n }\n}\n"
},
{
"answer_id": 74369974,
"author": "Muhammad Asif",
"author_id": 11782684,
"author_profile": "https://Stackoverflow.com/users/11782684",
"pm_score": 0,
"selected": false,
"text": "def REACT_NATIVE_VERSION = new File(['node', '--print',\"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version\"].execute(null, rootDir).text.trim());\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331287",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20269580/"
] |
74,331,290 | <p>I am starting my journey with Cypess and I have met the small problem. I need to check if div element has text which is one of two.</p>
<pre><code> getText(text1, text2) {
cy.get([data-cy=default-login-failed-label]).should('have.any.text', (text1, text2))
}
</code></pre>
<p>Could someone help me please? :)</p>
| [
{
"answer_id": 74334272,
"author": "Ammar Halbouni",
"author_id": 10028543,
"author_profile": "https://Stackoverflow.com/users/10028543",
"pm_score": 3,
"selected": false,
"text": "android/buld.gradle"
},
{
"answer_id": 74343794,
"author": "Dumi Jay",
"author_id": 1897885,
"author_profile": "https://Stackoverflow.com/users/1897885",
"pm_score": 0,
"selected": false,
"text": "import groovy.json.JsonSlurper\n\ndef REACT_NATIVE_VERSION = {\n def inputFile = new File(\"$rootDir/../package.json\")\n def packageJson = new JsonSlurper().parseText(inputFile.text)\n\n return packageJson[\"dependencies\"][\"react-native\"]\n}()\n\nallprojects {\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n }\n}\n"
},
{
"answer_id": 74369974,
"author": "Muhammad Asif",
"author_id": 11782684,
"author_profile": "https://Stackoverflow.com/users/11782684",
"pm_score": 0,
"selected": false,
"text": "def REACT_NATIVE_VERSION = new File(['node', '--print',\"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version\"].execute(null, rootDir).text.trim());\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331290",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20428256/"
] |
74,331,331 | <p>I'm a beginner in flutter, I want to display a text on the far left and a button on the far right in a container, here is my code:</p>
<pre><code>Container(
width: double.infinity,
margin: const EdgeInsets.all(10),
padding: const EdgeInsets.all(8.0),
),
child: Row(
mainAxisAlignment: MainAxisAlignment.center,
children: [
Text('TEXT'),
IconButton(
onPressed: () {},
icon: Icon(
Icons.price_change_outlined,
color: Colors.blue,
))
],
),
),
</code></pre>
| [
{
"answer_id": 74334272,
"author": "Ammar Halbouni",
"author_id": 10028543,
"author_profile": "https://Stackoverflow.com/users/10028543",
"pm_score": 3,
"selected": false,
"text": "android/buld.gradle"
},
{
"answer_id": 74343794,
"author": "Dumi Jay",
"author_id": 1897885,
"author_profile": "https://Stackoverflow.com/users/1897885",
"pm_score": 0,
"selected": false,
"text": "import groovy.json.JsonSlurper\n\ndef REACT_NATIVE_VERSION = {\n def inputFile = new File(\"$rootDir/../package.json\")\n def packageJson = new JsonSlurper().parseText(inputFile.text)\n\n return packageJson[\"dependencies\"][\"react-native\"]\n}()\n\nallprojects {\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n }\n}\n"
},
{
"answer_id": 74369974,
"author": "Muhammad Asif",
"author_id": 11782684,
"author_profile": "https://Stackoverflow.com/users/11782684",
"pm_score": 0,
"selected": false,
"text": "def REACT_NATIVE_VERSION = new File(['node', '--print',\"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version\"].execute(null, rootDir).text.trim());\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20349488/"
] |
74,331,342 | <p>I have a script that adds a class "notransition" to the body on the page load (it removes it after set time). I want to remove background-color and color transition from every element, but it doesn't seem to work.</p>
<pre><code>$(window).on("load", function(){
$("body").addClass("notransition");
setTimeout(function(){
$("body").removeClass("notransition");
}, 1000);
});
</code></pre>
<pre><code>.notransition *{
transition-property: background-color, color !important;
transition-duration: 0s !important;
}
</code></pre>
<p>However, I can remove every transition with code like this:</p>
<pre><code>.notransition *{
transition: none !important;
}
</code></pre>
<p>Is it possible to apply it only to color and background-color properties?</p>
| [
{
"answer_id": 74334272,
"author": "Ammar Halbouni",
"author_id": 10028543,
"author_profile": "https://Stackoverflow.com/users/10028543",
"pm_score": 3,
"selected": false,
"text": "android/buld.gradle"
},
{
"answer_id": 74343794,
"author": "Dumi Jay",
"author_id": 1897885,
"author_profile": "https://Stackoverflow.com/users/1897885",
"pm_score": 0,
"selected": false,
"text": "import groovy.json.JsonSlurper\n\ndef REACT_NATIVE_VERSION = {\n def inputFile = new File(\"$rootDir/../package.json\")\n def packageJson = new JsonSlurper().parseText(inputFile.text)\n\n return packageJson[\"dependencies\"][\"react-native\"]\n}()\n\nallprojects {\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n }\n}\n"
},
{
"answer_id": 74369974,
"author": "Muhammad Asif",
"author_id": 11782684,
"author_profile": "https://Stackoverflow.com/users/11782684",
"pm_score": 0,
"selected": false,
"text": "def REACT_NATIVE_VERSION = new File(['node', '--print',\"JSON.parse(require('fs').readFileSync(require.resolve('react-native/package.json'), 'utf-8')).version\"].execute(null, rootDir).text.trim());\n configurations.all {\n resolutionStrategy {\n force \"com.facebook.react:react-native:\" + REACT_NATIVE_VERSION\n }\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331342",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19647863/"
] |
74,331,362 | <p>I am defining few ADTs representing logic formulas. They all use i.e. <code>And</code> constructor, but then differ in what other constructors they use. I'd like to reuse case class definitions with a hope that I could reuse some code later. I'd like to do something like:</p>
<pre class="lang-scala prettyprint-override"><code>sealed trait Formula
sealed trait PositiveFormula
case class Not(sub) extends Formula
case class And(left, right) extends Formula, PositiveFormula
</code></pre>
<p>But this doesn't work for any single type for <code>sub</code>, <code>left</code> and <code>right</code>.
So I'd like to say:</p>
<pre class="lang-scala prettyprint-override"><code>sealed trait Formula
sealed trait PositiveFormula
case class Not[A](sub : A)
Not[Formula] extends Formula
case class And(left : A, right : A)
And[Formula] extends Formula
And[PositiveFormula] extends PositiveFormula
</code></pre>
<p>A few questions:</p>
<ol>
<li>Is anything like above possible and I just dont know syntax?</li>
<li>Is there other solution to "reuse case class constructors" problem?</li>
<li>What's your opinion on how useful this would be if possible?</li>
</ol>
| [
{
"answer_id": 74332539,
"author": "ELinda",
"author_id": 7484259,
"author_profile": "https://Stackoverflow.com/users/7484259",
"pm_score": 0,
"selected": false,
"text": "PositiveFormula"
},
{
"answer_id": 74337112,
"author": "Dmytro Mitin",
"author_id": 5249621,
"author_profile": "https://Stackoverflow.com/users/5249621",
"pm_score": 3,
"selected": true,
"text": "Not[T] extends T"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331362",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10497132/"
] |
74,331,366 | <p>`</p>
<pre><code>import re
import os
from flask import Flask, request, render_template, current_app
from flask_mail import Mail, Message
app = Flask(__name__)
app.config['MAIL_DEFAULT_SENDER'] = os.environ['MAIL_DEFAULT_SENDER']
app.config["MAIL_PASSWORD"] = os.environ["MAIL_PASSWORD"]
app.config["MAIL_PORT"] = 587
app.config["MAIL_SERVER"] = "smtp.gmail.com"
app.config["MAIL_USE_TLS"] = True
app.config["MAIL_USERNAME"] = os.environ["MAIL_USERNAME"]
mail = Mail(app)
SPORTS = [
"Basketball",
"Soccer",
"Ultimate Frisbee"
]
@app.route("/")
def index():
return render_template("index.html", sports=SPORTS)
@app.route("/register", methods=["POST"])
def register():
name = request.form.get("name")
email = request.form.get("email")
sport = request.form.get("sport")
if not name or not email or sport not in SPORTS:
return render_template("failure.html")
message = Message("You are registered!", recipients=[email])
mail.send(email)
return render_template("success.html")
</code></pre>
<p>`</p>
<pre><code>$ python -m flask run
Traceback (most recent call last):
File "<frozen runpy>", line 198, in _run_module_as_main
File "<frozen runpy>", line 88, in _run_code
File "C:\Python311\Lib\site-packages\flask\__main__.py", line 3, in <module>
main()
File "C:\Python311\Lib\site-packages\flask\cli.py", line 1047, in main
cli.main()
File "C:\Python311\Lib\site-packages\click\core.py", line 1055, in main
rv = self.invoke(ctx)
^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\click\core.py", line 1657, in invoke
return _process_result(sub_ctx.command.invoke(sub_ctx))
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\click\core.py", line 1404, in invoke
return ctx.invoke(self.callback, **ctx.params)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\click\core.py", line 760, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\click\decorators.py", line 84, in new_func
return ctx.invoke(f, obj, *args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\click\core.py", line 760, in invoke
return __callback(*args, **kwargs)
^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\flask\cli.py", line 911, in run_command
raise e from None
File "C:\Python311\Lib\site-packages\flask\cli.py", line 897, in run_command
app = info.load_app()
^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\flask\cli.py", line 308, in load_app
app = locate_app(import_name, name)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "C:\Python311\Lib\site-packages\flask\cli.py", line 218, in locate_app
__import__(module_name)
File "C:\*my_folders*\*my_folders*\froshimsemail\app.py", line 8, in <module>
app.config['MAIL_DEFAULT_SENDER'] = os.environ['MAIL_DEFAULT_SENDER']
~~~~~~~~~~^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen os>", line 678, in __getitem__
KeyError: 'MAIL_DEFAULT_SENDER'
</code></pre>
<p>What does error above even mean?? i am finding problem already few hours, i already uninstalled and installed it few times and checked i am on right python interpreter</p>
<p>Althrough this should go to the cs50 asking questions because it is from their course, but i am skeptical about how to explain my problem.</p>
| [
{
"answer_id": 74332539,
"author": "ELinda",
"author_id": 7484259,
"author_profile": "https://Stackoverflow.com/users/7484259",
"pm_score": 0,
"selected": false,
"text": "PositiveFormula"
},
{
"answer_id": 74337112,
"author": "Dmytro Mitin",
"author_id": 5249621,
"author_profile": "https://Stackoverflow.com/users/5249621",
"pm_score": 3,
"selected": true,
"text": "Not[T] extends T"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19199513/"
] |
74,331,370 | <p>I have an instance template that is supposed to run my app in a container running on Google Cloud's Container-Optimized OS. When I create a single VM from this template it runs just fine, but when I use it to create an instance group the containers don't start.</p>
<p>According to the logs the machine didn't even try to start them.</p>
<p>I tried to compare the output from <code>gcloud compute instances describe <instance-name></code> for the instance that works OK against one of the instances in the MIG, but other than some differences in the network interfaces and some that are due to the fact that one instance is managed by an instance group and the other one isn't I don't see anything unusual.</p>
<p>I also noticed that when I SSH to the instance that works, I get this message:</p>
<pre><code> ########################[ Welcome ]########################
# You have logged in to the guest OS. #
# To access your containers use 'docker attach' command #
###########################################################
</code></pre>
<p>but when I SSH to one of the instances in the MIG, I don't see it.</p>
<p>Is there a problem with using the container-optimized OS in an instance group?</p>
<p>My instance template is defined as follows:</p>
<pre class="lang-yaml prettyprint-override"><code>creationTimestamp: '2022-11-09T03:25:29.896-08:00'
description: ''
id: '757769630202081478'
kind: compute#instanceTemplate
name: server-using-docker-hub-1
properties:
canIpForward: false
confidentialInstanceConfig:
enableConfidentialCompute: false
description: ''
disks:
- autoDelete: true
boot: true
deviceName: server-using-docker-hub
index: 0
initializeParams:
diskSizeGb: '10'
diskType: pd-balanced
sourceImage: projects/cos-cloud/global/images/cos-stable-101-17162-40-20
kind: compute#attachedDisk
mode: READ_WRITE
type: PERSISTENT
keyRevocationActionType: NONE
labels:
container-vm: cos-stable-101-17162-40-20
machineType: e2-micro
metadata:
fingerprint: 76mZ3i--POo=
items:
- key: gce-container-declaration
value: |-
spec:
containers:
- name: server-using-docker-hub-1
image: docker.io/rinbar/kwik-e-mart
env:
- name: AWS_ACCESS_KEY_ID
value: <redacted>
- name: AWS_SECRET_ACCESS_KEY
value: <redacted>
- name: SECRET_FOR_SESSION
value: <redacted>
- name: SECRET_FOR_USER
value: <redacted>
- name: MONGODBURL
value: mongodb+srv://<redacted>@cluster0.<redacted>.mongodb.net/kwik-e-mart
- name: DEBUG
value: server:*
- name: PORT
value: '80'
stdin: false
tty: false
restartPolicy: Always
# This container declaration format is not public API and may change without notice. Please
# use gcloud command-line tool or Google Cloud Console to run Containers on Google Compute Engine.
kind: compute#metadata
networkInterfaces:
- kind: compute#networkInterface
name: nic0
network: https://www.googleapis.com/compute/v1/projects/rons-project-364411/global/networks/default
stackType: IPV4_ONLY
subnetwork: https://www.googleapis.com/compute/v1/projects/rons-project-364411/regions/me-west1/subnetworks/default
reservationAffinity:
consumeReservationType: ANY_RESERVATION
scheduling:
automaticRestart: true
onHostMaintenance: MIGRATE
preemptible: false
provisioningModel: STANDARD
serviceAccounts:
- email: 629139871582-compute@developer.gserviceaccount.com
scopes:
- https://www.googleapis.com/auth/devstorage.read_only
- https://www.googleapis.com/auth/logging.write
- https://www.googleapis.com/auth/monitoring.write
- https://www.googleapis.com/auth/servicecontrol
- https://www.googleapis.com/auth/service.management.readonly
- https://www.googleapis.com/auth/trace.append
shieldedInstanceConfig:
enableIntegrityMonitoring: true
enableSecureBoot: false
enableVtpm: true
tags:
items:
- http-server
selfLink: https://www.googleapis.com/compute/v1/projects/rons-project-364411/global/instanceTemplates/server-using-docker-hub-1
</code></pre>
| [
{
"answer_id": 74338043,
"author": "DazWilkin",
"author_id": 609290,
"author_profile": "https://Stackoverflow.com/users/609290",
"pm_score": 1,
"selected": false,
"text": "gcloud compute instance-templates create-with-container"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331370",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/840819/"
] |
74,331,409 | <p>I want to label encode subgroups in a pandas dataframe. Something like this:</p>
<pre class="lang-none prettyprint-override"><code>| Category | | Name |
| ---------- | | --------- |
| FRUITS | | Apple |
| FRUITS | | Orange |
| FRUITS | | Apple |
| Vegetables | | Onion |
| Vegetables | | Garlic |
| Vegetables | | Garlic |
</code></pre>
<p>to</p>
<pre class="lang-none prettyprint-override"><code>| Category | | Name | | Label |
| ---------- | | ------- | | ----- |
| FRUITS | | Apple | | 1 |
| FRUITS | | Orange | | 2 |
| FRUITS | | Apple | | 1 |
| Vegetables | | Onion | | 1 |
| Vegetables | | Garlic | | 2 |
| Vegetables | | Garlic | | 2 |
</code></pre>
| [
{
"answer_id": 74331522,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 1,
"selected": false,
"text": ".ngroup()"
},
{
"answer_id": 74333653,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 0,
"selected": false,
"text": "factorize"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14464348/"
] |
74,331,415 | <p>I wan to create a python script that print out a directory tree.
I'm aware there are tons of information about the topic, and many ways to achieve it.
Still, my problem really is about recursion.</p>
<p>In order to face the problem i choosed a OOP way:
Create a Class TreeNode
Store some props and methods
calling in the os.walk function (ya i know I can use pathlib or other libs.)
recursively create parent-child relationship of folders/files</p>
<p>First, the Class TreeNode:
properties: data, children, parent
methods: add_child(),
get_level(), to get the level of the parent/child relation in order to print it later
print_tree(), to actually print the tree (desired result shown above code)</p>
<pre><code>
class Treenode:
def __init__(self, data):
self.data = data
self.children = []
self.parent = None
def add_child(self,child):
child.parent = self
self.children.append(child)
def get_level(self):
level = 0
p = self.parent
while p:
level += 1
p = p.parent
return level
def print_tree(self):
spaces = " " * self.get_level() * 3
prefix = spaces + "|__" if self.parent else ""
print(prefix + self.data)
for child in self.children:
child.print_tree()
</code></pre>
<p>Second, the probelm. Function to creating the tree</p>
<pre><code>def build_tree(dir_path):
for root,dirs,files in os.walk(dir_path):
if dir_path == root:
for d in dirs:
directory = Treenode(d)
tree.add_child(directory)
for f in files:
file = Treenode(f)
tree.add_child(file)
working_directories = dirs
else:
for w in working_directories:
build_tree(os.path.join(dir_path,w))
return tree
</code></pre>
<p>Finally, the main method:</p>
<pre><code>if __name__ == '__main__':
tree = Treenode("C:/Level0")
tree = build_tree("C:/Level0")
tree.print_tree()
pass
</code></pre>
<p>The output of this code would be:</p>
<pre><code>C:/Level0
|__Level1
|__0file.txt
|__Level2
|__Level2b
|__1file1.txt
|__1file2.txt
|__Level3
|__2file1.txt
|__LEvel4
|__3file1.txt
|__4file1.txt
|__2bfile1.txt
</code></pre>
<p>The desired output should be:</p>
<pre><code>C:/Level0
|__Level1
|__Level2
|__Level3
|__LEvel4
|__4file1.txt
|__3file1.txt
|__2file1.txt
|__Level2b
|__2bfile1.txt
|__1file1.txt
|__1file2.txt
|__0file.txt
</code></pre>
<p>The problem lays in the tree.add_child(directory), since everytime the code get there it add the new directory (or file) as child of the same "root tree". Not in tree.children.children..etc
So here's the problem. How do i get that. The if else statement in the build_tree() function is probably unecessary, i was trying to work my way around but no luck.</p>
<p>I know it's a dumb problem, coming from a lack of proper study of algorithms and data structures..
If you will to help though, i'm here to learn ^^</p>
| [
{
"answer_id": 74331522,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 1,
"selected": false,
"text": ".ngroup()"
},
{
"answer_id": 74333653,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 0,
"selected": false,
"text": "factorize"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331415",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20428297/"
] |
74,331,438 | <pre><code>chars = list(range(0,10))
numbers_list = list(range(0,25))
for comb in itertools.combinations_with_replacement(chars, 5):
for A in numbers_list:
pure = str(A) + ':' + str(comb)
B = pure.replace(")", "").replace("(", "").replace("'", "").replace(",", "").replace(" ", "")
C = hashlib.sha256(B.encode('utf-8')).hexdigest()
rows = [A , str(B), str(C)]
print(rows)
header = ['A', 'B', 'C']
with open('data.csv', 'w', encoding='UTF8', newline='') as f:
writer = csv.writer(f)
writer.writerow(header)
writer.writerow(rows)
print('end')
</code></pre>
<p>Good afternoon everyone,
I am having an issue with csv file not being created. The rows are printing out in IDE, but when the script is done running all the rows of combinations after a few hours, it does not create the CSV file with the rows. I am bit new to programing in python. I would be really appreciative the help! Thank you!</p>
| [
{
"answer_id": 74331659,
"author": "will-wright-eng",
"author_id": 14343465,
"author_profile": "https://Stackoverflow.com/users/14343465",
"pm_score": 1,
"selected": false,
"text": "import itertools, hashlib, csv\n\ndata = []\nchars = list(range(0,10)) \nnumbers_list = list(range(0,25))\nfor comb in itertools.combinations_with_replacement(chars, 5): \n for A in numbers_list:\n pure = str(A) + ':' + str(comb) \n B = pure.replace(\")\", \"\").replace(\"(\", \"\").replace(\"'\", \"\").replace(\",\", \"\").replace(\" \", \"\") \n C = hashlib.sha256(B.encode('utf-8')).hexdigest()\n rows = [A , str(B), str(C)]\n data.append(rows)\n\n \n\nheader = ['A', 'B', 'C'] \nwith open('data.csv', 'w', encoding='UTF8', newline='') as f: \n writer = csv.writer(f)\n writer.writerow(header)\n for row in data:\n writer.writerow(row) \n\nprint('end')\n"
},
{
"answer_id": 74331708,
"author": "Mircea Mesesan",
"author_id": 20428489,
"author_profile": "https://Stackoverflow.com/users/20428489",
"pm_score": 1,
"selected": true,
"text": "import itertools\nimport hashlib\nimport pandas as pd\n\nchars = list(range(0,10))\nnumbers_list = list(range(0,25))\n\nrows = []\nfor combination in itertools.combinations_with_replacement(chars, 5):\n for number in numbers_list:\n pure_number_a = str(number) + ':' + str(combination) \n pure_number_b = pure_number_a.replace(\")\", \"\").replace(\"(\", \"\").replace(\"'\", \"\").replace(\",\", \"\").replace(\" \", \"\") \n pure_number_c = hashlib.sha256(pure_number_b.encode('utf-8')).hexdigest()\n\n rows.append([pure_number_a , pure_number_b, pure_number_c])\n\n\ndf = pd.DataFrame(data=rows, columns=['A', 'B', 'C'])\ndf.to_csv('data.csv', index=False)\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331438",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20428284/"
] |
74,331,447 | <p>I am trying to export my NumPy matrix to a <code>.tiff</code> file then to read its contents to verify if it worked. Given the following snippet</p>
<pre class="lang-py prettyprint-override"><code>import numpy as np
import cv2
data = np.array([[-0.1 for _ in range(128)] for _ in range(128)], dtype=np.float32)
cv2.imwrite('temp.tiff', data)
print('tiff file written')
image = cv2.imread('temp.tiff')
print(image)
</code></pre>
<p>returns</p>
<pre><code>tiff file written
[ WARN:0@19.816] global /io/opencv/modules/imgcodecs/src/grfmt_tiff.cpp (629) readData OpenCV TIFF: TIFFRGBAImageOK: Sorry, can not handle images with 32-bit samples
</code></pre>
<p>So then I lower down the <code>dtype</code> parameter to <code>dtype=np.float16</code></p>
<pre class="lang-py prettyprint-override"><code>data = np.array([[-0.1 for _ in range(128)] for _ in range(128)], dtype=np.float16)
</code></pre>
<p>but then I get another error...</p>
<pre><code>, line 50, in export_images_to_tiff
cv2.imwrite('temp.tiff', a)
cv2.error: OpenCV(4.6.0) :-1: error: (-5:Bad argument) in function 'imwrite'
> Overload resolution failed:
> - img data type = 23 is not supported
> - Expected Ptr<cv::UMat> for argument 'img'
[1] 24228 abort python3 main.py
</code></pre>
<p>I am honestly going nuts with this feature I'm trying to implement. Is there any alternatives or fix to the above? I read the documentation but that didn't help, and looking online these error codes yield nothing relevant. Do I just assume that the tiff file was successfully written in the first 32-bit pass and call it a day?</p>
| [
{
"answer_id": 74331659,
"author": "will-wright-eng",
"author_id": 14343465,
"author_profile": "https://Stackoverflow.com/users/14343465",
"pm_score": 1,
"selected": false,
"text": "import itertools, hashlib, csv\n\ndata = []\nchars = list(range(0,10)) \nnumbers_list = list(range(0,25))\nfor comb in itertools.combinations_with_replacement(chars, 5): \n for A in numbers_list:\n pure = str(A) + ':' + str(comb) \n B = pure.replace(\")\", \"\").replace(\"(\", \"\").replace(\"'\", \"\").replace(\",\", \"\").replace(\" \", \"\") \n C = hashlib.sha256(B.encode('utf-8')).hexdigest()\n rows = [A , str(B), str(C)]\n data.append(rows)\n\n \n\nheader = ['A', 'B', 'C'] \nwith open('data.csv', 'w', encoding='UTF8', newline='') as f: \n writer = csv.writer(f)\n writer.writerow(header)\n for row in data:\n writer.writerow(row) \n\nprint('end')\n"
},
{
"answer_id": 74331708,
"author": "Mircea Mesesan",
"author_id": 20428489,
"author_profile": "https://Stackoverflow.com/users/20428489",
"pm_score": 1,
"selected": true,
"text": "import itertools\nimport hashlib\nimport pandas as pd\n\nchars = list(range(0,10))\nnumbers_list = list(range(0,25))\n\nrows = []\nfor combination in itertools.combinations_with_replacement(chars, 5):\n for number in numbers_list:\n pure_number_a = str(number) + ':' + str(combination) \n pure_number_b = pure_number_a.replace(\")\", \"\").replace(\"(\", \"\").replace(\"'\", \"\").replace(\",\", \"\").replace(\" \", \"\") \n pure_number_c = hashlib.sha256(pure_number_b.encode('utf-8')).hexdigest()\n\n rows.append([pure_number_a , pure_number_b, pure_number_c])\n\n\ndf = pd.DataFrame(data=rows, columns=['A', 'B', 'C'])\ndf.to_csv('data.csv', index=False)\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331447",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12985747/"
] |
74,331,471 | <p>I am trying to use the BoolToObject converter class referenced here <a href="https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/converters/bool-to-object-converter" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/dotnet/communitytoolkit/maui/converters/bool-to-object-converter</a></p>
<p>In my XAML page I included the following line</p>
<pre><code><ContentPage xmlns="http://schemas.microsoft.com/dotnet/2021/maui"
xmlns:toolkit="http://schemas.microsoft.com/dotnet/2022/maui/toolkit">
</code></pre>
<p>I am trying to use it like as indicated in the reference page like so:</p>
<pre><code><ContentPage.Resources>
<ResourceDictionary>
<toolkit:BoolToObjectConverter x:Key="BoolToObjectConverter" TrueObject="42" FalseObject="0" />
</ResourceDictionary>
</ContentPage.Resources>
</code></pre>
<p>But it says the type "BoolToObjectConverter" can not be found. What am I missing?</p>
<p>Thanks for taking the time to help me.</p>
| [
{
"answer_id": 74331659,
"author": "will-wright-eng",
"author_id": 14343465,
"author_profile": "https://Stackoverflow.com/users/14343465",
"pm_score": 1,
"selected": false,
"text": "import itertools, hashlib, csv\n\ndata = []\nchars = list(range(0,10)) \nnumbers_list = list(range(0,25))\nfor comb in itertools.combinations_with_replacement(chars, 5): \n for A in numbers_list:\n pure = str(A) + ':' + str(comb) \n B = pure.replace(\")\", \"\").replace(\"(\", \"\").replace(\"'\", \"\").replace(\",\", \"\").replace(\" \", \"\") \n C = hashlib.sha256(B.encode('utf-8')).hexdigest()\n rows = [A , str(B), str(C)]\n data.append(rows)\n\n \n\nheader = ['A', 'B', 'C'] \nwith open('data.csv', 'w', encoding='UTF8', newline='') as f: \n writer = csv.writer(f)\n writer.writerow(header)\n for row in data:\n writer.writerow(row) \n\nprint('end')\n"
},
{
"answer_id": 74331708,
"author": "Mircea Mesesan",
"author_id": 20428489,
"author_profile": "https://Stackoverflow.com/users/20428489",
"pm_score": 1,
"selected": true,
"text": "import itertools\nimport hashlib\nimport pandas as pd\n\nchars = list(range(0,10))\nnumbers_list = list(range(0,25))\n\nrows = []\nfor combination in itertools.combinations_with_replacement(chars, 5):\n for number in numbers_list:\n pure_number_a = str(number) + ':' + str(combination) \n pure_number_b = pure_number_a.replace(\")\", \"\").replace(\"(\", \"\").replace(\"'\", \"\").replace(\",\", \"\").replace(\" \", \"\") \n pure_number_c = hashlib.sha256(pure_number_b.encode('utf-8')).hexdigest()\n\n rows.append([pure_number_a , pure_number_b, pure_number_c])\n\n\ndf = pd.DataFrame(data=rows, columns=['A', 'B', 'C'])\ndf.to_csv('data.csv', index=False)\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331471",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6015925/"
] |
74,331,474 | <p>Via SQL, I'm trying to get from this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>group_id</th>
<th>session_id</th>
<th>field_label</th>
<th>field_value</th>
<th>sent_at</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>frosted flakes</td>
<td>blue bowl</td>
<td>first_name</td>
<td>Bob</td>
<td>2022-11-05 18:18:19.093</td>
</tr>
<tr>
<td>2</td>
<td>frosted flakes</td>
<td>blue bowl</td>
<td>first_name</td>
<td>Bobby</td>
<td>2022-11-05 18:17:31.274</td>
</tr>
<tr>
<td>3</td>
<td>frosted flakes</td>
<td>blue bowl</td>
<td>last_name</td>
<td>Brown</td>
<td>2022-11-05 18:17:16.241</td>
</tr>
<tr>
<td>4</td>
<td>frosted flakes</td>
<td>blue bowl</td>
<td>last_name</td>
<td>Browning</td>
<td>2022-11-05 18:15:34.492</td>
</tr>
<tr>
<td>5</td>
<td>frosted flakes</td>
<td>blue bowl</td>
<td>last_name</td>
<td>Brownson</td>
<td>2022-11-05 18:14:58.465</td>
</tr>
<tr>
<td>6</td>
<td>cheerios</td>
<td>green cup</td>
<td>first_name</td>
<td>Christine</td>
<td>2022-11-05 18:18:58.222</td>
</tr>
<tr>
<td>7</td>
<td>cheerios</td>
<td>green cup</td>
<td>last_name</td>
<td>Christmas</td>
<td>2022-11-05 18:20:41.212</td>
</tr>
<tr>
<td>8</td>
<td>cheerios</td>
<td>green cup</td>
<td>last_name</td>
<td>Christopherson</td>
<td>2022-11-05 18:24:58.222</td>
</tr>
</tbody>
</table>
</div>
<p>where</p>
<ul>
<li><code>id</code> is unique</li>
<li><code>group_id</code> is not unique</li>
<li><code>session_id</code> is not unique</li>
</ul>
<p>to this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>group_id</th>
<th>session_id</th>
<th>amalgamated_field</th>
</tr>
</thead>
<tbody>
<tr>
<td>frosted flakes</td>
<td>blue bowl</td>
<td>Bob Brown</td>
</tr>
<tr>
<td>cheerios</td>
<td>green cup</td>
<td>Christine Christopherson</td>
</tr>
</tbody>
</table>
</div>
<p>Where I know the <code>field_label</code>s that I want to amalgamate, and I want to get the latest value for each amalgamated field label based on <code>sent_at</code> grouped by <code>group_id</code>.</p>
<p>So for group <strong>frosted flakes</strong>, I want to get the most recent <code>field_value</code> associated with <code>field_label</code> <strong>first_name</strong> (Bob) and the most recent <code>field_value</code> associated with <code>field_label</code> <strong>last_name</strong> (Brown).</p>
<p>And repeat.</p>
<p>I tried a cross join and I also tried an inner join similar to <a href="https://stackoverflow.com/questions/12464669/return-value-at-max-date-for-a-particular-id">this thread</a>. But I keep getting all combinations :/</p>
| [
{
"answer_id": 74331634,
"author": "ahmed",
"author_id": 12705912,
"author_profile": "https://Stackoverflow.com/users/12705912",
"pm_score": 3,
"selected": true,
"text": "ROW_NUMBER"
},
{
"answer_id": 74331635,
"author": "Ajax1234",
"author_id": 7326738,
"author_profile": "https://Stackoverflow.com/users/7326738",
"pm_score": 1,
"selected": false,
"text": "field_label"
},
{
"answer_id": 74331850,
"author": "GMB",
"author_id": 10676716,
"author_profile": "https://Stackoverflow.com/users/10676716",
"pm_score": 2,
"selected": false,
"text": "distinct on"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331474",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/392849/"
] |
74,331,493 | <p>I am trying to copy the last populated row from one spreadsheet to the first not populated row on another spreadsheet. This function works where the source and target sheet are from the same spreadsheet, but not if they are from different spreadsheets.</p>
<pre><code>function moveRows() {
// identifying source & target spreadsheets
let ss = SpreadsheetApp.openById('1PugO3VL8ZkGzA6zcYfUkQK4WkU-FfRUBHUzRDTmEbYE');
let target = SpreadsheetApp.openById('17my-WAAVkZK8m541dH50japQZYQY4WEC_vm12-fCKR8');
let source_sheet = ss.getSheetByName('Sheet2');
let target_sheet = target.getSheetByName('Sheet1');
// identifying the ranges
let row = source_sheet.getActiveRange().getRow();
let activeRow = source_sheet.getRange( row ,1, 1 ,10);
let last_row = target_sheet.getLastRow();
// row below gives -> Exception: Target range and source range must be on the same spreadsheet.
activeRow.copyTo(target_sheet.getRange('A'+(last_row+1)+':Q'+(last_row+1)));
}
</code></pre>
| [
{
"answer_id": 74331607,
"author": "great_pan",
"author_id": 20200173,
"author_profile": "https://Stackoverflow.com/users/20200173",
"pm_score": 1,
"selected": false,
"text": "function moveRows() {\n let sourceSs = SpreadsheetApp.openById('1PugO3VL8ZkGzA6zcYfUkQK4WkU-FfRUBHUzRDTmEbYE');\n let targetSs = SpreadsheetApp.openById('17my-WAAVkZK8m541dH50japQZYQY4WEC_vm12-fCKR8');\n let sourceSheet = sourceSs.getSheetByName('Sheet2');\n let targetSheet = targetSs.getSheetByName('Sheet1');\n let sourceLastRow = sourceSheet.getLastRow();\n let sourceValues = sourceSheet.getRange(sourceLastRow + ':' + sourceLastRow).getValues();\n let targetNextRow = targetSheet.getLastRow() + 1;\n targetSheet.getRange(targetNextRow + ':' + targetNextRow).setValues(sourceValues);\n} \n"
},
{
"answer_id": 74331944,
"author": "Cooper",
"author_id": 7215091,
"author_profile": "https://Stackoverflow.com/users/7215091",
"pm_score": 0,
"selected": false,
"text": "function moveLastRow() {\n let ss = SpreadsheetApp.openById('1PugO3VL8ZkGzA6zcYfUkQK4WkU-FfRUBHUzRDTmEbYE');\n let tss = SpreadsheetApp.openById('17my-WAAVkZK8m541dH50japQZYQY4WEC_vm12-fCKR8');\n let ssh = ss.getSheetByName('Sheet2');\n const svs = ssh.getDataRange().getValues();\n let o = svs[svs.length -1];\n let tsh = tss.getSheetByName('Sheet1');\n const tvs = tsh.getDataRange().getValues() \n tsh.getRange(tsh.getLastRow() + 1, 1, 1, o.length).setValues([o]);\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331493",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20426572/"
] |
74,331,538 | <p>I have started to face this issue just recently. I'm using the Visual Studio 2022 Preview latest. I made a few simple changes to the DB and used the validation tool in dbForge Studio 2022 for SQL Server to validate all objects. The DB is valid.</p>
<p>When I try to update my context, I get the following output.</p>
<pre><code>Build started...
Build succeeded.
System.NullReferenceException: Object reference not set to an instance of an object.
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpDbContextGenerator.TransformText()
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpModelGenerator.ProcessTemplate(ITextTransformation transformation)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.CSharpModelGenerator.GenerateModel(IModel model, ModelCodeGenerationOptions options)
at Microsoft.EntityFrameworkCore.Scaffolding.Internal.ReverseEngineerScaffolder.ScaffoldModel(String connectionString, DatabaseModelFactoryOptions databaseOptions, ModelReverseEngineerOptions modelOptions, ModelCodeGenerationOptions codeOptions)
at Microsoft.EntityFrameworkCore.Design.Internal.DatabaseOperations.ScaffoldContext(String provider, String connectionString, String outputDir, String outputContextDir, String dbContextClassName, IEnumerable`1 schemas, IEnumerable`1 tables, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluralize)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContextImpl(String provider, String connectionString, String outputDir, String outputDbContextDir, String dbContextClassName, IEnumerable`1 schemaFilters, IEnumerable`1 tableFilters, String modelNamespace, String contextNamespace, Boolean useDataAnnotations, Boolean overwriteFiles, Boolean useDatabaseNames, Boolean suppressOnConfiguring, Boolean noPluralize)
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.ScaffoldContext.<>c__DisplayClass0_0.<.ctor>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.<>c__DisplayClass3_0`1.<Execute>b__0()
at Microsoft.EntityFrameworkCore.Design.OperationExecutor.OperationBase.Execute(Action action)
Object reference not set to an instance of an object.
</code></pre>
<p>I get a successful build, but it immediately fails with the error. I'd like to research this, but no other log windows show any errors, and I cannot figure out what is causing this.</p>
| [
{
"answer_id": 74344057,
"author": "Hassan Gulzar",
"author_id": 481656,
"author_profile": "https://Stackoverflow.com/users/481656",
"pm_score": 1,
"selected": true,
"text": "CREATE TABLE [dbo].[LookupImportBrand] (\n [CompanyId] BIGINT NOT NULL,\n [BranchId] BIGINT NOT NULL,\n [Name] [dbo].[Name250] NOT NULL,\n [Active] [dbo].[Boolean] NOT NULL,\n CONSTRAINT [FK_LookupImportBrand_LookupImportCompany] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[LookupImportCompany] ([Id])\n);\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/481656/"
] |
74,331,553 | <p>I'm doing one of the freeCodeCamp' JavaScript course tasks and can't find the explanation why my code works for some of the given cases and does not work for others.</p>
<p>The exercise is:</p>
<blockquote>
<p>Return the lowest index at which a value (second argument) should be inserted into an array (first argument) once it has been sorted. The returned value should be a number.</p>
<p>For example, getIndexToIns([1,2,3,4], 1.5) should return 1 because it is greater than 1 (index 0), but less than 2 (index 1).</p>
<p>Likewise, getIndexToIns([20,3,5], 19) should return 2 because once the array has been sorted it will look like [3,5,20] and 19 is less than 20 (index 2) and greater than 5 (index 1).</p>
</blockquote>
<p>My code for this is:</p>
<pre><code>function getIndexToIns(arr, num) {
let newArray = [...arr, num].sort()
let result = newArray.indexOf(num);
return result;
}
</code></pre>
<p>And the code above outputs correct results for some of the cases (eg. getIndexToIns([10, 20, 30, 40, 50], 30) and incorrect results for other cases (eg. getIndexToIns([5, 3, 20, 3], 5).</p>
<p>I expected it to concatenate arr with num, sort it and then output the index of num, which is the case of this exercise. Can someone explain to me why it does not work?</p>
| [
{
"answer_id": 74344057,
"author": "Hassan Gulzar",
"author_id": 481656,
"author_profile": "https://Stackoverflow.com/users/481656",
"pm_score": 1,
"selected": true,
"text": "CREATE TABLE [dbo].[LookupImportBrand] (\n [CompanyId] BIGINT NOT NULL,\n [BranchId] BIGINT NOT NULL,\n [Name] [dbo].[Name250] NOT NULL,\n [Active] [dbo].[Boolean] NOT NULL,\n CONSTRAINT [FK_LookupImportBrand_LookupImportCompany] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[LookupImportCompany] ([Id])\n);\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331553",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11052810/"
] |
74,331,556 | <p>So I am creating a sheet to track some data, and I have it fed into a chart via a ratio and a date, so for instance, I had 10 and 5 equals a ratio of 2, at this particular time. I was able to find a script to automate the date, but I also wanted to automate the ratio, as every time I have to put in cell reference/ cell reference. Sure its just shift click and drag but I would like it to be automated just like the date. I have been teaching myself javascript but I am still VERY new. Basically I came up with this.</p>
<pre><code>function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Overall", "M&K", "Con" ) {
var r = s.getActiveCell();
if( r.getColumn() == 2 ) { //checks that the cell being edited is in column B
var nextCell = r.offset(0, -2);
if( nextCell.getValue() === '' ) //checks if the adjacent cell is empty or not?
nextCell.setValue(new Date()).setNumberFormat("dd/MM/yyyy, hh:mm");
}
}
}
function onEdit() {
var s1 = SpreadsheetApp.getActiveSheet();
if( s1.getName() == "Overall", "M&K", "Con" ) {
var r1 = s1.getActiveCell();
if( r1.getColumn() == 3 ) { //checks that the cell being edited is in column C
var a = r1.offset(0, 1);
var b = r1.offset(0, -1);
var c = r1.offset(0, 0);
if( a.getValue() === '' ) //checks if the adjacent cell is empty or not?
a.setValue(b.getValue()/c.getValue());
}
}
}
</code></pre>
<p>And when I put this into my one sheet, only one will work, not both, and its always the bottom one, and nothing will work if I try and put it first. I'm sure it has something to do with how the script is structured but I honestly have no idea.</p>
<p>I tried changing around the values and restructuring it to the best of my knowledge and ability, but I could never get two to run simultaneously, its always either one or the other.</p>
| [
{
"answer_id": 74344057,
"author": "Hassan Gulzar",
"author_id": 481656,
"author_profile": "https://Stackoverflow.com/users/481656",
"pm_score": 1,
"selected": true,
"text": "CREATE TABLE [dbo].[LookupImportBrand] (\n [CompanyId] BIGINT NOT NULL,\n [BranchId] BIGINT NOT NULL,\n [Name] [dbo].[Name250] NOT NULL,\n [Active] [dbo].[Boolean] NOT NULL,\n CONSTRAINT [FK_LookupImportBrand_LookupImportCompany] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[LookupImportCompany] ([Id])\n);\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20428426/"
] |
74,331,577 | <p>In a Swift navigation split view once all of the data has been loaded from core data (indicated by the isLoading variable being equal to false) the Progress View stops being displayed but the detail view is now empty. What I would like have happen at this point is for the Summary view to be displayed. I think this would require programmatically setting the list selection to "Home". How do I need to modify my code to accomplish this? Below is the code.</p>
<pre><code>struct ContentView: View {
@State private var selection: String?
@ObservedObject private var vooVM: VOOViewModel
@ObservedObject private var vfiaxVM: VFIAXViewModel
@ObservedObject private var prinVM: PrincipalViewModel
init(vooVM: VOOViewModel, vfiaxVM: VFIAXViewModel, prinVM: PrincipalViewModel) {
self.vooVM = vooVM
self.vfiaxVM = vfiaxVM
self.prinVM = prinVM
}
let myList = ["Home", "VOO Chart", "VOO List", "VFIAX Chart", "VFIAX List", "Principal Chart", "Principal List"]
var body: some View {
NavigationSplitView {
List(myList, id: \.self, selection: $selection) { listItem in
NavigationLink(value: listItem) {
Text(listItem)
} // end navigation link
} // end list
.navigationSplitViewColumnWidth(250)
} detail: {
if vooVM.isloading == true || vfiaxVM.isloading == true || prinVM.isloading == true {
Spacer()
ProgressView()
.navigationSplitViewColumnWidth(950)
Spacer()
} else if selection == "Home" {
Summary(vooVM: vooVM, vfiaxVM: vfiaxVM, prinVM: prinVM)
.navigationSplitViewColumnWidth(950)
} else if selection == "VOO Chart" {
LineChart(passedInArray: vooVM.values1)
.navigationSplitViewColumnWidth(950)
} else {
Text("Select an option in the list")
}
Spacer()
}
.frame(width: 1200,height: 900, alignment: .center)
} // end body
} // end struct
</code></pre>
| [
{
"answer_id": 74344057,
"author": "Hassan Gulzar",
"author_id": 481656,
"author_profile": "https://Stackoverflow.com/users/481656",
"pm_score": 1,
"selected": true,
"text": "CREATE TABLE [dbo].[LookupImportBrand] (\n [CompanyId] BIGINT NOT NULL,\n [BranchId] BIGINT NOT NULL,\n [Name] [dbo].[Name250] NOT NULL,\n [Active] [dbo].[Boolean] NOT NULL,\n CONSTRAINT [FK_LookupImportBrand_LookupImportCompany] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[LookupImportCompany] ([Id])\n);\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331577",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14880506/"
] |
74,331,606 | <p><a href="https://i.stack.imgur.com/rvesO.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rvesO.jpg" alt="enter image description here" /></a></p>
<p>I have this plot I made with the code below. As you can see, the leftmost graph is made very narrow when I arrange these plots into a grid. I want them all to be equally wide, even if all three have to be more narrow to accommodate the row labels. I don't think this is quite the same as questions posted in the past because of the inclusion of relatively long, horizontal row labels.</p>
<pre><code>
p1<-ggplot(main.frame2, aes(x=item.true.prev, y=reorder(substring(Shorthand,5), item.true.prev), color=item.republican))+
geom_point(size=3)+
theme_forest()+
xlim(0,1)+ xlab("True Prevalence")+ylab("Item")+
scale_colour_gradient(low="blue", high="red")+
geom_stripes(odd = "#33333333", even = "#00000000")+
tidytext::scale_y_reordered() +
guides(color = "none") +
theme(text = element_text(size=18))
p2<-ggplot(main.frame2, aes(x=perceived.prev, y=reorder(item.id.short, item.true.prev), color=item.republican))+
geom_point(size=3)+
theme_forest()+
xlim(0,1)+xlab("Perceived Prevalence")+ylab("")+
scale_colour_gradient(low="blue", high="red")+
geom_stripes(odd = "#33333333", even = "#00000000")+
tidytext::scale_y_reordered() +
theme(axis.text.y=element_blank())+
guides(color = "none") +
theme(text = element_text(size=18))
p3<-ggplot(main.frame2, aes(x=generic.acceptance, y=reorder(item.id.short, item.true.prev), color=item.republican))+
geom_point(size=3)+
theme_forest()+
xlim(0,1)+xlab("Generic Acceptance")+ylab("")+
scale_colour_gradient(low="blue", high="red")+
geom_stripes(odd = "#33333333", even = "#00000000")+
tidytext::scale_y_reordered() +
guides(color = "none")+
theme(axis.text.y=element_blank(),
axis.ticks.y=element_blank())+
theme(text = element_text(size=18))
gridExtra::grid.arrange(p1,p2, p3, nrow=1)
</code></pre>
<p>And here is what the dataframe looks like:</p>
<pre><code> item.id.short Shorthand perceived.prev item.true.prev generic.acceptance
<dbl> <chr> <dbl> <dbl> <dbl>
1 22 "(D) Liberal identity " 0.0755 0.07 0.0288
2 42 "(R) Conservative identity " 0.0935 0.13 0.0336
3 62 "(R) Prayer in schools" 0.132 0.18 0.0935
4 40 "(R) Require Lord's Prayer" 0.139 0.42 0.0959
5 28 "(D) Decrease police" 0.140 0.11 0.101
6 64 "(R) US as Christian nation" 0.141 0.06 0.0911
7 52 "(R) Ban trans soldiers" 0.142 0.11 0.0671
8 55 "(R) Withdraw Paris Deal" 0.154 0.11 0.0839
9 56 "(R) Build southern wall" 0.154 0.13 0.0839
10 60 "(R) Eliminate gun permits" 0.156 0.17 0.0983
</code></pre>
<p>I have tried using a ggtextable() to create a fourth object for the grid.arrange, but that did not work. I just want the same width for all 3 plots.</p>
| [
{
"answer_id": 74344057,
"author": "Hassan Gulzar",
"author_id": 481656,
"author_profile": "https://Stackoverflow.com/users/481656",
"pm_score": 1,
"selected": true,
"text": "CREATE TABLE [dbo].[LookupImportBrand] (\n [CompanyId] BIGINT NOT NULL,\n [BranchId] BIGINT NOT NULL,\n [Name] [dbo].[Name250] NOT NULL,\n [Active] [dbo].[Boolean] NOT NULL,\n CONSTRAINT [FK_LookupImportBrand_LookupImportCompany] FOREIGN KEY ([CompanyId]) REFERENCES [dbo].[LookupImportCompany] ([Id])\n);\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8896225/"
] |
74,331,626 | <p>How would I call this class within a class? I'm getting the 'class' is not defined error.</p>
<pre><code>class testArray:
class testObject:
blah = 0
def __init__(self, number):
self.number = 1
# Problem here
object = testObject()
object.blah = self.number
</code></pre>
| [
{
"answer_id": 74331647,
"author": "OtterLord",
"author_id": 19355475,
"author_profile": "https://Stackoverflow.com/users/19355475",
"pm_score": 2,
"selected": false,
"text": "testArray.testObject()"
},
{
"answer_id": 74331717,
"author": "Kings_M",
"author_id": 12904301,
"author_profile": "https://Stackoverflow.com/users/12904301",
"pm_score": 1,
"selected": false,
"text": "class testArray:\n class testObject:\n blah = 0\n \n def __init__(self, number):\n self.number = 1\n # just like other Methods\n object = self.testObject()\n object.blah = self.number \n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4595424/"
] |
74,331,639 | <p>I was doing a program that consisted of through these modules below create a new page on google, but it was not possible, because of some errors.</p>
<pre><code>from selenium import webdriver
from webdriver_manager.chrome import ChromeDriverManager
from selenium.webdriver.chrome.service import Service
servico=Service(ChromeDriverManager().install())
navegador=webdriver.Chrome(service=servico)
</code></pre>
<p>This was the errors:</p>
<pre><code>Traceback (most recent call last):
File "c:\\Users\\user\\Desktop\\Francisco\\trabalhos que não são da escola\\programação\\projeto1\\teste.py", line 2, in \<module\>
from webdriver_manager.chrome import ChromeDriverManager
File "C:\\Users\\user\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\webdriver_manager\\chrome.py", line 7, in \<module\>
from webdriver_manager.drivers.chrome import ChromeDriver
File "C:\\Users\\user\\AppData\\Local\\Packages\\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\\LocalCache\\local-packages\\Python310\\site-packages\\webdriver_manager\\drivers\\chrome.py", line 1, in \<module\>
from packaging import version
ModuleNotFoundError: No module named 'packaging'
</code></pre>
<p>I tried to reinstall all including "packaging" again but it didn´t work too.</p>
<p>What can I do?</p>
| [
{
"answer_id": 74333930,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 0,
"selected": false,
"text": "ChromeDriverManager"
},
{
"answer_id": 74334863,
"author": "Eugeny Okulik",
"author_id": 12023661,
"author_profile": "https://Stackoverflow.com/users/12023661",
"pm_score": 0,
"selected": false,
"text": "pip install --upgrade pip\n"
},
{
"answer_id": 74339932,
"author": "Francisco Frieza",
"author_id": 19520348,
"author_profile": "https://Stackoverflow.com/users/19520348",
"pm_score": 1,
"selected": false,
"text": "from packaging install version"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331639",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19520348/"
] |
74,331,644 | <p>I printed out every iteration. The contents of the list are perfect. But for some reason heappop is returning -8 val even though there is -15 in the list. Help me out</p>
<pre><code>class FoodRatings:
def __init__(self, foods: List[str], cuisines: List[str], ratings: List[int]):
self.find_cuisine = defaultdict()
self.hashset = defaultdict(list)
for f, c, r in zip(foods, cuisines, ratings):
self.find_cuisine[f] = (c, r)
heapq.heappush(self.hashset[c], (-r, f))
def changeRating(self, food: str, newRating: int) -> None:
c, r = self.find_cuisine[food]
self.hashset[c].remove((-r, food))
heapq.heappush(self.hashset[c], (-newRating, food))
self.find_cuisine[food] = (c, newRating)
def highestRated(self, cuisine: str) -> str:
r, f = heapq.heappop(self.hashset[cuisine])
heapq.heappush(self.hashset[cuisine], (r, f))
return f
</code></pre>
<blockquote>
<p>Input:</p>
</blockquote>
<p>foods = ["czopaaeyl","lxoozsbh","kbaxapl"],</p>
<p>cuisines = ["dmnuqeatj","dmnuqeatj","dmnuqeatj"],</p>
<p>ratings = [11,2,15]],</p>
<blockquote>
<p>calls</p>
</blockquote>
<p>"FoodRatings"</p>
<p>"changeRating" - ["czopaaeyl",12],</p>
<p>"highestRated" - ["dmnuqeatj"],</p>
<p>"changeRating" - ["kbaxapl",8],</p>
<p>"changeRating" - ["lxoozsbh",5],</p>
<p>"highestRated" - ["dmnuqeatj"],</p>
<blockquote>
<p>My output: [null,null,"kbaxapl",null,null,"kbaxapl"]</p>
</blockquote>
<blockquote>
<p>Expected Output: [null,null,"kbaxapl",null,null,"czopaaeyl"]</p>
</blockquote>
<pre><code></code></pre>
| [
{
"answer_id": 74333930,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 0,
"selected": false,
"text": "ChromeDriverManager"
},
{
"answer_id": 74334863,
"author": "Eugeny Okulik",
"author_id": 12023661,
"author_profile": "https://Stackoverflow.com/users/12023661",
"pm_score": 0,
"selected": false,
"text": "pip install --upgrade pip\n"
},
{
"answer_id": 74339932,
"author": "Francisco Frieza",
"author_id": 19520348,
"author_profile": "https://Stackoverflow.com/users/19520348",
"pm_score": 1,
"selected": false,
"text": "from packaging install version"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331644",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18506786/"
] |
74,331,651 | <p>I have captured an image with React Native (expo-app) and can't find a proper way to send it to backend, mostly 500 and 422 appears (422 at this example).</p>
<p>Here is how a image data looks</p>
<pre><code>{"base64": null, "height": 820, "uri": "file:///var/mobile/Containers/Data/Application/792E2665-5063-4853-876E-3793568C7FCF/Library/Caches/ExponentExperienceData/%2540anonymous%252Fexpo-app-27783a0c-0a97-44a6-be26-48d37639bb25/ImageManipulator/9FCEF372-7C90-484F-9028-7D4271F9978D.jpg", "width": 476}
</code></pre>
<p>Here is the axios request to the backend, a photo state contains the data of image like above</p>
<pre><code> const handleSubmit = async() => {
const formData = new FormData();
formData.append("photo", {
uri: photo.uri,
name: photo.uri.split('/').pop(),
type: 'image/jpg'
});
await axios.post("/api/upload", {
formData
}, {
headers: { "Content-Type": "multipart/form-data" },
}).then(response => {
console.log(response.data)
})
}
</code></pre>
<p>Here is the laravel side, it can't go through validation</p>
<pre><code>public function store(Request $request)
{
$validated = $request->validate([
'photo' => 'required|mimes:jpg,png,jpeg'
]);
return response()->json([
'status' => 'successfuly executed',
]);
}
</code></pre>
<p>Here is the laravel err log of what was in the request, even though console logging in the front end right before sending request, an object of image exist.</p>
<pre><code>{"formData": null}
</code></pre>
<p>I can't figure out how to upload or even get captured image to react back-end, any ideas?</p>
| [
{
"answer_id": 74333930,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 0,
"selected": false,
"text": "ChromeDriverManager"
},
{
"answer_id": 74334863,
"author": "Eugeny Okulik",
"author_id": 12023661,
"author_profile": "https://Stackoverflow.com/users/12023661",
"pm_score": 0,
"selected": false,
"text": "pip install --upgrade pip\n"
},
{
"answer_id": 74339932,
"author": "Francisco Frieza",
"author_id": 19520348,
"author_profile": "https://Stackoverflow.com/users/19520348",
"pm_score": 1,
"selected": false,
"text": "from packaging install version"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18683435/"
] |
74,331,660 | <p>I came across this example when looking at <code>std::enable_if</code>:</p>
<pre><code>template<class T,
typename = std::enable_if_t<std::is_array<T>::value> >
void destroy(T* t)
{
for(std::size_t i = 0; i < std::extent<T>::value; ++i) {
destroy((*t)[i]);
}
}
</code></pre>
<p>In template argument lists, you can put untemplated classes/structs. So the above code is still possible when we remove the <code>typename =</code>. What does the <code>typename =</code> in this code mean and do?</p>
| [
{
"answer_id": 74331714,
"author": "Remy Lebeau",
"author_id": 65863,
"author_profile": "https://Stackoverflow.com/users/65863",
"pm_score": 4,
"selected": true,
"text": "typename"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19333949/"
] |
74,331,680 | <p>I am trying to dynamically create a list of links to files in a static folder and failing with nested {{ {{ }} }} that would be logically required.</p>
<p>A Flask server has files in</p>
<pre><code>/Static/FileFolder
</code></pre>
<p>they are collected in a list with</p>
<pre><code>FileList = []
for path in os.listdir(FileFolderPath):
if os.path.isfile(os.path.join(FileFolderPath, path)):
Filelist.append(path)
</code></pre>
<p>the Link is built with</p>
<pre><code>return render_template('list.html', FileList = FileList)
</code></pre>
<p>and the Html has this piece</p>
<pre><code>{% for item in FileList %}
<li><a href=" {{url_for('static', filename=' {{item}} ') }}">{{item}}</a> </li>
{% endfor %}
</code></pre>
<p>which fails as</p>
<pre><code>filename=' {{item}} '
</code></pre>
<p>does not give me the url for the link to the file but just a nonsense link to</p>
<pre><code>http://127.0.0.1:5020/static/%20%7B%7Bitem%7D%7D%20
</code></pre>
<p>which has the wrong folder and name. So how can i give the correct folder and place a link to a {{item}} inside a {{ }} used for url_for ?</p>
| [
{
"answer_id": 74331714,
"author": "Remy Lebeau",
"author_id": 65863,
"author_profile": "https://Stackoverflow.com/users/65863",
"pm_score": 4,
"selected": true,
"text": "typename"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331680",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12713674/"
] |
74,331,722 | <p>I am trying to split texts into "steps"
Lets say my text is</p>
<pre><code>my $steps = "1.Do this. 2.Then do that. 3.And then maybe that. 4.Complete!"
</code></pre>
<p>I'd like the output to be:</p>
<pre><code>"1.Do this."
"2.Then do that."
"3.And then maybe that."
"4.Complete!"
</code></pre>
<p>I'm not really that good with regex so help would be great!</p>
<p>I've tried many combination like:</p>
<pre><code>split /(\s\d.)/
</code></pre>
<p>But it splits the numbering away from text</p>
| [
{
"answer_id": 74331989,
"author": "ikegami",
"author_id": 589924,
"author_profile": "https://Stackoverflow.com/users/589924",
"pm_score": 2,
"selected": false,
"text": "split"
},
{
"answer_id": 74332049,
"author": "zdim",
"author_id": 4653379,
"author_profile": "https://Stackoverflow.com/users/4653379",
"pm_score": 2,
"selected": false,
"text": "my @s = $steps =~ / [0-9]+\\. [^0-9]+ /xg; \n\nsay for @s;\n"
},
{
"answer_id": 74343821,
"author": "Polar Bear",
"author_id": 12313309,
"author_profile": "https://Stackoverflow.com/users/12313309",
"pm_score": 0,
"selected": false,
"text": "%steps"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20428539/"
] |
74,331,754 | <p>My typescript package contains a global type file that defines the <code>history</code> object like this:</p>
<p>lib.dom.d.ts</p>
<pre><code>interface History {
readonly length: number;
scrollRestoration: ScrollRestoration;
readonly state: any;
back(): void;
forward(): void;
go(delta?: number): void;
pushState(data: any, unused: string, url?: string | URL | null): void;
replaceState(data: any, unused: string, url?: string | URL | null): void;
}
declare var history: History;
</code></pre>
<p>I'd like to tell the compiler that the <code>state</code> property has a <code>key</code> property.</p>
<p>I tried this:</p>
<pre><code>declare global {
interface TypedHistory extends History {
state: { key: string };
}
var history: TypedHistory;
}
console.log(history.state.key);
</code></pre>
<p>But I'm getting this error:
<code>Subsequent variable declarations must have the same type. Variable 'history' must be of type 'History', but here has type 'TypedHistory'.</code></p>
<p>How would I accomplish this? Preferably by declaring it in the same file I'm using the <code>history</code> object.</p>
<p>I'm not concerned whether or not this type definition always holds true, just how to accomplish this.</p>
| [
{
"answer_id": 74331768,
"author": "Dakeyras",
"author_id": 1857909,
"author_profile": "https://Stackoverflow.com/users/1857909",
"pm_score": 0,
"selected": false,
"text": "history"
},
{
"answer_id": 74331771,
"author": "Chris Hamilton",
"author_id": 12914833,
"author_profile": "https://Stackoverflow.com/users/12914833",
"pm_score": 2,
"selected": true,
"text": "declare global {\n interface TypedHistory extends History {\n state: { key: string };\n }\n}\n\ndeclare var history: TypedHistory;\n"
},
{
"answer_id": 74335584,
"author": "Dimava",
"author_id": 5734961,
"author_profile": "https://Stackoverflow.com/users/5734961",
"pm_score": 0,
"selected": false,
"text": "declare global {\n interface History {\n key: 123\n }\n}\n\nhistory.key // 123\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12914833/"
] |
74,331,755 | <p>Currently taking CS50 Web Programming with Python and Javascript. I'm on the Week 3 Django lecture and trying to follow along but I'm running into trouble while trying to run python manage.py run server.</p>
<p>I'm getting the "ImportError: Couldn't import Django. Are you sure it's installed and available on your PYTHONPATH environment variable? Did you forget to activate a virtual environment?" error.</p>
<p>I'm using Windows, Django IS installed and I've reinstalled it multiple times. I've found a workaround by following the steps from <a href="https://www.youtube.com/watch?v=eJdfsrvnhTE&t=296s" rel="nofollow noreferrer">https://www.youtube.com/watch?v=eJdfsrvnhTE&t=296s</a> to set up a virtual env and can proceed after that, but in the lecture Brian doesn't need to setup a virtual env? It just loads straight through for him?</p>
<p>Yes I have scoured through reddit, stackoverflow, youtube, and other articles online before asking this here. It's not too much trouble to do so but I'm just wondeirng why he didn't need to make a virtualenv and if I'm actually going to have to make a virtual env for every Django project going forward? Is it because things have changed with python/pip/Django?</p>
<p>I would just find it more convenient if I could just run the run server command without having to run the extra 4 commands to setup the virtual env before being able to runserver.</p>
<p>Any info or guidance on this would be much appreciated. Thank you.</p>
<p>I have a workaround. I'm just wondering why in the lecture he didn't need to create a virtual env for it to work.</p>
| [
{
"answer_id": 74331933,
"author": "T. Bill",
"author_id": 8341684,
"author_profile": "https://Stackoverflow.com/users/8341684",
"pm_score": 0,
"selected": false,
"text": "python manage.py runserver"
},
{
"answer_id": 74332002,
"author": "Kings_M",
"author_id": 12904301,
"author_profile": "https://Stackoverflow.com/users/12904301",
"pm_score": -1,
"selected": false,
"text": "python -m django --version"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331755",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19002425/"
] |
74,331,856 | <p>So, React has UseState hook, and we should use it like this.</p>
<pre><code>const [value, setValue] = useState(0);
</code></pre>
<p>And if we want to change a value, it should be written like this:</p>
<pre><code>const increase = () => {
setValue(value + 1)
}
</code></pre>
<p>Why it's not possible to write it like this? Why we need setValue?</p>
<pre><code>const increase = () => {
return value + 1;
}
</code></pre>
<p>I understand that it just doesn't work, but I couldn't find an explanation why it is like that.</p>
| [
{
"answer_id": 74331992,
"author": "Balaji KR",
"author_id": 17787336,
"author_profile": "https://Stackoverflow.com/users/17787336",
"pm_score": 0,
"selected": false,
"text": "setValue()"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10331051/"
] |
74,331,861 | <p>I want to group and aggregate and then calculate a ratio based on values in a certain column.</p>
<p>In R it's pretty straight forward.</p>
<pre><code>df = data.frame(a = c('a', 'a', 'b', 'b'),
b = c('x', 'y', 'x', 'y'),
value = 1:4)
df %>%
group_by(a) %>%
summarise(calc = value[b == 'x']/value[b == 'y']) ## (1/2) and (3/4)
</code></pre>
<p>In python I tried</p>
<pre><code>df = pd.DataFrame({'a': ['a', 'a', 'b', 'b'],
'b': ['x', 'y', 'x', 'y'],
'value': [1, 2, 3, 4]})
df.groupby('a').agg(df[df['b'] == 'x'] / df[df['b'] == 'y'])
</code></pre>
<p>But its throwing errors</p>
| [
{
"answer_id": 74332113,
"author": "Anoushiravan R",
"author_id": 14314520,
"author_profile": "https://Stackoverflow.com/users/14314520",
"pm_score": 2,
"selected": false,
"text": "import pandas as pd\nimport numpy as np\n\ncond1 = lambda x: x['value'].loc[x['b'].eq('x')].to_numpy()\ncond2 = lambda x: x['value'].loc[x['b'].eq('y')].to_numpy()\n\n(df.groupby('a').apply(lambda x: (cond1(x) / cond2(x))[0])\n .reset_index(name = 'result'))\n\n a result\n0 a 0.50\n1 b 0.75\n"
},
{
"answer_id": 74334496,
"author": "onyambu",
"author_id": 8380272,
"author_profile": "https://Stackoverflow.com/users/8380272",
"pm_score": 1,
"selected": false,
"text": "df.pivot('a', 'b', 'value').assign(calc = lambda x: x.x/x.y).reset_index()\n \nb a x y calc\n0 a 1 2 0.50\n1 b 3 4 0.75\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331861",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5319229/"
] |
74,331,876 | <p>Without relying on <code>const_cast</code>, how can one make a C++ data member <code>const</code> <em>after but not during</em> construction when there is an expensive-to-compute intermediate value that is needed to calculate multiple data members?</p>
<p>The following minimal, complete, verifiable example further explains the question and its reason. To avoid wasting your time, I recommend that you begin by reading the example's two comments.</p>
<pre><code>#include <iostream>
namespace {
constexpr int initializer {3};
constexpr int ka {10};
constexpr int kb {25};
class T {
private:
int value;
const int a_;
const int b_;
public:
T(int n);
inline int operator()() const { return value; }
inline int a() const { return a_; }
inline int b() const { return b_; }
int &operator--();
};
T::T(const int n): value {n - 1}, a_ {0}, b_ {0}
{
// The integer expensive
// + is to be computed only once and,
// + after the T object has been constructed,
// is not to be stored.
// These requirements must be met without reliance
// on the compiler's optimizer.
const int expensive {n*n*n - 1};
const_cast<int &>(a_) = ka*expensive;
const_cast<int &>(b_) = kb*expensive;
}
int &T::operator--()
{
--value;
// To alter a_ or b_ is forbidden. Therefore, the compiler
// must abort compilation if the next line is uncommented.
//--a_; --b_;
return value;
}
}
int main()
{
T t(initializer);
std::cout << "before decrement, t() == " << t() << "\n";
--t;
std::cout << "after decrement, t() == " << t() << "\n";
std::cout << "t.a() == " << t.a() << "\n";
std::cout << "t.b() == " << t.b() << "\n";
return 0;
}
</code></pre>
<p>Output:</p>
<pre><code>before decrement, t() == 2
after decrement, t() == 1
t.a() == 260
t.b() == 650
</code></pre>
<p>(I am aware of <a href="https://stackoverflow.com/q/13458512/1275653">this previous, beginner's question,</a> but it treats an elementary case. Please see my comments in the code above. My trouble is that I have an expensive initialization I do not wish to perform twice, whose intermediate result I do not wish to store; whereas I still wish the compiler to protect my constant data members once construction is complete. I realize that some C++ programmers avoid constant data members on principle but this is a matter of style. I am not asking how to avoid constant data members; I am asking how <em>to implement</em> them in such a case as mine without resort to <code>const_cast</code> and without wasting memory, execution time, or runtime battery charge.)</p>
<p><strong>FOLLOW-UP</strong></p>
<p>After reading the several answers and experimenting on my PC, I believe that I have taken the wrong approach and, therefore, asked the wrong question. Though C++ does afford <code>const</code> data members, their use tends to run contrary to normal data paradigms. What <em>is</em> a <code>const</code> data member of a variable object, after all? It isn't really constant in the usual sense, is it, for one can overwrite it by using the <code>=</code> operator on its parent object. It is awkward. It does not suit its intended purpose.</p>
<p>@Homer512's comment illustrates the trouble with my approach:</p>
<blockquote>
<p>Don't overstress yourself into making members <code>const</code> when it is inconvenient. If anything, it can lead to inefficient code generation, e.g. by making move-construction fall back to copy constructions.</p>
</blockquote>
<p>The right way to prevent inadvertent modification to data members that should not change is apparently, simply to provide no interface to change them—and if it is necessary to protect the data members from the class's own member functions, why, @Some programmer dude's answer shows how to do this.</p>
<p>I now doubt that it is possible to handle <code>const</code> data members smoothly in C++. The <code>const</code> is protecting the wrong thing in this case.</p>
| [
{
"answer_id": 74331916,
"author": "Igor Tandetnik",
"author_id": 1670129,
"author_profile": "https://Stackoverflow.com/users/1670129",
"pm_score": 3,
"selected": false,
"text": "class T {\nprivate:\n T(int n, int expensive)\n : value{n-1}, a_{ka*expensive}, b_{kb*expensive} {}\npublic:\n T(int n) : T(n, n*n*n - 1) {}\n};\n"
},
{
"answer_id": 74331917,
"author": "Some programmer dude",
"author_id": 440558,
"author_profile": "https://Stackoverflow.com/users/440558",
"pm_score": 4,
"selected": true,
"text": "a"
},
{
"answer_id": 74332027,
"author": "lorro",
"author_id": 6292621,
"author_profile": "https://Stackoverflow.com/users/6292621",
"pm_score": 1,
"selected": false,
"text": "struct ExpensiveResult\n{\n int expensive;\n\n ExpensiveResult(int n)\n : expensive(n*n*n - 1)\n {}\n};\n\nclass T\n{\nprivate:\n const int a;\n const int b;\n\n T(const ExpensiveResult& e)\n : a(ka * e.expensive)\n , b(kb * e.expensive)\n {}\n};\n"
},
{
"answer_id": 74332856,
"author": "doug",
"author_id": 5282154,
"author_profile": "https://Stackoverflow.com/users/5282154",
"pm_score": 1,
"selected": false,
"text": "construct_at"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1275653/"
] |
74,331,877 | <p>So I have this dataset of temperatures. Each line describe the temperature in celsius measured by hour in a day.
<a href="https://i.stack.imgur.com/FfaUN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FfaUN.png" alt="enter image description here" /></a></p>
<p>So, I need to compute a new variable called avg_temp_ar_mensal which representsthe average temperature of a city in a month. City in this dataset is represented as estacao and month as mes.</p>
<p>I'm trying to do this using pandas. The following line of code is the one I'm trying to use to solve this problem:</p>
<p><code> df2['avg_temp_ar_mensal'] = df2['temp_ar'].groupby(df2['mes', 'estacao']).mean()</code></p>
<p>The goal of this code is to store in a new column the average of the temperature of the city and month. But it doesn't work. If I try the following line of code:</p>
<p><code> df2['avg_temp_ar_mensal'] = df2['temp_ar'].groupby(df2['mes']).mean()</code></p>
<p>It will works, but it is wrong. It will calculate for every city of the dataset and I don't want it because it will cause noise in my data. I need to separate each temperature based on month and city and then calculate the mean.</p>
| [
{
"answer_id": 74331916,
"author": "Igor Tandetnik",
"author_id": 1670129,
"author_profile": "https://Stackoverflow.com/users/1670129",
"pm_score": 3,
"selected": false,
"text": "class T {\nprivate:\n T(int n, int expensive)\n : value{n-1}, a_{ka*expensive}, b_{kb*expensive} {}\npublic:\n T(int n) : T(n, n*n*n - 1) {}\n};\n"
},
{
"answer_id": 74331917,
"author": "Some programmer dude",
"author_id": 440558,
"author_profile": "https://Stackoverflow.com/users/440558",
"pm_score": 4,
"selected": true,
"text": "a"
},
{
"answer_id": 74332027,
"author": "lorro",
"author_id": 6292621,
"author_profile": "https://Stackoverflow.com/users/6292621",
"pm_score": 1,
"selected": false,
"text": "struct ExpensiveResult\n{\n int expensive;\n\n ExpensiveResult(int n)\n : expensive(n*n*n - 1)\n {}\n};\n\nclass T\n{\nprivate:\n const int a;\n const int b;\n\n T(const ExpensiveResult& e)\n : a(ka * e.expensive)\n , b(kb * e.expensive)\n {}\n};\n"
},
{
"answer_id": 74332856,
"author": "doug",
"author_id": 5282154,
"author_profile": "https://Stackoverflow.com/users/5282154",
"pm_score": 1,
"selected": false,
"text": "construct_at"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331877",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18085406/"
] |
74,331,883 | <p>What I'm trying to do is simply find and define an x and y coordinate for the highest number in the array.</p>
<p>For example, 50000 would output: x = 2, y = 2. Is there an easy way to accomplish this?</p>
<p>I created this code below:</p>
<pre><code>data_array = [[0, 1, 2, 3, 50000],
[5, 6, 7, 8, 9],
[10, 11, 12, 13, 14],
[15, 16, 17, 18, 19],
[20, 21, 22, 23, 24]]
highest_num = data_array[0][0]
x = 0
y = 0
# looping from 0 to len(data_array)-1
for i in range(len(data_array)):
# looping from 0 to len(data_array[i])-1
for j in range(len(data_array[i])):
# checking data_array[x][y] is less than data_array[i][j]
if data_array[x][y] < data_array[i][j]:
# updating x and y
x = i
y = j
highest_num = data_array[i][j]
# printing the values of highest_num, x and y
print("highest_num =", highest_num)
print("x =", x)
print("y =", y)
</code></pre>
<p>But I would get x = 0, y = 4. I wanted to reference the middle of the array which is 12 and make the output be x = 2, y = 2.</p>
<p>Can this be accomplished without numpy where? I want the points to track with the max wherever it is.</p>
| [
{
"answer_id": 74331916,
"author": "Igor Tandetnik",
"author_id": 1670129,
"author_profile": "https://Stackoverflow.com/users/1670129",
"pm_score": 3,
"selected": false,
"text": "class T {\nprivate:\n T(int n, int expensive)\n : value{n-1}, a_{ka*expensive}, b_{kb*expensive} {}\npublic:\n T(int n) : T(n, n*n*n - 1) {}\n};\n"
},
{
"answer_id": 74331917,
"author": "Some programmer dude",
"author_id": 440558,
"author_profile": "https://Stackoverflow.com/users/440558",
"pm_score": 4,
"selected": true,
"text": "a"
},
{
"answer_id": 74332027,
"author": "lorro",
"author_id": 6292621,
"author_profile": "https://Stackoverflow.com/users/6292621",
"pm_score": 1,
"selected": false,
"text": "struct ExpensiveResult\n{\n int expensive;\n\n ExpensiveResult(int n)\n : expensive(n*n*n - 1)\n {}\n};\n\nclass T\n{\nprivate:\n const int a;\n const int b;\n\n T(const ExpensiveResult& e)\n : a(ka * e.expensive)\n , b(kb * e.expensive)\n {}\n};\n"
},
{
"answer_id": 74332856,
"author": "doug",
"author_id": 5282154,
"author_profile": "https://Stackoverflow.com/users/5282154",
"pm_score": 1,
"selected": false,
"text": "construct_at"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19563976/"
] |
74,331,918 | <p>I am trying to compile the ANTLR4 runtime sources
with GCC compiler and MinGW libraries. Is that
possible.</p>
<p>My development environment :
Windows 10, CodeBlocks, GCC, MinGW libraries</p>
<p>Compilation stops with the following error :</p>
<blockquote>
<p>error: 'mutex' in namespace 'std' does not name a type</p>
</blockquote>
<p>Kind regards
Pier Tilma</p>
| [
{
"answer_id": 74331916,
"author": "Igor Tandetnik",
"author_id": 1670129,
"author_profile": "https://Stackoverflow.com/users/1670129",
"pm_score": 3,
"selected": false,
"text": "class T {\nprivate:\n T(int n, int expensive)\n : value{n-1}, a_{ka*expensive}, b_{kb*expensive} {}\npublic:\n T(int n) : T(n, n*n*n - 1) {}\n};\n"
},
{
"answer_id": 74331917,
"author": "Some programmer dude",
"author_id": 440558,
"author_profile": "https://Stackoverflow.com/users/440558",
"pm_score": 4,
"selected": true,
"text": "a"
},
{
"answer_id": 74332027,
"author": "lorro",
"author_id": 6292621,
"author_profile": "https://Stackoverflow.com/users/6292621",
"pm_score": 1,
"selected": false,
"text": "struct ExpensiveResult\n{\n int expensive;\n\n ExpensiveResult(int n)\n : expensive(n*n*n - 1)\n {}\n};\n\nclass T\n{\nprivate:\n const int a;\n const int b;\n\n T(const ExpensiveResult& e)\n : a(ka * e.expensive)\n , b(kb * e.expensive)\n {}\n};\n"
},
{
"answer_id": 74332856,
"author": "doug",
"author_id": 5282154,
"author_profile": "https://Stackoverflow.com/users/5282154",
"pm_score": 1,
"selected": false,
"text": "construct_at"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18617454/"
] |
74,331,930 | <p>I have a task in where I am instructed to create a method that returns words from a string based on a given length. The specific instructions are as follows:</p>
<p><strong>This method will input a sentence with multiple words separated by spaces. The input number represents the size of the word we are looking for. Return a string array with all words found with the input size</strong></p>
<p><em>Example:</em></p>
<pre><code>String s = “Monday is a new day”;
int n = 3; //3 letter words
howManyWord(s, n) returns {“new”, “day”}
howManyWord(s, 2) returns {“is”}.
</code></pre>
<p>So far, this is my take at the solution. The main issue I am having is in the second for loop in terms of assigning words to the array itself</p>
<pre><code>public String[] howManyWord(String s, int n) {
//count the amount of words in the String
int counter1 = 0;
for(int a1 = 1; a1 < s.length(); a1++) {
char c1 = s.charAt(a1-1);
char c2 = s.charAt(a1);
if(c1 != ' ' && c2 == ' '){
counter1++;
}
}
counter1 += 1;
//Get the words of a string into an array + the loop in question
String[] words = new String[counter1];
String[] output = new String[counter1];
for(int a2 = 1; a2 < s.length(); a2++) {
char c1 = s.charAt(a2-1);
char c2 = s.charAt(a2);
int counter2 = 0;
if(c1 != ' ' && c2 == ' '){
int index1 = s.indexOf(c1);
int index2 = s.indexOf(c2);
words[counter2] = s.substring(index1, index2);
counter2++;
}
}
//assign words of a specific length into output array
for(int a3 = 0; a3 < output.length; a3++) {
if(words[a3].length() == n){
output[a3] = words[a3];
}
}
return output;
}
</code></pre>
<p>How would I go about this issue? Thanks!</p>
| [
{
"answer_id": 74332004,
"author": "Jens",
"author_id": 3636601,
"author_profile": "https://Stackoverflow.com/users/3636601",
"pm_score": 0,
"selected": false,
"text": "public static long howManyWord(String s, int n) {\n \n String[] words = s.split(\" \"); // split at blank to get all words\n return Arrays.stream(words).filter(s1 -> s1.length() == n).count(); // filter all words woth the length of n and count them\n}\n"
},
{
"answer_id": 74332047,
"author": "Bohemian",
"author_id": 256196,
"author_profile": "https://Stackoverflow.com/users/256196",
"pm_score": 3,
"selected": true,
"text": "split()"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20143802/"
] |
74,331,939 | <p>Let's say I have a function <code>f()</code> which I know accepts 1 argument, <code>action</code>, followed by a variable number of arguments.</p>
<p>Depending on the initial <code>action</code> value, the function expects a different set of following arguments, e.g. for action <code>1</code> we know we must have 3 extra arguments <code>p1</code>, <code>p2</code> and <code>p3</code>. Depending on how the function was called, these args can be either in <code>args</code> or `kwargs.</p>
<p>How do I retrieve them?</p>
<pre><code>def f(action, *args, **kwargs):
if action==1:
#we know that the function should have 3 supplementary arguments: p1, p2, p3
#we want something like:
#p1 = kwargs['p1'] OR args[0] OR <some default> (order matters?)
#p1 = kwargs['p1'] OR args[0] OR <some default>
#p1 = kwargs['p1'] OR args[0] OR <some default>
</code></pre>
<p>Note that:</p>
<pre><code>f(1, 3, 4, 5)
f(1,p1=3, p2=4, p3=5)
f(1, 2, p2=4, p3=5)
</code></pre>
<p>will place the different <code>p1</code>, <code>p2</code>, <code>p3</code> parameters in either <code>args</code> or <code>kwargs</code>. I could try with nested try/except statements, like:</p>
<pre><code>try:
p1=kwargs['p1']
except:
try:
p1=args[0]
except:
p1=default
</code></pre>
<p>but it does not feel right.</p>
| [
{
"answer_id": 74331995,
"author": "Dr. V",
"author_id": 7078614,
"author_profile": "https://Stackoverflow.com/users/7078614",
"pm_score": 3,
"selected": true,
"text": "f"
},
{
"answer_id": 74332094,
"author": "juanfe888",
"author_id": 20428849,
"author_profile": "https://Stackoverflow.com/users/20428849",
"pm_score": 2,
"selected": false,
"text": "def f(action, *args, **kwargs):\n if action==1:\n p1=kwargs.get('p1') or args[0] if len(args)>0 else 'default'\n ...\n"
},
{
"answer_id": 74332119,
"author": "Iliya",
"author_id": 16376310,
"author_profile": "https://Stackoverflow.com/users/16376310",
"pm_score": 1,
"selected": false,
"text": "from collections import OrderedDict\n\n\ndef f(action, *args, **kwargs):\n params = OrderedDict({\n 'p1': 'default',\n 'p2': 'default',\n 'p3': 'default',\n })\n\n if action == 1:\n for index, param in enumerate(params.keys()):\n if index < len(args):\n params[param] = kwargs[param] if param in kwargs else args[index]\n else:\n params[param] = kwargs[param] if param in kwargs else params[param]\n\n # Do something with `params`.\n\n\nf(1, 3, 4, 5)\nf(1, p1=3, p2=4, p3=5)\nf(1, 2, p2=4, p3=5)\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331939",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1159290/"
] |
74,331,984 | <p>Have this struct of User and Post and I try to make Name from User to be included within Post Struct when a user create a new post.</p>
<pre><code>type User struct {
ID int
Name string
Created time.Time
}
type Post struct {
ID int
PostTitle string
PostDesc string
Created time.Time
}
</code></pre>
<p>How can I create something connected between this two struct such as Author of the Post ?</p>
<p>The goal is try to get the name of the post author which from User struct with the code below:</p>
<pre><code>post, err := app.Models.Posts.GetPost(id)
</code></pre>
<p>GetPost() just run SELECT query and scan row</p>
| [
{
"answer_id": 74331995,
"author": "Dr. V",
"author_id": 7078614,
"author_profile": "https://Stackoverflow.com/users/7078614",
"pm_score": 3,
"selected": true,
"text": "f"
},
{
"answer_id": 74332094,
"author": "juanfe888",
"author_id": 20428849,
"author_profile": "https://Stackoverflow.com/users/20428849",
"pm_score": 2,
"selected": false,
"text": "def f(action, *args, **kwargs):\n if action==1:\n p1=kwargs.get('p1') or args[0] if len(args)>0 else 'default'\n ...\n"
},
{
"answer_id": 74332119,
"author": "Iliya",
"author_id": 16376310,
"author_profile": "https://Stackoverflow.com/users/16376310",
"pm_score": 1,
"selected": false,
"text": "from collections import OrderedDict\n\n\ndef f(action, *args, **kwargs):\n params = OrderedDict({\n 'p1': 'default',\n 'p2': 'default',\n 'p3': 'default',\n })\n\n if action == 1:\n for index, param in enumerate(params.keys()):\n if index < len(args):\n params[param] = kwargs[param] if param in kwargs else args[index]\n else:\n params[param] = kwargs[param] if param in kwargs else params[param]\n\n # Do something with `params`.\n\n\nf(1, 3, 4, 5)\nf(1, p1=3, p2=4, p3=5)\nf(1, 2, p2=4, p3=5)\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74331984",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15370616/"
] |
74,332,068 | <p>I have a really specific problem and can't think of an answer.</p>
<p>I have a function to generate a letter H or V.</p>
<p>I want to make that if the generator exceedes the limit for H to pick V and if the limit for V gets exceeded to pick H.</p>
<p>Example</p>
<p>Limit for H is 10
Limit for V is 10</p>
<pre><code>function generateLetter(){
let result = randomLetter; // Just pseudocode it picks H or V
if The limit for H is exceeded to pick
}
</code></pre>
<p>the result would be the letter H 10 times and letter V 10 times.</p>
<p>This is my code</p>
<p>H5 = Limit for H number
V5 = Limit for V number</p>
<pre><code>function generateType(h5, v5){
let type = ["H", "V"];
let randomType = Math.round(Math.random());
let selectedType = type[randomType];
if(totalH < h5 && selectedType == "H"){
totalH += 1;
}
if(totalV < v5 && selectedType == "V"){
totalV += 1;
}
if(totalH >= h5 && totalV < v5){
selectedType = "V";
}
if(totalV >= v5 && totalH < h5){
selectedType = "H";
}
return selectedType;
}
</code></pre>
<p><strong>EDIT</strong></p>
<p>I have a for loop that loops like 20 times</p>
<pre><code>let text = [];
for(let i = 0; i < 20; i++){
text1 = generateType();
text.push(text1);
}
</code></pre>
<p>I want to make it so that there is exactly 10 H and 10 V
or any number i choose</p>
<p>This is the entire Code</p>
<p>worker.js Using Web Workers</p>
<pre><code>
let letters = ["a", "b", "c", "d", "e", "f", "g", "h", "i", "j", "k", "l", "m", "n", "o", "p", "q","r", "s", "t", "u", "v", "w", "x", "y", "z"];
let tags = [];
let items = [];
let index = 0;
let textBack = "";
var hA = 0;
var vA = 0;
var minA;
var maxA;
let totalH = 0;
let totalV = 0;
function saveDATA(min, max, h, v){
minA = min;
maxA = max;
hA = Math.round(h / 50);
vA = Math.round(v / 50);
}
function generateTags(totalTags){
let tag;
for(let i = 0; i < totalTags; i++){
let r1 = Math.ceil(Math.random() * 15);
let r2 = Math.ceil(Math.random() * 7);
let r3 = Math.ceil(Math.random() * 5);
let r4 = Math.ceil(Math.random() * 9);
let r5 = Math.ceil(Math.random() * 17);
// console.log(r1, r2, r3, r4, r5);
tag = letters[r1] + letters[r2] + letters[r3] + letters[r4] + letters[r5];
if(tags.includes(tag)){
// Do nothing
let random = Math.round(Math.random());
if(random == 1){
tags.push(tag);
tags.concat(tag);
}
} else{
tags.push(tag);
tags.concat(tag);
tags.push(tag);
tags.concat(tag);
items.push(tag);
}
if(totalTags < 2){
return tag;
}
}
}
function generateType(h5, v5){
let type = ["H", "V"];
let randomType = Math.round(Math.random());
let selectedType = type[randomType];
if(totalH < h5 && selectedType == "H"){
totalH += 1;
}
if(totalV < v5 && selectedType == "V"){
totalV += 1;
}
if(totalH >= h5 && totalV < v5){
selectedType = "V";
}
if(totalV >= v5 && totalH < h5){
selectedType = "H";
}
return selectedType;
}
function getRandomInt(min, max) {
let minB, maxB;
minB = Math.ceil(Number(min));
maxB = Math.floor(Number(max));
return Math.floor(Math.random() * (maxB - minB + 1)) + minB;
}
function generateTagsInsideItem(){
let totalTags = getRandomInt(minA, maxA);
return totalTags;
}
function generateTagsItem(h4, v4){
let totalTags = generateTagsInsideItem();
let tags = "";
for(let i = 0; i < totalTags; i++) {
tags += " " + generateTags(1);
}
let text = generateType(h4, v4) + " " + totalTags + " " + tags;
return text;
}
function generateDocumnet(id, items, horizontal, vertical) {
hA = Math.round(Number(horizontal) / 50);
vA = Math.round(Number(vertical) / 50);
let totalItems = items;
for(let i = 0; i < totalItems; i++){
textBack += "\n" + generateTagsItem(hA, vA);
}
}
self.addEventListener("message", function(e) {
saveDATA(e.data.minimum, e.data.maximum, e.data.horizontal, e.data.vertical);
generateDocumnet(e.data.id, e.data.count, e.data.horizontal, e.data.vertical);
this.postMessage({id: e.data.id , result: textBack});
}, false);
</code></pre>
| [
{
"answer_id": 74331995,
"author": "Dr. V",
"author_id": 7078614,
"author_profile": "https://Stackoverflow.com/users/7078614",
"pm_score": 3,
"selected": true,
"text": "f"
},
{
"answer_id": 74332094,
"author": "juanfe888",
"author_id": 20428849,
"author_profile": "https://Stackoverflow.com/users/20428849",
"pm_score": 2,
"selected": false,
"text": "def f(action, *args, **kwargs):\n if action==1:\n p1=kwargs.get('p1') or args[0] if len(args)>0 else 'default'\n ...\n"
},
{
"answer_id": 74332119,
"author": "Iliya",
"author_id": 16376310,
"author_profile": "https://Stackoverflow.com/users/16376310",
"pm_score": 1,
"selected": false,
"text": "from collections import OrderedDict\n\n\ndef f(action, *args, **kwargs):\n params = OrderedDict({\n 'p1': 'default',\n 'p2': 'default',\n 'p3': 'default',\n })\n\n if action == 1:\n for index, param in enumerate(params.keys()):\n if index < len(args):\n params[param] = kwargs[param] if param in kwargs else args[index]\n else:\n params[param] = kwargs[param] if param in kwargs else params[param]\n\n # Do something with `params`.\n\n\nf(1, 3, 4, 5)\nf(1, p1=3, p2=4, p3=5)\nf(1, 2, p2=4, p3=5)\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74332068",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13642569/"
] |
74,332,075 | <p>Im trying to thrown an error from inside an for..of loop that sums array elements. In this case when it is present an object and array as part of the array. Jasmine is passing me all tests except this one. I'll show you my code. Keep in mind i've been learning for two weeks and stuff like .catch and .try I think shouldn't be needed for this exercise. Thanks in advance!</p>
<pre><code>const mixedArr = [6, 12, 'miami', 1, true, 'barca', '200', 'lisboa', 8, 10,
{ "color": "purple",
"type": "minivan"}]
function sum(mix) {
if (mix.length === 0) return 0;
let mixedSum = 0;
for (element of mix) {
if (typeof element === 'string') {
mixedSum += element.length;
} else if (typeof element === 'array' || typeof element === 'object') {
throw new error('error')
} else { mixedSum += element }
}
return mixedSum;
};
console.log(sum(mixedArr))
</code></pre>
<p><a href="https://i.stack.imgur.com/NInDE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NInDE.png" alt="enter image description here" /></a>`</p>
<p>I tried to create a new throw that prints a new error. I have seen some throw exercises where they dont use stuff like try and catch, but im obviously missing something here. The goal is to pass the jasmine test.</p>
| [
{
"answer_id": 74331995,
"author": "Dr. V",
"author_id": 7078614,
"author_profile": "https://Stackoverflow.com/users/7078614",
"pm_score": 3,
"selected": true,
"text": "f"
},
{
"answer_id": 74332094,
"author": "juanfe888",
"author_id": 20428849,
"author_profile": "https://Stackoverflow.com/users/20428849",
"pm_score": 2,
"selected": false,
"text": "def f(action, *args, **kwargs):\n if action==1:\n p1=kwargs.get('p1') or args[0] if len(args)>0 else 'default'\n ...\n"
},
{
"answer_id": 74332119,
"author": "Iliya",
"author_id": 16376310,
"author_profile": "https://Stackoverflow.com/users/16376310",
"pm_score": 1,
"selected": false,
"text": "from collections import OrderedDict\n\n\ndef f(action, *args, **kwargs):\n params = OrderedDict({\n 'p1': 'default',\n 'p2': 'default',\n 'p3': 'default',\n })\n\n if action == 1:\n for index, param in enumerate(params.keys()):\n if index < len(args):\n params[param] = kwargs[param] if param in kwargs else args[index]\n else:\n params[param] = kwargs[param] if param in kwargs else params[param]\n\n # Do something with `params`.\n\n\nf(1, 3, 4, 5)\nf(1, p1=3, p2=4, p3=5)\nf(1, 2, p2=4, p3=5)\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74332075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19805012/"
] |
74,332,129 | <p>i am tryng to make an IF function for a value of opacity and then divide it by 10 to get a decimal in a range between <code>(0.9 to 0.0)</code>, the function works when there is no value <code>(!e.target.style.opacity)</code> and when opacityValue gets to <code>9</code>; but then it gets stucked in <code>8</code>, i want to trigger that event until opacity gets value to <code>0</code>;</p>
<pre><code>function toEternalDarkness(e) {
let opacityValue = 9;
let opacityDegree;
if (!e.target.style.opacity) {
opacityDegree = opacityValue / 10;
e.target.style.opacity = opacityDegree;
console.log(opacityValue);
} else if (opacityValue > 0) {
opacityValue--;
opacityDegree = opacityValue / 10;
console.log(opacityDegree);
e.target.style.opacity = opacityDegree;
} else {return}
</code></pre>
<p>i tryed to declare the opacityDegree inside the iIF statement and it didnt work<br />
i tryed to declare a new variable to store newOpacityValue and didnt work<br />
i tryed a while loop inside the IF ELSE statement and it runs all the loop until opacity gets to zero;</p>
<p>here is a link for the projects i am trying to solve:
<a href="https://github.com/AliQTank/Etch-a-Sketch/tree/Op002" rel="nofollow noreferrer">https://github.com/AliQTank/Etch-a-Sketch/tree/Op002</a></p>
<p>a Grid created by multiple divs that change color with event listener mouseover, so i did my container background color black to decrease opacity level 10 percent for every event listener triggered and after 10 events, the color has to be totally transparent.
somebody put a solution applyed to a button, and didnt work in my project because if i triggered my opacity in one cell(div) the other ones get triggered from the last opacityValue, at the end one cell is triggreder from opacity 1 to 0.8 other from 1 to 0.7 and the last ones get from opacity 1 to opacity 0</p>
| [
{
"answer_id": 74332157,
"author": "Michael M.",
"author_id": 13376511,
"author_profile": "https://Stackoverflow.com/users/13376511",
"pm_score": 1,
"selected": false,
"text": "const btn = document.getElementById('btn');\nbtn.addEventListener('click', () => {\n if (!btn.style.opacity) btn.style.opacity = '1';\n opacity = parseFloat(btn.style.opacity);\n btn.style.opacity = opacity - 0.2;\n});"
},
{
"answer_id": 74332265,
"author": "dale landry",
"author_id": 1533592,
"author_profile": "https://Stackoverflow.com/users/1533592",
"pm_score": 1,
"selected": false,
"text": "opacityValue-- / 10"
},
{
"answer_id": 74364044,
"author": "Alber_Quintana",
"author_id": 18758297,
"author_profile": "https://Stackoverflow.com/users/18758297",
"pm_score": 0,
"selected": false,
"text": "let opacityIndex = 10;\nlet opacityValue;\nvar opacityDegree;\n\nfunction toEternalDarkness(e) {\n opacityValue = opacityIndex -1;\n opacityDegree = opacityValue / 10;\n if (!e.target.style.opacity) {\n e.target.style.opacity = opacityDegree; \n } else if (e.target.style.opacity !== 0) {\n e.target.style.opacity -= 0.1;\n } else {return}\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74332129",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18758297/"
] |
74,332,171 | <p>I have 2 tables in a database, <code>users</code> and <code>users_removed</code> with columns "id(primary key), email(unique), password" and "id, user_id(foreign key (user_id) references users(id)" respectively.</p>
<p>When a user registers the <code>users</code> table gets the data accordingly. And when the user wants to delete account I can get user's id in <code>users_removed</code> and consider it deleted such as</p>
<pre><code>INSERT into users_removed (user_id)
VALUES ((SELECT id FROM users WHERE email = 'user@example.com'))
</code></pre>
<p>The <code>id</code> from <code>users</code> gets inserted into <code>users_removed</code> with a foreign key constraint.</p>
<p>Now the question is what will be the right way to get rid of data from <code>users</code> with that <code>id</code> but preserve it somehow.</p>
<ol>
<li>Deleting entirely is not an option because I loose data and so the purpose of the table <code>users_removed</code>. Also if I delete I get error "Cannot delete or update a parent row: a foreign key constraint fails" because of the foreign key constraint.</li>
<li>The user should be able to re-register with previous email but considering it an entirely new entry, as <code>email</code> in <code>users</code> is unique.</li>
</ol>
<p>Is there a way in sql to make certain data unable to be used, disallow to perform query on it, such as it gets ignored when I perform query in the backend.</p>
<p>Or what could be the possible ways to the solution?</p>
<p>I have a way of restricting <code>users_removed</code> to be able to login, but how should I proceed with the registration thing.</p>
| [
{
"answer_id": 74332157,
"author": "Michael M.",
"author_id": 13376511,
"author_profile": "https://Stackoverflow.com/users/13376511",
"pm_score": 1,
"selected": false,
"text": "const btn = document.getElementById('btn');\nbtn.addEventListener('click', () => {\n if (!btn.style.opacity) btn.style.opacity = '1';\n opacity = parseFloat(btn.style.opacity);\n btn.style.opacity = opacity - 0.2;\n});"
},
{
"answer_id": 74332265,
"author": "dale landry",
"author_id": 1533592,
"author_profile": "https://Stackoverflow.com/users/1533592",
"pm_score": 1,
"selected": false,
"text": "opacityValue-- / 10"
},
{
"answer_id": 74364044,
"author": "Alber_Quintana",
"author_id": 18758297,
"author_profile": "https://Stackoverflow.com/users/18758297",
"pm_score": 0,
"selected": false,
"text": "let opacityIndex = 10;\nlet opacityValue;\nvar opacityDegree;\n\nfunction toEternalDarkness(e) {\n opacityValue = opacityIndex -1;\n opacityDegree = opacityValue / 10;\n if (!e.target.style.opacity) {\n e.target.style.opacity = opacityDegree; \n } else if (e.target.style.opacity !== 0) {\n e.target.style.opacity -= 0.1;\n } else {return}\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74332171",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14148548/"
] |
74,332,182 | <p>I have this code in in Python with SymPy:</p>
<pre class="lang-py prettyprint-override"><code>import sympy
from sympy import symbols, Matrix
phi = symbols('phi')
x = symbols('x')
y = symbols('y')
N1 = sympy.cos(phi)
N2 = sympy.sin(phi)
N3 = -sympy.sin(phi)
N4 = sympy.cos(phi)
N1.subs('phi', sympy.Float(0.785))
N2.subs('phi', sympy.Float(0.785))
N3.subs('phi', sympy.Float(0.785))
N4.subs('phi', sympy.Float(0.785))
x=4
y=2
UVG = Matrix(2, 1, [x, y])
T = Matrix(2, 2, [N1, N2, N3, N4])
UVL = T*UVG
print("hi")
</code></pre>
<p>In debug mode the substitution of x =4 and y = 2 do seem to be working however the subs function does not seem to work for phi which is not being updated to an actual numerical value. I can see the output in my debug window where the value of UVL is showing as:</p>
<pre class="lang-py prettyprint-override"><code>Matrix([[2*sin(phi) + 4*cos(phi)], [-4*sin(phi) + 2*cos(phi)]])
</code></pre>
<p>Is there a way for SymPy to get the value of phi to change to an actual floating point or decimal type number so that I can get my transformed x and y back out?</p>
<p>I tried:</p>
<pre class="lang-py prettyprint-override"><code>N1.subs('phi', sympy.Float(0.785))
N2.subs('phi', sympy.Float(0.785))
N3.subs('phi', sympy.Float(0.785))
N4.subs('phi', sympy.Float(0.785))
</code></pre>
<p>and</p>
<pre class="lang-py prettyprint-override"><code>N1.subs(phi, sympy.Float(0.785))
N2.subs(phi, sympy.Float(0.785))
N3.subs(phi, sympy.Float(0.785))
N4.subs(phi, sympy.Float(0.785))
</code></pre>
<p>and</p>
<pre><code>phi = 0.785
</code></pre>
<p>none of which seem to work at all in terms of changing phi to a floating point or decimal value or similar type.</p>
| [
{
"answer_id": 74332521,
"author": "prusso",
"author_id": 20135706,
"author_profile": "https://Stackoverflow.com/users/20135706",
"pm_score": 0,
"selected": false,
"text": "T = Matrix(2, 2, [N1, N2, N3, N4]).subs('phi',0.785)\n"
},
{
"answer_id": 74332526,
"author": "smichr",
"author_id": 1089161,
"author_profile": "https://Stackoverflow.com/users/1089161",
"pm_score": 1,
"selected": false,
"text": "subs"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74332182",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20135706/"
] |
74,332,212 | <p>I'm trying to download download a zip file from this site:</p>
<p><a href="https://resultados.tse.jus.br/oficial/app/index.html#/eleicao/dados-de-urna;e=e545;uf=mg;ufbu=mg;mubu=40037;zn=0001;se=0101/log-da-urna" rel="nofollow noreferrer">https://resultados.tse.jus.br/oficial/app/index.html#/eleicao/dados-de-urna;e=e545;uf=mg;ufbu=mg;mubu=40037;zn=0001;se=0101/log-da-urna</a></p>
<p>After clicking the button "download *.zip file" the download is performed.</p>
<p>I'm trying to do this with the resquest because then I want to automate it and just change "zn" and "se" in the ulr</p>
<p>The problem is that I am not able to download the zip file with resquests</p>
<p>This is the code i'm trying, can anyone help me?</p>
<pre><code>import py7zr
import json
import requests
r = requests.get('https://resultados.tse.jus.br/oficial/ele2022/arquivo-urna/407/dados/mg/40037/0001/0101/494a2b7171725964614e41336a4362695a32425276596447384e42434d644d73356241416e76797a6c45513d/o00407-4003700010101.logjez')
r.status_code
r.text # the file appears to come but I think it's not the right way to do it, when I automate it to look for another section (if) I won't have the correct file name
</code></pre>
<p><a href="https://i.stack.imgur.com/4qnFA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/4qnFA.png" alt="enter image description here" /></a></p>
<p>How can I automate something like this without knowing what the name of the next file will be when I change the ulr?
Thanks!</p>
| [
{
"answer_id": 74335861,
"author": "baduker",
"author_id": 6106791,
"author_profile": "https://Stackoverflow.com/users/6106791",
"pm_score": 2,
"selected": true,
"text": "import os\nimport time\nimport urllib.parse\nfrom pathlib import Path\nfrom shutil import copyfileobj\n\nimport requests\n\nheaders = {\n \"User-Agent\": \"Mozilla/5.0 (Macintosh; Intel Mac OS X 10.15; rv:104.0) Gecko/20100101 Firefox/104.0\",\n \"Referer\": \"https://resultados.tse.jus.br/oficial/app/index.html\",\n}\n\n\ndef download_file(source_url: str, directory: str) -> None:\n os.makedirs(directory, exist_ok=True)\n save_dir = Path(directory)\n file_name = (\n f\"LogDeUrna_Totalizado_{int(time.time())}\"\n f\"_{source_url.rsplit('/', 1)[-1].replace('.logjez', '')}\"\n f\".vscmr.zip\"\n )\n destination = save_dir / file_name\n with s.get(source_url, stream=True) as file, open(destination, \"wb\") as output:\n copyfileobj(file.raw, output)\n\n\nwith requests.session() as s:\n s.headers.update(headers)\n base_url = 'https://resultados.tse.jus.br/oficial/app/index.html#/m/dados-da-urna;e=e545;uf=mg;ufbu=mg;mubu=40037;zn=0001;se=0101/log-de-urna'\n # deconstruct the url to get the query parameters\n url_parts = (\n urllib.parse\n .urlsplit(base_url.rstrip(\"/log-de-urna\").rsplit('/', 1)[-1])\n .path.split(';')[2:]\n )\n # build a map of the query parameters\n d = dict([part.split('=') for part in url_parts])\n\n # rebuild the API url with the query parameters\n api_url = f\"https://resultados.tse.jus.br/oficial/ele2022/arquivo-urna/407/dados/mg/\" \\\n f\"{d['mubu']}/{d['zn']}/{d['se']}/\" \\\n f\"p000407-mg-m{d['mubu']}-z{d['zn']}-s{d['se']}-aux.json\"\n # get the API response and extract the hashes\n hashes = s.get(api_url).json()['hashes'][0]\n # build the download url with the hashes and query parameters\n zip_url = f\"https://resultados.tse.jus.br/oficial/ele2022/arquivo-urna/407/dados/mg/\" \\\n f\"{d['mubu']}/{d['zn']}/{d['se']}/\" \\\n f\"{hashes['hash']}/{hashes['nmarq'][3]}\"\n # download the file\n download_file(zip_url, 'zip_files')\n"
},
{
"answer_id": 74407711,
"author": "Rafael Eller",
"author_id": 13425249,
"author_profile": "https://Stackoverflow.com/users/13425249",
"pm_score": 0,
"selected": false,
"text": "with py7zr.SevenZipFile(path_to_zipfile, 'r') as zip_ref:\n zip_ref.extractall(temp_dir)\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74332212",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11391978/"
] |
74,332,215 | <pre><code>def get_data(url):
r = requests.get(url)
soup = BeautifulSoup(r.text, 'html.parser')
return soup
current_data = get_data(link)
x = current_data.find_all(text="Style Code:")
</code></pre>
<p>I'm trying to get the style code of a shoe off ebay but the problem is that it doesn't have a specific class or any kind of unique identifier so I can't just use find() to get the data. Currently I searched by text to find 'Style Code:' but how can I get to the next div? An example of a shoe product page would be <a href="https://www.ebay.com/itm/295319451862?epid=5052193901&hash=item44c26938d6%3Ag%3AdaoAAOSwgzxjEOX9&amdata=enc%3AAQAHAAAAoEMZK%2BAt53WWy7KwuyWFgYOxBl3QiPjE4CvliMZHtIrWxjXKkweXW3BEssmmSLXA71DcNcn2Iwuqw%2FsNbjK%2B%2F5aF3tI2I7MLD0UmVoRivcuKztAMEtexAROaUYy4wxo5n1HxO8HnswPaZb55q1Nau1tQRnAplrOCB2jDeiLDawK2BaZJqiUnNbOOqulNUXqD9y591w%2FrgTJEiOEUxBMYvnI%3D%7Ctkp%3ABk9SR7adraGJYQ&LH_BIN=1&LH_ItemCondition=1000" rel="nofollow noreferrer">this.</a></p>
| [
{
"answer_id": 74332267,
"author": "Rahul K P",
"author_id": 4407666,
"author_profile": "https://Stackoverflow.com/users/4407666",
"pm_score": 1,
"selected": false,
"text": "spans = soup.find_all('span', attrs={'class':'ux-textspans'})\nstyle_code = None\nfor idx, span in enumerate(spans):\n if span.text == 'Style Code:':\n style_code = spans[idx+1].text\n break\nprint(style_code)\n# 554724-371\n"
},
{
"answer_id": 74332966,
"author": "αԋɱҽԃ αмєяιcαη",
"author_id": 7658985,
"author_profile": "https://Stackoverflow.com/users/7658985",
"pm_score": 2,
"selected": false,
"text": "soup.select_one('span.ux-textspans:-soup-contains(\"Style Code:\")').find_next('span').get_text(strip=True)\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74332215",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12850168/"
] |
74,332,226 | <p>Build tools it is specifically asking for are located at C:\Users\id\AppData\Local\Android\sdk\build-tools How do I tell cordova where to look?</p>
<p>I have set location value to ANDROID_HOME, ANDROID_SDK_HOME, ANDROID_BUILD, and ANDROID_SDK_ROOT and nothing works</p>
| [
{
"answer_id": 74332267,
"author": "Rahul K P",
"author_id": 4407666,
"author_profile": "https://Stackoverflow.com/users/4407666",
"pm_score": 1,
"selected": false,
"text": "spans = soup.find_all('span', attrs={'class':'ux-textspans'})\nstyle_code = None\nfor idx, span in enumerate(spans):\n if span.text == 'Style Code:':\n style_code = spans[idx+1].text\n break\nprint(style_code)\n# 554724-371\n"
},
{
"answer_id": 74332966,
"author": "αԋɱҽԃ αмєяιcαη",
"author_id": 7658985,
"author_profile": "https://Stackoverflow.com/users/7658985",
"pm_score": 2,
"selected": false,
"text": "soup.select_one('span.ux-textspans:-soup-contains(\"Style Code:\")').find_next('span').get_text(strip=True)\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74332226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18208694/"
] |
74,332,269 | <p>I'm doing a double linked list from scratch in C and was programming the iter(able) function.
However my struct has a bunch of fields and I don't necessarily want to mess with all when I call the function. I want to choose what member to alter in the function call.</p>
<pre><code>typedef struct s_command
{
int argc;
char *argv[MAXARGS];
t_token *args;
char **envp;
t_builtin builtin;
void *input;
void *output;
struct s_command *next;
struct s_command *prev;
} t_command;
</code></pre>
<p>My obvious choice was having an int argument that gets caught by an if else (can't use switch) to pick what field I want.
As such:</p>
<pre><code>void dll_iter(t_command *lst, int property, void (*f)(void *))
{
if (!lst || !property || !f)
return ;
while (lst)
{
if(property == 1)
f(lst->argc);
else if(property == 2)
f(lst->argv);
else if(property == 3)
f(lst->args);
...
lst = lst->next;
}
}
</code></pre>
<p>But I can't stop but wonder if C has any way to simplify this. Make it cleaner.
What I would really like was someting like:</p>
<pre><code>void dll_iter(t_command *lst, void (*f)(void *))
</code></pre>
<p>where <code>f</code> would call directly the member it wants.</p>
<p>Is there any way to achieve this?</p>
| [
{
"answer_id": 74332318,
"author": "Joshua",
"author_id": 14768,
"author_profile": "https://Stackoverflow.com/users/14768",
"pm_score": -1,
"selected": false,
"text": "void dll_iter(t_command *lst, void *(*decoder)(t_command *entry), void (*f)(void *argpointer))\n{\n if (!lst || !decoder || !f)\n return ;\n while (lst)\n {\n f(decoder(lst));\n lst = lst->next;\n }\n}\n\nvoid *decoder_argc(t_command *entry) { return &entry->argc; }\nvoid *decoder_argv(t_command *entry) { return &entry->argv; }\n//...\n"
},
{
"answer_id": 74332427,
"author": "StoryTeller - Unslander Monica",
"author_id": 817643,
"author_profile": "https://Stackoverflow.com/users/817643",
"pm_score": 2,
"selected": false,
"text": "struct link {\n struct link *next;\n struct link *prev;\n};\n\nstruct command {\n struct link link;\n // other members...\n};\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74332269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16498000/"
] |
74,332,279 | <p>I have a big number of lambdas, all sharing the same libraries. Due to size constraints I can not package the libraries together with the lambda neither use the Lambda Layers, so I have created a Docker image (let's call it lambda_base:latest) with all the required libraries installed and deployed it in ECR.</p>
<p>Now, for every lambda, I have created a new Docker image based on lambda_base:latest where the only difference is that includes the lambda's code and it is working fine.</p>
<p>My question is, am I proceeding ok? I would expect to deploy the lambda a one and being able to chose as "runtime" lambda:latest instead whatever image that AWS uses to run the lambda but I don't find how to do that.</p>
<p>Maybe what I am doing is ok but I found weird to create a image for every single lambda.</p>
<p>Thanks a lot!!!</p>
<p>I have created</p>
| [
{
"answer_id": 74332318,
"author": "Joshua",
"author_id": 14768,
"author_profile": "https://Stackoverflow.com/users/14768",
"pm_score": -1,
"selected": false,
"text": "void dll_iter(t_command *lst, void *(*decoder)(t_command *entry), void (*f)(void *argpointer))\n{\n if (!lst || !decoder || !f)\n return ;\n while (lst)\n {\n f(decoder(lst));\n lst = lst->next;\n }\n}\n\nvoid *decoder_argc(t_command *entry) { return &entry->argc; }\nvoid *decoder_argv(t_command *entry) { return &entry->argv; }\n//...\n"
},
{
"answer_id": 74332427,
"author": "StoryTeller - Unslander Monica",
"author_id": 817643,
"author_profile": "https://Stackoverflow.com/users/817643",
"pm_score": 2,
"selected": false,
"text": "struct link {\n struct link *next;\n struct link *prev;\n};\n\nstruct command {\n struct link link;\n // other members...\n};\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74332279",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/948425/"
] |
74,332,285 | <p>I am trying to assign classes into an element depending on whether or not a <code>boolean</code> is true. I was able to do this using <code>v-bind:class</code> for some classes. However now I want to do this again for another <code>boolean</code> at the same time. This is for a to-do list app.</p>
<p>my current code:</p>
<pre class="lang-html prettyprint-override"><code><div
v-bind:class="[task.checked ? '!bg-gray-800 text-gray-600 line-through' : 'none']"
v-bind:class="[task.checked ? '!bg-gray-800 text-gray-600 line-through' : 'none']"
class="tasks_container grid grid-cols-10"
v-for="task in tasks"
>
<!-- task for loop -->
</div>
</code></pre>
<pre class="lang-js prettyprint-override"><code>data() {
return {
note_text: ' ',
tasks: [
{
text: 'hello',
checked: false,
selected: true
},
{
text: 'world',
checked: false,
selected: false
}
]
};
},
</code></pre>
<p>I tried doing <strong>:</strong></p>
<pre class="lang-html prettyprint-override"><code><div
v-bind:class="[task.checked ? '!bg-gray-800 text-gray-600 line-through' : 'none']"
v-bind:class="[task.selected ? '!bg-gray-100' : 'none']"
class="tasks_container grid grid-cols-10"
v-for="task in tasks"
>
<!-- task for loop -->
</div>
</code></pre>
<p>this didn't work because you cant have multiple <code>v-bind:class</code></p>
<p>I also tried <strong>:</strong></p>
<pre class="lang-html prettyprint-override"><code><div
v-bind:class="[task.checked?'!bg-gray-800 text-gray-600 line-through':'none'], ['task.selected? !bg-gray-100':'none']"
v-for="task in tasks"
>
<!-- task for loop -->
</div>
</code></pre>
<p>that didn't work but I forget what is said for why. I'm sorry if my code has weird please let me know how I can fix that I'm new to stackoverflow and any help is appreciated.</p>
| [
{
"answer_id": 74332459,
"author": "yoduh",
"author_id": 6225326,
"author_profile": "https://Stackoverflow.com/users/6225326",
"pm_score": 1,
"selected": false,
"text": "<div\n :class=\"{ '!bg-gray-800 text-gray-600 line-through': task.checked, '!bg-gray-100': task.selected }\"\n v-for=\"task in tasks\"\n>\n"
},
{
"answer_id": 74334033,
"author": "Rohìt Jíndal",
"author_id": 4116300,
"author_profile": "https://Stackoverflow.com/users/4116300",
"pm_score": 0,
"selected": false,
"text": "v-bind:class"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74332285",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20296392/"
] |
74,332,286 | <p>I have an AV log file showing a number of values for each process scanned: Name, Path, Total files scanned, Scan time. The file contains hundreds of these process entries (example below) and for <em>Total files scanned</em> and <em>Scan time</em> I'd like to sort and print the highest (or longest) values so I can determine which processes are impacting the system. I've tried various ways with grep but only seem to get a list running in numerical order, when what I really want is to say Process id: 86, Scan time (ns): 12761174 is the highest, then Process id 25, etc. Hope my explanation is clear enough.</p>
<pre><code>Process id: 25
Name: wwww
Path: "/usr/libexec/wwww"
Total files scanned: 42
Scan time (ns): "62416"
Status: Active
Process id: 7
Name: xxxx
Path: "/usr/libexec/xxxx"
Total files scanned: 0
Scan time (ns): "0"
Status: Active
Process id: 86
Name: yyyy
Path: "/usr/libexec/yyyy"
Total files scanned: 2
Scan time (ns): "12761174"
Status: Active
</code></pre>
<p>I have tried:</p>
<pre><code>grep -Eo | grep 'Scan time (ns)' '[0-9]+' file | sort
</code></pre>
<p>Which results in:</p>
<pre><code>file:Scan time (ns): "9391986"
file:Scan time (ns): "9532119"
file:Scan time (ns): "9730650"
file:Scan time (ns): "9743828"
file:Scan time (ns): "9793469"
file:Scan time (ns): "9911768"
</code></pre>
<p>What I am wanting to achieve is something such as:</p>
<pre><code>Process id 9, Scan time (ns): "34561"
Process id 86, Scan time (ns): "45630"
Process id 25, Scan time (ns): "1256822"
Process id 51, Scan time (ns): "52351290"
Process id 30, Scan time (ns): "90257651"
Process id 19, Scan time (ns): "178764794932"
</code></pre>
| [
{
"answer_id": 74332346,
"author": "Shawn",
"author_id": 9952196,
"author_profile": "https://Stackoverflow.com/users/9952196",
"pm_score": 1,
"selected": false,
"text": "perl"
},
{
"answer_id": 74332691,
"author": "RavinderSingh13",
"author_id": 5866580,
"author_profile": "https://Stackoverflow.com/users/5866580",
"pm_score": 2,
"selected": false,
"text": "awk"
},
{
"answer_id": 74334580,
"author": "M. Nejat Aydin",
"author_id": 13809001,
"author_profile": "https://Stackoverflow.com/users/13809001",
"pm_score": 3,
"selected": true,
"text": "sed"
},
{
"answer_id": 74334702,
"author": "Enlico",
"author_id": 5825294,
"author_profile": "https://Stackoverflow.com/users/5825294",
"pm_score": 1,
"selected": false,
"text": "RS"
},
{
"answer_id": 74334922,
"author": "root",
"author_id": 10678955,
"author_profile": "https://Stackoverflow.com/users/10678955",
"pm_score": 1,
"selected": false,
"text": "paste"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74332286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20422003/"
] |
74,332,315 | <p>How do we authenticate the app to the Firestore? (not using service account), because when service account have conflicts when security rules which needs authenticate. When I'm switching to production mode and perform a query I got this message</p>
<p><a href="https://i.stack.imgur.com/wUazU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wUazU.png" alt="enter image description here" /></a></p>
<p>This is the rules that is set in the production mode</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>match /{document=**} {
allow read, write: if request.auth!=null;
}
match /projects/{document=**} {
allow read, write;
}</code></pre>
</div>
</div>
</p>
<p>And this is my code. This code only works in the test mode how do I make this work in the production mode?</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>public function __construct(){
global $key;
$this->firestore = new FirestoreClient([
'keyFilePath' => $key,
'projectId' => 'test-4c1ff'
]);
}</code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74332514,
"author": "Frank van Puffelen",
"author_id": 209103,
"author_profile": "https://Stackoverflow.com/users/209103",
"pm_score": 3,
"selected": true,
"text": "request.auth"
},
{
"answer_id": 74376306,
"author": "Kissel James Paalaman",
"author_id": 20100490,
"author_profile": "https://Stackoverflow.com/users/20100490",
"pm_score": 1,
"selected": false,
"text": "composer require kreait/firebase-php"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74332315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12675979/"
] |
74,332,369 | <p>I output the scraped data in JSON format. Custom scrapy pipeline outputs a list of dictionaries in JSON format. Item type looks like this:</p>
<pre><code>[{
"product_id": "11980174",
"brand_id": 25354,
"brand_name": "Gucci",
"title": "beige and brown Dionysus GG Supreme mini canvas shoulder bag",
"slug": "/shopping/gucci-beige-and-brown-dionysus-gg-supreme-mini-canvas-shoulder-bag-11980174"
},
{
"product_id": "17070807",
"brand_id": 1168391,
"brand_name": "Jonathan Adler",
"title": "Clear acrylic chess set",
"slug": "/shopping/jonathan-adler-clear-acrylic-chess-set-17070807"
},
{
"product_id": "17022890",
"brand_id": 3543122,
"brand_name": "Anissa Kermiche",
"title": "pink, green and red Mini Jugs Jug earthenware vase set",
"slug": "/shopping/anissa-kermiche-pink-green-and-red-mini-jugs-jug-earthenware-vase-set-17022890"
},]
</code></pre>
<p>But I want to export the data in a valid json format:</p>
<pre><code>[{
"product_id": "11980174",
"brand_id": 25354,
"brand_name": "Gucci",
"title": "beige and brown Dionysus GG Supreme mini canvas shoulder bag",
"slug": "/shopping/gucci-beige-and-brown-dionysus-gg-supreme-mini-canvas-shoulder-bag-11980174"
},
{
"product_id": "17070807",
"brand_id": 1168391,
"brand_name": "Jonathan Adler",
"title": "Clear acrylic chess set",
"slug": "/shopping/jonathan-adler-clear-acrylic-chess-set-17070807"
},
{
"product_id": "17022890",
"brand_id": 3543122,
"brand_name": "Anissa Kermiche",
"title": "pink, green and red Mini Jugs Jug earthenware vase set",
"slug": "/shopping/anissa-kermiche-pink-green-and-red-mini-jugs-jug-earthenware-vase-set-17022890"
}]
</code></pre>
<p>I need to remove the comma from the last json object to make it a valid json.</p>
<p>Here is my custom scrapy json pipeline:</p>
<pre><code>from scrapy import signals
import boto3
from scrapy.utils.project import get_project_settings
import time
import json
class JsonWriterPipeline(object):
def __init__(self):
self.spider_time = f'{time.strftime("%Y/%G_%m/%Y.%m.%d/%Y.%m.%d")}'
@classmethod
def from_crawler(cls, crawler):
pipeline = cls()
crawler.signals.connect(pipeline.spider_opened, signals.spider_opened)
crawler.signals.connect(pipeline.spider_closed, signals.spider_closed)
return pipeline
def spider_opened(self, spider):
self.file = open("%s_items.json" % spider.name, "w")
self.file.write("[")
def process_item(self, item, spider):
line = line = json.dumps(dict(item), indent=4) + ",\n"
self.file.write(line)
return item
def spider_closed(self, spider):
self.file.write("]")
self.file.close()
settings = get_project_settings()
my_session = boto3.session.Session()
s3 = my_session.resource(
"s3",
endpoint_url=settings.get("AWS_ENDPOINT_URL"),
aws_access_key_id=settings.get("AWS_ACCESS_KEY_ID"),
aws_secret_access_key=settings.get("AWS_SECRET_ACCESS_KEY"),
)
boto_test_bucket = s3.Bucket(settings.get("AWS_STORAGE_BUCKET_NAME"))
boto_test_bucket.upload_file(
"%s_items.json" % spider.name,
f"brownsfashion-feeds/{spider.name}_{self.spider_time}.json",
)
</code></pre>
<p>Please advise me of any solutions. Thank you.</p>
| [
{
"answer_id": 74332514,
"author": "Frank van Puffelen",
"author_id": 209103,
"author_profile": "https://Stackoverflow.com/users/209103",
"pm_score": 3,
"selected": true,
"text": "request.auth"
},
{
"answer_id": 74376306,
"author": "Kissel James Paalaman",
"author_id": 20100490,
"author_profile": "https://Stackoverflow.com/users/20100490",
"pm_score": 1,
"selected": false,
"text": "composer require kreait/firebase-php"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18183763/"
] |
74,332,374 | <p>I have the following table :</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>city</th>
<th>state</th>
<th>numOrder</th>
<th>date</th>
<th>deadlineDate</th>
</tr>
</thead>
<tbody>
<tr>
<td>NY</td>
<td>NY</td>
<td>111</td>
<td>2022/11/05</td>
<td>2022/11/06</td>
</tr>
<tr>
<td>LA</td>
<td>CA</td>
<td>222</td>
<td>2022/11/01</td>
<td>2022/10/01</td>
</tr>
<tr>
<td>SD</td>
<td>CA</td>
<td>333</td>
<td>2022/05/05</td>
<td>2022/11/06</td>
</tr>
<tr>
<td>LA</td>
<td>CA</td>
<td>444</td>
<td>2022/11/01</td>
<td>2022/05/01</td>
</tr>
</tbody>
</table>
</div>
<p>I need to calculate the number of orders placed before the deadline divided by the number of orders placed by each state and city:</p>
<pre><code>(SELECT state, city ,count(*)
FROM orders
WHERE date <= deadlineDate
group by state, city) /
(SELECT state, city ,count(*)
FROM orders
group by state, city)
</code></pre>
<p>I tried:</p>
<pre><code>SELECT (
SELECT state, city ,count(*)
FROM orders
WHERE serviceDate <= limitDate
group by state, city
)/
(
SELECT state, city ,count(*)
FROM orders
group by state, city
)
FROM orders
</code></pre>
<p>But the I got ERROR:</p>
<blockquote>
<p>Subquery must return only one column</p>
</blockquote>
| [
{
"answer_id": 74332456,
"author": "slambeth",
"author_id": 1154544,
"author_profile": "https://Stackoverflow.com/users/1154544",
"pm_score": 0,
"selected": false,
"text": "SELECT A.COL1/B.COL1 AS MY_RATIO_COL\nFROM\n (SELECT COL1 FROM MY_TABLE WHERE [BLA BLA BLA]) A\n JOIN\n (SELECT COL1 FROM MY_TABLE WHERE [yata yata]) B\n ON A.KEYCOL1 = B.KEYCOL1\n"
},
{
"answer_id": 74332470,
"author": "ahmed",
"author_id": 12705912,
"author_profile": "https://Stackoverflow.com/users/12705912",
"pm_score": 2,
"selected": true,
"text": "SELECT state, city, \n COUNT(*) FILTER (WHERE date <= deadlineDate)*1.0 / COUNT(*) AS result\nFROM orders\nGROUP BY state, city\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332374",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20429050/"
] |
74,332,388 | <p>I need a function to allow me to update the sheet, for example, if I want to update one row, I want to be able to do it without erasing all the values in that row</p>
<pre><code>//function to get data by email - so as to get row with corresponding email
function getDataByEmail1(email){
var sheet = SpreadsheetApp.getActiveSpreadsheet().getActiveSheet();
var dataCells = sheet.getDataRange().getValues();
var result = null;
for(var i = 1; i < dataCells.length; i++){
if(dataCells[i][0] == email){
result = dataCells[i];
break;
}
}
return result;
}
// this code will check mySheet using the above function getDataByEmail(), and if an email exists, it will proceed to update that record... if email doesn't exit, it will execute the else if statement, which will create new record instead of updating.
function updateRecord(email, password, id, sex, date) {
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var mySheet = sheet.getSheetByName("sheet1");
var getLastRow = mySheet.getLastRow();
var check = getDataByEmail(email);
var table_values = mySheet.getRange(2, 1, getLastRow - 1, 8).getValues();
for(i = 0; i < table_values.length; i++){
if(table_values[i][0] == email) {
mySheet.getRange(i+2, 1).setValue(email);
mySheet.getRange(i+2, 2).setValue(password);
mySheet.getRange(i+2, 3).setValue(id);
mySheet.getRange(i+2, 4).setValue(sex);
mySheet.getRange(i+2, 5).setValue(date);
status = 'Record Updated';
}
else if (check == null){ // this else if statement works, it submits new data to the spreadsheet
var sheet = SpreadsheetApp.getActiveSpreadsheet();
var mySheet = sheet.getSheetByName("sheet1");
var data = [[email,password,id,sex,date]];
var row = mySheet.getLastRow() + 1;
var cel = 1;
var rowLength = data.length;
var celLength = data[0].length;
mySheet.getRange(row, cel, rowLength, celLength).setValues(data);
status = 'New Record created';
}
}
return status;
}
// below is the function i use to test updateRecord()
function updateRecordTest(){
var data = updateRecord("user1@example.com", "pass1", "id1", "id1");
Logger.log(JSON.stringify(data));
}
// The problem is when I update, it is able to get getDataByEmail, and then updating the row that has the corresponding email.. but if all the columns are not filled out, it erases the values in columns that are not filled out and then submits those new updated records...
</code></pre>
<p>I did all kinds of Google Apps Script documentation search, nothing worked for me.</p>
| [
{
"answer_id": 74332706,
"author": "Tanaike",
"author_id": 7108653,
"author_profile": "https://Stackoverflow.com/users/7108653",
"pm_score": 1,
"selected": false,
"text": "check"
},
{
"answer_id": 74332868,
"author": "Cooper",
"author_id": 7215091,
"author_profile": "https://Stackoverflow.com/users/7215091",
"pm_score": 0,
"selected": false,
"text": "function updateRecord(email, password, id, sex, date) {\n var ss = SpreadsheetApp.getActiveSpreadsheet();\n var sh1 = ss.getSheetByName(\"sheet1\");\n var check = getDataByEmail(email);\n var vs1 = sh1.getRange(2, 1, getLastRow() - 1, 8).getValues();\n vs1.forEach(([a, b, c, d, e, f, g, h], i) => {\n if (a == email) {\n sh1.getRange(i + 2, 1, 8).setValues([[a, password, id, sex, date, f, g, h]])\n status = 'Record Updated';\n } else if (check == null) {\n sh1.getRange(sh1.getLastRow(), 1, 1, 8).setValues([[email, password, id, sex, date, f, g, h]]);\n status = 'New Record created';\n }\n })\n return status;\n}\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13995470/"
] |
74,332,390 | <p>I am attempting to understand what this snippet of code does:</p>
<pre><code>passwd1=re.sub(r'^.*? --', ' -- ', line)
password=passwd1[4:]
</code></pre>
<p>I understand that the top line uses regex to remove the " -- ", and the bottom line I think removes something as well? I went back to this code after a while and need to improve it but to do that I need to understand this again. I've been trying to read regex docs to no avail, what is this: <code>r'^.*? </code> at the beginning of the regex?.</p>
| [
{
"answer_id": 74332412,
"author": "Nathaniel Ford",
"author_id": 442945,
"author_profile": "https://Stackoverflow.com/users/442945",
"pm_score": 3,
"selected": true,
"text": "r'^.*? --"
},
{
"answer_id": 74332413,
"author": "Dakeyras",
"author_id": 1857909,
"author_profile": "https://Stackoverflow.com/users/1857909",
"pm_score": 2,
"selected": false,
"text": "' -- '"
},
{
"answer_id": 74332443,
"author": "Skapis9999",
"author_id": 11002498,
"author_profile": "https://Stackoverflow.com/users/11002498",
"pm_score": 1,
"selected": false,
"text": "r"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17170174/"
] |
74,332,403 | <p>I have this code:</p>
<p><code>type(i[0]) == 'str'</code>. How can I get it as a list? and later get <code>print(i[0][0]) == 'a'</code></p>
<pre><code>import csv
i = [['a', 'b'], 'c', 'd']
with open('a.csv', 'a', newline='', encoding='utf-8') as file:
writer = csv.writer(file, delimiter=';')
writer.writerow(i)
file.close()
with open('a.csv', 'r', newline='', encoding='utf-8') as file:
for i in csv.reader(file, delimiter=';'):
print(type(i[0]))
</code></pre>
| [
{
"answer_id": 74332412,
"author": "Nathaniel Ford",
"author_id": 442945,
"author_profile": "https://Stackoverflow.com/users/442945",
"pm_score": 3,
"selected": true,
"text": "r'^.*? --"
},
{
"answer_id": 74332413,
"author": "Dakeyras",
"author_id": 1857909,
"author_profile": "https://Stackoverflow.com/users/1857909",
"pm_score": 2,
"selected": false,
"text": "' -- '"
},
{
"answer_id": 74332443,
"author": "Skapis9999",
"author_id": 11002498,
"author_profile": "https://Stackoverflow.com/users/11002498",
"pm_score": 1,
"selected": false,
"text": "r"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332403",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19983217/"
] |
74,332,435 | <p>I have a this warning:</p>
<pre><code>[Vue warn]: Error in render: "TypeError: Cannot read properties of undefined (reading 'nestedArray')"
</code></pre>
<p>What is the solution to this? This is my beforeCreate functions:</p>
<pre><code> beforeCreate() {
this.$store.dispatch("loadCities").then((response) => {
this.cities = response;
this.sortingCities=this.cities.slice(0).sort(function(a,b) {
return a.row - b.row || a.col-b.col;
})
this.sortingCities.map(item => {
if (!this.nestedArray[item.row]) {
this.nestedArray[item.row] = [];
}
this.nestedArray[item.row][item.col] = item;
});
});
</code></pre>
<p>My data property:</p>
<pre><code> data() {
return {
cities: [],
selectedCity: null,
sortingCities:[],
nestedArray:[],
};
},
</code></pre>
<p>I use this property:</p>
<pre><code><img :src="require(`../images/${this.nestedArray?.[row]?.[col].imageId}.png`)" alt="">
</code></pre>
| [
{
"answer_id": 74332469,
"author": "Dakeyras",
"author_id": 1857909,
"author_profile": "https://Stackoverflow.com/users/1857909",
"pm_score": -1,
"selected": false,
"text": "if (!this.nestedArray[item.row])"
},
{
"answer_id": 74332566,
"author": "tao",
"author_id": 1891677,
"author_profile": "https://Stackoverflow.com/users/1891677",
"pm_score": 2,
"selected": false,
"text": "beforeCreate"
},
{
"answer_id": 74333955,
"author": "Rohìt Jíndal",
"author_id": 4116300,
"author_profile": "https://Stackoverflow.com/users/4116300",
"pm_score": 0,
"selected": false,
"text": "data"
},
{
"answer_id": 74333990,
"author": "Amini",
"author_id": 15351296,
"author_profile": "https://Stackoverflow.com/users/15351296",
"pm_score": 0,
"selected": false,
"text": "new Vue({\n el: \"#app\",\n data() {\n return {\n nestedArrays: []\n }\n },\n created() {\n console.log(this.nestedArrays)\n }\n})"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19301566/"
] |
74,332,440 | <p>The <a href="https://en.cppreference.com/w/cpp/language/parameter_pack" rel="nofollow noreferrer">cppreference page on parameter pack</a> states there is a parameter pack like this:</p>
<pre><code>type ... pack-name(optional) (1)
</code></pre>
<p>But how do you use it?</p>
<p>This doesn't work and the error is syntactical:</p>
<pre><code>template<int... Ints>
int sum_2_int(Ints... args)
{
return (int)(args + ...);
}
</code></pre>
<p>I can't figure out how to use this thing from the description and I don't see an example of the usage anywhere on that page. I may have just skipped it because I am very inexperienced in this part of c++.</p>
<p><strong>EDIT1:</strong>
I am not trying to sum an arbitrary amount of integers or whatever types. I've written this function because of my complete lack of understanding of how and where to use this type of parameter pack since I assumed it will be similar to the type (2) <code>typename|class ... pack-name(optional)</code>.</p>
<p><strong>EDIT2:</strong> Now I know that trying to use <code>Ints... args</code> as a parameter in function definition is futile. I made a new snippet, that works now <a href="https://stackoverflow.com/a/74332699/5202246">here</a>. If you know more examples of the usage of this type of parameter pack, please share.</p>
| [
{
"answer_id": 74332542,
"author": "Nelfeal",
"author_id": 3854570,
"author_profile": "https://Stackoverflow.com/users/3854570",
"pm_score": 0,
"selected": false,
"text": "template<int... Ints>\nint sum_2_int()\n{\n return (int)(Ints + ...);\n}\n\nsum_2_int<1, 2, 3>(); // template arguments must be known at compile time\n"
},
{
"answer_id": 74332699,
"author": "a_girl",
"author_id": 5202246,
"author_profile": "https://Stackoverflow.com/users/5202246",
"pm_score": 3,
"selected": true,
"text": "template<int... Ints> int foo(...) {...}"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332440",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5202246/"
] |
74,332,552 | <p>I am making a list word counter and trying to merge two dictionaries that have a counter for each character, but I keep getting the wrong outputs. Here is what I attempted in an effort to figure out why. Everything seems to go well except for the last two keys in the dictionary.</p>
<pre><code>counts = {"a": 1, "p": 2, "l": 1, "e": 1}
new_counts = {"h": 1, "e": 1, "l": 2, "o": 1}
counts.update(new_counts)
for letters in counts:
if letters in counts and new_counts:
counts[letters] += 1
else:
counts[letters] = 1
print(counts)
</code></pre>
<p>What I need:</p>
<pre><code>{"a": 1, "p": 2, "l": 3, "e": 2, "h": 1, "o": 1}
</code></pre>
<p>What I get:</p>
<pre><code>{'a': 2, 'p': 3, 'l': 3, 'e': 2, 'h': 2, 'o': 2}
</code></pre>
| [
{
"answer_id": 74332585,
"author": "Chris",
"author_id": 15261315,
"author_profile": "https://Stackoverflow.com/users/15261315",
"pm_score": 0,
"selected": false,
"text": "collections.defaultdict"
},
{
"answer_id": 74332598,
"author": "kosciej16",
"author_id": 3361462,
"author_profile": "https://Stackoverflow.com/users/3361462",
"pm_score": 1,
"selected": false,
"text": "Counter"
},
{
"answer_id": 74332607,
"author": "Michael M.",
"author_id": 13376511,
"author_profile": "https://Stackoverflow.com/users/13376511",
"pm_score": 2,
"selected": true,
"text": "counts = {\"a\": 1, \"p\": 2, \"l\": 1, \"e\": 1}\nnew_counts = {\"h\": 1, \"e\": 1, \"l\": 2, \"o\": 1}\n\nfor k, v in new_counts.items():\n if k in counts:\n counts[k] += v\n else:\n counts[k] = v\n\nprint(counts) # => {'a': 1, 'p': 2, 'l': 3, 'e': 2, 'h': 1, 'o': 1}\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332552",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20017084/"
] |
74,332,613 | <p>This question is already solved, it is a mapping from a String to a "Maybe a", with empty,insert,lookup functions as defined below, i'm unable to understand the solution.</p>
<p>The code:</p>
<pre><code>type Map a = String -> Maybe a
empty :: Map a
empty = \x -> Nothing
insert :: (String, a) -> Map a -> Map a
insert (s, a) m = \x -> if x == s then Just a else m x
lookup :: String -> Map a -> Maybe a
lookup x m = m x
</code></pre>
<p>empty and lookup i think i understand.</p>
<p>insert however is puzzling to me,the lambda inside it i don't understand, how is x used in the equality when it is never taken as a parameter, x is from what i can see is a String, but it isn't given a value anywhere.
what would be the resulting function from <code>insert ("foo", 61) empty</code> how would it be evaluated, and what does x represent?</p>
<p>also why would a line like this work and return "Just 61"
<code>lookup "foo" (insert ("foo", 61) empty)</code></p>
| [
{
"answer_id": 74332774,
"author": "Steven",
"author_id": 6543301,
"author_profile": "https://Stackoverflow.com/users/6543301",
"pm_score": 3,
"selected": true,
"text": "type Map a = String -> Maybe a"
},
{
"answer_id": 74332782,
"author": "chepner",
"author_id": 1126841,
"author_profile": "https://Stackoverflow.com/users/1126841",
"pm_score": 2,
"selected": false,
"text": "Map a"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332613",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20426362/"
] |
74,332,637 | <p>I have a df thats big, and has int's and float's inside, some have bigger values over 1 thousand, and that gives error when using them as int</p>
<p>ex:<br />
A B C
0 1,598 65.79 79<br />
1 -300 46.90 90</p>
<p><a href="https://i.stack.imgur.com/leUQh.png" rel="nofollow noreferrer">the format doesnt let me write the df</a></p>
<p>How can I replace the "," for this: ""?</p>
| [
{
"answer_id": 74332736,
"author": "fholl124",
"author_id": 14320213,
"author_profile": "https://Stackoverflow.com/users/14320213",
"pm_score": 0,
"selected": false,
"text": "import pandas as pd\n\ndef convert_value(input_value):\n return input_value.replace(\"Dollars\", \"Pounds\")\n\ndf = pd.read_csv(\"your_file.csv\", converters={\"UNITS\":convert_value})\n"
},
{
"answer_id": 74333905,
"author": "Panda Kim",
"author_id": 20430449,
"author_profile": "https://Stackoverflow.com/users/20430449",
"pm_score": 2,
"selected": true,
"text": "df"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20354586/"
] |
74,332,703 | <p>Given:</p>
<pre><code>d = {'c': 3, 'b': 2, 'a': 1, 'd': 4, 'e': 5}
sorted_dict = d.keys()
sorted_dict = sorted(sorted_dict)
for key in sorted_dict:
print(key)
</code></pre>
<p>How do I make it so that it outputs every other key. Right now it outputs:</p>
<pre><code>a
b
c
d
e
</code></pre>
<p>but I want it to output:</p>
<pre><code>a
c
e
</code></pre>
| [
{
"answer_id": 74332721,
"author": "Mateen Ulhaq",
"author_id": 365102,
"author_profile": "https://Stackoverflow.com/users/365102",
"pm_score": 0,
"selected": false,
"text": "d"
},
{
"answer_id": 74332732,
"author": "Blackasaurus",
"author_id": 20139782,
"author_profile": "https://Stackoverflow.com/users/20139782",
"pm_score": 0,
"selected": false,
"text": "sorted_dict = d.keys()\nsorted_dict = sorted(sorted_dict)\nfor key in range(0, len(sorted_dict),2): print(key)\n"
},
{
"answer_id": 74332779,
"author": "Richard Plester",
"author_id": 15474105,
"author_profile": "https://Stackoverflow.com/users/15474105",
"pm_score": 2,
"selected": true,
"text": "d = {'c': 3, 'b': 2, 'a': 1, 'd': 4, 'e': 5}\nsorted_dict = d.keys()\nsorted_dict = sorted(sorted_dict)\n\nfor key in sorted_dict[::2]:\n print(key)\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332703",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20066884/"
] |
74,332,710 | <p>I am trying to create a countdown timer using useEffect hook and setInterval function, but it is not ever executing the code when the timer reaches 0. Also, when I console.log the value of the countdown variable it doesn't decrement.</p>
<pre><code>
// set up counter for (un)flipped phone countdown
// countdown of 20 seconds
const [countdown, setCountdown] = useState(20);
let intervalID: any;
// on initialize
useEffect(() => {
// every second reduce countdown by 1
intervalID = setInterval(() => {
setCountdown(countdown - 1);
}, 1000);
return () => clearInterval(intervalID);
}, []);
// check if countdown has reached 0
useEffect(() => {
if (countdown == 0) {
timerReset();
alert("TIMER RESET");
clearInterval(intervalID);
}
}, []);
</code></pre>
| [
{
"answer_id": 74333124,
"author": "J.dev",
"author_id": 10196369,
"author_profile": "https://Stackoverflow.com/users/10196369",
"pm_score": 1,
"selected": false,
"text": "const [countdown, setCountdown] = useState(20);\n\nuseEffect(() => {\n let intervalID = setInterval(() => {\n setCountdown(prev => {\n if (prev === 0) clearInterval(intervalID); // handle the condition here\n return prev - 1;\n });\n }, 1000);\n return () => clearInterval(intervalID);\n}, []);\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11683609/"
] |
74,332,719 | <p>The following code attempts to store a <code>void</code> pointer inside a pointer of a different type using <code>memcpy</code> (i.e. <em>not</em> casting) and then recover the original <code>void</code> pointer. Does it invoke undefined behavior?</p>
<pre><code>#include <assert.h>
#include <string.h>
#include <stdio.h>
int main()
{
// Ensure that an int pointer is large enough to store a void pointer
_Static_assert( sizeof( int* ) >= sizeof( void* ) );
// Create a void pointer pointing to a dummy value
void *a = &(short){ 10 };
// Stash the void pointer inside an int pointer via memcpy
int *b = NULL;
memcpy( &b, &a, sizeof( void *) );
// Duplicate the int pointer via assignment
// Maybe undefined behavior as b could be an invalid int pointer
// or the assignment may not copy padding bits that are actually significant to us?
int *c = b;
// Extract the void pointer from inside the int pointer duplicate
void *d;
memcpy( &d, &c, sizeof( void *) );
// The extracted void pointer should now equal the original void pointer
// Hence, this line should print 10
printf( "%d", *(short *)d );
return 0;
}
</code></pre>
<p>Someone is bound to ask why we might want to do this. The (crazy?) idea is to store a pointer to <code>malloc</code>ed memory inside a pointer to another type and then recover the original pointer inside a function <em>that doesn’t know the other pointer type</em>:</p>
<pre><code>#include <stdlib.h>
#include <string.h>
void alloc_mem( void *p )
{
void *mem = malloc( 100 );
memcpy( p, &mem, sizeof( void * ) );
}
void do_something_with_mem( void *p )
{
void *mem;
memcpy( &mem, p, sizeof( void * ) );
if( mem )
{
// Do something with mem
}
}
int main()
{
// int for the purpose of demonstration, but it could be any type
_Static_assert( sizeof( int* ) >= sizeof( void* ) );
int *foo = NULL;
alloc_mem( &foo );
int *bar = foo;
do_something_with_mem( &bar );
return 0;
}
</code></pre>
| [
{
"answer_id": 74332863,
"author": "selbie",
"author_id": 104458,
"author_profile": "https://Stackoverflow.com/users/104458",
"pm_score": 0,
"selected": false,
"text": "void alloc_mem(void* p)\n{\n void* mem = malloc(100);\n strcpy(mem, \"hello world\\n\");\n *(void**)p = mem;\n}\n\nvoid do_something_with_mem(void* p)\n{\n void* mem = *(void**)p;\n if (mem)\n {\n // Do something with mem\n printf(\"%s\", (char*)mem);\n }\n}\n"
},
{
"answer_id": 74332872,
"author": "ikegami",
"author_id": 589924,
"author_profile": "https://Stackoverflow.com/users/589924",
"pm_score": 0,
"selected": false,
"text": "int*"
},
{
"answer_id": 74334216,
"author": "root",
"author_id": 10678955,
"author_profile": "https://Stackoverflow.com/users/10678955",
"pm_score": 2,
"selected": false,
"text": "memcpy()"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17039046/"
] |
74,332,751 | <p>I'm working on site navigation, and I'm trying to create a dropdown menu. I have three list items with additional unordered lists that I would like to drop down. However, I am having issues with the :hover pseudo-class. If I do <code>nav ul:hover ul {display: block;}</code> then a dropdown appears, but it occurs whenever I hover over any area of the navigation bar. However, if I code <code>nav li:hover ul {display: block;}</code> then I can't get any dropdown to appear at all. Any advice regarding what I'm doing wrong would be much appreciated.</p>
<p>This is the CSS I'm currently working with:</p>
<pre><code>nav { padding: 0;
font-size: 100%;
text-align: center;
position: relative;
}
nav ul { list-style-type: none;
margin: 0.5em;
padding-left: 0;
font-size: 100%;
}
nav li {border-bottom: 1px solid #002171;}
nav a { text-decoration: none;
display: block;
}
nav a:hover { color: #A52F00;
background-color: #000000; }
nav ul ul { position: absolute;
display: none;
padding: 0;
}
nav ul ul li { display: block;
background-color: #FFFFFF;
width: 15em;
text-align: center;
margin-left: 0;}
nav li:hover ul { display: block; }
</code></pre>
<hr />
<p>I am using it on the following HTML:</p>
<pre><code><nav>
<ul>
<li><a href="index.html">Home</a></li>
<li><a href="#">Link 2</a></li>
<ul>
<li><a href="#">Drop 1</a></li>
<li><a href="#">Drop 2</a></li>
<li><a href="#">Drop 3</a></li>
<li><a href="#">Drop 4</a></li>
</ul>
<li><a href="#">Link 3</a></li>
<ul>
<li><a href="#">Link 3 Drop</a></li>
</ul>
<li><a href="#">Link 4</a></li>
<ul>
<li><a href="#">Link 4 Drop</a></li>
</ul>
<li><a href="#">Link 5</a></li>
</ul>
</nav>
</code></pre>
| [
{
"answer_id": 74332827,
"author": "str1ng",
"author_id": 12826055,
"author_profile": "https://Stackoverflow.com/users/12826055",
"pm_score": 2,
"selected": true,
"text": "ul/ol"
},
{
"answer_id": 74332947,
"author": "html_coder",
"author_id": 17942512,
"author_profile": "https://Stackoverflow.com/users/17942512",
"pm_score": 0,
"selected": false,
"text": "<li><a></a></li>\n// It should be inside the li's everything down there\n<ul>\n//The dropdown menu\n...\n</ul>\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332751",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20429300/"
] |
74,332,756 | <p>Trying to install lxml on Python 311. Faced with this error.</p>
<pre><code>PS C:\Users\chharlie\Desktop\code> pip install lxml
Collecting lxml
Using cached lxml-4.9.1.tar.gz (3.4 MB)
Preparing metadata (setup.py) ... done
Building wheels for collected packages: lxml
Building wheel for lxml (setup.py) ... error
error: subprocess-exited-with-error
× python setup.py bdist_wheel did not run successfully.
│ exit code: 1
╰─> [74 lines of output]
Building lxml version 4.9.1.
Building without Cython.
Building against pre-built libxml2 andl libxslt libraries
running bdist_wheel
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-311
creating build\lib.win-amd64-cpython-311\lxml
copying src\lxml\builder.py -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\cssselect.py -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\doctestcompare.py -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\ElementInclude.py -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\pyclasslookup.py -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\sax.py -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\usedoctest.py -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\_elementpath.py -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\__init__.py -> build\lib.win-amd64-cpython-311\lxml
creating build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\__init__.py -> build\lib.win-amd64-cpython-311\lxml\includes
creating build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\builder.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\clean.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\defs.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\diff.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\ElementSoup.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\formfill.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\html5parser.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\soupparser.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\usedoctest.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\_diffcommand.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\_html5builder.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\_setmixin.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\__init__.py -> build\lib.win-amd64-cpython-311\lxml\html
creating build\lib.win-amd64-cpython-311\lxml\isoschematron
copying src\lxml\isoschematron\__init__.py -> build\lib.win-amd64-cpython-311\lxml\isoschematron
copying src\lxml\etree.h -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\etree_api.h -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\lxml.etree.h -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\lxml.etree_api.h -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\includes\c14n.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\config.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\dtdvalid.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\etreepublic.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\htmlparser.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\relaxng.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\schematron.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\tree.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\uri.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\xinclude.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\xmlerror.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\xmlparser.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\xmlschema.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\xpath.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\xslt.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\__init__.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\etree_defs.h -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\lxml-version.h -> build\lib.win-amd64-cpython-311\lxml\includes
creating build\lib.win-amd64-cpython-311\lxml\isoschematron\resources
creating build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\rng
copying src\lxml\isoschematron\resources\rng\iso-schematron.rng -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\rng
creating build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl
copying src\lxml\isoschematron\resources\xsl\RNG2Schtrn.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl
copying src\lxml\isoschematron\resources\xsl\XSD2Schtrn.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl
creating build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_abstract_expand.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_dsdl_include.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_message.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_skeleton_for_xslt1.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_svrl_for_xslt1.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
running build_ext
building 'lxml.etree' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
note: This error originates from a subprocess, and is likely not a problem with pip.
ERROR: Failed building wheel for lxml
Running setup.py clean for lxml
Failed to build lxml
Installing collected packages: lxml
Running setup.py install for lxml ... error
error: subprocess-exited-with-error
× Running setup.py install for lxml did not run successfully.
│ exit code: 1
╰─> [76 lines of output]
Building lxml version 4.9.1.
Building without Cython.
Building against pre-built libxml2 andl libxslt libraries
running install
C:\Users\chharlie\AppData\Local\Programs\Python\Python311\Lib\site-packages\setuptools\command\install.py:34: SetuptoolsDeprecationWarning: setup.py install is deprecated. Use build and pip and other standards-based tools.
warnings.warn(
running build
running build_py
creating build
creating build\lib.win-amd64-cpython-311
creating build\lib.win-amd64-cpython-311\lxml
copying src\lxml\builder.py -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\cssselect.py -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\doctestcompare.py -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\ElementInclude.py -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\pyclasslookup.py -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\sax.py -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\usedoctest.py -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\_elementpath.py -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\__init__.py -> build\lib.win-amd64-cpython-311\lxml
creating build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\__init__.py -> build\lib.win-amd64-cpython-311\lxml\includes
creating build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\builder.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\clean.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\defs.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\diff.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\ElementSoup.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\formfill.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\html5parser.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\soupparser.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\usedoctest.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\_diffcommand.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\_html5builder.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\_setmixin.py -> build\lib.win-amd64-cpython-311\lxml\html
copying src\lxml\html\__init__.py -> build\lib.win-amd64-cpython-311\lxml\html
creating build\lib.win-amd64-cpython-311\lxml\isoschematron
copying src\lxml\isoschematron\__init__.py -> build\lib.win-amd64-cpython-311\lxml\isoschematron
copying src\lxml\etree.h -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\etree_api.h -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\lxml.etree.h -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\lxml.etree_api.h -> build\lib.win-amd64-cpython-311\lxml
copying src\lxml\includes\c14n.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\config.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\dtdvalid.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\etreepublic.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\htmlparser.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\relaxng.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\schematron.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\tree.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\uri.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\xinclude.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\xmlerror.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\xmlparser.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\xmlschema.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\xpath.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\xslt.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\__init__.pxd -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\etree_defs.h -> build\lib.win-amd64-cpython-311\lxml\includes
copying src\lxml\includes\lxml-version.h -> build\lib.win-amd64-cpython-311\lxml\includes
creating build\lib.win-amd64-cpython-311\lxml\isoschematron\resources
creating build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\rng
copying src\lxml\isoschematron\resources\rng\iso-schematron.rng -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\rng
creating build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl
copying src\lxml\isoschematron\resources\xsl\RNG2Schtrn.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl
copying src\lxml\isoschematron\resources\xsl\XSD2Schtrn.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl
creating build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_abstract_expand.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_dsdl_include.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_schematron_message.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
n-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\iso_svrl_for_xslt1.xsl -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
copying src\lxml\isoschematron\resources\xsl\iso-schematron-xslt1\readme.txt -> build\lib.win-amd64-cpython-311\lxml\isoschematron\resources\xsl\iso-schematron-xslt1
running build_ext
building 'lxml.etree' extension
error: Microsoft Visual C++ 14.0 or greater is required. Get it with "Microsoft C++ Build Tools": https://visualstudio.microsoft.com/visual-cpp-build-tools/
[end of output]
error: legacy-install-failure
× Encountered error while trying to install package.
╰─> lxml
note: This is an issue with the package mentioned above, not pip.
hint: See above for output from the failure.
</code></pre>
<p>You can see at the end it states the 'legacy-install-failure', as well as a suggestion to download Visual C++ 14.0. I have done this. When trying to download LXML from the original site, and installing it into my \scripts\ folder in python311 through CMD, I am faced with</p>
<pre><code>PS C:\Users\chharlie\Downloads> C:\Users\chharlie\AppData\Local\Programs\Python\Python311\Scripts\pip install "lxml-4.9.0-cp311-cp311-win32.whl"
ERROR: lxml-4.9.0-cp311-cp311-win32.whl is not a supported wheel on this platform.
</code></pre>
<p>You can see I used the Windows 32 version to attempt a successful install, in case the 64 version wouldn't work for some reason.</p>
<p>It seems as if Python is having trouble building a 'wheel' for lxml, among possible other errors. Apologies, I'm still a beginner.</p>
<p>Thanks for any help. This is my first Stack Overflow post, so apologies if anything is done wrong.</p>
| [
{
"answer_id": 74332827,
"author": "str1ng",
"author_id": 12826055,
"author_profile": "https://Stackoverflow.com/users/12826055",
"pm_score": 2,
"selected": true,
"text": "ul/ol"
},
{
"answer_id": 74332947,
"author": "html_coder",
"author_id": 17942512,
"author_profile": "https://Stackoverflow.com/users/17942512",
"pm_score": 0,
"selected": false,
"text": "<li><a></a></li>\n// It should be inside the li's everything down there\n<ul>\n//The dropdown menu\n...\n</ul>\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20429389/"
] |
74,332,757 | <p>I have an old script where I extract the contents of archives into a new directory with the name of the archives. I need to simplify this as I find it inefficient since the commands run regardless. I'm not an expert with bash, and this worked for a while, but has become unbearable of late.</p>
<p>I get constant errors because the directory is already created or is not a unzip/unrar archive.
I don't know how to check if the file is unrar or zip format prior to starting the script so I don't know how to put together a proper if/else for loop. I'm no expert with bash and this is just a small portion of a much larger script all written in bash years ago.</p>
<pre><code>for x in $(find -name '*.cbr'); do dir=${x%%.cbr}; mkdir "$dir"; unzip -d "$dir" $x; done
for x in $(find -name '*.cbr'); do dir=${x%%.cbr}; mkdir "$dir"; unrar e $x "$dir"; done
for x in $(find -name '*.cbz'); do dir=${x%%.cbz}; mkdir "$dir"; unzip -d "$dir" $x; done
for x in $(find -name '*.cbz'); do dir=${x%%.cbz}; mkdir "$dir"; unrar e $x "$dir"; done
</code></pre>
| [
{
"answer_id": 74332828,
"author": "Zac Anger",
"author_id": 5774952,
"author_profile": "https://Stackoverflow.com/users/5774952",
"pm_score": 1,
"selected": false,
"text": "file"
},
{
"answer_id": 74417754,
"author": "superuser-Miguel",
"author_id": 12947441,
"author_profile": "https://Stackoverflow.com/users/12947441",
"pm_score": 1,
"selected": true,
"text": " for x in $(find -name '*.cbr' -o -name '*.cbz');\n do dir=${x%.*};\n mkdir \"$dir\";\n unrar e $x \"$dir\" || unzip -d \"$dir\" $x;\n done\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12947441/"
] |
74,332,790 | <p>I would like use a for loop over a list of pandas dataframes, to make similar changes to each one. But the changes don't seem to take effect globally.</p>
<p>For a simpler example that works as expected (but with python lists instead of dataframes): the following works as I would expect it to:</p>
<p><strong>Example 1:</strong></p>
<pre><code>u=[68, 82, 75]
v=[92, 54, 71, 56]
for x in [u,v]:
x[0]=100
print(u)
print(v)
</code></pre>
<p>The 0th entry in both $u$ and $v$ have been updated to 100, as I expected.</p>
<p>But when I try to do something similar with pandas dataframes, the updates don't seem to stick:</p>
<p><strong>Example 2:</strong></p>
<pre><code>import pandas as pd
data_current = [['tom', 72], ['nick', 77], ['julie', 68]]
data_desired = [['mary', 65], ['john', 73], ['Alex', 74]]
# Create the pandas DataFrames
df_current = pd.DataFrame(data_current, columns=['Name', 'Height'])
df_desired = pd.DataFrame(data_desired, columns=['Name', 'Height'])
#go through both dataframes and keep only those with height > 70
for df in [df_current, df_desired]:
df=df[df['Height']>70]
print("Current Roster:")
print(df_current)
print("Desired Roster:")
print(df_desired)
</code></pre>
<p>I would have expected the final two printouts to only include rows where the height was >70, but no rows have been excluded. I.e., the dataframe adjustments in the for loop haven't taken effect globally.</p>
<p>I think I can cobble together a way to do it based on other SO answers, but I would like to understand why Example 1 works as I expect, but Example 2 does not.</p>
| [
{
"answer_id": 74332828,
"author": "Zac Anger",
"author_id": 5774952,
"author_profile": "https://Stackoverflow.com/users/5774952",
"pm_score": 1,
"selected": false,
"text": "file"
},
{
"answer_id": 74417754,
"author": "superuser-Miguel",
"author_id": 12947441,
"author_profile": "https://Stackoverflow.com/users/12947441",
"pm_score": 1,
"selected": true,
"text": " for x in $(find -name '*.cbr' -o -name '*.cbz');\n do dir=${x%.*};\n mkdir \"$dir\";\n unrar e $x \"$dir\" || unzip -d \"$dir\" $x;\n done\n"
}
] | 2022/11/06 | [
"https://Stackoverflow.com/questions/74332790",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20427868/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.