qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,145,537 | <p>A team at my work works with Dymola and is using it to simulate a quite complex model for quite a long time.</p>
<p>They end up with large output files (.mat) of around 150gb and therefore have issues post processing it.</p>
<p>I am in IT and have graduated as an engineer so I have enough experience with typical softwares to know that they could reduce the output frequency or the amount of data stored (e.g. choosing less variables to output). But for some reason, they can’t or don’t want.</p>
<p>Now I don’t know dymola enough to identify another possibility and that is why I am asking the community : is there another way to have the same accuracy, complexity and amount of data while having smaller output files?</p>
<p>Is there a way in Dymola to cut a simulation into multiple time-domains for example ? So one file for 0-500s, another for 500-1000s and so on? They told me it’s possible but complicated. Is that true? Isn’t there a way to do this in Dymola ?</p>
<p>Thanks in advance</p>
| [
{
"answer_id": 74145774,
"author": "Ömer Can Korkmaz",
"author_id": 12475930,
"author_profile": "https://Stackoverflow.com/users/12475930",
"pm_score": 2,
"selected": false,
"text": "for (const event of filteredEvents) {\n for (let agent of event.agents) {\n const data = this.fe... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5555782/"
] |
74,145,539 | <p>My use case is if list2 elements are in list1 then add them to a new list3 and do the set function on list3 and if length is ==2 then print it as <code>partial</code> if length greater than 2 then <code>multiple </code> . I want to add the option column in the excel below. Below excel file can print the 1st and second column but for the `option' i'm not getting the logic on how to do it. can someone help me with that?
Thanks</p>
| [
{
"answer_id": 74145774,
"author": "Ömer Can Korkmaz",
"author_id": 12475930,
"author_profile": "https://Stackoverflow.com/users/12475930",
"pm_score": 2,
"selected": false,
"text": "for (const event of filteredEvents) {\n for (let agent of event.agents) {\n const data = this.fe... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12415367/"
] |
74,145,585 | <p>I'm trying to build a little function that enables middlewares (Express ones in this case) to transform the <code>Request</code> object by adding props to it, so any other following middleware on the chain can use them while maintaining the types.</p>
<p>Maybe it's easier to understand with an example:</p>
<pre class="lang-js prettyprint-override"><code>app.post(
'/some/endpoint',
pipeMiddleware(
(req, res) => {
// do some async stuff
return { entity: { /* ... */ } }
},
(req, res) => {
// do some async stuff
return { otherEntity: { /* ... */ } }
},
(req, res) => handler(req.entity, req.otherEntity, req.body, res)
)
)
</code></pre>
<p>So in that case, the second middleware will have access to <code>entity</code>, and the third one will have access to both <code>entity</code> & <code>otherEntity</code>.</p>
<p>I've managed to make it work by doing some ugly stuff like:</p>
<pre class="lang-js prettyprint-override"><code>type Dict = { [key: string]: any };
export const mw = <
J extends Request,
T extends Response,
R extends Dict,
K extends Dict | void,
P extends Dict | void,
>(
fn1: (a: J, a2: T) => Promise<R>,
fn2: (a: J & R, a2: T) => Promise<K> = async () => ({} as any as K),
fn3: (a: J & R & K, a2: T) => Promise<P> = async () => ({} as any as P),
) => async (arg1: J, arg2: T) => {
const first = Object.assign(arg1, await fn1(arg1, arg2));
const second = Object.assign(first, await fn2(first, arg2));
const third = Object.assign(second, await fn3(second, arg2));
return third;
};
</code></pre>
<p>And it actually returns the correct types, but I want to make it better by allowing to provide N number of parameters without having to update that function...</p>
| [
{
"answer_id": 74211897,
"author": "Dimava",
"author_id": 5734961,
"author_profile": "https://Stackoverflow.com/users/5734961",
"pm_score": 0,
"selected": false,
"text": "\nclass ChainableExpress<Q extends Request = Request, S extends Response = Response> {\n app: Application\n middlew... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1789025/"
] |
74,145,594 | <p>I am trying to create a script in AIX (ksh/bash) where I need to compare two variables with two different date formats, and raise an alert if the difference between the StartTime and CurrentTime is greater than 5 minutes.</p>
<p>As an example, if I have a script that has these three variables:</p>
<pre><code>StartTime="20 Oct 2022 12:20:48 -0700"
CurrentTime=$(date)
AlertThreshold=300
</code></pre>
<p>How can I compare the two, and do something if the difference between StartTime and CurrentTime is greater than AlertThreshold (300 seconds)?</p>
<p>The value returned by $(date) is in this format: Thu Oct 20 12:37:05 PDT 2022</p>
<p>I am stuck trying to figure out a way to convert both variables to a format where I can compare the values, so that I can test to see if the time difference is greater than AlertThreshold.</p>
<p>I assume both would need to be converted to unix timestamp to compare?</p>
<p>Any help would be appreciated.</p>
<p>date command usage:</p>
<pre><code>[mmddHHMM[[cc]yy]] [+"Field Descriptors"]
Usage: date [-n][-u] [mmddHHMM[.SS[cc]yy]] [+"Field Descriptors"]
Usage: date [-a [+|-]sss[.fff]]
</code></pre>
| [
{
"answer_id": 74146391,
"author": "Fravadona",
"author_id": 3387716,
"author_profile": "https://Stackoverflow.com/users/3387716",
"pm_score": 3,
"selected": true,
"text": "perl"
},
{
"answer_id": 74147673,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": ... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7087863/"
] |
74,145,623 | <p>I've got a ToC (Table of Content) table that's implemented as a Div. It uses the following HTML and CSS:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>h3.articletitle {
font-weight: bold;
font-size: 30px;
border-bottom: 1px solid #4F120B;
}
h4.articlesubtitle {
font-weight: bold;
font-size: 22px;
border-bottom: 1px solid #4F120B;
}
h5.articlesubtitle {
font-weight: bold;
font-size: 18px;
border-bottom: 1px solid #4F120B;
}
#toc_container {
background: rgba(92, 9, 0, 0.14);
border: 1px solid #4F120B;
display: block;
font-size: 90%;
margin-bottom: 1em;
margin-right: 1em;
padding: 20px;
width: auto;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="book">
<h3 class="articletitle">Title</h3>
<article>
<div style="float: left; margin-left: auto;" id="toc_container">
<p class="toc_title">Contents</p>
<ul class="toc_list">
<li><a href="#Scociety">Scociety</a></li>
<ul>
<li><a href="#ArtHistory">Art</a></li>
<li><a href="#PopCulture">Pop Culture</a></li>
<li><a href="#HighCulture">High Culture</a></li>
<li><a href="#CommunicationAndTheSpreadOfIdeas">Communication And The Spread Of Ideas</a></li>
<li><a href="#Holidays">Holidays</a></li>
<li><a href="#GenderAndGenderRoles">Gender and Gender Roles</a></li>
<li><a href="#SubculturesAndAlternativeLifestyles">Subcultures and Alternative Lifestyles</a></li>
<li><a href="#UniversalFears">Universal Fears</a></li>
</ul>
</div>
<p>Lorem ipsum dolor sit amet, consectetur adipiscing elit, sed do eiusmod tempor incididunt ut labore et dolore magna aliqua. Ut enim ad minim veniam, quis nostrud exercitation ullamco laboris nisi ut aliquip ex ea commodo consequat.</p>
<h4 class="articlesubtitle" id="Scociety">Scociety</h4>
<h5 class="articlesubtitle" id="ArtHistory">Art</h5>
<p>Sed ut perspiciatis unde omnis iste natus error sit voluptatem accusantium doloremque laudantium, totam rem aperiam, eaque ipsa quae ab illo inventore veritatis et quasi architecto beatae vitae dicta sunt explicabo. Nemo enim ipsam voluptatem quia voluptas sit aspernatur aut odit aut fugit, sed quia consequuntur magni dolores eos qui ratione voluptatem sequi nesciunt.</p>
</div></code></pre>
</div>
</div>
</p>
<p>You can see how the border under the headers extends under the ToC's div. How do I get them to wrap with the text? I tried putting them in their own divs and adjusting the width via percentages, but that only worked fullscreen. When resizing, the borders will poke back into the ToC.</p>
<p>I'm new to web design, please keep explanations noob friendly.</p>
| [
{
"answer_id": 74146391,
"author": "Fravadona",
"author_id": 3387716,
"author_profile": "https://Stackoverflow.com/users/3387716",
"pm_score": 3,
"selected": true,
"text": "perl"
},
{
"answer_id": 74147673,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": ... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19912006/"
] |
74,145,646 | <p>Please I'm trying to number this loop:</p>
<pre class="lang-py prettyprint-override"><code>TopList = {'1350180828': 3, '1670937087': 2, '0743180828': 1, '9864937087': 8}
meg = "Top Referral List\n"
sort = sorted(TopList.items(), key=lambda x: x[1], reverse=True)
for info in sort:
num = 1
userlink = f'<a href="tg://user?id={info[0]}">{info[0]}</a>'
meg += f"\n{num} {userlink} - {info[1]}\n"
if len(sort) > 10:
break
print(meg)
</code></pre>
<p>I want it to look like this:</p>
<pre><code>Top Referral List
1 9864937087 - 8
2 1350180828 - 3
3 1670937087 - 2
4 0743180828 - 1
</code></pre>
| [
{
"answer_id": 74146391,
"author": "Fravadona",
"author_id": 3387716,
"author_profile": "https://Stackoverflow.com/users/3387716",
"pm_score": 3,
"selected": true,
"text": "perl"
},
{
"answer_id": 74147673,
"author": "Adam Liss",
"author_id": 29157,
"author_profile": ... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145646",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20254128/"
] |
74,145,671 | <p>I find myself practicing the <strong>get</strong> and <strong>set</strong> properties Javascript.</p>
<p>My output (below) is not showing the new breed for gato1 nor the new color for gato2 when I change it.</p>
<p>But if I call the property <code>gato1.getRaza</code> or <code>gato2.getColor</code>, it returns the value already changed.</p>
<pre><code>class Animal{
constructor (clase,especie,color){
this.clase = clase;
this.especie = especie;
this.color = color;
this.info = `El ${this.especie}, es un animal ${this.clase} de color ${this.color}`;
}
verInfo(){
document.write(`<label class="animals">${this.info}</label><br><br><br>`);
}
set setColor(color){
this.color = color;
}
get getColor(){
return this.color;
}
}
class Gato extends Animal{
constructor(clase,especie,color,raza){
super(clase,especie,color);
this.raza = raza;
this.info += `, además es de raza ${this.raza}`;
}
set setRaza(newRaza){
this.raza = newRaza;
}
get getRaza(){
return this.raza;
}
maullar(){
document.write(`<label class="animals__cat">El ${this.especie}
hace "Miau"</label><br><br><br>`);
}
}
const gato1 = new Gato(`terrestre`,`Gato`,`blanco`,`andro`);
// created a gato1 object of the Cat class, inherited from the Animal class
const gato2 = new Animal(`terrestre`,`Gato`,`gris`);
// create a gato2 object of the Animal class
gato1.verInfo();
// I see current information from gato1
gato1.maullar();
//I run the maullar() method to show that only the gato1 of the Cat class can effectively meow
gato1.setRaza = `angora`;
// here I apply the property set to change the property race of the gato1
gato1.verInfo();
/*I call again the method verInfo() to observe that the breed for which the
gato1 object was previously entered has been changed*/
gato2.verInfo();
// I call gato2 to see their properties
gato2.setColor = `negro`;
// changed its color
gato2.verInfo();
// I show again its properties where it is supposed to have changed its color
</code></pre>
<p>Output:</p>
<ul>
<li>El Gato, es un animal terrestre de color blanco, además es de raza andro</li>
<li>El Gato hace "Miau"</li>
<li>El Gato, es un animal terrestre de color blanco, además es de raza <em><strong>andro</strong></em> <-- here</li>
<li>El Gato, es un animal terrestre de color gris</li>
<li>El Gato, es un animal terrestre de color <em><strong>gris</strong></em> <--- here</li>
</ul>
| [
{
"answer_id": 74145710,
"author": "Fastnlight",
"author_id": 20153035,
"author_profile": "https://Stackoverflow.com/users/20153035",
"pm_score": 2,
"selected": false,
"text": "info"
},
{
"answer_id": 74145979,
"author": "Ruan Mendes",
"author_id": 227299,
"author_pro... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145671",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20294238/"
] |
74,145,685 | <p>This is my first Module I'm creating, I have learnt in the <a href="https://www.odoo.com/documentation/15.0/developer/howtos/backend.html#data-files" rel="nofollow noreferrer">documentation</a> that after creating the action (record tag) I have to mention this action in the (Menu tag) to act on it, as the following</p>
<pre><code><record model="ir.actions.act_window" id="action_list_ideas">
<field name="name">Ideas</field>
<field name="res_model">idea.idea</field>
<field name="view_mode">tree,form</field> </record>
<menuitem id="menu_ideas" parent="menu_root" name="Ideas" sequence="10"
action="action_list_ideas"/>
</code></pre>
<p><strong>My question is</strong></p>
<p>I want to create another action type</p>
<p><code>record model="ir.ui.view"</code>
how to make the relation between the action and the menu ?</p>
<p>This is what I wrote, 4 actions for 2 menu</p>
<pre><code><!-- record ir.ui.view for menu "about company" --->
<record id="globalhaatahmedviewa" model="ir.ui.view">
<field name="name">haatglobal_ahmed</field>
<field name="model">haatglobal_ahmed.haatglobal_ahmed</field>
<field name="priority" eval="16"/>
<field name="arch" type="xml">
<!-- view content: <form>, <tree>, <graph>, ... -->
<form create="false" edit="false">
HTML Text to
</form>
</field>
</record>
<!-- record ir.ui.view for menu "support" --->
<record id="globalhaatahmedviews" model="ir.ui.view">
<field name="name">haatglobal_ahmed</field>
<field name="model">haatglobal_ahmed.haatglobal_ahmed</field>
<field name="priority" eval="16"/>
<field name="arch" type="xml">
<!-- view content: <form>, <tree>, <graph>, ... -->
<form create="false" edit="false">
HTML Text to
</form> </field>
</record>
<!-- record ir.window for menu "about company" --->
<record id="haatglobal_ahmed_about_a" model="ir.actions.act_window">
<field name="name">HAAT_Global</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">haatglobal_ahmed.haatglobal_ahmed</field>
<field name="view_mode">form</field>
<field name="view_id" ref="globalhaatahmedviewa"/>
<field name="help" type="html">
<p> about company window </p>
</field>
</record>
<!-- record ir.window for menu "about company" --->
<record id="haatglobal_ahmed_about_s" model="ir.actions.act_window">
<field name="name">HAAT_Global</field>
<field name="type">ir.actions.act_window</field>
<field name="res_model">haatglobal_ahmed.haatglobal_ahmed</field>
<field name="view_mode">form</field>
<field name="view_id" ref="globalhaatahmedviews"/>
<field name="help" type="html">
<p>
Support window
</p>
</field>
</record>
<menuitem name="HAAT Global" id="haatglobal_ahmed.menu_root"/>
<menuitem name="About Company" id="haatglobal_ahmed.menu_a" parent="haatglobal_ahmed.menu_root" action="haatglobal_ahmed_about_about"/>
<menuitem name="Support" id="haatglobal_ahmed.menu_s" parent="haatglobal_ahmed.menu_root"
action="haatglobal_ahmed_about_about" />
</code></pre>
<p>was that right?</p>
<p>My target is to create (main menu) and (two sub menu) if I click on the (sub menu) it will show just text in the page.</p>
<p>Thanks for help in advance</p>
<p>I'm odoo 15</p>
| [
{
"answer_id": 74145710,
"author": "Fastnlight",
"author_id": 20153035,
"author_profile": "https://Stackoverflow.com/users/20153035",
"pm_score": 2,
"selected": false,
"text": "info"
},
{
"answer_id": 74145979,
"author": "Ruan Mendes",
"author_id": 227299,
"author_pro... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19344511/"
] |
74,145,688 | <p>I have this data:</p>
<pre><code>Animal Age Animal (Unique)
Dog 4 Dog
Dog 3 Cat
Cat 10 Bird
Bird 1
Cat 2
Bird 3
Cat 2
Dog 12
</code></pre>
<p>I want to find the max values, so I tried this:</p>
<pre><code>Animal Age Animal (Unique) Max_age
Dog 4 Dog MAX(IF(A:A=C2,B:B))
Dog 3 Cat MAX(IF(A:A=C3,B:B))
Cat 10 Bird MAX(IF(A:A=C4,B:B))
Bird 1
Cat 2
Bird 3
Cat 2
Dog 12
</code></pre>
<p>But I have an error and I dont know why.</p>
| [
{
"answer_id": 74145710,
"author": "Fastnlight",
"author_id": 20153035,
"author_profile": "https://Stackoverflow.com/users/20153035",
"pm_score": 2,
"selected": false,
"text": "info"
},
{
"answer_id": 74145979,
"author": "Ruan Mendes",
"author_id": 227299,
"author_pro... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145688",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17205925/"
] |
74,145,711 | <p>I am new to the Regex and the grammar made me confused. Here is the original string field : <code>(f-dqcn-bus1),(f-cdqc-bus2)</code></p>
<p>I would like to have the new result like <code>bus1,bus2</code>.</p>
<p>There could be one or several parenthesis but the bus name is always after the second hyphen in each parenthesis. I plan to use the <code>str.findall(regex_pattern)</code> to extract, and could anyone help to develop the regex_pattern here? Thanks very much!</p>
| [
{
"answer_id": 74145812,
"author": "Sumaia A",
"author_id": 11821378,
"author_profile": "https://Stackoverflow.com/users/11821378",
"pm_score": 2,
"selected": false,
"text": "import pandas as pd\n\ndata = [('f-dqcn-bus1'), ('f-cdqc-bus2')]\ndf = pd.DataFrame(data, columns=['column_name']... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145711",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19453983/"
] |
74,145,717 | <p>I quote the <a href="https://doc.rust-lang.org/std/primitive.reference.html" rel="noreferrer">official documentation</a>:</p>
<blockquote>
<p>A reference represents a borrow of some owned value.</p>
</blockquote>
<p>Coming from C, Java, Perl and PHP, I see a "reference" as an <em>address</em> (or <em>pointer</em>) to a value. It is possible to declare a variable of type "T" or a reference (or pointer) to a variable of type "T" (using <code>&</code> - or <code>\</code> in Perl).</p>
<p>However, I am not sure that this representation is totally valid with Rust. Something bothers me.</p>
<p>I always see the "string slice" manipulated as a reference, that is, in its borrowed form (<code>&str</code>).</p>
<p>I have (so far) never seen a variable of type "<code>str</code>".</p>
<p>I tried to declare a variable of type "<code>str</code>"... but the compiler does not let me do that.</p>
<p><strong>QUESTION: can we define a variable of type "<code>str</code>" ?</strong></p>
<p>If it is impossible, then it means that we are facing a type of data that cannot be declared other than as a reference. This seems weird...</p>
| [
{
"answer_id": 74145851,
"author": "jthulhu",
"author_id": 5956261,
"author_profile": "https://Stackoverflow.com/users/5956261",
"pm_score": 3,
"selected": false,
"text": "str"
},
{
"answer_id": 74145962,
"author": "Kevin Reid",
"author_id": 99692,
"author_profile": "... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4487348/"
] |
74,145,729 | <p>I created a secret in <code>us-east-1</code> region. I am able to dynamically reference the secret in CloudFormation stack template deployed to region <code>us-east-1</code>. The command in template looks something like</p>
<pre><code>{{resolve:secretsmanager:arn:aws:secretsmanager:us-east-1:<accountId>:secret:<secretName>:SecretString:<secretKey>::}}
</code></pre>
<p>I have another stack template being deployed to region <code>eu-west-2</code>. The command to resolve the secret looks exactly the same as described above. However, when deploying, I get CloudFormation error</p>
<pre><code>Secrets Manager can't find the specified secret. (Service: AWSSecretsManager; Status Code: 400; Error Code: ResourceNotFoundException; Request ID: <someId>; Proxy: null)
</code></pre>
<p>Based on documentation, it should be possible to resolve secrets from different AWS account when full secret ARN is specified as <code>secret-id</code>. I was not able to find any cross-region information, hence raising the question here.</p>
<blockquote>
<p><a href="https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html#dynamic-references-secretsmanager" rel="nofollow noreferrer">https://docs.aws.amazon.com/AWSCloudFormation/latest/UserGuide/dynamic-references.html#dynamic-references-secretsmanager</a></p>
</blockquote>
<p>Am I missing something that I can't import the secret from same account, but different region? Or is this not supported.</p>
| [
{
"answer_id": 74145851,
"author": "jthulhu",
"author_id": 5956261,
"author_profile": "https://Stackoverflow.com/users/5956261",
"pm_score": 3,
"selected": false,
"text": "str"
},
{
"answer_id": 74145962,
"author": "Kevin Reid",
"author_id": 99692,
"author_profile": "... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145729",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2712553/"
] |
74,145,759 | <p>Here is my situation:</p>
<ul>
<li>I'm working in a repo with 40+ submodules</li>
<li><code>git status</code> and <code>git submodule update</code> take a LONG time (submodule update is several minutes)</li>
<li>If I checkout a different commit and only a couple submodules have been changed, I can see the submodules that need updating using <code>git status</code>, then skip the long wait of a full <code>git submodule update</code> by doing</li>
</ul>
<pre><code>git submodule update <submodule path> <submodule path>
</code></pre>
<p>This will only update the submodules listed, taking only a few seconds</p>
<p>Is there a way to have <code>git submodule update</code> only update the modules that actually need it, instead of every one? I don't mind listing out a couple submodules manually, but when there's 6+, it'd be nice for git to somehow use the <code>git status</code> result to only run <code>git submodule update</code> on the ones that need it.</p>
<p>Does anyone know of any git command tricks I can do to achieve this and speed up my submodule updates? If not, is there a trick I can use to make a bash script to extract the necessary information from <code>git status</code> and build & run a <code>git submodule update <> <> <></code> command for me?</p>
<p>Bonus: is there a way to achieve a similar result on submodules that have had their content modified? That is, the submodule needs to be <code>git reset --hard HEAD</code>, not checked out to a new commit. But doing this without entering EVERY submodule, such as <code>git submodule foreach git reset --hard HEAD</code>, only ones that need it?</p>
<p>Example <code>git status --porcelain</code></p>
<pre><code>$ git status --porcelain
M ABC
M XYZ
M XXX
M YYY
M FOO/BAR
</code></pre>
| [
{
"answer_id": 74147465,
"author": "joanis",
"author_id": 3216427,
"author_profile": "https://Stackoverflow.com/users/3216427",
"pm_score": 3,
"selected": true,
"text": "git status"
},
{
"answer_id": 74165473,
"author": "jthill",
"author_id": 1290731,
"author_profile"... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11672706/"
] |
74,145,763 | <p>I'm a beginner with regular expressions and am processing data from a pdf and with R. Unfortunately R did not capture the decimal points in the data so I need to replace specific occurrences of white space with periods. I was able to figure out an admittedly heavy handed solution to this problem but suspect there is a much more efficient way to accomplish this with regular expressions. Below is some example data, the solution I am using, and the resulting data set I want to get.</p>
<pre><code>ex<-c("16 7978 38 78 651 42 651 42","25 1967 8 94 225 26 225 26",
"16 5000 8 00 132 00 132 00", "16 6125 2 00 33 23 33 23")
df<-data.frame(row=1:4,string=ex)
df
row string
1 16 7978 38 78 651 42 651 42
2 25 1967 8 94 225 26 225 26
3 16 5000 8 00 132 00 132 00
4 16 6125 2 00 33 23 33 23
df$tst<-stri_replace_first_fixed(df$string," ",".")
df$rate<-sapply(strsplit(df$tst," ",fixed=T),"[",1)
df$string2<-stri_replace_first_fixed(df$tst,df$rate,"")%>% trimws()
df$tst<-stri_replace_first_fixed(df$string2," ",".")
df$hours<-sapply(strsplit(df$tst," ",fixed=T),"[",1)
df$string3<-stri_replace_first_fixed(df$tst,df$hours,"")%>% trimws()
df$tst<-stri_replace_first_fixed(df$string3," ",".")
df$period_amt<-sapply(strsplit(df$tst," ",fixed=T),"[",1)
df$string4<-stri_replace_first_fixed(df$tst,df$period_amt,"")%>% trimws()
df$tst<-stri_replace_first_fixed(df$string3," ",".")
df$ytd_amt<-sapply(strsplit(df$tst," ",fixed=T),"[",1)
df<-df %>% dplyr::select(-string2,-string3,-tst,-string4)
df
row string rate hours period_amt ytd_amt
1 16 7978 38 78 651 42 651 42 16.7978 38.78 651.42 651.42
2 25 1967 8 94 225 26 225 26 25.1967 8.94 225.26 225.26
3 16 5000 8 00 132 00 132 00 16.5000 8.00 132.00 132.00
4 16 6125 2 00 33 23 33 23 16.6125 2.00 33.23 33.23
</code></pre>
<p>In the solution above I replace the first occurrence of white space with a period, extract the corrected number, then remove the corrected number from the string. This processing is then repeated iteratively until all values have been extracted. As I said the solution works but it seems pretty sloppy to me and would be tedious if I needed to correct and extract a large number of values from the text. Any suggestions on better ways to accomplish this in R would be greatly appreciated.</p>
<p>Thanks in advance!</p>
| [
{
"answer_id": 74147465,
"author": "joanis",
"author_id": 3216427,
"author_profile": "https://Stackoverflow.com/users/3216427",
"pm_score": 3,
"selected": true,
"text": "git status"
},
{
"answer_id": 74165473,
"author": "jthill",
"author_id": 1290731,
"author_profile"... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6106226/"
] |
74,145,764 | <p>I'm trying to validate two conditions within the function .find() as I'm able to do only one succesfully, this <code><td>{contactNames?.find(data =>{return data.contact_id_customer === report.contactIdCustomer})?.nombre}</td></code> is working perfect, it is giving the name of the customers instead of the customer id from the database, however, I need to do the same validation with contact_id_providers but we don't want to render it in a different column from the table but in the customer's column one as well, so we can only leave the name as name on that column.</p>
<p>This is the Array object contactsName list that I'm bringing from the context provider, im not able to past images.</p>
<blockquote>
<p>Array(28)0:contact_id_customer: 0contact_id_provider: 0nombre: nullpnombre: null[[Prototype]]: Object12: {contact_id_provider: 0, nombre: '464 IN-CO TELMEX G1', pnombre: null, contact_id_customer: 223}13: {contact_id_customer: 0, contact_id_provider: 5, nombre: null, pnombre: 'ARIATEL CORP'}14: {nombre: 'AGENTES MARCA 00464', contact_id_provider: 0, pnombre: null, contact_id_customer: 74}15: {contact_id_customer: 0, contact_id_provider: 2, pnombre: 'A&D MONTANA CORP', nombre: null}16: {contact_id_customer: 0, contact_id_provider: 5, nombre: null, pnombre: 'ARIATEL CORP'}17: {contact_id_customer: 0, pnombre: 'ATLANTEL INC', contact_id_provider: 6, nombre: null}18: {contact_id_provider: 67, contact_id_customer: 0, pnombre: 'ITX ETB TPBCL', nombre: null}19: {contact_id_provider: 0, pnombre: null, nombre: 'ADRIA-DMS Telecom LLC', contact_id_customer: 303}20: {contact_id_customer: 18, contact_id_provider: 0, pnombre: null, nombre: 'VARSATEL CORPORATION'}21: {nombre: 'AIRTIME TECHNOLOGIES', contact_id_provider: 0, contact_id_customer: 294, pnombre: null}22: {contact_id_customer: 0, contact_id_provider: 0, pnombre: null, nombre: null}23: {contact_id_customer: 0, contact_id_provider: 0, pnombre: null, nombre: null}24: {contact_id_customer: 0, contact_id_provider: 0, pnombre: null, nombre: null}25: {contact_id_customer: 0, contact_id_provider: 0, pnombre: null, nombre: null}26: {contact_id_provider: 0, nombre: 'XXXXX Videocon Carrier Services Limited', pnombre: null, contact_id_customer: 190}27: {contact_id_provider: 0, pnombre: null, contact_id_customer: 138, nombre: 'VASUDEV GLOBAL LTD'}length: 28[[Prototype]]: Array(0)</p>
</blockquote>
<p>I have tried this way: {contactNames?.find(data =>{return data.contact_id_customer && data.contact_id_provider === report.contactIdCustomer && report.contactIdProvider})?.nombre}
But it is only returning only the names of the provider.</p>
<p>Here is my code from the component CDRTable:</p>
<pre><code>import React, { useContext, useState } from 'react'
import { useEffect } from 'react';
import { Button, Modal } from 'react-bootstrap';
import Table from 'react-bootstrap/Table';
import { CdrsContext } from '../../contexts/CDRDownloadingContext';
import { CustomerContext } from '../../contexts/CustomerContext';
import { ProviderContext } from '../../contexts/ProviderContext';
import { UserContext } from '../../contexts/UserContext';
import UseAuth from '../../hooks/UseAuth';
import styles from '../stylePages/CDRDownloading.module.css'
const CDRTable = () => {
const { getUserDetails, record } = useContext(UserContext)
const { cdrListFiltered, getCdrsListMadeByUser, deleteCdr, getContactNames, contactNames } = useContext(CdrsContext);
const { auth } = UseAuth();
/*************************************
* GETTING THE USER ID TO GET THE LIST OF REPORT REQUESTS SENT BY THE SPECIFIC USER
//*************************************/
// Auth.username is providing an object type user from the backend, which among the properties it contains the user id.
const extractedUsername = auth.username;
// Once the user details have been loaded with the getUserDetails(extractedUsername); function which expects a username to get data.
// I get the especific user and with the record
const extractedUserById = record.serie;
//**************************************/
/**
* Function to mount the list of report requests made by the logged in user
*/
useEffect(() => {
getUserDetails(extractedUsername);
if (extractedUserById !== undefined) {
getCdrsListMadeByUser(extractedUserById)
}
}, [extractedUserById]);
const typeReport = {
0: 'Cliente',
1: 'Proveedor'
}
const callFilter = {
0: 'Contestadas',
1: 'No contestadas',
2: 'Todas'
}
const statusStage = {
0: 'Recibido',
1: 'En proceso',
2: 'Finalizado'
}
useEffect(() => {
getContactNames();
}, [])
return (
<>
<div>
<br />
</div>
<Table className={styles.table}>
<thead className={styles.tableHead}>
<tr>
<th>ID</th>
<th>SOLICITADO</th>
<th>DESDE</th>
<th>HASTA</th>
<th>TIPO</th>
<th>Nombre cliente</th>
<th>Nombre proveedor</th>
<th>NOMBRE</th> // Here is where I'm trying to get the name in this column
<th>RGIDs</th>
<th>FILTRO</th>
<th>ESTADO</th>
<th>PROCESO INICIADO</th>
<th>PROCESO FINALIZADO</th>
<th>OPCIONES</th>
</tr>
</thead>
<tbody>
{cdrListFiltered?.map((report, reportIndex) => (
<tr key={reportIndex} >
<td>{reportIndex + 1}</td>
<td>{report.requestDate}</td>
<td>{report.startDate}</td>
<td>{report.endDate}</td>
<td>{typeReport[report.reportType]}</td>
<td>{report.contactIdCustomer}</td>
<td>{report.contactIdProvider}</td>
<td>{contactNames?.find(data =>{return data.contact_id_customer === report.contactIdCustomer})?.nombre}</td>
<td>{contactNames?.find(data =>{return data.contact_id_provider === report.contactIdProvider})?.pnombre}</td>
<td>{report.rgids}</td>
<td>{callFilter[report.callQuery]}</td>
<td>{statusStage[report.status]}</td>
<td>{report.processStart}</td>
<td>{report.processFinish}</td>
<td className={styles.buttonOptions}>
<Button
variant='primary'
className={styles.btnGuardar}
>
<span className={styles.textButton}>Descargar</span>
</Button>
<Button
variant='danger'
className={styles.btnEliminar}
onClick={() => handleClickDelete(report.id)}
>
<span className={styles.textButton}>Eliminar</span>
</Button>
</td>
</tr>
)
)}
</tbody>
</Table>
</>
)
}
export default CDRTable
</code></pre>
<p>I'm a little stuck here, so I was wondering if anyone knows how to handle this type of case?</p>
| [
{
"answer_id": 74147465,
"author": "joanis",
"author_id": 3216427,
"author_profile": "https://Stackoverflow.com/users/3216427",
"pm_score": 3,
"selected": true,
"text": "git status"
},
{
"answer_id": 74165473,
"author": "jthill",
"author_id": 1290731,
"author_profile"... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145764",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20134306/"
] |
74,145,771 | <p>I am writing a code that is triggered on the current candle value, but uses the previous candle's as well. I was successful however this code looks probably kind of funny :)</p>
<p>Is there an easier way of using the previous candle value, i.o. repeating [..]?</p>
<p>Thanks a lot.</p>
<pre><code>signal6a =( signal6[12] or signal6[11] or signal6[10] or signal6[9] or signal6[8] or signal6[7] or signal6[6] or signal6[5] or signal6[4] or signal6[3] or signal6[2] or signal6[1] or signal6 or signal6[13] or signal6[14] or signal6[15] or signal6[16] or signal6[17] or signal6[18] or signal6[19] or signal6[20] or signal6[21] or signal6[22] or signal6[23] or signal6[24] or signal6[25] or signal6[26] or signal6[27] or signal6[28] or signal6[29] or signal6[30] or signal6[31] or signal6[32] or signal6[33] or signal6[34] or signal6[35] or signal6[36] or signal6[37] or signal6[38] or signal6[39] or signal6[40]) and high >ta.ema(high, 8)
</code></pre>
| [
{
"answer_id": 74145975,
"author": "mr_statler",
"author_id": 17978157,
"author_profile": "https://Stackoverflow.com/users/17978157",
"pm_score": 0,
"selected": false,
"text": "signal6"
},
{
"answer_id": 74145977,
"author": "vitruvius",
"author_id": 7209631,
"author_p... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20295244/"
] |
74,145,785 | <p>I need to output the contents of a directory only if the file has been created within the last year.</p>
<pre><code><?php
$dirpath = "Dir/foo/bar/";
$files = array();
$files = glob($dirpath . "*");
rsort($files);
$today = date("Y-m-d");
$lastYear = date("Y-m-d", strtotime("-1 years"));
$todayTimeStamp = strtotime($today);
$beginningTimeTtamp = strtotime($lastYear);
foreach($files as $item) {
if(filetime($item) > $beginningTimeStamp && < $todayTimeStamp) {
echo "basename($item)";
}
}
</code></pre>
<p>This doesn't return anything - I just want to return $item that is greater than the date a year from today and less than today (not necessary?).</p>
<p>Am I wrong converting the $beginningTimeStamp and $todayTimeStamp to a timestamp to compare filetime? Im not able to convert each $item to its filetime... Is there a better way to do this?</p>
| [
{
"answer_id": 74145975,
"author": "mr_statler",
"author_id": 17978157,
"author_profile": "https://Stackoverflow.com/users/17978157",
"pm_score": 0,
"selected": false,
"text": "signal6"
},
{
"answer_id": 74145977,
"author": "vitruvius",
"author_id": 7209631,
"author_p... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145785",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/362437/"
] |
74,145,793 | <p>My script currently works to send me an error alert if my .py script fails. However, sometimes the script is not necessarily failing. its just that there are no files for it to process. My final objective is to alter my email alerting script in such a way that if Combine.csv is not present in directory(src),then DONT send me error an email. How do i achieve this?</p>
<pre><code>import pandas as pd
import smtplib
from email.message import EmailMessage
import glob
import os
import shutil
df = pd.read_fwf(r'Combine.csv', header=None)
end_str = '#--- END --'
cols_to_check = ["0"]
def email_alert(subject,body,to):
msg = EmailMessage()
msg.set_content(body)
msg['subject'] = subject
msg['to'] = to
user = "DataScienceScriptAlerts@afonsfu.com"
msg['from'] = user
server = smtplib.SMTP("smtpray.corp.group.com", 25)
server.starttls()
#server.login(user,password)
server.send_message(msg)
server.quit()
src = r'C:/R'
dest = r'C:/R/Failed Scripts'
if __name__ == '__main__':
for col in cols_to_check:
if not df[0].str.contains(end_str).any():
body = "The Combine.py script in IV had errors on the last execution" + col + "."
print(body)
email_alert("Combine failure alert",body,"htvldba@group.com")
if not df[0].str.contains(end_str).any():
for file_path in glob.glob(os.path.join(src,'*.Rout'), recursive=True):
new_path = os.path.join(dest, os.path.basename(file_path))
shutil.copy(file_path, new_path)
</code></pre>
| [
{
"answer_id": 74145975,
"author": "mr_statler",
"author_id": 17978157,
"author_profile": "https://Stackoverflow.com/users/17978157",
"pm_score": 0,
"selected": false,
"text": "signal6"
},
{
"answer_id": 74145977,
"author": "vitruvius",
"author_id": 7209631,
"author_p... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145793",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18572659/"
] |
74,145,805 | <p>Following old advices <a href="https://stackoverflow.com/a/13429948/1791306">here</a> and <a href="https://stackoverflow.com/a/38172245/1791306">here</a>
I'm curious what is the proper syntax for APACHE server:</p>
<pre><code>AddType font/woff2 .woff2
ExpiresByType font/woff2 "access plus 1 year"
</code></pre>
<p>or</p>
<pre><code>AddType application/woff2 .woff2
ExpiresByType application/woff2 "access plus 1 year"
</code></pre>
| [
{
"answer_id": 74146052,
"author": "Valeriu Ciuca",
"author_id": 4527645,
"author_profile": "https://Stackoverflow.com/users/4527645",
"pm_score": 0,
"selected": false,
"text": "ExpiresActive on"
},
{
"answer_id": 74147405,
"author": "MrWhite",
"author_id": 369434,
"a... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1791306/"
] |
74,145,817 | <p>is it possible to hide/show column items based on another field in SharePoint 365?</p>
<p>Example:</p>
<p>In first column I have:</p>
<ul>
<li>Item 1</li>
<li>Item 2</li>
<li>Item 3</li>
</ul>
<p>In second column I have:</p>
<ul>
<li>Item A</li>
<li>Item B</li>
<li>Item C</li>
<li>Item D</li>
</ul>
<p>I need when I select the item in first column, in the second only appaers some of them:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>First Column</th>
<th>Second Colum</th>
</tr>
</thead>
<tbody>
<tr>
<td>Item 1</td>
<td>Item A</td>
</tr>
<tr>
<td>Item 1</td>
<td>Item B</td>
</tr>
<tr>
<td>Item 2</td>
<td>Item C</td>
</tr>
<tr>
<td>Item 3</td>
<td>Item D</td>
</tr>
</tbody>
</table>
</div>
<p>PS: I don't have "admin center" access and I can't use Power Apps in this case.</p>
| [
{
"answer_id": 74146052,
"author": "Valeriu Ciuca",
"author_id": 4527645,
"author_profile": "https://Stackoverflow.com/users/4527645",
"pm_score": 0,
"selected": false,
"text": "ExpiresActive on"
},
{
"answer_id": 74147405,
"author": "MrWhite",
"author_id": 369434,
"a... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145817",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11562321/"
] |
74,145,828 | <p>I'm reading a blog post and trying to understand what's going on.
<a href="https://martinfowler.com/articles/replaceThrowWithNotification.html" rel="nofollow noreferrer">This is the blogpost.</a></p>
<p>it has this code:</p>
<pre><code>if (validation().hasErrors())
throw new IllegalArgumentException(validation().errorMessage());
</code></pre>
<p>In the validation() method we have some object initialization and calculations so let' say it's an expensive call. Is it going to be executed twice? Or will it be optimized by the compiler to be something like this?</p>
<pre><code>var validation = validation();
if (validation.hasErrors())
throw new IllegalArgumentException(validation.errorMessage());
</code></pre>
<p>Thanks!</p>
| [
{
"answer_id": 74146026,
"author": "Ahmad Mtera",
"author_id": 17350710,
"author_profile": "https://Stackoverflow.com/users/17350710",
"pm_score": 2,
"selected": false,
"text": "int[] grades = new int[500];\nint countOfGrades = arr.length;\nfor (int i = 0; i < countOfGrades; i++) {\n ... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8362224/"
] |
74,145,837 | <p>I have the below code for populating my dataframe (final_df) with either a '1' or a '0' based on the year and the month columns, into a new column called 'Lockdown'.</p>
<p>My code is not working - is there a more efficient way to write this?</p>
<pre><code>
import numpy
conditions = [
(final_df['Year'] == 2020) & (final_df['Month'] == 3),
(final_df['Year'] == 2020) & (final_df['Month'] == 4),
(final_df['Year'] == 2020) & (final_df['Month'] == 5),
(final_df['Year'] == 2020) & (final_df['Month'] == 6),
(final_df['Year'] == 2020) & (final_df['Month'] == 10),
(final_df['Year'] == 2020) & (final_df['Month'] == 11),
(final_df['Year'] == 2020) & (final_df['Month'] == 12),
(final_df['Year'] == 2021) & (final_df['Month'] == 1),
(final_df['Year'] == 2021) & (final_df['Month'] == 2),
(final_df['Year'] == 2021) & (final_df['Month'] == 3)
]
values = ['1']
final_df['Lockdown'] = np.select(conditions, values)
final_df.head()
</code></pre>
<p>Thank you</p>
| [
{
"answer_id": 74146026,
"author": "Ahmad Mtera",
"author_id": 17350710,
"author_profile": "https://Stackoverflow.com/users/17350710",
"pm_score": 2,
"selected": false,
"text": "int[] grades = new int[500];\nint countOfGrades = arr.length;\nfor (int i = 0; i < countOfGrades; i++) {\n ... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145837",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18738272/"
] |
74,145,872 | <p>I have a form where users can use a DateTimepicker to select a starting time and date or click on a "use current time" button to get the starting time and date. Also, for the ending date and time, the users can use DateTimepicker for selection or use one of 3 buttons labeled <code>30 minutes</code>, <code>1 hour</code> and <code>4 hours</code> which adds 30 minutes, 1 hr and 4 hrs to the starting time respectively.</p>
<p>But when I click on any of this button, it only works once. Then I have to click on another before I see any change again.</p>
<p><strong>My Aim</strong></p>
<p>I want it such that, when I click on <code>30 minutes</code>, it adds 30 minutes to the starting time, if I click on it again, it adds another 30 minutes. And, if I then click on the <code>1 hour</code>, it adds 1 hr to the time I have already.</p>
<p>This is my code shown below. How can I achieve my aim?</p>
<pre><code>...
<div className={`time-buttons-container ${!showTime ? "hide-buttons" : ""}`}>
<button className={`time-buttons`} onClick={() => addTime(1, 30)}> + 30 mins</button>
<button className={`time-buttons`} onClick={() => addTime(1, 60)}>+ 1 hour</button>
<button className={`time-buttons`} onClick={() => addTime(4, 60)}>+ 4 hours</button>
</div>
...
</code></pre>
<p><strong>The adding function</strong></p>
<pre><code>const addTime = (hours, minutes) => {
let dateVar;
let timeVar;
if(!startDate ){
dateVar = createDateAsUTC()
} else {
dateVar = startDate
}
if(!startTime ){
timeVar = createDateAsUTC();
} else {
timeVar = startTime
}
const getDate = new Date(dateVar)
const getHours = new Date(timeVar).getHours()
const getMinutes = new Date(timeVar).getMinutes()
const dateTime = new Date(getDate).setHours(getHours, getMinutes);
const thirtyMinutes = hours * minutes * 60 * 1000;
const futureTime = new Date().setTime(dateTime + thirtyMinutes);
const newTime = new Date(futureTime)
setStartDate(dateVar)
setStartTime(timeVar)
setEndDate(newTime);
setEndTime(newTime);
};
</code></pre>
<p><strong>My states</strong></p>
<pre><code> const [startDate, setStartDate] = useState("");
const [endDate, setEndDate] = useState("");
const [showTime, setTime] = useState(false);
const [startTime, setStartTime] = useState("");
const [endTime, setEndTime] = useState("");
</code></pre>
<p>Thanks for your responses.</p>
| [
{
"answer_id": 74146026,
"author": "Ahmad Mtera",
"author_id": 17350710,
"author_profile": "https://Stackoverflow.com/users/17350710",
"pm_score": 2,
"selected": false,
"text": "int[] grades = new int[500];\nint countOfGrades = arr.length;\nfor (int i = 0; i < countOfGrades; i++) {\n ... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18303212/"
] |
74,145,890 | <p>after long nights of programming, I have finally finished my app and would now like to upload it to the AppStore Connect for testing purposes, but I always get the same 2 error messages because of certain sizes of the app icon are missing (screenshot attached). I have tried pretty much everything from Stackoverflow, but nothing helped or a lot of things are already out of date, because in Xcode 14 you can only specify one size for the app icon (1.024px x 1.024px).</p>
<p>Does anyone here have a solution for this problem?</p>
<p>The "AppIcon" is in the <code>Assets.xcassets</code> folder & I added some attributes in the <code>info.plist</code> file to eliminate some other error messages. (Do I have to add my App as a target in the info.plist file, because I get some errors when I do?)</p>
<p><strong>AppIcon in Assets folder</strong>
<a href="https://i.stack.imgur.com/K4BMH.png" rel="nofollow noreferrer">AppIcon in Assets folder</a></p>
<p><strong>Info.plist file</strong>
<a href="https://i.stack.imgur.com/kFETJ.png" rel="nofollow noreferrer">Info.plist File</a></p>
<p><strong>Error messages</strong>
<a href="https://i.stack.imgur.com/mrvX3.png" rel="nofollow noreferrer">Error messages</a></p>
<p>Sorry I'm new to stackoverflow so I can't post images directly.</p>
| [
{
"answer_id": 74200221,
"author": "SCH361",
"author_id": 19307953,
"author_profile": "https://Stackoverflow.com/users/19307953",
"pm_score": 1,
"selected": true,
"text": "Assets.xcassets"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19307953/"
] |
74,145,905 | <p>I'm trying to be able to upload an Excel file to populate the Line Details Smart Panel grid, but having no luck.</p>
<p>I've set the "AllowUploads" Mode Layout property to "true" - and it shows the icon - but it's always disabled:</p>
<p><a href="https://i.stack.imgur.com/hctPe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hctPe.png" alt="enter image description here" /></a></p>
<p>I've also redefined the splits view in the BLC extension to add the following attribute:</p>
<p><a href="https://i.stack.imgur.com/bIVfn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bIVfn.png" alt="enter image description here" /></a></p>
<p>I've also tried to use a RowSelected event in the business logic to AllowUpdate - but there is no property in the "splits" view to enabled that.</p>
<p>Bottom line: How can I enable this button and allow file uploads?</p>
| [
{
"answer_id": 74200221,
"author": "SCH361",
"author_id": 19307953,
"author_profile": "https://Stackoverflow.com/users/19307953",
"pm_score": 1,
"selected": true,
"text": "Assets.xcassets"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145905",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3923540/"
] |
74,145,914 | <pre><code>$response = Invoke-WebRequest -Uri 'BLAHBLAHBLAH' -Method POST `
-Headers $headers `
-ContentType 'application/json' `
-Body '{"archived":false,"warranty_months":null,
"depreciate":false,
"supplier_id":null,
"requestable":false,
"rtd_location_id":null,
"last_audit_date":"null",
"location_id":null,
"status_id":2,
"model_id":34,
"serial":$SERIAL,
"name":$COMPUTERNAME}'
</code></pre>
<p>For the body portion, i've used double and single quotes to no avail. I've used the <code>" </code>" and ${SERIAL} and that hasn't helped either. I can use single quotes to make the call but am not able to use my SERIAL variable. Any ideas?</p>
| [
{
"answer_id": 74200221,
"author": "SCH361",
"author_id": 19307953,
"author_profile": "https://Stackoverflow.com/users/19307953",
"pm_score": 1,
"selected": true,
"text": "Assets.xcassets"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145914",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20295362/"
] |
74,145,917 | <p>I don’t know how it is possible for the number to have the last 5 digits ... I will be very grateful for the help!</p>
<pre><code>const num = 1666297292886;
//result
1666297200000
</code></pre>
| [
{
"answer_id": 74145933,
"author": "Pac0",
"author_id": 479251,
"author_profile": "https://Stackoverflow.com/users/479251",
"pm_score": 4,
"selected": true,
"text": "const num = 1666297292886;\n\nconst roundedDownResult = num - (num % 100000);\nconsole.log(roundedDownResult);"
},
{
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145917",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19744543/"
] |
74,145,918 | <ol>
<li>Ran <code>git log</code>, which showed following</li>
</ol>
<pre><code>commit on master( in my case, it is develop branch) a867b4af366350be2e7c21b8de9cc6504678a61b`
Author: Me <me@me.com>
Date: Thu Nov 4 18:59:41 2010 -0400
blah blah blah...
commit 25eee4caef46ae64aa08e8ab3f988bc917ee1ce4
Author: Me <me@me.com>
Date: Thu Nov 4 05:13:39 2010 -0400
more blah blah blah...
commit 0766c053c0ea2035e90f504928f8df3c9363b8bd
Author: Me <me@me.com>
Date: Thu Nov 4 00:55:06 2010 -0400
And yet more blah blah...
commit 0d1d7fc32e5a947fbd92ee598033d85bfc445a50
Author: Me <me@me.com>
Date: Wed Nov 3 23:56:08 2010 -0400
Yep, more blah blah.
</code></pre>
<ol start="2">
<li><p>As I'm not able to revert or reset my master branch to certain commit, created a new branch from the old commit, which contains the deleted branch by running following command</p>
<p>git checkout -b "branch_name" 0d1d7fc32e5a947fbd92ee598033d85bfc445a50</p>
</li>
</ol>
<p>USING git hash of 03 November 2010, created a new branch (this commit contains the xyz.java file which does not exist in the latest commit on master (develop) branch)</p>
<ol start="3">
<li>Do not have any more changes to make in this new branch (created in step 2 above). purpose of creating this new branch was to revert the xyz.java file, which has been deleted in master. Pushed this new branch to remote.</li>
</ol>
<p>Git does not allow me to create a PR for this new branch as it shows an error that this new branch does not contain any change, which is not already contained in develop.</p>
<p>If I rebase my new branch with master (develop, in my case) by running following command, it deletes xyz.java file from my new branch.</p>
<pre><code>git pull origin develop
</code></pre>
<p>How do you get xyz.java file back in my new branch, which allows git to recognise this new branch contains xyz.java file, which has been deleted in master branch?</p>
| [
{
"answer_id": 74146815,
"author": "Ivan Yuzafatau",
"author_id": 1889110,
"author_profile": "https://Stackoverflow.com/users/1889110",
"pm_score": 0,
"selected": false,
"text": "git checkout <hash> -- <full/path/to/the/file>\n"
},
{
"answer_id": 74147346,
"author": "joanis",... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6588518/"
] |
74,145,924 | <p>I'm trying to get the html structure of multiple websites using NodeJS, and I'm having difficulties. I want to get just the HTML structure of the document, and no content. I want to preserve classes, IDs, and other attributes.</p>
<p>Example of what I want back:</p>
<pre><code><title></title>
</head>
<body>
<h1></h1>
<div>
<div class="something">
<p></p>
</div>
</div>
</body>
</code></pre>
<p>Any suggestion on how to do this? Thanks</p>
| [
{
"answer_id": 74146010,
"author": "Mina",
"author_id": 11887902,
"author_profile": "https://Stackoverflow.com/users/11887902",
"pm_score": 1,
"selected": false,
"text": "match"
},
{
"answer_id": 74146205,
"author": "IT goldman",
"author_id": 3807365,
"author_profile"... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145924",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/194319/"
] |
74,145,973 | <p>I have two dataframe like:</p>
<pre><code>import pandas as pd
df1 = pd.DataFrame({'Airplanes' : ['U-2','B-52,P-51', 'F-16', 'MiG-21,F-16;A-10', 'P-51','A-10;P-51' ],
'Company' : ['Air_1', 'Air_3', 'Air_2','Air_1', 'Air_7', 'Air_3']})
------------------------------
Airplanes Company
0 U-2 Air_1
1 B-52,P-51 Air_3
2 F-16 Air_2
3 MiG-21,F-16;A-10 Air_1
4 P-51 Air_7
5 A-10;P-51 Air_3
-------------------------------
df2 = pd.DataFrame({'Model' : ['U-2','B-52', 'F-16', 'MiG-21', 'P-51','A-10' ],
'Description' : ['Strong', 'Huge', 'Quick','Light', 'Silent', 'Comfortable']})
------------------------------
Model Description
0 U-2 Strong
1 B-52 Huge
2 F-16 Quick
3 MiG-21 Light
4 P-51 Silent
5 A-10 Comfortable
------------------------------
</code></pre>
<p>I would like to insert the information of df2 inside df1. In particular, the Description column must appear in df1, respecting the separators of the df1 column ['Airplanes'].
So in this case the output should be:</p>
<pre><code>---------------------------------------------------------
Airplanes Company Description
0 U-2 Air_1 Srong
1 B-52,P-51 Air_3 Huge,Silent
2 F-16 Air_2 Quick
3 MiG-21,F-16;A-10 Air_1 Light,Quick;Comfortable
4 P-51 Air_7 Silent
5 A-10;P-51 Air_3 Comfortable;Silent
--------------------------------------------------------
</code></pre>
<p>How can I do?</p>
| [
{
"answer_id": 74146095,
"author": "BENY",
"author_id": 7964527,
"author_profile": "https://Stackoverflow.com/users/7964527",
"pm_score": 1,
"selected": false,
"text": "split"
},
{
"answer_id": 74146100,
"author": "mozway",
"author_id": 16343464,
"author_profile": "ht... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20294394/"
] |
74,145,981 | <p>I'm playing with ND4J basics to come up to speed with its linear algebra capabilities.</p>
<p>I'm running on a Macbook Pro using <code>nd4j-api</code> and <code>nd4j-native</code> dependencies version 1.0.0-M2.1, Open JDK version 17, Kotlin 1.7.20, and IntelliJ 2022.2.2 Ultimate Edition.</p>
<p>I'm writing JUnit 5 tests to perform simple operations: add, subtract, multiply, and divide a 2x2 matrix and a scalar. All are successful and pass just fine.</p>
<p>I was successful at adding a 1x2 row vector to the first and second rows of a 2x2 matrix:</p>
<pre><code>@ParameterizedTest
@ValueSource(longs = [0L, 1L])
fun `add a row vector to each row in a matrix`(rowIndex : Long) {
// setup
val a = Nd4j.create(doubleArrayOf(1.0, 2.0, 3.0, 4.0), intArrayOf(2, 2))
val row = Nd4j.create(doubleArrayOf(11.0, 13.0), intArrayOf(2))
// Adds the row vector to all rows
val expected = arrayOf(
Nd4j.create(doubleArrayOf(12.0, 15.0, 3.0, 4.0), intArrayOf(2, 2)),
Nd4j.create(doubleArrayOf(1.0, 2.0, 14.0, 17.0), intArrayOf(2, 2)))
// exercise
a.getRow(rowIndex).addi(row)
// assert
Assertions.assertEquals(expected[rowIndex.toInt()], a)
}
</code></pre>
<p>I try to duplicate the trick by adding a 2x1 column vector to the 2x2 matrix:</p>
<pre><code>@Test
fun `add a column vector to the second column of a matrix`() {
// setup
val a = Nd4j.create(doubleArrayOf(1.0, 2.0, 3.0, 4.0), intArrayOf(2, 2))
val col = Nd4j.create(doubleArrayOf(11.0, 13.0), intArrayOf(2, 1))
// Adds the row vector to all rows
val expected = Nd4j.create(doubleArrayOf(1.0, 2.0, 14.0, 17.0), intArrayOf(2, 2))
// exercise
a.getColumn(1).addi(col)
// assert
Assertions.assertEquals(expected, a)
}
</code></pre>
<p>I get an error saying that the array shapes don't match:</p>
<pre><code>java.lang.IllegalStateException: Cannot perform in-place operation "addi": result array shape does not match the broadcast operation output shape: [2].addi([2, 1]) != [2].
In-place operations like x.addi(y) can only be performed when x and y have the same shape, or x and y are broadcastable with x.shape() == broadcastShape(x,y)
</code></pre>
<p>I have not been successful in figuring out why. Can anyone see where I've gone wrong and suggest a solution?</p>
| [
{
"answer_id": 74146599,
"author": "Adam Gibson",
"author_id": 5131255,
"author_profile": "https://Stackoverflow.com/users/5131255",
"pm_score": 2,
"selected": true,
"text": "INDArray vec = Nd4j.zeros(5);\nvec.getColumn(0).addi(vec.reshape(5,1));\n"
},
{
"answer_id": 74153648,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145981",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/37213/"
] |
74,145,987 | <p>Suppose I have the dataframe below:</p>
<pre><code>>colnames(df)
>[1] "0939.HK.Open" "0939.HK.High" "0939.HK.Low" "0939.HK.Close" "0939.HK.Volume" "0939.HK.Adjusted"
</code></pre>
<p>Wondering if I can replace column name with a defined symbol?</p>
<pre><code>>symbol<-'0123.KI'
</code></pre>
<p>And what I would like to obtain is:</p>
<pre><code>>[1] "0123.KI.Open" "0123.KI.High" "0123.KI.Low" "0123.KI.Close" "0123.KI.Volume" "0123.KI.Adjusted"
</code></pre>
<p>Thank you so much guys.</p>
| [
{
"answer_id": 74146051,
"author": "zx8754",
"author_id": 680068,
"author_profile": "https://Stackoverflow.com/users/680068",
"pm_score": 3,
"selected": true,
"text": "colnames(df) <- paste0(symbol, \".\", tools::file_ext(colnames(df)))\n"
},
{
"answer_id": 74146087,
"author"... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145987",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16601198/"
] |
74,145,993 | <p>I have a character that should "eat" for 200 microseconds, "sleep" for 200 microseconds, and repeat, until they die, which happens if they haven't eaten for <code>time_to_die</code> microseconds.</p>
<p>In the code snippet in function <code>main</code> indicated below, the struct <code>time_to_die</code> has a member <code>tv_usec</code> configured for 1000 microseconds and I expect it to loop forever.</p>
<p>After some time, one execution of the function <code>busy_wait</code> takes around 5 times more than it is supposed to (enough to kill the character), and the character dies. I want to know why and how to fix it.</p>
<pre><code>#include <sys/time.h>
#include <stdio.h>
#include <stdlib.h>
#include <stdbool.h>
struct timeval time_add_microseconds(struct timeval time, long long microseconds)
{
time.tv_usec += microseconds;
while (time.tv_usec >= 1000000)
{
time.tv_sec += 1;
time.tv_usec -= 1000000;
}
return (time);
}
short time_compare(struct timeval time_one, struct timeval time_two)
{
if (time_one.tv_sec != time_two.tv_sec)
{
if (time_one.tv_sec > time_two.tv_sec)
return (1);
else
return (-1);
}
else
{
if (time_one.tv_usec > time_two.tv_usec)
return (1);
else if (time_one.tv_usec == time_two.tv_usec)
return (0);
else
return (-1);
}
}
// Wait until interval in microseconds has passed or until death_time is reached.
void busy_wait(int interval, struct timeval last_eaten_time, struct timeval time_to_die)
{
struct timeval time;
struct timeval end_time;
struct timeval death_time;
gettimeofday(&time, NULL);
end_time = time_add_microseconds(time, interval);
death_time = time_add_microseconds(last_eaten_time, time_to_die.tv_sec * 1000000ULL + time_to_die.tv_usec);
while (time_compare(time, end_time) == -1)
{
gettimeofday(&time, NULL);
if (time_compare(time, death_time) >= 0)
{
printf("%llu died\n", time.tv_sec * 1000000ULL + time.tv_usec);
exit(1);
}
}
}
int main(void)
{
struct timeval time;
struct timeval time_to_die = { .tv_sec = 0, .tv_usec = 1000};
struct timeval last_eaten_time = { .tv_sec = 0, .tv_usec = 0 };
while (true)
{
gettimeofday(&time, NULL);
printf("%llu eating\n", time.tv_sec * 1000000ULL + time.tv_usec);
last_eaten_time = time;
busy_wait(200, last_eaten_time, time_to_die);
gettimeofday(&time, NULL);
printf("%llu sleeping\n", time.tv_sec * 1000000ULL + time.tv_usec);
busy_wait(200, last_eaten_time, time_to_die);
}
}
</code></pre>
<p>Note: Other than the system functions I already used in my code, I'm only allowed to use usleep, write, and malloc and free.</p>
<p>Thank you for your time.</p>
| [
{
"answer_id": 74146486,
"author": "John Bollinger",
"author_id": 2402272,
"author_profile": "https://Stackoverflow.com/users/2402272",
"pm_score": 1,
"selected": false,
"text": "gettimeofday"
},
{
"answer_id": 74146511,
"author": "wkz",
"author_id": 715363,
"author_p... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15045752/"
] |
74,145,997 | <p>I was coding along Colt Steele's Web developer bootcamp. This is the original file [link] I was confused on line 5, while loop on line 5 continues as long as we don't type "quit" or "q". It requires only one thing "quit" or "q" to close the loop, when I type either "quit" or "q" loop closes. Only one thing to close the loop ("quit" or "q") But I read that AND need both conditions in order to be true. Isn't it ? And when I use || instead of && it behaves oddly. Can anyone explain plz? Thank you in advance.</p>
| [
{
"answer_id": 74146035,
"author": "Konrad",
"author_id": 5089567,
"author_profile": "https://Stackoverflow.com/users/5089567",
"pm_score": 0,
"selected": false,
"text": "command"
},
{
"answer_id": 74146082,
"author": "Libor",
"author_id": 5940854,
"author_profile": "... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74145997",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20295419/"
] |
74,146,000 | <p>That is my current dao</p>
<pre><code>@PrimaryKey(autoGenerate = true)
val id: Int,
val name: String,
val date: LocalDate,
val amount: Int,
val uri: String,
val tag: String,
val toList: Boolean,
val inUse: Boolean,
val listValue: Int
</code></pre>
<p>now I have the problem that in a previous version of that dao there is a variable in that table that I now want to remove.</p>
<p>I found a 4 step guid:</p>
<p>1.) create new table 2.) insert from the old table 3.) drop the old table 4.) alter new table name back to old table name</p>
<p>that's fine but my problem is that I have a variable with a LocalDate which uses a DateTypeConverter to function properly.</p>
<p>How do I insert that LocalDate into the new table? I just know of TEXT and INTEGER</p>
| [
{
"answer_id": 74146035,
"author": "Konrad",
"author_id": 5089567,
"author_profile": "https://Stackoverflow.com/users/5089567",
"pm_score": 0,
"selected": false,
"text": "command"
},
{
"answer_id": 74146082,
"author": "Libor",
"author_id": 5940854,
"author_profile": "... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146000",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19127469/"
] |
74,146,012 | <p>I have a Win UI 3 app that checks it here is a new update available, it dowloads the installer, but is it possible to execute such installer without closing the app?</p>
<ul>
<li>How execute the installer from the code?</li>
<li>How to handle tha installation from within the app without closing?</li>
</ul>
<p>Is it to complex? or should I just have the user do it manually?</p>
| [
{
"answer_id": 74146035,
"author": "Konrad",
"author_id": 5089567,
"author_profile": "https://Stackoverflow.com/users/5089567",
"pm_score": 0,
"selected": false,
"text": "command"
},
{
"answer_id": 74146082,
"author": "Libor",
"author_id": 5940854,
"author_profile": "... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146012",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7327744/"
] |
74,146,020 | <p>I'm working on a program for a course of mine, so I'd appreciate it if answers were kept abstract. I am working on a key-value hash table in C that stores a string for a key and an int for the value. I'm getting a segmentation fault on the helper function for the put() method. Below is the problematic code. I've changed it slightly for academic honesty purposes, and I've only included the parts that lead up to the error. I've tried adjusting how I dereference or don't dereference <code>table[index]->symbol</code>, but to no avail. I'm thinking that that line that the SEGFAULT is happening on probably isn't the culprit, but I'm struggling to find where it might otherwise appear. Any help on this matter would be greatly appreciated, be it GDB hints, high-level explanations, etc. I just ask that code snippets be kept vague so that I actually learn, rather than just being told an answer. Thank you!</p>
<pre><code>#include <stdlib.h>
#include <string.h>
#include <stdio.h>
typedef struct elem_t elem_t;
struct elem_t {
const char* symbol;
void* data;
elem_t* next;
};
typedef struct {
size_t length;
size_t size;
elem_t** table;
} table_t;
static unsigned int hash(const char *str) {
const unsigned int p = 16777619;
unsigned int hash = 2166136261u;
while (*str) {
hash = (hash ^ *str) * p;
str += 1;
}
hash += hash << 13;
hash ^= hash >> 7;
hash += hash << 3;
hash ^= hash >> 17;
hash += hash << 5;
return hash;
}
void *createTable(int sizeHint) {
table_t* table;
table = malloc(sizeof(table));
if (table == NULL) {
return NULL;
}
table->length = 0;
table->size = sizeHint * 2;
table->table = calloc(table->size, sizeof(elem_t*));
if (table->table == NULL) {
free(table);
return NULL;
}
return table;
}
static const char* putHelper(elem_t** table, size_t size, const char* symbol, void* data, size_t* length) {
unsigned int hashVal = hash(symbol);
size_t index = (size_t)(hashVal & (unsigned int)(size - 1));
while (table[index]->symbol != NULL) { // !!! SEGFAULT HERE !!!
if (strcmp(symbol, table[index]->symbol) == 0) { // collision
elem_t* cur = table[index];
while (table[index]->next != NULL) { // separate chaining
cur = cur->next;
}
elem_t* newElem = (elem_t*)malloc(sizeof(elem_t)); // make new element to hang at the end of the chain
cur->next = newElem;
newElem->data = data;
newElem->symbol = symbol;
newElem->next = NULL;
return newElem->symbol;
}
index++;
if (index >= size) {
index = 0;
}
}
if (length != NULL) {
symbol = strdup(symbol);
if (symbol == NULL) {
return NULL;
}
(*length)++;
}
table[index]->symbol = (char*)symbol;
table[index]->data = data;
return symbol;
}
int put(void *tableHandle, const char *symbol, void *data) {
table_t* table = (table_t*)tableHandle;
if (data == NULL) {
return 0;
}
table->length++;
const char* result = putHelper(table->table, table->size, symbol, data, &table->length);
if (result != NULL) {
return 1;
} else {
return 0;
}
}
int main() {
table_t* table = createTable(200);
int result = put(table, "t1", 25);
if (result == 0) {
printf("put failed");
return 1;
}
}
</code></pre>
| [
{
"answer_id": 74146035,
"author": "Konrad",
"author_id": 5089567,
"author_profile": "https://Stackoverflow.com/users/5089567",
"pm_score": 0,
"selected": false,
"text": "command"
},
{
"answer_id": 74146082,
"author": "Libor",
"author_id": 5940854,
"author_profile": "... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146020",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13965343/"
] |
74,146,023 | <p>Here is some custom code I wrote that I think might be problematic for this particular use case.</p>
<pre><code>class SQLServerConnection:
def __init__(self, database):
...
self.connection_string = \
"DRIVER=" + str(self.driver) + ";" + \
"SERVER=" + str(self.server) + ";" + \
"DATABASE=" + str(self.database) + ";" + \
"Trusted_Connection=yes;"
self.engine = sqlalchemy.create_engine(
sqlalchemy.engine.URL.create(
"mssql+pyodbc", \
query={'odbc_connect': self.connection_string}
)
)
# Runs a command and returns in plain text (python list for multiple rows)
# Can be a select, alter table, anything like that
def execute(self, command, params=False):
# Make a connection object with the server
with self.engine.connect() as conn:
# Can send some parameters along with a plain text query...
# could be single dict or list of dict
# Doc: https://docs.sqlalchemy.org/en/14/tutorial/dbapi_transactions.html#sending-multiple-parameters
if params:
output = conn.execute(sqlalchemy.text(command,params))
else:
output = conn.execute(sqlalchemy.text(command))
# Tell SQL server to save your changes (assuming that is applicable, is not with select)
# Doc: https://docs.sqlalchemy.org/en/14/tutorial/dbapi_transactions.html#committing-changes
try:
conn.commit()
except Exception as e:
#pass
warn("Could not commit changes...\n" + str(e))
# Try to consolidate select statement result into single object to return
try:
output = output.all()
except:
pass
return output
</code></pre>
<p>If I try:</p>
<pre><code>cnxn = SQLServerConnection(database='MyDatabase')
cnxn.execute("SELECT * INTO [dbo].[MyTable_newdata] FROM [dbo].[MyTable] ")
</code></pre>
<p>or</p>
<pre><code>cnxn.execute("SELECT TOP 0 * INTO [dbo].[MyTable_newdata] FROM [dbo].[MyTable] ")
</code></pre>
<p>Python returns this object without error, <code><sqlalchemy.engine.cursor.LegacyCursorResult at 0x2b793d71880></code>, but upon looking in MS SQL Server, the new table was not generated. I am not warned about the commit step failing with the <code>SELECT TOP 0</code> way; I am warned (<code>'Connection' object has no attribute 'commit'</code>) in the above way.</p>
<p><code>CREATE TABLE</code>, <code>ALTER TABLE</code>, or <code>SELECT</code> (etc) appears to work fine, but <code>SELECT * INTO</code> seems to not be working, and I'm not sure how to troubleshoot further. Copy-pasting the query into SQL Server and running appears to work fine.</p>
| [
{
"answer_id": 74169002,
"author": "Jabbar",
"author_id": 16930239,
"author_profile": "https://Stackoverflow.com/users/16930239",
"pm_score": 0,
"selected": false,
"text": "#!python\nfrom sqlalchemy.sql import Select\nfrom sqlalchemy.ext.compiler import compiles\n\nclass SelectInto(Selec... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6664252/"
] |
74,146,029 | <p>im trying to make a js app that tells someone to log in and saves the email and password in a text file, after some googling it looks like js doesn't have access to system files so node is required.</p>
<p>so i searched how to do it, but i keep getting an error that says Uncaught ReferenceError: require is not defined at HTMLButtonElement</p>
<p>this is the JS code:</p>
<pre><code>let email = document.querySelector(".txt");
let password = document.querySelector(".pass");
let log_btn = document.querySelector("button");
log_btn.addEventListener("click", () => {
let mail = email.value;
let pass = password.value;
var fs = require('fs');
let content = `email: ${mail}\n password: ${pass}`;
fs.writeFile("info.txt", content, err => {
if (err) {
console.error(err);
return;
}
console.log("file created");
});
window.location.href = "index2.html"
})
</code></pre>
<p>what is preventing this from working, is there something i should include or install or anything.
hope someone has the answer, thanks in advance.</p>
| [
{
"answer_id": 74146117,
"author": "Dimava",
"author_id": 5734961,
"author_profile": "https://Stackoverflow.com/users/5734961",
"pm_score": 1,
"selected": false,
"text": "nw.exe"
},
{
"answer_id": 74146490,
"author": "Pankaj Aggarwal",
"author_id": 12415632,
"author_p... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146029",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19568328/"
] |
74,146,045 | <p>I have a stored procedure used for looking up part information to feed a report. I would like to run the procedure to gather the data on a daily, weekly and monthly basis. Currently I have the below but can't figure out how to properly format the case statement in a where clause or if this is the best way to accomplish the goal.</p>
<pre><code>SET ANSI_NULLS ON
GO
SET QUOTED_IDENTIFIER ON
GO
ALTER PROCEDURE [dbo].[Assemblies]
@FREQUENCY varchar(10)
AS
BEGIN
SET NOCOUNT ON;
SELECT SC01 AS 'Part Number',
(CASE
WHEN SC01 LIKE '%Assembly1%' THEN 'A1'
WHEN SC01 LIKE '%Assembly2%' THEN 'A2'
WHEN SC01 LIKE '%Assembly3%' THEN 'A3'
ELSE 'Other'
END) AS 'Assembly',
(CASE
WHEN SC01 LIKE '%Component1%' THEN 'C1'
WHEN SC01 LIKE '%Component2%' THEN 'C2'
WHEN SC01 LIKE '%Component3%' THEN 'C3'
ELSE 'Other'
END) AS 'Component',
Key3 AS 'Group'
FROM dbo.Part
WHERE (SC01 LIKE '%Assembly%' OR SC01 LIKE '%Component%') AND
CASE
WHEN @FREQUENCY = 'DAILY' THEN
Date01 = (CAST(GETDATE())
WHEN @FREQUENCY = 'WEEKLY' THEN
Date01 >= DATEADD(DAY, 1-DATEPART(dw, GETDATE() - 4), CONVERT(DATE,GETDATE() - 4))
AND Date01 <= DATEADD(DAY, 8-DATEPART(dw, GETDATE() - 4), CONVERT(DATE,GETDATE() - 4))
WHEN @FREQUENCY = 'MONTHLY' THEN
Date01 >= DATEADD(MONTH, DATEDIFF(MONTH, 0, GETDATE()), 0) AND Date01 <= GETDATE()
END
ORDER BY SC01
END
</code></pre>
| [
{
"answer_id": 74146188,
"author": "rory",
"author_id": 19963620,
"author_profile": "https://Stackoverflow.com/users/19963620",
"pm_score": 0,
"selected": false,
"text": "CASE \nWHEN @FREQUENCY = 'DAILY' \n AND Date01 = (CAST(GETDATE()) \nTHEN 1\nWHEN @FREQUENCY = 'WEEKLY' \n AND D... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146045",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3600373/"
] |
74,146,089 | <p>How do I adapt this jQuery <code>.prop()</code> to return mutiple <code>href</code> results?</p>
<pre><code>window.onload = function() {
var val = jQuery(".ro_title").prop("href");
jQuery("#form-field-name").val(val);
</code></pre>
| [
{
"answer_id": 74146188,
"author": "rory",
"author_id": 19963620,
"author_profile": "https://Stackoverflow.com/users/19963620",
"pm_score": 0,
"selected": false,
"text": "CASE \nWHEN @FREQUENCY = 'DAILY' \n AND Date01 = (CAST(GETDATE()) \nTHEN 1\nWHEN @FREQUENCY = 'WEEKLY' \n AND D... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146089",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20295480/"
] |
74,146,121 | <p><a href="https://i.stack.imgur.com/GldH2.png" rel="nofollow noreferrer">exemple</a></p>
<p>I use line renderer to draw a line and then use the start and end as the only points.
This makes a perfect line of two points, then I added in the middle of the line so 3 points.</p>
<p>I want to make and animation and i have to move the middle point on the perpendicular to the line.</p>
<p>To resume it that it is easier to understand, in the end, if i move move point on this perpendicular "axis", it will create an isosceles triangle.</p>
<pre class="lang-cs prettyprint-override"><code>//mid
float x = start.x + (end.x - start.x) / 2;
float y = start.y + (end.y - start.y) / 2;
Vector2 mid = new Vector2(x, y);
</code></pre>
| [
{
"answer_id": 74146461,
"author": "Milan Egon Votrubec",
"author_id": 8051819,
"author_profile": "https://Stackoverflow.com/users/8051819",
"pm_score": -1,
"selected": false,
"text": "var mid = ( start + end ) / 2;\nvar direction = end - start;\nvar perp = Vector2.Perpendicular(directio... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146121",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20295424/"
] |
74,146,134 | <p>Essentially I would like to convert an array of the following custom struct into data for data for easier saving in CoreData as Binary Data. How can the following be converted into data to then be ready to decode back:</p>
<p><strong>Custom Struct</strong></p>
<pre><code>struct Place: Codable, Identifiable {
var id = UUID()
var coordinate: Coordinate
struct Coordinate: Codable {
let latitude: Double
let longitude: Double
func locationCoordinate() -> CLLocationCoordinate2D {
return CLLocationCoordinate2D(latitude: self.latitude,
longitude: self.longitude)
}
}
}
</code></pre>
<p><strong>Adding to Custom Struct</strong></p>
<pre><code>var mapAddresses = [Place]()
Task {
mapAddresses.append(Place(coordinate: try await getCoordinate(from:
post.location)))
}
</code></pre>
<p>The issue I am having is converting the array mapAddresses with the custom structure into Binary Data, that can then be decoded back into the custom array.</p>
| [
{
"answer_id": 74146461,
"author": "Milan Egon Votrubec",
"author_id": 8051819,
"author_profile": "https://Stackoverflow.com/users/8051819",
"pm_score": -1,
"selected": false,
"text": "var mid = ( start + end ) / 2;\nvar direction = end - start;\nvar perp = Vector2.Perpendicular(directio... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146134",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8196779/"
] |
74,146,176 | <p>I have a model like this:</p>
<pre><code>class InvoiceItem(models.Model):
book = models.ForeignKey(Book, on_delete=models.PROTECT)
invoice = models.ForeignKey(Invoice, on_delete=models.PROTECT, related_name='items')
title = models.CharField(max_length=100, null=True, blank=True)
price = models.IntegerField(null=True, blank=True)
discount = models.IntegerField(blank=True, default=0)
totalprice = models.IntegerField(null=True, blank=True)
count = models.IntegerField(null=True, blank=True)
</code></pre>
<p>and I want to calculate discount from book's discount table
How can I do it?
should I calculate it in models?</p>
| [
{
"answer_id": 74146282,
"author": "Hashem",
"author_id": 18806558,
"author_profile": "https://Stackoverflow.com/users/18806558",
"pm_score": 2,
"selected": false,
"text": "class MyModel(models.Model):\n ...\n def save(self, *args, **kwargs):\n here you can get field va... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146176",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15781112/"
] |
74,146,183 | <p>I want to create a checkout form with stripe using api and nextjs.<br />
Documentation <a href="https://stripe.com/docs/api/checkout/sessions/create?lang=node" rel="nofollow noreferrer">https://stripe.com/docs/api/checkout/sessions/create?lang=node</a></p>
<pre><code>const stripe = require('stripe')('');
const session = await stripe.checkout.sessions.create({
success_url: 'https://example.com/success',
cancel_url: 'https://example.com/cancel',
line_items: [
{price: 'price_H5ggYwtDq4fbrJ', quantity: 2},
],
mode: 'payment',
});
</code></pre>
<p>when i run the code I get the following :
<a href="https://i.stack.imgur.com/e8fSt.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/e8fSt.png" alt="enter image description here" /></a>
<a href="https://i.stack.imgur.com/OEK1g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OEK1g.png" alt="enter image description here" /></a>
I also tried <a href="https://stackoverflow.com/a/74095665/18355976">https://stackoverflow.com/a/74095665/18355976</a></p>
| [
{
"answer_id": 74146282,
"author": "Hashem",
"author_id": 18806558,
"author_profile": "https://Stackoverflow.com/users/18806558",
"pm_score": 2,
"selected": false,
"text": "class MyModel(models.Model):\n ...\n def save(self, *args, **kwargs):\n here you can get field va... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18355976/"
] |
74,146,200 | <p>Got this code from another post and I'm trying to use it to create my first bot, I want it to announce using @everyone when someone enters a voice channe. No idea about the source or the error, any help?</p>
<p>Error: RangeError [BitFieldInvalid]: Invalid bitfield flag or number: undefined.</p>
<pre><code> const { Client, GatewayIntentBits } = require('discord.js');
const client = new Client({
intents: [
GatewayIntentBits.GUILDS,
GatewayIntentBits.GUILD_MESSAGES,
GatewayIntentBits.GUILD_VOICE_STATES,
],
});
client.on('voiceStateUpdate', async (oldState, newState) => {
const VOICE_ID = 'xxxxxx';
const LOG_CHANNEL_ID = 'xxxxxx';
// if there is no newState channel, the user has just left a channel
const USER_LEFT = !newState.channel;
// if there is no oldState channel, the user has just joined a channel
const USER_JOINED = !oldState.channel;
// if there are oldState and newState channels, but the IDs are different,
// user has just switched voice channels
const USER_SWITCHED = newState.channel?.id !== oldState.channel?.id;
// if a user has just left a channel, stop executing the code
if (USER_LEFT)
return;
if (
// if a user has just joined or switched to a voice channel
(USER_JOINED || USER_SWITCHED) &&
// and the voice channel is the same
newState.channel.id === VOICE_ID
) {
try {
let logChannel = await client.channels.fetch(LOG_CHANNEL_ID);
logChannel.send(
`${newState.member.displayName} joined the channel`,
);
} catch (err) {
console.error('❌ Error finding the log channel, check the error below');
console.error(err);
return;
}
}
});
</code></pre>
<p><a href="https://i.stack.imgur.com/0CFxV.png" rel="nofollow noreferrer">Error message</a></p>
| [
{
"answer_id": 74146282,
"author": "Hashem",
"author_id": 18806558,
"author_profile": "https://Stackoverflow.com/users/18806558",
"pm_score": 2,
"selected": false,
"text": "class MyModel(models.Model):\n ...\n def save(self, *args, **kwargs):\n here you can get field va... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146200",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20295527/"
] |
74,146,222 | <p>Let's say I have this data in my table A:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>group_id</th>
<th>type</th>
<th>active</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>A</td>
<td>true</td>
</tr>
<tr>
<td>1</td>
<td>B</td>
<td>false</td>
</tr>
<tr>
<td>1</td>
<td>C</td>
<td>true</td>
</tr>
<tr>
<td>2</td>
<td>null</td>
<td>false</td>
</tr>
<tr>
<td>3</td>
<td>B</td>
<td>true</td>
</tr>
<tr>
<td>3</td>
<td>C</td>
<td>false</td>
</tr>
</tbody>
</table>
</div>
<p>I want to create a query which return the <code>A</code> row if exists (without the type column), else return a row with <code>active</code> <code>false</code>.</p>
<p>For this specific table the result will be:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>group_id</th>
<th>active</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>true</td>
</tr>
<tr>
<td>2</td>
<td>false</td>
</tr>
<tr>
<td>3</td>
<td>false</td>
</tr>
</tbody>
</table>
</div>
<p>How can I do this ?</p>
<p>I'm assuming I have to use a <code>GROUP BY</code> but I can't find a way to do it.</p>
<p>Thank you</p>
| [
{
"answer_id": 74146294,
"author": "Dale K",
"author_id": 1127428,
"author_profile": "https://Stackoverflow.com/users/1127428",
"pm_score": 2,
"selected": false,
"text": "row_number"
},
{
"answer_id": 74146310,
"author": "Tim Jarosz",
"author_id": 2452207,
"author_pro... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6824121/"
] |
74,146,231 | <p>I am having trouble trying to figure out how to count even numbers when there is string that has a minimum and a maximum this string is a user input string. For example:
<a href="https://i.stack.imgur.com/GYNCi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GYNCi.png" alt="enter image description here" /></a></p>
<ul>
<li>But if the user just enters a single number, then that becomes the max. For example:
<a href="https://i.stack.imgur.com/fSzMd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fSzMd.png" alt="enter image description here" /></a></li>
</ul>
<pre><code>Sub AddupEvenNumbers2()
Dim num As Variant
Dim evennum As Long
Dim sum As Double
Dim str As String
Dim count As Integer
Dim max As String
Dim min As String
str = "Please enter the beginning number " & vbNewLine & "and maximum number (4 22) " & vbNewLine & "or just the maximum number (22) " & vbNewLine & "to get the total sum. "
Do
num = InputBox(str)
If num Like "* *" Then
min = Split(num)(0)
max = Right(num, min)
Else
max = IsNumeric(num)
End If
Loop While IsNumeric(num)
evennum = num
sum = 0
For evennum = min To max Step 2
sum = min + max
Next
MsgBox "The sum of even numbers " & vbNewLine & "from " & min & max & vbNewLine & "is " & sum
End Sub
</code></pre>
| [
{
"answer_id": 74146730,
"author": "Ike",
"author_id": 16578424,
"author_profile": "https://Stackoverflow.com/users/16578424",
"pm_score": 2,
"selected": true,
"text": "Sub AddupEvenNumbers2()\n Dim num As Variant\n Dim evennum As Long\n Dim sum As Double\n Dim str As String\... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146231",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20178476/"
] |
74,146,242 | <p>I have a dataframe with this shape:</p>
<pre><code> date date_lag test_date
<date> <dbl> <date>
1 2018-12-01 NA 2018-12-01
2 2019-03-01 90 2019-03-01
3 2019-05-01 61 2019-03-01
4 2020-03-10 314 2020-03-10
5 2020-03-16 6 2020-03-10
6 2020-03-23 7 2020-03-16
7 2020-03-24 1 2020-03-23
</code></pre>
<p>In order to create <code>date_lag</code> & <code>test_date</code>, I applied this code:</p>
<pre><code>lag <- lag %>%
mutate(date_lag = as.numeric(date - lag(date), units="days")) %>%
mutate(test_date = case_when(
is.na(date_lag) ~ date,
date_lag < 69 ~ date-date_lag,
TRUE ~ date))
</code></pre>
<p>If dates are less than 69 days apart, I want them to have the same date. The problem with my code is that if you see column 6, I don't want it to have the date of column 5 but the date of column 4 because the date_lag is still less than 69 days apart from the previous column, meaning that my desired data will look like:</p>
<pre><code> date date_lag test_date
<date> <dbl> <date>
1 2018-12-01 NA 2018-12-01
2 2019-03-01 90 2019-03-01
3 2019-05-01 61 2019-03-01
4 2020-03-10 314 2020-03-10
5 2020-03-16 6 2020-03-10
6 2020-03-23 7 2020-03-10
7 2020-03-24 1 2020-03-10
</code></pre>
<p>Thanks in advance.</p>
| [
{
"answer_id": 74146548,
"author": "zephryl",
"author_id": 17303805,
"author_profile": "https://Stackoverflow.com/users/17303805",
"pm_score": 3,
"selected": true,
"text": "library(dplyr)\nlibrary(purrr)\nlibrary(lubridate)\n\n# example data\ndate_df <- tibble(\n date = ymd(\"2018-12-01... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146242",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13769905/"
] |
74,146,243 | <p>I am new to Django.
I am going to build simple register and login fullstack application by using React and Django.
My problem is when I received register request with form data.
Is it ok to create custom table for users?
I am going to create another table related to user table.
So in that case, there must be id in the users.
That's why I am going to create custom table.
Please help me it is good practice.</p>
| [
{
"answer_id": 74146326,
"author": "Hashem",
"author_id": 18806558,
"author_profile": "https://Stackoverflow.com/users/18806558",
"pm_score": -1,
"selected": false,
"text": "OneToOne\nForeignKey\nManyToMany\n"
},
{
"answer_id": 74146803,
"author": "Swift",
"author_id": 88... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146243",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20273729/"
] |
74,146,246 | <p>A permutation of size n is a sequence of n integers in which each of the values from 1 to n occurs exactly once. For example, the sequences [3, 1, 2], [1], and [1, 2, 3, 4] are permutations, while [2], [4, 1, 2], [3, 1] are not.</p>
<p>So i recieve 2 inputs: 1 - number of numbers in permutation,2 - the permutation by itself.</p>
<p>The question is: how many intervals are there [l;r](1 ≤ l ≤ r ≤ n) for which the sequence p[l..r] is also a permutation?
For example:</p>
<pre class="lang-none prettyprint-override"><code>input - 7; [6, 3, 4, 1, 2, 7, 5]
The answer is 4:
permutation is [6, 3, 4, 1, 2, 7, 5];
permutation is [1];
permutation is [1, 2];
permutation is [3, 4, 1, 2]
</code></pre>
<p>Hope u undestood the question.</p>
<p>I wrote the first 2 cases, but i don't know how to check for others:</p>
<pre><code>numbers = int(input("Amount of elements in permutation: "))
perm = list(input("Permutation: "))
perm = [ int(x) for x in perm if x != " "]
amount = 1
first = 1
if len(perm) == numbers and int(max(perm)) == numbers and int(min(perm)) == 1:
if first in perm and len(perm) > 1:
amount += 1
</code></pre>
| [
{
"answer_id": 74146724,
"author": "Dave",
"author_id": 2041077,
"author_profile": "https://Stackoverflow.com/users/2041077",
"pm_score": 0,
"selected": false,
"text": "count = 1\nmax_elt = 1\n`l` and `r` point to the left and right indices adjacent to 1.\n"
},
{
"answer_id": 741... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146246",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18692348/"
] |
74,146,268 | <p>Here's the problem. I'm given a div with uneven top and bottom padding. There is a text box centered in the div. Like so:
<a href="https://i.stack.imgur.com/M7guR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/M7guR.png" alt="enter image description here" /></a></p>
<p>as the user adds more text, the text box will expand both up and down, until it hits the top padding (since the top is padded more).
<a href="https://i.stack.imgur.com/wh7Bc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/wh7Bc.png" alt="enter image description here" /></a></p>
<p>if the user adds more text, the text box will only expand downwards, until it hits the bottom padding.
<a href="https://i.stack.imgur.com/sRkpb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sRkpb.png" alt="enter image description here" /></a></p>
<p>if the user continues adding text, the outer div will expand to accomodate.
I have tried messing with padding in the outer div, but the text box will then center slightly lower in the div (to account for the extra padding on top). Any ideas on how to circumvent this? here is a <a href="https://jsfiddle.net/8zfoenx3/43/" rel="nofollow noreferrer">jsfiddle</a><code>with some starter code</code>.</p>
| [
{
"answer_id": 74146724,
"author": "Dave",
"author_id": 2041077,
"author_profile": "https://Stackoverflow.com/users/2041077",
"pm_score": 0,
"selected": false,
"text": "count = 1\nmax_elt = 1\n`l` and `r` point to the left and right indices adjacent to 1.\n"
},
{
"answer_id": 741... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11477067/"
] |
74,146,293 | <p>I have the following scenario and problem, I recive by CSV File and mapping with DW, groupping by column "PON", i need to get the total of the order multiply this column ( Qty * Price ), I don't have the correct result, I will show you:</p>
<p>CSV Data:</p>
<pre><code>PON,Item,Qty,Price
PON1000,2015,2,38.08
PON1000,2016,1,33.37
PON1001,2015,2,38.08
</code></pre>
<p>DW:</p>
<pre><code>%dw 2.0
output application/json
---
payload groupBy ($.PON) pluck $ map ( () -> {
"order": $[0].PON default "",
"total": (sum( $.Price filter ($ != "") ) as Number) as String {format: "##,###.00"},
"products": $ map {
"product": $.Item,
"price": ($.Price as Number) as String {format: "##,###.00"},
"quantity": $.Qty
}
})
</code></pre>
<p>Obtained Result:</p>
<pre><code>[
{
"order": "PON1000",
"total": "71.45",
"products": [
{
"product": "2015",
"price": "38.08",
"quantity": "2"
},
{
"product": "2016",
"price": "33.37",
"quantity": "1"
}
]
},
{
"order": "PON1001",
"total": "38.08",
"products": [
{
"product": "2015",
"price": "38.08",
"quantity": "2"
}
]
}
]
</code></pre>
<p>I NEED MULTIPLY BY ORDER THE "price" * "quantity" CORRESPONDENT AND FINALLY SUM THAT VALUE AND PUT IN THE COLUMN total by ORDER</p>
<p>Expected Result:</p>
<pre><code>[
{
"order": "PON1000",
"total": "109.53",
"products": [
{
"product": "2015",
"price": "38.08",
"quantity": "2"
},
{
"product": "2016",
"price": "33.37",
"quantity": "1"
}
]
},
{
"order": "PON1001",
"total": "76.16",
"products": [
{
"product": "2015",
"price": "38.08",
"quantity": "2"
}
]
}
]
</code></pre>
<p>Any help would be appreciated. Thank you.</p>
<p>Best Regards!!!</p>
| [
{
"answer_id": 74146447,
"author": "Jorge Garcia",
"author_id": 7116931,
"author_profile": "https://Stackoverflow.com/users/7116931",
"pm_score": 1,
"selected": false,
"text": "Arrays::sumBy"
},
{
"answer_id": 74193894,
"author": "Shyam Raj Prasad",
"author_id": 19568815,... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18901832/"
] |
74,146,300 | <p>Let's imagine we have a list of employees, where each day we track what their task_list was. We can assign a boolean if that list includes something we call 'critical', in this case let's assume the person asked to lock the door has the 'critical' task.</p>
<p>For this additional responsibility, we want to reward any of the employees who have demonstrated that they are competent enough to manage that task for a given number of days in a row.</p>
<p>I've got this list of critical tasks, and am able to flag them successfully day by day, but am having trouble figuring out how to get our counter applied correctly.</p>
<p>Ideally, it increments for each consecutive day where we find one of the critical tasks within their task_list, and resets to 0 on a day where they do not have a critical task.</p>
<p>Here's an example desired output:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Employee</th>
<th>Day</th>
<th>Task_List</th>
<th>Critical_Task</th>
<th>Consec_Days_Crit_Task</th>
</tr>
</thead>
<tbody>
<tr>
<td>Tom J</td>
<td>10/1/22</td>
<td>Sweep, Lock Door*</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>Tom J</td>
<td>10/2/22</td>
<td>Sweep, Lock Door*</td>
<td>1</td>
<td>2</td>
</tr>
<tr>
<td>Tom J</td>
<td>10/3/22</td>
<td>Mop, Dishes</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>Tom J</td>
<td>10/4/22</td>
<td>Sweep, Lock Door*</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>Sue B</td>
<td>10/1/22</td>
<td>Mop, Dishes</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>Sue B</td>
<td>10/2/22</td>
<td>Mop, Dishes</td>
<td>0</td>
<td>0</td>
</tr>
<tr>
<td>Sue B</td>
<td>10/3/22</td>
<td>Sweep, Lock Door*</td>
<td>1</td>
<td>1</td>
</tr>
<tr>
<td>Sue B</td>
<td>10/4/22</td>
<td>Mop, Dishes</td>
<td>0</td>
<td>0</td>
</tr>
</tbody>
</table>
</div>
<p>I'm able to get the first 4 columns into a temp table no problem, I've tried using a loop to update those counter values as well as tried to use something like the lag function. Just can't seem to wrap my head around how to write the partition statement I guess.</p>
<p>Any advice?</p>
| [
{
"answer_id": 74146447,
"author": "Jorge Garcia",
"author_id": 7116931,
"author_profile": "https://Stackoverflow.com/users/7116931",
"pm_score": 1,
"selected": false,
"text": "Arrays::sumBy"
},
{
"answer_id": 74193894,
"author": "Shyam Raj Prasad",
"author_id": 19568815,... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20295547/"
] |
74,146,336 | <p>This is my HTML Code:</p>
<pre><code><div class="desc">
<p>Lorem ipsum dolor sit amet,....</p>
<img src="http://sample.com/dl/image-1.jpg">
<p>Lorem ipsum dolor sit amet,....</p>
<img src="http://sample.com/dl/image-2.jpg">
<p>Lorem ipsum dolor sit amet,....</p>
<img src="http://sample.com/dl/image-3.jpg">
<p>Lorem ipsum dolor sit amet,....</p>
<img src="http://sample.com/dl/image-4.jpg">
</div>
</code></pre>
<p>This is my JavaScript code:</p>
<pre><code>$(document).ready(function() {
$('.desc img').addClass('thumb lazyload').attr('data-src', $('.desc img').attr('src') ).attr('src','img/ui/logo/lazy.jpg');
});
</code></pre>
<p>I want the code to be as below, but the JavaScript code does not work:</p>
<pre><code><div class="desc">
<p>Lorem ipsum dolor sit amet,....</p>
<img class="thumb lazyload" src="img/ui/logo/lazy.jpg" data-src="http://sample.com/dl/image-1.jpg">
<p>Lorem ipsum dolor sit amet,....</p>
<img class="thumb lazyload" src="img/ui/logo/lazy.jpg" data-src="http://sample.com/dl/image-2.jpg">
<p>Lorem ipsum dolor sit amet,....</p>
<img class="thumb lazyload" src="img/ui/logo/lazy.jpg" data-src="http://sample.com/dl/image-3.jpg">
<p>Lorem ipsum dolor sit amet,....</p>
<img class="thumb lazyload" src="img/ui/logo/lazy.jpg" data-src="http://sample.com/dl/image-4.jpg">
</div>
</code></pre>
| [
{
"answer_id": 74146447,
"author": "Jorge Garcia",
"author_id": 7116931,
"author_profile": "https://Stackoverflow.com/users/7116931",
"pm_score": 1,
"selected": false,
"text": "Arrays::sumBy"
},
{
"answer_id": 74193894,
"author": "Shyam Raj Prasad",
"author_id": 19568815,... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12716298/"
] |
74,146,380 | <p>I have this function:</p>
<pre class="lang-py prettyprint-override"><code>__version__: str | None = ...
def get_version_parts() -> tuple[str, str] | None:
if __version__ is None:
return None
return tuple(__version__.split('+', maxsplit=1))
</code></pre>
<p>Unsurprisingly, Mypy does not realize that the returned value here is indeed <code>tuple[str, str]</code>, instead thinking that it is a <code>tuple[str, ...]</code>.</p>
<p>Do I have to use <code>typing.cast</code> here, or is there some other way to work around this problem?</p>
| [
{
"answer_id": 74146447,
"author": "Jorge Garcia",
"author_id": 7116931,
"author_profile": "https://Stackoverflow.com/users/7116931",
"pm_score": 1,
"selected": false,
"text": "Arrays::sumBy"
},
{
"answer_id": 74193894,
"author": "Shyam Raj Prasad",
"author_id": 19568815,... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2954547/"
] |
74,146,383 | <p>I have some programming experience and want to switch to QA roles that suit my skills better, I have more knowledge of Java but some Python.</p>
<ol>
<li>I am wondering if I should focus on Selenium that I have some knowledge of or Protractor or Cypress that are considered as the latest standards?
I am more of a front end guy as a developer.</li>
<li>Also, I generally use guru99, tutorialspoint or w3schools to get started. Any other great resources for free or less expensive for quick learning for these topics?</li>
<li>Will cloud upgrades affect this learning process?
Please advice.</li>
</ol>
| [
{
"answer_id": 74146447,
"author": "Jorge Garcia",
"author_id": 7116931,
"author_profile": "https://Stackoverflow.com/users/7116931",
"pm_score": 1,
"selected": false,
"text": "Arrays::sumBy"
},
{
"answer_id": 74193894,
"author": "Shyam Raj Prasad",
"author_id": 19568815,... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146383",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4602344/"
] |
74,146,414 | <p>I have a long array of docs to create. When I create them I get no errors.</p>
<pre class="lang-js prettyprint-override"><code>const docsJson =[some array of json of docs to create]
const orders = await MySchema.create(ordersJSON);
// orders.length returns the same number of docs as docsJson
</code></pre>
<p>But when I search for the new docs, only some were created.</p>
<pre class="lang-js prettyprint-override"><code>
const actualOrdersCreated = await MySchema.find({ _id: { $in: orders.map((p) => p._id) } });
// actualOrdersCreated.length returns less docs than in docsJson
</code></pre>
<p>What's causing this?</p>
| [
{
"answer_id": 74146447,
"author": "Jorge Garcia",
"author_id": 7116931,
"author_profile": "https://Stackoverflow.com/users/7116931",
"pm_score": 1,
"selected": false,
"text": "Arrays::sumBy"
},
{
"answer_id": 74193894,
"author": "Shyam Raj Prasad",
"author_id": 19568815,... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146414",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5004011/"
] |
74,146,425 | <p>Trying to reverse a file line by line</p>
<pre><code>public static void main(String[] args) throws FileNotFoundException {
System.out.println("filname: ");
Scanner input = new Scanner(System.in);
String filnamn = input.nextLine();
File file = new File(filnamn);
Scanner inputFile = new Scanner(file);
PrintWriter writer = new PrintWriter(file);
while (input.hasNextLine()) {
String fil = input.next();
int reverse = 0;
for (int i = fil.length(); i >= 0; i--) {
reverse = reverse + fil.charAt(i);
writer.print(reverse);
}
}
inputFile.close();
writer.close();
input.close();
}
</code></pre>
<p>When trying to reverse my file it just get erased instead of it being backwards</p>
| [
{
"answer_id": 74146606,
"author": "Hiran Chaudhuri",
"author_id": 4222206,
"author_profile": "https://Stackoverflow.com/users/4222206",
"pm_score": 1,
"selected": false,
"text": "inputFile"
},
{
"answer_id": 74146646,
"author": "Yosef.Schwartz",
"author_id": 15633731,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20295698/"
] |
74,146,442 | <p>src = user/my.git dest = /home/git_name ver = 1.1</p>
<pre><code>def run
p = subprocess.run(cmd, stdout=PIPE, stderr=PIPE)
</code></pre>
<p>I am calling this run with the following cmds</p>
<pre><code>1. self.run(['mkdir', '-p', dest])
2. self.run(['git', 'clone', '--no-checkout',src, dest])
3. self.run(['cd', dest, ';', 'git', 'checkout', '--detach', ver]])
</code></pre>
<p>output:
1st run is a success<br />
2nd run to clone gets the error stderr=b"Cloning into ' /home/git_name'...\n<br />
3rd run is a success.</p>
<p>This directory /home/git_name.OLD.1723430 gets created and I see a .git inside this directory.
I also have a file /home/git_name which points to the src, basically has a link to the src directory.</p>
<p>Both of these should happen in the same directory and I don't know why there are two and partial results in both.
I am not sure what's wrong</p>
<p>Also,
src = user/my.git/repos/tags/1.1 is the actual location of the tags
when I try to use the entire path git clone says path is not right</p>
<p>Why does this happen?</p>
| [
{
"answer_id": 74149450,
"author": "VonC",
"author_id": 6309,
"author_profile": "https://Stackoverflow.com/users/6309",
"pm_score": 1,
"selected": false,
"text": "/home"
},
{
"answer_id": 74282065,
"author": "Zapper",
"author_id": 15551066,
"author_profile": "https://... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146442",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15551066/"
] |
74,146,457 | <p>I'm really enjoying python types, but can't seem to figure out how you might type a list with known length and indices.</p>
<p>Let's say for working with bounding boxes (which contain a lot of information) we want to just store data in a list to reduce the size of the data structure... (as compared to storing in a dict)</p>
<p>For examples sake the structure would want to be -> <code>List[List[x: int, y: int, w: int, h: int, frame: int]]</code></p>
<p>Is there a way to support type hinting in Python that would support hints for the indices?</p>
<p>Thanks!</p>
| [
{
"answer_id": 74146776,
"author": "njho",
"author_id": 5819072,
"author_profile": "https://Stackoverflow.com/users/5819072",
"pm_score": 0,
"selected": false,
"text": "tuple"
},
{
"answer_id": 74147001,
"author": "wjandrea",
"author_id": 4518341,
"author_profile": "h... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146457",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5819072/"
] |
74,146,466 | <p>I am having a problem with some new CSS due to an update of our plugin. The page in question is here: <a href="https://www.renophil.com/event/ghostbusters-in-concert/" rel="nofollow noreferrer">https://www.renophil.com/event/ghostbusters-in-concert/</a></p>
<p>Basically from the title below the image down to the share icons should be a left column. Then the description that starts with "Kick off your Halloween weekend..." should be a larger right column.</p>
<p>We are using Wordpress and Visual Composer. The left column uses the class of <code>vc_col-sm-4</code> and the right uses <code>vc_col-sm-8</code>. These are set to have the correct widths and work on mobile devices.</p>
<pre><code>.vc_col-sm-4 {
width: 33.33333333%;
}
.vc_col-sm-8 {
width: 66.66666667%;
}
</code></pre>
<p>The problem is that the plugin we use for the events (The Events Calendar) has this CSS rule:</p>
<pre><code>.tribe-events-single>.tribe_events>:not(.primary,.secondary,.tribe-events-related-events-title,.tribe-related-events) {
order: 1;
width: 100%;
}
</code></pre>
<p>which is overriding the width of my columns mentioned above. I thought I could fix it with <code>width:auto</code> but it didn't work. Is there a way to cancel it or do I have to add !important to the <code>.vc-col-sm-4</code> and <code>.vc-col-sm-8</code> code?</p>
| [
{
"answer_id": 74146776,
"author": "njho",
"author_id": 5819072,
"author_profile": "https://Stackoverflow.com/users/5819072",
"pm_score": 0,
"selected": false,
"text": "tuple"
},
{
"answer_id": 74147001,
"author": "wjandrea",
"author_id": 4518341,
"author_profile": "h... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1714970/"
] |
74,146,473 | <p>I installed MagicDraw 190_sp3 on my mac but it couldn't be opened. When I try to open it shows the error that the developer couldn't be verified. Can anyone help me in this regard, please?</p>
| [
{
"answer_id": 74146776,
"author": "njho",
"author_id": 5819072,
"author_profile": "https://Stackoverflow.com/users/5819072",
"pm_score": 0,
"selected": false,
"text": "tuple"
},
{
"answer_id": 74147001,
"author": "wjandrea",
"author_id": 4518341,
"author_profile": "h... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7033151/"
] |
74,146,479 | <p>In <a href="https://stackblitz.com/edit/angular-ivy-pamzb6?file=src/app/app.component.html" rel="nofollow noreferrer">this StackBlitz ToDo</a> application, I'm writing a simple 3 column presentation based on chaining observables.</p>
<p>In the <code>AppComponent</code>, my observables are declared and initialized as follows:</p>
<pre><code>import { Component, OnInit } from '@angular/core';
import { forkJoin, map, merge, Observable, zip } from 'rxjs';
import { DataService } from './data.service';
import { Item } from './item';
import { State } from './state';
@Component({
selector: 'my-app',
templateUrl: './app.component.html',
styleUrls: ['./app.component.css'],
})
export class AppComponent implements OnInit {
protected allItems: Observable<Item[]>;
protected pendingItems: Observable<Item[]>;
protected inProgressItems: Observable<Item[]>;
protected doneItems: Observable<Item[]>;
protected cancelledItems: Observable<Item[]>;
protected terminalItems: Observable<Item[]>;
constructor(protected _dataSvc: DataService) {
this.allItems = this._dataSvc.items.asObservable();
this.pendingItems = this.allItems.pipe(
map((data) => data.filter((p) => p.status === State.Todo))
);
this.inProgressItems = this.allItems.pipe(
map((data) => data.filter((p) => p.status === State.Doing))
);
this.doneItems = this.allItems.pipe(
map((data) => data.filter((p) => p.status === State.Done))
);
this.cancelledItems = this.allItems.pipe(
map((data) => data.filter((p) => p.status === State.Cancelled))
);
// First option
this.terminalItems = merge(this.doneItems, this.cancelledItems);
// Second option
//this.terminalItems = forkJoin([this.doneItems, this.cancelledItems]).pipe(
// map(d => d[0].concat(d[1])));
//);
// Third option
//this.terminalItems = concat(this.doneItems, this.cancelledItems);
// Fourth option
//this.terminalItems = zip(this.doneItems, this.cancelledItems)
// .pipe(map(d => d[0].concat(d[1])));
}
ngOnInit(): void {
this._dataSvc.initData();
}
}
</code></pre>
<p>As you can see in the <code>InMemoryDataService</code>, the field <code>allItems</code> gets the following content</p>
<pre><code>let items: Item[] = [
{id:1, name: "Eat", status: State.Todo},
{id:2, name: "Sleep", status: State.Todo},
{id:3, name: "Code", status: State.Todo},
{id:4, name: "Game", status: State.Doing},
{id:5, name: "Swim", status: State.Done},
{id:6, name: "Bike", status: State.Cancelled},
];
</code></pre>
<p>The <a href="https://rxjs.dev/operator-decision-tree" rel="nofollow noreferrer">RxJS operator decision tree</a> guided me to use <code>merge</code> to initialize the observable <code>terminalItems</code> as follows:</p>
<p><code>this.terminalItems = merge(this.doneItems, this.cancelledItems);</code></p>
<p>In <code>app.component.html</code>, I expected the <strong>Terminal</strong> <code>div</code>, to contain items of status <code>Cancelled</code> and <code>Done</code> (i.e. Bike, Swim).</p>
<p>However, the <strong>Terminated</strong> column contains only <code>cancelledItems</code>. Changing the order of the arguments of the <code>merge</code> operator makes the <code>doneItems</code> appear, but not the <code>cancelledItems</code>.</p>
<p>Checking the documentation and trying alternatives (<a href="https://rxjs.dev/api/index/function/forkJoin" rel="nofollow noreferrer">forkJoin</a>, <a href="https://rxjs.dev/api/index/function/concat" rel="nofollow noreferrer">concat</a> and <a href="https://rxjs.dev/api/index/function/zip" rel="nofollow noreferrer">zip</a>), I tested how different operators produce terminated items and found the following:</p>
<ul>
<li><code>forkJoin</code>: Showed no elements in Terminated column. Check Second option commented in the code, which basically tests the solution proposed in <a href="https://stackoverflow.com/questions/44141569/how-to-concat-two-observable-arrays-into-a-single-array">this answer</a></li>
<li><code>concat</code>: Depending on arguments order, shows either <code>cancelledItems</code> <strong>or</strong> <code>doneItems</code></li>
<li><code>zip</code>: Showed both <code>cancelledItems</code> and <code>doneItems</code></li>
</ul>
<p>Could someone explain why only <code>zip</code> is working as expected? although according to the documentation, <code>merge</code> looks like it must work!</p>
| [
{
"answer_id": 74146787,
"author": "Chris Hamilton",
"author_id": 12914833,
"author_profile": "https://Stackoverflow.com/users/12914833",
"pm_score": 2,
"selected": false,
"text": "combineLatest"
},
{
"answer_id": 74146858,
"author": "Mark van Straten",
"author_id": 10690... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1662819/"
] |
74,146,528 | <pre><code>names = ['Amir', 'Bear', 'Charlton', 'Daman']
print(names[-1][-1])
</code></pre>
<p>I'd expect it to print Daman twice but it's giving outputting the letter n instead??</p>
| [
{
"answer_id": 74146551,
"author": "Diego Torres Milano",
"author_id": 236465,
"author_profile": "https://Stackoverflow.com/users/236465",
"pm_score": 1,
"selected": false,
"text": "print(names[-1])\n"
},
{
"answer_id": 74146565,
"author": "Vlad_Gesin",
"author_id": 14507... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146528",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20252553/"
] |
74,146,532 | <p>I have the following code:</p>
<pre><code>getData = async function (afgJSON) {
console.log("step 2")
await axios.post(process.env.afgEndPoint, afgJSON, {
headers: headers
})
.then((response) => {
console.log("step 3")
return response.data
})
.catch((e) => {
console.log("step 3")
return e.response.data
})
}
</code></pre>
<p>Which I call as this:</p>
<pre><code>console.log("step 1")
let afgResponse = await common.getData(afgJSON);
console.log("step 4")
console.log(afgResponse)
</code></pre>
<p>afgResponse always is undefined, and the console.logs show the right order:</p>
<p>step 1</p>
<p>step 2</p>
<p>step 3</p>
<p>step 4</p>
<p>undefined</p>
<p>... but if I console.log response.data (.then), the response is fine.</p>
<p>I was reading other posts at stackoverflow about .then => with Axios but I still cant figure this out.</p>
<p>Thanks.</p>
| [
{
"answer_id": 74147291,
"author": "boubaks",
"author_id": 7263945,
"author_profile": "https://Stackoverflow.com/users/7263945",
"pm_score": -1,
"selected": false,
"text": "getData = async function (afgJSON) {\n try {\n const { data } = await axios.post(process.env.afgEndPoint, a... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146532",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14867749/"
] |
74,146,533 | <p>I am curious if anyone knows how to apply the Value.1s for each year of df1 to their corresponding years in df2. This will hopefully create two columns for "Value.1" and "Value.2" inside df2. Obviously, the real dataset is quite large and I would rather not do this the long way. I imagine the code will start with df2 %>% mutate(...), ifelse? case_when? I really appreciate any help!</p>
<pre><code>df1 <- data.frame(Year = c(2000:2002),
Value.1 = c(0:2))
Year Value.1
1 2000 0
2 2001 1
3 2002 2
df2 <- data.frame(Year = c(2000,2000,2000,2001,2001,2001,2002,2002,2002),
Value.2 = c(1:9))
Year Value.2
1 2000 1
2 2000 2
3 2000 3
4 2001 4
5 2001 5
6 2001 6
7 2002 7
8 2002 8
9 2002 9
</code></pre>
| [
{
"answer_id": 74146697,
"author": "Tech Commodities",
"author_id": 9541415,
"author_profile": "https://Stackoverflow.com/users/9541415",
"pm_score": 0,
"selected": false,
"text": "df3 <- dplyr::left_join(df2, df1, by = \"Year\")\n\n Year Value.2 Value.1\n1 2000 1 0\n2 2000 ... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146533",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15533335/"
] |
74,146,537 | <p>This is an assignment I am attempting to work on where I am attempting to create a program that asks for a books title, its author, and its date of publication, before displaying all inputs at the end. My primary obstacle is trying to get everything to display in a somewhat decent way, with additional text written to clarify the information properly.</p>
<p>It should look like this:</p>
<pre><code>Title: Great Expectations Fahrenheit 451 Animal Farm
Author: Charles Dickens Ray Bradbury George Orwell
Date: 1824 1956 1948
</code></pre>
<pre><code>#include <string>
#include <vector>
using namespace std;
int main ()
{
int i=0;
int n;
string bookTitle;
string bookAuthor;
string bookDate;
vector<string> Title;
vector<string> Author;
vector<string> Date;
cout << "Enter the Number of Books: ";
cin >> n;
cin.ignore();
for (i; i < n; i++)
{
cout << "Type the Book's Title: ";
getline (cin, bookTitle);
Title.push_back(bookTitle);
cout << "Type the Book's Author: ";
getline (cin, bookAuthor);
Author.push_back(bookAuthor);
cout << "Type the Book's Date: ";
getline (cin, bookDate);
Date.push_back(bookDate);
}
cout << endl;
cout << "The Titles: ";
for (auto it = Title.begin(); it != Title.end(); ++it) {
cout << *it << " ";
}
cout << endl;
cout << "Written by: ";
for (auto ib = Author.begin(); ib != Author.end(); ++ib) {
cout << *ib << " ";
}
cout << endl;
cout << "Written in: ";
for (auto ic = Date.begin(); ic != Date.end(); ++ic) {
cout << *ic << " ";
}
return 0;
}
</code></pre>
| [
{
"answer_id": 74146780,
"author": "paddy",
"author_id": 1553090,
"author_profile": "https://Stackoverflow.com/users/1553090",
"pm_score": 2,
"selected": false,
"text": "struct Book {\n string title;\n string author;\n string date;\n};\n\nvector<Book> books;\n"
},
{
"ans... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20294958/"
] |
74,146,544 | <p>New to Python Selenium.</p>
<p>I am trying to create an script to login to my home router and press the button restart.</p>
<p>Running to error, when trying to login to the router, can some on guide on my mistake here.</p>
<p>below is the code and also attaching the .<a href="https://i.stack.imgur.com/y3KZs.jpg" rel="nofollow noreferrer">screenshot</a></p>
<pre class="lang-py prettyprint-override"><code>from selenium import webdriver
from selenium.webdriver.chrome.service import Service
driver_service = Service(executable_path="C:\Program Files (x86)\chromedriver.exe")
driver = webdriver.Chrome(service=driver_service)
PASSWORD = 'testtes'
login_page = 'http://192.168.2.1/login.html'
driver.get(login_page)
driver.find_element_by_xpath("//input[@placeholder='Password']").send_keys(PASSWORD)
</code></pre>
<p>Below is the error I am getting.</p>
<blockquote>
<p>Traceback (most recent call last):
File "C:\Users\admin\Desktop\pyhton\index.py", line 14, in
driver.find_element_by_xpath("//input[@placeholder='Password']").send_keys(PASSWORD)
AttributeError: 'WebDriver' object has no attribute 'find_element_by_xpath'</p>
</blockquote>
<p>getting this error now.</p>
<p>Traceback (most recent call last):
File "C:\Users\admin\Desktop\pyhton\index.py", line 13, in
driver.find_element(By.XPATH, "//input[@placeholder='Password']").send_keys(PASSWORD)
File "C:\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 856, in find_element
return self.execute(Command.FIND_ELEMENT, {
File "C:\Python310\lib\site-packages\selenium\webdriver\remote\webdriver.py", line 429, in execute
self.error_handler.check_response(response)
File "C:\Python310\lib\site-packages\selenium\webdriver\remote\errorhandler.py", line 243, in check_response
raise exception_class(message, screen, stacktrace)
selenium.common.exceptions.NoSuchElementException: Message: no such element: Unable to locate element: {"method":"xpath","selector":"//input[@placeholder='Password']"}</p>
| [
{
"answer_id": 74146584,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 2,
"selected": false,
"text": "find_element_by_xpath"
},
{
"answer_id": 74146602,
"author": "kotschi123",
"author_id": 19042422,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146544",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14957585/"
] |
74,146,558 | <p>How can I multiply two elements in a list?
I am reading a text file, and printing the following:</p>
<pre><code>for i in range(len(listeisotoper)):
print("Isotop type:"+listeisotoper[i][0])
print("Isotopisk masse u: "+listeisotoper[i][1])
print("Naturlig forekomst: "+listeisotoper[i][2])
print("xxx"+"g/mol")
print("\n")
</code></pre>
<p>However i cannot fathom how i can multiply the <code>listeisotoper[i][1] * listeisotoper[i][2]</code>
and then have it print the number with decimal points.
Any suggestions?</p>
| [
{
"answer_id": 74146584,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 2,
"selected": false,
"text": "find_element_by_xpath"
},
{
"answer_id": 74146602,
"author": "kotschi123",
"author_id": 19042422,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9861217/"
] |
74,146,589 | <p>I apologize in advance for a wall of text question. SPFx is a new requirement mandated from on high and I don't have any working experience with it at this point.</p>
<p>I created a vanilla SPFx project added to github to make it easier. There are just too many moving parts to try and get them all in the question.</p>
<p><a href="https://github.com/cyberjetx/dtspfx/tree/AddDt" rel="nofollow noreferrer">https://github.com/cyberjetx/dtspfx/tree/AddDt</a></p>
<p><strong>Description of problem:</strong><br />
Trying to make the basic datatable work with zero configuration in SharePoint framework (SPFx) this is new ground for me and it has been mandated from on-high that we will be using SPFx or not on the intranet at all.</p>
<p>I am trying to document the process so that others using dt will have a base to start from or at least be able to see what is needed to to add dt to their SPFxs. This process is started in the readme.md.</p>
<p>in Area51WebPart.ts</p>
<pre class="lang-js prettyprint-override"><code>import 'datatables.net';
</code></pre>
<p>in main.js</p>
<pre class="lang-js prettyprint-override"><code>$(document).ready(function () {
$('#example').DataTable();
});
</code></pre>
<p>In config.json I would IDEALLY like to just use the combined file from dataTables cdn. I have also tried <code>npm install --save datatables.net-dt</code> and linked in config as <code>"path": "/node_modules/datatables.net/js/jquery.dataTables.min.js",</code> earning the following:</p>
<blockquote>
<p>[17:03:22] Error - [webpack] 'dist':
"C:\code\dtspfx\node_modules\datatables.net\js\jquery.dataTables.min.js"
does not exist. Ensure the path is correct and relative to the project
root.</p>
</blockquote>
<p>however, it is indeed there, if I copy and paste the path and open in notepad it's there.</p>
<pre class="lang-json prettyprint-override"><code>. . .
"externals": {
"jquery": {
"path": "https://cdnjs.cloudflare.com/ajax/libs/jquery/3.5.0/jquery.min.js",
"globalName": "jQuery"
}
,"datatables.net": {
"path": "/node_modules/datatables.net/js/jquery.dataTables.min.js",
// "path": "https://cdn.datatables.net/v/dt/jszip-2.5.0/dt-1.12.1/af-2.4.0/b-2.2.3/b-colvis-2.2.3/b-html5-2.2.3/b-print-2.2.3/cr- 1.5.6/date-1.1.2/fc-4.1.0/fh-3.2.4/kt-2.7.0/r-2.3.0/rg-1.2.0/rr-1.2.8/sc-2.0.7/sb-1.3.4/sp-2.0.2/sl-1.4.0/sr-1.1.1/datatables.min.js",
"globalName": "jQuery",
"globalDependencies": [
"jquery"
]
}
},
. . .
</code></pre>
| [
{
"answer_id": 74146584,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 2,
"selected": false,
"text": "find_element_by_xpath"
},
{
"answer_id": 74146602,
"author": "kotschi123",
"author_id": 19042422,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/561710/"
] |
74,146,608 | <p>This works perfectly if none of the data-validated cells raise an error on the sheet being written to. However, once the script reaches a cell where the copied value doesn't follow the data validation rules, it returns an error and stops executing. How can I ignore this error, continue to write into the cell, and continue running the script?</p>
<pre><code>
function addNew() {
Week = "2022-01-03"
x = 4
y = 17
for (var i=0; i<21; i++)
{
var readRange = SpreadsheetApp.getActive().getRange(`Versionality!I${x}:K${y}`)
var readValues = readRange.getValues();
var writeRange = SpreadsheetApp.openById("------");
var writeValues = writeRange.getRange(`${Week}!H${x}:J${y}`)
writeValues.setValues(readValues);
x += 17
y += 17
}
}
</code></pre>
| [
{
"answer_id": 74146584,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 2,
"selected": false,
"text": "find_element_by_xpath"
},
{
"answer_id": 74146602,
"author": "kotschi123",
"author_id": 19042422,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146608",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20295752/"
] |
74,146,626 | <p>I would like to get dates (monthYear,weekYear,etc.) as columns, and having the value as count activities by users, but i'm not reaching it :(</p>
<p>Some example:</p>
<ul>
<li>My table</li>
</ul>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>userid</th>
<th>activityId</th>
<th>activityStatus</th>
<th>activityDate</th>
</tr>
</thead>
<tbody>
<tr>
<td>A1</td>
<td>z1</td>
<td>finished</td>
<td>2022-08-01T15:00:00</td>
</tr>
<tr>
<td>A2</td>
<td>z2</td>
<td>finished</td>
<td>2022-08-07T20:00:00</td>
</tr>
<tr>
<td>A2</td>
<td>z3</td>
<td>finished</td>
<td>2022-08-08T10:00:00</td>
</tr>
<tr>
<td>A1</td>
<td>z4</td>
<td>finished</td>
<td>2022-09-17T16:00:00</td>
</tr>
<tr>
<td>A1</td>
<td>z5</td>
<td>finished</td>
<td>2022-09-20T17:00:00</td>
</tr>
<tr>
<td>A3</td>
<td>z6</td>
<td>finished</td>
<td>2022-08-19T13:00:00</td>
</tr>
</tbody>
</table>
</div>
<p>What I'im trying to do, something like this (but I know now that's not working):</p>
<pre><code>SELECT
userid,
COUNT(activityId) as doneActivities,
CONCAT(EXTRACT(YEAR from activityDate),'-',EXTRACT(WEEK from activityDate))
</code></pre>
<p>And the result of this attemp is like:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>userid</th>
<th>doneActivities</th>
<th>weekYear</th>
</tr>
</thead>
<tbody>
<tr>
<td>A1</td>
<td>1</td>
<td>31-2022</td>
</tr>
<tr>
<td>A1</td>
<td>2</td>
<td>33-2022</td>
</tr>
<tr>
<td>A2</td>
<td>1</td>
<td>31-2022</td>
</tr>
<tr>
<td>A2</td>
<td>1</td>
<td>32-2022</td>
</tr>
<tr>
<td>A3</td>
<td>1</td>
<td>33-2022</td>
</tr>
</tbody>
</table>
</div>
<ul>
<li>Expected result would be something like this:</li>
</ul>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>userid</th>
<th>31-2022</th>
<th>32-2022</th>
<th>33-2022</th>
</tr>
</thead>
<tbody>
<tr>
<td>A1</td>
<td>1</td>
<td>0</td>
<td>2</td>
</tr>
<tr>
<td>A2</td>
<td>1</td>
<td>1</td>
<td>0</td>
</tr>
<tr>
<td>A3</td>
<td>0</td>
<td>0</td>
<td>1</td>
</tr>
</tbody>
</table>
</div>
<p>I know how to do it on Power BI, but I want to automate this for futures queries.</p>
<p>If it's not clear, please let me know guys, and I'll try to explain again. There is some time that I don't practice english.</p>
<p>Thanks in advance!</p>
| [
{
"answer_id": 74146584,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 2,
"selected": false,
"text": "find_element_by_xpath"
},
{
"answer_id": 74146602,
"author": "kotschi123",
"author_id": 19042422,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18272070/"
] |
74,146,651 | <p>Question:
Write the function <code>wordWrap(text, width)</code> which takes a string text containing only lowercase letters or spaces and a positive integer width, and returns a possibly-multiline string that matches the original string, only with line wrapping at the given width. For example, <code>wordWrap('abc', 3)</code> just returns <code>'abc'</code>, but <code>wordWrap('abc', 2)</code> returns a 2-line string, with <code>'ab'</code> on the first line and <code>'c'</code> on the second line.</p>
<p>All spaces should be converted to dashes ('-'), so they can be easily seen in the resulting string.</p>
<p>For example, wordWrap('abcdefghij', 4) returns</p>
<pre><code>'''\
abcd
efgh
ij'''
</code></pre>
<p>and <code>wordWrap('a b c de fg', 4)</code> returns</p>
<pre><code>'''\
a-b-
c-de
-fg'''
</code></pre>
<p>This is my code so far:</p>
<pre><code>def wordWrap(text, width):
result = ''
line = ''
for i in text:
if i.isalpha():
line += i
if len(line) == width:
result += line
line = ''
a = text.index(i)
if (a+1) != len(text):
result += '\n'
if len(text) - (a+1) < width:
for n in text[a+1:]:
if n.isalpha:
result += n
if n.isspace():
result += '-'
if i.isspace():
line += '-'
if len(line) == width:
result += line
line = ''
a = text.index(i)
if (a+1) != len(text):
result += '\n'
if len(text) - (a+1) < width:
for n in text[a+1:]:
if n.isalpha:
result += n
if n.isspace():
result += '-'
return result
# wordWrap('a b c de fg', 4) returns
'''\
a-b-
c-de
-fg'''
</code></pre>
<p>Where is that extra space in the last line coming from?</p>
| [
{
"answer_id": 74146584,
"author": "Prophet",
"author_id": 3485434,
"author_profile": "https://Stackoverflow.com/users/3485434",
"pm_score": 2,
"selected": false,
"text": "find_element_by_xpath"
},
{
"answer_id": 74146602,
"author": "kotschi123",
"author_id": 19042422,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20125006/"
] |
74,146,672 | <p>I'm trying to flatten the following structure at scala:</p>
<pre><code>Array[((String, String, String),(String, String, String))]
</code></pre>
<p>To obtain:</p>
<pre><code>(String, String, String, String, String, String)
</code></pre>
<p>So far, I tried something similar to:</p>
<pre><code>val = payload.map(_.productIterator.toList.map(_.toString)).toList
</code></pre>
<p>which produces: <code>List[List[String]]</code></p>
<p>Any ideas about how to achieve this?</p>
<p>Thanks!</p>
| [
{
"answer_id": 74146805,
"author": "Arnon Rotem-Gal-Oz",
"author_id": 1018659,
"author_profile": "https://Stackoverflow.com/users/1018659",
"pm_score": 0,
"selected": false,
"text": "val x=Seq(((\"A\",\"B\",\"C\"),(\"D\",\"E\",\"F\")),((\"A1\",\"B1\",\"C1\"),(\"D1\",\"E1\",\"F1\")))\nx.f... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146672",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5504855/"
] |
74,146,689 | <p>I'm aware that 302 redirections in cross-domain situations can make cookies get lost, but the API / Azure Function is on the same domain as the <code>redirectUrl</code>. Considering the following code snippet:</p>
<pre><code>const expirationDate = new Date(Date.now())
expirationDate.setHours(expirationDate.getHours() + 24)
logger.add(`Token cookie expiration date set to: ${expirationDate}`)
const headers = {
Location: `${auth?.redirectUrl}?clientName=${clientName}`,
"Set-Cookie": `token=${
auth?.token
}; Expires=${expirationDate.toUTCString()}; Path=/;`,
}
</code></pre>
<p>After the browser redirects to the <code>redirectUrl</code>, the cookie canno't be found in the
browser's Application tab, as it gets lost somehow. I'm guessing that's a specific problem of Azure Functions and that it wouldn't happen if I used express.js, for example. How can I set cookies while 302-redirecting at the same time?</p>
| [
{
"answer_id": 74183463,
"author": "Alex AIT",
"author_id": 336378,
"author_profile": "https://Stackoverflow.com/users/336378",
"pm_score": 3,
"selected": true,
"text": "context.res = {\n status: 302, /* Defaults to 200 */\n // body: responseMessage,\n headers: {\n Locati... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146689",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1795924/"
] |
74,146,712 | <p>Not sure if anyone can help. This is my first class so I'm very new to python and programming in general. I have a program for my Python class that I am stuck on. I have it doing the basics, but cannot figure out how to check the inventory quantity against the user inputted quantity. I know the nested if statement is incorrect ( I left that in so I had something) but that's what I'm struggling with.</p>
<p>Also..I have only laid out the ending part of the program which is why my input is blank.</p>
<p>supplier_data is what was provided to us by the instructor.</p>
<pre><code> supplier_data = '{"parts": ["sprocket", "gizmo", "widget", "dodad"], "sprocket":
{"price": 3.99, "quantity": 32}, "gizmo": {"price": 7.98, "quantity": 2}, "widget":
{"price": 14.32, "quantity": 4}, "dodad": {"price": 0.5, "quantity": 0}}'
import json
json.loads(supplier_data)
new_data = json.loads(supplier_data)
print(new_data)
print("Welcome to the parts ordering system, please enter in a part name, followed
by a quantity.\n")
print("Parts for order are:\n")
print("sprocket")
print("gizmo")
print("widget")
print("dodad\n\n")
order = {}
inventory = True
while inventory:
part_input = input("Please enter in a part name, or quit to exit: ")
if part_input in new_data.keys():
quantity_input = int(input("Please enter in a quantity to order: "))
order[part_input] = quantity_input
print(order)
if quantity_input >= new_data['sprocket']['quantity']:
print("Error, only" + new_data['sprocket']['quantity'] + part_input + "
are available!")
continue
elif part_input == "quit":
inventory = False
else:
print("Error, part does not exist, try again.")
</code></pre>
<p>This is what I get currently when I run it.</p>
<pre><code>Welcome to the parts ordering system, please enter in a part name, followed by a quantity.
Parts for order are:
sprocket
gizmo
widget
dodad
Please enter in a part name, or quit to exit: sprocket
Please enter in a quantity to order: 3
{'sprocket': 3}
Please enter in a part name, or quit to exit: gizmo
Please enter in a quantity to order: 1
{'sprocket': 3, 'gizmo': 1}
Please enter in a part name, or quit to exit: widget
Please enter in a quantity to order: 8
{'sprocket': 3, 'gizmo': 1, 'widget': 8}
Please enter in a part name, or quit to exit: dodad
Please enter in a quantity to order: 1
{'sprocket': 3, 'gizmo': 1, 'widget': 8, 'dodad': 1}
Please enter in a part name, or quit to exit: quit
Your Order
Total: $
Thank you for using the parts ordering system!
Process finished with exit code 0
</code></pre>
| [
{
"answer_id": 74146840,
"author": "MatErW3len",
"author_id": 18322491,
"author_profile": "https://Stackoverflow.com/users/18322491",
"pm_score": 2,
"selected": false,
"text": "if quantity_input >= new_data['sprocket']['quantity']:\n print(\"Error, only\" + new_data['sproc... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20295812/"
] |
74,146,731 | <p>I am following Cloud Guru K8S course and have issues with the template they provided. I can't see what’s wrong.</p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
name: blue-deployment
spec:
replicas: 1
selector:
matchLabels:
app: bluegreen-test
color: blue
template:
metadata:
labels:
app: bluegreen-test
color: blue
spec:
containers:
- name: nginx
image: linuxacademycontent/ckad-nginx:blue
ports:
- containerPort: 80
</code></pre>
<p>When I run</p>
<pre><code>kubectl apply -f my-deployment.yml
</code></pre>
<p>I get</p>
<pre><code>error: error parsing blue-deployment.yml: error converting YAML to JSON: yaml: line 4: found character that cannot start any token
</code></pre>
<p>What's wrong with this template? It's nearly identical to the official example deployment definition <a href="https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#creating-a-deployment" rel="nofollow noreferrer">https://kubernetes.io/docs/concepts/workloads/controllers/deployment/#creating-a-deployment</a></p>
<pre><code>apiVersion: apps/v1
kind: Deployment
metadata:
name: nginx-deployment
labels:
app: nginx
spec:
replicas: 3
selector:
matchLabels:
app: nginx
template:
metadata:
labels:
app: nginx
spec:
containers:
- name: nginx
image: nginx:1.14.2
ports:
- containerPort: 80
</code></pre>
| [
{
"answer_id": 74147951,
"author": "JasonY",
"author_id": 12418459,
"author_profile": "https://Stackoverflow.com/users/12418459",
"pm_score": 3,
"selected": true,
"text": "vim my-deployment.yml"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4741620/"
] |
74,146,740 | <p>my site (<a href="https://frogos.ga" rel="nofollow noreferrer">https://frogos.ga</a>) is adding a small overflow to the bottom which has nothing in it and I am wondering what is causing it.</p>
<p>My code is below.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>//Elements
const apps = document.querySelector("#br-os-apps")
var menu = document.querySelector("#os-ct-menu")
const os_window = document.querySelector(".br-os-window")
const brand_window = document.querySelector(".brand")
const tbarapps = document.querySelector("#tbarapps")
const app_main = document.querySelector("#app-main")
const maximise = document.querySelector("#maximise")
const shorter = document.querySelector("#shorter")
const cross = document.querySelector("#cross")
const taskbar = document.querySelector("#taskbar")
/* Sound effects */
const click = new Audio("assets/music/click.wav")
const con = new Audio("assets/music/alert.wav")
const okay = new Audio("assets/music/positive.wav")
const no = new Audio("assets/music/negative.wav")
//Operations
/* Reseting window */
close(os_window)
/* Creating apps */
create_app("Browser", "assets/images/apps/chromium.png", "browser", "/browser")
create_app("Calculator", "/assets/images/apps/calculator.png", "calculator", "https://calculator.pottere6.repl.co")
create_app("Text editor", "assets/images/apps/notepad.png", "tedit", "texteditor.html")
create_app("Settings", "assets/images/apps/settings.png", "settings", "/settings")
//App creation function
function create_app(name, image, id, src) {
let app = document.createElement("div")
app.classList.add("app")
app.id = id
app.onclick = () => window_open(id, src, image)
app.oncontextmenu = e => {
click.play()
open_menu(e, id)
}
let img = document.createElement("img");
img.src = image
img.setAttribute("alt", name)
let p = document.createElement("p")
let tbarapp = document.createElement("img")
tbarapp.src = image
tbarapp.id = id
tbarapp.onclick = () => window_open(id, src);
p.innerText = name
app.appendChild(img)
app.appendChild(p)
apps.appendChild(app)
tbarapps.appendChild(tbarapp)
}
function open(tag) {
tag.style.display = "inline-block"
}
function close(tag) {
tag.style.display = "none"
}
//Window open function
function window_open(id, src) {
click.play()
brand_window.innerHTML = ""
app_main.innerHTML = "<iframe src=" + src + "></iframe>"
init_window()
let main = document.querySelector("#" + id)
let img = document.createElement("img")
img.src = main.childNodes[0].src
img.setAttribute("alt", main.childNodes[0].getAttribute("alt"))
img.setAttribute("alt", main.childNodes[0].getAttribute("alt"))
let p = document.createElement("p")
p.innerText = main.childNodes[1].innerText
brand_window.appendChild(img)
brand_window.appendChild(p)
open(os_window)
dragElement(document.getElementById(id));
}
//Start menu
function startmenu() {
const newmenu = document.createElement("div");
newmenu.id = "startmenu"
}
function init_window() {
close(shorter)
minimize.onclick = e => {
click.play()
minimize_window()
}
maximise.onclick = e => {
click.play()
maximise_window()
}
shorter.onclick = e => {
click.play()
shorter_window()
}
cross.onclick = e => {
click.play()
close(os_window)
os_window
}
}
//Window minimize function
function minimize_window() {
os_window.style.display = "none"
}
//Window maximize function
function maximise_window() {
open(shorter)
close(maximise)
window.restoreX = os_window.style.left
window.restoreY = os_window.style.top
os_window.style.top = 0
os_window.style.left = 0
os_window.style.width = "100%"
os_window.style.height = "100vh"
}
//Window un-maximize function
function shorter_window() {
open(maximise)
close(shorter)
os_window.style.top = window.restoreY
os_window.style.left = window.restoreX
os_window.style.width = "50%"
os_window.style.height = "50vh"
}
function open_menu(e, id) {
e.preventDefault()
menu.classList.add("active")
menu.querySelectorAll("ul li")[0].childNodes[0].onclick = () => {
window_open(id)
}
menu.querySelectorAll("ul li")[1].childNodes[0].onclick = () => {
admin_access(id)
}
menu.querySelectorAll("ul li")[2].childNodes[0].onclick = () => {
remove_app(id)
}
menu.querySelectorAll("ul li")[3].childnodes[0].onclick = () => {
app_properties()
}
menu.style.top = e.pageY + 5 + "px"
menu.style.left = e.pageX + 5 + "px"
return false
}
function admin_access(id) {
con.play()
vex.dialog.confirm({
message: "Would you like to give admin access to this app?",
callback: function(value) {
if (value) {
okay.play()
window_open(id)
} else {
no.play()
vex.dialog.alert({
message: "Admin permissions declines"
})
}
}
})
}
function remove_app(id) {
con.play()
vex.dialog.confirm({
message: "Are you sure to remove this app?",
callback: function(value) {
if (value) {
okay.play()
document.querySelector("#" + id).remove()
} else {
no.play()
vex.dialog.alert({
message: "App was not removed"
})
}
}
})
}
//Anonymous functions in Event Listeners
window.onclick = e => {
if (menu.classList.contains("active")) {
menu.classList.remove("active")
}
}
dragElement(document.querySelector(".br-os-window"));
function dragElement(elmnt) {
var pos1 = 0,
pos2 = 0,
pos3 = 0,
pos4 = 0;
if (document.getElementById(elmnt.id + "header")) {
// if present, the header is where you move the DIV from:
document.getElementById(elmnt.id + "header").onmousedown = dragMouseDown;
} else {
// otherwise, move the DIV from anywhere inside the DIV:
elmnt.onmousedown = dragMouseDown;
}
function dragMouseDown(e) {
e = e || window.event;
e.preventDefault();
// get the mouse cursor position at startup:
pos3 = e.clientX;
pos4 = e.clientY;
document.onmouseup = closeDragElement;
// call a function whenever the cursor moves:
document.onmousemove = elementDrag;
}
function elementDrag(e) {
e = e || window.event;
e.preventDefault();
// calculate the new cursor position:
pos1 = pos3 - e.clientX;
pos2 = pos4 - e.clientY;
pos3 = e.clientX;
pos4 = e.clientY;
// set the element's new position:
elmnt.style.top = (elmnt.offsetTop - pos2) + "px";
elmnt.style.left = (elmnt.offsetLeft - pos1) + "px";
}
function closeDragElement() {
// stop moving when mouse button is released:
document.onmouseup = null;
document.onmousemove = null;
}
}
function checkbg() {
let bgurl = document.cookie
if (bgurl) {
document.querySelector("br-os-window").style.backgroundimage = "url(" + bgurl + ")";
} else {
document.querySelector("br-os-window").style.backgroundimage = "url(../images/hi.jpg)"
}
}
function loop() {
const date = new Date();
const sec = date.getSeconds();
setTimeout(() => {
setInterval(() => {
datetime()
}, 60 * 500);
}, (60 - sec) * 1000);
}
function datetime() {
const val = new Date();
const min = val.getMinutes();
const bmin = min.toString();
if (bmin.length == 1) {
let hours = val.getHours();
let day = val.getDate();
let month = val.getMonth() + 1;
let year = val.getFullYear();
let sess = "AM"
if (hours == 0) {
hours = 12
sess = "AM"
} else if (hours > 12) {
hours = hours - 12;
sess = "PM"
}
const time = hours + ":0" + min + " " + sess;
const date = month + "/" + day + "/" + year;
document.getElementById('time').innerHTML = (time);
document.getElementById('date').innerHTML = (date);
} else {
let hours = val.getHours();
let day = val.getDate();
let month = val.getMonth() + 1;
let year = val.getFullYear();
let sess = "AM"
if (hours == 0) {
hours = 12
sess = "AM"
} else if (hours > 12) {
hours = hours - 12;
sess = "PM"
}
const time = hours + ":" + min + " " + sess;
const date = month + "/" + day + "/" + year;
document.getElementById('time').innerHTML = (time);
document.getElementById('date').innerHTML = (date);
}
}
//Nasa APOD
const url = 'https://api.nasa.gov/planetary/apod?api_key='
const api_key = "ExY2DF0hrHkIlzNaaJboNXxGkiksfybTvubFBgg5"
const fetchNASAData = async() => {
try {
const response = await fetch(`${url}${api_key}`)
const data = await response.json()
console.log('NASA APOD data', data)
displayData(data)
} catch (error) {
console.log(error)
}
}
const displayData = data => {
document.getElementById("br-os-container").style.backgroundImage = "url('" + data.hdurl + "')";
}
fetchNASAData()
document.getElementById('loading').style.display = 'none';
document.getElementById('br-os-container').style.display = 'block';</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>#loading {
display: block;
}
* {
margin: 0;
padding: 0;
box-sizing: border-box;
text-decoration: none;
list-style-type: none;
font-family: sans-serif;
}
@keyframes fadeIn {
0% {
opacity: 0;
}
100% {
opacity: 1;
}
}
:root::-webkit-scrollbar {
display: none;
}
:root {
-ms-overflow-style: none;
scrollbar-width: none;
}
#br-os-container {
animation: fadeIn 3.5s;
width: 100%;
min-height: 100vh;
background-size: 100% 100%;
}
iframe {
width: 100%;
height: 100%;
position: absolute;
display: block;
top: 20;
left: 0;
}
#dateandtime {
text-align: right;
}
#tbarapps {
position: absolute;
left: 45px;
}
#tbarapps img {
width: 45px;
height: 44px;
cursor: pointer;
}
#br-os-apps {
width: 100%;
padding: 10px;
}
#br-os-apps .app {
width: 100px;
display: flex;
flex-direction: column;
justify-content: center;
margin-bottom: 10px;
cursor: pointer;
}
#br-os-apps .app img {
width: 50px;
height: 50px;
margin: 0 auto;
}
#br-os-apps .app p {
color: white;
font-size: 14px;
text-align: center;
}
#taskbar {
position: absolute;
bottom: 0;
width: 100%;
height: 45px;
background: grey;
}
#startmenubtn {
position: absolute;
width: 45px;
height: 45px;
border-top-style: none;
border-right-style: solid;
border-bottom-style: none;
border-left-style: none;
border-width: 2px;
cursor: pointer;
}
#startmenu {
position: absolute;
width: 45%;
height: 100px;
bottom: 0px;
left: 0px;
z-index: 1;
background-color: grey;
}
.br-os-window {
position: absolute;
top: 20%;
left: 25%;
display: flex;
flex-direction: column;
width: 50%;
height: 50%;
border: 1px solid #EEE;
border-radius: 10px;
overflow: hidden;
resize: both;
}
.br-os-window .window-bar {
display: flex;
justify-content: space-between;
width: 100%;
background: rgb(182, 182, 182);
padding: 0 10px;
cursor: move;
cursor: -moz-grab;
cursor: -webkit-grab;
}
.br-os-window .window-bar:active {
cursor: grabbing;
cursor: -moz-grabbing;
cursor: -webkit-grabbing;
}
.br-os-window .window-bar .brand {
display: flex;
justify-content: center;
align-items: center;
}
.br-os-window .window-bar .brand img {
width: 32px;
}
.br-os-window .window-bar .brand p {
color: rgb(0, 0, 0);
margin-left: 10px;
}
.br-os-window .window-bar .brand .buttons {
display: flex;
justify-content: center;
align-items: center;
}
.br-os-window .window-bar .brand .buttons button {
border: none;
outline: none;
margin-right: 5px;
color: #FFF;
padding: 5px;
width: 26px;
height: 26px;
border-radius: 50%;
cursor: pointer;
}
.br-os-window .window-bar .brand .buttons button:first-child {
background: rgb(3, 82, 0);
}
.br-os-window .window-bar .brand .buttons button:nth-child(2) {
background: rgb(59, 0, 82);
}
.br-os-window .window-bar .brand .buttons button:nth-child(3) {
background: rgb(121, 45, 1);
}
.br-os-window .window-bar .brand .buttons button:last-child {
background: rgb(255, 43, 43);
margin-right: 0;
}
.br-os-window .window-bar .brand .buttons button:hover {
background: rgb(182, 182, 182);
color: rgb(255, 43, 43);
}
.br-os-window .app {
width: 100%;
height: 100%;
background: #FFF;
overflow: auto;
}
#os-ct-menu {
display: none;
position: absolute;
z-index: 10;
background: #FFF;
padding: 10px;
border-radius: 5px;
box-shadow: 3px 5px 10px rgba(255, 255, 255, 0, 3), 6px 10px 10px rgba(255, 255, 255, 0, 3);
}
#os-ct-menu ul li {
color: rgb(46, 26, 3);
}
#os-ct-menu ul li:hover {
background: antiquewhite;
}
#os-ct-menu.active {
display: block;
}
#taskbarbuttondiv {
position: absolute;
width: 45px;
height: 45px;
background-color: black;
border-style: none;
cursor: pointer;
}
textarea {
position: absolute;
width: 100%;
height: 90%;
bottom: 0px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
<head>
<script async src="https://pagead2.googlesyndication.com/pagead/js/adsbygoogle.js?client=ca-pub-7529225411166140" crossorigin="anonymous"></script>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<title>Frog OS</title>
<link rel="shortcut icon" href="favicon.ico" type="image/x-icon">
<link rel="preconnect" href="https://fonts.googleapis.com">
<link rel="preconnect" href="https://fonts.gstatic.com" crossorigin>
<link href="https://fonts.googleapis.com/css2?family=Poppins:ital,wght@0,300;0,400;0,500;0,600;0,700;1,300;1,400;1,500;1,600;1,700&display=swap" rel="stylesheet">
<link rel="stylesheet" href="assets/css/style.css">
<script src="https://kit.fontawesome.com/d7d87efefa.js" crossorigin="anonymous"></script>
<link rel="stylesheet" href="assets/plugins/vex/css/vex-theme-os.css">
<link rel="manifest" href="manifest.json">
</head>
<body onload="datetime(), loop()">
<div id="br-os-container">
<div id="br-os-apps">
</div>
<div id="taskbar">
<div id="startmenubtn">
<img src="/assets/images/FrogOS.png" onclick="startmenu()" id="startmenubtn"></img>
</div>
<div id="tbarapps"></div>
<div id="dateandtime">
<p id="time">Loading...</p>
<p id="date">Loading...</p>
</div>
</div>
</div>
<div class="br-os-window" draggable="true">
<div class="window-bar">
<div class="brand"></div>
<div class="buttons">
<button id="minimize">
<i class="fa fa-window-minimize"></i>
</button>
<button id="maximise">
<i class="fa fa-window-maximize"></i>
</button>
<button id="shorter">
<i class="fa fa-window-restore"></i>
</button>
<button id="cross">
<i class="fa fa-times"></i>
</button>
</div>
</div>
<div class="app" id="app-main">
</div>
</div>
<div id="app-hide"></div>
<nav id="os-ct-menu">
<uL>
<li><a href="javascript:;">Open</a></li>
<li><a href="javascript:;">Open as administrator</a></li>
<li><a href="javascript:;">Remove</a></li>
<li><a href="javascript:;">Properties</a></li>
</uL>
</nav>
<script src="assets/plugins/vex/js/vex.combined.js"></script>
<script>
vex.defaultOptions.className = "vex-theme-os"
</script>
<script src="assets/js/script.js"></script>
</body>
</html></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74147951,
"author": "JasonY",
"author_id": 12418459,
"author_profile": "https://Stackoverflow.com/users/12418459",
"pm_score": 3,
"selected": true,
"text": "vim my-deployment.yml"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20140332/"
] |
74,146,752 | <p>I have got a <code>tibble</code> of more than 2 million rows. One of the columns <code>size</code> is a value using M to represent million, k to represent thousand; it also has some <code><NA></code> values. The column type is <code>character</code>, like the following:</p>
<pre class="lang-r prettyprint-override"><code>size
1.3M
5k
302
8.6M
<NA>
4.4k
21
</code></pre>
<p>...and so on.</p>
<p>I tried the following code:</p>
<pre class="lang-r prettyprint-override"><code>for (i in 1:length(example$size)) {
if (!is.na(example$size[i])) {
if (str_sub(example$size[i],-1,-1) == "M") {
example$size[i] = as.numeric(str_sub(example$size[i], 1,-2)) * 1000000
} else if (str_sub(example$size[i],-1,-1) == "k") {
example$size[i] = as.numeric(str_sub(example$size[i], 1,-2)) * 1000
}
}
}
</code></pre>
<p>But it took more than half hour and still running, so I interrupted that as I was not sure if my code was wrong and it's in a infinite loop. Is there anything wrong or any way of coding to improve the efficiency?</p>
| [
{
"answer_id": 74147000,
"author": "KacZdr",
"author_id": 12382064,
"author_profile": "https://Stackoverflow.com/users/12382064",
"pm_score": 1,
"selected": false,
"text": "size <- c(\"1.3M\",\"5k\",NA,21,\"4.4k\")\n\nsize <- ifelse(!is.na(size) & grepl(\"M\",size),as.numeric(sub(\"M.*\"... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20012176/"
] |
74,146,786 | <p>(There is no genuine use-case here, so this <em>is</em> my code)</p>
<p>I'm trying to make a function that throws an error if the string is "fish". I was successfully able to do this by using <code>as</code>, however,
is there any way to avoid using <code>as</code> for this scenario?</p>
<pre><code>function throwIfFish<S extends string>(string: S): S extends "fish" ? never : S {
if (string === "fish") {
throw new Error("fish");
}
return string as S extends "fish" ? never : S;
// ^ is this unavoidable?
}
</code></pre>
<p><a href="https://www.typescriptlang.org/play?#code/GYVwdgxgLglg9mABFAFgJzgdwJLAGIwDOKAPAMqICmAHlJWACaGKFRoxgDmAfABSvsuALkRkAlCIo06jZgCJgRFHMQB%20RGEoA3SmkSTEAbwBQiM4hjBE-Nh06IAvE8QKlcsUdPnvqDJg2U-gCiaBhovK7E7gDcXmYAvnGIAPTJiAASWIgQAIZI2Ig5WnAwDIgghHYuOYQqHMgoRCwwUCA5sAiqSWiUrWhIAlU1olS09EwuilFqATp6krGJxqmIKHBziOu6DZSIoJAdSLkANsfIcCyUuy3MUACeAA6UxhAIrIjUjg1%20uATEEVNlGIXm8oIg7l9fFhfkoInRWO4gA" rel="nofollow noreferrer">Typescript Playground</a></p>
| [
{
"answer_id": 74146814,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 1,
"selected": false,
"text": "function throwIfFish<S extends string>(string: S): S extends \"fish\" ? never : S;\nfunction throwIfFish(string: stri... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7589775/"
] |
74,146,842 | <p>I have a huge data frame.</p>
<p>I am using a for loop in the below sample code:</p>
<pre><code>for i in range(1, len(df_A2C), 1):
A2C_TT= df_A2C.loc[(df_A2C['TO_ID'] == i)].sort_values('DURATION_H').head(1)
if A2C_TT.size > 0:
print (A2C_TT)
</code></pre>
<p>This is working fine but I want to use df.iterrows() since it will help me to automaticall avoid empty frame issues.</p>
<p>I want to iterate through <code>TO_ID</code> and looking for <code>minimum values</code> accordingly.</p>
<p><strong>How should I replace my classical <code>i</code> loop counter with df.iterrows()?</strong></p>
<p><strong>Sample Data:</strong></p>
<pre><code>FROM_ID TO_ID DURATION_H DIST_KM
1 7 0.528555556 38.4398
2 26 0.512511111 37.38515
3 71 0.432452778 32.57571
4 83 0.599486111 39.26188
5 98 0.590516667 35.53107
6 108 1.077794444 76.79874
7 139 0.838972222 58.86963
8 146 1.185088889 76.39174
9 158 0.625872222 45.6373
10 208 0.500122222 31.85239
11 209 0.530916667 29.50249
12 221 0.945444444 62.69099
13 224 1.080883333 66.06291
14 240 0.734269444 48.1778
15 272 0.822875 57.5008
16 349 1.171163889 76.43536
17 350 1.080097222 71.16137
18 412 0.503583333 38.19685
19 416 1.144961111 74.35502
</code></pre>
| [
{
"answer_id": 74147036,
"author": "Naveed",
"author_id": 3494754,
"author_profile": "https://Stackoverflow.com/users/3494754",
"pm_score": 3,
"selected": true,
"text": "# run the loop for as many unique TO_ID you have\n# instead of iterrows, which runs for all the DF or running to the s... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146842",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13373167/"
] |
74,146,853 | <p>My teacher gave us a lesson where we had to find out how many times a x number was drawn in the lottery. He gave us a .txt document containing all datas from the previous years. He told us to build a function to discover these values. I ended up with this:</p>
<pre><code>//Transfer the txt logs to variable 'conteudo'
try {
conteudo = fs.readFileSync("dados.txt", "utf8");
conteudo = conteudo.split("\r\n");
vezessort = 0;
} catch(erro) {
console.error(erro.message);
}
//Function created to review all the lines in the txt file
//First for loop is to split each line, making them an array
//Second loop is to compare the values 2 to 7 on each line, where contains the numbers drawn in the lottery
function vezSort(a){
for (i = 1; i < conteudo.length; i++){
conteudo[i] = conteudo[i].split(";");
for(j = 2; j < 8; j++){
if(conteudo[i][j] == a){
vezessort += 1;
}
}
}
}
//In this exercise we need to capture the input from user, and use it as a parameter on the function
a = parseInt(prompt('Digite um número: '));
r = vezSort(a);
console.log(`O número foi sorteado ${vezessort} vezes.`);
</code></pre>
<p>It works perfectly, the final values matches with the desired output he gave. The problem is, in the next question he tell us to loop the function for each number between 1 to 60. But every attempt I try to loop I get problems with this line: <code>conteudo[i] = conteudo[i].split(";");</code>. What I am doing wrong? (Btw, in this exercise the input from the user is not needed.)</p>
| [
{
"answer_id": 74146961,
"author": "doctorjay",
"author_id": 7237929,
"author_profile": "https://Stackoverflow.com/users/7237929",
"pm_score": -1,
"selected": false,
"text": ".split()"
},
{
"answer_id": 74147096,
"author": "Barmar",
"author_id": 1491895,
"author_profi... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20276727/"
] |
74,146,913 | <p>It's only giving me the result of the first operation which is multiplied even if my input was the addition.</p>
<pre><code>print('Calculator')
operation = input('Choose:\n Mltiply(*)\n Divise\(/)\n Add(+)\n Subbstract(-)\n ')
if operation == 'mutiply' or 'Multiply' or 'MULTIPLY' or '*':
num1 = input('Write Your number :')
num2 = input('Write your next number :')
result = float(num1) * float(num2)
print(result )
elif operation == 'DIVISE' or 'divise' or 'Divise' or '/':
num1 = input('Write Your number :')
num2 = input('Write your next number :')
result = float(num1) / float(num2)
print(result )
elif operation == 'Add' or 'add' or 'ADD' or '+':
num1 = input('Write Your number :')
num2 = input('Write your next number :')
result = float(num1) + float(num2)
print(result )
elif operation == 'Subbstract' or 'subbstract' or 'SUBBSTRACT' or '-':
num1 = input('Write Your number :')
num2 = input('Write your next number :')
result = float(num1) - float(num2)
print(result )
else:
print('SYNTAX ERROR')
</code></pre>
| [
{
"answer_id": 74146961,
"author": "doctorjay",
"author_id": 7237929,
"author_profile": "https://Stackoverflow.com/users/7237929",
"pm_score": -1,
"selected": false,
"text": ".split()"
},
{
"answer_id": 74147096,
"author": "Barmar",
"author_id": 1491895,
"author_profi... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146913",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20295953/"
] |
74,146,920 | <p>I am trying to deploy a Laravel 9 site onto an IIS Server (and no, I don't have the option of using a Linux server). If I run the local server setup with "php artisan serve", it works fine through 127.0.0.1 on the server, including all calls to the database.</p>
<p>However, if I try to run the site through the IIS server via its domain name, I get a 500 server error. Failed Response Tracing shows a FASTCGI_UNKNOWN_ERROR: "The directory name is invalid. (0x8007010b)"</p>
<p><img src="https://certification.lionenergy.com/500_server_error.png" alt="Error Screenshot" /></p>
<p>The DNS is functioning properly as I have tested a phpinfo page on it.</p>
<p>Is there a configuration in IIS I need to set in order for the Laravel site to work?</p>
| [
{
"answer_id": 74146961,
"author": "doctorjay",
"author_id": 7237929,
"author_profile": "https://Stackoverflow.com/users/7237929",
"pm_score": -1,
"selected": false,
"text": ".split()"
},
{
"answer_id": 74147096,
"author": "Barmar",
"author_id": 1491895,
"author_profi... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146920",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1143891/"
] |
74,146,945 | <p>I'm having trouble explaining this so please bare with me.</p>
<p>I have several lists and I want to write a python script that picks an item at random from the first list, then checks that result against a "fail list," if the item isn't on the "fail list" I want to move to the next list and do the same thing until it fails.</p>
<pre><code>#Go through these lists one by one, picking random item.
action_heros = ['thor', 'batman', 'spiderman', 'superbart']
friends = ['joey', 'feebee', 'rachael', 'dog']
himym = ['robin', 'marshall', 'ted', 'lily', 'barney']
# fail list
simpsons = ['bart', 'homer', 'marg', 'superbart', 'dog', 'barney']
#This is how I've been trying to solve it, but I can't get the code to move to the second or third attempt
# pick a random word from the lists
rand_action_hero = random.choice(action_heros)
rand_friend = random.choice(friends)
rand_himym = random.choice(himym)
#run the random word from each list against the checklist one by one until it fails.
if rand_action_hero in simpsons:
print('failed at actionheros')
#if the random word isn't in simpsons I want it to pick a new random word and try against friend, then himym
</code></pre>
<p>Thanks for any help, I'm still learning to code so it means a lot!</p>
| [
{
"answer_id": 74146961,
"author": "doctorjay",
"author_id": 7237929,
"author_profile": "https://Stackoverflow.com/users/7237929",
"pm_score": -1,
"selected": false,
"text": ".split()"
},
{
"answer_id": 74147096,
"author": "Barmar",
"author_id": 1491895,
"author_profi... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146945",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11437774/"
] |
74,146,965 | <h1>Typical EncoderDecoderModel that works on a Pre-coded Dataset</h1>
<p>The code snippet snippet as below is frequently used to train an <a href="https://huggingface.co/docs/transformers/model_doc/encoder-decoder" rel="nofollow noreferrer"><code>EncoderDecoderModel</code></a> from Huggingface's transformer library</p>
<pre><code>from transformers import EncoderDecoderModel
from transformers import PreTrainedTokenizerFast
multibert = EncoderDecoderModel.from_encoder_decoder_pretrained(
"bert-base-multilingual-uncased", "bert-base-multilingual-uncased"
)
tokenizer = PreTrainedTokenizerFast.from_pretrained("bert-base-multilingual-uncased")
...
</code></pre>
<h1>And a pre-processed/coded dataset can be used to train the model as such, when using the <code>wmt14</code> dataset:</h1>
<pre><code>import datasets
train_data = datasets.load_dataset("wmt14", "de-en", split="train")
val_data = datasets.load_dataset("wmt14", "de-en", split="validation[:10%]")
from functools import partial
def process_data_to_model_inputs(batch, encoder_max_length=512, decoder_max_length=512, batch_size=2):
inputs = tokenizer([segment["en"] for segment in batch['translation']],
padding="max_length", truncation=True, max_length=encoder_max_length)
outputs = tokenizer([segment["de"] for segment in batch['translation']],
padding="max_length", truncation=True, max_length=encoder_max_length)
batch["input_ids"] = inputs.input_ids
batch["attention_mask"] = inputs.attention_mask
batch["decoder_input_ids"] = outputs.input_ids
batch["decoder_attention_mask"] = outputs.attention_mask
batch["labels"] = outputs.input_ids.copy()
# because BERT automatically shifts the labels, the labels correspond exactly to `decoder_input_ids`.
# We have to make sure that the PAD token is ignored
batch["labels"] = [[-100 if token == tokenizer.pad_token_id else token for token in labels] for labels in batch["labels"]]
return batch
def munge_dataset_to_pacify_bert(dataset, encoder_max_length=512, decoder_max_length=512, batch_size=2):
bert_wants_to_see = ["input_ids", "attention_mask", "decoder_input_ids",
"decoder_attention_mask", "labels"]
_process_data_to_model_inputs = partial(process_data_to_model_inputs,
encoder_max_length=encoder_max_length,
decoder_max_length=decoder_max_length,
batch_size=batch_size
)
dataset = dataset.map(_process_data_to_model_inputs,
batched=True,
batch_size=batch_size
)
dataset.set_format(type="torch", columns=bert_wants_to_see)
return dataset
train_data = munge_dataset_to_pacify_bert(train_data)
val_data = munge_dataset_to_pacify_bert(val_data)
</code></pre>
<h1>Then the training can be done easily as such:</h1>
<pre><code>from transformers import Seq2SeqTrainer, Seq2SeqTrainingArguments
# set training arguments - these params are not really tuned, feel free to change
training_args = Seq2SeqTrainingArguments(
output_dir="./",
evaluation_strategy="steps",
...
)
# instantiate trainer
trainer = Seq2SeqTrainer(
model=multibert,
tokenizer=tokenizer,
args=training_args,
train_dataset=train_data,
eval_dataset=val_data,
)
trainer.train()
</code></pre>
<p>A working example can be found on something like: <a href="https://www.kaggle.com/code/alvations/neural-plasticity-bert2bert-on-wmt14" rel="nofollow noreferrer">https://www.kaggle.com/code/alvations/neural-plasticity-bert2bert-on-wmt14</a></p>
<h1>However, parallel data used to train an EncoderDecoderModel usually exists as <code>.txt</code> or <code>.tsv</code> files, not a pre-coded dataset</h1>
<p>Given a large <code>.tsv</code> file (e.g. 1 billion lines), e.g.</p>
<pre><code>hello world\tHallo Welt
how are you?\twie gehts?
...\t...
</code></pre>
<h4>Step 1: we can convert into the parquet / pyarrow format, one can do something like:</h4>
<pre><code>import vaex # Using vaex
import sys
filename = "train.en-de.tsv"
df = vaex.from_csv(filename, sep="\t", header=None, names=["src", "trg"], convert=True, chunk_size=50_000_000)
df.export(f"{filename}.parquet")
</code></pre>
<h4>Step 2: Then we will can read it into a Pyarrow table to fit into the <code>datasets.Dataset</code> object and use the <code>munge_dataset_to_pacify_bert()</code> as shown above, e.g</h4>
<pre><code>from datasets import Dataset, load_from_disk
import pyarrow as pa
_ds = Dataset(pa.compute.drop_null(pa.parquet.read_table('train.en-de.tsv.parquet')
_ds.save_to_disk('train.en-de.tsv.parquet.hfdataset')
_ds = load_from_disk('train.en-de.tsv.parquet.hfdataset')
train_data = munge_dataset_to_pacify_bert(_ds)
train_data.save_to_disk('train.en-de.tsv.parquet.hfdataset')
</code></pre>
<h4>While the process above works well for small-ish dataset, e.g. 1-5 million lines of data, when the scale of the goes to 500 million to 1 billion, the last <code>.save_to_disk()</code> function seems like it is runningf "forever" and the end is no where in sight.</h4>
<p>Breaking down the steps in the <code>munge_dataset_to_pacify_bert()</code>, there are 2 sub-functions:</p>
<ul>
<li><code>dataset.map(_process_data_to_model_inputs, batched=True, batch_size=batch_size)</code></li>
<li><code>dataset.set_format(type="torch", columns=bert_wants_to_see)</code></li>
</ul>
<p>For the <code>.map()</code> process, it's possible to scale in parallel threads by specifying by</p>
<pre><code>dataset.map(_process_data_to_model_inputs,
batched=True, batch_size=100,
num_proc=32 # num of parallel threads.
)
</code></pre>
<p>And when I tried to process with</p>
<ul>
<li><code>num_proc=32</code></li>
<li><code>batch_size=100</code></li>
</ul>
<p>The <code>.map()</code> function finishes the processing of 500 million lines in 18 hours of compute time on Intel Xeon E5-2686 @ 2.3GHz with 32 processor cores, optimally.</p>
<p>But somehow the <code>.map()</code> function created 32 temp <code>.arrow</code> files and 128 <code>tmp...</code> binary files. Seemingly the last <code>save_to_disk</code> function has been running for more than 10+ hours and have not finished combining the temp files in parts to save the final HF Dataset to disk.</p>
<hr />
<p>Given the above context, my questions in parts are:</p>
<h2>Question (Part 1): When the mapping function ends and created the temp <code>.arrow</code> and <code>tmp...</code> files, is there a way to read these individually instead of try to save them into a final directory using the <code>save_to_disk()</code> function?</h2>
<hr />
<h2>Question (Part 2): Why is the <code>save_to_disk()</code> function so slow after the mapping and how can the mapped processed data be saved in a faster manner?</h2>
<hr />
<h2>Question (Part 3): Is there a way to avoid the <code>.set_format()</code> function after the <code>.map()</code> and make it part of the <code>_process_data_to_model_inputs</code> function?</h2>
<hr />
| [
{
"answer_id": 74146961,
"author": "doctorjay",
"author_id": 7237929,
"author_profile": "https://Stackoverflow.com/users/7237929",
"pm_score": -1,
"selected": false,
"text": ".split()"
},
{
"answer_id": 74147096,
"author": "Barmar",
"author_id": 1491895,
"author_profi... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/610569/"
] |
74,146,980 | <p>I currently have code to randomly generate values from 1-10 but I want to increase the probability of generating 10 by 3. How do I go about changing up my code?</p>
| [
{
"answer_id": 74147034,
"author": "doctorjay",
"author_id": 7237929,
"author_profile": "https://Stackoverflow.com/users/7237929",
"pm_score": -1,
"selected": false,
"text": " array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10 10]\n myRandomValue = array[Math.floor(Math.random() * array.length)]... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20296073/"
] |
74,146,990 | <p>I am using <code>recoil-relay</code> to fetch queries directly for selectors.
Currently, I am using <code>graphQLSelector</code>, but having problems when trying to get the value returned by the selector.
Sample code:</p>
<pre><code>import { graphql } from "react-relay";
import { graphQLSelector } from "recoil-relay";
import { RelayEnvironment } from "../relay_env";
export interface Client {
Id: string;
age: string;
gender: string;
income: string;
location: string;
}
const clientsSelector = graphQLSelector({
key: "clientsSelector",
environment: RelayEnvironment,
query: graphql`
query ClientsAtomsQuery {
clients {
Id
age
gender
income
location
}
}
`,
variables: {},
mapResponse: (data) => data.clients as Array<Client>,
});
</code></pre>
<p>The error appears in runtime, while executing:</p>
<pre><code>const clients = useRecoilValue(clientsSelector);
</code></pre>
<p>The relay environment is not the problem, because when I try to use the same query using only Relay, it works.</p>
<p>The relay-compiler is working and generates the correct <code>.graphql.ts</code> file:</p>
<pre><code>...
import { ConcreteRequest, Query } from 'relay-runtime';
export type ClientsAtomsQuery$variables = {};
export type ClientsAtomsQuery$data = {
readonly clients: ReadonlyArray<{
readonly Id: number | null;
readonly age: string;
readonly gender: string;
readonly income: string;
readonly location: string;
}>;
};
export type ClientsAtomsQuery = {
response: ClientsAtomsQuery$data;
variables: ClientsAtomsQuery$variables;
};
const node: ConcreteRequest = (function(){
var v0 = [
{
"alias": null,
"args": null,
"concreteType": "Client",
"kind": "LinkedField",
"name": "clients",
"plural": true,
"selections": [
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "Id",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "age",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "gender",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "income",
"storageKey": null
},
{
"alias": null,
"args": null,
"kind": "ScalarField",
"name": "location",
"storageKey": null
}
],
"storageKey": null
}
];
return {
"fragment": {
"argumentDefinitions": [],
"kind": "Fragment",
"metadata": null,
"name": "ClientsAtomsQuery",
"selections": (v0/*: any*/),
"type": "Query",
"abstractKey": null
},
"kind": "Request",
"operation": {
"argumentDefinitions": [],
"kind": "Operation",
"name": "ClientsAtomsQuery",
"selections": (v0/*: any*/)
},
"params": {
"cacheID": "30edf9a9b7f2c445a8a07730198d719d",
"id": null,
"metadata": {},
"name": "ClientsAtomsQuery",
"operationKind": "query",
"text": "query ClientsAtomsQuery {\n clients {\n Id\n age\n gender\n income\n location\n }\n}\n"
}
};
})();
(node as any).hash = "e029635c746ef9ec4ca4b7503898730d";
export default node;
</code></pre>
| [
{
"answer_id": 74147034,
"author": "doctorjay",
"author_id": 7237929,
"author_profile": "https://Stackoverflow.com/users/7237929",
"pm_score": -1,
"selected": false,
"text": " array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10 10]\n myRandomValue = array[Math.floor(Math.random() * array.length)]... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74146990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20295945/"
] |
74,147,004 | <p>Can anyone help me with this problem, I'm trying to make a for loop that does not accept any negative integers, therefore asking the user to enter a positive integer.</p>
<pre><code>current = []
print("Enter 6 integers greater than 0")
for i in range(6):
current.append(eval(input()))
</code></pre>
| [
{
"answer_id": 74147034,
"author": "doctorjay",
"author_id": 7237929,
"author_profile": "https://Stackoverflow.com/users/7237929",
"pm_score": -1,
"selected": false,
"text": " array = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 10 10]\n myRandomValue = array[Math.floor(Math.random() * array.length)]... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74147004",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20296069/"
] |
74,147,023 | <p>I'd like to get some kind of call back once <code>memoizedTodos</code> are displayed on the screen.</p>
<p>or execute <code>handleOpen</code> function once <code>memoizedTodos</code> are displayed on the screen.</p>
<p>Right now what I'm displaying on the screen is just the text. but you could imagine that this useMemo returns thousands of texts and images so it will take a while for those to be on the screen.</p>
<p>What I want to do here is run the <code>handleOpen</code> function after memoizedTodos returns are displayed like I can see all the todos visibly on the screen.</p>
<p>Are there any way that I can do this?</p>
<p>I thought I could use <code>async/await</code> to do this? or what would it be the best way to do this?</p>
<pre><code>import React, { useMemo } from "react";
import "./styles.css";
export default function App() {
const handleOpen = () => {
console.log("this is running");
};
const memoizedTodos = useMemo(() => {
return [...Array(n)].map((e, i) => <li key={i}>This is so many data</li>);
}, []);
return (
<div className="App">
<h1>Hello CodeSandbox</h1>
<>{memoizedTodos}</>
</div>
);
}
</code></pre>
| [
{
"answer_id": 74147126,
"author": "kind user",
"author_id": 6695924,
"author_profile": "https://Stackoverflow.com/users/6695924",
"pm_score": 1,
"selected": false,
"text": "useEffect"
},
{
"answer_id": 74147412,
"author": "elVengador",
"author_id": 12126422,
"author_... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74147023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14489531/"
] |
74,147,044 | <p>Is it possible for a Python function to return different types depending on the if-else case?</p>
<pre><code>def return_different() -> [String, List]:
a = random.randint(1, 10)
if a%2 == 0:
return []
else:
return "odd"
</code></pre>
<p>So in one case, it could return a String, or in another, it could return a List. Is this possible in Python with function signatures?</p>
| [
{
"answer_id": 74147072,
"author": "Carcigenicate",
"author_id": 3000206,
"author_profile": "https://Stackoverflow.com/users/3000206",
"pm_score": 3,
"selected": true,
"text": "Union"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74147044",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13856040/"
] |
74,147,073 | <p>here are models.py file</p>
<pre><code>class album(TimeStampedModel):
#album_artist = models.ForeignKey(artist, on_delete=models.CASCADE)
album_name = models.CharField(max_length=100, default="New Album")
#released_at = models.DateTimeField(blank=False, null=False)
#price = models.DecimalField(
# max_digits=6, decimal_places=2, blank=False, null=False)
#is_approved = models.BooleanField(
# default=False, blank=False)
#def __str__(self):
# return self.album_name
class song(models.Model):
name = models.CharField(max_length=100,blank=True,null=False)
album = models.ForeignKey(album, on_delete=models.CASCADE,default=None)
# image = models.ImageField(upload_to='images/', blank = False)
# thumb = ProcessedImageField(upload_to = 'thumbs/', format='JPEG')
# audio = models.FileField(
# upload_to='audios/', validators=[FileExtensionValidator(['mp3', 'wav'])])
# def __str__(self):
# return self.name
</code></pre>
<p>I want to make the default value of the song name equal to the album name which i choose by the album Foreignkey. (in the admin panel page)
any help ?</p>
| [
{
"answer_id": 74147727,
"author": "theeomm",
"author_id": 9983720,
"author_profile": "https://Stackoverflow.com/users/9983720",
"pm_score": 2,
"selected": true,
"text": "blank=True"
},
{
"answer_id": 74147885,
"author": "Nealium",
"author_id": 10229768,
"author_profi... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74147073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20271785/"
] |
74,147,112 | <p>I have two files: file1.py and file2.py</p>
<p>file1.py</p>
<pre><code>print("34343433")
def print_hello():
print("Hello")
</code></pre>
<p>file2.py</p>
<pre><code>from file1 import print_hello
print_hello()
</code></pre>
<p>the output of file2 is:</p>
<pre><code>34343433
Hello
</code></pre>
<p>I just want to have it print only the "Hello" portion.</p>
| [
{
"answer_id": 74147727,
"author": "theeomm",
"author_id": 9983720,
"author_profile": "https://Stackoverflow.com/users/9983720",
"pm_score": 2,
"selected": true,
"text": "blank=True"
},
{
"answer_id": 74147885,
"author": "Nealium",
"author_id": 10229768,
"author_profi... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74147112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20296110/"
] |
74,147,117 | <p>I am doing an assignment where I must use nested loops in order to add up the squares and cubes of integers from 1 to N (N being whatever the user inputs). For example, if the user input the number 5, the program is supposed to do "1²+2²+3²+4²+5²" and output the sum of those numbers, as well "1³+2³+3³+4³+5³" and output the sum of those numbers.</p>
<p>However, I am having trouble figuring out how to code it in a way that I receive the proper output? This is what I wrote. Scanners were already added.</p>
<pre><code>int limitNum = input.nextInt();
double squareNums:
double sumofSq = 0;
double cubedNums;
double sumofCubes = 0;
for(int s = 1; s <= limitNum; s++)
{
for(int c = 1; c <= limitNum; c++)
{
cubedNums = Math.pow(c, 3);
sumofCubes = sumofCubes + cubedNums;
}
squareNums= Math.pow(s, 2);
sumofSq = sumofSq + squareNums;
}
</code></pre>
<p>But currently, when I run this program, the sum of the squares output correctly, but the sum of the cubes is always some big number. For example if 5 is used, sumofSq would output 55.0, but sumofCubes would output 1125.0.</p>
| [
{
"answer_id": 74147727,
"author": "theeomm",
"author_id": 9983720,
"author_profile": "https://Stackoverflow.com/users/9983720",
"pm_score": 2,
"selected": true,
"text": "blank=True"
},
{
"answer_id": 74147885,
"author": "Nealium",
"author_id": 10229768,
"author_profi... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74147117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20296057/"
] |
74,147,127 | <p>How do I convert an array into a string with a dash '-' in between in bash. For eg, I have this array</p>
<pre><code>arr=(a b c d e)
</code></pre>
<p>I want to convert it into a string "a-b-c-d".
I figured out this "a-b-c-d-e," but there is an unwanted dash at the end. Is there an efficient way of doing this?</p>
<p>Thanks</p>
| [
{
"answer_id": 74147188,
"author": "glenn jackman",
"author_id": 7552,
"author_profile": "https://Stackoverflow.com/users/7552",
"pm_score": 2,
"selected": false,
"text": "\"${arr[*]}\""
},
{
"answer_id": 74147541,
"author": "Diego Torres Milano",
"author_id": 236465,
... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74147127",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16666341/"
] |
74,147,168 | <p>I have a div with a h3, p and button elements. I want the h3 to be on a separate line, and the p and button element on a different line. How can I implement this?</p>
<p>Like:</p>
<p>****<strong>{names}</strong></p>
<p><strong>{date} Trashicon</strong>****</p>
<pre><code> <div className="nameHeader">
<h3>{names}</h3>
<p>{date}</p>
<button
className="nameHeader__icon"
onClick={deletetNames}
>
<GrTrash />
</button>
</div>
</code></pre>
<pre><code>.nameHeader {
width: 100%;
height: 100%;
padding: 1rem;
h3 {
font-weight: 600;
}
p {
font-size: 20px;
}
&__icon {
color: #ccc;
}
}
</code></pre>
| [
{
"answer_id": 74147255,
"author": "Konrad",
"author_id": 5089567,
"author_profile": "https://Stackoverflow.com/users/5089567",
"pm_score": 0,
"selected": false,
"text": "inline-block"
},
{
"answer_id": 74147340,
"author": "Kr1ss",
"author_id": 18141852,
"author_profi... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74147168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19055100/"
] |
74,147,172 | <p>I'm trying to make a webpage that when you click on both buttons it'll change the background color, but for some reason that event won't happen unless i change them from the original variable. I think it's because my functions aren't getting and changing my variable's value for some reason but there may be another reason that i can't see. Is there a correct way to change variable values inside functions that i'm not using?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let uno = false;
let dos = false;
function change1() {
uno = true;
return uno;
}
function change2() {
dos = true;
return dos;
}
if (uno && dos) {
document.body.classList.add("change");
}</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>html,
body {
height: 100%;
width: 100%;
}
body {
margin: 0;
background-color: #8AB0AB;
display: flex;
align-items: center;
justify-content: center;
}
.change {
background-color: #F4D35E;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><html>
<body>
<button id="1" onclick="change1()">
#1
</button>
<button id='2' onclick="change2()">
#2
</button>
</body>
</html></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74147204,
"author": "Barmar",
"author_id": 1491895,
"author_profile": "https://Stackoverflow.com/users/1491895",
"pm_score": 2,
"selected": false,
"text": "if (uno && dos)"
},
{
"answer_id": 74148117,
"author": "Ronnie Royston",
"author_id": 4797603,
"a... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74147172",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19156989/"
] |
74,147,213 | <p>So I have a table in my SQL and it saves ServerID from discord, now like 500 users verified and on the table it says like ServerID: 123 User: Test
Now I accidentally I have deleted the server on dashboard and all things with the server id 123 have been deleted, I have made a backup earlier, now my question is can I do it like I only search id 123 can download only the strings with it and add it to my old database? Thanks!</p>
| [
{
"answer_id": 74147270,
"author": "David Moruzzi",
"author_id": 20287283,
"author_profile": "https://Stackoverflow.com/users/20287283",
"pm_score": 1,
"selected": false,
"text": "SELECT * FROM table WHERE id = 123;"
}
] | 2022/10/20 | [
"https://Stackoverflow.com/questions/74147213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19518105/"
] |
74,147,262 | <p>Right now I am practicing List
I am facing a problem of inserting nested list.
for instance; I have a nested list and i want to make another nested.</p>
<p>example</p>
<pre><code>a = [[1, 'a', 2], [2, 'a', 3], [3, 'b', 4], [4, 'c', 5]]
</code></pre>
<p>output should be:</p>
<pre><code>output = [['a'[1,2],[2,3]], ['b'[3],[4]], ['c'[4],[5]]]
</code></pre>
| [
{
"answer_id": 74147310,
"author": "Barmar",
"author_id": 1491895,
"author_profile": "https://Stackoverflow.com/users/1491895",
"pm_score": 3,
"selected": true,
"text": "from collections import defaultdict\n\na = [[1, 'a', 2], [2, 'a', 3], [3, 'b', 4], [4, 'c', 5]]\noutput_dict = default... | 2022/10/20 | [
"https://Stackoverflow.com/questions/74147262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20154400/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.