question_id int64 37.6M 73.2M | input_text stringlengths 88 52.4k | output_text stringlengths 37 35.6k | title stringlengths 15 150 | tags stringlengths 1 107 | q_score int64 -19 397 | view_count int64 3 879k | answer_count int64 1 21 | accepted_answer_id int64 37.6M 73.8M | answer_id int64 37.6M 73.8M | a_score int64 -5 1.29k | is_accepted bool 1
class | creation_date stringlengths 20 24 | input_text_instruct stringlengths 251 52.6k |
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
72,907,636 | Get sinon to resolve a promise when stubbed function is called<p>I have a set of integration tests for message queueing code (over a real RabbitMQ). The tests are verifying that the correct use case is triggered when a specific message arrives.</p>
<pre class="lang-js prettyprint-override"><code>it("should trigger... | <p>I think you can use an empty promise to await, so the app logic eventually resolves that promise when it is called. Sinon provides a <a href="https://sinonjs.org/releases/v14/promises/" rel="nofollow noreferrer">promise fake</a> that makes this a bit easier than creating a <code>new Promise</code> with an external r... | Get sinon to resolve a promise when stubbed function is called | javascript|node.js|sinon | 1 | 53 | 1 | 72,910,327 | 72,910,327 | 1 | true | 2022-07-08T06:47:14.773Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Get sinon to resolve a promise when stubbed function is called<p>I have a set of integration tests for message queueing code (over a real RabbitMQ). The test... |
73,014,412 | How to understand const Someclass& a in constructor<p>I'm trying to understand the code below. More specifically, why is b.x in the main function 5?<br />
As far as I understand, I have a constructor <code>Someclass(int xx):x(xx){}</code> in the class which sets my attribute x to xx. Therefore, a.x in the main function... | <p>When you instantiate <code>a</code> with the following line:</p>
<pre><code>Someclass a(4);
</code></pre>
<p>You are calling the "normal" constructor, namely:</p>
<pre><code>class Someclass {
public:
int x;
public:
Someclass(int xx):x(xx){} // <= This one
Someclass(const Someclass& a... | How to understand const Someclass& a in constructor | c++|class|constructor|reference | -1 | 53 | 1 | 73,014,582 | 73,014,582 | 1 | true | 2022-07-17T18:38:47.633Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to understand const Someclass& a in constructor<p>I'm trying to understand the code below. More specifically, why is b.x in the main function 5?<br />
As... |
72,776,848 | Get role id in slashcommand option<p>I'm trying to make a command where you can put a role inside an option.
If the user mentions a role within the slashcommand option, this role becomes an ID to be later added to the channel to the channel to see the content.</p>
<p>If the user does not put any role, the permission is... | <p>Use <code>addRoleOption</code> instead.</p>
<p>You can get an option's value with this: <code>interaction.options.getRole('name')</code>(the name you set earlier with 'setName'). <a href="https://discordjs.guide/interactions/slash-commands.html#parsing-options" rel="nofollow noreferrer">Parsing Options</a></p>
<pre>... | Get role id in slashcommand option | javascript|discord.js|bots | 1 | 53 | 1 | 72,778,750 | 72,778,750 | 1 | true | 2022-06-27T18:31:47.633Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Get role id in slashcommand option<p>I'm trying to make a command where you can put a role inside an option.
If the user mentions a role within the slashcomm... |
72,829,916 | Infer type of constructed object<p>In my TypeScript app, I'm taking an <a href="https://swagger.io/specification/" rel="nofollow noreferrer">OpenAPI spec</a> and constructing an example from it. So the spec might look something like this, to simplify:</p>
<pre><code>const spec = {
type: 'object',
properties: {
... | <p>The main goal here is to write a type function <code>type SchemaToType<T> = ...</code> which takes a schema type as input and produces the corresponding value type as output. So you want <code>SchemaToType<{type: "string"}></code> to be <code>string</code>, and <code>SchemaToType<{type: &qu... | Infer type of constructed object | typescript | 1 | 53 | 1 | 72,830,423 | 72,830,423 | 1 | true | 2022-07-01T13:19:22.117Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Infer type of constructed object<p>In my TypeScript app, I'm taking an <a href="https://swagger.io/specification/" rel="nofollow noreferrer">OpenAPI spec</a>... |
72,901,292 | How to use dynamoDB batchWriteItem with nodejs sdk?<p>I have a use case where I need to perform a batch_write operation on dynamodb. I referred <a href="https://vin0d.medium.com/dynamodb-batch-write-nodejs-f2a9d0d7d740" rel="nofollow noreferrer">this</a> article which has a good solution for similar use case. I impleme... | <p>Here's one simple way to batch the items:</p>
<pre><code>const BATCH_MAX = 25;
const batchWrite = async (items, table_name) => {
const BATCHES = Math.floor((items.length + BATCH_MAX - 1) / BATCH_MAX);
for (let batch = 0; batch < BATCHES; batch++) {
const itemsArray = [];
for (let ii = 0; ii <... | How to use dynamoDB batchWriteItem with nodejs sdk? | node.js|amazon-dynamodb | 0 | 53 | 2 | 72,901,986 | 72,901,986 | 1 | true | 2022-07-07T16:25:25.607Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to use dynamoDB batchWriteItem with nodejs sdk?<p>I have a use case where I need to perform a batch_write operation on dynamodb. I referred <a href="http... |
72,965,998 | Regex Match URL Without Query String<p>I need to match <a href="https://example.com/" rel="nofollow noreferrer">https://example.com/</a> exactly but ignore any query strings so:</p>
<p><a href="https://example.com/something" rel="nofollow noreferrer">https://example.com/something</a> should not match but <a href="https... | <p><code>^https:\/\/example\.com(\/?\?.*)?$</code> will match</p>
<pre><code>https://example.com/?abc
https://example.com?abc
https://example.com
</code></pre>
<p>but ignore</p>
<pre><code> https://example.com/something
</code></pre>
<p>Is that what you're looking for? Demo at <a href="https://regex101.com/r/B22n1p/... | Regex Match URL Without Query String | regex | 0 | 53 | 2 | 72,966,452 | 72,966,452 | 1 | true | 2022-07-13T12:04:37.047Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Regex Match URL Without Query String<p>I need to match <a href="https://example.com/" rel="nofollow noreferrer">https://example.com/</a> exactly but ignore a... |
72,962,308 | Powershell Variables for XML node/path addressing<p>Hello dear Powershell experts,</p>
<p>I need some advice. I try to use Powershell variables (which i get from parameters) to address XML paths/nodes.</p>
<p><strong>My Scenario</strong></p>
<p>The code below shows a short cutout of my code. With this cutout i will try... | <p>If you want to <strong>use PowerShell's adaptation of the XML DOM</strong>, which allows <strong>property-like access to the elements and attributes using the <code>.</code> operator</strong>, you can drill down into your XML document <em>iteratively</em> by splitting a <code>.</code>-separated path string into its ... | Powershell Variables for XML node/path addressing | xml|powershell|parsing|variables|gpo | 2 | 53 | 1 | 73,027,077 | 73,027,077 | 1 | true | 2022-07-13T07:17:18.600Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Powershell Variables for XML node/path addressing<p>Hello dear Powershell experts,</p>
<p>I need some advice. I try to use Powershell variables (which i get ... |
72,772,341 | TSQL - New column value based on other columns with highest level of match<p>So I've got a mapping table with the following information:</p>
<pre><code>Number | FCODE | CCODE
---------------------------------------------
0********* | 12345 | 1
01******** | 12345 | 2
012******* | ***** | ... | <p>You can use values from the <code>mapping</code> table as regular expression patterns to match against values in a <code>fact</code> table.</p>
<p>And if i understand correctly, you need to get maximum <code>CCODE</code> for both matches <code>mapping.Number</code> with <code>fact.Number</code> and <code>mapping.FCo... | TSQL - New column value based on other columns with highest level of match | sql|tsql | 1 | 53 | 1 | 72,774,861 | 72,774,861 | 1 | true | 2022-06-27T12:46:00.357Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
TSQL - New column value based on other columns with highest level of match<p>So I've got a mapping table with the following information:</p>
<pre><code>Numbe... |
73,026,220 | Keep original lombok builder setter and overload<p>I'm making a Builder using lombok but have noticed that if I overload a setter, it stops generating the original.</p>
<p>In example below, there's no setter for <code>NamedIdentity player</code> anymore. In my case, I want both the original and the overload. I don't se... | <p>You can make Lombok ignore existing methods by annotating them with <a href="https://projectlombok.org/features/experimental/Tolerate" rel="nofollow noreferrer"><code>@Tolerate</code></a>.</p> | Keep original lombok builder setter and overload | java|lombok | 3 | 53 | 1 | 73,026,245 | 73,026,245 | 1 | true | 2022-07-18T17:21:13.117Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Keep original lombok builder setter and overload<p>I'm making a Builder using lombok but have noticed that if I overload a setter, it stops generating the or... |
72,988,593 | C++ lambda macro to force argument type<p>Going through cdda's opensource codebase I found a pretty funky looking macro that I'd like to understand better</p>
<p>Macro definition</p>
<pre><code>/**
* The purpose of this macro is to provide a concise syntax for
* creation of inline literals (std::string, string_id, et... | <p>OP asked</p>
<blockquote>
<p>Why does the lamda have the "()" after it? Is the execute call for the function?</p>
</blockquote>
<p>Yes. This is the definition of a lambda which is immediately called. Hence, the whole forms an expression and can be used where expressions (of compatible type) are expected.</... | C++ lambda macro to force argument type | c++|lambda|macros|type-conversion | 1 | 53 | 1 | 72,989,919 | 72,989,919 | 1 | true | 2022-07-15T02:54:17.377Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
C++ lambda macro to force argument type<p>Going through cdda's opensource codebase I found a pretty funky looking macro that I'd like to understand better</p... |
72,833,779 | How to plot curve for each row in dataframe without plotting NaN values<p>I have the following dataframe:</p>
<pre><code> 0 5 15 20 25 30 35 40 45 50
----------------------------------------------
0 85 75 65 52 39 21 12 5 2 0
1 80 69 52 48 21 12 5 2 0 0
2 81 68 ... | <p>If you want to keep only the first 0 and not the trail of 0s, you can use numpy's function <code>nonzero</code> to find the index of nonzero values and trim the array to include those values plus the first 0. This works for plotting and data manipulation.</p>
<pre><code>import matplotlib.pyplot as plt
import pandas ... | How to plot curve for each row in dataframe without plotting NaN values | python|pandas|numpy|matplotlib | 0 | 53 | 1 | 72,834,523 | 72,834,523 | 1 | true | 2022-07-01T19:20:42.380Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to plot curve for each row in dataframe without plotting NaN values<p>I have the following dataframe:</p>
<pre><code> 0 5 15 20 25 30 35 4... |
72,917,853 | What is the best way to find if there are any duplicates in nested child property in a JavaScript Object?<p>I have an array of objects(Vue 3 prop) like below. The array is for <code>room</code> objects. Each room contains <code>adults</code> and <code>childs</code> array with <code>adult</code> and <code>child</code> o... | <p>Here's my naive attempt</p>
<p>I <strong>assumed</strong> you want to find duplicates among adults separately from duplicates among children - it's not clear since the only duplicate is Jane Doe and she appears twice as an adult and twice as a child!</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-... | What is the best way to find if there are any duplicates in nested child property in a JavaScript Object? | javascript|vuejs3 | 0 | 53 | 3 | 72,918,015 | 72,918,015 | 1 | true | 2022-07-08T23:24:06.713Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
What is the best way to find if there are any duplicates in nested child property in a JavaScript Object?<p>I have an array of objects(Vue 3 prop) like below... |
72,797,877 | Scroll automatically to the right side of a datatable<p>Is there any way, in R Shiny, to set the scroll bar from a datatable automatically to the right side when rendered (i.e. to the last column), instead of the left side as it is set by default ?</p>
<p>Base example :</p>
<pre><code>library(shiny)
runApp(shinyApp(
... | <pre><code>library(shiny)
runApp(shinyApp(
ui = fluidPage(
tags$div(id = "parent",
DT::dataTableOutput("results", width = 300)
),
tags$style("
#parent {direction: rtl; max-height: 80vh; overflow: auto; margin: 0 auto}
#results {direction: ltr; ... | Scroll automatically to the right side of a datatable | r|shiny|dt | 1 | 53 | 2 | 72,839,179 | 72,839,179 | 1 | true | 2022-06-29T08:06:18.643Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Scroll automatically to the right side of a datatable<p>Is there any way, in R Shiny, to set the scroll bar from a datatable automatically to the right side ... |
72,824,690 | Minus all doesn't work although minus works<pre><code>SELECT jt.*
FROM JSON_TABLE (
TO_CLOB ('[{"A":1,"B":11},{"A":1,"B":11}]'),
'$[*]'
COLUMNS (A VARCHAR2 (200) PATH '$.A', B VARCHAR2 (200) PATH '$.B'))
AS jt
MINUS --all
SELECT jt.*
FR... | <p>You can achieve it with the help of row_number() window function.</p>
<p>Since in below query every A and B combination has unique row numbers only matching number of rows will be removed.</p>
<p>Query:</p>
<pre><code> select row_number()over(partition by A,B order by A,B)rn,A,B from (SELECT jt.*
FROM JSON_TABLE ... | Minus all doesn't work although minus works | sql|oracle | 1 | 53 | 2 | 72,824,861 | 72,824,861 | 1 | true | 2022-07-01T05:20:10.880Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Minus all doesn't work although minus works<pre><code>SELECT jt.*
FROM JSON_TABLE (
TO_CLOB ('[{"A":1,"B":11},{"A"... |
72,951,808 | Is there a way to run dplyr functions over a set of predefined variables?<pre><code>df <- mtcars
prop <- df %>%
group_by(cyl, .drop = FALSE) %>%
filter(rowMeans(is.na(across(c(disp, drat, wt)))) <= 0.5) %>%
summarise(N = n(), across(c(disp, drat, wt, qsec, vs), ~mean(. == 1, na.rm=TRUE))) %>... | <p>Using <code>!!</code> from <code>{rlang}</code></p>
<pre class="lang-r prettyprint-override"><code>library(rlang)
library(dplyr)
df <- mtcars
select1 <- df %>% select(disp, drat, wt) %>% names()
select2 <- df %>% select(disp, drat, wt, qsec, vs) %>% names()
df %>%
group_by(cyl, .drop =... | Is there a way to run dplyr functions over a set of predefined variables? | r|dplyr | 3 | 53 | 1 | 72,951,938 | 72,951,938 | 1 | true | 2022-07-12T11:47:33.610Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Is there a way to run dplyr functions over a set of predefined variables?<pre><code>df <- mtcars
prop <- df %>%
group_by(cyl, .drop = FALSE) %>... |
72,955,134 | NullPointerException when i want setColor in my ImageView<p>When I try to set color for my imageView it gives me NullPointerException error</p>
<p>I've already tried a bunch of solutions, but I just can't figure out what the problem is.
In XML files, I have a background color and an outline color and I don't understand... | <p>I found a solution,</p>
<p>I Just set background and src attributes in ImageView tag in <code>activity_coloring.xml</code> file:</p>
<pre class="lang-xml prettyprint-override"><code>android:src="@color/white"
android:background="@drawable/set_color_default"
</code></pre> | NullPointerException when i want setColor in my ImageView | android|nullpointerexception | 0 | 53 | 2 | 72,968,580 | 72,968,580 | 1 | true | 2022-07-12T15:53:48.030Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
NullPointerException when i want setColor in my ImageView<p>When I try to set color for my imageView it gives me NullPointerException error</p>
<p>I've alrea... |
72,921,864 | How to correctly loop pandas dataframe creating new columns<p>I have this dataframe (name: res_d)</p>
<pre><code> time entry take_profit stop_loss
2022-04-05 3881.5 False 3854.5
2022-04-06 3835.5 False 3816.5
2022-04-07 3767.0 3785.5 False ... | <p>my fav method is:</p>
<pre><code>df.loc[(condition), 'new_column'] = 'value'
</code></pre>
<p>example condition:</p>
<pre><code>(df.col >= 10) & (df.col2.notna())
</code></pre> | How to correctly loop pandas dataframe creating new columns | python|pandas|dataframe | 0 | 53 | 3 | 72,922,193 | 72,922,193 | 1 | true | 2022-07-09T13:44:38.060Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to correctly loop pandas dataframe creating new columns<p>I have this dataframe (name: res_d)</p>
<pre><code> time entry take_profit stop_los... |
72,778,695 | Extract time against Max and Min values in r<p>For the table below, I would like to extract the time against the peak and trough of the values. The dataset is analogous to a groundwater level which is expected to peak coinciding a rainfall and gradually drop down until the next rainfall event. Here, I'd like to extract... | <p>It does not have to be hard to find single peaks and troughs, but a complicating factor is peaks and troughs that are more than one observation wide. Therefore I have added one such instance to your example data:</p>
<h4>example input</h4>
<pre><code>df <- data.frame(CS = c(70L, 138L, 138L, 120L, 100L, 80L, 110L,... | Extract time against Max and Min values in r | r | 0 | 53 | 1 | 72,779,645 | 72,779,645 | 1 | true | 2022-06-27T21:54:41.063Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Extract time against Max and Min values in r<p>For the table below, I would like to extract the time against the peak and trough of the values. The dataset i... |
73,010,561 | When I list the integers in a list, an extra one gets added at the end [Python]<pre><code>numberlist = [1, 4, 7, 5, 6, 2, 4]
for i in numberlist:
pos = numberlist.index(i)
next = pos + 1
ordering = [i, numberlist[next]]
print(ordering)
</code></pre>
<p>This is the code I'm having problems with. When I ... | <pre><code>numberlist = [1, 4, 7, 5, 6, 2, 4]
</code></pre>
<p>Based on your example and your for loop, there are 7 elements in the list.</p>
<p>Once i is 6 which is the last position on the list, it will still carry out all the codes in the for loop. What I could suggest is to use a if condition to break the for loop ... | When I list the integers in a list, an extra one gets added at the end [Python] | python|list|for-loop|printing | 1 | 53 | 2 | 73,010,643 | 73,010,643 | 1 | true | 2022-07-17T09:11:51.367Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
When I list the integers in a list, an extra one gets added at the end [Python]<pre><code>numberlist = [1, 4, 7, 5, 6, 2, 4]
for i in numberlist:
pos = ... |
72,884,093 | Fold expression: Replacing specific type but forwarding all others, how to correctly specialise `std::forward`?<p>I've trying to replace a specific type within a fold expression while simply forwarding all other types, but failed miserably.</p>
<p>A simulation of <code>std::forward</code>; actually copied GCC's impleme... | <p>To be noted in advance: This attempt is entirely illegal since C++ 20 and illegal for the given use case (replacing <code>std::string</code>) as well as template specialisations for standard types have been illegal even before C++20 (thanks <a href="https://stackoverflow.com/a/72903092/1312382">@Nimrod</a> for the h... | Fold expression: Replacing specific type but forwarding all others, how to correctly specialise `std::forward`? | c++|templates | 1 | 53 | 2 | 72,910,535 | 72,910,535 | 1 | true | 2022-07-06T13:05:23.833Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Fold expression: Replacing specific type but forwarding all others, how to correctly specialise `std::forward`?<p>I've trying to replace a specific type with... |
73,024,720 | How to compare column values when Dtype is object array in Pandas dataframe<p>Suppose I have a simple table with 4 columns. The last 2 rows have empty values or have been set to 'unDefined':</p>
<pre><code>import pandas
# initialize data of lists.
data = {'id': [12, 45, 13, 32, 43, 38],
'org_type': [1, 2, 3, 1, Non... | <p>When comparing a Series to a value (<code>new_df[desc_col] == 'Undefined'</code>) you get a boolean series, which you can't use in an if statement in its entirety.</p>
<p>You can use a <a href="https://pandas.pydata.org/docs/getting_started/intro_tutorials/10_text_data.html#how-to-manipulate-textual-data" rel="nofol... | How to compare column values when Dtype is object array in Pandas dataframe | arrays|python-3.x|pandas|dtype | 1 | 53 | 2 | 73,025,102 | 73,025,102 | 1 | true | 2022-07-18T15:19:03.853Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to compare column values when Dtype is object array in Pandas dataframe<p>Suppose I have a simple table with 4 columns. The last 2 rows have empty values... |
72,939,850 | Generic response type based on input type<p>I try to write types for simple function <code>fun</code>.</p>
<p>Here are some interfaces for input and response:</p>
<pre class="lang-js prettyprint-override"><code>interface Input {
test1?: true
test2?: true
test3?: true
}
interface Res {
test1?: string
test2?: s... | <p>You can perhaps do something like this with generics:</p>
<p><a href="https://www.typescriptlang.org/play?#code/C4TwDgpgBAkgdmArsKBeKBvAsAKClYCAZ2AEYB+ALigCMB7OgGwgEM4oAfKROAEwgBmASzgReufIRIAmKrQbM2nbn0EixEgsWABmOfSat2XHv2GjxOAL65coSFABKxADwAVKBAAehPkVgIyAB8aJiaUmTUbgDaAOQRpLEAup4+EH7yhkrkUCQATiIA5lDUpmoWUAD0lVBsdMA... | Generic response type based on input type | typescript | 0 | 53 | 1 | 72,940,436 | 72,940,436 | 1 | true | 2022-07-11T14:04:13.630Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Generic response type based on input type<p>I try to write types for simple function <code>fun</code>.</p>
<p>Here are some interfaces for input and response... |
72,808,410 | Regex cleaning some html string<p>I am trying to parse some html from a website.</p>
<p>The html may contain some invalid html which cause that the parser are not able to parse the html.</p>
<p>this is my regex that I wrote</p>
<pre class="lang-js prettyprint-override"><code>/(\[class\]((=)("|')?.*("|')))|(\[... | <p>Here's a little function to remove specific attributes (and their values) from an HTML string.
<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>var src = `</div><span [clas... | Regex cleaning some html string | javascript|regex | 0 | 53 | 2 | 72,808,520 | 72,808,520 | 1 | true | 2022-06-29T22:14:39.693Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Regex cleaning some html string<p>I am trying to parse some html from a website.</p>
<p>The html may contain some invalid html which cause that the parser ar... |
72,777,759 | ValueError when reading dates from hfsql database using ODBC<p>With some struggles I connected to a hfsql server using ODBC. I've tried both pypyodbc and pyodbc.
My goal is to get some insights in the data (and visualize some aspects).</p>
<p>For some planning visualization I need to read out some of the data, which wo... | <pre class="lang-sql prettyprint-override"><code>SELECT CAST(DeliveryDate AS varchar(12)) AS dd FROM Orders …
</code></pre>
<p>(as suggested in a comment to the question) solved the issue.</p> | ValueError when reading dates from hfsql database using ODBC | python|sql|datetime|pyodbc|pypyodbc | 0 | 53 | 1 | 72,815,974 | 72,815,974 | 1 | true | 2022-06-27T20:05:58.963Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
ValueError when reading dates from hfsql database using ODBC<p>With some struggles I connected to a hfsql server using ODBC. I've tried both pypyodbc and pyo... |
72,897,290 | combine lists nested in a tibble<p>I want to count the number of unique values in a table that contains several from...to pairs like below:</p>
<pre><code>tmp <- tribble(
~group, ~from, ~to,
1, 1, 10,
1, 5, 8,
1, 15, 20,
2, 1, 10,
2, 5, 10,
2, 1... | <pre><code>tmp %>%
rowwise() %>%
mutate(nrs = list(from:to)) %>%
group_by(group) %>%
summarise(n_uni = n_distinct(unlist(nrs)))
</code></pre>
<p>The issue with OP's approach is that <code>rowwise</code> is the equivalent of a new grouping, that drops the initial <code>group_by</code> step. Thus ... | combine lists nested in a tibble | r|dplyr | 0 | 53 | 1 | 72,897,859 | 72,897,859 | 1 | true | 2022-07-07T11:48:49.040Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
combine lists nested in a tibble<p>I want to count the number of unique values in a table that contains several from...to pairs like below:</p>
<pre><code>tm... |
72,969,975 | How to get username of Instagram account<p>I want to know how I can print the username of the Instagram account by the link the user will provide using python. Image attached for better understanding.</p>
<p><a href="https://i.stack.imgur.com/NaZMd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NaZM... | <p>As you mentioned, the Instagram link should be something like this:</p>
<p><code>link = "https://www.instagram.com/instagram"</code></p>
<p>What you can do, is split the string using <code>/</code> as separator, which turns it into a list, and from there get the last value of it:</p>
<p><code>username = li... | How to get username of Instagram account | python|html | -1 | 53 | 2 | 72,970,048 | 72,970,048 | 1 | true | 2022-07-13T16:57:17.803Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to get username of Instagram account<p>I want to know how I can print the username of the Instagram account by the link the user will provide using pytho... |
72,922,252 | Seeing GemWrappers error when doing bundle install<p>Doing <code>bundle install</code> using <code>rails 6.1.5.11</code> and <code>ruby 2.7.6</code>, I keeping seeing a GemWrappers error after installing each gem e.g.</p>
<pre><code> Fetching sprockets 4.0.3
Installing sprockets 4.0.3
GemWrappers: Can not wr... | <p>Gem <code>gem-wrappers</code> is not actively maintained it seems. Last update was in 2017. As per Rubygems it relies on rake < 11.</p>
<p><a href="https://rubygems.org/gems/gem-wrappers" rel="nofollow noreferrer">https://rubygems.org/gems/gem-wrappers</a></p>
<p>Although Rails 6.1.5.1 installs rake 13.0.6</p>
<p... | Seeing GemWrappers error when doing bundle install | ruby-on-rails|bundle|rake | 1 | 53 | 1 | 72,927,542 | 72,927,542 | 1 | true | 2022-07-09T14:38:05.547Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Seeing GemWrappers error when doing bundle install<p>Doing <code>bundle install</code> using <code>rails 6.1.5.11</code> and <code>ruby 2.7.6</code>, I keepi... |
72,993,004 | SelectSingleNode with each node having different namespace<p>I have the following XML:</p>
<pre><code><Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
<cbc:CustomizationID xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2">urn:cen.eu:... | <p>FYI in the future if you have a "default” namespace like this (notice there's no alias on this one)</p>
<pre><code><Invoice xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
</code></pre>
<p>...then you can create a dummy alias while including it in your namespaces list:</p>
<pre c... | SelectSingleNode with each node having different namespace | xml|vba|selectsinglenode | 0 | 53 | 1 | 72,997,440 | 72,997,440 | 1 | true | 2022-07-15T11:04:19.323Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
SelectSingleNode with each node having different namespace<p>I have the following XML:</p>
<pre><code><Invoice xmlns="urn:oasis:names:specification:u... |
72,774,266 | Convert period delimited string into nested dictionary<p>I'm trying to convert a string delimited by periods like this <code>fruits.apple.color</code> into a nested dictionary ( later I'll convert it to JSON):</p>
<pre class="lang-py prettyprint-override"><code>{
"fruits": {
"apple": {
... | <p>I will answer with some simple code here, but I advance you might be interested to use <code>extradict.NestedData</code> in the <code>extradict</code>. Just <code>pip install extradict</code> and it should work out of the box: <a href="https://github.com/jsbueno/extradict" rel="nofollow noreferrer">https://github.c... | Convert period delimited string into nested dictionary | python | 1 | 53 | 2 | 72,774,338 | 72,774,338 | 1 | true | 2022-06-27T15:01:08.183Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Convert period delimited string into nested dictionary<p>I'm trying to convert a string delimited by periods like this <code>fruits.apple.color</code> into a... |
73,023,766 | Pandas select all rows from the recent group<p>I have df:</p>
<pre><code>id date group
1 1.1 3
1 2.1 3
1 3.1 5
1 4.1 5
2 5.2 2
2 6.2 1
2 9.2 1
2 12.2 1
3 15.3 15
3 20.3 20
</code></pre>
<p>I want for each group to get all the rows fro... | <p>this needs 2 steps.</p>
<ol>
<li>get last group per id.</li>
<li>filter df by 1.</li>
</ol>
<pre><code>df = pd.DataFrame(
data=np.array([[1,1.1,3],[1,2.1,3],[1,3.1,5],[1,4.1,5],[2,5.2,2],[2,6.2,1],[2,9.2,1],[2,12.2,1,],[3,15.3,15],[3,20.3,20]]),
columns=['id', 'date', 'group']
)
</code></pre>
<p>step 1. ... | Pandas select all rows from the recent group | python|pandas | -1 | 53 | 1 | 73,023,924 | 73,023,924 | 1 | true | 2022-07-18T14:12:47.207Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Pandas select all rows from the recent group<p>I have df:</p>
<pre><code>id date group
1 1.1 3
1 2.1 3
1 3.1 5
1 4.1 5
... |
72,831,614 | Is there an R function for applying a threshold?<p>I have a dataset that looks like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>start_date</th>
<th>end_date</th>
</tr>
</thead>
<tbody>
<tr>
<td>2021-11-28 05:00:00</td>
<td>2022-06-29 04:00:00</td>
</tr>
<tr>
<td>2021-09-03 04:00:0... | <p>We could create our own treshold function and then apply it to the desired column:</p>
<pre><code>library(dplyr)
library(lubridate)
my_treshold_function <- function(x){
ifelse(x >1, 1, x)
}
df %>%
mutate(across(ends_with("date"), ymd_hms),
days_approved = round(as.numeric(end_date-... | Is there an R function for applying a threshold? | r|datetime|threshold | 0 | 53 | 2 | 72,831,819 | 72,831,819 | 1 | true | 2022-07-01T15:37:30.460Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Is there an R function for applying a threshold?<p>I have a dataset that looks like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>... |
73,009,897 | Creating lists of indexes based on a data frames column's values<p>I would like to extract lists of indexes based on the value of column <code>ID</code>.</p>
<pre><code>data={'ID':[1,1,2,3,6,4,2,6], 'Number': [10,20,5,6,100,90,40,5]}
df=pd.DataFrame(data)
</code></pre>
<p>I know how to do that manually, one value/list... | <p>You can use a for loop</p>
<pre><code>idx_list = []
for ID in data["ID"]:
idx_list.append(df.index[df.ID == ID].tolist())
</code></pre>
<p>This will give you the indices for each <code>ID</code>. Note that there will be duplicates. To avoid this, only add to <code>idx_list</code> if the value is alread... | Creating lists of indexes based on a data frames column's values | python|pandas|list|dataframe | 0 | 53 | 2 | 73,009,953 | 73,009,953 | 1 | true | 2022-07-17T07:20:44.550Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Creating lists of indexes based on a data frames column's values<p>I would like to extract lists of indexes based on the value of column <code>ID</code>.</p>... |
72,980,170 | Regex to find all strings that are not inside balanced parentheses<p>I want to find a regex that works in JavaScript and have the logic to find all strings that are not inside balanced parentheses, i.e. all strings that start and finish with the char <code>"</code> but are not surrounded by both char <code>(</code... | <p><a href="https://www.rexegg.com/regex-best-trick.html#thetrick" rel="nofollow noreferrer">The Trick</a> can make it easier: Match what you don't want, <em>but</em> <a href="https://www.regular-expressions.info/brackets.html" rel="nofollow noreferrer">capture</a> what you need...<br />
<code>not this|(but that)</cod... | Regex to find all strings that are not inside balanced parentheses | regex | 2 | 53 | 1 | 72,980,966 | 72,980,966 | 1 | true | 2022-07-14T12:02:46.060Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Regex to find all strings that are not inside balanced parentheses<p>I want to find a regex that works in JavaScript and have the logic to find all strings t... |
72,870,314 | How to dynamically use icon in a React app based on a string value<p>I have the following setup, and it is working.</p>
<pre><code>import * as Icon1 from 'images/img1.svg'
import * as Icon2 from 'images/img2.svg'
const Foo = () => {
return (<>
<AComponent icon={Icon1}/>
</>)
}
</co... | <p>as @messerbill suggests, you can write a method for it which returns the correct value based on the given parameter.
The method can contain either a 'switch case' or 'if else statements'.
Also you can write an object with values based on icons you have imported:</p>
<pre><code>import * as Icon1 from 'images/img1.svg... | How to dynamically use icon in a React app based on a string value | javascript|reactjs|next.js | 0 | 53 | 2 | 72,870,760 | 72,870,760 | 1 | true | 2022-07-05T13:30:29.543Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to dynamically use icon in a React app based on a string value<p>I have the following setup, and it is working.</p>
<pre><code>import * as Icon1 from 'im... |
72,978,422 | Change names of columns which contain only positive values<p>Let's consider data frame following:</p>
<pre><code>import pandas as pd
df = pd.DataFrame([[1, -2, 3, -5, 4 ,2 ,7 ,-8 ,2], [2, -4, 6, 7, -8, 9, 5, 3, 2], [2, 4, 6, 7, 8, 9, 5, 3, 2], [1, 2, 3, 4, 5, 6, 7, 8, 9]]).transpose()
df.columns = ["A", "... | <p>You are saving the new column names onto a copy of the dataframe. The below statement is not overwriting column names of <code>df</code>, but only of the slice <code>df[pos_idx]</code></p>
<pre><code>df[pos_idx].columns = df[pos_idx].columns + "pos"
</code></pre>
<p>Your second code example directly accces... | Change names of columns which contain only positive values | python|pandas | 0 | 53 | 2 | 72,978,537 | 72,978,537 | 1 | true | 2022-07-14T09:40:50.010Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Change names of columns which contain only positive values<p>Let's consider data frame following:</p>
<pre><code>import pandas as pd
df = pd.DataFrame([[1, -... |
72,986,245 | Index issues while data cleaning<p>Original code credit-Ken Jee</p>
<pre><code>Salary = df['Salary Estimate'].apply(lambda x:x.split('(')[0])
minus_Kd = Salary.apply(lambda x:x.replace('K','').replace('$',''))
min_hr=minus_Kd.apply(lambda x:x.lower().replace('per hour;','').replace('employer
provided salary:',''))
d... | <p>Using .str accessor with extract, regex and eval:</p>
<p>Given df,</p>
<pre><code>df = pd.DataFrame({'Job':['Job 1', 'Job 2', 'Job 3'],
'Salary':['$78K - $191K', '$77K - $107K', '$100K']})
</code></pre>
<p>Input df:</p>
<pre><code> Job Salary
0 Job 1 $78K - $191K
1 Job 2 $77K - $107... | Index issues while data cleaning | python|pandas|visual-studio-code|data-science|data-cleaning | 1 | 53 | 1 | 72,988,192 | 72,988,192 | 1 | true | 2022-07-14T20:19:59.460Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Index issues while data cleaning<p>Original code credit-Ken Jee</p>
<pre><code>Salary = df['Salary Estimate'].apply(lambda x:x.split('(')[0])
minus_Kd = Sala... |
72,396,266 | Navigating screens from different files (BottomNavigationBar using PageController)<p>My project hierarchy is created similar to a MVC design pattern:</p>
<p><a href="https://i.stack.imgur.com/7FPWXm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7FPWXm.png" alt="enter image description here" /></a><... | <p>Your navigation code is correct, the screen shows like that because your <code>NewView</code> is not inside a Scaffold,
to navigate to screen and keep the bottom navigation shown, See the question <a href="https://stackoverflow.com/questions/49628510/flutter-keep-bottomnavigationbar-when-push-to-new-screen-with-navi... | Navigating screens from different files (BottomNavigationBar using PageController) | flutter|dart | 0 | 53 | 1 | 72,396,583 | 72,396,583 | 1 | true | 2022-05-26T18:12:16.550Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Navigating screens from different files (BottomNavigationBar using PageController)<p>My project hierarchy is created similar to a MVC design pattern:</p>
<p>... |
72,401,343 | How to change $(document).ready (function) to onload special tag in order to pass variable to js function<p>Each of them supposed to show a value from database when the page loads. So I wrote three <code>$(document).ready(function)</code> with three input for <code>GET</code> controller value. I know they run parallel ... | <p><code>onload</code> is not a <a href="https://developer.mozilla.org/en-US/docs/Web/HTML/Global_attributes" rel="nofollow noreferrer">global attribute</a> you can't just stick it on any element and expect it to work.</p>
<p>What you should have done was call <code>bringData</code> from the ready function:</p>
<pre cl... | How to change $(document).ready (function) to onload special tag in order to pass variable to js function | javascript|jquery|asp.net-core | 0 | 53 | 1 | 72,402,157 | 72,402,157 | 1 | true | 2022-05-27T06:31:35.520Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to change $(document).ready (function) to onload special tag in order to pass variable to js function<p>Each of them supposed to show a value from databa... |
72,385,273 | What would be the cause of clicking failure in selenium for this checkbox?<p>I have a page as this,
<a href="https://i.stack.imgur.com/oDCTb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oDCTb.png" alt="enter image description here" /></a></p>
<p>And I want to click the top checkbox, which by defau... | <p>The exception message indicates that there is another element that will receive the click. This is a kind of protection in Selenium.<br />
You can try to click this label that is on top of your element. Or click the parent div. Or click your element with JavaScript.</p>
<pre><code>WebElement element = driver.findEle... | What would be the cause of clicking failure in selenium for this checkbox? | selenium|xpath | 0 | 53 | 1 | 72,414,353 | 72,414,353 | 1 | true | 2022-05-25T23:56:05.917Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
What would be the cause of clicking failure in selenium for this checkbox?<p>I have a page as this,
<a href="https://i.stack.imgur.com/oDCTb.png" rel="nofoll... |
72,387,717 | How would I save a player's purchases to DataStore?<p>So I'm working on a game with my friend and we have these game upgrades that unlock new stuff, but I'm wondering how I could save them?</p>
<p>My purchase module is set up like this:</p>
<pre class="lang-lua prettyprint-override"><code>local module = {}
local Upgra... | <p>You can return the id value and purchased value like this.</p>
<pre class="lang-lua prettyprint-override"><code>-- for returning single upgrade
module.getUpgrade = function(upgradeID)
for i, upg in pairs(Upgrades) do
if upg.id == upgradeID then
return {id = upg.id, purchased = upg.purchased}
... | How would I save a player's purchases to DataStore? | lua|roblox | 1 | 53 | 2 | 72,420,214 | 72,420,214 | 1 | true | 2022-05-26T06:37:09.777Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How would I save a player's purchases to DataStore?<p>So I'm working on a game with my friend and we have these game upgrades that unlock new stuff, but I'm ... |
72,390,374 | How to mock methods in the below code in the .NET 6 using Moq?<p>Below is <strong>InvokeAsync</strong> method which need to tested.</p>
<pre><code> public async Task<bool> InvokeAsync(Batch batch)
{
var refundRequests = await this.RefundRepository.GetsAsync(batch.RefundRequests.Select(x => x.Id)... | <p>When you <code>Setup</code> your mocks with a specific parameter, the <code>Returns</code> only applies when this specific parameter is used.</p>
<p>The reason <code>UpdateBatch</code> works is because you're using the same reference to the same <code>Batch</code> in both the mock and the class under test:</p>
<pre>... | How to mock methods in the below code in the .NET 6 using Moq? | c#|asp.net-core|moq|.net-6.0|xunit.net | 1 | 53 | 1 | 72,422,192 | 72,422,192 | 1 | true | 2022-05-26T10:29:38.200Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to mock methods in the below code in the .NET 6 using Moq?<p>Below is <strong>InvokeAsync</strong> method which need to tested.</p>
<pre><code> public... |
72,394,112 | Data entry field displaying entered values<p>My application has a modal window with filters. I would like to add another kind of filter to it. I just don’t know how to implement it in React (perhaps you can help me with the code, recommend links).</p>
<p>The meaning is as follows: I want the filters to have a line in w... | <p>For UI you can use or create a custom input field like this <a href="https://evergreen.segment.com/components/tag-input" rel="nofollow noreferrer">https://evergreen.segment.com/components/tag-input</a>.</p>
<p>For implementation:
Now you have fields searched by user
Ex-</p>
<p><div class="snippet" data-lang="js" dat... | Data entry field displaying entered values | javascript|reactjs|filter | 0 | 53 | 2 | 72,425,841 | 72,425,841 | 1 | true | 2022-05-26T15:16:07.673Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Data entry field displaying entered values<p>My application has a modal window with filters. I would like to add another kind of filter to it. I just don’t k... |
72,334,143 | Do the 1>, 2>, 3> symbols in msbuild output stand for threads?<p>I recently turned on normal logging verbosity for msbuild to debug some build issues. I use the -m -graph arguments and am building a solution that contains 3 projects. One project is a MyProjectlibrary, one is a MyProjectTests test project that calls the... | <p>The numbers are a 'project key'. They are generated per build and within a build are unique per project.</p>
<p>The numbers do indicate parallel processing and identify chunks of messages that have been gathered in a centralized logger. But the numbers are not the nodes.</p>
<p>An 'MSBuild node' is an isolated proce... | Do the 1>, 2>, 3> symbols in msbuild output stand for threads? | c#|msbuild | 1 | 53 | 1 | 72,441,477 | 72,441,477 | 1 | true | 2022-05-22T01:00:35.783Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Do the 1>, 2>, 3> symbols in msbuild output stand for threads?<p>I recently turned on normal logging verbosity for msbuild to debug some build issues. I use ... |
72,310,241 | how to make the captcha have a bootstrap class?<p>I have a problem with the captcha, I'm using the ¨Django Simple Captcha¨ the problem is that it doesn't let me place a bootstrap class so that the input has a better appearance.</p>
<p>I tried to:</p>
<ul>
<li>I Put widget_tweaks in that input, but it does not send the ... | <p>I haven't verified this, but you might try:</p>
<pre><code>from captcha.fields import CaptchaField, CaptchaTextInput
class RegisterForm(UserCreationForm):
captcha=CaptchaField(widget=CaptchaTextInput(attrs={'class': 'form-control'}))
</code></pre>
<p>Not sure if widget_tweaks plays nicely with MultiValueFields, ... | how to make the captcha have a bootstrap class? | python|css|django | 1 | 53 | 1 | 72,312,087 | 72,312,087 | 1 | true | 2022-05-19T19:38:28.063Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
how to make the captcha have a bootstrap class?<p>I have a problem with the captcha, I'm using the ¨Django Simple Captcha¨ the problem is that it doesn't let... |
72,292,791 | Set the labels of legend based on input selection in shiny app<p>In the shiny app below below I want to modify the names in the legend with the following logic. When <code>geom_line(aes(x,y))</code> then besides to the brand name should be pasted <code>Sell Out</code>,when <code>geom_line(aes(x1,y1))</code> then beside... | <p>It might be easier if you setup your data frame in a long form.</p>
<p>Try this</p>
<pre><code>## app.R ##
library(shiny)
library(shinydashboard)
library(plotly)
library(tidyr)
BRAND<-c("CHOKIS","CHOKIS","CHOKIS","CHOKIS","CHOKIS","CHOKIS","LARA CHO... | Set the labels of legend based on input selection in shiny app | r|ggplot2|shiny | 0 | 53 | 1 | 72,295,515 | 72,295,515 | 1 | true | 2022-05-18T16:23:48.403Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Set the labels of legend based on input selection in shiny app<p>In the shiny app below below I want to modify the names in the legend with the following log... |
72,305,685 | Erasing list elements step by step<p>I want to erase list elements one by one. Before removing any of list elements I want to see the whole list.</p>
<pre><code>#include <iostream>
#include <list>
int main()
{
std::list<int>numbers{0,1,2,3,4,5,6,7,8,9};
auto it=numbers.begin();
for(int i=0... | <p>The issue is with these two lines</p>
<pre><code>it=numbers.erase(it);
it++;
</code></pre>
<p>The function, <code>list::erase</code>, returns an iterator pointing to the element that followed the last element erased. Here, your code removes the item from the list and sets <code>it</code> to the next element in the l... | Erasing list elements step by step | c++|stdlist | 0 | 53 | 3 | 72,306,619 | 72,306,619 | 1 | true | 2022-05-19T13:43:46.910Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Erasing list elements step by step<p>I want to erase list elements one by one. Before removing any of list elements I want to see the whole list.</p>
<pre><c... |
72,239,657 | Tkinter: move scrollbar automatically to the founded item when searching<p>This is a little replica of my app where I've numerous text widget create with a for loop; I've also create a search entry and option to highlight the context inside the text widget to make it easier to find the text that one is looking for. I w... | <p>This worked for me:</p>
<p>There are comments where I changed something, explaining what the added code does</p>
<pre class="lang-py prettyprint-override"><code>class App(tk.Frame):
# (rest of code)
def search(self):
self.found = self.entry.get()
# variable to store index of Label w... | Tkinter: move scrollbar automatically to the founded item when searching | python|tkinter | 0 | 53 | 1 | 72,240,532 | 72,240,532 | 1 | true | 2022-05-14T11:13:09.780Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Tkinter: move scrollbar automatically to the founded item when searching<p>This is a little replica of my app where I've numerous text widget create with a f... |
72,385,927 | How to convert lifetime of boxed reference without allocating a new box?<h2>Context</h2>
<p><a href="https://play.rust-lang.org/?version=stable&mode=debug&edition=2021&gist=1f50896fc89fa4535da952a2d8c5399c" rel="nofollow noreferrer">Playground</a>, This works:</p>
<pre><code>fn get_owned_box_working<'a&g... | <blockquote>
<p>How come the compiler can't update the lifetime of the existing box from <code>'a</code> -> <code>'static</code> when I mutate it?</p>
</blockquote>
<p>From the compiler point of view, you cannot "update" the value from using <code>'a</code> to using <code>'static</code>. You are assigning ... | How to convert lifetime of boxed reference without allocating a new box? | rust | 1 | 53 | 2 | 72,386,017 | 72,386,017 | 1 | true | 2022-05-26T02:06:20.030Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to convert lifetime of boxed reference without allocating a new box?<h2>Context</h2>
<p><a href="https://play.rust-lang.org/?version=stable&mode=debu... |
72,240,613 | Keep selected theme on page refresh using HTML, CSS and JavaScript<p>I would like to keep the selected theme when refreshing the page as well as across all other pages. I've seen other examples but I don't know how to implement it in the code as I'm quite newbie. I've included the code of the functionality so far. Many... | <p>For that you could use <a href="https://developer.mozilla.org/en-US/docs/Web/API/Window/localStorage" rel="nofollow noreferrer">localStorage</a>. Keep your HTML and CSS code as they are. Your JavaScript code could be like so :</p>
<pre class="lang-js prettyprint-override"><code>// get stored theme on load
let stored... | Keep selected theme on page refresh using HTML, CSS and JavaScript | javascript|html|css | 2 | 53 | 3 | 72,240,715 | 72,240,715 | 1 | true | 2022-05-14T13:21:00.857Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Keep selected theme on page refresh using HTML, CSS and JavaScript<p>I would like to keep the selected theme when refreshing the page as well as across all o... |
72,366,470 | Accessing script file location from an external file python<p>I have the following bizarre set up. Consider 3 scripts in different directories:</p>
<ul>
<li>root1/folderA/scriptA.py</li>
<li>root2/folderB/scriptB.py</li>
<li>root2/folderC/scriptC.py</li>
</ul>
<p>The first file and it's location are fully modifiable. T... | <p>It looks like the trick is to use <code>__init_subclass__</code> which runs whenever a class is sub-classed, in conjunction with a class's <code>__module__</code> attribute to retrieve its containing module, and <code>__file__</code> to retrieve the absolute path to the python script or module.</p>
<p>For example, i... | Accessing script file location from an external file python | python|inheritance|path|filepath | 2 | 53 | 1 | 72,366,657 | 72,366,657 | 1 | true | 2022-05-24T16:36:38.067Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Accessing script file location from an external file python<p>I have the following bizarre set up. Consider 3 scripts in different directories:</p>
<ul>
<li>... |
72,252,431 | How could i save all the hashes generated from jpg images into a csv file and not only the last one?<pre><code>import imagehash
from PIL import Image
import glob
import numpy as np
image_list = []
for filename in glob.glob('/home/folder/*.jpg'):
im=Image.open(filename)
image_list.append(im)
hash = imagehas... | <p>Here, you're overwriting your <code>list_rows</code> variable for every step in the loop. You should append to the list instead, and then write the content of the list to your csv.</p>
<pre class="lang-py prettyprint-override"><code>import imagehash
from PIL import Image
import glob
import numpy as np
image_list = ... | How could i save all the hashes generated from jpg images into a csv file and not only the last one? | python|imagehash | 0 | 53 | 1 | 72,252,532 | 72,252,532 | 1 | true | 2022-05-15T21:49:01.667Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How could i save all the hashes generated from jpg images into a csv file and not only the last one?<pre><code>import imagehash
from PIL import Image
import ... |
72,388,395 | How to query multiplte row in one json object<p>table provider</p>
<p><a href="https://i.stack.imgur.com/plsOe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/plsOe.png" alt="enter image description here" /></a></p>
<p>table provider_properties</p>
<p><a href="https://i.stack.imgur.com/Fi1po.png" rel... | <p>Since your expected results need specific formatting in json. You want to refer to <a href="https://dev.mysql.com/doc/mysql-shell/8.0/en/mysql-shell-json-output.html" rel="nofollow noreferrer">JSON Formatted output</a>. This is for shell though.</p>
<p>You might also want to try this...</p>
<p>This would give you a ... | How to query multiplte row in one json object | mysql|sql | 0 | 53 | 2 | 72,388,813 | 72,388,813 | 1 | true | 2022-05-26T07:41:29.157Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to query multiplte row in one json object<p>table provider</p>
<p><a href="https://i.stack.imgur.com/plsOe.png" rel="nofollow noreferrer"><img src="https... |
72,278,641 | How can I transpose from a column to rows an employee timesheet data<p>I have a employee timesheet data in 1 column and need to transpose this to lines and columns.</p>
<p><strong>Original data with 1 column</strong></p>
<pre><code>mon
02/05/2022
9:04
12:47
13:52
18:09
-
-
tue
03/05/2022
9:13
13:03
14:06
1... | <p>try:</p>
<pre><code>={QUERY(A1:A, "skipping 8", ),
QUERY(A2:A, "skipping 8", ),
QUERY(A3:A, "skipping 8", ),
QUERY(A4:A, "skipping 8", ),
QUERY(A5:A, "skipping 8", ),
QUERY(A6:A, "skipping 8", ),
QUERY(A7:A, "skipping 8", ),
Q... | How can I transpose from a column to rows an employee timesheet data | arrays|google-sheets|filter|transpose|flatten | 1 | 53 | 2 | 72,278,973 | 72,278,973 | 1 | true | 2022-05-17T17:56:43.900Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How can I transpose from a column to rows an employee timesheet data<p>I have a employee timesheet data in 1 column and need to transpose this to lines and c... |
72,307,055 | Change all option tags to the same value<p>I am trying get all the rounds to be the same and the best i can do is change the first one. The current code has all the player scorecards open now i just need to be able to select the same round for all of them.</p>
<p>ignore all the imports i was trying a few things, i am e... | <p>This code runs a first loop to open the scorecards, then a second loop to change the round. The command <code>.send_keys(Keys.DOWN * n)</code> where n is an integer, press the down arrow n times.</p>
<pre><code>import time
from selenium.webdriver.common.keys import Keys
number_of_players = 10
round_to_select = 1
f... | Change all option tags to the same value | python|selenium|loops|dropdown | 0 | 53 | 1 | 72,309,462 | 72,309,462 | 1 | true | 2022-05-19T15:13:50.593Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Change all option tags to the same value<p>I am trying get all the rounds to be the same and the best i can do is change the first one. The current code has ... |
72,346,642 | How to split string according to two conditions at the beginning and end of a sentence simultaneously?<p>I have a string like,</p>
<pre><code>str1 = "ZZZ。10月,AAA。11月2日,BBB。CCC。3日,DDD。EEE。12月,FFF"
</code></pre>
<p>And I want to split this string by two conditions: <code>日</code> or <code>月</code> appear at the... | <p>You can use <code>re.split</code> with</p>
<pre class="lang-none prettyprint-override"><code>(?<=。)(?=\s*\d{1,2}[日月])
</code></pre>
<p>See the <a href="https://regex101.com/r/A44JBd/4" rel="nofollow noreferrer">regex demo</a>. <em>Details</em>:</p>
<ul>
<li><code>(?<=。)</code> - match a location right after a ... | How to split string according to two conditions at the beginning and end of a sentence simultaneously? | python|python-3.x|regex | 1 | 53 | 1 | 72,346,717 | 72,346,717 | 1 | true | 2022-05-23T10:00:11.030Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to split string according to two conditions at the beginning and end of a sentence simultaneously?<p>I have a string like,</p>
<pre><code>str1 = "ZZ... |
72,272,848 | How to merge DataFrames on their columns index places?<p>Suppose I have two dataframes (note column indices):</p>
<p><a href="https://i.stack.imgur.com/mipdp.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/mipdp.png" alt="enter image description here" /></a> = A =</p>
<pre><code> 2 3 4
... | <p>Here is a way to do what you've asked:</p>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
import numpy as np
A = pd.DataFrame(data={j: ['A' + str(i) for i in range(1, 6)] for j in range(2, 5)})
B = pd.DataFrame(data={j: ['B' + str(i) for i in range(1, 6)] for j in range(6, 10)})
print(A)
print(... | How to merge DataFrames on their columns index places? | python|pandas|dataframe | 1 | 53 | 3 | 72,273,295 | 72,273,295 | 1 | true | 2022-05-17T10:59:33.697Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to merge DataFrames on their columns index places?<p>Suppose I have two dataframes (note column indices):</p>
<p><a href="https://i.stack.imgur.com/mipdp... |
72,312,231 | Python: convert column containing string to column containing json dictionary<p>I have a Dataframe with columns that look like this:</p>
<pre><code>df=pd.DataFrame()
df['symbol'] = ['A','B','C']
df['json_list'] = ['[{name:S&P500, perc:25, ticker:SPY, weight:1}]',
'[{name:S&P500, perc:25, ticker:SPY, w... | <p><strong>UPDATED</strong> to reflect the fact that the json strings in the question are not singleton lists, but can contain multiple dict-like elements.</p>
<p>This will put a <code>list</code> of <code>dict</code> object in a new column of your dataframe:</p>
<pre class="lang-py prettyprint-override"><code>def foo(... | Python: convert column containing string to column containing json dictionary | python|json|pandas|string|dictionary | 0 | 53 | 2 | 72,312,294 | 72,312,294 | 1 | true | 2022-05-20T00:03:54.260Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Python: convert column containing string to column containing json dictionary<p>I have a Dataframe with columns that look like this:</p>
<pre><code>df=pd.Dat... |
72,240,577 | How can I show company name with logo up, when seaching in address bar?<p>When I search a company in URL search bar, Some companies show their logo, company name, and description which links to their website.</p>
<p>I really want to add this feature to my company,
so.. How can I add this feature? I even have no idea, w... | <p>You should make a google business profile. <a href="https://business.google.com/create" rel="nofollow noreferrer">https://business.google.com/create</a></p>
<p>It will take the added photo of the profile and display it automatically. Don't know if it's instant to be honest (can be google needs to index it first), bu... | How can I show company name with logo up, when seaching in address bar? | google-chrome|web | 1 | 53 | 1 | 72,240,994 | 72,240,994 | 1 | true | 2022-05-14T13:16:42.830Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How can I show company name with logo up, when seaching in address bar?<p>When I search a company in URL search bar, Some companies show their logo, company ... |
72,274,399 | Quantifying frequency of codons in a transmembrane sequence - apply function?<p>I am trying to look at the codon usage within the transmembrane domains of certain proteins.</p>
<p>To do this, I have the sequences for the TM domain, and I want to search these sequences for how often certain codons appear (the frequency)... | <p>Split the problem into sub-problems, solve them individually, and compose the solution.</p>
<p>The first subproblem is: how do I get codon frequencies of a given (in-frame) sequence? The answer is either to use a pre-made solution (e.g. Bioconductor’s <code>Biostrings:: trinucleotideFrequency(…, steps = 3L)</code>),... | Quantifying frequency of codons in a transmembrane sequence - apply function? | r|apply|bioinformatics|lapply|dna-sequence | 4 | 53 | 2 | 72,275,787 | 72,275,787 | 1 | true | 2022-05-17T12:51:23.973Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Quantifying frequency of codons in a transmembrane sequence - apply function?<p>I am trying to look at the codon usage within the transmembrane domains of ce... |
72,284,464 | nested ul li out of position<p>I created small nav menu which will hold another options. The li element needs to be opened and another list appears. Unfortunately my nested list appears next to the parent li instead of below. Meanwhile I tweaked there and here and can´t find my problem, it must be something so simple w... | <p>You have a problem related to the flexbox. All elements under <code>main-menu-li</code> are flex items including your sub <code>ul</code>.</p>
<p>For a fix, you should separate those elements in <code>main-menu-li</code> by divs and set flexboxes for divs instead.</p>
<p><div class="snippet" data-lang="js" data-hide... | nested ul li out of position | html|css | 2 | 53 | 1 | 72,284,771 | 72,284,771 | 1 | true | 2022-05-18T06:56:10.603Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
nested ul li out of position<p>I created small nav menu which will hold another options. The li element needs to be opened and another list appears. Unfortun... |
72,317,454 | How to use pandas groupby to an unknown amout of columns?<p>I just want to know how it is possible to use this command <code>df.groupby(['column1', 'column2', 'column3']).size()</code> with a variable amount of columns.</p> | <p>You can give groupby a list of columns.</p>
<pre><code>grouper = ['column1', 'column2', 'column3']
df.groupby(grouper).size()
</code></pre>
<p>There is no difference between instantiating the list to give it as a function parameter or assigning it to a variable and using that in the function. You can change the col... | How to use pandas groupby to an unknown amout of columns? | python|pandas | -1 | 53 | 3 | 72,317,505 | 72,317,505 | 1 | true | 2022-05-20T10:34:36.093Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to use pandas groupby to an unknown amout of columns?<p>I just want to know how it is possible to use this command <code>df.groupby(['column1', 'column2'... |
72,335,652 | how to round a number to N decimal places in C++? (correction)<p>I want to round a number (6.756765345678765) to 10 decimal places , but it returns '6.75677', although it could returns '6.7567653457'</p>
<pre><code>#include <iostream>
#include <cmath>
using namespace std;
double rounded(double number, int ... | <p>You can use <code>setprecision(10)</code> function of <code><iomanip></code>.</p>
<pre><code>#include <iostream>
#include <iomanip>
using namespace std;
int main()
{
double value = 6.756765345678765;
cout << setprecision(10) << value;
}
</code></pre>
<p>Output:</p>
<pre><code>... | how to round a number to N decimal places in C++? (correction) | python|c++ | 0 | 53 | 2 | 72,335,724 | 72,335,724 | 1 | true | 2022-05-22T07:37:01.487Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
how to round a number to N decimal places in C++? (correction)<p>I want to round a number (6.756765345678765) to 10 decimal places , but it returns '6.75677'... |
72,338,847 | Inject the right set of Props into Modal based on clicked button ID<p>I am facing a problem, which I am sure is simple to solve, however, I cannot figure out the solution to it.
The problem is the following:</p>
<p>I am writing a <code>Vue.js</code> application. I have a component with 3 buttons in it. Each button is m... | <p>You can set and pass index of <code>modalMessages</code> in <code>showModal</code> method, and bind props in modal component:</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... | Inject the right set of Props into Modal based on clicked button ID | javascript|vue.js|vuejs2 | 0 | 53 | 1 | 72,338,967 | 72,338,967 | 1 | true | 2022-05-22T15:17:31.917Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Inject the right set of Props into Modal based on clicked button ID<p>I am facing a problem, which I am sure is simple to solve, however, I cannot figure out... |
72,368,217 | Dynamically Binding parameters to push to SQL Server<p>I have a lot of historical data I'm pushing to SQL. As a stop gap I'm coding this in VBA first. I open the <code>.xlsx</code> file, put the headers into an array to determine what SQL table the data goes into. Then I'm using solution #3 from <a href="https://stacko... | <p>My VBA is more than a little rusty, so there's likely a mistake in here, but I do believe this will get you to a better place.</p>
<p>That disclaimer out of the way, a <code>.</code> is just another binary operator, and so I think the space in</p>
<pre><code>.Parameters.Append .CreateParameter
</code></pre>
<p>is no... | Dynamically Binding parameters to push to SQL Server | sql-server|excel|vba | 1 | 53 | 2 | 72,368,740 | 72,368,740 | 1 | true | 2022-05-24T19:05:54.487Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Dynamically Binding parameters to push to SQL Server<p>I have a lot of historical data I'm pushing to SQL. As a stop gap I'm coding this in VBA first. I open... |
72,378,300 | How to select the last paragraph element ONLY if no other elements follow after her? (CSS selector question)<p>How can I select the last paragraph <code><p></code> element, if and only its the last and lowest HTML element of the <code><article></code> element?</p>
<p>I don't want to use <code>.classes</code... | <p>Some options for you. Main thing selecting the first <code>article</code> child.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>article:nth-child(1) p:last-of-type {
ba... | How to select the last paragraph element ONLY if no other elements follow after her? (CSS selector question) | html|css|layout|css-selectors|selector | 1 | 53 | 3 | 72,378,405 | 72,378,405 | 1 | true | 2022-05-25T13:11:19.043Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to select the last paragraph element ONLY if no other elements follow after her? (CSS selector question)<p>How can I select the last paragraph <code><... |
72,366,076 | Grouping With aggregation in MongoDB<p>Currently I'm using aggregation in MongoDB. There is a field with province and religion in my collections. I'm doing this</p>
<pre><code>const data = await submit.aggregate([
{ "$group": { _id: { province: "$province" ,religion:"$religion"}, count... | <p>You seek 2 different <code>$group</code> at the same time -- this is exactly what <code>$facet</code> is for. Think of <code>$facet</code> like "multi-group." Given an input set similar to the following:</p>
<pre class="lang-js prettyprint-override"><code> { religion: 'a', province: 'aa' },
{ reli... | Grouping With aggregation in MongoDB | mongodb | 1 | 53 | 1 | 72,366,911 | 72,366,911 | 1 | true | 2022-05-24T16:05:39.173Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Grouping With aggregation in MongoDB<p>Currently I'm using aggregation in MongoDB. There is a field with province and religion in my collections. I'm doing t... |
72,246,793 | Sql query find all rows where value is null but another row wih same value not null (Mariadb)<pre><code>id_product|pn|ean13|supplier|
-----------------------------
1 |1F46G| FGH45642346|1|
2 |8BBBB| null |1|
3 |1F46G| null |2|
4 |1F46G| FGH45642346 |3|
</code></pre>
<p>Hello I have table structure like this (just more ... | <p>You can rewrite the query as below to get the desired output.
Write a subquery to identify pn having ean13 as not null.</p>
<pre><code>SELECT id_product,pn
from product
WHERE pn !='' AND (ean13 is null OR ean13 = '')
and pn in(
select pn from product where not (ean13 is null OR ean13 = '')
);
</code></pre>
<p>DB Fid... | Sql query find all rows where value is null but another row wih same value not null (Mariadb) | mysql|sql|select|mariadb | -1 | 53 | 2 | 72,246,888 | 72,246,888 | 1 | true | 2022-05-15T08:46:29.353Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Sql query find all rows where value is null but another row wih same value not null (Mariadb)<pre><code>id_product|pn|ean13|supplier|
-----------------------... |
72,243,210 | Add elements in a list at the n index of a other list<pre><code>calibres_prix =['115-135', '1.87'], ['136-165', '1.97'], ['150-180', '1.97'],
['190-220', '1.97'], ['80-95', '1.42'], ['95-115', '1.52'], ['150-180', '1.82'],
['115-135', '1.72'], ['136-165', '1.82'], ['150-180', '1.82'], ['190-220', '1.82'],
... | <p>Close! You are appending all the varieties to each list in your loop, however.</p>
<p>You could try this instead:</p>
<pre><code>for i in range(0, len(calibres_prix)):
calibres_prix[i] = [varieties[i//24]] + calibres_prix[i]
</code></pre>
<p>For each list in <code>calibres_prix</code> (I have assumed this is a ... | Add elements in a list at the n index of a other list | python|list|indexing|insert|range | 0 | 53 | 3 | 72,243,261 | 72,243,261 | 2 | true | 2022-05-14T19:13:48.850Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Add elements in a list at the n index of a other list<pre><code>calibres_prix =['115-135', '1.87'], ['136-165', '1.97'], ['150-180', '1.97'],
['190-220'... |
72,266,895 | How to iterate through this html table and get data from rows whose last col is not empty?<p>I've been trying to get this data, but the array comes out empty:</p>
<pre><code>function saveData() {
var tableData = [];
var table = document.getElementById("dtable");
console.log(table)
for (var i = 0; i &... | <p>In your script, as one of several possible modifications, how about the following modification?</p>
<h3>From:</h3>
<pre><code>var tableData = [];
var table = document.getElementById("dtable");
console.log(table)
for (var i = 0; i < table.length; i++) {
let tableCells = table.rows.item(i).cells;
let... | How to iterate through this html table and get data from rows whose last col is not empty? | javascript|html|google-apps-script|web-applications | 1 | 53 | 1 | 72,267,022 | 72,267,022 | 2 | true | 2022-05-17T00:14:03.787Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to iterate through this html table and get data from rows whose last col is not empty?<p>I've been trying to get this data, but the array comes out empty... |
72,288,748 | Why fgets just have one line when i want to count the number of char<p>I tried this to count the number of char in a .txt that looks like that</p>
<pre><code>ID2;Orelsan;San;Musiques\\Orelsan San.mp3
ID1;Rick Astley;Never Gonna Give You Up;Musiques\\Rick Astley - Never Gonna Give You Up.mp3
</code></pre>
<p>I wrote thi... | <p><code>fgets</code> returns <code>NULL</code> (and not <code>EOF</code>) if there is no more data left to read.</p>
<p>You probably want this:</p>
<pre><code>inputFile = fopen("bddmp3.txt", "rt");
if (inputFile == NULL) {
.. handle error
}
while (fgets(buffer2,255,inputFile) != NULL) {
size... | Why fgets just have one line when i want to count the number of char | c|string|char|fgets | 0 | 53 | 2 | 72,288,866 | 72,288,866 | 2 | true | 2022-05-18T11:55:28.123Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Why fgets just have one line when i want to count the number of char<p>I tried this to count the number of char in a .txt that looks like that</p>
<pre><code... |
72,291,452 | Calculate the rowwise mean when a maximum number of NA values is given for a set of columns using dplyr<p>Example dataset...</p>
<pre><code>> tribble(
+ ~colA, ~colB, ~colC, ~colD, ~colE,
+ 1, 2, 3, 4, 5,
+ 2, 3, NA, 4, 5,
+ 3, NA, NA, NA, 4,
+ 4, NA, NA, 5, 6
+ )
# A tibble: 4 × 5
colA colB colC col... | <p>We can use <code>across</code> to select column of interest.</p>
<pre><code>library(dplyr)
dat %>%
mutate(mean = ifelse(rowSums(is.na(across(-colA))) > 2,
NA,
rowMeans(across(-colA), na.rm = T)))
# A tibble: 4 × 6
colA colB colC colD colE mean
<... | Calculate the rowwise mean when a maximum number of NA values is given for a set of columns using dplyr | r|dplyr|across|tidyselect | 1 | 53 | 4 | 72,291,592 | 72,291,592 | 2 | true | 2022-05-18T14:53:07.040Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Calculate the rowwise mean when a maximum number of NA values is given for a set of columns using dplyr<p>Example dataset...</p>
<pre><code>> tribble(
+ ... |
72,302,547 | SQL reset row_number when previous id column null<p>This is hard to explain so I will give an example.
I need SQL (ms server), I assume its with row_number over partition but can't get it to work.</p>
<p>I have this table:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>Previous... | <p>Seems you want a windowed <code>COUNT</code> of rows where the value of <code>PreviousID</code> is <code>NULL</code>.</p>
<pre class="lang-sql prettyprint-override"><code>SELECT ID,
COUNT(CASE WHEN PreviousID IS NULL THEN 1 END) OVER (ORDER BY ID) AS NewID,
Data
FROM dbo.YourTable;
</code></pre> | SQL reset row_number when previous id column null | sql|sql-server | -1 | 53 | 1 | 72,302,581 | 72,302,581 | 2 | true | 2022-05-19T10:01:05.983Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
SQL reset row_number when previous id column null<p>This is hard to explain so I will give an example.
I need SQL (ms server), I assume its with row_number o... |
72,303,516 | Hosting Angular app on Vercel with dependencies<p>I get the following error when trying to host my Angular application on Vercel:</p>
<blockquote>
<p>Error: src/app/spotify.service.ts:25:32 - error TS2339: Property 'spotifyApiKey' does not exist on type '{ production: boolean; }'.</p>
</blockquote>
<p>This makes sense ... | <blockquote>
<p>This makes sense since the property spotifyApiKey is set by a JavaScript script that is called in package.json.</p>
</blockquote>
<p>Okay, but you haven't properly typed it. The type should be:</p>
<pre class="lang-js prettyprint-override"><code>{ production: boolean, spotifyApiKey: string }
</code></pr... | Hosting Angular app on Vercel with dependencies | javascript|angular|package.json|vercel | 1 | 53 | 1 | 72,303,648 | 72,303,648 | 2 | true | 2022-05-19T11:11:44.510Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Hosting Angular app on Vercel with dependencies<p>I get the following error when trying to host my Angular application on Vercel:</p>
<blockquote>
<p>Error: ... |
72,303,742 | Problem with the "and" operator in python<p>I was working on what seemed an easy exercise but I ran into a problem with a the "and" orperator.
I think I understand quite well how it works:</p>
<pre><code>print("0 and 0 : ", (0 and 0))
print("0 and 1 : ", (0 and 1))
print("1 and 0 : &q... | <p>Let's take a slightly different case:</p>
<pre><code>0 and None -> 0
None and 0 -> None
'1' and '0' -> '0'
'0' and '1' -> '1'
</code></pre>
<p>Why? Well in the first two cases, both <code>0</code> (an integer) and <code>None</code> are falsy, so the first one is returned. In the second two cases, you hav... | Problem with the "and" operator in python | python|logic|operator-keyword | 1 | 53 | 3 | 72,304,240 | 72,304,240 | 2 | true | 2022-05-19T11:28:40.383Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Problem with the "and" operator in python<p>I was working on what seemed an easy exercise but I ran into a problem with a the "and" orperator.
I th... |
72,308,874 | how to order columns by names containing special symbols R<p>I have dataframe below:</p>
<pre><code>df <- data.frame(aa = rep(1,4),
ae = rep(2,4),
dd = rep(3,4),
`aa%` = rep(11,4),
`ae%` = rep(22,4),
`dd%` = rep(33,4))
aa ae dd aa. ae... | <p>Use <code>mixedsort</code> instead of <code>mixedorder</code></p>
<pre><code>library(gtools)
library(dplyr)
df %>%
select(mixedsort(names(.)))
aa aa. ae ae. dd dd.
1 1 11 2 22 3 33
2 1 11 2 22 3 33
3 1 11 2 22 3 33
4 1 11 2 22 3 33
</code></pre>
<hr />
<p>The issue with <code>mixed... | how to order columns by names containing special symbols R | r|dataframe|dplyr|tidyverse | 2 | 53 | 5 | 72,308,907 | 72,308,907 | 2 | true | 2022-05-19T17:34:52.627Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
how to order columns by names containing special symbols R<p>I have dataframe below:</p>
<pre><code>df <- data.frame(aa = rep(1,4),
ae = r... |
72,308,894 | Javascript not working when imported into html from js file?<p>I have some code in a .js file that is used in checkboxes. When imported into the html, though, the first two checkbox sections work (location, pop) but the last one does not. When I have the js in the html instead of importing it, all three sections (locat... | <p>Make sure the script is loaded at the bottom of your HTML document, or better, use the <code>defer</code> attribute so the script wait for the entire HTML to be ready before running.</p>
<p>Having the script being executed too early can make it try to manipulate HTML tags that are not yet ready.</p>
<p>For more info... | Javascript not working when imported into html from js file? | javascript|html | 0 | 53 | 3 | 72,309,118 | 72,309,118 | 2 | true | 2022-05-19T17:36:07.767Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Javascript not working when imported into html from js file?<p>I have some code in a .js file that is used in checkboxes. When imported into the html, though... |
72,324,668 | Define type alias between template and class declaration in order to inherent from it<p>I have a class template which uses some type alias through its implementation, and also inherits from the same type:</p>
<pre><code>template<typename TLongTypename,
typename TAnotherLongTypename,
typename THey... | <p>You could declare the type alias <code>Meow</code> as a default template parameter, directly in the template parameter list, which means you only have to spell it out once:</p>
<pre><code>template<typename TLongTypename,
typename TAnotherLongTypename,
typename THeyLookAnotherTypename,
... | Define type alias between template and class declaration in order to inherent from it | c++|templates|alias | 0 | 53 | 1 | 72,325,774 | 72,325,774 | 2 | true | 2022-05-20T20:52:24.753Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Define type alias between template and class declaration in order to inherent from it<p>I have a class template which uses some type alias through its implem... |
72,328,504 | Does PHP have a password_verify bug?<p>The following code snippet should not emit 'MATCHED' because the password 'testtest' does not match 'testtesttest', but does on PHP 7.4.3 for me. Am I doing something wrong?</p>
<pre class="lang-php prettyprint-override"><code><?php
$sPass = 'testtesttest';
$sSalt = hash('sha25... | <p><a href="https://en.wikipedia.org/wiki/Bcrypt" rel="nofollow noreferrer">BCrypt can only handle 72 characters</a>, your salt takes up 64 characters, so only 8 characters of your password are considered.</p>
<blockquote>
<p>The input to the bcrypt function is the password string (<strong>up to 72 bytes</strong>), a n... | Does PHP have a password_verify bug? | php|passwords|password-hash | 0 | 53 | 1 | 72,328,579 | 72,328,579 | 2 | true | 2022-05-21T09:58:15.067Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Does PHP have a password_verify bug?<p>The following code snippet should not emit 'MATCHED' because the password 'testtest' does not match 'testtesttest', bu... |
72,340,585 | How to combine 3 separate SQL statements into 1 set of results<p>I have a SQL query that I am running 3 times (3 changing only the date range) and want to combine the result into one table, instead of running 3 different queries and trying to join outside of SQL. I am trying to find amount of times something has occurr... | <p>Looks like you need conditional aggregation with three different start dates.</p>
<pre class="lang-sql prettyprint-override"><code>DECLARE @D date = '2022-05-20';
DECLARE @M date = '2022-04-21';
DECLARE @Y date = '2021-05-21';
SELECT InvNum = LEFT(li.InventoryNumber, 3)
,DayCount = COUNT(CASE WHEN i.Dat... | How to combine 3 separate SQL statements into 1 set of results | sql|sql-server | -1 | 53 | 4 | 72,340,939 | 72,340,939 | 2 | true | 2022-05-22T19:11:46.637Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to combine 3 separate SQL statements into 1 set of results<p>I have a SQL query that I am running 3 times (3 changing only the date range) and want to co... |
72,353,452 | Firestore Security rules with payment form<p>I'm creating a raffle website. The user connects his wallet and pays for a raffle ticket. After the blockchain transaction confirmation, I add his raffle ticket in a collection in firestore.</p>
<p>It causes a security issue because if I allow the user to write to the raffle... | <p>You say you do the payment over the blockchain and I assume you use solidity as your smart contract language?</p>
<ol>
<li>Why don't you <a href="https://www.tutorialspoint.com/solidity/solidity_events.htm" rel="nofollow noreferrer">emit an event in your smart contract</a>?</li>
<li>You then <a href="https://ethereu... | Firestore Security rules with payment form | reactjs|typescript|google-cloud-firestore|firebase-security | 1 | 53 | 1 | 72,353,807 | 72,353,807 | 2 | true | 2022-05-23T18:43:50.103Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Firestore Security rules with payment form<p>I'm creating a raffle website. The user connects his wallet and pays for a raffle ticket. After the blockchain t... |
72,347,284 | How can we calculate the number of Apis exposed through AWS api gateway?<p>So We have multiple API gateways and in each gateway, we have exposed multiple RESt endpoints. Is there any way to calculate the number of endpoints exposed in each gateway ?</p> | <p><strong>This python script worked for me:</strong></p>
<pre><code>import boto3
from botocore.exceptions import ClientError
import logging
apiGw = boto3.client("apigateway",region_name = "ap-south-1")
def get_rest_api_id():
"""Retrieve the ID of an API Gateway REST API
:re... | How can we calculate the number of Apis exposed through AWS api gateway? | amazon-web-services|rest|aws-api-gateway | 3 | 53 | 2 | 72,367,380 | 72,367,380 | 2 | true | 2022-05-23T10:49:00.533Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How can we calculate the number of Apis exposed through AWS api gateway?<p>So We have multiple API gateways and in each gateway, we have exposed multiple RES... |
72,369,261 | Negative Lookbehind Works in Editor But Not in Powershell Script<p>Using the following. I am attempting to replace spaces with comma-space for all instances in a string. While avoiding repeating commas already present in the string.</p>
<p>Test string:</p>
<pre><code>'186 ATKINS, Cindy Maria 25 Every Street Smalltown, ... | <p>Part of the problem here is that you are trying to force through the regex to do the replacement, when, like @WiktorStribiżew mentions, simply use <code>-replace</code> like it's supposed to be used. i.e. <code>-replace</code> does all the hard work for you.</p>
<p>When you do this:</p>
<pre><code>$match = ($_ | Sel... | Negative Lookbehind Works in Editor But Not in Powershell Script | regex|powershell|text | 0 | 53 | 2 | 72,370,478 | 72,370,478 | 2 | true | 2022-05-24T20:45:47.793Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Negative Lookbehind Works in Editor But Not in Powershell Script<p>Using the following. I am attempting to replace spaces with comma-space for all instances ... |
72,372,705 | Using .Contains with List(Of Structures<p>This code works - I get true, then false</p>
<pre><code>Dim listDates As New List(Of Date)
listDates.Add("2022-03-15")
Debug.Print(listDates.Contains("2022-03-15"))
Debug.Print(listDates.Contains("2022-03-16"))
</code></pre>
<p>If, instead of simpl... | <p>The <code>Any</code> extension method is what you want. The <code>Contains</code> method basically says "does the list contain an item equal to this" while the <code>Any</code> method says "does the list contain an item that satisfies this condition". In your case:</p>
<pre class="lang-vb prettyp... | Using .Contains with List(Of Structures | vb.net | 0 | 53 | 2 | 72,372,827 | 72,372,827 | 2 | true | 2022-05-25T06:13:27.680Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Using .Contains with List(Of Structures<p>This code works - I get true, then false</p>
<pre><code>Dim listDates As New List(Of Date)
listDates.Add("2022... |
72,377,378 | How to spread string across multiple lines<p>Let's say I have a script <code>script.py</code> accepting some command line arguments, and a bash script <code>main.sh</code> that calls it with multiple combinations as defined below. Now contrary to my example below the variables <code>MYARGS</code> and<code>MOREARGS</cod... | <p>A quoted string can span multiple lines. This script:</p>
<pre><code>MYARGS="-a=asdf
-b=2.1828
-c=foo
"
echo $MYARGS
</code></pre>
<p>Produces as output:</p>
<pre><code>-a=asdf -b=2.1828 -c=foo
</code></pre>
<p>This works fine, but it ends up getting tricky when you have arguments that contain whitespace.... | How to spread string across multiple lines | bash | 0 | 53 | 1 | 72,377,484 | 72,377,484 | 2 | true | 2022-05-25T12:08:49.260Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to spread string across multiple lines<p>Let's say I have a script <code>script.py</code> accepting some command line arguments, and a bash script <code>... |
72,382,758 | Google Sheet SUMIF across range of cells<p>I am trying to use a formula in google sheets to find averages based on the contents of a different cell.</p>
<p>Below is some sample data, I am pretty sure I have done similar in the past in Excel by using table headers as a reference but struggling to see how to achieve this... | <p>Try</p>
<pre><code>=AVERAGEIF($E$2:$H$2,B$1,$E3:$H3)
</code></pre>
<p><a href="https://i.stack.imgur.com/pOz8g.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pOz8g.png" alt="enter image description here" /></a></p>
<p><a href="https://support.google.com/docs/answer/3256529" rel="nofollow noreferr... | Google Sheet SUMIF across range of cells | google-sheets|google-sheets-formula | 0 | 53 | 1 | 72,383,147 | 72,383,147 | 2 | true | 2022-05-25T18:45:50.190Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Google Sheet SUMIF across range of cells<p>I am trying to use a formula in google sheets to find averages based on the contents of a different cell.</p>
<p>B... |
72,399,296 | Combine if statement with apply in python<p>New to python. I am trying to figure out the best way to create a column based on other columns. Ideally, the code would be as such.</p>
<pre><code>df['new'] = np.where(df['Country'] == 'CA', df['x'], df['y'])
</code></pre>
<p>I do not think this works because it thinks that ... | <p>Any of these three approaches (<code>np.where</code>, <code>apply</code>, <code>mask</code>) seems to work:</p>
<pre class="lang-py prettyprint-override"><code>df['where'] = np.where(df.country=='CA', df.x, df.y)
df['apply'] = df.apply(lambda row: row.x if row.country == 'CA' else row.y, axis=1)
mask = df.country=='... | Combine if statement with apply in python | python|pandas | 0 | 53 | 2 | 72,399,366 | 72,399,366 | 2 | true | 2022-05-27T00:29:14.907Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Combine if statement with apply in python<p>New to python. I am trying to figure out the best way to create a column based on other columns. Ideally, the cod... |
72,396,418 | Configure virtualenv content path instead of .venv/local/bin/activate<p>I don't know why but my venv files are being created in a slightly different path than usual.</p>
<p>It should be <code>.venv/bin/activate</code>, instead of <code>.venv/local/bin/activate</code>. This is giving me issues in other tools.</p>
<p>Why... | <p>It's a bug in setuptools, source: <a href="https://github.com/pypa/setuptools/issues/3278" rel="nofollow noreferrer">https://github.com/pypa/setuptools/issues/3278</a></p> | Configure virtualenv content path instead of .venv/local/bin/activate | python|virtualenv | 0 | 53 | 1 | 72,437,285 | 72,437,285 | 2 | true | 2022-05-26T18:26:01.360Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Configure virtualenv content path instead of .venv/local/bin/activate<p>I don't know why but my venv files are being created in a slightly different path tha... |
72,348,501 | Is it possible to model recursion with requestanimationframe?<p>I am creating a maze generation function, which requires uses recursive backtracking and <em>obviously</em> requires recursion. The function has to be run <code>length * breath</code> times, which sometimes exceeds the maximum recursion depth. The followin... | <p>Here's an example of your code refactored to run in a single while loop. I'm not sure if there's a specific approach to it, but just showing you the code might help...</p>
<p>This is the main part:</p>
<pre class="lang-js prettyprint-override"><code>let pos = start;
let revisit = [];
while (pos) {
const next = ra... | Is it possible to model recursion with requestanimationframe? | javascript|recursion|maze | 2 | 53 | 1 | 72,355,204 | 72,355,204 | 2 | true | 2022-05-23T12:27:13.740Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Is it possible to model recursion with requestanimationframe?<p>I am creating a maze generation function, which requires uses recursive backtracking and <em>... |
72,306,939 | How do you reason about fluctuations in benchmarking data?<p>Suppose you're trying to optimize a function and using some benchmarking framework (like Google Benchmark) for measurement. You run the benchmarks on the original function 3 times and see average wall clock time/CPU times of 100 ms, 110 ms, 90 ms. Then you ru... | <h3>Rule of Thumb</h3>
<ol>
<li>Minimum(!) of each series => <strong>90ms</strong> vs <strong>80ms</strong></li>
<li>Estimate noise => ~ <strong>10ms</strong></li>
<li>Pessimism => <strong>It probably didn't get any slower.</strong></li>
</ol>
<p>Not happy yet?</p>
<ol start="4">
<li><p>Take more measurements.... | How do you reason about fluctuations in benchmarking data? | performance|optimization|benchmarking|micro-optimization|microbenchmark | 3 | 53 | 2 | 72,310,384 | 72,310,384 | 2 | true | 2022-05-19T15:05:37.687Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How do you reason about fluctuations in benchmarking data?<p>Suppose you're trying to optimize a function and using some benchmarking framework (like Google ... |
72,369,854 | 'IN' gives empty result - c# and cosmos<p>I am trying to query the cosmos and the query works. The query looks like</p>
<pre><code>'Select * from c where c.id IN ('123', '456')'.
</code></pre>
<p>Now in my c# code, I get empty result. The c# code looks like :</p>
<pre><code>public void GetValue(IEnumerable<string>... | <p>The problem is here:</p>
<pre class="lang-cs prettyprint-override"><code>.Append("WHERE t.id IN (@items) ")
</code></pre>
<p>The list cannot be parameterized. One possiblity is to add the list items as separate parameters. There is an example of that <a href="https://nodogmablog.bryanhogan.net/2016/01/para... | 'IN' gives empty result - c# and cosmos | c#|azure-cosmosdb | 0 | 53 | 1 | 72,370,089 | 72,370,089 | 2 | true | 2022-05-24T21:50:31.043Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
'IN' gives empty result - c# and cosmos<p>I am trying to query the cosmos and the query works. The query looks like</p>
<pre><code>'Select * from c where c.i... |
72,389,919 | what happens here: typedef int (*ptr) (void) in .h file C<p>I have a piece of C code and don't understand what happens here:</p>
<pre><code>typedef int (*ptr) (void *ptr2, const char *name);
</code></pre>
<p>What I do understand is the typedef int (*ptr) part, but what happens in the second()? I've seen some questions ... | <p>If you have for example a function declaration like</p>
<pre><code>int f( void *ptr2, const char *name );
</code></pre>
<p>(as it is seen the function type is <code>int( void *, const char * )</code>) then a pointer to the function will look like</p>
<pre><code>int ( *pf )( void *, const char * ) = f;
</code></pre>
... | what happens here: typedef int (*ptr) (void) in .h file C | c|function-pointers|declaration|typedef|implicit-conversion | 1 | 53 | 1 | 72,389,983 | 72,389,983 | 2 | true | 2022-05-26T09:50:58.583Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
what happens here: typedef int (*ptr) (void) in .h file C<p>I have a piece of C code and don't understand what happens here:</p>
<pre><code>typedef int (*ptr... |
72,320,624 | How to implement search page via TextField in Flutter?<p>I need to make a search page. Made by means of TextField a field on clicking on which the page of search should open. Tell me how to implement clicking on the TextField and so that the back button appears on the left and the buttons disappear on the right?</p>
<p... | <p>Wrap everything into a <code>StatefulWidget</code>.</p>
<p>Then, when clicking the <code>TextFormField</code>, change the attributes of the <code>StatefulWidget</code>.</p>
<pre class="lang-dart prettyprint-override"><code>class YourPage extends StatefulWidget {
_YourPageState createState() => _YourPageState();... | How to implement search page via TextField in Flutter? | flutter|dart | 0 | 53 | 1 | 72,320,916 | 72,320,916 | 2 | true | 2022-05-20T14:29:51.613Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to implement search page via TextField in Flutter?<p>I need to make a search page. Made by means of TextField a field on clicking on which the page of se... |
72,356,469 | How to transform elements of list into dict/tuple? Python<p>I need to transform this list:</p>
<pre><code>[124, '-9.6713520', '-35.745578', 132, '-9.6713765', '-35.745620', 140, '-9.6712351', '-35.745561', 159, '-9.6712457', '-35.745545']
</code></pre>
<p>Into:</p>
<pre><code>[{'uc': 124, 'location': (-9.6713520, -35.7... | <p>If you make an iterator from your list, you can zip it with itself three times to iterate in triples:</p>
<pre><code>l = [124, '-9.6713520', '-35.745578', 132, '-9.6713765', '-35.745620', 140, '-9.6712351', '-35.745561', 159, '-9.6712457', '-35.745545']
it = iter(l)
[{'uc': k, 'location': (float(a), float(b))} f... | How to transform elements of list into dict/tuple? Python | python | -1 | 53 | 4 | 72,356,494 | 72,356,494 | 2 | true | 2022-05-24T02:03:03.077Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to transform elements of list into dict/tuple? Python<p>I need to transform this list:</p>
<pre><code>[124, '-9.6713520', '-35.745578', 132, '-9.6713765'... |
72,306,750 | CSS, changing already specified property within media query not working<p>I'm currently creating a website for a University-Project. Therefore I want to change the view based on the screensize (for mobile-users).</p>
<p>Therefore I would like to change some properties, which I've already specified inside the regarding ... | <p>The blue background wins here just because it comes later in the stylesheet. The media query does not affect specificity. For this to work, you should change the position of the media query, like so:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snip... | CSS, changing already specified property within media query not working | html|css | 0 | 53 | 2 | 72,306,871 | 72,306,871 | 2 | true | 2022-05-19T14:52:00.613Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
CSS, changing already specified property within media query not working<p>I'm currently creating a website for a University-Project. Therefore I want to chan... |
72,266,255 | Find the next free timestamp not in a table yet<p>I have a table, <code>event</code>, with a column <code>unique_time</code> of type <code>timestamptz</code>. I need each of the values in <code>unique_time</code> to be unique.</p>
<p>Given a <code>timestamptz</code> input, <code>input_time</code>, I need to find the <s... | <p>I suggest a function with a loop:</p>
<pre class="lang-sql prettyprint-override"><code>CREATE OR REPLACE FUNCTION f_next_free(_input_time timestamptz, OUT _next_free timestamptz)
LANGUAGE plpgsql STABLE STRICT AS
$func$
BEGIN
LOOP
SELECT INTO _next_free _input_time
WHERE NOT EXISTS (SELECT FROM ev... | Find the next free timestamp not in a table yet | sql|postgresql|gaps-and-islands | 2 | 53 | 2 | 72,267,316 | 72,267,316 | 2 | true | 2022-05-16T22:26:22.397Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Find the next free timestamp not in a table yet<p>I have a table, <code>event</code>, with a column <code>unique_time</code> of type <code>timestamptz</code>... |
72,246,683 | Writing/reading 2D char array in C to binary file<p>I have an array, which holds 6 words and a secret word</p>
<pre><code>char boardInputs[7][6];
</code></pre>
<p>I need to autosave to binary file this array every time when user entered the word. After restarting the program, I need to read the saved array of words fro... | <p>There are multiple problems in your code:</p>
<ul>
<li>you do not test for <code>fopen()</code> failure in <code>readArray</code>;</li>
<li>you do not close the file in <code>read_array</code>;</li>
<li><code>result</code> is unused in <code>autoSave</code>;</li>
<li><code>strcpy</code> is incorrect to copy the whol... | Writing/reading 2D char array in C to binary file | c | 2 | 53 | 2 | 72,247,241 | 72,247,241 | 2 | true | 2022-05-15T08:30:12.603Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Writing/reading 2D char array in C to binary file<p>I have an array, which holds 6 words and a secret word</p>
<pre><code>char boardInputs[7][6];
</code></pr... |
72,242,245 | Prove recursive function exists using only `nat_ind`<p>I'm trying to prove the following in Coq:</p>
<pre><code>∀ B: Type, ∀ a: B, ∀ b: nat -> B -> B, ∃ f: nat -> B, f 0 = a ∧ ∀ n: nat, f (S n) = b n (f n).
</code></pre>
<p>Which implies that a fairly general class of recursive functions exist. I know that I c... | <p>The problem seems to be to obtain recursion from the following axiomatization of <code>nat</code>:</p>
<pre><code>Parameter nat : Type.
Parameter O : nat.
Parameter S : nat -> nat.
Parameter disjoint_O_S : forall n, O <> S n.
Parameter injective_S : forall n n', S n = S n' -> n = n'.
Parameter nat_rect :... | Prove recursive function exists using only `nat_ind` | recursion|coq|induction | 0 | 53 | 1 | 72,244,183 | 72,244,183 | 2 | true | 2022-05-14T16:46:19.387Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Prove recursive function exists using only `nat_ind`<p>I'm trying to prove the following in Coq:</p>
<pre><code>∀ B: Type, ∀ a: B, ∀ b: nat -> B -> B, ... |
72,247,449 | How to print the contents of an instance in java or pde?<pre class="lang-py prettyprint-override"><code>class bouncingBall():
def __init__(self, bounce, window, position):
self.bounce = bounce
self.window = window
self.position = position
ball = bouncingBall(0.35, 1.5, 0.75)
print(ball) # &... | <p>As Saksham(+1) points you, one option is to override <code>toString()</code>: this is manual, but it doesn't have the overhead of reflection.</p>
<p>You can also use <a href="https://www.baeldung.com/java-reflection" rel="nofollow noreferrer">java.lang.reflect.*;</a> which you could use for a utilty function in a su... | How to print the contents of an instance in java or pde? | java|processing|pde | 1 | 53 | 2 | 72,248,282 | 72,248,282 | 2 | true | 2022-05-15T10:32:02.610Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to print the contents of an instance in java or pde?<pre class="lang-py prettyprint-override"><code>class bouncingBall():
def __init__(self, bounce, ... |
72,325,742 | Python Convert Counters into DataFrame Columns<p>I haven't been able to find an answer here specific to my issue and I'm wondering if I could get some help (apologies for the links, I'm not allowed to embed images yet).</p>
<p>I have stored Counter objects within my DataFrame and also want them added to the DataFrame a... | <p>You can use <a href="https://pandas.pydata.org/docs/reference/api/pandas.json_normalize.html" rel="nofollow noreferrer"><code>json_normalize</code></a>:</p>
<pre><code>df.join(pd.json_normalize(df['found']).fillna(0, downcast='infer'))
</code></pre>
<p>Output:</p>
<pre><code> words stuff found ... | Python Convert Counters into DataFrame Columns | python|pandas|dataframe|counter | 2 | 53 | 2 | 72,326,877 | 72,326,877 | 2 | true | 2022-05-21T00:03:06.547Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Python Convert Counters into DataFrame Columns<p>I haven't been able to find an answer here specific to my issue and I'm wondering if I could get some help (... |
72,311,816 | SQL recursion on a self-referencing table to obtain specific order<p>I have a table as below:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Id</th>
<th>LinkSlug</th>
<th>ParentPageId</th>
<th>Order</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>home</td>
<td></td>
<td>0</td>
</tr>
<tr>
<... | <p>You would need a recursive CTE to build the hierarchy and maintain the sequence</p>
<p><strong>Example</strong></p>
<pre><code>with cte1 as (
Select [Id]
,[LinkSlug]
,[ParentPageId]
,[Order]
,Seq = cast(10000+Row_Number() over (Order by [Order]) as varchar(500))... | SQL recursion on a self-referencing table to obtain specific order | sql|sql-server | 2 | 53 | 2 | 72,312,259 | 72,312,259 | 2 | true | 2022-05-19T22:43:03.910Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
SQL recursion on a self-referencing table to obtain specific order<p>I have a table as below:</p>
<div class="s-table-container">
<table class="s-table">
<th... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.