qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,178,614 | <p>I have a geodata frame. I have a column and I would like to create a new one subtracting one if that column is strictly greater than 0, otherwise, maintain the same value.</p>
<p>I have tried the following:</p>
<pre><code>df['new_column'] = df.apply(lambda y: (df['old_column'].subtract(1)) if y['old_column'] > 0 else y['old_column'], axis=1)
</code></pre>
<p>It's doing well at the time to differentiate when <code>old_column</code> is greater than 0, but at the moment to substract one, it's doing something strange, it's not substracting, it's just given a series of numbers, 3-2 2-1 1 1-1, things like that. Why is it doing that?</p>
| [
{
"answer_id": 74178755,
"author": "bitflip",
"author_id": 20027803,
"author_profile": "https://Stackoverflow.com/users/20027803",
"pm_score": 1,
"selected": false,
"text": "apply"
},
{
"answer_id": 74178964,
"author": "Victor Linde",
"author_id": 19407522,
"author_pr... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178614",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18232059/"
] |
74,178,624 | <p>I'm trying to convert large string in lines, but failing if <code>\n</code> is occurred in it.</p>
<p><strong>Example string</strong></p>
<pre><code>s1 = """
x = 10
y = 20
print(f"Sample Calculator:\n{x} + {y} = {x+y}")"""
</code></pre>
<pre><code>lines = s1.splitlines() # Similar results on lines = s1.split('\n')
print(*lines, sep='\n------\n')
</code></pre>
<p><strong>output:</strong></p>
<pre><code>
------
x = 10
------
y = 20
------
print(f"Sample Calculator:
------
{x} + {y} = {x+y}")
</code></pre>
<p><strong>Required output:</strong></p>
<pre><code>
------
x = 10
------
y = 20
------
print(f"Sample Calculator:\n{x} + {y} = {x+y}")
</code></pre>
| [
{
"answer_id": 74178671,
"author": "Copium-Enjoyer",
"author_id": 17969175,
"author_profile": "https://Stackoverflow.com/users/17969175",
"pm_score": 1,
"selected": false,
"text": "print(f\"Sample Calculator:\\\\n{x} + {y} = {x+y}\")\"\"\""
},
{
"answer_id": 74179194,
"author... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15276432/"
] |
74,178,637 | <p>When the user clicks the component I make a get request to my fetch_description which returns this exact response :</p>
<pre><code>[{"Descrizione":"test1"},{"Descrizione":"test2"}]
</code></pre>
<p>What I want is to take what's in the response and put that into my modal. In my console.log(result.data) the data is shown correctly, so I think my issue is in operationList.js, in the map function but I don't understand what is wrong there.</p>
<p>However the modal I get is showing empty lists</p>
<pre><code> <li>
</code></pre>
<p><strong>My code is here:</strong></p>
<p>Calendar.js</p>
<pre><code>const Calendar = () => {
const [show, setShow] = useState(false);
const [operations, listOperations] = useState([]);
return (
<>
<FullCalendar
plugins={[listDayPlugin]}
timeZone="local"
locale="it"
initialView="listDay"
events="http://localhost:5000/parse_appointments"
eventClick =
{
function(arg){
Axios.get("http://localhost:5000/fetch_description", {
params: {
id: arg.event.id
}
})
.then(
(result) => {
listOperations(result.data);
setShow(true);
console.log(result.data);
}
)
.catch(err => console.log(err))
}
}
/>
<Modal show={show} onHide={() => setShow(false)}>
<Modal.Header>Hi</Modal.Header>
<Modal.Body>
<div>
{ operations ?
(
<TodoList operations={operations}/>
)
:
(
<h1> Loading</h1>
)
}
</div>
</Modal.Body>
<Modal.Footer>This is the footer</Modal.Footer>
</Modal>
</>
);
};
export default Calendar;
</code></pre>
<p>operationList.js</p>
<pre><code>const TodoList = ({ operations }) => {
return (
<ul>
{operations.map((operation) => (
<li
key={operation.Descrizione}
>
</li>
))}
</ul>
);
};
export default TodoList;
</code></pre>
| [
{
"answer_id": 74178707,
"author": "A.Vinuela",
"author_id": 9095818,
"author_profile": "https://Stackoverflow.com/users/9095818",
"pm_score": 1,
"selected": false,
"text": " const [operations, listOperations] = useState([]);\n"
},
{
"answer_id": 74178749,
"author": "Abrar B... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178637",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12947815/"
] |
74,178,651 | <p><strong>Edit - I have solved this problem but if its okay, I would like the experts here to still explain this problem so that other beginners could learn. You would do a way better job explaining.</strong></p>
<p>I'm trying to learn recursion and I kind of get the idea of recursion (dividing a big problem into smaller solutions and then combining them together. I have a few questions about this particular problem though. Factorial.</p>
<pre><code>def fact(n):
if n==1:
return 1
else:
return n*fact(n-1)
</code></pre>
<p>The problem is, I don't know exactly how the calculation has been done after we reduce the n value by 1 on every recursion. For example, if n = 5, then the n value would go down by 1 every time (5,4,3,2,1). What I don't get is, what happens with those values? When are they actually multiplied up together? Can someone write the output or what's happening to the n value maybe step-by-step? I have tried to visualize this on PythonTutor, it was helpful but not very helpful.
<a href="https://i.stack.imgur.com/115jT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/115jT.png" alt="enter image description here" /></a></p>
<p>If you guys feel as if this is a repeated question or very common, please link me to a source like (Youtube) where this is explained. Thank you very much.</p>
| [
{
"answer_id": 74178707,
"author": "A.Vinuela",
"author_id": 9095818,
"author_profile": "https://Stackoverflow.com/users/9095818",
"pm_score": 1,
"selected": false,
"text": " const [operations, listOperations] = useState([]);\n"
},
{
"answer_id": 74178749,
"author": "Abrar B... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178651",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20017312/"
] |
74,178,657 | <p>I am analysing some JSON data in Palantir Foundry using PySpark. The source is a 30MB uploaded JSON file containing four elements, one of which holds a table of some 60 columns and 20,000 rows. Some of the columns in this table are strings that contain HTML entities representing UTF characters (other columns are numeric or boolean). I want to clean these strings to replace the HTML entities with the corresponding characters.</p>
<p>I realise that I can apply <code>html.unescape(my_str)</code> in a UDF to the string columns once all the JSON data has been converted into dataframes. However, this sounds inefficient. <a href="https://stackoverflow.com/a/38181647/937094">This answer</a> suggests it would be better to process the whole JSON file in one go, before converting it to a dataframe. However, my current code uses <code>spark_session.read.json()</code> to go automatically from the raw file to a dataframe with a proper schema. I can't see how to modify it to include the <code>unescape()</code> stage without ending up with everything as <code>StringType()</code>, and I don't want to have to manually code the schema for every column of the nested data structure. My current code to read the JSON into a dataframe looks like this:</p>
<pre class="lang-py prettyprint-override"><code>from transforms.verbs.dataframes import sanitize_schema_for_parquet
from transforms.api import transform, Input, Output, Check
@transform(
parsed_output=Output("out_path"),
raw_file_input=Input("in_path")
)
def read_json(ctx, parsed_output, raw_file_input):
filesystem = raw_file_input.filesystem()
hadoop_path = filesystem.hadoop_path
paths = [f"{hadoop_path}/{f.path}" for f in filesystem.ls()]
df = ctx.spark_session.read.json(paths)
parsed_output.write_dataframe(sanitize_schema_for_parquet(df))
</code></pre>
<p><strong>How can I adapt this to <code>unescape()</code> the plain text of the JSON before it is parsed?</strong> Or would it actually be likely to be more efficient to <code>unescape</code> row by row and column by column later, using the parallelism in Spark, than trying to process the data as a single 30MB-long string?</p>
<p>An example of my JSON input format. The real input is about 30MB long and not pretty-printed. The <code>Data</code> structure has many more rows, and around 60 columns. String columns are mixed in between numeric and boolean columns, in no particular order:</p>
<pre class="lang-json prettyprint-override"><code>{
"Data": [
{"Id": 1, "Lots": "more", "data": "of", "different": "types", "Flag1": true, "RefNumber": 17},
{"Id": 2, "Lots": "of the string", "data": "includes entities like &#8804; in", "different": "places", "Flag1": false, "RefNumber": 17781}
],
"TotalRows":2,
"Warnings":null,
"Errors":null
}
</code></pre>
<p>The final expected output from the above would end up as the below (I don't have any problem with processing the JSON into the right columns, it's just efficiently converting the HTML entities to characters that is an issue). Note the math symbol <code>≤</code> in the 'data' field in row 2, rather than the entity <code>&#8804;</code>:</p>
<pre class="lang-none prettyprint-override"><code>Id | Lots | data | different | Flag1 | RefNumber
---+-----------------+-------------------------------+-----------+-------+-----------
1 | "more" | "of" | "types" | true | 17
2 | "of the string" | "includes entities like ≤ in" | "places" | false | 17781
</code></pre>
| [
{
"answer_id": 74178877,
"author": "Yayati Sule",
"author_id": 5742662,
"author_profile": "https://Stackoverflow.com/users/5742662",
"pm_score": 0,
"selected": false,
"text": "withColumn(cnameNew, udf_unescape(columnWithHtml))"
},
{
"answer_id": 74180992,
"author": "Aaron Rub... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178657",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/937094/"
] |
74,178,665 | <p>As I understand The LSU(Load/Store Unit) in a RISC architecture like Arm handles load/store calls, and DMA(Direct Memory Access) Unit is responsible for moving data independent from the processor, memory to memory, peripheral to memory, etc. What I am confused about is which one handles the prefetching of instructions or data for branch predictor or instruction/data cache. Since prefetching is not an instruction but an automatic process to speed up the processor, is this job handled by DMA? I am confused since the DMA unit is shown as an external unit in the example design given at Arm Cortex-M85 technical reference manual
<a href="https://i.stack.imgur.com/5Exzy.png" rel="nofollow noreferrer">example design</a></p>
| [
{
"answer_id": 74178877,
"author": "Yayati Sule",
"author_id": 5742662,
"author_profile": "https://Stackoverflow.com/users/5742662",
"pm_score": 0,
"selected": false,
"text": "withColumn(cnameNew, udf_unescape(columnWithHtml))"
},
{
"answer_id": 74180992,
"author": "Aaron Rub... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20319866/"
] |
74,178,681 | <p>How do I add a time interval to this code?
I want the code to automatically fetch data during a specific time interval.</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>function fetch(){
$.ajax({
type: 'POST',
url: 'resultsget.php',
dataType: 'json',
success: function(response){
$('#content').html(response).iCheck({checkboxClass: 'icheckbox_flat-green',radioClass: 'iradio_flat-green'});
}
});
}</code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74178877,
"author": "Yayati Sule",
"author_id": 5742662,
"author_profile": "https://Stackoverflow.com/users/5742662",
"pm_score": 0,
"selected": false,
"text": "withColumn(cnameNew, udf_unescape(columnWithHtml))"
},
{
"answer_id": 74180992,
"author": "Aaron Rub... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178681",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15672454/"
] |
74,178,685 | <p>I recently found out about a nuget called <code>LanguageExt.Core</code> and why it is not so efficient to throw exceptions while handling them via middleware or so.</p>
<p>Speaking of it, I would like to know what is the best way to simply check if the result has faulted, so I can throw the exception in order to trigger Polly's retry pattern logic.</p>
<p>The best I could think of:</p>
<pre class="lang-cs prettyprint-override"><code>private async Task RunAsync(Uri uri)
{
await ConnectAsync(uri);
var result = await ConnectAsync(uri);
if (result.IsFaulted)
{
// Cannot access result.Exception because it's internal
}
_ = result.IfFail(ex =>
{
_logger.LogError(ex, "Error while connecting to the endpoint");
throw ex;
});
...
</code></pre>
<pre class="lang-cs prettyprint-override"><code>private async Task<Result<Unit>> ConnectAsync(Uri uri)
{
if (_ws is not null)
{
return new Result<Unit>(new InvalidOperationException("The websocket client is already connected"));
}
var ws = Options.ClientFactory();
try
{
using var connectTimeout = new CancellationTokenSource(Options.Timeout);
await ws.ConnectAsync(uri, connectTimeout.Token).ConfigureAwait(false);
}
catch
{
ws.Dispose();
return new Result<Unit>(new InvalidOperationException("Failed to connect to the endpoint"));
}
await _connectedEvent.InvokeAsync(new ConnectedEventArgs(uri));
_ws = ws;
IsRunning = true;
return Unit.Default;
}
</code></pre>
| [
{
"answer_id": 74178877,
"author": "Yayati Sule",
"author_id": 5742662,
"author_profile": "https://Stackoverflow.com/users/5742662",
"pm_score": 0,
"selected": false,
"text": "withColumn(cnameNew, udf_unescape(columnWithHtml))"
},
{
"answer_id": 74180992,
"author": "Aaron Rub... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178685",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12090115/"
] |
74,178,701 | <p>I have a data frame in which I want to filter out whole groups if the top row of that group does not contain a particular condition in one column.</p>
<p>An example using the following dataset:</p>
<p><code>df <- data.frame(team=c('A', 'A', 'A', 'A', 'B', 'B', 'B', 'C', 'D', 'D', 'D', 'E', 'E'), gameplayed=c('Yes', 'No', 'Yes', 'Yes', 'No', 'Yes', 'No', 'Yes', 'Yes', 'No', 'Yes', 'No', 'Yes'))</code></p>
<p>I want to group these by 'team' first. Then, I want to remove the entire group if the first row contains a 'No' in the 'gameplayed' column.</p>
<p>This would be the desired output:</p>
<pre><code>df2 <- data.frame(team=c('A', 'A', 'A', 'A', 'C', 'D', 'D', 'D'), gameplayed=c('Yes', 'No', 'Yes', 'Yes', 'Yes', 'Yes', 'No', 'Yes'))
</code></pre>
<p>I've played around with various options, such as the following, but can't get it to work for me:</p>
<pre><code>> df %>% group_by(team) %>% + filter("Yes" == first(gameplayed))
</code></pre>
| [
{
"answer_id": 74178875,
"author": "Elias",
"author_id": 11801269,
"author_profile": "https://Stackoverflow.com/users/11801269",
"pm_score": 0,
"selected": false,
"text": "gameplayed"
},
{
"answer_id": 74180071,
"author": "GKi",
"author_id": 10488504,
"author_profile"... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20318892/"
] |
74,178,771 | <p>ord() is used to get the ascii value of the character we insert.
like <em><strong>ord("A") => 65</strong></em>
does anyone know what ord stands for? like ordinal or something else?</p>
| [
{
"answer_id": 74178875,
"author": "Elias",
"author_id": 11801269,
"author_profile": "https://Stackoverflow.com/users/11801269",
"pm_score": 0,
"selected": false,
"text": "gameplayed"
},
{
"answer_id": 74180071,
"author": "GKi",
"author_id": 10488504,
"author_profile"... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178771",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20320292/"
] |
74,178,800 | <h2>Hello,</h2>
<p>I´m creating a roslyn analyzer to check the usage of an attribute from my framework code.<br />
Example:</p>
<p><strong>Framework.csproj</strong></p>
<pre class="lang-cs prettyprint-override"><code>public class ModuleAttribute : Attribute { }
</code></pre>
<p><strong>Framework.Analyzer.csproj</strong></p>
<pre class="lang-cs prettyprint-override"><code>[DiagnosticAnalyzer(LanguageNames.CSharp)]
public class IsModuleAPublicClassAnalyzer : DiagnosticAnalyzer
{ ... }
</code></pre>
<p><strong>Framework.Analyzer.Test.csproj</strong></p>
<pre class="lang-cs prettyprint-override"><code>[Fact]
public async Task MyTestMethod()
{
string test = @"
using Framework;
namespace MyNamespace;
[Module]
public class MyConcreteModule
{
}
";
DiagnosticResult expected = VerifyCs
.Diagnostic(AsyncPropertySetterAnalyzer.DiagnosticId)
.WithLocation(line: 6, column: 0);
await new CSharpAnalyzerTest<IsModuleAPublicClassAnalyzer, XUnitVerifier>
{
TestState =
{
Sources = { test },
ExpectedDiagnostics = { expected }
}
}
.RunAsync();
}
</code></pre>
<p>How can I add a reference to <code>Framework.dll</code> in the test codesnippet?
All projects are in the same solution.</p>
<p>Thank you for your help! </p>
<h2>Update 1</h2>
<p>I noticed that it is possible to add additional <code>MetadataReference</code>s like this:
<strong>Framework.Analyzer.Test.csproj</strong></p>
<pre class="lang-cs prettyprint-override"><code>[Fact]
public async Task MyTestMethod()
{
string test = @"
using Framework;
namespace MyNamespace;
[Module]
public class MyConcreteModule
{
}
";
DiagnosticResult expected = VerifyCs
.Diagnostic(AsyncPropertySetterAnalyzer.DiagnosticId)
.WithLocation(line: 6, column: 0);
await new CSharpAnalyzerTest<IsModuleAPublicClassAnalyzer, XUnitVerifier>
{
TestState =
{
Sources = { test },
ExpectedDiagnostics = { expected },
AdditionalReferences =
{
MetadataReference.CreateFromFile(typeof(ModuleAttribute).Assembly.Location)
}
}
}
.RunAsync();
}
</code></pre>
<p>Now I get that error:</p>
<pre><code>error CS1705: Assembly 'Framework' with identity 'Framework, Version=1.0.0.0, Culture=neutral, PublicKeyToken=29fe1ef4929b04aa' uses 'System.Runtime, Version=7.0.0.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a' which has a higher version than referenced assembly 'System.Runtime' with identity 'System.Runtime, Version=4.2.2.0, Culture=neutral, PublicKeyToken=b03f5f7f11d50a3a'
</code></pre>
<p><code>Framework.csproj</code> and <code>Framework.Analyzer.Test.cspoj</code> have
target framework <code>net7.0</code><br />
<code>Framework.Analyzer.csproj</code> is <code>netstandard2.0</code></p>
| [
{
"answer_id": 74210988,
"author": "m0sa",
"author_id": 155005,
"author_profile": "https://Stackoverflow.com/users/155005",
"pm_score": 0,
"selected": false,
"text": "public override void Initialize(AnalysisContext ac)\n{\n ac.RegisterCompilationStartAction(start=> {\n // Avoid calli... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178800",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8848515/"
] |
74,178,812 | <p>I am building a <strong>net6.0</strong> application where we have to interact with an external device that communicates via <strong>RS232</strong> serial port.</p>
<p>The external device utilizes a protocol in order to communicate with the application, where we know beforehand the size and some parts (<strong>header-like</strong>) of the message packet and is based on the <strong>client-server architecture</strong>.</p>
<p>In my attempt to implement the solution, I used <strong>polling</strong> in an infinite while loop on the serial which was working fine, although it would take quite a few time to synchronize (approx <em>30 seconds</em>).</p>
<p>I tried to workaround that solution and go to a more "<strong>event driven approach</strong>" based on <a href="https://learn.microsoft.com/en-us/dotnet/csharp/programming-guide/events/" rel="nofollow noreferrer">events</a> and trying to read data via the <strong>DataReceived</strong> <a href="https://learn.microsoft.com/en-us/dotnet/api/system.io.ports.serialport.datareceived?view=dotnet-plat-ext-6.0" rel="nofollow noreferrer">event</a>.</p>
<p>While it seemed that I was getting data back, the actual contents of the buffer were significantly different than the ones expected, much bigger in size (expecting approx 10-15 bytes maximum, got around 140 bytes).</p>
<p>I read the remarks on the second link provided and there seems to be some ambiguous results:</p>
<ol>
<li>The operating system decides when to raise an event</li>
<li>An event will not be raised upon each byte arrival</li>
</ol>
<p>My questions are:</p>
<ol>
<li><p>When does the <strong>DataReceived</strong> event triggered? Would there be the case where the OS is <strong>buffering</strong> the data received and sends them as a batch? For example, one "request" from RS232 would be 12 bytes and the next one 14 bytes etc and thus when I am trying to access the data from the buffer there is a much bigger amount of bytes?</p>
</li>
<li><p>Is there a way to configure the application or the OS (not sure how portable that solution would be) so that when the RS232 device sends any kind of payload (for example either 12 bytes or 14 bytes etc), this would explicitly trigger an event?</p>
</li>
</ol>
<p>Thank you very much for your time!</p>
| [
{
"answer_id": 74210988,
"author": "m0sa",
"author_id": 155005,
"author_profile": "https://Stackoverflow.com/users/155005",
"pm_score": 0,
"selected": false,
"text": "public override void Initialize(AnalysisContext ac)\n{\n ac.RegisterCompilationStartAction(start=> {\n // Avoid calli... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,178,813 | <p>I have an if statement which should be executet to 80-%.</p>
<p>Easy example:</p>
<pre><code>x = True # 80% of the time
y = False # 20% of the time
z = # Either x or y
i = 0
while i < 10:
if z == True:
print(True)
else:
print(False)
i = i+1
</code></pre>
| [
{
"answer_id": 74210988,
"author": "m0sa",
"author_id": 155005,
"author_profile": "https://Stackoverflow.com/users/155005",
"pm_score": 0,
"selected": false,
"text": "public override void Initialize(AnalysisContext ac)\n{\n ac.RegisterCompilationStartAction(start=> {\n // Avoid calli... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20291779/"
] |
74,178,819 | <p>Currently, we are setting the value of _id when saving documents in the index. However, by doing that, we avoid Elasticsearch from computing the _id on its own, and therefore, forcing documents to be stored in a particular shard. In effect, there is a possibility where some shards could potentially be disproportionally larger than others, since Elasticsearch places the documents on the corresponding shard based on the _id of the document.</p>
<p>Is there a way to balance the shards while retaining the setting of _id of the document?</p>
| [
{
"answer_id": 74210988,
"author": "m0sa",
"author_id": 155005,
"author_profile": "https://Stackoverflow.com/users/155005",
"pm_score": 0,
"selected": false,
"text": "public override void Initialize(AnalysisContext ac)\n{\n ac.RegisterCompilationStartAction(start=> {\n // Avoid calli... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20204076/"
] |
74,178,898 | <p>I have this model in <code>peewee</code>:</p>
<pre><code>class User(Model):
username = CharField()
password = CharField()
class Meta:
database = db
</code></pre>
<p>I change password and save the model like this:</p>
<pre><code>u = User.get()
u.password = 'newpassword'
u.save()
</code></pre>
<p>It update both username and password but i want to update password only.</p>
| [
{
"answer_id": 74210988,
"author": "m0sa",
"author_id": 155005,
"author_profile": "https://Stackoverflow.com/users/155005",
"pm_score": 0,
"selected": false,
"text": "public override void Initialize(AnalysisContext ac)\n{\n ac.RegisterCompilationStartAction(start=> {\n // Avoid calli... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178898",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20320341/"
] |
74,178,906 | <p>I have a file (<strong>file.xvg</strong>), of which I plot the result using matplotlib and numpy (version Python 3.9.12).
here my script:</p>
<pre><code>import matplotlib.pyplot as plt
import numpy
import numpy as np
from scipy import signal
x, y = numpy.loadtxt("file.xvg", unpack=True)
fig = plt.figure(figsize=(13,8))
ax = fig.add_subplot(111)
ax.plot(x, y, color="k", linestyle='solid', linewidth=0.8)
ax.set_xlabel("Times (ps)", fontweight='bold', fontsize = 18, labelpad=3)
ax.set_ylabel("Pressures (bar)", fontweight='bold', fontsize = 18, labelpad=3)
plt.show()
</code></pre>
<p>and the file.xvg</p>
<blockquote>
<pre><code> 0.0000000 0.0287198
0.0100000 0.0655187
0.0200000 0.0665948
0.0300000 0.0676697
0.0400000 0.0797021
0.0500000 0.0883750
0.0600000 0.0824649
0.0700000 0.0726798
0.0800000 0.0749663
0.0900000 0.0746549
0.1000000 0.0767466
0.1100000 0.1051620
0.1200000 0.0846607
0.1300000 0.0746683
0.1400000 0.0744862
0.1500000 0.0913541
0.1600000 0.0844304
0.1700000 0.0750595
0.1800000 0.0783450
0.1900000 0.0869718
0.2000000 0.0969575
0.2100000 0.0924280
0.2200000 0.0759971
0.2300000 0.0704025
.
.
.
</code></pre>
</blockquote>
<p>I wanted to plot the running average as in the figure below:
<a href="https://i.stack.imgur.com/nmqia.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nmqia.png" alt="enter image description here" /></a></p>
<p>The average value of the plot figure is <strong>7.5 ± 160.5 bar</strong></p>
| [
{
"answer_id": 74210988,
"author": "m0sa",
"author_id": 155005,
"author_profile": "https://Stackoverflow.com/users/155005",
"pm_score": 0,
"selected": false,
"text": "public override void Initialize(AnalysisContext ac)\n{\n ac.RegisterCompilationStartAction(start=> {\n // Avoid calli... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178906",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12146102/"
] |
74,178,928 | <p>can I please for a help in this exercise? I exhausted my knowledge, after many hours.
I need to write a static method in Java that takes as a parameter list of numbers and returns int value. The value is a result of adding and multiplying alternate numbers in a list. As a addition I CANNOT use the modulo % to take odd or even index from loop.<br />
How can I break the J inner loop, it is not incrementing when I use break, so j index is always 2. I am complete beginner.</p>
<p>As a example: [1, 2, 3, 4, 5] should be as a result: (1 + 2 * 3 + 4 * 5) = 27</p>
<pre><code>import java.util.Collections;
import java.util.LinkedList;
import java.util.List;
public class Exercise {
static int addAndMultiply(List<Integer> list) {
boolean flag = true;
int sum = 0;
for (int i = 0; i < list.size(); i++) {
for (int j = 1; j < list.size(); j++) {
if(flag) {
sum+= list.get(i) + list.get(j);
flag = false;
} else {
sum += list.get(i) * list.get(j);
flag = true;
}
} break;
}
return sum;
}
public static void main(String[] args) {
List<Integer> numbers = new LinkedList<>();
Collections.addAll(numbers, 1, 2, 3, 4, 5);
System.out.println(Exercise.addAndMultiply(numbers));
}
}
</code></pre>
| [
{
"answer_id": 74210988,
"author": "m0sa",
"author_id": 155005,
"author_profile": "https://Stackoverflow.com/users/155005",
"pm_score": 0,
"selected": false,
"text": "public override void Initialize(AnalysisContext ac)\n{\n ac.RegisterCompilationStartAction(start=> {\n // Avoid calli... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178928",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19698865/"
] |
74,178,933 | <p>I need to execute the delete IP command ("sudo ufw delete 3") but after sending Ssh.net's RunCommand or CreateCommand & Execute, there will be no response and let me execute the next step, so I can't execute the command Y to delete, if I use putty it is It can be done by executing y after executing sudo ufw delete 3.
By the way, is it possible to delete the specified IP.</p>
<pre><code>string _host = "xxx.xxx.xxx.xxx";
string _username = "root";
string _password = "xxxxx";
int _port = 22;
SshClient sshClient = new SshClient(_host,_port,_username,_password);
if (!sshClient.IsConnected)
{
sshClient.Connect();
}
SshCommand sshCmd = sshClient.RunCommand($"sudo ufw delete 3"); <--- no response
sshCmd = sshClient.RunCommand($"y");
sshClient.Disconnect();
sshClient.Dispose()
</code></pre>
<p>I have test RunCommand on</p>
<pre><code>SshCommand sshCmd = sshClient.RunCommand($"sudo ufw allow from {_IP} to any port 22");
</code></pre>
<p>This can work.But it doesnt need press "Y"</p>
| [
{
"answer_id": 74179358,
"author": "Heinzi",
"author_id": 87698,
"author_profile": "https://Stackoverflow.com/users/87698",
"pm_score": 2,
"selected": true,
"text": "ufw"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178933",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14141819/"
] |
74,178,934 | <p>I need make a request to a server of an open API. The rule of the open API asked json parameter must make keys as a special order(not the A-Z order nor Z-A order).</p>
<pre class="lang-swift prettyprint-override"><code>struct Req : Encodable {
let SourceText: String
let Target: String
let Source: String
let ProjectId: Int = 0
}
</code></pre>
<p>What I want is:</p>
<pre class="lang-json prettyprint-override"><code>{"SourceText":"你好","Source":"zh","Target":"en","ProjectId":0}
</code></pre>
<p>But the encoded json is:</p>
<pre class="lang-json prettyprint-override"><code>{"ProjectId":0,"Source":"zh","SourceText":"你好","Target":"en"}
</code></pre>
| [
{
"answer_id": 74179358,
"author": "Heinzi",
"author_id": 87698,
"author_profile": "https://Stackoverflow.com/users/87698",
"pm_score": 2,
"selected": true,
"text": "ufw"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178934",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1882505/"
] |
74,178,950 | <p>i am trying to use nuxt-image on NUXT3, but it seems it doesn't work with the generate command. Images work during dev, but get a 404 when using nuxt generate.</p>
<p>in my nuxt config i have</p>
<pre><code>modules: ["@nuxt/image-edge"],
image: {
dir: "assets/images",
},
</code></pre>
<p>then in my files i have</p>
<pre><code><NuxtImg
format="webp"
class="mobile"
src="/website/home/above-fold-illustration-mobile.png"
alt="illustration"
aria-hidden="true"
/>
</code></pre>
<p>So i am wondering if anyone else had a problem or if this is just a compatibility issue with nuxt-image and nuxt3 generate</p>
| [
{
"answer_id": 74179033,
"author": "kissu",
"author_id": 8816585,
"author_profile": "https://Stackoverflow.com/users/8816585",
"pm_score": 0,
"selected": false,
"text": "dir"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178950",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20136507/"
] |
74,178,989 | <p>Plotly Dash uses the index_string value to customize the Dash's HTML Index Template as explained <a href="https://dash.plotly.com/external-resources" rel="nofollow noreferrer">here</a>.</p>
<p>To integrate Dash with Flask, one can pass Flask app as Dash server, and get back the Flask app with the Dash app integrated in it, also taking advantage of Jinja. This approach is nicely explained in several tutorial, such as <a href="https://hackersandslackers.com/plotly-dash-with-flask/" rel="nofollow noreferrer">this one</a>.</p>
<p>If you want to add a Jinja template, you can pass the HTML template to the code initializing Dash. The index string shall contain the {%" + filed + "%} required by Dash, but rendering the template will escape that code.</p>
<p>A trick is nicely explained in an answer <a href="https://stackoverflow.com/questions/50827099/passing-dash-html-components-into-a-jinja-template">here</a>, where the HTML is enriched with comments, which are ignored by Jinja during the rendering, and then replaced in the code with the fields for Dash before setting the index_string upon Dash app initialization.
This effectively works, the dash app is well integrated in the Flask server, and the Jinja template is inegrated and rendered.</p>
<p>Here some code to frame this a bit more concretely:</p>
<pre><code>def init_dashboard(server,url):
"""Create a Plotly Dash dashboard."""
dash_app = dash.Dash(
server=server,
routes_pathname_prefix=url,
external_stylesheets=[
"/static/dist/css/styles.css",
"https://fonts.googleapis.com/css?family=Lato",
],
)
# Both app context and a request context to use url_for() in the Jinja2 templates are needed
with server.app_context(), server.test_request_context():
#items = Item.query.all()
html_body = render_template_string(html_layout)
comments_to_replace = ("metas", "title", "favicon", "css", "app_entry", "config", "scripts", "renderer")
for comment in comments_to_replace:
html_body = html_body.replace(f"<!-- {comment} -->", "{%" + comment + "%}")
dash_app.index_string = html_body
# Load DataFrame
df = create_dataframe()
# Create Layout
dash_app.layout = my_layout
init_callbacks(dash_app)
return dash_app.server
</code></pre>
<p>With the layout in HTML:</p>
<pre><code> html_layout = """
{% extends "base.html" %}
{% block title %}
Calculator
{% endblock %}
{% block content %}
<body class="dash-template">
<header>
<div class="nav-wrapper">
<!-- <a href="/">
<img src="/static/img/logo.png" class="logo" />
<h1>Plotly Dash Flask Tutorial</h1>
</a> -->
<nav>
</nav>
</div>
</header>
<!-- app_entry -->
<footer>
<!-- config -->
<!-- scripts -->
<!-- renderer -->
</footer>
</body>
{% endblock %}
"""
</code></pre>
<p>Now, the problem I have is that I would like to <em>update</em> the index_string in the Dash_app during the execution, for example during a callback, and not only on initialization.
Upon debug, I can get the dash_app embedded in the Flask app with the dash.get_app() function. There, I can find my index_string nicely set. But I could not find a way to <em>set</em> back that index_string value, effectively updating the dash template. Do you have any idea on how I could achieve this feature?</p>
| [
{
"answer_id": 74196384,
"author": "C M",
"author_id": 20320174,
"author_profile": "https://Stackoverflow.com/users/20320174",
"pm_score": 1,
"selected": false,
"text": "index_page"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20320174/"
] |
74,178,994 | <p>I'm trying to return an nested list, however running into some conversion error.
Below is small piece of code for reproduction of error.</p>
<pre><code>from numba import njit, prange
@njit("ListType(ListType(ListType(int32)))(int32, int32)", fastmath = True, parallel = True, cache = True)
def test(x, y):
a = []
for i in prange(10):
b = []
for j in range(4):
c = []
for k in range(5):
c.append(k)
b.append(c)
a.append(b)
return a
</code></pre>
<p>Error
<a href="https://i.stack.imgur.com/QLZdT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/QLZdT.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74196384,
"author": "C M",
"author_id": 20320174,
"author_profile": "https://Stackoverflow.com/users/20320174",
"pm_score": 1,
"selected": false,
"text": "index_page"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74178994",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8427065/"
] |
74,179,028 | <p>I tried to get data from api like this, but I couldn't display it
I need to get data from request api and show it in widget, api gives me data of one user, i want to show my data like this :</p>
<pre><code> getUser() async {
var response = await http.get(Uri.parse(url));
var jsonData = jsonDecode(response.body);
return jsonData['data'].map<User>(User.fromJson).toString();
}
Container(
decoration: BoxDecoration(
color: Colors.white,
borderRadius: BorderRadius.all(Radius.circular(12))),
padding: EdgeInsets.only(left: 10, right: 10),
height: 120,
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceBetween,
children: [
CircleAvatar(
radius: 28,
backgroundImage: NetworkImage('API AVATAR'),
),
Text(
'TEXT FROM MY API',
style: TextStyle(fontSize: 17, color: Colors.black),
),
Icon(
Icons.arrow_forward_ios,
color: Colors.grey,
),
],
),
), ```
</code></pre>
| [
{
"answer_id": 74196384,
"author": "C M",
"author_id": 20320174,
"author_profile": "https://Stackoverflow.com/users/20320174",
"pm_score": 1,
"selected": false,
"text": "index_page"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20320364/"
] |
74,179,073 | <p>What I want is when I select "AUD" from the dropdown menu my button's("dropbtn") innerHtml changes to "AUD" similarly other way around. I want my button to change its text to the text of the I select from my dropdown menu
Here is the code:
App.js:</p>
<pre><code> import './App.css'
import React, { useState, useEffect, useRef } from "react";
export default function App() {
const [listopen, setListopen] = useState(false)
const Dropdown = () => {
if (listopen) {
setListopen(false)
} else {
setListopen(true)
}
}
return (
<main>
<nav>
<ul>
<div class="dropdown">
<li><button class="dropbtn" onClick={() => Dropdown()} >USD
</button></li>
<div class="dropdown-content" id="myDropdown" style={{ display: listopen === false ? 'none' : 'block' }}>
<a href="/">AUD($)</a>
<a href="/">USD($)</a>
<a href="/">PKR($)</a>
</div>
</div>
</ul>
</nav>
</main>
)
}
</code></pre>
<p>App.css:</p>
<pre><code>.dropdown-content {
display: none;
position: absolute;
background-color: #1a2456;
box-shadow: 0px 8px 16px 0px rgba(0,0,0,0.2);
z-index: 100;
width: 9.5vw;
}
.dropdown-content a {
float: none;
color: #fead94;
padding: 12px 16px;
text-decoration: none;
display: block;
text-align: left;
z-index: 100;
}
</code></pre>
| [
{
"answer_id": 74179153,
"author": "Muhammad",
"author_id": 19174990,
"author_profile": "https://Stackoverflow.com/users/19174990",
"pm_score": 2,
"selected": true,
"text": "export default function App() {\n const [listopen, setListopen] = useState(false)\n const [btnText, setBtnText] ... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179073",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20003281/"
] |
74,179,097 | <p>I have a dataframe:</p>
<pre><code>df = c1 c2 c3 code
1. 2. 3. 200
1. 5. 7. 220
1. 2. 3. 200
2. 4. 1. 340
6. 1. 1. 370
6. 1. 5. 270
9. 8. 2. 300
1. 6. 9. 700
9. 2. 1. 200
8. 1. 2 400
1. 2 1. 200
2. 5. 3 900
8. 0. 4. 300
9. 1. 2. 620
</code></pre>
<p>I want to take only the rows that are between any row with 300 code to its previous 200 code.
So here I will have</p>
<pre><code>df. c1 c2 c3 code batch_num
1. 2. 3. 200. 0
2. 4. 1. 340. 0
6. 1. 1. 370. 0
6. 1. 5. 270. 0
9. 8. 2. 300. 0
1. 2 1. 200. 1
2. 5. 3 900. 1
8. 0. 4. 300. 1
</code></pre>
<p>So basically what I need is to:
find each 300, and for each - find the nearest previous 200, and take the rows between them.
It is guaranteed that there will always be at least one 200 before each 300.
Than, add a columns that indicate the proper batch.
How can I do it efficiently in pandas?</p>
| [
{
"answer_id": 74179153,
"author": "Muhammad",
"author_id": 19174990,
"author_profile": "https://Stackoverflow.com/users/19174990",
"pm_score": 2,
"selected": true,
"text": "export default function App() {\n const [listopen, setListopen] = useState(false)\n const [btnText, setBtnText] ... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179097",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6057371/"
] |
74,179,136 | <p>I'm making a budget tracker app. And I'm implementing the functions display and add transactions for the app. However, I'm struggling to find a way to dynamically set the image URL (the icon) based on the transaction category type.</p>
<p>The app is written in React Native.</p>
<p>For example, I have a list of transactions as below:</p>
<pre><code>[
{
id: 1,
type: 'Expense',
category: 'Food',
description: 'Burger',
amount: 100,
date: '2020-10-10',
createdAt: '2021-01-01',
},
{
id: 2,
type: 'Expense',
category: 'Entertainment',
description: 'Movie',
amount: 200,
date: '2020-10-10',
createdAt: '2021-10-02',
},
{
id: 3,
type: 'Income',
category: 'Salary',
description: 'Salary',
amount: 1000,
date: '2020-10-10',
createdAt: '2021-10-03',
},
{
id: 4,
type: 'Expense',
category: 'Food',
description: 'Burger',
amount: 100,
date: '2020-10-10',
createdAt: '2021-01-01',
},
]
</code></pre>
<p>Then I want to display it in a list, and each list item contains the icon representing the category, like this image:
<a href="https://i.stack.imgur.com/OHiSI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OHiSI.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74179153,
"author": "Muhammad",
"author_id": 19174990,
"author_profile": "https://Stackoverflow.com/users/19174990",
"pm_score": 2,
"selected": true,
"text": "export default function App() {\n const [listopen, setListopen] = useState(false)\n const [btnText, setBtnText] ... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179136",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14359130/"
] |
74,179,138 | <p>I have this code that adds a custom field to my products in woocommerce:</p>
<pre><code>add_action( 'woocommerce_single_product_summary', 'shoptimizer_custom_author_field', 3 );
function shoptimizer_custom_author_field() { ?>
<?php if(get_field('author')) { ?>
<div class="cg-author"><?php the_field('author'); ?></div>
<?php }
}
</code></pre>
<p>Now I would want to add a condition to the if-statement that says "if field is not empty, hide product title".</p>
<p>The class for the product page product title seems to be "product_title".</p>
<p>Will be fascinating how this will look like once It's added into this piece of code above. I think it's not a big deal, but my comprehension ends with HTML and CSS sadly.</p>
| [
{
"answer_id": 74179153,
"author": "Muhammad",
"author_id": 19174990,
"author_profile": "https://Stackoverflow.com/users/19174990",
"pm_score": 2,
"selected": true,
"text": "export default function App() {\n const [listopen, setListopen] = useState(false)\n const [btnText, setBtnText] ... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179138",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19331418/"
] |
74,179,149 | <p>how can I set animation time considering the object rotation. Gameobject have limited rotation on Z axis from 0 to 32,8. And animation have 0,25 sec.</p>
<p>So I have to do something like this: when gameobject is on 0% Z = 0; animation time = 0 too.
When gameobject is on 50% Z = 16,4; animation time = 0,125 so 50% too.</p>
<p>This is what I have, but it does not work:</p>
<pre><code> if(this.gameObject.transform.rotation.z <= 0)
{
animator.SetTrigger("Start");
animator.speed = 1;
animator.SetFloat("Time", 0);
}
else if(this.gameObject.transform.rotation.z > 0 && this.gameObject.transform.rotation.z <= 8.2f)
{
animator.SetFloat("Time", 0.0625f);
}
else if (this.gameObject.transform.rotation.z > 8.2f && this.gameObject.transform.rotation.z <= 16.4f)
{
animator.SetFloat("Time", 0.125f);
}
else if (this.gameObject.transform.rotation.z > 16.4f && this.gameObject.transform.rotation.z <= 24.6f)
{
animator.SetFloat("Time", 0.1875f);
}
else if (this.gameObject.transform.rotation.z > 24.6f && this.gameObject.transform.rotation.z <= 32.8f)
{
animator.SetFloat("Time", 0.25f);
}
</code></pre>
<p>Any idea how to solve it?</p>
| [
{
"answer_id": 74180411,
"author": "derHugo",
"author_id": 7111561,
"author_profile": "https://Stackoverflow.com/users/7111561",
"pm_score": 2,
"selected": true,
"text": "transform.rotation.z"
},
{
"answer_id": 74181058,
"author": "V1lko",
"author_id": 17025894,
"auth... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17025894/"
] |
74,179,152 | <p>In javascript I have a function, where I have too many conditions. I wonder what will be the smartest solution to rework this function.</p>
<p>Currently I have it like this. Of course there are more than 20 conditions, just for example I have 3 here:</p>
<pre><code>function checkURL(pageName) (
let urlPart = '';
if (pageName == 'something') { urlPart = "main/contact";}
if (pageName == 'anythingelse') { urlPart = "administration/user";}
if (pageName == 'another page') { urlPart = "administration/country";}
return urlPart;
)
</code></pre>
<p>I was thinking to rework it with <code>switch/case</code> or put the <code>pageName</code> variable into array and <code>urlPart</code> as well, and then just find the <code>pageName</code> position in array and compare with <code>urlPart</code> position, e.g.:</p>
<pre><code> function checkURL(pageName) (
const pg = ["something", "anythingelse", "another page"];
const url = ["main/contact", "administration/user", "administration/country"];
let index1 = pg.indexOf(pageName);
if (index1>=0) {return url[index1];} else {return ''; }
)
</code></pre>
<p>The problem might be with matching the same position of both elements in array, as people will add more and more items to the array and they can do a mistake where the position in first array will not match the correct position in second array when we will have 50 items maybe.</p>
| [
{
"answer_id": 74179244,
"author": "Michael Beeson",
"author_id": 524324,
"author_profile": "https://Stackoverflow.com/users/524324",
"pm_score": 3,
"selected": true,
"text": "const urls = {\n \"something\": \"main/contact\",\n \"anythingelse\": \"administration/user\",\n \"another pa... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1345089/"
] |
74,179,154 | <p>My code:</p>
<pre><code>def replaces(_str:str,a=list,b=list):
output = ''
for num,i in enumerate(_str):
output += i.replace(a[num],b[num])
return output
</code></pre>
<p>but it outputs this:</p>
<pre><code>>>> print(replaces('12345',['1','2','3'],['one','two','three']))
Traceback (most recent call last):
File "g:\+ Project\beat_machine\test.py", line 7, in <module>
text = replaces('12345',['1','2','3'],['one','two','three'])
File "g:\+ Project\beat_machine\test.py", line 4, in replaces
output += i.replace(a[num],b[num])
IndexError: list index out of range
</code></pre>
<p>How to fix this?</p>
| [
{
"answer_id": 74179328,
"author": "Dmitriy Neledva",
"author_id": 16786350,
"author_profile": "https://Stackoverflow.com/users/16786350",
"pm_score": 0,
"selected": false,
"text": "def replaces(s:str,a=list,b=list)->str:\n return \" \".join([dict(zip(a,b)).get(i,i) for i in s.split()... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179154",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20248745/"
] |
74,179,155 | <p>I have these datasets: <code>df</code> as the main dataframe (but let's imagine all of them as very big datasets).</p>
<pre><code>df = data.frame(x = seq(1,20,2),
y = c('a','a','b','c','a','a','b','c','a','a'),
z = c('d','e','e','d','f','e','e','d','e','f') )
stage1 = data.frame(xx = c(2,3,4,5,7,8,9) )
stage2 = data.frame(xx = c(3,5,7,8,9) )
stage3 = data.frame(xx = c(2,3,6,8) )
stage4 = data.frame(xx = c(1,3,6) )
</code></pre>
<p>And then creating count tables as follows:</p>
<pre><code>library(dplyr)
library(purrr)
map(lst(stage1 , stage2 ,stage3 ,stage4 ),
~ inner_join(df, .x, by = c("x" = "xx")) %>%
count(y, name = 'Count'))
</code></pre>
<p>I wish to apply a chi squared test to study if the difference between each two consecutive tables is significant or not.</p>
| [
{
"answer_id": 74179328,
"author": "Dmitriy Neledva",
"author_id": 16786350,
"author_profile": "https://Stackoverflow.com/users/16786350",
"pm_score": 0,
"selected": false,
"text": "def replaces(s:str,a=list,b=list)->str:\n return \" \".join([dict(zip(a,b)).get(i,i) for i in s.split()... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19720935/"
] |
74,179,168 | <p>I have this part of my site where i'm using javascript to show and hide a div when clicked, so far so good, my problem is i want the color of the button to change when clicked, so that the color in ".steg1" changes to #CCA200 when i click ".steg2".</p>
<p>I have tried focus, but I have more places on the same page where I need to use this so I'm looking for a different solution. I've tried some jquery with no luck, is this doable in javascript?</p>
<p>here is the code:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><button class="steg1" onclick="myFunctionq();">
1 - TECKNA MOBILABONNEMANG
</button>
<style>
.steg1 {
font-family: 'mark-heavy';
font-size: 16px;
background-color: transparent;
border: none;
border-bottom: solid 5px;
color: #223137;
padding: 0 40px;
}
</style>
<script>
function myFunctionq() {
var x =
document.getElementById("tecknamobil");
var y =
document.getElementById("tecknael");
var z =
document.getElementById("rabatt");
if (x.style.display === "block") {
x.style.display = "none";
} else {
x.style.display = "block";
}
y.style.display = "none";
z.style.display = "none";
}
</script>
<button class="steg2" onclick="myFunctionp()">
2 - TECKNA ELAVTAL
</button>
<style>
.steg2 {
font-family: 'mark-heavy';
font-size: 16px;
background-color: transparent;
border: none;
border-bottom: solid 5px;
padding: 0 60px;
color: #CCA200;
}
</style>
<script>
function myFunctionp() {
var x =
document.getElementById("tecknael");
var y =
document.getElementById("tecknamobil");
var z =
document.getElementById("rabatt");
if (x.style.display === "block") {
x.style.display = "none";
} else {
x.style.display = "block";
}
y.style.display = "none";
z.style.display = "none";
}
</script>
<button class="steg3" onclick="myFunctionr(); buttonColorb()">
3 - FÅ RABATT PÅ ELEN
</button>
<style>
.steg3 {
font-family: 'mark-heavy';
font-size: 16px;
background-color: transparent;
border: none;
border-bottom: solid 5px;
padding: 0 50px;
color: #CCA200;
}
</style>
<script>
function myFunctionr() {
var x =
document.getElementById("rabatt");
var y =
document.getElementById("tecknael");
var z =
document.getElementById("tecknamobil");
if (x.style.display === "block") {
x.style.display = "none";
} else {
x.style.display = "block";
}
y.style.display = "none";
z.style.display = "none";
}
</script></code></pre>
</div>
</div>
</p>
<p>Ok, i've gotten it to work to almost perfection, I only need to when step1 is pressed after the other steps, it stays black, how do i put so that "if this is .focused then it should be .colored? here is the updated code.</p>
<pre><code><button id="step1button" class="step1" onclick="step1Click();">
1 - TECKNA MOBILABONNEMANG
</button>
<style>
#step1button {
font-family:'mark-heavy';
font-size:16px;
background-color:transparent;
border:none;
border-bottom:solid 5px;
color:#223137;
padding: 0 40px;
}
</style>
<script>
function step1Click() {
var x =
document.getElementById("tecknamobil");
var y =
document.getElementById("tecknael");
var z =
document.getElementById("rabatt");
if (x.style.display === "block") {
x.style.display = "none";
} else {
x.style.display = "block";
}
y.style.display = "none";
z.style.display = "none";
document.getElementById('step1button').classList.add('focused');
document.getElementById('step3button').classList.remove('focused');
document.getElementById('step2button').classList.remove('focused');
}
</script>
<button id="step2button" class="step2" onclick="step2Click()">
2 - TECKNA ELAVTAL
</button>
<style>
#step2button {
font-family:'mark-heavy';
font-size:16px;
background-color:transparent;
border:none;
border-bottom: solid 5px;
padding:0 60px;
color:#CCA200;
}
</style>
<script>
function step2Click() {
var x =
document.getElementById("tecknael");
var y =
document.getElementById("tecknamobil");
var z =
document.getElementById("rabatt");
if (x.style.display === "block") {
x.style.display = "none";
} else {
x.style.display = "block";
}
y.style.display = "none";
z.style.display = "none";
document.getElementById('step1button').classList.add('colored');
document.getElementById('step3button').classList.remove('focused');
document.getElementById('step2button').classList.add('focused');
}
</script>
<button id="step3button" class="step3" onclick="step3Click(); colorchange()">
3 - FÅ RABATT PÅ ELEN
</button>
<style>
#step3button {
font-family:'mark-heavy';
font-size:16px;
background-color:transparent;
border:none;
border-bottom: solid 5px;
padding: 0 50px;
color:#CCA200;
}
.colored {
color:#CCA200 !important;
}
.focused {
color:#223137 !important;
}
</style>
<script>
function step3Click() {
var x =
document.getElementById("rabatt");
var y =
document.getElementById("tecknael");
var z =
document.getElementById("tecknamobil");
if (x.style.display === "block") {
x.style.display = "none";
} else {
x.style.display = "block";
}
y.style.display = "none";
z.style.display = "none";
document.getElementById('step1button').classList.add('colored');
document.getElementById('step3button').classList.add('focused');
document.getElementById('step2button').classList.remove('focused');
}
</script>
</code></pre>
| [
{
"answer_id": 74179328,
"author": "Dmitriy Neledva",
"author_id": 16786350,
"author_profile": "https://Stackoverflow.com/users/16786350",
"pm_score": 0,
"selected": false,
"text": "def replaces(s:str,a=list,b=list)->str:\n return \" \".join([dict(zip(a,b)).get(i,i) for i in s.split()... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20320519/"
] |
74,179,175 | <p>I have created a custom React hook to use MUI Dialog using React Context API. However, I need to return some value from Dialog, like if the OK button has been clicked. But I have some troubles.</p>
<p>Here is code snippet from context provider:</p>
<pre><code>const showAlertDialog = (title: string, text?: string): Promise<boolean> => {
setOpen(true);
setTitle(title);
setText(text);
return new Promise<boolean>((resolve: (value: boolean) => void) => {
setActionCallback(resolve);
});
};
const handleOKClick = () => {
setOpen(false);
actionCallback?.(true);
};
return (
<DialogContext.Provider value={{ showAlertDialog }}>
{children}
<DialogContainer
title={title}
open={open}
text={text}
onOK={handleOKClick}
></DialogContainer>
</DialogContext.Provider>
);
}
export const useMuiDialog = () => {
return useContext(DialogContext);
};
</code></pre>
<p>However when I call the await showAlertDialog form onClick handler, it immediately returns without waiting for promise to resolve/reject:</p>
<pre><code>const handleClick = async () => {
console.log('dialog');
const answer = await showAlertDialog('test', 'test');
console.log(answer);
};
</code></pre>
<p>I am not getting something here, but I don't know what...</p>
<p>The whole example can be found on:</p>
<p><a href="https://stackblitz.com/edit/react-bk1d19?file=demo.tsx" rel="nofollow noreferrer">https://stackblitz.com/edit/react-bk1d19?file=demo.tsx</a></p>
<p>Thank you</p>
| [
{
"answer_id": 74179339,
"author": "Giorgi Moniava",
"author_id": 3963067,
"author_profile": "https://Stackoverflow.com/users/3963067",
"pm_score": 1,
"selected": false,
"text": " setActionCallback(resolve);\n"
},
{
"answer_id": 74179492,
"author": "Elie Bsaibes",
"autho... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1007935/"
] |
74,179,193 | <p>In Flutter I have a SingleChildScrollView with a column as the child. Inside that column is 3 widgets: A ListView.separated widget, a sized box, and a different ListView.separated widget.</p>
<p>The ListView.separated widgets have shrinkWrap set to true and physics set to NeverScrollableScrollPhysics() to allow the SingleChildScrollView to handle scrolling.</p>
<p>My question is, are the two ListView widgets loaded lazily (on demand) or does the SingleChildScrollView and column parent mean they are loaded in full when the page loads?</p>
| [
{
"answer_id": 74179339,
"author": "Giorgi Moniava",
"author_id": 3963067,
"author_profile": "https://Stackoverflow.com/users/3963067",
"pm_score": 1,
"selected": false,
"text": " setActionCallback(resolve);\n"
},
{
"answer_id": 74179492,
"author": "Elie Bsaibes",
"autho... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/892028/"
] |
74,179,218 | <p>This is my line of code:</p>
<pre><code> const { userName }: { userName: string } = useSelector((s: ReduxType) => s.currentUser.info) || '';
</code></pre>
<p>Iam getting this warning " Property 'userName' is missing in type '{}' but required in type '{ userName: string; }"</p>
<p>info is an object which contains following properties</p>
<pre><code> type userInfo = {
id: number;
userName: string;
userEmail: string;
created_date: string;
last_updated: string;
last_login: string;
active: boolean;
fullName: string;
};
</code></pre>
<p>If I use</p>
<pre><code> const { userName }: any = useSelector((s: ReduxType) => s.currentUser.info) || '';
</code></pre>
<p>then warning will disappear but i want to use proper generic type</p>
<p>Thank you in adavnce</p>
| [
{
"answer_id": 74179240,
"author": "Kiran D Patkar",
"author_id": 18362655,
"author_profile": "https://Stackoverflow.com/users/18362655",
"pm_score": 1,
"selected": true,
"text": "const { userName }: { userName?: string } = useSelector((s: ReduxType) => s.currentUser.info) || '';\n"
},... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18362655/"
] |
74,179,222 | <p>I used the "Shopware 6 Toolbox" plugin for creating a custom cms element.</p>
<p>When I add my custom cms-block with my custom cms-element I get the following warnings:</p>
<blockquote>
<p>vue.esm.js?a026:628 [Vue warn]: Unknown custom element: - did
you register the component correctly? For recursive components, make
sure to provide the "name" option.</p>
<p>found in</p>
<p>---> < SwCmsBlockGalleryInfobox >
< SwCmsBlock >
< SwCmsSection >
< SwPage >
< SwCmsDetail >
< SwErrorBoundary>
< SwDesktop>
< SwAdmin>
< Root></p>
</blockquote>
<p>and</p>
<blockquote>
<p>vue.esm.js?a026:628 [Vue warn]: Missing required prop: "element"</p>
<p>found in</p>
<p>---> < SwCmsElComponentInfoBox>
< SwCmsBlockGalleryInfobox>
< SwCmsBlock>
< SwCmsSection>
< SwPage>
< SwCmsDetail>
< SwErrorBoundary>
< SwDesktop>
< SwAdmin>
< Root></p>
</blockquote>
<p>I compared all index.js with those from the <a href="https://developer.shopware.com/docs/guides/plugins/plugins/content/cms/add-cms-element" rel="nofollow noreferrer">tutorial</a> and didn't find any difference. Does anyone knows why I get this warning?</p>
<p>I also get an error:</p>
<blockquote>
<p>An error was captured in current module: TypeError: Cannot set
properties of undefined (setting 'config')
at VueComponent.initElementConfig (sw-cms-element.mixin.js?7948:64:13)
at VueComponent.createdComponent (index.js?7f82:19:18)
at VueComponent.created (index.js?7f82:14:14)
at invokeWithErrorHandling (vue.esm.js?a026:1872:1)
at callHook (vue.esm.js?a026:4244:1)
at Vue._init (vue.esm.js?a026:5031:1)
at new VueComponent (vue.esm.js?a026:5177:1)
at createComponentInstanceForVnode (vue.esm.js?a026:3313:1)
at init (vue.esm.js?a026:3142:1)
at createComponent (vue.esm.js?a026:6033:1)</p>
</blockquote>
<p>I haven't customized the generated cms-element, so there is nothing to configure. Now I'm asking myself why I get this error. Can anybody answer my question?</p>
<hr />
<p>Here's the code</p>
<pre><code>plugins/ProductInfoBox/src/Resources/app/administration/src/main.js
import './module/sw-cms/blocks/commerce/gallery-infobox';
import './module/sw-cms/elements/info-box';
</code></pre>
<pre><code>plugins/ProductInfoBox/src/Resources/app/administration/src/module/sw-cms/elements/
info-box/index.js
import './component';
import './config';
import './preview';
Shopware.Service('cmsService').registerCmsElement({
name: 'info-box',
label: 'sw-cms.elements.info-box.label',
component: 'sw-cms-el-component-info-box',
configComponent: 'sw-cms-el-config-info-box',
previewComponent: 'sw-cms-el-preview-info-box',
defaultConfig: {
content: {
source: 'static',
value: `
<h2>Lorem Ipsum dolor sit amet</h2>
<p>Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat,
sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum.
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consetetur sadipscing elitr,
sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua.
At vero eos et accusam et justo duo dolores et ea rebum.
Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.</p>
`.trim(),
},
verticalAlign: {
source: 'static',
value: null,
},
},
defaultData: {}
});
</code></pre>
<pre><code>plugins/ProductInfoBox/src/Resources/app/administration/src/module/sw-cms/elements/
info-box/component/index.js
import template from './sw-cms-el-component-info-box.html.twig';
import './sw-cms-el-component-info-box.scss';
const {Component, Mixin} = Shopware;
Component.register('sw-cms-el-component-info-box', {
template,
mixins: [
Mixin.getByName('cms-element')
],
computed: {
getText(){
return this.element.config.content.value;
}
},
created() {
this.createdComponent();
},
methods: {
createdComponent() {
this.initElementConfig('info-box');
this.initElementData('info-box');
},
},
});
</code></pre>
<pre><code>plugins/ProductInfoBox/src/Resources/app/administration/src/module/sw-cms/elements/info-box/config/index.js
import template from './sw-cms-el-config-info-box.html.twig';
import './sw-cms-el-config-info-box.scss';
const {Component, Mixin} = Shopware;
Component.register('sw-cms-el-config-info-box', {
template,
inject: ['repositoryFactory'],
mixins: [
Mixin.getByName('cms-element')
],
computed: {
getText(){
return this.element.config.content.value;
}
},
created() {
this.createdComponent();
},
methods: {
createdComponent() {
this.initElementConfig('info-box');
},
},
});
</code></pre>
<pre><code>plugins/ProductInfoBox/src/Resources/app/administration/src/module/sw-cms/elements/
info-box/preview/index.js
import template from './sw-cms-el-preview-info-box.html.twig';
import './sw-cms-el-preview-info-box.scss';
const {Component} = Shopware;
Component.register('sw-cms-el-preview-info-box', {
template
});
</code></pre>
| [
{
"answer_id": 74179240,
"author": "Kiran D Patkar",
"author_id": 18362655,
"author_profile": "https://Stackoverflow.com/users/18362655",
"pm_score": 1,
"selected": true,
"text": "const { userName }: { userName?: string } = useSelector((s: ReduxType) => s.currentUser.info) || '';\n"
},... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179222",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18221536/"
] |
74,179,300 | <p>I am trying to create a small laptop rental system in the Google Sheets which sends email depending on checkbox which is selected (checked).</p>
<p>Two emails which are sent are: 1. Approved and 2. Overdue.</p>
<p>Problem that I have with my attempt is that multiple emails are sent even to the users which already have received the approval email when approved checkbox is selected <a href="https://i.stack.imgur.com/gYqva.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gYqva.png" alt="enter image description here" /></a>and that no user is receiving any overdue email when overdue checkbox is selected. Also I have a Trigger set up with On edit. Its been wrecking my head for a while now, an help, pointers are greatly appreciated.</p>
<pre><code>function onCheckboxEdit(e) {
var source = e.source;
var sheet = source.getActiveSheet();
var range = e.range;
var row = range.getRow();
var column = range.getColumn();
console.log("column:: ", column);
var targetRange = sheet.getRange(row, 1, 1, 17);
var targetValues = targetRange.getValues();
console.log("targetRange:: ", targetValues);
var student = targetValues[0][2];
var recipient = targetValues[0][1];
var checkboxValue = targetValues[0][9];
var checkboxValue2 = targetValues[0][17];
var subject = ("Laptop Loan Approved");
var body = ("Hello "+ student +", \n\nWe are happy to confirm that your laptop loan application has been approved.");
var subject2 = ("Laptop Loan");
var body2 = ("Hello "+ student +", \n\nPlease disregard last e-mail sent by us, it was mistakenly sent.");
var subject3 = ("Overdue Laptop Loan");
var body3 = ("Hello "+ student +", \n\nThe laptop you have been loaned is due to be returned.");
if(column = 10 && checkboxValue == true) {
console.log("chekbox marked true")
MailApp.sendEmail(recipient, subject, body)
} else if (column = 10 && checkboxValue == false) {
console.log("chekbox marked false")
MailApp.sendEmail(recipient, subject2, body2)
} else {
console.log("No clue")
}
if(column = 18 && checkboxValue2 == true) {
console.log("chekbox marked true")
MailApp.sendEmail(recipient, subject3, body3)
} else if (column = 18 && checkboxValue2 == false) {
console.log("chekbox marked false")
MailApp.sendEmail(recipient, subject3, body2)
} else {
console.log("No clue")
}
}
</code></pre>
| [
{
"answer_id": 74180732,
"author": "J M",
"author_id": 15611264,
"author_profile": "https://Stackoverflow.com/users/15611264",
"pm_score": 3,
"selected": true,
"text": "if(column = 10 .........)\n"
},
{
"answer_id": 74204631,
"author": "Cluster",
"author_id": 6624303,
... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6624303/"
] |
74,179,308 | <p>I can’t solve the problem, the v-icon are displayed normally if the middleware is not enabled, maybe my middleware is not correct?</p>
<p>template:</p>
<pre><code><v-icon>{{'mdi-close'}}</v-icon>
</code></pre>
<p>script:</p>
<pre><code>middleware: ['auth'],
</code></pre>
<p>middleware/auth.js</p>
<pre><code>export default function({store, redirect}){
if (!store.getters.hasToken) {
redirect('/login')
}
}
</code></pre>
| [
{
"answer_id": 74180732,
"author": "J M",
"author_id": 15611264,
"author_profile": "https://Stackoverflow.com/users/15611264",
"pm_score": 3,
"selected": true,
"text": "if(column = 10 .........)\n"
},
{
"answer_id": 74204631,
"author": "Cluster",
"author_id": 6624303,
... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179308",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20320458/"
] |
74,179,315 | <p>Short description:
Dataflow is processing the same input element many times, even at the same time in parallel (so this is not fail-retry build-in mechanism of dataflow, because previous process didn't fail).</p>
<p>Long description:
Pipeline gets pubsub message in which path to GCS file is stored.
In next step (DoFn class) this file is open and read line by line, so sometimes for very big files this is long process and takes up to 1 hour (per file).</p>
<p>Many times (very often) those big files are processing at the same time.
I see it based on logs messages, that first process loads already 500k rows, another one 300k rows and third one just started, all of them are related to the same file and all of them based on the same pubsub message (the same message_id).</p>
<p>Also pubsub queue chart is ugly, those messages are not acked so unacked chart does not decrease.</p>
<p>Any idea what is going on? Have you experienced something similar?</p>
<p>I want to underline that this is not a issue related to fail and retry process.
If first process fails and second one started for the same file - that is fine and expected.
Unexpected is, if those two processes lives at the same time.</p>
| [
{
"answer_id": 74180732,
"author": "J M",
"author_id": 15611264,
"author_profile": "https://Stackoverflow.com/users/15611264",
"pm_score": 3,
"selected": true,
"text": "if(column = 10 .........)\n"
},
{
"answer_id": 74204631,
"author": "Cluster",
"author_id": 6624303,
... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179315",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12135668/"
] |
74,179,336 | <p>I have some elements each has some attribute</p>
<p>Example:</p>
<p>a1 = Quadrupole(Name= 'qd1.1', Length = 2.9)</p>
<p>Some of them had additional attribute called R1:</p>
<p>a2 = Quadrupole(Name= 'qd1.1', Length = 2.9, R1=some value)</p>
<p>I want to loop through this element and append the attribute R, first i got the error "'Quadrupole' object has no attribute 'R1'" for the elements that don't have the attribute, i want to append zero value for these elements, i want to implement something like:</p>
<pre><code>i = 0
while (i < len(elements_indexes)):
if (a[i].FamName).startswith('q') and a[i].R1 exist:
skew_quad_coof = a[i].R1
else:
skew_quad_coof = 0
k_qs.append(skew_quad_coof)
i += 1
</code></pre>
<p>However, this did not work</p>
| [
{
"answer_id": 74179418,
"author": "jthulhu",
"author_id": 5956261,
"author_profile": "https://Stackoverflow.com/users/5956261",
"pm_score": 3,
"selected": true,
"text": "hasattr"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18207904/"
] |
74,179,346 | <p>I am using scala.</p>
<p>I want to filter latest folder and read only latest and also all files in it from hdfs dir.</p>
<p>Now it looks like</p>
<pre class="lang-scala prettyprint-override"><code>val read_csv =
spark
.read
.format("csv")
.load( "hdfs://device/signs/load=16»)
</code></pre>
<p>in the folder <strong>signs</strong> there are few folders with load (load=10, load=13, load=14, load=16) and I want to get only max value.</p>
| [
{
"answer_id": 74179418,
"author": "jthulhu",
"author_id": 5956261,
"author_profile": "https://Stackoverflow.com/users/5956261",
"pm_score": 3,
"selected": true,
"text": "hasattr"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179346",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20300722/"
] |
74,179,359 | <p>I've got a big table (~500m rows) in mysql RDS and I need to export specific columns from it to csv, to enable import into questDb.</p>
<p>Normally I'd use <code>into outfile</code> but this isn't supported on RDS as there is no access to the file system.</p>
<p>I've tried using workbench to do the export but due to size of the table, I keep getting out-of-memory issues.</p>
| [
{
"answer_id": 74179394,
"author": "Sam Shiles",
"author_id": 450159,
"author_profile": "https://Stackoverflow.com/users/450159",
"pm_score": 3,
"selected": true,
"text": "#!bin/bash\n\n# Maximum number of rows to export/total rows in table, set a bit higher if live data being written\nM... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179359",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/450159/"
] |
74,179,388 | <p>I want to write a jquery that by a mouseover change the contain of the first <code><ul></code>, the first <code><ul></code> by default contains <code>111</code> and when the mouse is over <code>aaa</code> appears <code>111</code>, <code>bbb</code> appears <code>222</code>, <code>ccc</code> appears <code>333</code></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>const firstul = document.getElementById('span_Lan');
const boxLi = document.getElementById('ul_box').children;
for (let i = 0; i < boxLi.length; i++) {
boxLi[i].addEventListener('mouseover', () => {
firstul.value += boxLi[i].textContent;
if (boxLi[i].id == "lnk1") firstul.value += "111";
else if (boxLi[i].id == "lnk2") firstul.value += "222";
else if (boxLi[i].id == "lnk2") firstul.value += "333";
})
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div>
<ul>
<li id="li_box"> <span id="span_Lan"></span></li>
</ul>
<ul id="ul_box">
<li><a id="lnk1" class="">aaa</a></li>
<li><a id="lnk2" class="">bbb</a></li>
<li><a id="lnk3" class="">ccc</a></li>
</ul>
</div></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74179525,
"author": "Pete",
"author_id": 1790982,
"author_profile": "https://Stackoverflow.com/users/1790982",
"pm_score": 1,
"selected": true,
"text": "innerText"
},
{
"answer_id": 74179730,
"author": "Remco Kersten",
"author_id": 13029349,
"author_pro... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179388",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19834581/"
] |
74,179,391 | <p>I am responsible for a series of exercises for nonlinear optimization.
I thought it would be cool to start with some examples of optimization problems and solve them with <code>pyomo</code> + some black box solvers.</p>
<p>However, as the students learn more about optimization algorithms I wanted them to also implement some simple methods and test there implementation for the same examples. I hoped there would be an "easy" way to add a custom solver to <code>pyomo</code> however I cannot find any information about this.</p>
<p>Basically that would allow the students to check their implementation by just changing a single line in there code and compare to a well tested solver.</p>
<p>I would also try to implement a <strong>simple</strong> wrapper myself but I do not know anything about the <code>pyomo</code> internals.</p>
<p><strong>Q: Can I add my own solvers written in python to <code>pyomo</code>? Solver could have an interface like the ones of <code>scipy.optimize</code>.</strong></p>
<p>Ty for reading,</p>
<p>Franz</p>
<hr />
<p>Related:</p>
<ul>
<li><a href="https://stackoverflow.com/questions/51631899/pyomo-solver-communication">Pyomo-Solver Communication</a></li>
<li><a href="https://stackoverflow.com/questions/47821346/call-scipy-optimize-inside-pyomo">Call scipy.optimize inside pyomo</a></li>
</ul>
| [
{
"answer_id": 74179525,
"author": "Pete",
"author_id": 1790982,
"author_profile": "https://Stackoverflow.com/users/1790982",
"pm_score": 1,
"selected": true,
"text": "innerText"
},
{
"answer_id": 74179730,
"author": "Remco Kersten",
"author_id": 13029349,
"author_pro... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179391",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11785620/"
] |
74,179,393 | <p>I'm trying to connect to a public IP CloudSQL Postgres database from a cloud function with Prisma.
The database has SSL enforced. I assume I can use the Cloud Auth Proxy, and it works locally, but when I deploy it gives me an error.</p>
<p>I've tried both:</p>
<p><strong>Option 1:</strong></p>
<pre><code>datasource db {
provider = "postgresql"
url = "postgresql://USER:PASSWORD@localhost:3307/DATABASE_NAME?host=CONNECTION_URL"
}
</code></pre>
<p>Got error:</p>
<pre><code>Can't reach database server at `CONNECTION_URL`:`3307`
</code></pre>
<hr />
<p><strong>Option 2:</strong></p>
<pre><code>datasource db {
provider = "postgresql"
url = "postgresql://USER:PASSWORD@localhost/DATABASE_NAME?host=CONNECTION_URL"
}
</code></pre>
<p>Got error:</p>
<pre><code>Can't reach database server at `IP_ADDRESS`:`5432`
</code></pre>
<p>Where IP_ADDRESS is the correct public IP address for the database that I can see in the console</p>
<p>CONNECTION_URL is /cloudsql/PROJ:REGION:INSTANCE</p>
| [
{
"answer_id": 74179525,
"author": "Pete",
"author_id": 1790982,
"author_profile": "https://Stackoverflow.com/users/1790982",
"pm_score": 1,
"selected": true,
"text": "innerText"
},
{
"answer_id": 74179730,
"author": "Remco Kersten",
"author_id": 13029349,
"author_pro... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10856865/"
] |
74,179,408 | <p>I am pretty new to Asp.Net Core and I managed to create a mvc project. In This project I have created an API and it is secured with token based authorization. I am trying to consume this api and make a post request to save data to database. To achieve this I have created one API controller and one MVC controller. These two controllers are used with different purposes. In order to consume the api I have to generate a JWT token and attach token to request header. I use MVC controller for that purpose and after attach authorization header, I consume API post endpoint by sending request from MVC controller to API controller. Here is the process.</p>
<p>I have a form to collect product data in view. Data is send to the MVC controller through ajax. Ajax coding part is successfully working and I can see all the data have passed to controller.</p>
<p><strong>MVC Controller</strong></p>
<pre><code>[HttpPost]
public async Task<IActionResult> stockIn([FromBody] Products products)
{
var user = await _userManager.GetUserAsync(User);
var token = getToken(user);
var json = JsonConvert.SerializeObject(products);
var content = new StringContent(json, Encoding.UTF8, "application/json");
var httpClient = _clientFactory.CreateClient();
var request = new HttpRequestMessage(HttpMethod.Post,
"https://localhost:7015/api/stocks/stockIn/");
request.Headers.Add("Authorization", "Bearer " + token);
request.Content = content;
HttpResponseMessage response = await httpClient.SendAsync(request);
if (response.StatusCode == System.Net.HttpStatusCode.OK)
{
var apiData = await response.Content.ReadAsStringAsync();
return Ok(apiData);
}
return StatusCode(StatusCodes.Status500InternalServerError);
}
</code></pre>
<p>This code(MVC controller) also works fine, when I debug this just before the request is sent, I can see token and content also have generated and request is attached with them. Request method is also set to POST.<a href="https://i.stack.imgur.com/9f6NT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9f6NT.png" alt="enter image description here" /></a></p>
<p>Then I put a breakpoint on API controller and once the request is sent, the <strong>Request Uri - Api endpoint</strong> is hiiting and I can see that <strong>request method has become GET and the content become Null</strong></p>
<p><strong>API Controller</strong></p>
<pre><code>[HttpPost]
[Route("StockIn")]
public async Task<IActionResult> StockAdd(HttpRequestMessage httpRequestMessage)
{
var content = httpRequestMessage.Content;
string jsonContent = content.ReadAsStringAsync().Result;
Products products = new Products();
products = JsonConvert.DeserializeObject<Products>(jsonContent);
await _context.StoresProducts.AddAsync(products);
await _context.SaveChangesAsync();
return Ok(new { success = "Stock updated successfully" });
}
</code></pre>
<p>When I am hovering over the received httpRequestMessage on API controller :<a href="https://i.stack.imgur.com/ES85B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ES85B.png" alt="received httpRequestMessage" /></a></p>
<p>When I am debuging line by line API controller, A null exception is thrown When request message content access.</p>
<p><a href="https://i.stack.imgur.com/jYalB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jYalB.png" alt="Null Exception" /></a></p>
<p>I found that there are many posts regarding this issue. I have tried almost every solution mentioned on them.</p>
<p><strong>Tried fixes: None of them work</strong></p>
<pre><code>var httpClient = _clientFactory.CreateClient();
httpClient.DefaultRequestHeaders.ExpectContinue = false;
httpClient.DefaultRequestHeaders.Accept.Add(
new MediaTypeWithQualityHeaderValue("application/json"));
</code></pre>
<p>I also tried changing request Url by adding '/' to end of it, does not work either. Some of the posts has guessed that there must be a redirection but I can not find a redirection also. I think sometime this caused because I am calling the api endpoint via MVC controller action. Since I want to attach token to request header before api calling, I can not find a way to call api endpoint directly without MVC controller action. Please help me to find the issue here or show me how to achieve this task correctly. Thank you.</p>
| [
{
"answer_id": 74189047,
"author": "Ceemah Four",
"author_id": 9278478,
"author_profile": "https://Stackoverflow.com/users/9278478",
"pm_score": 2,
"selected": true,
"text": " [HttpPost]\n [Route(\"StockIn\")]\n public async Task<IActionResult> StockAdd(IEnumerable<P... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20254102/"
] |
74,179,409 | <p>I am trying to create a view that displays the time of employee stamps.</p>
<p>This is what the table looks like now:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Person</th>
<th>Person_Number</th>
<th>Date</th>
<th>Stamp_number</th>
<th>Time_Stamp</th>
</tr>
</thead>
<tbody>
<tr>
<td>Paul</td>
<td>1</td>
<td>22-10-24</td>
<td>1</td>
<td>8:00</td>
</tr>
<tr>
<td>Paul</td>
<td>1</td>
<td>22-10-24</td>
<td>2</td>
<td>10:00</td>
</tr>
<tr>
<td>Paul</td>
<td>1</td>
<td>22-10-24</td>
<td>3</td>
<td>10:30</td>
</tr>
<tr>
<td>Paul</td>
<td>1</td>
<td>22-10-24</td>
<td>4</td>
<td>12:00</td>
</tr>
<tr>
<td>Jimmy</td>
<td>2</td>
<td>22-10-23</td>
<td>1</td>
<td>9:00</td>
</tr>
<tr>
<td>Jimmy</td>
<td>2</td>
<td>22-10-23</td>
<td>2</td>
<td>11:00</td>
</tr>
<tr>
<td>Jimmy</td>
<td>2</td>
<td>22-10-23</td>
<td>3</td>
<td>12:00</td>
</tr>
</tbody>
</table>
</div>
<p>And I would like it to look like this using only a <code>select</code> query</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Person</th>
<th>Person_Number</th>
<th>Date</th>
<th>Start</th>
<th>End</th>
<th>Duration</th>
</tr>
</thead>
<tbody>
<tr>
<td>Paul</td>
<td>1</td>
<td>22-10-24</td>
<td>8:00</td>
<td>10:00</td>
<td>2:00</td>
</tr>
<tr>
<td>Paul</td>
<td>1</td>
<td>22-10-24</td>
<td>10:30</td>
<td>12:00</td>
<td>1:30</td>
</tr>
<tr>
<td>Jimmy</td>
<td>2</td>
<td>22-10-23</td>
<td>9:00</td>
<td>11:00</td>
<td>2:00</td>
</tr>
<tr>
<td>Jimmy</td>
<td>1</td>
<td>22-10-23</td>
<td>12:00</td>
<td>null</td>
<td>null</td>
</tr>
</tbody>
</table>
</div>
<p>Is it possible ?</p>
| [
{
"answer_id": 74179497,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 3,
"selected": true,
"text": "ROW_NUMBER"
},
{
"answer_id": 74180056,
"author": "ahmed",
"author_id": 12705912,
"author... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179409",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16878379/"
] |
74,179,435 | <p>I'm relatively new to Haskell and rather inexperienced with programming in general.
A function is causing a stack overflow on certain inputs and I'm not sure why.</p>
<p>Function in question:</p>
<pre><code>digitSum :: Integer -> Integer -> Integer
digitSum _ 1 = 1
digitSum base x = (x `mod` base) + digitSum base (x `div`base)
</code></pre>
<p>On some inputs (e.g. 10 15, 11 121, 16 19, 3 1234) it works while on others (10 456 for example) it breaks
Could someone explain this to me, so that I can avoid it in the future?</p>
| [
{
"answer_id": 74179508,
"author": "jthulhu",
"author_id": 5956261,
"author_profile": "https://Stackoverflow.com/users/5956261",
"pm_score": 4,
"selected": true,
"text": "digitSum 2 0"
},
{
"answer_id": 74187575,
"author": "Chris",
"author_id": 15261315,
"author_profi... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20320644/"
] |
74,179,452 | <p>I did make some changes in Github (added some lines and changed a file name), but now my local repo is different from the Github repo.</p>
<p>I would expect that <code>git status</code> would show which files are different, and then <code>git add .</code>+ <code>git commit -m '*'</code>+<code>git push</code> would make my Github repo the same as my local repo, but it doesn't... How can I fix this?</p>
| [
{
"answer_id": 74179508,
"author": "jthulhu",
"author_id": 5956261,
"author_profile": "https://Stackoverflow.com/users/5956261",
"pm_score": 4,
"selected": true,
"text": "digitSum 2 0"
},
{
"answer_id": 74187575,
"author": "Chris",
"author_id": 15261315,
"author_profi... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19092246/"
] |
74,179,470 | <p>I'm attempting to create a simple WinForms application written in C# that:</p>
<ol>
<li>Takes user input from a text box.</li>
<li>Uses the data from that text box, and stores it in a <code>user_command</code> variable, which is then used in a method that runs the string in that variable in windows cmd.</li>
</ol>
<p>E.g: I enter "calc.exe" in the text box. The program then passes that into cmd, therefore opening the calculator.</p>
<p>I am unaware of how I use that data from that text-box and put it into <code>System.Diagnostics.Process.Start("CMD.exe", user_command);</code></p>
<p>I will leave all the code below:</p>
<pre><code>using Microsoft.Win32;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;
namespace gui_1
{
public partial class Form1 : Form
{
public Form1()
{
InitializeComponent();
}
public void button1_Click(object sender, EventArgs e)
{
string user_command = textBox1.Text;
}
private void textBox1_TextChanged(object sender, EventArgs e, string user_command)
{
System.Diagnostics.Process.Start("CMD.exe", user_command);
}
}
}
</code></pre>
<p>The errors I get are:</p>
<pre><code>Error CS0123 No overload for 'textBox1_TextChanged' matches delegate 'EventHandler' gui_1
</code></pre>
| [
{
"answer_id": 74179698,
"author": "Henry",
"author_id": 3405661,
"author_profile": "https://Stackoverflow.com/users/3405661",
"pm_score": 2,
"selected": false,
"text": "System.Diagnostics.Process.Start(\"CMD.exe\", user_command);"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179470",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18040631/"
] |
74,179,490 | <p>I am trying to scroll and request focus to an off screen element from a recycler view. I have a list of 15 languages. When app starts the user can select one language from the recycler. Then if the app starts again the recycler scrolls and request focusto that item.</p>
<p>But imagine the user selects the last language from the list which is not showed in the recycler when the app starts. How to scroll and therefore reqeust focus to that element which is not currently showed in the recycler?</p>
<p>I expected to do something like recycler.scrollToPosition(14) and then scrollToPosition(14) , but the index is outof bunds... I guess thats because the element is not created yet. Any idea?</p>
| [
{
"answer_id": 74179698,
"author": "Henry",
"author_id": 3405661,
"author_profile": "https://Stackoverflow.com/users/3405661",
"pm_score": 2,
"selected": false,
"text": "System.Diagnostics.Process.Start(\"CMD.exe\", user_command);"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179490",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17331235/"
] |
74,179,500 | <p>I am making BDD test with a Cucumber-Playwright suit. A page I am making a test for has buttons that will trigger a PUT API request and update the page (<strong>Note: The button will not link to new address, just trigger and API request</strong>).</p>
<p>I want to make sure that all network events have finished before moving on to the next step as it may try to act too soon before the API request has returned and cause the test to fail.</p>
<p>I want to avoid hard waits so I read the documentation and found a step structure that uses <code>Promise.all([])</code> to combine two or more steps. From what I understand they will check that each step in the array to be true at the same time before moving on.</p>
<p>So the steps looks like this:</p>
<pre><code>
await Promise.all([inviteUserButton.click(), page.waitForLoadState('networkidle')])
await page.goto('https://example/examplepage')
</code></pre>
<p>This stage of the test is flaky however, it will work about 2/3 times. From the trace files I read to debug the test I see that the the network response repsondes with <code>net::ERR_ABORTED POST https://.....</code></p>
<p>I believe this is due to to the <code>page.goto()</code> step has interrupted the network request/response. Due to this, it will cause the coming assertion to fail as it was not completed.</p>
<p>Is there a way to test that all the pages network events have finished from a onClick event or similar before moving onto the next step?</p>
| [
{
"answer_id": 74179698,
"author": "Henry",
"author_id": 3405661,
"author_profile": "https://Stackoverflow.com/users/3405661",
"pm_score": 2,
"selected": false,
"text": "System.Diagnostics.Process.Start(\"CMD.exe\", user_command);"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179500",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17580280/"
] |
74,179,521 | <p><a href="https://codepen.io/zaidzac95/pen/qBKWKep" rel="nofollow noreferrer">https://codepen.io/zaidzac95/pen/qBKWKep</a></p>
<p>I want to have navigation links and image in the same line.</p>
<p>This is what HTML of header looks like:</p>
<pre><code><div class="container">
<div class="header">
<nav class="sub-header">
<ul>
<li> <a href="">Home</a> </li>
<li> <a href="">AboutUs</a> </li>
<li> <a href="">Products</a> </li>
<li> <a href="">Services</a> </li>
<li> <a href="">Contact Us</a> </li>
</ul>
</nav>
<img src="ethereum-eth-logo.png" class="logo">
</div>
</div>
</code></pre>
| [
{
"answer_id": 74179698,
"author": "Henry",
"author_id": 3405661,
"author_profile": "https://Stackoverflow.com/users/3405661",
"pm_score": 2,
"selected": false,
"text": "System.Diagnostics.Process.Start(\"CMD.exe\", user_command);"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179521",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18071008/"
] |
74,179,524 | <p>I have this:</p>
<pre><code><div onclick="myFunc()" style="height:200px;width:200px;">
<button></button>
</div>
</code></pre>
<p>I want myFunc to execute when any place on the div is clicked EXCEPT for the button. How can I do this?</p>
| [
{
"answer_id": 74179566,
"author": "David McEleney",
"author_id": 2281257,
"author_profile": "https://Stackoverflow.com/users/2281257",
"pm_score": 2,
"selected": false,
"text": "function button_click(event) {\n event.stopPropagation();\n console.log(\"button clicked.\");\n }\n"
... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179524",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12830311/"
] |
74,179,530 | <p>I have template html file which look like this</p>
<pre><code><!DOCTYPE html>
<html lang="en">
<style>
table, th, td {
border:1px solid black;
}
</style>
<body>
<h2>Email Report: Crash in Log File</h2>
<table style="width:100%">
<tr>
<th>Device Mode</th>
<th>IP</th>
<th>Platform</th>
<th>Host Name</th>
<th>Test</th>
<th>Time</th>
</tr>
<tr>
<td id="dm"></td>
<td id="ip"></td>
<td id="pla"></td>
<td id="hn"></td>
<td id="test"></td>
<td id="time"></td>
</tr>
</table>
<br>
<br>
<br>
<table style="width:100%">
<tr>
<th>Stack Trace</th>
</tr>
<tr>
<td id="st"></td>
</tr>
</table>
</body>
</html>
</code></pre>
<p>I have in my java porgram variables like ip, deviceName and etc and i want to insert these variables to the table</p>
<p>for exsample insert the ip var to <code><td id="ip"></td></code></p>
<p>how can I do it ?</p>
| [
{
"answer_id": 74179566,
"author": "David McEleney",
"author_id": 2281257,
"author_profile": "https://Stackoverflow.com/users/2281257",
"pm_score": 2,
"selected": false,
"text": "function button_click(event) {\n event.stopPropagation();\n console.log(\"button clicked.\");\n }\n"
... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179530",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12699161/"
] |
74,179,537 | <p>My json file looks like this:</p>
<pre><code> "parameters": {
"$connections": {
"value": {
"azureblob": {
"connectionId": "/subscriptions/2b06d50xxxxxedd021/resourceGroups/Reource1005/providers/Microsoft.Web/connections/azureblob",
"connectionName": "azureblob",
"connectionProperties": {
"authentication": {
"type": "ManagedServiceIdentity"
}
},
"id": "/subscriptions/2b06d502-3axxxxxxedd021/providers/Microsoft.Web/locations/eastasia/managedApis/azureblob"
},
"office365": {
"connectionId": "/subscriptions/2b06d502xxxxxc8-5a8939edd021/resourceGroups/Reource1005/providers/Microsoft.Web/connections/office365",
"connectionName": "office365",
"id": "/subscriptions/2b06d50xxxxxx939edd021/providers/Microsoft.Web/locations/eastasia/managedApis/office365"
}
}
}
}
</code></pre>
<p>}</p>
<p>I want to use <strong>sed</strong> command to replace the string in connectionId, currently my script is as follows:</p>
<pre><code>script: 'sed -e ''/connectionId/c\ \"connectionId\" : \"/subscriptions/2b06d50xxxxb-92c8-5a8939edd021/resourceGroups/Reourcetest/providers/Microsoft.Web/connections/azureblob\",'' "$(System.DefaultWorkingDirectory)/function-app-actions/templates/copycode.json"'
</code></pre>
<p>This script can replace the strings <strong>in both connectionIds</strong> in the json file with "Resourcetest", that's what I want to make the strings in the second connectionId replace with other values, how can I do that?</p>
<p>I'm new to sed commands, any insight is appreciated。</p>
<p><strong>Edit:</strong></p>
<p>I just want to replace "Resource1005" in both connectionId strings in the json file with "Resourcetest", but I need <strong>other content in the connectionIds string to keep the previous value</strong></p>
<p>So my expected output should look like this:</p>
<pre><code>"connectionId": "/subscriptions/2b06d502-3axxxx8939edd021/resourceGroups/Reourcetest/providers/Microsoft.Web/connections/azureblob"
"connectionId": "/subscriptions/2b06d502-3axxxx8939edd021/resourceGroups/Reourcetest/providers/Microsoft.Web/connections/office365"
</code></pre>
<p>If I use the script I mentioned above, it does replace the two Resource1005s, but the other values in the string are also replaced with the same (I just want to replace the Resource1005 value)</p>
| [
{
"answer_id": 74188624,
"author": "RavinderSingh13",
"author_id": 5866580,
"author_profile": "https://Stackoverflow.com/users/5866580",
"pm_score": 3,
"selected": true,
"text": "awk"
},
{
"answer_id": 74190553,
"author": "Ivan",
"author_id": 12607443,
"author_profile... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179537",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20048547/"
] |
74,179,543 | <p>I have a response in JSON:</p>
<pre><code>{
"data": {
"id": "12-43-abc",
"number": "4",
"name": "Admin Test 1",
"stage": "active",
"sex": "female",
"title": "admin",
"dob": null,
"phoneNumber": "1",
"email": "admin1@gmail.com",
"address": null,
"mId": null,
"createdDateTime": "2020-09-17T02:42:10.447Z",
"totalRemain": null,
"carryOverRemain": null,
"fromTime": null,
"toTime": null
}
}
</code></pre>
<p>To convert JSON to Object, I create a model:</p>
<pre><code>class User {
String? id;
String? number;
String? name;
String? stage;
String? sex;
String? title;
DateTime? dob;
String? phoneNumber;
String? email;
String? address;
String? mId;
DateTime? createdDateTime;
int? totalRemain;
int? carryOverRemain;
DateTime? fromTime;
DateTime? toTime;
User({
this.id,
this.number,
this.name,
this.stage,
this.sex,
this.title,
this.dob,
this.phoneNumber,
this.email,
this.address,
this.mId,
this.createdDateTime,
this.totalRemain,
this.carryOverRemain,
this.fromTime,
this.toTime});
factory User.fromJson(Map<String, dynamic> json) {
return User(
id: json['id'],
number: json['badgeNumber'] ?? "null",
name: json['name'] ?? "null",
stage: json['status'],
sex: json['gender'] ?? "null",
title: json['title'] ?? "null",
dob: DateTime.parse(json['birthDay']),
phoneNumber: json['phone'] ?? "null",
email: json['email'] ?? "null",
address: json['address'] ?? "null",
mId: json['managerId'] ?? "null",
createdDateTime: DateTime.parse(json['createdDateTime']),
totalRemain: json['totalRemain'],
carryOverRemain: json['carryOverRemain'],
fromTime: DateTime.parse(json['fromTime']),
toTime: DateTime.parse(json['toTime'])
);
}
}
</code></pre>
<p>I create a signIn method:</p>
<pre><code>Future<Either<Failure, dynamic>> signIn(String number, String password) async {
try {
Map<String, String> bd = {
'number': number,
'password': password
};
final Response res = await dio.post(Endpoint.signIn, data: bd);
if(res.statusCode == 200) {
return Right(User.fromJson(res.data['data']));
}
else {
return Right(res.data['error']);
}
}
catch(e) {
throw e;
return Left(SystemFailure());
}
}
</code></pre>
<p>When debugging, the status code is 200 but it throws an exception <strong>type 'Null' is not a subtype of type 'String'</strong>. I've searched Google for it but still have no answer. No idea what's wrong in my model class. Thanks for your help.</p>
| [
{
"answer_id": 74179604,
"author": "Ivo",
"author_id": 1514861,
"author_profile": "https://Stackoverflow.com/users/1514861",
"pm_score": 2,
"selected": true,
"text": "dob"
},
{
"answer_id": 74179615,
"author": "Gwhyyy",
"author_id": 18670641,
"author_profile": "https:... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8244724/"
] |
74,179,546 | <p>currently what I'm trying to do in Bash on my Ubuntu machine is utilize <code>xdg-open</code> to find a certain path or file.</p>
<p>In the command line, here's what typically happens;</p>
<p>When I run <code>xdg-open ~/Downloads/</code>,
This opens the file manager in the <code>~/Downloads/</code> folder, regardless of where my current directory is, as it should.</p>
<p>However, when I run <code>xdg-open ~/Downloads/</code> in a bash script, it attempts to read from the script's path <strong>and</strong> the path provided, which results in something similar to <code>xdg-open /path/of/my/script/~/Downloads/</code>, which I don't want.</p>
<p>My current script looks a bit like this;</p>
<pre><code>#!/usr/bin/env bash
input=$(zenity --entry --text="Enter the URL or file." --title=Run --window-icon=question)
echo version=$BASH_VERSION
xdg-open "$input"
exit
</code></pre>
<p>How could I make it so my Bash script's <code>xdg-open</code> line behave how it does in the command line?</p>
| [
{
"answer_id": 74179604,
"author": "Ivo",
"author_id": 1514861,
"author_profile": "https://Stackoverflow.com/users/1514861",
"pm_score": 2,
"selected": true,
"text": "dob"
},
{
"answer_id": 74179615,
"author": "Gwhyyy",
"author_id": 18670641,
"author_profile": "https:... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16599232/"
] |
74,179,556 | <p>I have to multiply many (about 700) matrices with a random element (in the following, I'm using a box distribution) in python:</p>
<pre><code>#define parameters
μ=2.
σ=2.
L=700
#define random matrix
T=[None]*L
product=np.array([[1,0],[0,1]])
for i in range(L):
m=np.random.uniform(μ-σ*3**(1/2), μ+σ*3**(1/2)) #box distribution
T[i]=np.array([[-1,-m/2],[1,0]])
product=product.dot(T[i]) #multiplying matrices
Det=abs(np.linalg.det(product))
print(Det)
</code></pre>
<p>For this choice of μ and σ, I obtain quantities of the order of e^30+, but this quantity should converge to 0. How do I know? Because analytically it can be demonstrated to be equivalent to:</p>
<pre><code>Y=[None]*L
product1=np.array([[1,0],[0,1]])
for i in range(L):
m=np.random.uniform(μ-σ*(3**(1/2)), μ+σ*(3**(1/2))) #box distribution
Y[i]=np.array([[-m/2,0],[1,0]])
product1=product1.dot(Y[i])
l,v=np.linalg.eig(product1)
print(abs(l[1]))
</code></pre>
<p>which indeed gives e^-60.
I think there is an overflow issue here. How can I fix it?</p>
<p><strong>EDIT:</strong></p>
<p>The two printed quantities are expected to be equivalent because the first one is the abs of the determinant of:</p>
<p><a href="https://i.stack.imgur.com/Tng0C.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Tng0C.png" alt="product" /></a></p>
<p>which is, according to the <em>Binet theorem</em> (the determinant of a product is the product of determinants):</p>
<p><a href="https://i.stack.imgur.com/CFBHX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CFBHX.png" alt="determinant" /></a></p>
<p>The second code prints the abs of the greatest eigenvalue of:</p>
<p><a href="https://i.stack.imgur.com/x5pX6.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/x5pX6.png" alt="product1" /></a></p>
<p>It is easy to see that one eigenvalue is 0, the other equals <a href="https://i.stack.imgur.com/CFBHX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CFBHX.png" alt="determinant" /></a>.</p>
| [
{
"answer_id": 74181950,
"author": "Nikolay Zakirov",
"author_id": 9023490,
"author_profile": "https://Stackoverflow.com/users/9023490",
"pm_score": 1,
"selected": true,
"text": "import numpy as np\n#define parameters\nμ=2.\nσ=2.\nL=700\n\n#define random matrix\nT=[None]*L\n\nscale = 1\n... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179556",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19282170/"
] |
74,179,573 | <p>I want to read from a yml file line by line and want to check if a command line argument is in the line, if it is I want to put the entire line in a different file.</p>
<p>Below is the simplified version of the code I am working with.</p>
<pre><code>while IFS= read -r line; do
if [[ "$line" =~ ".*$1:" ]]; then
echo "$line" >> file_copy.yml
fi
done < file.yml
</code></pre>
<p>I have tried <code>"$line" == *".*\$1:"*</code> but it didn't work.</p>
<p>Edit:</p>
<p>As soon as I pass a command line argument it says there is a syntax error.</p>
| [
{
"answer_id": 74181950,
"author": "Nikolay Zakirov",
"author_id": 9023490,
"author_profile": "https://Stackoverflow.com/users/9023490",
"pm_score": 1,
"selected": true,
"text": "import numpy as np\n#define parameters\nμ=2.\nσ=2.\nL=700\n\n#define random matrix\nT=[None]*L\n\nscale = 1\n... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179573",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18709582/"
] |
74,179,582 | <p>i am studying React and Material UI and
I am trying to change the background color of the clicked div, for the moment they changed all.</p>
<p>I would like to change the background color from white to lightblue when one of the div is clicked and back to white only when we click on the other div.
I am getting the datas from a JSON file.
I hope it make sense.</p>
<p>I will share my code.</p>
<pre><code> <Grid sx={{ display:'flex' }} >
{ props.supplies.map((supply,id) => {
return(
<Grid onClick={changeBackground} lg={4} key={id} sx={{ marginRight:"0.8rem", backgroundColor:`${background}`, border:2, borderRadius:2, borderColor:'#ddedf4', padding:'5px 8px 25px 25px' }}>
<RadioGroup
name={supply.months}
onChange={handleChange}
value={value}
>
<FormControlLabel value={ supply.months } control={<Radio size="small"/>} label={ <Typography fontSize='14px'>{supply.months}</Typography> } />
<Typography marginLeft='30px'>{ supply.boxes }</Typography>
</RadioGroup>
</Grid>
)
})}
</Grid>
</code></pre>
<p>This code will render 3 divs with a checkbox and some text with a white background color from white to lightblue</p>
<pre><code> const[background,setBackground] = useState('white')
const handleChange = (e:React.ChangeEvent<HTMLInputElement>) =>
console.log(e.target.value)
const changeBackground = () => setBackground('lightblue')
</code></pre>
<p>When i click on a div they all change background color.</p>
<p>Can someone help me to understand the problem, i am still a beginner.</p>
<p>Have a good day</p>
| [
{
"answer_id": 74181950,
"author": "Nikolay Zakirov",
"author_id": 9023490,
"author_profile": "https://Stackoverflow.com/users/9023490",
"pm_score": 1,
"selected": true,
"text": "import numpy as np\n#define parameters\nμ=2.\nσ=2.\nL=700\n\n#define random matrix\nT=[None]*L\n\nscale = 1\n... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179582",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11916661/"
] |
74,179,589 | <p>I'm creating a basic css animation for a restart button. The button is basically going to shrink and grow infinitely. It's for a rock paper scissor game. I'm only going to put the relevant code here. Idk why the animation isn't working. Take a look at the html and CSS code.</p>
<pre><code><div id="gameOver" class="gameOver">
<p id="finalResult">Game Over! You Lost/Won</p>
<button id="restartButton">Restart</button>
</div>
</code></pre>
<p>CSS:</p>
<pre><code>#restartButton {
width: 17%;
height: 100px;
cursor: pointer;
color:rgb(255, 197, 249);
font-size: 3.5em;
border-style: solid;
border-width: 5px;
border-color: white;
background-color: rgb(42, 40, 40);
border-radius: 35px;
transition: 0.4s;
animation-name: example 5s infinite;
}
@keyframes example {
from {height: 100px; width: 17%;}
to {height: 80px; width: 14%;}
}
#restartButton:hover {
transition: 0.4s;
border-radius: 75px;
color: rgb(42, 40, 40);
background-color: rgb(255, 197, 249);
}
</code></pre>
| [
{
"answer_id": 74179617,
"author": "Andrei Fedorov",
"author_id": 6641198,
"author_profile": "https://Stackoverflow.com/users/6641198",
"pm_score": 2,
"selected": true,
"text": "animation-name"
},
{
"answer_id": 74179915,
"author": "DSDmark",
"author_id": 16517581,
"a... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179589",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14138731/"
] |
74,179,594 | <p>I have a sheet I need to transform from data being stored horizontally to vertically, i.e. from:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">Company ID</th>
<th style="text-align: right;">DoB</th>
<th style="text-align: center;">Name</th>
<th style="text-align: center;">DoB</th>
<th style="text-align: center;">Name</th>
<th style="text-align: center;">DoB</th>
<th style="text-align: center;">Name</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">ID 1</td>
<td style="text-align: right;">DoB 1</td>
<td style="text-align: center;">Name 1</td>
<td style="text-align: center;">DoB 2</td>
<td style="text-align: center;">Name 2</td>
<td style="text-align: center;">DoB 3</td>
<td style="text-align: center;">Name 3</td>
</tr>
<tr>
<td style="text-align: left;">ID 2</td>
<td style="text-align: right;">DoB 4</td>
<td style="text-align: center;">Name 4</td>
<td style="text-align: center;">DoB 5</td>
<td style="text-align: center;">Name 5</td>
<td style="text-align: center;"></td>
<td style="text-align: center;"></td>
</tr>
</tbody>
</table>
</div>
<p>To:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">Company ID</th>
<th style="text-align: right;">DoB</th>
<th style="text-align: center;">Name</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">ID 1</td>
<td style="text-align: right;">DoB 1</td>
<td style="text-align: center;">Name 1</td>
</tr>
<tr>
<td style="text-align: left;">ID 1</td>
<td style="text-align: right;">DoB 2</td>
<td style="text-align: center;">Name 2</td>
</tr>
<tr>
<td style="text-align: left;">ID 1</td>
<td style="text-align: right;">DoB 3</td>
<td style="text-align: center;">Name 3</td>
</tr>
<tr>
<td style="text-align: left;">ID 2</td>
<td style="text-align: right;">DoB 4</td>
<td style="text-align: center;">Name 4</td>
</tr>
<tr>
<td style="text-align: left;">ID 2</td>
<td style="text-align: right;">DoB 5</td>
<td style="text-align: center;">Name 5</td>
</tr>
</tbody>
</table>
</div>
<p>The data is structured such that the DoB/name entities always occur periodically on rows as illustrated above. The number of entities stored horizontally on each row can vary from none to 16.</p>
<p>How would one go about solving this in Python/Pandas (or something else)? This is a one-time thing, so performance is not really an issue.</p>
<p>Thankful for any help!</p>
| [
{
"answer_id": 74179617,
"author": "Andrei Fedorov",
"author_id": 6641198,
"author_profile": "https://Stackoverflow.com/users/6641198",
"pm_score": 2,
"selected": true,
"text": "animation-name"
},
{
"answer_id": 74179915,
"author": "DSDmark",
"author_id": 16517581,
"a... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18299436/"
] |
74,179,634 | <p>How do I get multiple data with same user id from a table in nestjs? suppose I have a user table. How can I get user id matched data?</p>
<pre><code>import { Injectable } from '@nestjs/common';
import { InjectRepository } from '@nestjs/typeorm';
import { Repository } from 'typeorm';
import { usertbl } from './usertbl.entity';
@Injectable()
export class UsersService {
constructor(
@InjectRepository(usertbl)
private UsertblRepository: Repository<usertbl>,
) {}
findAll(): Promise<usertbl[]> {
return this.UsertblRepository.find();
}
findOne(User_ID: string): Promise<usertbl> {
return this.UsertblRepository.findOneBy({ User_ID });
}
createusertbl(Usertbl: usertbl ): Promise<usertbl> {
return this.UsertblRepository.save(Usertbl);
}
}
</code></pre>
| [
{
"answer_id": 74179617,
"author": "Andrei Fedorov",
"author_id": 6641198,
"author_profile": "https://Stackoverflow.com/users/6641198",
"pm_score": 2,
"selected": true,
"text": "animation-name"
},
{
"answer_id": 74179915,
"author": "DSDmark",
"author_id": 16517581,
"a... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179634",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10338715/"
] |
74,179,663 | <p>I have tried to make a function to quickly make an error bar based on a grouping factor and a numerical value as defined below:</p>
<pre><code>#### Function ####
quick.error <- function(data,x,y){
d <- data
plot.d <- d %>%
mutate(x = as.factor(x)) %>%
group_by(x) %>%
summarise(
sd = sd(y, na.rm = TRUE),
mean = mean(y, na.rm=TRUE)
) %>%
ggplot(aes(x,
mean,
fill=x)) +
geom_col(color = "black") +
geom_errorbar(aes(ymin = mean-sd,
ymax = mean+sd),
width = 0.2) +
theme(legend.position = "none")
return(plot.d)
}
</code></pre>
<p>However, when I try to run this with the <code>iris</code> dataset:</p>
<pre><code>#### Test ####
quick.error(data=iris,
x=Species,
y=Petal.Length)
</code></pre>
<p>This gives me an error:</p>
<pre><code>Error in `mutate()`:
! Problem while computing `x = as.factor(x)`.
Caused by error in `is.factor()`:
! object 'Species' not found
</code></pre>
<p>Running it explicitly with <code>$</code> operators gives me a different issue:</p>
<pre><code>#### Test ####
quick.error(data=iris,
x=iris$Species,
y=iris$Petal.Length)
</code></pre>
<p>As you can see here, it has made all the bars the same, I assume because it did not group the mean like it was supposed to:</p>
<p><a href="https://i.stack.imgur.com/soLx0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/soLx0.png" alt="enter image description here" /></a></p>
<p>How do I fix this problem?</p>
| [
{
"answer_id": 74179778,
"author": "stefan",
"author_id": 12993861,
"author_profile": "https://Stackoverflow.com/users/12993861",
"pm_score": 2,
"selected": false,
"text": "x"
},
{
"answer_id": 74179780,
"author": "Limey",
"author_id": 13434871,
"author_profile": "htt... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16631565/"
] |
74,179,731 | <p>Hello guys I'm trying to creat a function that works similarly to split() function but I'm unable to make it count " " as an item and seperate it
here is my code:</p>
<pre><code>def mysplit(argstr, delimitor):
A = ""
B = []
for i in argstr, delimitor:
if i != " ":
A += i
elif A != "":
B.append(A)
A = ""
if A != "":
B.append(A)
return B
print(mysplit('abc def',' '))
</code></pre>
| [
{
"answer_id": 74179778,
"author": "stefan",
"author_id": 12993861,
"author_profile": "https://Stackoverflow.com/users/12993861",
"pm_score": 2,
"selected": false,
"text": "x"
},
{
"answer_id": 74179780,
"author": "Limey",
"author_id": 13434871,
"author_profile": "htt... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179731",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20156403/"
] |
74,179,749 | <p>Im trying to make a flutter app for HR and for my employee's section I need to have it so that their initials are shown if a profile picture is unavailable is there a widget which allows me to do this?</p>
<p>Below is an example of what im trying to achieve</p>
<p><a href="https://i.stack.imgur.com/PFUlf.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PFUlf.jpg" alt="This is an Example of what im trying to achieve" /></a></p>
| [
{
"answer_id": 74179902,
"author": "targiasld",
"author_id": 5812524,
"author_profile": "https://Stackoverflow.com/users/5812524",
"pm_score": 3,
"selected": true,
"text": "CachedNetworkImage(\n imageUrl: \"http://myimage...\",\n placeholder: (context, url) => new C... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17237271/"
] |
74,179,774 | <p>Is it possible to merge two name value pairs into one in an object? Can it be done by a foreach or something? I have seen examples of merging two objects to one but not merging name value pairs within an object of an array.</p>
<p>Original array:</p>
<pre><code>[
{
"id": "10bf820c19869d1097b0f056c924d9f8",
"text1": "Text A",
"text2": "Option"
},
{
"id": "7b6a8f291986955097b0f056c924d981",
"text1": "Text B",
"text2": "Option"
},
{
"id": "99ca5a64b45a551097b07caca12ca710",
"text1": "Text C",
"text2": "Option"
}
]
</code></pre>
<p>To be:</p>
<pre><code>[
{
"id": "10bf820c19869d1097b0f056c924d9f8",
"text": "Text A - Option"
},
{
"id": "7b6a8f291986955097b0f056c924d981",
"text": "Text B - Option"
},
{
"id": "99ca5a64b45a551097b07caca12ca710",
"text": "Text A - Option"
}
]
</code></pre>
| [
{
"answer_id": 74179803,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 3,
"selected": true,
"text": "map()"
},
{
"answer_id": 74179822,
"author": "Woohaik",
"author_id": 17200950,
"author_profile"... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20320673/"
] |
74,179,813 | <p>I have tried and I cant figure out why I keep getting an error.
I have looked over the commas, parenthesis and semicolons and don't see any issues.</p>
<pre class="lang-sql prettyprint-override"><code>SELECT INVOICE.INVOICE_NUMBER, INVOICE.BUSINESS_NAME, INVOICE_ITEM.PRODUCT_SKU AS PRODUCT_SKU, INVOICE_ITEM.QUANTITY_ORDERED AS QUANTITY
FROM INVOICE_ITEM
INNER JOIN INVOICE ON INVOICE_ITEM.INVOICE_NUMBER = INVOICE.INVOICE_NUMBER
GROUP BY BUSINESS
ORDER BY QUANTITY_ORDERED DESC
WHERE QUANTITY_ORDERED > (
SELECT DISTINCT BUSINESS_NAME AS BUSINESS, PRODUCT_SKU, SUM(QUANTITY_ORDERED)
FROM INVOICE_ITEM group by BUSINESS_NAME, PRODUCT_SKU
WHERE PRODUCT_SKU = 'UJT123' AND QUANTITY >= 3
);
</code></pre>
<p>I'm trying to get an output of invoice number - business name - and quantity ordered more than 3 (can be across multiple orders).</p>
| [
{
"answer_id": 74179908,
"author": "Littlefoot",
"author_id": 9097906,
"author_profile": "https://Stackoverflow.com/users/9097906",
"pm_score": 0,
"selected": false,
"text": "where"
},
{
"answer_id": 74179971,
"author": "MT0",
"author_id": 1509264,
"author_profile": "... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15099611/"
] |
74,179,827 | <p>I have a very large xml file which I need to split into several based on a particular tag.
The XML file is something like this:</p>
<pre class="lang-xml prettyprint-override"><code><xml>
<file id="13">
<head>
<talkid>2458</talkid>
<transcription>
<seekvideo id="645">So in college,</seekvideo>
...
</transcription>
</head>
<content> *** This is the content I am trying to save *** </content>
</file>
<file>
...
</file>
</xml>
</code></pre>
<p>I want to extract the <strong>content</strong> of each <strong>file</strong> and save based on the <strong>talkid</strong>.</p>
<p>Here is the code I have tried with:</p>
<pre class="lang-py prettyprint-override"><code>import xml.etree.ElementTree as ET
all_talks = 'path\\to\\big\\file'
context = ET.iterparse(all_talks, events=('end', ))
for event, elem in context:
if elem.tag == 'file':
content = elem.find('content').text
title = elem.find('talkid').text
filename = format(title + ".txt")
with open(filename, 'wb', encoding='utf-8') as f:
f.write(ET.tostring(content), encoding='utf-8')
</code></pre>
<p>But I get the following error:</p>
<pre><code>AttributeError: 'NoneType' object has no attribute 'text'
</code></pre>
| [
{
"answer_id": 74179908,
"author": "Littlefoot",
"author_id": 9097906,
"author_profile": "https://Stackoverflow.com/users/9097906",
"pm_score": 0,
"selected": false,
"text": "where"
},
{
"answer_id": 74179971,
"author": "MT0",
"author_id": 1509264,
"author_profile": "... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179827",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11926527/"
] |
74,179,903 | <p>I am trying to implement a function which checks whether a counter contains "similar" percentage of each items. That is</p>
<pre><code>from collections import Counter
c = Counter(["Dog", "Cat", "Dog", "Horse", "Dog"])
size = 5
lst = list(c.values())
percentages = [x / size * 100 for x in lst] # [60.0, 20.0, 20.0]
</code></pre>
<p>How can I check whether those <code>percentages</code> are all "similar"? I would like to apply the <a href="https://www.w3schools.com/python/ref_math_isclose.asp" rel="nofollow noreferrer"><code>math.isclose</code></a> method with <code>abs_tol=2</code> but it takes two arguments not the entire list.</p>
<p>In the example, items do <em>not</em> occurs similarly.</p>
<p>This method will be used for checking whether a training set of labels is balanced or not.</p>
| [
{
"answer_id": 74180035,
"author": "S.B",
"author_id": 13944524,
"author_profile": "https://Stackoverflow.com/users/13944524",
"pm_score": 2,
"selected": true,
"text": "isclose()"
},
{
"answer_id": 74180233,
"author": "cheersmate",
"author_id": 8394915,
"author_profil... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179903",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20175459/"
] |
74,179,927 | <p>After upgrade to php 8.1 (Linux PHP) , Azure webapp does not seems to have driver for MS SQL. It was OK with php 7.4.</p>
<p>Following this guide (<a href="https://learn.microsoft.com/en-us/azure/app-service/deploy-local-git?tabs=cli" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/azure/app-service/deploy-local-git?tabs=cli</a>), steps to build and configure Azure App service was:
az appservice plan create -g rg-MyResourceG -n MyPlan --is-linux
az webapp create -g rg-MyResource --plan MyPlan --name MyApp --% --runtime "PHP|7.4" --deployment-local-git
Change to PHP 8.1 following this guide: <a href="https://github.com/Azure/app-service-linux-docs/blob/master/Runtime_Support/php_support.md" rel="nofollow noreferrer">https://github.com/Azure/app-service-linux-docs/blob/master/Runtime_Support/php_support.md</a>
az webapp config appsettings set --name MyApp --resource-group MyResourceG --settings DEPLOYMENT_BRANCH='main'
on my local server: php artisan key:generate --show
az webapp config appsettings set --name Glados9L --resource-group rg-blueprism-tst --settings APP_KEY="Output from last command" APP_DEBUG="true"
git remote add glados9l https://MyUser@MyApp.scm.azurewebsites.net/MyApp.git
git push glados9l main
...........
remote: Done in 223 sec(s).
remote:
remote: Removing existing manifest file
remote: Creating a manifest file...
remote: Manifest file created.
remote: Copying .ostype to manifest output directory.
remote:
remote: Done in 457 sec(s).
remote: Running post deployment command(s)...
remote:
remote: Generating summary of Oryx build
remote: Parsing the build logs
remote: Found 0 issue(s)
remote:
remote: Build Summary :
remote: ===============
remote: Errors (0)
remote: Warnings (0)
remote:
remote: Triggering recycle (preview mode disabled).
remote: Deployment successful. deployer = deploymentPath =
remote: Deployment Logs : 'https://glados9l.scm.azurewebsites.net/newui/jsonviewer?view_url=/api/deployments/ef2b3e8ce9341d66fa5e64826721e09085dbe214/log'
To <a href="https://myplan.scm.azurewebsites.net/Glados9L.git" rel="nofollow noreferrer">https://myplan.scm.azurewebsites.net/Glados9L.git</a></p>
<ul>
<li>[new branch] main -> main</li>
</ul>
<pre><code>root@9dcf7762daa9:/home# php -i | grep sqlsrv
Cannot load Zend OPcache - it was already loaded
root@9dcf7762daa9:/home# odbcinst -j
unixODBC 2.3.7
DRIVERS............: /etc/odbcinst.ini
SYSTEM DATA SOURCES: /etc/odbc.ini
FILE DATA SOURCES..: /etc/ODBCDataSources
USER DATA SOURCES..: /root/.odbc.ini
SQLULEN Size.......: 8
SQLLEN Size........: 8
SQLSETPOSIROW Size.: 8
root@9dcf7762daa9:/home# php -v
Cannot load Zend OPcache - it was already loaded
PHP 8.1.6 (cli) (built: Aug 17 2022 07:43:32) (NTS)
Copyright (c) The PHP Group
Zend Engine v4.1.6, Copyright (c) Zend Technologies
with Zend OPcache v8.1.6, Copyright (c), by Zend Technologies
root@9dcf7762daa9:/home#
</code></pre>
| [
{
"answer_id": 74239823,
"author": "Nicolas",
"author_id": 20361052,
"author_profile": "https://Stackoverflow.com/users/20361052",
"pm_score": 0,
"selected": false,
"text": "try {\n $conn = new PDO(\"sqlsrv:server = tcp:delachauxrailtechbddserver.database.windows.net,1433; Database = ... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179927",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13318689/"
] |
74,179,936 | <p>There is a problem, I have a clickable element and if I want to click on a button in the element, then both of them will work, when I need only the button to work. Implementation via ReactJS. Button position absolute in element! Code example:</p>
<pre><code> <div onClick={() => alert(1)}>
...content
<button onClick={() => alert(2)}>Click me!</button>
</div>
</code></pre>
| [
{
"answer_id": 74180000,
"author": "Apostolos",
"author_id": 1121008,
"author_profile": "https://Stackoverflow.com/users/1121008",
"pm_score": 2,
"selected": true,
"text": "event.stopPropagation();"
},
{
"answer_id": 74180006,
"author": "shurikation",
"author_id": 1940726... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179936",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8528301/"
] |
74,179,948 | <p>Let say I supply R with a color name <code>'#023e8a'</code></p>
<p>Now I want to get 5 following color names with alpha values as <code>c(0.8, 0.6, 0.5, 0.3, 0.2)</code>, which will be passed to <code>ggplot</code> as <code>fill</code> aesthetics.</p>
<p>Is there any function available in <code>R</code> or <code>ggplot</code> to achieve this? I know that in <code>ggplot</code> I could pass alpha values in any layer, but I want to get specific names of the color shades.</p>
<p>Any pointer will be very appreciated.</p>
| [
{
"answer_id": 74180015,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 2,
"selected": false,
"text": "scales::alpha"
},
{
"answer_id": 74180022,
"author": "stefan",
"author_id": 12993861,
"author_pro... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179948",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20141993/"
] |
74,179,969 | <p>how do i set the virtual terminal size with shell_exec() ? i tried</p>
<pre class="lang-php prettyprint-override"><code>function shell_exec_with_size(string $cmd, int $columns = 999, int $rows = 999): string
{
$cmd = '/bin/bash -c ' . escapeshellarg("stty columns {$columns}; stty rows {$rows};{$cmd}");
return shell_exec($cmd);
}
</code></pre>
<p>but that seems to have no effect, at least the columns property wasn't actually applied (don't know if the rows property was set or not)..</p>
<p>having a problem with <code>yum check-updates</code> changing the format depending on column size, with a "small" column size and a long update name, the format is</p>
<pre><code>python-devel.x86_64 2.7.18-1.amzn2.0.5 amzn2-core
python-libs.x86_64 2.7.18-1.amzn2.0.5 amzn2-core
python-pillow.x86_64 2.0.0-23.gitd1c6db8.amzn2.0.1
amzn2-core
</code></pre>
<p>(where python-pillow's update name <code>2.0.0-23.gitd1c6db8.amzn2.0.1</code> is too long), but with a large terminal size it's instead printed as</p>
<pre><code>python.x86_64 2.7.18-1.amzn2.0.5 amzn2-core
python-devel.x86_64 2.7.18-1.amzn2.0.5 amzn2-core
python-libs.x86_64 2.7.18-1.amzn2.0.5 amzn2-core
python-pillow.x86_64 2.0.0-23.gitd1c6db8.amzn2.0.1 amzn2-core
python2-rpm.x86_64 4.11.3-48.amzn2.0.2 amzn2-core
</code></pre>
<p>and im trying to parse the list programmatically, so specifying the terminal size would help get a consistent format from <code>yum check-updates</code>... also i have checked if yum perhaps separates the properties with tabs or something: it doesn't. it just seem to separate the properties with spaces, or newline and spaces, depending on terminal size.</p>
| [
{
"answer_id": 74180015,
"author": "Maël",
"author_id": 13460602,
"author_profile": "https://Stackoverflow.com/users/13460602",
"pm_score": 2,
"selected": false,
"text": "scales::alpha"
},
{
"answer_id": 74180022,
"author": "stefan",
"author_id": 12993861,
"author_pro... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1067003/"
] |
74,179,973 | <p>I can not come up with syntax to get the results in order with unions.
What I am after is that if the first union has a result, it must appear first, if second one has a result, it must appear second and so on so forth..</p>
<pre><code>select a.id, a.id2
from Table1 a
where a.id3=(select c1.id1 from table c1 where c1.name='A') --Must be first result
UNION
select distinct a.id, a.id2
from Table1 a
where a.id3=(select c2.id2 from table c2 where c2.name='B')--Must be second result (if exists)
UNION
select distinct a.id, a.id2
from Table1 a
where a.id3=(select c3.id3 from table c3 where c3.name='C')--Must be 3rd result (if exists)
</code></pre>
<p>Now if second union does not have a result, the 3rd one will be second..
Can some one please guide?</p>
| [
{
"answer_id": 74180020,
"author": "Larnu",
"author_id": 2029983,
"author_profile": "https://Stackoverflow.com/users/2029983",
"pm_score": 3,
"selected": false,
"text": "JOIN"
},
{
"answer_id": 74180038,
"author": "Fnaxiom",
"author_id": 5534881,
"author_profile": "ht... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1063108/"
] |
74,179,976 | <p>I am currently trying to run a program in GPS and this is my first time trying to use Ada and don't quite understand some things to it. I have some code that was told was supposed to run but can't seem to get it running. When I try to compile it or run the code, I keep getting an error message: "end of file expected. file can only be one compilation unit." I also included a photo to help show the problem. I'd appreciate any tips or hints on how to solve this please!</p>
<p><a href="https://i.stack.imgur.com/JkhNV.jpg" rel="nofollow noreferrer">enter image description here</a></p>
| [
{
"answer_id": 74180974,
"author": "Niklas Holsti",
"author_id": 15004077,
"author_profile": "https://Stackoverflow.com/users/15004077",
"pm_score": 2,
"selected": false,
"text": "generic\n ...\npackage CircularQueue is\n"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20320953/"
] |
74,179,979 | <p>I've been following the Livewire docs and screencasts to build my new app, but I could be doing something wrong because the <code><head></code> tag is been included twice.</p>
<p>Here is my code:</p>
<p><strong>routes\web.php</strong></p>
<pre class="lang-php prettyprint-override"><code><?php
use Illuminate\Support\Facades\Route;
use App\Http\Livewire\User\All as UserAll;
Route::get('/', function () {
return view('welcome');
});
Route::middleware([
'auth:sanctum',
config('jetstream.auth_session'),
'verified'
])->group(function () {
Route::get('/dashboard', function () {
return view('dashboard');
})->name('dashboard');
// Users
Route::prefix('users')->group(function () {
Route::get('/', UserAll::class)->name('users-all');
});
});
</code></pre>
<p><strong>App\Http\Livewire\User\All.php</strong></p>
<pre class="lang-php prettyprint-override"><code><?php
namespace App\Http\Livewire\User;
use Livewire\WithPagination;
use App\Models\User;
use Livewire\Component;
class All extends Component
{
use WithPagination;
public $search = '';
public function render()
{
return view('livewire.user.all', [
'users' => User::search('name', $this->search)->paginate(10)
]);
}
}
</code></pre>
<p><strong>App\View\Components\UserLayout.php</strong></p>
<pre class="lang-php prettyprint-override"><code><?php
namespace App\View\Components;
use Illuminate\View\Component;
class UserLayout extends Component
{
/**
* Get the view / contents that represent the component.
*
* @return \Illuminate\Contracts\View\View|\Closure|string
*/
public function render()
{
return view('layouts.user');
}
}
</code></pre>
<p><strong>resourse\views\layoutsuser.blade.php</strong></p>
<pre class="lang-php prettyprint-override"><code><!DOCTYPE html>
<html lang="{{ str_replace('_', '-', app()->getLocale()) }}">
<head>
<meta charset="utf-8">
<meta name="viewport" content="width=device-width, initial-scale=1">
<meta name="csrf-token" content="{{ csrf_token() }}">
<title>{{ config('app.name', 'Laravel') }}</title>
<!-- Fonts -->
<link rel="stylesheet" href="https://fonts.bunny.net/css2?family=Nunito:wght@400;600;700&display=swap">
<!-- Scripts -->
@vite(['resources/css/app.css', 'resources/js/app.js'])
<!-- Styles -->
@livewireStyles
</head>
<body class="font-sans antialiased dashboard">
<x-jet-banner />
<div class="min-h-screen bg-gray-100">
@livewire('navigation-menu')
<!-- Page Heading -->
@if (isset($header))
<header class="bg-white shadow">
<div class="max-w-7xl mx-auto py-6 px-4 sm:px-6 lg:px-8">
{{ $header }}
</div>
</header>
@endif
<!-- Page Content -->
<main>
{{ $slot }}
</main>
</div>
@stack('modals')
@livewireScripts
</body>
</html>
</code></pre>
<p><strong>resourse\views\livewire\user\all.blade.php</strong></p>
<pre class="lang-php prettyprint-override"><code><x-user-layout>
<x-slot name="header">
<h2 class="font-semibold text-xl text-gray-800 leading-tight">
{{ __('Users') }}
</h2>
<input wire:model="search" type="text">
</x-slot>
<div class="py-12">
<div class="max-w-7xl mx-auto sm:px-6 lg:px-8">
<div class="bg-white overflow-hidden shadow-xl sm:rounded-lg">
<div class="bg-white overflow-hidden shadow-sm sm:rounded-lg">
<div class="p-6 bg-white border-b border-gray-200">
<table>
<thead>
<tr>
<th>{{ __('ID') }}</th>
<th>{{ __('Name') }}</th>
<th>{{ __('Email') }}</th>
<th>{{ __('Date') }}</th>
</tr>
</thead>
<tbody>
@foreach ($users as $user)
<tr>
<td>{{ $user->id }}</td>
<td>{{ $user->name }}</td>
<td>{{ $user->email }}</td>
<td>{{ $user->created_at->format('M, d Y') }}</td>
</tr>
@endforeach
</tbody>
</table>
<div class="my-7">
{{ $users->links() }}
</div>
</div>
</div>
</div>
</div>
</div>
</x-user-layout>
</code></pre>
<p>If I remove the <code><x-user-layout></code> tag in the blade, the problem seems to be fixed, but then livewire doesn't work.</p>
<p>I've tried many solutions, but nothig works. What am I doing wrong here?</p>
<p>Thanks a lot in advance.</p>
| [
{
"answer_id": 74180974,
"author": "Niklas Holsti",
"author_id": 15004077,
"author_profile": "https://Stackoverflow.com/users/15004077",
"pm_score": 2,
"selected": false,
"text": "generic\n ...\npackage CircularQueue is\n"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74179979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11516475/"
] |
74,180,010 | <p>I need to write in python3 a function that fills the bigger square with smaller squares basing on the input.</p>
<p>The input is a list of positive integers. Each integer is the number of squares per row. So the list [3, 8, 5, 2] means I got 4 rows of squares where first one has 3 squares, second one 8 and so on. All squares in all rows are of the same size.</p>
<p>The output should be description of rows distribution in the form of list of lists.</p>
<p>The thing is that on the output there can not be empty rows. So effectively the number of columns can not be greater than the number of rows. The rows can be split though into two or more rows. So for example for the list [3, 8, 5, 2] the function should return [[3], [5, 3], [5], [2]]:</p>
<pre><code>AAA
BBBBB
BBB
CCCCC
DD
</code></pre>
<p>and for input [14,13,2,12] it should return [[7,7], [7,6], [2], [7,5]]:</p>
<pre><code>AAAAAAA
AAAAAAA
BBBBBBB
BBBBBB
CC
DDDDDDD
DDDDD
</code></pre>
<p>As we can see, the number of rows and columns is in both examples equal. Of course it's not always possible but the lesser difference between the number of columns and rows, the more efficient the algorythm is - the better the square is filled. In general we aim to get as many columns as possible and as little rows as possible.</p>
<p>And here is the issue - the above examples used 4 input rows - the input list can have a lot of more elements (for example 200 input rows). And the problem is to find optimial way to split the rows (for example if i should split 18 as 9+9 or 6+6+6 or 7+7+4 or maybe 5+5+5+3). Because every time i split the rows basing on available columns (that depend on the number of used rows), I get more output rows and therefore I am able to use more additional available columns - and I fall into some weird loop or recursion.</p>
<p>I'm sorry if there is some easy solution that I don't see and thank you in advance for help <3</p>
<p>EDIT: Here I include example function that simply ignores the fact that the number of rows increases and just treats the number of input rows as maximum amount of columns possible:</p>
<pre><code>def getSquare(x):
output = list()
ln = len(x)
for i in x:
if i <= ln:
output.append([i])
else:
split = list()
nrows = i // ln
for j in range(nrows):
split.append(ln)
if i % ln:
split.append(i % ln)
output.append(split)
return output
print(getSquare([14, 13, 2, 12]))
# returns [[4, 4, 4, 2], [4, 4, 4, 1], [2], [4, 4, 4]]
# so 4 columns and 12 rows
# columns - maximum number in the matrix
# rows - number of all elements in the matrix (length of flattened output)
# while it should return: [[7,7], [7,6], [2], [7,5]]
# so 7 columns and 7 rows
#(nr of columns should be not larger but as close to the number of rows as possible)
</code></pre>
<p>EDIT2: It doesn't have to return perfect square - just something as close to square as possible - for example for [4,3,3] it should return [[3,1],[3]
,[3]] while for extreme cases like [1,1,1] it should just return [[1],[1],[1]]</p>
| [
{
"answer_id": 74180974,
"author": "Niklas Holsti",
"author_id": 15004077,
"author_profile": "https://Stackoverflow.com/users/15004077",
"pm_score": 2,
"selected": false,
"text": "generic\n ...\npackage CircularQueue is\n"
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180010",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9630049/"
] |
74,180,063 | <p>Any Idea how we can design this with dart?</p>
<p>I've tried using using stacks and containers but I'm not getting a so good result?</p>
<p>Or any package for this?</p>
<p><a href="https://i.stack.imgur.com/y3DOQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/y3DOQ.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74387072,
"author": "hamzat_yhs",
"author_id": 16886036,
"author_profile": "https://Stackoverflow.com/users/16886036",
"pm_score": 0,
"selected": false,
"text": "CustomPaint(\n size: Size(screenWidth * 0.9, 500),\n painter: DemoPainter(color: Colors.white),\n ),\n... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180063",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16886036/"
] |
74,180,074 | <p>I want to bring users who have not updated their salary information in the last 1 year. BUT WITH ORM not For Loop.</p>
<pre><code>from simple_history.models import HistoricalRecords
class User(AbstractUser):
...
salary_expectation = models.IntegerField()
history = HistoricalRecords(cascade_delete_history=True)
</code></pre>
<p>################################################################</p>
<pre><code> User.objects.filter(# MAGIC ) # Get users who have NOT updated their salary information in the last year
</code></pre>
| [
{
"answer_id": 74180591,
"author": "LeTorky",
"author_id": 19401302,
"author_profile": "https://Stackoverflow.com/users/19401302",
"pm_score": 2,
"selected": false,
"text": "sub_query = ~Q(history__history_date__lte= \"Replace with end of date\", history__history_date__gte= \"Replace wi... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15423388/"
] |
74,180,100 | <p>Based on this Article <a href="https://medium.com/@Taha_Shashtari/an-easy-way-to-detect-clicks-outside-an-element-in-vue-1b51d43ff634" rel="nofollow noreferrer">https://medium.com/@Taha_Shashtari/an-easy-way-to-detect-clicks-outside-an-element-in-vue-1b51d43ff634</a>
i implemented the same methodology of the directive for detecting outside element click, at first i had to change things as vue 2 directives have been changed in vue 3, but i got so far that:</p>
<ol>
<li>When i click the Icon to Toggle the Box -> The box is shown</li>
<li>When i click outside the Box -> The box is toggled</li>
</ol>
<p><strong>The only thing that isn't working is when i click inside the box itself it gets toggled again, which isnt suppose to happen.</strong></p>
<p>Code</p>
<p>Directive:</p>
<pre><code>let handleOutsideClick;
const closable = {
beforeMount(el, binding, vnode) {
handleOutsideClick = (e) => {
e.stopPropagation();
const { handler, exclude } = binding.value;
let clickedOnExcludedEl = false;
exclude.forEach((id) => {
if (!clickedOnExcludedEl) {
const excludedEl = document.getElementById(id);
clickedOnExcludedEl = excludedEl.contains(e.target);
}
});
if (!el.contains(e.target) && !clickedOnExcludedEl) {
binding.instance[handler]();
}
};
document.addEventListener("click", handleOutsideClick);
document.addEventListener("touchstart", handleOutsideClick);
},
afterMount() {
document.removeEventListener("click", handleOutsideClick);
document.removeEventListener("touchstart", handleOutsideClick);
},
};
export default closable;
</code></pre>
<p>PS: I changed the usage of refs into IDs</p>
<p>CartIcon:</p>
<pre><code><template>
<div
id="checkoutBoxHandler"
ref="checkoutBoxHandler"
@click="showPopup = !showPopup"
class="cart-icon"
>
<font-awesome-icon icon="fa-solid fa-cart-shopping" />
<span id="cart-summary-item">{{ cartItemsCount }}</span>
<div
v-show="showPopup"
v-closable='{
exclude: ["checkoutBox","checkoutBoxHandler"],
handler: "onClose",
}'
id="checkoutBox"
>
<CheckOutBox v-if="this.userCart" :userCart="this.userCart"></CheckOutBox>
</div>
</div>
</template>
</code></pre>
<p>onClose handler:</p>
<pre><code> onClose() {
this.showPopup = false;
},
</code></pre>
<p>Can anyone see what i might be doing wrong here or maybe missing?</p>
<p>Thanks in advance</p>
<p><strong>EDIT after Turtle Answers:</strong></p>
<p>This is the Code i m using:</p>
<p>Directive:</p>
<pre><code>const clickedOutsideDirective = {
mounted(element, binding) {
const clickEventHandler = (event) => {
event.stopPropagation();
console.log(element.contains(event.target))//True on click on the box
if (!element.contains(event.target)) {
binding.value(event)
}
}
element.__clickedOutsideHandler__ = clickEventHandler
document.addEventListener("click", clickEventHandler)
},
unmounted(element) {
document.removeEventListener("click", element.__clickedOutsideHandler__)
},
}
export default clickedOutsideDirective
</code></pre>
<p>Component:</p>
<pre><code><div
id="checkoutBoxHandler"
ref="checkoutBoxHandler"
@click="showPopup = !showPopup"
v-closable='onClose'
class="cart-icon"
>
<font-awesome-icon icon="fa-solid fa-cart-shopping" />
<span id="cart-summary-item">{{ cartItemsCount }}</span>
<div
v-show="showPopup"
ref="checkoutBox"
id="checkoutBox"
>
<CheckOutBox :userCart="this.userCart"></CheckOutBox>
</div>
</div>
</code></pre>
<p>The box is being displayed but on click on the box it still disappear</p>
| [
{
"answer_id": 74180591,
"author": "LeTorky",
"author_id": 19401302,
"author_profile": "https://Stackoverflow.com/users/19401302",
"pm_score": 2,
"selected": false,
"text": "sub_query = ~Q(history__history_date__lte= \"Replace with end of date\", history__history_date__gte= \"Replace wi... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180100",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15100059/"
] |
74,180,105 | <p>Thats my data. I want to copy B2:M9 and insert it to P2. Furher, I want to copy B13:M20 and paste it to P2. Then I want to copy B24:M31 and paste it to P2 and so on.
Does anyone have an idea how I can do it?</p>
<p><a href="https://i.stack.imgur.com/Hz7mM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Hz7mM.png" alt="My data" /></a></p>
<p>Thank you!</p>
| [
{
"answer_id": 74180591,
"author": "LeTorky",
"author_id": 19401302,
"author_profile": "https://Stackoverflow.com/users/19401302",
"pm_score": 2,
"selected": false,
"text": "sub_query = ~Q(history__history_date__lte= \"Replace with end of date\", history__history_date__gte= \"Replace wi... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180105",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9763867/"
] |
74,180,125 | <p>i made a form in django with one field required (imagefield) but when I fill it by selecting an image, once I fill it it considers that the form is not valid and asks to fill it again I don't understand why, here is my code below:</p>
<p>view.py:</p>
<pre><code>def success(request):
return HttpResponse('successfully uploaded')
def contact(request, plage_name):
name = plage_name
plage = Spot.objects.get(name__iexact=name)
if request.method == 'POST':
form = ContactUsForm(request.FILES) # ajout d’un nouveau formulaire ici
if form.is_valid():
print("it's valide")
plage.photo = form.cleaned_data['photo']
plage.save()
return redirect('success')
else:
form = ContactUsForm()
return render(request,
'pages/Testform.html',
{'form': form}) # passe ce formulaire au gabarit
</code></pre>
<p>form.py</p>
<pre><code>class ContactUsForm(forms.Form):
photo = forms.ImageField(required=True)
</code></pre>
<p>html</p>
<pre><code><form action="" method="post" novalidate>
{% csrf_token %}
{{ form }}
<input type="submit" value="Envoyer">
</form>
</code></pre>
<p>Url.py</p>
<pre><code>urlpatterns = [
path('contact-us/<path:plage_name>', views.contact, name='contact'),
]
</code></pre>
| [
{
"answer_id": 74180591,
"author": "LeTorky",
"author_id": 19401302,
"author_profile": "https://Stackoverflow.com/users/19401302",
"pm_score": 2,
"selected": false,
"text": "sub_query = ~Q(history__history_date__lte= \"Replace with end of date\", history__history_date__gte= \"Replace wi... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20320977/"
] |
74,180,132 | <p>I would like to use <code>awk</code> to filter out a multi valued column.</p>
<p>My data is two columned with the delimiter <code>;</code>. The second column has three float values separated with white spaces.</p>
<pre><code>randUni15799:1;0.00 0.00 0.00
randUni1785:1;0.00 0.00 0.00
randUni18335:1;0.00 0.00 0.00
randUni18368:1;223.67 219.17 0.00
randUni18438:1;43.71 38.71 1.52
</code></pre>
<p>What I want to achieve is the following. I want to filter all rows that the first and second value of the second column is bigger than 200.</p>
<pre><code>randUni18368:1;223.67 219.17 0.00
</code></pre>
<p>Update:
With help from the comments, I tried this and worked</p>
<pre><code>awk -F ";" '{split($2, a, " "); if (a[1] > 200 && a[2] > 200) print}'
</code></pre>
| [
{
"answer_id": 74180591,
"author": "LeTorky",
"author_id": 19401302,
"author_profile": "https://Stackoverflow.com/users/19401302",
"pm_score": 2,
"selected": false,
"text": "sub_query = ~Q(history__history_date__lte= \"Replace with end of date\", history__history_date__gte= \"Replace wi... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180132",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15951758/"
] |
74,180,139 | <p>This is my code, where I am trying to show the values from the remote API which I am trying to fetch via a .php file in Wordpress.</p>
<pre><code><?php
try {
$response = wp_remote_get( 'MYURLHERE', array(
'headers' => array(
'Accept' => 'application/json',
)
) );
if ( ( !is_wp_error($response)) && (200 === wp_remote_retrieve_response_code( $response ) ) ) {
$result = json_decode( wp_remote_retrieve_body( $response, true) );
echo $result['data']['0']['id'];
}
} catch( Exception $ex ) {
//Handle Exception.
}
?>
</code></pre>
<p>Getting the following error:</p>
<pre><code>Fatal error: Uncaught Error: Cannot use object of type stdClass as array
</code></pre>
<p>What am I doing wrong?</p>
<p>This should be the array:</p>
<pre><code>Array
(
[data] => Array
(
[0] => Array
(
[id] => 124
[name] => MyName
[supertype] => Mso
</code></pre>
| [
{
"answer_id": 74180243,
"author": "thephper",
"author_id": 1794000,
"author_profile": "https://Stackoverflow.com/users/1794000",
"pm_score": 0,
"selected": false,
"text": "$result"
},
{
"answer_id": 74180270,
"author": "Yoshi Varela",
"author_id": 16366067,
"author_p... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2524335/"
] |
74,180,152 | <p><a href="https://en.cppreference.com/w/c/language/arithmetic_types" rel="noreferrer">cppreference.com</a> states that <code>char</code> is</p>
<blockquote>
<p>Equivalent to either <code>signed char</code> or <code>unsigned char</code> [...], but <code>char</code> is a distinct type, different from both <code>signed char</code> and <code>unsigned char</code></p>
</blockquote>
<p>I assume this means that a <code>char</code> can hold exactly the same values as either <code>unsigned char</code> or <code>signed char</code>, but is not compatible with either. Why was it decided to work this way? Why does unqualified <code>char</code> not denote a <code>char</code> of the platform-appropriate signedness, like with the other integer types, where <code>int</code> denotes exactly the same type as <code>signed int</code>?</p>
| [
{
"answer_id": 74295907,
"author": "klutt",
"author_id": 6699433,
"author_profile": "https://Stackoverflow.com/users/6699433",
"pm_score": 3,
"selected": false,
"text": "char"
},
{
"answer_id": 74296241,
"author": "Chris Dodd",
"author_id": 16406,
"author_profile": "h... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6281090/"
] |
74,180,175 | <p>From <a href="https://stackoverflow.com/a/45522405/6528261">this SO answer</a> I'm trying to build a text replace function.</p>
<p>The problem is that it can't do multi level. Or at least I don't know how.</p>
<p>If I have this query:</p>
<pre class="lang-cs prettyprint-override"><code>var foo = await _dbContext.Foos.Include(x => x.Bar).AsNoTracking().FirstOrDefaultAsync(x => x.Id == someId);
</code></pre>
<p>I can do:</p>
<pre class="lang-cs prettyprint-override"><code>var fooName = GetPropertyValue(foo, "Name");
</code></pre>
<p>But I can't do:</p>
<pre class="lang-cs prettyprint-override"><code>var barName = GetPropertyValue(foo, "Bar.Name");
</code></pre>
<p>Is that possible?</p>
<pre class="lang-cs prettyprint-override"><code>public class Foo
{
public string Name {get;set;}
public Guid BarId {get;set;}
public Bar Bar {get;set;}
}
public class Bar
{
public string Name {get;set;}
}
</code></pre>
| [
{
"answer_id": 74295907,
"author": "klutt",
"author_id": 6699433,
"author_profile": "https://Stackoverflow.com/users/6699433",
"pm_score": 3,
"selected": false,
"text": "char"
},
{
"answer_id": 74296241,
"author": "Chris Dodd",
"author_id": 16406,
"author_profile": "h... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180175",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6528261/"
] |
74,180,183 | <p>I want to achive do cumulate values per day per product and reset the value for every new year.</p>
<p>What I have:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: center;">Date</th>
<th style="text-align: center;">productID</th>
<th style="text-align: center;">value</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">01.01.2022</td>
<td style="text-align: center;">1270</td>
<td style="text-align: center;">30000</td>
</tr>
<tr>
<td style="text-align: center;">01.01.2022</td>
<td style="text-align: center;">1280</td>
<td style="text-align: center;">200000</td>
</tr>
<tr>
<td style="text-align: center;">02.01.2022</td>
<td style="text-align: center;">1280</td>
<td style="text-align: center;"> -50</td>
</tr>
<tr>
<td style="text-align: center;">01.02.2022</td>
<td style="text-align: center;">1280</td>
<td style="text-align: center;">100</td>
</tr>
<tr>
<td style="text-align: center;">01.02.2022</td>
<td style="text-align: center;">1280</td>
<td style="text-align: center;">200</td>
</tr>
<tr>
<td style="text-align: center;">01.02.2022</td>
<td style="text-align: center;">1270</td>
<td style="text-align: center;">-20</td>
</tr>
<tr>
<td style="text-align: center;">01.03.2022</td>
<td style="text-align: center;">1270</td>
<td style="text-align: center;">80</td>
</tr>
<tr>
<td style="text-align: center;">29.12.2022</td>
<td style="text-align: center;">1270</td>
<td style="text-align: center;">100</td>
</tr>
<tr>
<td style="text-align: center;">29.12.2022</td>
<td style="text-align: center;">1280</td>
<td style="text-align: center;">10</td>
</tr>
<tr>
<td style="text-align: center;">31.12.2022</td>
<td style="text-align: center;">1270</td>
<td style="text-align: center;">35</td>
</tr>
<tr>
<td style="text-align: center;">31.12.2022</td>
<td style="text-align: center;">1270</td>
<td style="text-align: center;">5</td>
</tr>
<tr>
<td style="text-align: center;">01.01.2023</td>
<td style="text-align: center;">1270</td>
<td style="text-align: center;">50000</td>
</tr>
<tr>
<td style="text-align: center;">01.01.2023</td>
<td style="text-align: center;">1280</td>
<td style="text-align: center;">100000</td>
</tr>
<tr>
<td style="text-align: center;">04.01.2023</td>
<td style="text-align: center;">1270</td>
<td style="text-align: center;">50</td>
</tr>
<tr>
<td style="text-align: center;">06.01.2023</td>
<td style="text-align: center;">1280</td>
<td style="text-align: center;">-100</td>
</tr>
</tbody>
</table>
</div>
<p>Value should be calculated cumulative per day with a fresh start from each year and per productID.</p>
<p>What I want as a measure is Cumulative Per Year.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: center;">Date</th>
<th style="text-align: center;">productID</th>
<th style="text-align: center;">value</th>
<th style="text-align: center;">Cumulative per Year</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">01.01.2022</td>
<td style="text-align: center;">1270</td>
<td style="text-align: center;">30000</td>
<td style="text-align: center;">30000</td>
</tr>
<tr>
<td style="text-align: center;">01.01.2022</td>
<td style="text-align: center;">1280</td>
<td style="text-align: center;">200000</td>
<td style="text-align: center;">200000</td>
</tr>
<tr>
<td style="text-align: center;">02.01.2022</td>
<td style="text-align: center;">1280</td>
<td style="text-align: center;"> -50</td>
<td style="text-align: center;">199950</td>
</tr>
<tr>
<td style="text-align: center;">01.02.2022</td>
<td style="text-align: center;">1280</td>
<td style="text-align: center;">100</td>
<td style="text-align: center;">200050</td>
</tr>
<tr>
<td style="text-align: center;">01.02.2022</td>
<td style="text-align: center;">1280</td>
<td style="text-align: center;">200</td>
<td style="text-align: center;">200250</td>
</tr>
<tr>
<td style="text-align: center;">01.02.2022</td>
<td style="text-align: center;">1270</td>
<td style="text-align: center;">-20</td>
<td style="text-align: center;">29980</td>
</tr>
<tr>
<td style="text-align: center;">01.03.2022</td>
<td style="text-align: center;">1270</td>
<td style="text-align: center;">80</td>
<td style="text-align: center;">30060</td>
</tr>
<tr>
<td style="text-align: center;">29.12.2022</td>
<td style="text-align: center;">1270</td>
<td style="text-align: center;">100</td>
<td style="text-align: center;">30160</td>
</tr>
<tr>
<td style="text-align: center;">29.12.2022</td>
<td style="text-align: center;">1280</td>
<td style="text-align: center;">10</td>
<td style="text-align: center;">200260</td>
</tr>
<tr>
<td style="text-align: center;">31.12.2022</td>
<td style="text-align: center;">1270</td>
<td style="text-align: center;">35</td>
<td style="text-align: center;">30195</td>
</tr>
<tr>
<td style="text-align: center;">31.12.2022</td>
<td style="text-align: center;">1270</td>
<td style="text-align: center;">5</td>
<td style="text-align: center;">30200</td>
</tr>
<tr>
<td style="text-align: center;">01.01.2023</td>
<td style="text-align: center;">1270</td>
<td style="text-align: center;">50000</td>
<td style="text-align: center;">50000</td>
</tr>
<tr>
<td style="text-align: center;">01.01.2023</td>
<td style="text-align: center;">1280</td>
<td style="text-align: center;">100000</td>
<td style="text-align: center;">100000</td>
</tr>
<tr>
<td style="text-align: center;">04.01.2023</td>
<td style="text-align: center;">1270</td>
<td style="text-align: center;">50</td>
<td style="text-align: center;">50050</td>
</tr>
<tr>
<td style="text-align: center;">06.01.2023</td>
<td style="text-align: center;">1280</td>
<td style="text-align: center;">-100</td>
<td style="text-align: center;">99900</td>
</tr>
</tbody>
</table>
</div>
<p>What I tried:</p>
<pre><code>Cumulative per Year =
VAR varProductID = SELECTEDVALUE(MyTable[productID])
VAR varYear = SELECTEDVALUE(MyTable[date])
CALCULATE(SUM(MyTable[Value],
FILTER(MyTable,
varProductID = MyTable[productID] &&
varYear = MyTable[date]
)
What I also tried is STARTOFYEAR() and ENDOFYEAR() to know when the cumulative should reset but I not meant to work with selectedvalue() also for some reason MyTable[date].Year wont work.
</code></pre>
<p>Thanks for any help.</p>
| [
{
"answer_id": 74186896,
"author": "Kasia Wichrowska",
"author_id": 7291306,
"author_profile": "https://Stackoverflow.com/users/7291306",
"pm_score": 0,
"selected": false,
"text": "Cummulative Total=TOTALYTD(SUM(Table[Value]),DateTable[Date])\n"
},
{
"answer_id": 74187067,
"a... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8011460/"
] |
74,180,194 | <p>I have already installed ionic with the command <code>npm install -g @ionic/cli native-run cordova-res</code> and then I did this command ng add @ionic/angular and it did help that it added the line <code>"@ionic/angular": "^6.3.2 ",</code>
in <code>package.json</code> but when I add import of ionic
<code>import {IonicModule} from '@ionic/angular'</code>
I get dozens of bugs . '.node_modules/@ionic/angular/directives/proxies.d.ts(725,21): error TS2694: Namespace '"C:/Project/MCProject/MCProject-client/node_modules/@angular/core/core"' has no exported member 'ɵɵComponentDeclaration'...
and more
what can i do this import without this bug??? Please help me to solve the problem</p>
| [
{
"answer_id": 74186896,
"author": "Kasia Wichrowska",
"author_id": 7291306,
"author_profile": "https://Stackoverflow.com/users/7291306",
"pm_score": 0,
"selected": false,
"text": "Cummulative Total=TOTALYTD(SUM(Table[Value]),DateTable[Date])\n"
},
{
"answer_id": 74187067,
"a... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180194",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19344062/"
] |
74,180,211 | <p>I have 2 entities: Post and Comments and i wanna display all comments by post</p>
<p>Entity Post</p>
<pre><code>@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
public class Post {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idPost;
@CreationTimestamp
private Date createdAt;
private String content;
@OneToMany(mappedBy = "post",fetch=FetchType.LAZY)
@JsonIgnore
private List<Comment> comments= new CopyOnWriteArrayList<>();
}
</code></pre>
<p>And entity Comment</p>
<pre><code>@Data
@NoArgsConstructor
@AllArgsConstructor
@Entity
public class Comment {
@Id
@GeneratedValue(strategy = GenerationType.IDENTITY)
private Long idComment;
private String content;
@ManyToOne(fetch=FetchType.LAZY)
@JoinColumn(name = "postIdPost", referencedColumnName = "idPost")
private Post post;
}
</code></pre>
<p>and this is in angular</p>
<pre><code>import { User } from "./user";
import { Comment } from "./comment";
import { Like } from "./like";
export class Post {
idPost!: number;
user!:User;
createdAt!:Date;
content!:string;
photo!:string;
comments!: Comment[];
likes:Like[]=[];
}
</code></pre>
<p>when i try to display comments by post it never displayed even when i try to access to comments length by {{posts.comments.length}} it shows nothing</p>
<pre><code><ng-container *ngFor="let p of posts">
<div class="card" >
<div> p.content </div>
.
.
.
<ul class="comment-wrap list-unstyled" *ngFor="let com of p.comments ">
<p class="small mb-0">{{com.content}}.</p>
</ul>
</code></pre>
| [
{
"answer_id": 74186896,
"author": "Kasia Wichrowska",
"author_id": 7291306,
"author_profile": "https://Stackoverflow.com/users/7291306",
"pm_score": 0,
"selected": false,
"text": "Cummulative Total=TOTALYTD(SUM(Table[Value]),DateTable[Date])\n"
},
{
"answer_id": 74187067,
"a... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180211",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16292904/"
] |
74,180,224 | <p>I'm trying to design an interface in Python using Tkinter. The interface should be divided into five rows. In each of these row, a button or a frame/label frame shold be accomodate. In the case of a frame/label frame row, other widgets will be hosted. So I decided to define a frame that will act as a container of buttons and frames/label frames, and configured in 5 rows of equal weight. Then I added a label frame at row=0 and a button at row=1. Why only the button appears?</p>
<pre><code>import sys
import tkinter as tk
import tkinter.ttk as ttk
from tkinter.constants import *
# %% ROOT
root = tk.Tk()
root.geometry("710x630+410+100")
root.minsize(120, 1)
root.resizable(1, 1)
root.title("myGUI")
root.configure(background="#d9d9d9")
root.configure(highlightbackground="#d9d9d9")
root.configure(highlightcolor="black")
# %% EXTERNAL FRAME
ExtFrame = tk.Frame(root)
ExtFrame.place(relheight=1, relwidth=1)
# ExtFrame.configure(bg='blue')
ExtFrame.rowconfigure(0, weight=1)
ExtFrame.rowconfigure(1, weight=1)
ExtFrame.rowconfigure(2, weight=1)
ExtFrame.rowconfigure(3, weight=1)
ExtFrame.rowconfigure(4, weight=1)
ExtFrame.rowconfigure(5, weight=1)
# %% RESULTS FOLDER LOCATION
Labelframe_ResultsFolderLocation = tk.LabelFrame(ExtFrame)
Labelframe_ResultsFolderLocation.grid(row=0, padx=10, pady=10)
Labelframe_ResultsFolderLocation.configure(relief='groove')
Labelframe_ResultsFolderLocation.configure(text='''Results Folder Location''')
# %% BUTTON OPEN FILE
Button_OpenFile = tk.Button(ExtFrame)
Button_OpenFile.grid(row=1, padx=10, pady=10)
Button_OpenFile.configure(activebackground="#ececec")
Button_OpenFile.configure(activeforeground="#000000")
Button_OpenFile.configure(background="#d9d9d9")
Button_OpenFile.configure(compound='left')
Button_OpenFile.configure(disabledforeground="#a3a3a3")
Button_OpenFile.configure(foreground="#000000")
Button_OpenFile.configure(highlightbackground="#d9d9d9")
Button_OpenFile.configure(highlightcolor="black")
Button_OpenFile.configure(text='''OPEN FILE''')
root.mainloop()
</code></pre>
| [
{
"answer_id": 74180784,
"author": "Loxley",
"author_id": 19291069,
"author_profile": "https://Stackoverflow.com/users/19291069",
"pm_score": 2,
"selected": false,
"text": "height"
},
{
"answer_id": 74181045,
"author": "Tester",
"author_id": 20149606,
"author_profile"... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180224",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16389095/"
] |
74,180,283 | <p>I am working on a project called "Flash card". Does anyone know how to share the same object between more than two functions? It seems setting the variable as global is not the answer. May I know why it isn't? In my case, I want the same "dict2" to be used in Known(), Switch_Word() and Reset(), as it will be refilled the original data when Reset() is pressed. Then, it will be passed to Switch_Word() and Known() for further processing. I found out that there are different "dict2" when printing their ID.</p>
<pre><code>from tkinter import *
import pandas
import random
import copy
BACKGROUND_COLOR = "#B1DDC6"
dataframe = pandas.read_csv(r"C:\Users\User\Desktop\Python Visual Studio Code\100Days\Day31\flash-card-project-start\data\french_words.csv")
global dict
dict = dataframe.to_dict(orient="records")
print(len(dict))
global dict2
dict2 = copy.deepcopy(dict)
Current_Vocab = {}
def Switch_to_English():
canvas.itemconfig("Image",image=bg_image)
canvas.itemconfig("title",text="English",fill="white")
Current_Vocab_English = Current_Vocab["English"]
canvas.itemconfig("word",text=f"{Current_Vocab_English}",fill="white")
def Switch_Word():
global Current_Vocab
canvas.itemconfig("Image",image = ft_image)
Current_Vocab = random.choice(dict2)
Current_Vocab_French = Current_Vocab["French"]
canvas.itemconfig("title",text="French",fill = "black")
canvas.itemconfig("word",text=f"{Current_Vocab_French}", fill = "black")
window.after(3000,Switch_to_English)
def Known():
Switch_Word()
dict2.remove(Current_Vocab)
print(len(dict2))
print(id(dict2))
def Reset():
dict2 = copy.deepcopy(dict)
print(len(dict2))
print(id(dict2))
Switch_Word()
window = Tk()
window.title("Flashy")
window.config(padx=50, pady=50, bg=BACKGROUND_COLOR)
ft_image = PhotoImage(file= r"C:\Users\User\Desktop\Python Visual Studio Code\100Days\Day31\flash-card-project-start\images\card_front.png")
bg_image = PhotoImage(file= r"C:\Users\User\Desktop\Python Visual Studio Code\100Days\Day31\flash-card-project-start\images\card_back.png")
tick_image = PhotoImage(file= r"C:\Users\User\Desktop\Python Visual Studio Code\100Days\Day31\flash-card-project-start\images\right.png")
cross_image = PhotoImage(file= r"C:\Users\User\Desktop\Python Visual Studio Code\100Days\Day31\flash-card-project-start\images\wrong.png")
Rev = []
flip_timer = window.after(3000, func=Switch_Word)
canvas = Canvas(width=800, height = 526, highlightthickness=0)
canvas.create_image(400, 253, image=ft_image, tags = "Image")
canvas.create_text(400, 158, text="Title", font = ("Arial",40,"italic"), tags = "title")
canvas.create_text(400, 263, text="Word", font = ("Arial",60,"italic"), tags = "word")
canvas.config(bg=BACKGROUND_COLOR,highlightthickness=0)
canvas.grid(row=0,column=1)
tick_label = Label(image=tick_image, bg = BACKGROUND_COLOR, highlightthickness= 0)
tick_btn = Button(window, image=tick_image, command=Known)
tick_btn.grid(row=1,column=2)
cross_label = Label(image=cross_image, bg=BACKGROUND_COLOR, highlightthickness=0)
cross_btn = Button(window, image=cross_image, command=Switch_Word)
cross_btn.grid(row=1,column=0)
Reset_Button = Button(text="Reset", command = Reset)
Reset_Button.grid(row=0,column=2)
window.mainloop()
</code></pre>
| [
{
"answer_id": 74180784,
"author": "Loxley",
"author_id": 19291069,
"author_profile": "https://Stackoverflow.com/users/19291069",
"pm_score": 2,
"selected": false,
"text": "height"
},
{
"answer_id": 74181045,
"author": "Tester",
"author_id": 20149606,
"author_profile"... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180283",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17690070/"
] |
74,180,296 | <p>I need to create a dictionary whose keys contain the position of the column and the value the names of the variables of the dataframe.</p>
<p>DataFrame:</p>
<pre><code> ID A B C
0 p 1 3 2
1 q 4 3 2
2 r 4 0 9
</code></pre>
<p>Output should be like this:</p>
<pre><code>Dictionary = {'1': [ID], '2': [A], '3': [B],'4': [C]}
</code></pre>
| [
{
"answer_id": 74180316,
"author": "jezrael",
"author_id": 2901002,
"author_profile": "https://Stackoverflow.com/users/2901002",
"pm_score": 2,
"selected": false,
"text": "enumerate"
},
{
"answer_id": 74180666,
"author": "Carmoreno",
"author_id": 4508767,
"author_prof... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180296",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9088306/"
] |
74,180,335 | <p>I received a mail from Google warning me about "REQUEST_INSTALL_PACKAGES" permission.
I understand the warning, but I can't find which dependency brings this permission.</p>
<p>I found the "REQUEST_INSTALL_PACKAGES" permission in the merged manifest, but it is not added by my code, so I guess it comes from a dependency but I can't find which one.</p>
<p>Do you know how I can find which dependency brings this permission ?</p>
<p>For your information, I'm on Xamarin.Android 11 and Xamarin.Forms 4.8.</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<packages>
<package id="FastAndroidCamera" version="2.0.0" targetFramework="monoandroid81" />
<package id="Forms9Patch" version="1.5.0.9" targetFramework="monoandroid81" />
<package id="LiteDB" version="5.0.9" targetFramework="monoandroid81" />
<package id="Microsoft.AppCenter" version="1.6.0" targetFramework="monoandroid81" />
<package id="Microsoft.AppCenter.Analytics" version="1.6.0" targetFramework="monoandroid81" />
<package id="Microsoft.AppCenter.Crashes" version="1.6.0" targetFramework="monoandroid81" />
<package id="Microsoft.AppCenter.Distribute" version="1.6.0" targetFramework="monoandroid81" />
<package id="Microsoft.AspNetCore.Connections.Abstractions" version="3.1.20" targetFramework="monoandroid11.0" />
<package id="Microsoft.AspNetCore.Http.Connections.Client" version="3.1.20" targetFramework="monoandroid11.0" />
<package id="Microsoft.AspNetCore.Http.Connections.Common" version="3.1.20" targetFramework="monoandroid11.0" />
<package id="Microsoft.AspNetCore.Http.Features" version="3.1.20" targetFramework="monoandroid11.0" />
<package id="Microsoft.AspNetCore.SignalR.Client" version="3.1.20" targetFramework="monoandroid11.0" />
<package id="Microsoft.AspNetCore.SignalR.Client.Core" version="3.1.20" targetFramework="monoandroid11.0" />
<package id="Microsoft.AspNetCore.SignalR.Common" version="3.1.20" targetFramework="monoandroid11.0" />
<package id="Microsoft.AspNetCore.SignalR.Protocols.Json" version="3.1.20" targetFramework="monoandroid11.0" />
<package id="Microsoft.Bcl.AsyncInterfaces" version="6.0.0" targetFramework="monoandroid11.0" />
<package id="Microsoft.CSharp" version="4.5.0" targetFramework="monoandroid81" />
<package id="Microsoft.Extensions.Configuration" version="3.1.20" targetFramework="monoandroid11.0" />
<package id="Microsoft.Extensions.Configuration.Abstractions" version="3.1.20" targetFramework="monoandroid11.0" />
<package id="Microsoft.Extensions.Configuration.Binder" version="3.1.20" targetFramework="monoandroid11.0" />
<package id="Microsoft.Extensions.DependencyInjection" version="3.1.20" targetFramework="monoandroid11.0" />
<package id="Microsoft.Extensions.DependencyInjection.Abstractions" version="5.0.0" targetFramework="monoandroid11.0" />
<package id="Microsoft.Extensions.Logging" version="3.1.20" targetFramework="monoandroid11.0" />
<package id="Microsoft.Extensions.Logging.Abstractions" version="3.1.20" targetFramework="monoandroid11.0" />
<package id="Microsoft.Extensions.Options" version="3.1.20" targetFramework="monoandroid11.0" />
<package id="Microsoft.Extensions.Primitives" version="3.1.20" targetFramework="monoandroid11.0" />
<package id="Microsoft.Identity.Client" version="4.29.0" targetFramework="monoandroid81" />
<package id="Microsoft.IdentityModel.Clients.ActiveDirectory" version="3.19.8" targetFramework="monoandroid81" />
<package id="Microsoft.NETCore.Platforms" version="1.1.1" targetFramework="monoandroid81" />
<package id="Microsoft.NETCore.Targets" version="1.1.3" targetFramework="monoandroid81" />
<package id="Microsoft.Rest.ClientRuntime" version="2.3.13" targetFramework="monoandroid81" />
<package id="Microsoft.VisualStudio.Threading" version="17.1.46" targetFramework="monoandroid11.0" />
<package id="Microsoft.VisualStudio.Threading.Analyzers" version="17.1.46" targetFramework="monoandroid11.0" developmentDependency="true" />
<package id="Microsoft.VisualStudio.Validation" version="17.0.43" targetFramework="monoandroid11.0" />
<package id="Microsoft.Win32.Primitives" version="4.3.0" targetFramework="monoandroid81" />
<package id="Microsoft.Win32.Registry" version="5.0.0" targetFramework="monoandroid11.0" />
<package id="Mvvmicro" version="0.10.17" targetFramework="monoandroid11.0" />
<package id="Navigation.Abstractions" version="2.4.0-unstable0002" targetFramework="monoandroid81" />
<package id="NETStandard.Library" version="2.0.1" targetFramework="monoandroid81" />
<package id="Newtonsoft.Json" version="12.0.1" targetFramework="monoandroid81" />
<package id="NLog" version="4.5.4" targetFramework="monoandroid81" />
<package id="NLog.Config" version="4.5.4" targetFramework="monoandroid81" />
<package id="NLog.Schema" version="4.5.4" targetFramework="monoandroid81" />
<package id="Plugin.CurrentActivity" version="2.1.0.2" targetFramework="monoandroid81" />
<package id="Plugin.Permissions" version="3.0.0.12" targetFramework="monoandroid81" />
<package id="Rg.Plugins.Popup" version="1.1.5.188" targetFramework="monoandroid81" />
<package id="SkiaSharp" version="2.80.2" targetFramework="monoandroid11.0" />
<package id="SkiaSharp.Svg" version="1.59.1" targetFramework="monoandroid81" />
<package id="SkiaSharp.Views" version="2.80.2" targetFramework="monoandroid11.0" />
<package id="SkiaSharp.Views.Forms" version="2.80.2" targetFramework="monoandroid11.0" />
<package id="StyleCop.MSBuild" version="6.0.0-beta04" targetFramework="monoandroid81" developmentDependency="true" />
<package id="System.AppContext" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Buffers" version="4.5.1" targetFramework="monoandroid11.0" />
<package id="System.Collections" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Collections.Concurrent" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.ComponentModel.Annotations" version="4.7.0" targetFramework="monoandroid11.0" />
<package id="System.ComponentModel.TypeConverter" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Console" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Diagnostics.Debug" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Diagnostics.Process" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Diagnostics.Tools" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Diagnostics.Tracing" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Dynamic.Runtime" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Globalization" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Globalization.Calendars" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.IO" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.IO.Compression" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.IO.Compression.ZipFile" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.IO.FileSystem" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.IO.FileSystem.Primitives" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.IO.Pipelines" version="4.7.4" targetFramework="monoandroid11.0" />
<package id="System.Linq" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Linq.Expressions" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Memory" version="4.5.2" targetFramework="monoandroid11.0" />
<package id="System.Net.Http" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Net.Primitives" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Net.Sockets" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Numerics.Vectors" version="4.5.0" targetFramework="monoandroid81" />
<package id="System.ObjectModel" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Private.Uri" version="4.3.2" targetFramework="monoandroid81" />
<package id="System.Reflection" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Reflection.Extensions" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Reflection.Primitives" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Reflection.TypeExtensions" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Resources.ResourceManager" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Runtime" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Runtime.CompilerServices.Unsafe" version="4.7.1" targetFramework="monoandroid11.0" />
<package id="System.Runtime.Extensions" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Runtime.Handles" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Runtime.InteropServices" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Runtime.InteropServices.RuntimeInformation" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Runtime.Numerics" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Runtime.Serialization.Formatters" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Runtime.Serialization.Json" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Runtime.Serialization.Primitives" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Security.AccessControl" version="5.0.0" targetFramework="monoandroid11.0" />
<package id="System.Security.Cryptography.Algorithms" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Security.Cryptography.Encoding" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Security.Cryptography.Primitives" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Security.Cryptography.X509Certificates" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Security.Principal.Windows" version="5.0.0" targetFramework="monoandroid11.0" />
<package id="System.Security.SecureString" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Text.Encoding" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Text.Encoding.Extensions" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Text.Encodings.Web" version="4.7.1" targetFramework="monoandroid11.0" />
<package id="System.Text.Json" version="4.7.2" targetFramework="monoandroid11.0" />
<package id="System.Text.RegularExpressions" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Threading" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Threading.Channels" version="4.7.1" targetFramework="monoandroid11.0" />
<package id="System.Threading.Tasks" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Threading.Tasks.Extensions" version="4.5.4" targetFramework="monoandroid11.0" />
<package id="System.Threading.Timer" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Xml.ReaderWriter" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Xml.XDocument" version="4.3.0" targetFramework="monoandroid81" />
<package id="System.Xml.XmlDocument" version="4.3.0" targetFramework="monoandroid81" />
<package id="Toasts.Forms.Plugin" version="3.3.2" targetFramework="monoandroid81" />
<package id="Xam.Forms.QRCode" version="0.5.0" targetFramework="monoandroid81" />
<package id="Xam.Plugin.Media" version="5.0.1" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Arch.Core.Common" version="1.1.1.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Arch.Lifecycle.Common" version="1.1.1.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Arch.Lifecycle.Runtime" version="1.1.1.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.Animated.Vector.Drawable" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.Annotations" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.Compat" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.Core.UI" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.Core.Utils" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.CustomTabs" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.Design" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.Fragment" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.Media.Compat" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.Transition" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.v4" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.v7.AppCompat" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.v7.CardView" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.v7.MediaRouter" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.v7.Palette" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.v7.RecyclerView" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.Android.Support.Vector.Drawable" version="28.0.0.3" targetFramework="monoandroid81" />
<package id="Xamarin.AndroidX.Activity" version="1.2.0.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Annotation" version="1.2.0" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Annotation.Experimental" version="1.0.0.9" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.AppCompat" version="1.2.0.7" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.AppCompat.AppCompatResources" version="1.3.0" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.AppCompat.Resources" version="1.1.0" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Arch.Core.Common" version="2.1.0.8" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Arch.Core.Runtime" version="2.1.0.8" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.AsyncLayoutInflater" version="1.0.0.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Browser" version="1.0.0.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.CardView" version="1.0.0.8" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Collection" version="1.1.0.7" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.ConstraintLayout" version="2.0.4.2" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.ConstraintLayout.Solver" version="2.0.4.2" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.CoordinatorLayout" version="1.1.0.7" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Core" version="1.5.0" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.CursorAdapter" version="1.0.0.7" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.CustomView" version="1.1.0.6" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.DocumentFile" version="1.0.1.7" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.DrawerLayout" version="1.1.1.2" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.DynamicAnimation" version="1.0.0.7" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Fragment" version="1.3.0.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Interpolator" version="1.0.0.7" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Legacy.Support.Core.UI" version="1.0.0.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Legacy.Support.Core.Utils" version="1.0.0.7" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Legacy.Support.V4" version="1.0.0.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Lifecycle.Common" version="2.3.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Lifecycle.LiveData" version="2.1.0.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Lifecycle.LiveData.Core" version="2.3.0.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Lifecycle.Runtime" version="2.3.1.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Lifecycle.ViewModel" version="2.3.0.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Lifecycle.ViewModelSavedState" version="2.3.0.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Loader" version="1.1.0.7" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.LocalBroadcastManager" version="1.0.0.7" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Media" version="1.3.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.MediaRouter" version="1.2.4" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Migration" version="1.0.8" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.MultiDex" version="2.0.1.5" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Palette" version="1.0.0.7" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Print" version="1.0.0.7" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.RecyclerView" version="1.1.0.8" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.SavedState" version="1.1.0.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.SlidingPaneLayout" version="1.0.0.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.SwipeRefreshLayout" version="1.0.0.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.Transition" version="1.4.0.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.VectorDrawable" version="1.1.0.7" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.VectorDrawable.Animated" version="1.1.0.7" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.VersionedParcelable" version="1.1.1.7" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.ViewPager" version="1.0.0.7" targetFramework="monoandroid11.0" />
<package id="Xamarin.AndroidX.ViewPager2" version="1.0.0.9" targetFramework="monoandroid11.0" />
<package id="Xamarin.Build.Download" version="0.4.11" targetFramework="monoandroid81" />
<package id="Xamarin.Controls.SignaturePad" version="2.3.0" targetFramework="monoandroid81" />
<package id="Xamarin.Controls.SignaturePad.Forms" version="2.3.0" targetFramework="monoandroid81" />
<package id="Xamarin.Essentials" version="1.5.3.2" targetFramework="monoandroid81" />
<package id="Xamarin.FFImageLoading" version="2.4.5.922" targetFramework="monoandroid81" />
<package id="Xamarin.FFImageLoading.Forms" version="2.4.5.922" targetFramework="monoandroid81" />
<package id="Xamarin.FFImageLoading.Svg" version="2.4.5.922" targetFramework="monoandroid81" />
<package id="Xamarin.FFImageLoading.Svg.Forms" version="2.4.5.922" targetFramework="monoandroid81" />
<package id="Xamarin.Firebase.Common" version="60.1142.1" targetFramework="monoandroid81" />
<package id="Xamarin.Firebase.Iid" version="60.1142.1" targetFramework="monoandroid81" />
<package id="Xamarin.Firebase.Messaging" version="60.1142.1" targetFramework="monoandroid81" />
<package id="Xamarin.Forms" version="4.8.0.1821" targetFramework="monoandroid11.0" />
<package id="Xamarin.Google.Android.Material" version="1.3.0.1" targetFramework="monoandroid11.0" />
<package id="Xamarin.Google.Guava.ListenableFuture" version="1.0.0.2" targetFramework="monoandroid11.0" />
<package id="Xamarin.GooglePlayServices.Base" version="60.1142.1" targetFramework="monoandroid81" />
<package id="Xamarin.GooglePlayServices.Basement" version="60.1142.1" targetFramework="monoandroid81" />
<package id="Xamarin.GooglePlayServices.Location" version="60.1142.1" targetFramework="monoandroid81" />
<package id="Xamarin.GooglePlayServices.Tasks" version="60.1142.1" targetFramework="monoandroid81" />
<package id="ZXing.Net" version="0.16.4" targetFramework="monoandroid81" />
<package id="ZXing.Net.Mobile" version="2.4.1" targetFramework="monoandroid81" />
<package id="ZXing.Net.Mobile.Forms" version="2.4.1" targetFramework="monoandroid81" />
</packages>
</code></pre>
<p>Thanks in advance</p>
| [
{
"answer_id": 74188377,
"author": "Liyun Zhang - MSFT",
"author_id": 17455524,
"author_profile": "https://Stackoverflow.com/users/17455524",
"pm_score": 1,
"selected": false,
"text": "tools:node=\"remove\""
}
] | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180335",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20321203/"
] |
74,180,341 | <p>What is the most pythonic way to reverse the elements of one list based on another equally-sized list?</p>
<pre><code>lista = [1,2,4]
listb = ['yes', 'no', 'yep']
# expecting [-1, 2,-4]
[[-x if y in ['yes','yep'] else x for x in lista] for y in listb]
# yields [[-1, -2, -4], [1, 2, 4], [-1, -2, -4]]
</code></pre>
<p>if <code>listb[i]</code> is <code>yes</code> or <code>yep</code>, <code>result[i]</code> should be the opposite of <code>lista</code>.</p>
<p>Maybe a lambda function applied in list comprehension?</p>
| [
{
"answer_id": 74180486,
"author": "koyeung",
"author_id": 135699,
"author_profile": "https://Stackoverflow.com/users/135699",
"pm_score": 3,
"selected": true,
"text": "zip"
},
{
"answer_id": 74180862,
"author": "Arifa Chan",
"author_id": 19574157,
"author_profile": "... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180341",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5224236/"
] |
74,180,358 | <p>I create a component for my Dialog and my Checkbox my issue is when my checkbox is not in the Dialog the update works but when it's inside it doesn't work. I don't understand why.</p>
<pre><code>const Popup = ({ title, handleClose, openned, children }) => {
return (
<Dialog className='react-popup-template' fullWidth={true} maxWidth='sm' open={openned} onClose={handleClose} aria-labelledby="parent-modal-title" aria-describedby="parent-modal-description">
<DialogContent id="modal-description" >
<div>
{title && <div><h4 style={{ textAlign: 'center', fontWeight: 'bold', fontSize : '23px' }}>{title}</h4><br/></div>}
{children}
</div>
</DialogContent>
</Dialog>
);
}
const CheckBox = (value, onChange) => {
return (
<label>
<input type='checkbox' value={value} onChange={onChange} />
</label>)
}
const App = () =>{
const [openPopup, setOpenPopup] = React.useState(false)
const [checked, setChecked] = React.useState(false)
const [title, setTitle] = React.useState('')
const [description, setDescription] = React.useState('')
const showModal = (title) =>{
setTitle(title)
setDescription(<CheckBox value={checked} onChange={() => {setChecked(!checked)}} />)
}
return (
<button onClick={() => {showModal('Title')}}>showModal</button>
<PopupTemplate title={title} handleClose={() => { setOpenPopup(false) }} openned={openPopup}>
{description}
</PopupTemplate>)
}
</code></pre>
| [
{
"answer_id": 74180486,
"author": "koyeung",
"author_id": 135699,
"author_profile": "https://Stackoverflow.com/users/135699",
"pm_score": 3,
"selected": true,
"text": "zip"
},
{
"answer_id": 74180862,
"author": "Arifa Chan",
"author_id": 19574157,
"author_profile": "... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10863293/"
] |
74,180,368 | <p>I have two(n) Python dictionaries <code>dict_1 = {"obj_value": 1, "other_key": 10}</code> and <code>dict_2 = {"obj_value": 0, "other_key": 10}</code> and I need a rutine that returns the dictionary that minimizes the <code>obj_value</code> key, in this case, <code>dict_2</code></p>
<p>Any ideas about this problem without using conditionals (if)? I would want to extend this to more than two dictionaries.</p>
| [
{
"answer_id": 74180481,
"author": "PirateNinjas",
"author_id": 8237877,
"author_profile": "https://Stackoverflow.com/users/8237877",
"pm_score": 1,
"selected": false,
"text": "chosen_dict = dict_1 if dict_1[\"object_value\"] < dict_2[\"object_value\"] else dict_2\n"
},
{
"answer... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20321213/"
] |
74,180,372 | <p>I have a long list of time diff calculations I want to make. Given the names of the columns are long and contain spaces (pulled from an API) I've created a table of the variable names to be used for each operation:</p>
<pre><code>stage_refs <- structure(list(new.diff.var = c("time diff 1", "time diff 2",
"time diff 3", "time diff 4"), var.1 = c("time value 2", "time value 3",
"time value 4", "time value 5"), var.2 = c("time value 1", "time value 2",
"time value 3", "time value 4")), row.names = c(NA, -4L), spec = structure(list(
cols = list(new.diff.var = structure(list(), class = c("collector_character",
"collector")), var.1 = structure(list(), class = c("collector_character",
"collector")), var.2 = structure(list(), class = c("collector_character",
"collector"))), default = structure(list(), class = c("collector_guess",
"collector")), delim = ","), class = "col_spec"), class = c("spec_tbl_df",
"tbl_df", "tbl", "data.frame"))
</code></pre>
<p>And a date frame of dates with missing values for where no dates are as yet recorded:</p>
<pre><code>date_values <- structure(list(`time value 1` = structure(c(18993, 18993, 18993,
NA), class = "Date"), `time value 2` = structure(c(19024, NA,
19026, 19027), class = "Date"), `time value 3` = structure(c(NA,
19084, 19085, 19086), class = "Date"), `time value 4` = structure(c(19113,
19114, NA, 19116), class = "Date"), `time value 5` = structure(c(19174,
19175, 19176, 19177), class = "Date")), row.names = c(NA, -4L
), class = c("tbl_df", "tbl", "data.frame"))
</code></pre>
<p>In the production data set there are up to 20 diff time calculations to make, hence why I've put in a table so I can use a function such as:</p>
<pre><code>library(tidyverse)
difftime_fun <- function(x, y, z) {
date_values |>
mutate(!!x = difftime(y, z))
}
</code></pre>
<p>... to create a new column from x by the calculation between y & z and then apply this function row-wise over <code>stage_refs</code> using a loop:</p>
<pre><code>for(i in 1:nrow(time_diff_stages)) {
difftime_fun(
stage_refs$new.diff.var[[i]],
stage_refs$var.1[[i]],
stage_refs$var.2[[i]]
)
</code></pre>
<p>What I want is as many timediff columns added to <code>date_values</code> as rows in <code>stage_refs</code> using the variable names from <code>stage_refs</code> for assignment of the cols and for the calculations.</p>
<p>There are 2 places I'm stuck:</p>
<ol>
<li>I'm running into non-standard-evaluation problems with using the variable names in the function. I've tried combinations of <code>!!</code>, <code>{{ }}</code>, <code>eval</code> etc and can't make sense of it.</li>
<li>I suspect there's a better way than using the loop to go row-wise using <code>apply</code> or some such, but not solving (1) means it's hard to trial and error using <code>apply</code>.</li>
</ol>
<p>I have looked at <a href="https://stackoverflow.com/questions/26003574/use-dynamic-name-for-new-column-variable-in-dplyr">this solution</a>, but can't make sense as to how to use for this problem.</p>
<p>Thanks.</p>
<p>For clarification the final df would have the following columns:</p>
<pre><code>[1] "time value 1" "time value 2" "time value 3" "time value 4" "time value 5" "time diff 1"
[7] "time diff 2" "time diff 3" "time diff 4"
</code></pre>
| [
{
"answer_id": 74180760,
"author": "stefan",
"author_id": 12993861,
"author_profile": "https://Stackoverflow.com/users/12993861",
"pm_score": 3,
"selected": true,
"text": ".data"
},
{
"answer_id": 74181593,
"author": "Ritchie Sacramento",
"author_id": 2835261,
"author... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7871804/"
] |
74,180,443 | <p>I have a vector of 3D coordinates:</p>
<pre><code>vector<float64>contourdata;
contourdata={x0,y0,z0,x1,y1,z1,x2,y2,z2,...}
</code></pre>
<p>And I want to sort them by the vector of the z value.
How can I do it in c++?</p>
| [
{
"answer_id": 74180760,
"author": "stefan",
"author_id": 12993861,
"author_profile": "https://Stackoverflow.com/users/12993861",
"pm_score": 3,
"selected": true,
"text": ".data"
},
{
"answer_id": 74181593,
"author": "Ritchie Sacramento",
"author_id": 2835261,
"author... | 2022/10/24 | [
"https://Stackoverflow.com/questions/74180443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19190785/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.