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,897,127 | Query parent table on multiple child conditions<p>I have two tables (Mail and MailTag), each containing over 500,000 records so query efficiency is very important.</p>
<p>For each email record (Mail) there is a minimum of one tag recorded in the MailTag child table. Every email can have multiple tag (so 1 or many).</p>... | <p>As I mentioned, use a conditional aggregate in the <code>HAVING</code>. For just needing those tags, then use the following:</p>
<pre class="lang-sql prettyprint-override"><code>SELECT M.IdEmail,
M.Subject,
M.[Other...]
FROM dbo.Mail
JOIN dbo.MailTag MT ON M.IdMail = MT.IdMail
GROUP BY M.IdEmail,
... | Query parent table on multiple child conditions | sql-server|tsql | -1 | 41 | 1 | 72,897,559 | 72,897,559 | 1 | true | 2022-07-07T11:37:20.650Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Query parent table on multiple child conditions<p>I have two tables (Mail and MailTag), each containing over 500,000 records so query efficiency is very impo... |
72,790,983 | Setting property value in constructor VS assigning directly to the property<p>I tried but could not find the difference between this:</p>
<pre class="lang-csharp prettyprint-override"><code>public class MyClass
{
public MyClass(){
MyProperty = "value";
}
public string MyProperty { get; se... | <p>There are some subtle differences between field initializers and constructors.</p>
<p>First, their order:<br />
The goal of the compiler is to construct an object in a deterministic manner. The compiler will always ensure that all class and instance variables are completely initialized before it will make the instan... | Setting property value in constructor VS assigning directly to the property | c#|.net|properties | 1 | 41 | 1 | 72,793,760 | 72,793,760 | 1 | true | 2022-06-28T17:43:13.573Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Setting property value in constructor VS assigning directly to the property<p>I tried but could not find the difference between this:</p>
<pre class="lang-cs... |
72,850,732 | Turning two columns of data in R into a series of lists as long as the columns<p>I have two columns of data referring to international abbreviations for countries (their ISO 2-Code and ISO 3-Code). I am going to use this as a "dictionary" to substitute the 2Codes for the 3Codes in another table using the gsu... | <p>First, some test data:</p>
<pre><code>df <- data.frame(code3 = c("ABW","AFG"), code2 = c("AW", "AF"))
</code></pre>
<p>If each of the 3-Code values have to be unique, then <code>split</code> it:</p>
<pre><code>split(df$code2, df$code3)
#$ABW
#[1] "AW"
#
#$AFG
#[1]... | Turning two columns of data in R into a series of lists as long as the columns | r|list | 1 | 41 | 1 | 72,850,833 | 72,850,833 | 1 | true | 2022-07-04T00:16:40.750Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Turning two columns of data in R into a series of lists as long as the columns<p>I have two columns of data referring to international abbreviations for coun... |
72,788,121 | How can I flag missing start/end dates per account in pandas?<p>I have a pandas related question. My dataframe has daily records of unique account numbers:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Account</th>
<th>Date</th>
<th>Balance</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>... | <p>You can use <a href="https://pandas.pydata.org/docs/reference/api/pandas.core.groupby.DataFrameGroupBy.transform.html" rel="nofollow noreferrer"><code>groupby.transform</code></a> to get the min/max date per group and compare to the absolute min/max, then assign boolean columns:</p>
<pre><code>s = pd.to_datetime(df[... | How can I flag missing start/end dates per account in pandas? | python|pandas | 1 | 41 | 1 | 72,788,433 | 72,788,433 | 1 | true | 2022-06-28T14:17:18.343Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How can I flag missing start/end dates per account in pandas?<p>I have a pandas related question. My dataframe has daily records of unique account numbers:</... |
72,914,906 | Separate each number using “;” every 8 digits in pandas<p>All,
I have a data frame looks something like this :</p>
<pre><code>Column A : X , Y
Column B : 123456781234567812345678,123456781234567812345678
</code></pre>
<p>The goal is to use pandas such that I can split Column B every 8 characters with “;” between number... | <p>You can use a regex:</p>
<pre><code># example input
df = pd.DataFrame({'A': ['X', 'Y'],
'B': [123456781234567812345678,
123456781234567812345678]})
df['B'] = df['B'].astype(str).str.replace(r'(\d{8})(?<!$)', r'\1;', regex=True)
</code></pre>
<p>output (as new column B2... | Separate each number using “;” every 8 digits in pandas | python|pandas | 1 | 41 | 1 | 72,914,952 | 72,914,952 | 1 | true | 2022-07-08T17:22:57.327Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Separate each number using “;” every 8 digits in pandas<p>All,
I have a data frame looks something like this :</p>
<pre><code>Column A : X , Y
Column B : 123... |
72,957,361 | Click a button with part of current URL for language use<p>Halo everyone,</p>
<p>Cause I got a website which have many language and each language will have a subdirectory.</p>
<p>for example</p>
<pre><code>1) sample.com/en
2) sample.com/jp
3) sample.com/zh
</code></pre>
<p>And the question is, I want the user stay on t... | <p>To clean up the HTML, you can add a data attribute to each button for that button's language.</p>
<p>Then instead of using an inline event handler, you can delegate the event handler to the document itself. Then check for a data attribute for language. Then I'm splitting the current URL by the slash to get the page ... | Click a button with part of current URL for language use | javascript | 1 | 41 | 2 | 72,957,586 | 72,957,586 | 1 | true | 2022-07-12T19:20:15.647Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Click a button with part of current URL for language use<p>Halo everyone,</p>
<p>Cause I got a website which have many language and each language will have a... |
72,791,202 | Does anyone else have this issue with vscode<p>I have a <code>.txt</code> file that has the pound symbol in <code>£</code>. When I use <code>filename.read()</code> it will print the pound sign how it should be, but it will also print with another letter that I didn't add which is <code>Â</code></p>
<p>Anybody know what... | <p>The file encoding is UTF-8, but read as (probably) Windows-1252.</p>
<p>The reason for two characters is UTF-8 is a multibyte encoding, and the pound sign is encoded as <code>C2 A3</code>, but Windows-1252 is a single byte encoding and the pound sign is only encoded as <code>A3</code>. <code>C2</code> in Windows-12... | Does anyone else have this issue with vscode | python|visual-studio-code | 0 | 41 | 1 | 72,791,338 | 72,791,338 | 1 | true | 2022-06-28T18:02:38.477Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Does anyone else have this issue with vscode<p>I have a <code>.txt</code> file that has the pound symbol in <code>£</code>. When I use <code>filename.read()<... |
72,852,831 | How to set a column value into null in select query in oracle?<p>I want to select a column value which is equal to a specific page item value and select the other values as null.
The main table data is the following:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>first_numbers<... | <p>Use <code>CASE</code> expression:</p>
<p>Sample data:</p>
<pre><code>SQL> with test (id, first_numbers, second_numbers) as
2 (select 1, 1112, 2222 from dual union all
3 select 2, 3434, 1112 from dual
4 )
</code></pre>
<p>Query itself:</p>
<pre><code> 5 select id,
6 case when first_numbers ... | How to set a column value into null in select query in oracle? | oracle|oracle-apex|oracle19c | 0 | 41 | 1 | 72,852,926 | 72,852,926 | 1 | true | 2022-07-04T06:59:57.880Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to set a column value into null in select query in oracle?<p>I want to select a column value which is equal to a specific page item value and select the ... |
72,988,494 | C++ File How to auto generate number for next data to store<pre><code>#include <iostream>
#include <fstream>
using namespace std;
class Customer {
private:
fstream database;
string customerRecord = "customerRecord.txt";
int movieID = 0;
public:
void wri... | <p>If you read to the end of the file and stop reading because you tried to read past the end of the file, the fail bit and the eof bit are set and you cannot read or write until both are cleared.</p>
<p>The only way out of</p>
<pre class="lang-cpp prettyprint-override"><code>while(getline(database, lines)) {
movie... | C++ File How to auto generate number for next data to store | c++|file | -1 | 41 | 1 | 72,989,010 | 72,989,010 | 1 | true | 2022-07-15T02:34:03.093Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
C++ File How to auto generate number for next data to store<pre><code>#include <iostream>
#include <fstream>
using namespace std;
class Custome... |
72,832,847 | function returns multiple values, assignment to tuples with different number of entries?<p>A Python-function foo(p, q) calculates four values a, b, c, and returns</p>
<pre><code>return a, b, c, d
</code></pre>
<p>In the calling function I need an assignment like</p>
<pre><code>(r, s, t, u) = (p, q, foo(p, q))
</code></... | <p>The structure of the receivers should be the same as what's being assigned and returned.</p>
<pre><code>r, s, (w, x, y, z) = p, q, foo(p, q)
</code></pre>
<p>If you only want the last two elements of the <code>foo(p, q)</code> respnse you can slice it:</p>
<pre><code>r, s, (w, x) = p, q, foo(p, q)[2:]
</code></pre>
... | function returns multiple values, assignment to tuples with different number of entries? | python|python-3.x|return-type | 1 | 41 | 1 | 72,832,901 | 72,832,901 | 1 | true | 2022-07-01T17:33:35.153Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
function returns multiple values, assignment to tuples with different number of entries?<p>A Python-function foo(p, q) calculates four values a, b, c, and re... |
72,856,208 | pySpark: add current month to column name<p>I have a self written function and it gets a dataframe and returns the whole dataframe plus a new column. That new column must not have a fixed name but instead the current month as part of the new column name. E.g. "forecast_august2022".</p>
<p>I tried it like
.wit... | <p>You can define a variable at start with current month and year and use it in f string while adding it in with column</p>
<pre><code>from pyspark.sql import functions as F
import datetime
mydate = datetime.datetime.now()
month_nm=mydate.strftime("%B%Y") #gives you July2022 for today
dql1=spark.range(3).toDF... | pySpark: add current month to column name | pyspark | 0 | 41 | 2 | 72,856,342 | 72,856,342 | 1 | true | 2022-07-04T11:48:10.483Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
pySpark: add current month to column name<p>I have a self written function and it gets a dataframe and returns the whole dataframe plus a new column. That ne... |
72,395,320 | Index of a sentence in a paragraph<p>I have two strings, <code>a</code> and <code>b</code>, and I can use <code>a.index(b)</code> to find the index of string <code>b</code> in string <code>a</code>.</p>
<pre><code>a = """
Hello! This is a string which I am using to present a quesion to stackoverflow beca... | <p>The straightforward approach is to iterate over the possible indices and count the mismatches between the substring of <code>a</code> starting at that index and <code>b</code>, returning the index if the number of mismatches is below the threshold:</p>
<pre class="lang-py prettyprint-override"><code>def fuzzy_index(... | Index of a sentence in a paragraph | python-3.x | 2 | 41 | 1 | 72,395,878 | 72,395,878 | 1 | true | 2022-05-26T16:48:36.540Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Index of a sentence in a paragraph<p>I have two strings, <code>a</code> and <code>b</code>, and I can use <code>a.index(b)</code> to find the index of string... |
72,395,749 | Remove delimiter from text variable while reading<p>i received this file form the server and stored it automatically<br>
Text file chall.txt :</p>
<pre><code>"rnIgOUXql5SEgpYy6vul"
</code></pre>
<p>JAVASCRIPT :</p>
<pre><code>const fs = require('fs');
var challange = fs.readFileSync('chall.txt', 'utf8');
</co... | <p>Replace the quotes.</p>
<pre><code>const fs = require('fs');
let content = fs.readFileSync('chall.txt', 'utf-8');
content = content.replace('"', '');
</code></pre> | Remove delimiter from text variable while reading | javascript|node.js | -1 | 41 | 2 | 72,396,054 | 72,396,054 | 1 | true | 2022-05-26T17:24:24.503Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Remove delimiter from text variable while reading<p>i received this file form the server and stored it automatically<br>
Text file chall.txt :</p>
<pre><code... |
72,382,133 | Form a list of pairwise metrics (distance) using a matrix lookp comming from a python pandas dataframe<p>I have a distance matrix as a dataframe:</p>
<pre><code>data_map = {
'startNode':["0","0","0","0","0","455","455","455","455"... | <p>You can use <a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.pivot.html" rel="nofollow noreferrer"><code>DataFrame.pivot</code></a> with <a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.reindex.html" rel="nofollow noreferrer"><code>DataFrame.reind... | Form a list of pairwise metrics (distance) using a matrix lookp comming from a python pandas dataframe | python-3.x|pandas|dataframe|matrix|distance | 0 | 41 | 2 | 72,400,622 | 72,400,622 | 1 | true | 2022-05-25T17:44:18.977Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Form a list of pairwise metrics (distance) using a matrix lookp comming from a python pandas dataframe<p>I have a distance matrix as a dataframe:</p>
<pre><c... |
72,377,546 | sqlalchemy listens_for happening before table is fully created<p>I have noticed the listens_for decorator for sqlalchemy starts before the table is fully created, at least in my code. What should I be doing in order to make sure it starts after. Let me know if you need further code.</p>
<p>The error is</p>
<blockquote>... | <p>The problem here is that <code>Base.metadata.create_all</code> is using a different connection than <code>db_session</code>, so when <code>commit()</code> is called in the event listener <code>create_all</code>'s transaction has yet to commit.</p>
<p>The event listener receives both the table object and the connecti... | sqlalchemy listens_for happening before table is fully created | python|sqlalchemy|psycopg2 | 0 | 41 | 1 | 72,477,750 | 72,477,750 | 1 | true | 2022-05-25T12:20:15.900Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
sqlalchemy listens_for happening before table is fully created<p>I have noticed the listens_for decorator for sqlalchemy starts before the table is fully cre... |
72,376,312 | Convert one-dimensional array to two-dimensional array so that each element is a row in the result<p>I want to know how to convert this: <code>array([0, 1, 2, 3, 4, 5])</code> to this:</p>
<pre class="lang-py prettyprint-override"><code>array([[0, 0, 0],
[1, 1, 1],
[2, 2, 2],
[3, 3, 3],
[4, ... | <p>You can use numpy's <a href="https://numpy.org/doc/stable/reference/generated/numpy.repeat.html" rel="nofollow noreferrer"><code>repeat</code></a> like this:</p>
<pre><code>np.repeat(range(10), 4).reshape(10,4)
</code></pre>
<p>which gives:</p>
<pre><code>[[0 0 0 0]
[1 1 1 1]
[2 2 2 2]
[3 3 3 3]
[4 4 4 4]
[5 5... | Convert one-dimensional array to two-dimensional array so that each element is a row in the result | python|arrays|python-3.x|numpy | 0 | 41 | 2 | 72,376,622 | 72,376,622 | 1 | true | 2022-05-25T10:54:31.720Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Convert one-dimensional array to two-dimensional array so that each element is a row in the result<p>I want to know how to convert this: <code>array([0, 1, 2... |
72,357,164 | Having issue with getting value from object variable. No errors showing<p>I created an array called animals containing two objects. I want to get a value from the name variable in the object animals and insert that value in a return statement in the map method. I used ${} to access the variable.</p>
<p><div class="snip... | <p>Check in your code instead of:</p>
<pre><code>'<h1>${item.name}</h1>'
</code></pre>
<p>Should be:</p>
<pre><code>`<h1>${item.name}</h1>`
</code></pre>
<p>Here is the documentation for <a href="https://developer.mozilla.org/en-US/docs/Web/JavaScript/Reference/Template_literals" rel="nofollow n... | Having issue with getting value from object variable. No errors showing | javascript|arrays|javascript-objects | 1 | 41 | 3 | 72,357,180 | 72,357,180 | 1 | true | 2022-05-24T04:18:55.837Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Having issue with getting value from object variable. No errors showing<p>I created an array called animals containing two objects. I want to get a value fro... |
72,285,949 | Python Color Dataframe cells depending on values<p>I am trying to color the cells</p>
<p>I have the following Dataframe:</p>
<pre><code> pd.DataFrame({'Jugador': {1: 'M. Sanchez',
2: 'L. Ovalle',
3: 'K. Soto',
4: 'U. Kanu',
5: 'K. Abud'},
'Equipo': {1: 'Houston Dash',
2: 'Tigres UANL',
3: 'Guadalajara',
... | <p>Use <a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.io.formats.style.Styler.applymap.html" rel="nofollow noreferrer"><code>Styler.applymap</code></a> with custom function:</p>
<pre><code>def styler(v):
if v > 60:
return 'background-color:green'
elif v < 40:
re... | Python Color Dataframe cells depending on values | python|pandas | 1 | 41 | 1 | 72,286,261 | 72,286,261 | 1 | true | 2022-05-18T08:46:58.033Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Python Color Dataframe cells depending on values<p>I am trying to color the cells</p>
<p>I have the following Dataframe:</p>
<pre><code> pd.DataFrame({'Jug... |
72,348,911 | element-wise product matrix x matrix<p>How to do element-wise product by column, i am looking for a non-loop technique cause i have dozens of columns in each dataframe and different width size</p>
<p>example:</p>
<pre><code>mat1=pd.DataFrame({"a":[1,1,1],"b":[2,2,2]})
mat2=pd.DataFrame({"c"... | <p>Use <a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.mul.html" rel="nofollow noreferrer"><code>DataFrame.mul</code></a> with <a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.MultiIndex.from_product.html" rel="nofollow noreferrer"><code>MultiIndex.from_produ... | element-wise product matrix x matrix | python|pandas|numpy | 0 | 41 | 2 | 72,348,922 | 72,348,922 | 1 | true | 2022-05-23T12:58:02.317Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
element-wise product matrix x matrix<p>How to do element-wise product by column, i am looking for a non-loop technique cause i have dozens of columns in each... |
72,390,912 | Need to filter a object using JavaScript<p>I have a object</p>
<pre><code>course = [
{
id: 1,
name: 'Computer Science',
country: 'Uinited State',
university:{
id: 1,
name: 'Oxford'
}
},
{
id: 2,
name: 'BBA',
country: 'Uinited State',
university:{
id: 2,
... | <p>Its not so much a filter you need, its really grouping by university name, and ensuring there is a maximum of 3 items in each group</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"... | Need to filter a object using JavaScript | javascript | 0 | 41 | 2 | 72,391,053 | 72,391,053 | 1 | true | 2022-05-26T11:13:13.163Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Need to filter a object using JavaScript<p>I have a object</p>
<pre><code>course = [
{
id: 1,
name: 'Computer Science',
country: 'Uinited State... |
72,328,331 | After boxing, cannot change the object value by passing the object as an argument of a function<p>I am boxing an integer as an object (<em>System.Object</em>). Then if I assign a new value to the object within the same scope, the value of the object is getting updated. But, if I try to pass the object as an argument in... | <p>When you pass an argument into a function, it creates a new "pointer" to the value passed in. When you set <code>obj = 30;</code> you are re-setting the address of this new pointer to point to a new boxed version of <code>30</code>.</p>
<p>All the while, the first "pointer" (<code>object obj = i;... | After boxing, cannot change the object value by passing the object as an argument of a function | c#|boxing | -1 | 41 | 1 | 72,328,459 | 72,328,459 | 1 | true | 2022-05-21T09:35:22.933Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
After boxing, cannot change the object value by passing the object as an argument of a function<p>I am boxing an integer as an object (<em>System.Object</em>... |
72,245,317 | Outlook VSTO - DAST query returning condition is not valid<p>I am trying to search for appointment on a shared calendar. The first step is I am saving the appointment in shared calendar with a custom property <strong>twMeetingId</strong>. This is working fine:</p>
<pre><code>Outlook.AppointmentItem nurseAppointment = G... | <p>You have an erroneous space between <code>@SQL</code> and <code>=</code>. The following condition worked without error for me:</p>
<pre><code>@SQL="http://schemas.microsoft.com/mapi/string/{00020329-0000-0000-C000-000000000046}/twMeetingId/0000001f" = 'test'
</code></pre>
<p>Also make sure <code>appointmen... | Outlook VSTO - DAST query returning condition is not valid | c#|outlook|vsto|outlook-addin|office-addins | 0 | 41 | 2 | 72,252,911 | 72,252,911 | 1 | true | 2022-05-15T03:21:46.463Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Outlook VSTO - DAST query returning condition is not valid<p>I am trying to search for appointment on a shared calendar. The first step is I am saving the ap... |
72,326,061 | How to find point on the circumference of a circle from an angle<p>position holds the center of a circle with a diameter variable.
enemy.position is the top left corner of a square which is an enemy, size is the width and height of the enemy.
I am using pVector and line() from the processing.core.pApplet library in jav... | <p>You can find the side of the rectangle by finding the point on the rectangle that lies on the straight line given by the center of the circle and the center of the rectangle.</p>
<p>The point on the rectangle and the circle can be computed by the minimum relation of the offset between the center points and the size ... | How to find point on the circumference of a circle from an angle | java|vector|processing|trigonometry|angle | 1 | 41 | 1 | 72,327,323 | 72,327,323 | 1 | true | 2022-05-21T01:39:36.250Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to find point on the circumference of a circle from an angle<p>position holds the center of a circle with a diameter variable.
enemy.position is the top ... |
72,269,235 | Using R while loop to generate random variables<p>I want to generate a random variable X by continuing generating U(0,1) random variables as long as their product falls below exp(-2). Then my random variable X would be equal to the number of U(0,1) random variables that was generated minus 1.<br />
I tried using the wh... | <h1>update</h1>
<p>If you want to replicate the process by <code>100</code> times, you can use <code>replicate</code></p>
<pre><code>replicate(
100,
{
p <- 1
counter <- 0
repeat {
p <- p * runif(1)
counter <- counter + 1
if (p < exp(-2))... | Using R while loop to generate random variables | r|poisson|uniform|uniform-distribution | 2 | 41 | 1 | 72,269,772 | 72,269,772 | 1 | true | 2022-05-17T06:43:01.010Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Using R while loop to generate random variables<p>I want to generate a random variable X by continuing generating U(0,1) random variables as long as their pr... |
72,395,011 | Mongoose: Get objects by a search query<p>I am trying to pull out data of 2 types from my BSON document using mongoose.
The 2 data are;</p>
<ol>
<li>Intention 1 - I want to get objects from the items array where tagNo == 2</li>
<li>Intention 2 -I want to get objects from the items array where tagNo == 2 and tagID == kL... | <p>You need aggregation framework</p>
<pre><code> db.collection.aggregate([
{
$match: { //Match condition to get the matching arrays
"fileID": "0pdn3jdndndj3msms",
"items.tagNo": 2
}
},
{
$project: {
"items": {
$filter: { //Project onl... | Mongoose: Get objects by a search query | javascript|mongodb|mongoose|nosql|aggregation-framework | 1 | 41 | 1 | 72,395,124 | 72,395,124 | 1 | true | 2022-05-26T16:23:23.267Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Mongoose: Get objects by a search query<p>I am trying to pull out data of 2 types from my BSON document using mongoose.
The 2 data are;</p>
<ol>
<li>Intentio... |
72,307,930 | Is `this` a keyword or a literal?<p>Why JS specs call <code>this</code> a keyword and not a literal?</p>
<p>It more seems to be a literal, because we can use it as a value, or what am I missing?</p>
<pre class="lang-js prettyprint-override"><code>return this
</code></pre>
<p>What is it then?</p> | <p>It doesn't really matter, but it's a keyword according to the specification: See <a href="https://tc39.es/ecma262/multipage/ecmascript-language-lexical-grammar.html#sec-keywords-and-reserved-words" rel="nofollow noreferrer">Keywords and Reserved Words</a> and <a href="https://tc39.es/ecma262/multipage/ecmascript-lan... | Is `this` a keyword or a literal? | javascript|syntax|grammar|keyword|literals | 0 | 41 | 1 | 72,308,021 | 72,308,021 | 1 | true | 2022-05-19T16:18:55.617Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Is `this` a keyword or a literal?<p>Why JS specs call <code>this</code> a keyword and not a literal?</p>
<p>It more seems to be a literal, because we can use... |
72,290,863 | Java how to close a stage from Service Object<p>I am in the situation where I start a new view but in its controller i make a request to server to get some objects. This request takes some time so i want to implement a little loading view during this waiting time. So, in my controller i implemented a Service Object to ... | <p>There are two main threading rules in JavaFX (similar to most other UI toolkits).</p>
<ol>
<li>You must not perform operations on the UI from a background thread. This includes creating, showing, or hiding windows.</li>
<li>You must not block the UI thread (the "FX Application Thread").</li>
</ol>
<p>You v... | Java how to close a stage from Service Object | java|javafx | 0 | 41 | 1 | 72,291,125 | 72,291,125 | 1 | true | 2022-05-18T14:15:57.297Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Java how to close a stage from Service Object<p>I am in the situation where I start a new view but in its controller i make a request to server to get some o... |
72,330,904 | How do I increase number S, N times, until it reaches number F?<p>I have a known <code>startValue</code>, a known <code>finalValue</code> and a fixed number of allowed <code>iterations</code>.</p>
<p>Starting with <code>startValue</code> I need to keep increasing the value each time round the loop until I reach <code>f... | <p>You can generate an array based on the following logic:</p>
<p>1st item: <code>startValue</code></p>
<p>2nd item: <code>startValue + diff</code></p>
<p>3rd item: <code>startValue + (diff * 2)</code></p>
<p>and so on...</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false... | How do I increase number S, N times, until it reaches number F? | javascript|math | 1 | 41 | 1 | 72,331,129 | 72,331,129 | 1 | true | 2022-05-21T15:25:29.390Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How do I increase number S, N times, until it reaches number F?<p>I have a known <code>startValue</code>, a known <code>finalValue</code> and a fixed number ... |
72,390,287 | Retrive only replacement template of regex in C#<br/>
can i get only the substitution of the Regex.Replace?<br/>
Example.
<pre><code>String text = @"asdfgs sda gsa ga s
SECTOR:124 NAME:Ricko
asdfgs sda gsa ga s";
String regex = "^SECTOR:(\d+) NAME:(\w+)";
String substitution = "$2 $1";
St... | <p>You are not matching all the characters around what you want to keep that should be deleted.</p>
<p>You could have the dot match a newline and using the multiline flag for the anchor.</p>
<pre><code>(?sm).*?^SECTOR:(\d+) NAME:(\w+).*
</code></pre>
<p>The pattern matches:</p>
<ul>
<li><code>(?sm)</code> Inline flags ... | Retrive only replacement template of regex in C# | c#|regex|regexp-replace | -1 | 41 | 2 | 72,390,405 | 72,390,405 | 1 | true | 2022-05-26T10:21:32.117Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Retrive only replacement template of regex in C#<br/>
can i get only the substitution of the Regex.Replace?<br/>
Example.
<pre><code>String text = @"asd... |
72,327,097 | How to return original root node with updated values after converting tree in function<p>I am attempting LeetCode problem <a href="https://leetcode.com/problems/convert-bst-to-greater-tree/" rel="nofollow noreferrer">538. Convert BST to Greater Tree</a>:</p>
<blockquote>
<p>Given the <code>root</code> of a Binary Searc... | <p>Here are some of the issues:</p>
<ul>
<li>The main problem is that your code uses both <code>val</code> and <code>value</code> as node attribute. In the LeetCode problem, the class is defined with a <code>val</code> attribute, but <em>your</em> class has <code>value</code>, and the rest of your code has a mix of <co... | How to return original root node with updated values after converting tree in function | python|data-structures|binary-search-tree | 0 | 41 | 1 | 72,327,889 | 72,327,889 | 1 | true | 2022-05-21T06:08:24.923Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to return original root node with updated values after converting tree in function<p>I am attempting LeetCode problem <a href="https://leetcode.com/probl... |
72,341,723 | How do I go through the result of a parameterized query?<p>I'm trying to go through the result of a paremeterized query in PHP.
I'm trying this way</p>
<pre><code>//creating a prepared statement
$stmt = $mysqli->stmt_init();
$query = "SELECT pcode,price,description FROM products WHERE descriptio... | <p>You need to bind the result to some variables:</p>
<pre><code>$query = "SELECT pcode,price,description FROM products WHERE description like ? ORDER BY PRICE";
$stmt = $mysqli->prepare($query);
$search_criteria = '%'.$search_criteria.'%';
$stmt->bind_param('s', $search_criteria);
$stm... | How do I go through the result of a parameterized query? | php|mysqli|prepared-statement|resultset | 1 | 41 | 1 | 72,341,797 | 72,341,797 | 1 | true | 2022-05-22T22:30:41.370Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How do I go through the result of a parameterized query?<p>I'm trying to go through the result of a paremeterized query in PHP.
I'm trying this way</p>
<pre>... |
72,387,297 | JS - Can I get the next open div element - Not the sibling<p>Is it possible using just JS (or possibly with jQuery) to get the next <code>open</code> html element?</p>
<p>In the snippet below, if I click on any <code>div</code> it'll give me the <code>id</code> of that div. I want it to get the <em>next</em> open eleme... | <p>I first create a flat array <code>divs</code> with all existing div <code>id</code>s. In the click event handler I then look up the clicked element's successor <code>id</code>.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="... | JS - Can I get the next open div element - Not the sibling | javascript|html|jquery | 0 | 41 | 2 | 72,387,439 | 72,387,439 | 1 | true | 2022-05-26T05:54:05.953Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
JS - Can I get the next open div element - Not the sibling<p>Is it possible using just JS (or possibly with jQuery) to get the next <code>open</code> html el... |
72,332,382 | insertion in a table of objects with nested table in oracle<p>I have a problem inserting in a nested table in oracle</p>
<p>These are the relevant types and tables;</p>
<pre><code>create type movies_type as Table of ref movie_type;
create type actor_type under person_type
(
starring movies_type
) Final;
create tab... | <p>You want to use <code>CAST</code> and <code>COLLECT</code> to aggregate the references into a collection:</p>
<pre class="lang-sql prettyprint-override"><code>insert into actor values(
actor_type(
29,
'Carrie',
'Fisher',
DATE '1956-10-21',
DATE '2016-12-27',
'USA',
(
SELECT CAST( ... | insertion in a table of objects with nested table in oracle | oracle|oracle11g | 0 | 41 | 1 | 72,333,849 | 72,333,849 | 1 | true | 2022-05-21T18:48:40.260Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
insertion in a table of objects with nested table in oracle<p>I have a problem inserting in a nested table in oracle</p>
<p>These are the relevant types and ... |
72,241,491 | I want to make an calculator for average but i'm facing some issues<p>I want to make an calculator for average but i'm facing some issues. I want the numbers entered by the users come as a print statement but it is just throwing the last entered value.Here is my code.</p>
<pre><code>numlist = list()
while True:
inp... | <h2>Solution</h2>
<p>we can print the list</p>
<pre><code>numlist = list()
while True:
inp = input(f"Enter a number, (Enter done to begin calculation): ")
if inp == 'done':
break
value = float(inp)
numlist.append(value)
average = sum(numlist) / len(numlist)
print(f"The Entered num... | I want to make an calculator for average but i'm facing some issues | python|list | 0 | 41 | 3 | 72,241,560 | 72,241,560 | 1 | true | 2022-05-14T15:11:25.170Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
I want to make an calculator for average but i'm facing some issues<p>I want to make an calculator for average but i'm facing some issues. I want the numbers... |
72,300,799 | JOLT shift through properties with different names<p>I have a JSON:</p>
<pre class="lang-json prettyprint-override"><code>{
"relations": {
"advertiser_id": {
"9968": {
"name": "Advance/Unicredit",
"id": 9968
},
"101... | <p>If your aim is to accumulate each array of objects under those properties(<code>advertiser_id</code> and <code>campaign_id</code>), then use the following spec</p>
<pre class="lang-json prettyprint-override"><code>[
{
"operation": "shift",
"spec": {
"*": {
... | JOLT shift through properties with different names | json|jolt | 0 | 41 | 1 | 72,301,127 | 72,301,127 | 1 | true | 2022-05-19T08:02:37.100Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
JOLT shift through properties with different names<p>I have a JSON:</p>
<pre class="lang-json prettyprint-override"><code>{
"relations": {
&q... |
72,318,032 | How can I calculate the smallest difference in days between date in dictionaries that have the same label python<p>I have dictionaries like this :</p>
<pre><code>tr1 = {'label': 'name1', 'date': '2021-09-29'}
tr2 = {'label': 'name1', 'date': '2021-08-30'}
tr3 = {'label': 'name1', 'date': '2021-09-30'}
tr4 = {'label': '... | <p>IIUC, you can sort the dates per group and get the min <code>diff</code>:</p>
<pre><code>l = [tr1, tr2, tr3, tr4, tr5, tr6]
(pd.DataFrame(l)
.assign(date=lambda d: pd.to_datetime(d['date']))
.groupby('label')['date']
.transform(lambda s: s.sort_values().diff().min())
)
</code></pre>
<p>Output:</p>
<pre><c... | How can I calculate the smallest difference in days between date in dictionaries that have the same label python | python|pandas|datetime|group-by | 2 | 41 | 1 | 72,318,237 | 72,318,237 | 1 | true | 2022-05-20T11:15:17.253Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How can I calculate the smallest difference in days between date in dictionaries that have the same label python<p>I have dictionaries like this :</p>
<pre><... |
72,280,585 | Using a history table, how can I identify each period of time in which any task is active, and reduce the data set to non-overlapping date periods<p>I have a history table in Teradata that contains information about tasks that occurred on an account. In typical history table fashion, the data present has a Load (Valid ... | <p>Use Teradata's NORMALIZE to combine periods that overlap or meet. Based on your sample data, it appears this would work; you may need to adjust slightly for the real data.</p>
<pre><code>SELECT ACCT_NUM,
BEGIN(PD) AS ACTIVE_START_DT,
PRIOR(END(PD)) AS ACTIVE_END_DT
FROM
(SELECT NORMALIZE ACCT_NUM,
... | Using a history table, how can I identify each period of time in which any task is active, and reduce the data set to non-overlapping date periods | sql|teradata | 0 | 41 | 1 | 72,281,197 | 72,281,197 | 1 | true | 2022-05-17T20:55:43.683Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Using a history table, how can I identify each period of time in which any task is active, and reduce the data set to non-overlapping date periods<p>I have a... |
72,337,915 | Migrating from Python 2.7 to 3.7 - difference between isinstance(obj, None) vs is None<p>I have to migrate a project from Python 2.7 to 3.7.</p>
<p>This line of code used to work in 2.7</p>
<pre><code>if isinstance(obj, None):
</code></pre>
<p>for some reason it doesn't anymore. If I modify it this way:</p>
<pre><code>... | <p><code>is</code> operator is used to check if both the objects are one and the same, whereas <code>isinstance</code> is used to check if the second parameter appears anywhere in the inheritance chain of the first parameter.</p>
<pre><code>obj is None
</code></pre>
<p><code>obj</code> is actually <code>None</code>.</p... | Migrating from Python 2.7 to 3.7 - difference between isinstance(obj, None) vs is None | python | -1 | 41 | 1 | 72,337,970 | 72,337,970 | 1 | true | 2022-05-22T13:18:55.667Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Migrating from Python 2.7 to 3.7 - difference between isinstance(obj, None) vs is None<p>I have to migrate a project from Python 2.7 to 3.7.</p>
<p>This line... |
72,253,199 | python while statement with for loop<p>I am trying to iterate through a dictionary and get user response.</p>
<p>At the second to last question, I want to specifically declare that there is one more question left.</p>
<p>I am having trouble combining a while statement with for loop. This is my code:</p>
<pre><code># my... | <p>I'm not sure why you'd want to use a while loop here. Why not just have an if-statement like so:</p>
<pre><code>q_dict = {"where are we? " : "usa",
"who are you? " : "jon",
"how old are you? " : 22}
for key, val in q_dict.items():
q_prom... | python while statement with for loop | python|for-loop|while-loop | 0 | 41 | 1 | 72,253,217 | 72,253,217 | 1 | true | 2022-05-16T00:50:03.553Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
python while statement with for loop<p>I am trying to iterate through a dictionary and get user response.</p>
<p>At the second to last question, I want to sp... |
72,253,282 | p5.js keyIsDown() behaving inconsistently when more than 2 keys are pressed at once<p>My code (reduced to demonstrate bug) consists of a keyboard class which handles drawing keys in specific locations and sets their color based on some logic and a key class which handles drawing the key and keeping track of other attri... | <p>I suspect this behavior is a keyboard limitation, it has a limit on how many keys a keyboard can recognize.
I tested it on <a href="https://en.key-test.ru/" rel="nofollow noreferrer">another site</a> that has the same purpose and the behavior is the same.</p>
<p>My keyboard can recognize more than 5 keys.</p>
<p>Fur... | p5.js keyIsDown() behaving inconsistently when more than 2 keys are pressed at once | javascript|p5.js | 3 | 41 | 1 | 72,253,723 | 72,253,723 | 1 | true | 2022-05-16T01:08:37.387Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
p5.js keyIsDown() behaving inconsistently when more than 2 keys are pressed at once<p>My code (reduced to demonstrate bug) consists of a keyboard class which... |
72,338,299 | HTML python, flask and sqlalchemy<p>so here's my create page code:-</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en" dir="ltr">
... | <p>You are looping through 'details' in your Html file, but you haven't passed 'details' from the render_template function. You don't have to use for loop here as you are not passing a dictionary or a list, instead, you can simply put {{name}} or {{profession}} or {{email}} or whatever you want inside your html file.
I... | HTML python, flask and sqlalchemy | html|flask|sqlalchemy|jinja2|flask-sqlalchemy | 0 | 41 | 3 | 72,339,040 | 72,339,040 | 1 | true | 2022-05-22T14:04:42.337Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
HTML python, flask and sqlalchemy<p>so here's my create page code:-</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-bab... |
72,341,155 | IOException: The process cannot access the file 'fileName/textFile.txt' because it is being used by another process<p>I saw other threads about this problem, and non of them seems to solve my exact problem.</p>
<pre class="lang-cs prettyprint-override"><code>static void RecordUpdater(string username,int points,string t... | <p>You should use the <a href="https://www.bing.com/ck/a?!&&p=3a5e597aabe8f7e230fa73d2df31e2bacd966340afc97dcbfda6b6f116262e83JmltdHM9MTY1MzI1Mjc1NSZpZ3VpZD00Y2ExMWU2Mi1mZjRmLTQwZjEtYWEwZC1hMjU3NjAwY2FkY2UmaW5zaWQ9NTE1OA&ptn=3&fclid=1b2310f0-da11-11ec-9ba9-3bf5485ddc30&u=a1aHR0cHM6Ly9kb2NzLm1pY3Jvc2... | IOException: The process cannot access the file 'fileName/textFile.txt' because it is being used by another process | c#|streamreader|streamwriter|txt | 1 | 41 | 1 | 72,341,211 | 72,341,211 | 1 | true | 2022-05-22T20:42:55.600Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
IOException: The process cannot access the file 'fileName/textFile.txt' because it is being used by another process<p>I saw other threads about this problem,... |
72,381,286 | Remove duplicate code in WPF's TabControl<p>Having trouble removing duplicated code in XAML code.</p>
<p>Example:</p>
<pre><code><TabControl x:Name="TabControl">
<TabItem Header="1">
<TabItem.Content>
<GridView x:Name="GridView1">
... | <p>If you are referring to the entire GridView content, you can create your own control just as you would a form. But instead of</p>
<pre><code><Window x:Class...
other xmlns stuff of window >
[actual content within]
</Window>
</code></pre>
<p>Just create a file with the content of your gridview such... | Remove duplicate code in WPF's TabControl | c#|wpf|xaml|dry | -1 | 41 | 1 | 72,381,477 | 72,381,477 | 1 | true | 2022-05-25T16:27:24.540Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Remove duplicate code in WPF's TabControl<p>Having trouble removing duplicated code in XAML code.</p>
<p>Example:</p>
<pre><code><TabControl x:Name="... |
72,312,633 | Replace column with another array using python<p>I have one A array of <code>(5x5)</code> elements and a second B array of <code>(5x1)</code>. Now I want to replace the column of A with B. My array is</p>
<pre><code>A=array([[1, 2, -3, 4, 5],[1, 2, -3, -4, 5],[-1, 2, -3, -4, 5],[-1, -2, -3, -4, 5],[-1, -2, -3, -4, -5]]... | <p>You could use <a href="https://numpy.org/doc/stable/reference/generated/numpy.argmax.html" rel="nofollow noreferrer"><code>argmax</code></a> to find the first row for each column in which there is a negative value, and then use that result as an index into B:</p>
<pre class="lang-py prettyprint-override"><code>impor... | Replace column with another array using python | python|numpy | 0 | 41 | 1 | 72,312,744 | 72,312,744 | 1 | true | 2022-05-20T01:22:22.763Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Replace column with another array using python<p>I have one A array of <code>(5x5)</code> elements and a second B array of <code>(5x1)</code>. Now I want to ... |
72,288,468 | Is there a way to project max value in a range then finding documents within a new range starting at this max value in just one aggregate?<p>Given the following data in a Mongo collection:</p>
<pre class="lang-json prettyprint-override"><code> {
_id: "1",
dateA: ISODate("2021-12-31T00:... | <p>Assuming the matched initial <code>dateA</code> range is not huge, here is alternate approach that exploits <code>$push</code> and <code>$filter</code> and avoids the hit of a <code>$lookup</code> stage:</p>
<pre class="lang-js prettyprint-override"><code>db.foo.aggregate([
{$match: {dateA: {$gte: new ISODate(&q... | Is there a way to project max value in a range then finding documents within a new range starting at this max value in just one aggregate? | mongodb|mongodb-query|aggregation-framework | 1 | 41 | 2 | 72,290,711 | 72,290,711 | 1 | true | 2022-05-18T11:36:17.207Z | 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 project max value in a range then finding documents within a new range starting at this max value in just one aggregate?<p>Given the follow... |
72,361,530 | when a certain time value comes from false back to true<p>I need to make it automatically when it comes <code>leave_date</code>(leaveted date) <code>room_bool == True</code> now it's all done via urls.py <code>/get/by/<int:pk></code></p>
<p><code>views.py</code></p>
<pre><code> date = datetime.datetime.now().s... | <p>You need something to control timing, it's not easy achieved.</p>
<p>Easier way is to create model called <code>Reservation</code> or something u prefer. Then if someone reserved - create that object. Room can check reservations with methods.</p>
<pre><code>class Reservation(...):
room = models.ForeignKey(...)
... | when a certain time value comes from false back to true | python|django|django-views | 0 | 41 | 1 | 72,366,254 | 72,366,254 | 1 | true | 2022-05-24T10:46:20.403Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
when a certain time value comes from false back to true<p>I need to make it automatically when it comes <code>leave_date</code>(leaveted date) <code>room_boo... |
72,298,083 | How can I detect the timing when I have to change a method in rspec?<p>Suppose I have the following code.</p>
<pre class="lang-rb prettyprint-override"><code>class Answer
enum type: %i[text checkbox image]
def round_type
case answer.type
when text, checkbox
:text
when image
:multimedia
... | <p>If I understood you correctly, you have to make your specs a bit more dynamic and you have to test the <code>else</code> statement as well:</p>
<pre><code>class Answer < ApplicationRecord
enum type: %i[text checkbox image]
def round_type
case type
when 'text', 'checkbox'
:text
when 'image'
... | How can I detect the timing when I have to change a method in rspec? | ruby-on-rails|unit-testing|testing|rspec | 2 | 41 | 1 | 72,300,007 | 72,300,007 | 1 | true | 2022-05-19T02:49:59.507Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How can I detect the timing when I have to change a method in rspec?<p>Suppose I have the following code.</p>
<pre class="lang-rb prettyprint-override"><code... |
72,242,226 | How can I count dictionary items with specific values inside list in Python?<p>I want to print and count the users who are 'male' and are born on 1973, 1980. Is there a way to search '1973' and '1980' in 'birthday' values so I can count them too?</p>
<pre><code>def getMen():
count = 0
users = [
{'name':... | <p>You can extract the year as a substring of the birthday and then compare:</p>
<pre class="lang-py prettyprint-override"><code> for user in users:
if user['gender']=='male' and user['birthday'][0:4] in ['1973', '1980']:
count +=1
print(user)
</code></pre> | How can I count dictionary items with specific values inside list in Python? | python|list|dictionary | 0 | 41 | 2 | 72,242,248 | 72,242,248 | 2 | true | 2022-05-14T16:43:04.657Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How can I count dictionary items with specific values inside list in Python?<p>I want to print and count the users who are 'male' and are born on 1973, 1980.... |
72,245,497 | Why is the minimal value greater than zero?<p>I was just testing numbers in JavaScript when I noticed something weird occurring.</p>
<p>Why is <code>Number.MIN_VALUE</code> greater than <code>0</code>? I expected it to be a very small negative value.</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-con... | <p>The value of <code>Number.MIN_VALUE</code> is equal to <code>5e-324</code>. This can be shown below.</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>console.log(Number.MIN_V... | Why is the minimal value greater than zero? | javascript|numbers|min|zero | 1 | 41 | 2 | 72,245,541 | 72,245,541 | 2 | true | 2022-05-15T04:23:51.683Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Why is the minimal value greater than zero?<p>I was just testing numbers in JavaScript when I noticed something weird occurring.</p>
<p>Why is <code>Number.M... |
72,258,273 | Find the most recent file saved under same name but in different directories using .NET C#<p>The directories are the 3 below</p>
<pre><code> filename = Path.GetDirectoryName(Assembly.GetExecutingAssembly().Location);
filenameprint = System.Environment.CurrentDirectory;
pathload = Environment.GetFolderPath(En... | <p>This should do the trick:</p>
<pre><code> var files = new List<string>() {filename, filenameprint, pathload};
var newestFile = files.Select(file => new FileInfo(file)).OrderByDescending(f => f.LastWriteTime).First();
</code></pre>
<p>Edit: naturally you will have to combine the filename with the p... | Find the most recent file saved under same name but in different directories using .NET C# | c#|.net|visual-studio | 0 | 41 | 1 | 72,258,524 | 72,258,524 | 2 | true | 2022-05-16T11:10:58.187Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Find the most recent file saved under same name but in different directories using .NET C#<p>The directories are the 3 below</p>
<pre><code> filename = Pa... |
72,263,407 | Python descending number<p>I need to create a program that will take a integer, (e.g. 4586), and return the number with the digits in descending order (e.g. 8654).</p>
<pre class="lang-py prettyprint-override"><code>num = 4586
num1 = num #num1 is a string
descendingNumber = []
for i in num1:
for j in i:
if i <... | <p>That insertion process doesn't look quite right. You can accomplish this in one line using built-ins.</p>
<p>First, we get the individual digits by using <code>str()</code>, and then sort them using <code>sorted()</code>. This gives us a list of digits, so we then use <code>''.join()</code> to turn it back into a st... | Python descending number | python | 0 | 41 | 1 | 72,263,450 | 72,263,450 | 2 | true | 2022-05-16T17:38:30.520Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Python descending number<p>I need to create a program that will take a integer, (e.g. 4586), and return the number with the digits in descending order (e.g. ... |
72,254,451 | how do I parse a varible do isolate a singular piece of data in python?<p>when I output the variable p using
<code>p[0]</code>
it outputs</p>
<pre><code><Ether dst=4a:aa:ac:d6:57:00 src=99:c3:88:b0:56:2e type=IPv4 |<IP version=4 ihl=5 tos=0x0 len=32 id=1 flags= frag=0 ttl=64 proto=icmp chksum=0x83e5 src=192.168... | <p>You can access the data by using:</p>
<pre><code>p[0][Raw].load
</code></pre>
<p>The <code>[Raw]</code> accesses the <code>Raw</code> <em>layer</em>, and the <code>.load</code> accesses the <code>load</code> <em>field</em> (from the <code>Raw</code> <em>layer</em>).</p> | how do I parse a varible do isolate a singular piece of data in python? | python-3.x|scapy | 1 | 41 | 2 | 72,263,692 | 72,263,692 | 2 | true | 2022-05-16T05:21:25.877Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
how do I parse a varible do isolate a singular piece of data in python?<p>when I output the variable p using
<code>p[0]</code>
it outputs</p>
<pre><code><... |
72,266,807 | Is useState meant to hold a custom object?<pre><code>const [obj, set_obj] = useState(new CusObj())
</code></pre>
<p>Is there any difference between useState holding a primitive vs a custom object?</p> | <p>From the <a href="https://reactjs.org/docs/hooks-reference.html#usestate" rel="nofollow noreferrer">docs</a></p>
<blockquote>
<p>Unlike the setState method found in class components, useState does
not automatically merge update objects. You can replicate this
behavior by combining the function updater form with obje... | Is useState meant to hold a custom object? | javascript|reactjs|react-hooks|use-state | -5 | 41 | 1 | 72,266,866 | 72,266,866 | 2 | true | 2022-05-16T23:58:27.613Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Is useState meant to hold a custom object?<pre><code>const [obj, set_obj] = useState(new CusObj())
</code></pre>
<p>Is there any difference between useState ... |
72,278,749 | How to know if there is any similar elements in two set<p>this is my code can any one pinpoint where i was mistaken ?
I am new to the coding so i expect help from the community</p>
<pre><code>first_set = (1,2,3,4)
second_set = (2,7,5,4)
m = len(first_set)
n = len(second_set)
a = 0
b = 0
for a in range(m):
for b in ra... | <p>You can use <a href="https://docs.python.org/3/library/stdtypes.html?highlight=set#frozenset.intersection" rel="nofollow noreferrer"><code>set.intersection</code></a> to get the common elements of two sets.</p>
<pre class="lang-py prettyprint-override"><code>a = set([1,2,3])
b = set([4,5,3])
print(a.intersection(b)... | How to know if there is any similar elements in two set | python | -1 | 41 | 3 | 72,278,783 | 72,278,783 | 2 | true | 2022-05-17T18:06:03.737Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to know if there is any similar elements in two set<p>this is my code can any one pinpoint where i was mistaken ?
I am new to the coding so i expect help... |
72,279,845 | UWP RenderTargetBitmap.RenderAsync Hangs<p>I wrote a function to rasterize stroke data from an InkCanvas, but for some reason <code>renderBMP.RenderAsync(...)</code> hangs indefinitely. Any advice?</p>
<pre><code> RenderTargetBitmap rasterizePage(int pageNumber) {
if (readStrokes(pageNumber) == null) return... | <p>As Theodor Zoulias said, you synchronous call to async methods make thread stuck, you could use await keyword to repalce <code>task.AsTask().Wait();</code>, please refer to the following code</p>
<pre><code>public async Task<RenderTargetBitmap> rasterizePage(int pageNumber)
{
if (readStrokes(pageNumber) =... | UWP RenderTargetBitmap.RenderAsync Hangs | c#|multithreading|uwp|rendertargetbitmap | 1 | 41 | 1 | 72,282,615 | 72,282,615 | 2 | true | 2022-05-17T19:45:19.450Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
UWP RenderTargetBitmap.RenderAsync Hangs<p>I wrote a function to rasterize stroke data from an InkCanvas, but for some reason <code>renderBMP.RenderAsync(...... |
72,283,726 | Matching value to column index pandas<p>I have dataframe that looks like the following:</p>
<pre><code> Given Y1 eY1 Y2 eY2 Y3 eY3 Y4 eY4 Y5
0 0.45 0.25 0.3550 0.39 0.4200 0.43 0.5950 0.65 0.7175 0.74
1 0.39 0.15 0.2400 0.27 0.5025 0.58 0.7675 0.83 0.8600 0.87
2 ... | <p>First subtract all columns without <code>Given</code> by column <code>Given</code> by <a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.sub.html" rel="nofollow noreferrer"><code>DataFrame.sub</code></a> with absolute values and then use <a href="http://pandas.pydata.org/pandas-docs/... | Matching value to column index pandas | python|pandas|dataframe|numpy | 2 | 41 | 1 | 72,283,755 | 72,283,755 | 2 | true | 2022-05-18T05:40:16.613Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Matching value to column index pandas<p>I have dataframe that looks like the following:</p>
<pre><code> Given Y1 eY1 Y2 eY2 Y3 eY3 ... |
72,289,508 | Triggering a Twilio flow execution to a contact channel address while another execution to the same number is still active<p>Triggering a twilio flow execution to the same number while another execution is still in progress will send a response of the same execution id without any indication that this execution is not ... | <p>Use v2 of the Executions resource, it will return a 409 response.</p>
<p><a href="https://www.twilio.com/docs/studio/rest-api/v2#differences-between-v1-and-v2" rel="nofollow noreferrer">Differences Between v1 and v2</a></p> | Triggering a Twilio flow execution to a contact channel address while another execution to the same number is still active | twilio|twilio-api|twilio-studio | 0 | 41 | 1 | 72,289,955 | 72,289,955 | 2 | true | 2022-05-18T12:48:09.437Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Triggering a Twilio flow execution to a contact channel address while another execution to the same number is still active<p>Triggering a twilio flow executi... |
72,290,980 | Using the last day in each month of my time series in R<p>I need to use only the last day available in my dataset to aggregate later on but I didn´t have success...</p>
<pre><code>library(tibbletime)
dataset <- data.frame(
timestamp = c("2010-01-01", "2010-01-03", "2010-01-23")... | <p>The answer from Julian is a nice start, but it won't work across multiple years because the grouping variable doesn't include information about the year.</p>
<p>The typical way to do this is to group on year-month, and then filter to the max date per year-month group.</p>
<p>Also, as the creator of tibbletime I woul... | Using the last day in each month of my time series in R | r|date|time-series|aggregate|tibbletime | 1 | 41 | 2 | 72,291,949 | 72,291,949 | 2 | true | 2022-05-18T14:22:44.153Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Using the last day in each month of my time series in R<p>I need to use only the last day available in my dataset to aggregate later on but I didn´t have suc... |
72,293,616 | Is it possible to make the height of an element 100% of it's container width?<p>I'd like to make an element have the same width and height so it is a perfect square. However the width is not a set value but rather defined by the viewport plus some whitespace. The whitespace is defined by some <code>grid</code> <code>fr... | <p>There is a CSS property just for that: <a href="https://developer.mozilla.org/en-US/docs/Web/CSS/aspect-ratio" rel="nofollow noreferrer"><code>aspect-ratio</code></a></p>
<blockquote>
<p>The aspect-ratio CSS property sets a preferred aspect ratio for the
box, which will be used in the calculation of auto sizes and s... | Is it possible to make the height of an element 100% of it's container width? | html|css | 0 | 41 | 1 | 72,293,944 | 72,293,944 | 2 | true | 2022-05-18T17:33:09.990Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Is it possible to make the height of an element 100% of it's container width?<p>I'd like to make an element have the same width and height so it is a perfect... |
72,294,757 | Better approach when obtaining multiple values from the same method at once<p>I have the following method which returns a tuple,</p>
<pre><code>public Tuple<int, bool> GetStudentInformation(long stutID)
</code></pre>
<p>Called as,</p>
<pre><code>Marks= GetStudentInformation((Id).Item1;
HasPassed= GetStudentInform... | <p>You just need to save return value</p>
<pre class="lang-cs prettyprint-override"><code>Tuple<int, bool> info = GetStudentInformation(Id);
Marks = info.Item1;
HasPassed = info.Item2;
</code></pre> | Better approach when obtaining multiple values from the same method at once | c#|.net | 1 | 41 | 2 | 72,294,833 | 72,294,833 | 2 | true | 2022-05-18T19:10:48.160Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Better approach when obtaining multiple values from the same method at once<p>I have the following method which returns a tuple,</p>
<pre><code>public Tuple&... |
72,297,845 | How to check if an object is an instance of template class of multiple template arguments and that one of said arguments fulfills some condition?<p>From <a href="https://stackoverflow.com/questions/72279095/how-to-check-if-an-object-is-an-instance-of-a-template-class-of-multiple-templat/72279177#72279177">How to check ... | <p>You were on the right track:</p>
<pre><code>#include <type_traits>
#include <iostream>
template <typename T1, typename T2>
struct A
{
};
template <typename Type, typename=void>
struct IsA: std::false_type
{
};
template <typename T1, typename T2>
struct IsA<A<T1, T2>, std::en... | How to check if an object is an instance of template class of multiple template arguments and that one of said arguments fulfills some condition? | c++|templates|typetraits | 2 | 41 | 1 | 72,298,054 | 72,298,054 | 2 | true | 2022-05-19T02:01:38.560Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to check if an object is an instance of template class of multiple template arguments and that one of said arguments fulfills some condition?<p>From <a h... |
72,299,126 | "on error goto" glitch. How to deal with a consecutive error and ignoring last row command<p>I am just learning the abc on vba</p>
<p>I have been working with this code, to auto-populate a list based on 2 others.
I have a client list, each client has a consultant, I needed to populate the team each client belonged to, ... | <p>Your error handling is not working as you expect. If you read the documentation of the <a href="https://docs.microsoft.com/en-us/dotnet/visual-basic/language-reference/statements/resume-statement" rel="nofollow noreferrer">Resume Statement</a> it says <code>Resume Next</code> does the follwing:</p>
<blockquote>
<p>E... | "on error goto" glitch. How to deal with a consecutive error and ignoring last row command | excel|vba|onerror | 2 | 41 | 2 | 72,299,994 | 72,299,994 | 2 | true | 2022-05-19T05:35:50.537Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
"on error goto" glitch. How to deal with a consecutive error and ignoring last row command<p>I am just learning the abc on vba</p>
<p>I have been working wit... |
72,299,992 | Multiple async queries in nodejs (mongoose)<p>I am a nodejs newbie. I have two simple models, User and Story. Here is what I want to do:</p>
<ul>
<li>I want to retrieve all stories that have {status:"public"} and store it in an array called retrievedStories.</li>
<li>Then for each story I want to use its &quo... | <p>You can simplify your query by using <code>populate</code> to retrieve <code>User</code>'s data:</p>
<pre><code>router.get('/', async (req, res) => {
try {
const retrievedStories = await Story.find({ status: 'public' })
.populate('user')
.exec();
return res.json(retrievedStories);
... | Multiple async queries in nodejs (mongoose) | javascript|node.js|mongoose|async-await | 0 | 41 | 1 | 72,300,061 | 72,300,061 | 2 | true | 2022-05-19T07:01:57.840Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Multiple async queries in nodejs (mongoose)<p>I am a nodejs newbie. I have two simple models, User and Story. Here is what I want to do:</p>
<ul>
<li>I want ... |
72,305,724 | How to create a dataframe from existing data frame where few column are appended as rows?<p>I have a data frame like below:</p>
<pre><code>data = {'Age': [20, 30, 19, 21],'city1':['ny','nj','ln','tampa'],'country1':['usa','usa','usa','usa'],'city2':['london','edinburg',np.nan,'tampa'],
'country2':['uk','uk','uk... | <p>You can use <a href="https://pandas.pydata.org/docs/reference/api/pandas.wide_to_long.html" rel="nofollow noreferrer"><code>wide_to_long</code></a>:</p>
<pre><code>(pd
.wide_to_long(df1.reset_index(),
stubnames=['city', 'country'], i=['index', 'Age'], j='id')
.droplevel(-1)
.reset_index('Age')
)
</... | How to create a dataframe from existing data frame where few column are appended as rows? | python|pandas|list|dataframe|row | 0 | 41 | 2 | 72,305,865 | 72,305,865 | 2 | true | 2022-05-19T13:46:01.967Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to create a dataframe from existing data frame where few column are appended as rows?<p>I have a data frame like below:</p>
<pre><code>data = {'Age': [20... |
72,306,553 | Looking for a solution to add numeric and float elements stored in list format in one of the columns in dataframe<pre><code>| Index | col1 |
| -------- | -------------- |
| 0 | [0,0] |
| 2 | [7.9, 11.06] |
| 3 | [0.9, 4] |
| 4 | NAN |
</code></pre>
... | <p>Using <code>na_action</code> parameter in map should work as well:</p>
<pre><code>df['Total'] = df['col1'].map(sum,na_action='ignore')
</code></pre> | Looking for a solution to add numeric and float elements stored in list format in one of the columns in dataframe | python|pandas|list|dataframe|numpy | -3 | 41 | 2 | 72,307,146 | 72,307,146 | 2 | true | 2022-05-19T14:38:21.440Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Looking for a solution to add numeric and float elements stored in list format in one of the columns in dataframe<pre><code>| Index | col1 |
| -... |
72,302,222 | Where does bazel store fetched packages?<p>In my <code>WORKSPACE</code> file I have defined a http_archive like</p>
<pre><code>http_archive(
name = "awscli_zip",
urls = [
"https://awscli.amazonaws.com/awscli-exe-linux-x86_64-{version}.zip".format(version = awscli_version)
],
... | <p>See <code>$(bazel info output_base)/external</code>.</p>
<p>(The "convenience symlinks", as the <code>bazel-*</code> symlinks in the workspace root as are known, are only created on build or test commands.)</p> | Where does bazel store fetched packages? | package|bazel | 1 | 41 | 1 | 72,309,924 | 72,309,924 | 2 | true | 2022-05-19T09:42:02.967Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Where does bazel store fetched packages?<p>In my <code>WORKSPACE</code> file I have defined a http_archive like</p>
<pre><code>http_archive(
name = "... |
72,313,592 | How to construct 32-bit uint in Python using ctypes bit field?<p>I would like to construct an unsigned 32-bit int using Python3 ctypes bit field, as follows:</p>
<pre><code>c_uint = ctypes.c_uint32
class Flags_bits(ctypes.LittleEndianStructure):
_fields_ = [
("a", c_uint, 4),
(&q... | <p>It IS stored little-endian. The <code>binascii.hexlify</code> function reads the value as a set of bytes, and returns a string of those bytes. It's not treating them as an integer. As bytes, the values are 21 43 65 87. Unless you treat a set of bytes as a multi-byte unit, endianness does not apply.</p>
<p>If you... | How to construct 32-bit uint in Python using ctypes bit field? | python|endianness|bit-fields | 1 | 41 | 1 | 72,313,636 | 72,313,636 | 2 | true | 2022-05-20T04:26:12.927Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to construct 32-bit uint in Python using ctypes bit field?<p>I would like to construct an unsigned 32-bit int using Python3 ctypes bit field, as follows:... |
72,316,330 | YAML syntax for set_fact and vars in ansible<p>I have difficulties to get the differences between the following syntaxes when I set vars or facts in a YAML role:</p>
<pre class="lang-yaml prettyprint-override"><code>vars:
app_path1: "{{ (ansible_facts.env.ProgramFiles + '\\\\' + item.installation_directory) if i... | <p>For the new line, this is the behaviour of those two YAML style indicator.<br />
There is <a href="https://yaml.org/spec/1.2.2/#8112-block-chomping-indicator" rel="nofollow noreferrer"><em>"strip chomping indicator"</em></a> to get rid of them though:</p>
<p>So, <code>app_path2</code> and <code>app_path3</... | YAML syntax for set_fact and vars in ansible | syntax|ansible|yaml | 2 | 41 | 1 | 72,316,611 | 72,316,611 | 2 | true | 2022-05-20T09:08:05.693Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
YAML syntax for set_fact and vars in ansible<p>I have difficulties to get the differences between the following syntaxes when I set vars or facts in a YAML r... |
72,315,607 | Javascript why Product2 is never called contrary to Product1<p>I'm experimenting with javascript function as object and async. Why Product2 below is never called ?</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 ... | <p>Not every function is a constructor. Some quotes from the ECMAScript specification clarify this:</p>
<p><a href="https://tc39.es/ecma262/2021/#table-essential-internal-methods" rel="nofollow noreferrer">Essential Internal Methods</a></p>
<blockquote>
<p>A function object is an object that supports the <code>[[Call]]... | Javascript why Product2 is never called contrary to Product1 | javascript | -1 | 41 | 3 | 72,316,777 | 72,316,777 | 2 | true | 2022-05-20T08:12:55.793Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Javascript why Product2 is never called contrary to Product1<p>I'm experimenting with javascript function as object and async. Why Product2 below is never ca... |
72,316,600 | should I hide my fcm details, like: apiKey, authDomain, projectId, storageBucket, messagingSenderId, appId, measurementId and vapidkey<p>I've these details, exposed to many websites developed for me by me.</p>
<p>I use these to try sending notifications to my users/subscribers. But I was thinking if someone evil gets t... | <p>There is no problem, indeed is needed to comunicate with yout service. You can take a look a this response:</p>
<p><a href="https://stackoverflow.com/a/38860737/7414755">https://stackoverflow.com/a/38860737/7414755</a></p> | should I hide my fcm details, like: apiKey, authDomain, projectId, storageBucket, messagingSenderId, appId, measurementId and vapidkey | firebase|firebase-cloud-messaging | 0 | 41 | 1 | 72,316,786 | 72,316,786 | 2 | true | 2022-05-20T09:28:01.983Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
should I hide my fcm details, like: apiKey, authDomain, projectId, storageBucket, messagingSenderId, appId, measurementId and vapidkey<p>I've these details, ... |
72,321,900 | How to propely observe sign-in state in MVVM<p>I'm trying to observing sign-in state with below code,</p>
<pre><code>@HiltViewModel
class LoginViewModel @Inject constructor(
private val auth: FirebaseAuth,
):ViewModel(){
fun getUser():MutableLiveData<FirebaseUser?>?{
return MutableLiveData(auth.c... | <p>Your LiveData will only ever produce one value:</p>
<pre><code>MutableLiveData(auth.currentUser)
</code></pre>
<p>That is, the value of <code>auth.currentUser</code> at the time the object was constructed (null). It's not "listening" to anything at all, and not responding to any changes in the user's auth... | How to propely observe sign-in state in MVVM | android|kotlin|firebase-authentication | 0 | 41 | 1 | 72,321,953 | 72,321,953 | 2 | true | 2022-05-20T16:10:54.567Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to propely observe sign-in state in MVVM<p>I'm trying to observing sign-in state with below code,</p>
<pre><code>@HiltViewModel
class LoginViewModel @Inj... |
72,332,128 | Execute a Code Depending on Variable Input<p>I am creating an Enrollment Management Program as an output for our school.</p>
<p>The program I am creating contains a section that asks the user about their family.</p>
<p>One category is how many siblings they have. I want the program to ask the user for the number of sib... | <p>The trouble is that for any non-negative value of <code>siblingCount</code>, <code>while</code> loop will run forever. You may want use a <code>for</code> loop instead:</p>
<pre><code>def siblingCheck():
input("Name: ")
input("Age: ")
input("Grade Level: ")
siblingCount = ... | Execute a Code Depending on Variable Input | python|variables | 0 | 41 | 1 | 72,332,233 | 72,332,233 | 2 | true | 2022-05-21T18:11:46.453Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Execute a Code Depending on Variable Input<p>I am creating an Enrollment Management Program as an output for our school.</p>
<p>The program I am creating con... |
72,334,855 | Date Conversion fails in C# via Parameter adding (SqlDbType.DateTime)<p>I am new to C#. I have this statement that fails:</p>
<pre><code>dbCmd.Parameters.Add("@createdTime", SqlDbType.DateTime);
</code></pre>
<p>The value in the createdTime is: 1/18/2012 11:54:11 AM
After a lot of troubleshooting I was able t... | <p>Parse the value explicitly in C# so the db parameter contains a DateTime, not a string:</p>
<pre><code>dbCmd.Parameters.Add("@createdTime", SqlDbType.DateTime)
.Value = DateTime.ParseExact(theVariableHoldingStringDateTime, "M/d/yyyy hh:mm:ss tt", CultureInfo.InvariantCulture);
</code></pre>
<p>... | Date Conversion fails in C# via Parameter adding (SqlDbType.DateTime) | c#|sql|ssis|ssis-2017 | -1 | 41 | 1 | 72,335,418 | 72,335,418 | 2 | true | 2022-05-22T04:43:54.667Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Date Conversion fails in C# via Parameter adding (SqlDbType.DateTime)<p>I am new to C#. I have this statement that fails:</p>
<pre><code>dbCmd.Parameters.Add... |
72,337,312 | Function only on click of the exact class and data-id<p>I have two elements both with the same class <code>.one</code>. Click this button and show class <code>.A</code>.
One of those elements also has a data-id of <code>two</code>. Click this button and show class <code>.B</code>.</p>
<p>But, as the second "button... | <p>Just use the <a href="https://api.jquery.com/not-selector/" rel="nofollow noreferrer">:not</a> selector like this:</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>$('.one:no... | Function only on click of the exact class and data-id | javascript|html|jquery|css | 0 | 41 | 3 | 72,337,370 | 72,337,370 | 2 | true | 2022-05-22T11:49:06.550Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Function only on click of the exact class and data-id<p>I have two elements both with the same class <code>.one</code>. Click this button and show class <cod... |
72,327,772 | how to pass object values in WithMessage function in fluentvalidation<p>I have the following code :</p>
<pre><code> RuleFor(record => record)
.Must(WholeObject => Mandatory(WholeObject, keyValuePairs))
.WithName( X => X.KeyName).WithMessage("KeyValue is mandatory but some values ... | <p>Change your code like below:</p>
<pre><code>RuleFor(record => record)
.Must(WholeObject => Mandatory(WholeObject,keyValuePairs))
.WithName(X => X.KeyName).WithMessage(x => $"{x.KeyName} is mandatory but some values are missing");
</code></pre>
<p>Whole code:</p>
<pre><code>publ... | how to pass object values in WithMessage function in fluentvalidation | asp.net-core|fluentvalidation | 0 | 41 | 1 | 72,342,727 | 72,342,727 | 2 | true | 2022-05-21T08:08:40.753Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
how to pass object values in WithMessage function in fluentvalidation<p>I have the following code :</p>
<pre><code> RuleFor(record => record)
... |
72,354,664 | Plot data from data frame list<p>I have a list of data frames,</p>
<pre><code>>head(df.list.xyg[["archae.list"]])
motif obs pred prop stat pval stdres
AAB 1189 760.1757 0.05556028 11811.94 0 16.00425
CDD 1058 249.7147 0.01825133 11811.94 0 51.62291
DDE 771 415.1314 0.03034143 11811.94 0 17.73730... | <p>If you just want the plots to appear together in a single plotting window, you can use facets. You can bind the rows of your data frames together with <code>dplyr::bind_rows</code>, which will create an id column to label which data frame each row belongs to. We facet by this ID variable.</p>
<pre class="lang-r pret... | Plot data from data frame list | r|ggplot2|lapply|geom-bar|facet-wrap | 1 | 41 | 2 | 72,354,891 | 72,354,891 | 2 | true | 2022-05-23T20:49:19.180Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Plot data from data frame list<p>I have a list of data frames,</p>
<pre><code>>head(df.list.xyg[["archae.list"]])
motif obs pred prop stat pval ... |
72,356,871 | Convert timestamp from API into date and add +3 hours<p>I have the following timestamps from an API call:</p>
<pre><code>2022-05-22T13:53:42.010238Z
2022-05-22T11:53:30.910039Z
2022-05-22T11:46:43.904101Z
2022-05-22T11:46:27.815341Z
2022-05-22T11:46:12.581602Z
2022-05-22T11:41:56.246782Z
2022-05-22T11:41:39.443423Z
</c... | <p>You can try below formula-</p>
<pre><code>=SUM(SPLIT(SUBSTITUTE(A1,"Z",""),"T"))+TIME(3,0,0)
</code></pre>
<p><a href="https://i.stack.imgur.com/IiPYz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IiPYz.png" alt="enter image description here" /></a></p> | Convert timestamp from API into date and add +3 hours | google-apps-script|google-sheets | 0 | 41 | 3 | 72,356,927 | 72,356,927 | 2 | true | 2022-05-24T03:24:19.053Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Convert timestamp from API into date and add +3 hours<p>I have the following timestamps from an API call:</p>
<pre><code>2022-05-22T13:53:42.010238Z
2022-05-... |
72,362,566 | Access previous dataframe during pandas method chaining<p><a href="https://en.wikipedia.org/wiki/Method_chaining" rel="nofollow noreferrer">Method chaining</a> is a known way to improve code readability and often referred to as a Fluent API [<a href="https://florianeinfalt.de/posts/fluent-interfaces-in-python/" rel="no... | <p>Use <a href="https://pandas.pydata.org/docs/reference/api/pandas.DataFrame.pipe.html" rel="nofollow noreferrer"><code>pipe</code></a>:</p>
<pre><code>dropped = (
pd
.concat([df_1, df_2], axis=1)
.pipe(lambda d: d.dropna(how='any',
subset=[c for c in d.columns if c != 'col4'])... | Access previous dataframe during pandas method chaining | python|pandas|dataframe|concatenation|method-chaining | 3 | 41 | 1 | 72,362,604 | 72,362,604 | 2 | true | 2022-05-24T12:03:37.310Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Access previous dataframe during pandas method chaining<p><a href="https://en.wikipedia.org/wiki/Method_chaining" rel="nofollow noreferrer">Method chaining</... |
72,367,364 | Pandas get date range from timeseries column<p>I have a dataframe which looks something like this:</p>
<pre><code>id ts factor
A 2020-01-01 1
A 2020-01-02 1
A 2020-01-03 1
A 2020-01-04 1
A 2020-01-05 1
A 2020-01-06 10
A 2020-01-07 10
A 2020-01-08 10
A 2020-01-09 10
A 2020-01-10 10
A 20... | <p>Use <code>cumsum</code> on comparison with shift of <code>factor</code> to find the <code>factor</code> blocks, then add it to <code>groupby</code>:</p>
<pre><code>blocks = df['factor'].ne(df['factor'].shift()).cumsum()
df.groupby(['id','factor',blocks], sort=False)['ts'].agg(['min','max'])
</code></pre>
<p>Output:<... | Pandas get date range from timeseries column | python|pandas|dataframe | 2 | 41 | 2 | 72,367,455 | 72,367,455 | 2 | true | 2022-05-24T17:53:07.183Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Pandas get date range from timeseries column<p>I have a dataframe which looks something like this:</p>
<pre><code>id ts factor
A 2020-01-01 1
A 2020-0... |
72,380,346 | Accessing a numpy array with an array of indices<p>I'm trying to access a numpy array A using another array B providing the indices at each position:</p>
<pre class="lang-py prettyprint-override"><code>A = np.array([[1,2],[3,4]])
B = np.array([[[0,0],[0,0]],[[0,1],[0,1]]])
</code></pre>
<p>Desired output:</p>
<pre clas... | <p>I probably should have insisted on seeing the iterative solution first, but here's the array one:</p>
<pre><code>In [45]: A[B[:,:,1], B[:,:,0]]
Out[45]:
array([[1, 1],
[3, 3]])
</code></pre>
<p>I first tried <code>A[B[:,:,0], B[:,:,1]]</code>, the natural order of the inner dimension. Your own code could ha... | Accessing a numpy array with an array of indices | python|numpy | 1 | 41 | 2 | 72,380,519 | 72,380,519 | 2 | true | 2022-05-25T15:22:06.553Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Accessing a numpy array with an array of indices<p>I'm trying to access a numpy array A using another array B providing the indices at each position:</p>
<pr... |
72,384,629 | i dont know why the functions aren´t using my variable<p>i made a variable with a string inside, an then put that variable in two different functions. The problem here is that it shows me an error: "Uncaught ReferenceError: mostrarDatosTexto is not defined". I´m not sure enough why is this happening. Here´s t... | <p><code>mostrarDatosTexto</code> is a property, not a variable. You need to access it using <code>XXX.mostrarDatosTexto</code> syntax.</p>
<p>Inside an object method, you can use <code>this</code> to refer to the object that the method was called on. But you have to use an ordinary function, not an arrow function, bec... | i dont know why the functions aren´t using my variable | javascript|html|css | -1 | 41 | 1 | 72,384,673 | 72,384,673 | 2 | true | 2022-05-25T22:04:51.320Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
i dont know why the functions aren´t using my variable<p>i made a variable with a string inside, an then put that variable in two different functions. The pr... |
72,389,941 | Looking for doing a small animation with gnuplot and ffmpeg<p>I am trying to do a small animations from multiples images (generated by the plot of input files test_matter_power_xxx.dat).</p>
<p>Here the script :</p>
<pre><code>#!/bin/bash
for i in {1..398}; do
gnuplot -p <<-EOFMarker
set terminal jpeg;
set logsc... | <p>You can't do:</p>
<pre><code>plot "test_matterpower_$i.dat" u 1:2 w l > pic$i.jpeg;
</code></pre>
<p>You need to set the output:</p>
<pre><code>set output "pic$i.jpeg";
plot "test_matterpower_$i.dat" u 1:2 w l;
</code></pre> | Looking for doing a small animation with gnuplot and ffmpeg | bash|animation|ffmpeg|gnuplot|script | 1 | 41 | 1 | 72,390,334 | 72,390,334 | 2 | true | 2022-05-26T09:52:42.700Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Looking for doing a small animation with gnuplot and ffmpeg<p>I am trying to do a small animations from multiples images (generated by the plot of input file... |
72,394,854 | Can I keep a branch in sync with main except for specific files?<p>Is it possible to keep a feature branch totally in sync with the main branch except for a couple of specific files?</p>
<p>So for example I have a branch I create specifically for trying out a new style which has some changes to a css file, I'm not sure... | <p>I think you're already taking the right approach: create a separate branch for your "special CSS".</p>
<p>You can (and should) frequently merge changes in "main" back to your "dev" branch, to keep everything in sync.</p>
<p>Unless that particular CSS file is changing in "main"... | Can I keep a branch in sync with main except for specific files? | git | 1 | 41 | 2 | 72,395,167 | 72,395,167 | 2 | true | 2022-05-26T16:10:57.290Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Can I keep a branch in sync with main except for specific files?<p>Is it possible to keep a feature branch totally in sync with the main branch except for a ... |
72,395,405 | baseVariants in site definition with ports<p>I use docker on Mac OS X. On Mac OS X there is no possibility to map a domain name like mysite.local to something like http://localhost:8015/ etc.</p>
<p>So I have to call my docker container with http://localhost:8015/ The backend works as expected and shows me the applicat... | <p>OK, i found the solution: it was a minor error in my configuration. In the htaccess file of my docker volume i wrote:</p>
<pre><code>SetEnv TYPO3_CONTEXT=Development/Docker
</code></pre>
<p>this syntax is wrong but it works in the backend ... so TYPO3 showed me in the backend the context "Development/Docker&quo... | baseVariants in site definition with ports | typo3 | 0 | 41 | 1 | 72,397,153 | 72,397,153 | 2 | true | 2022-05-26T16:55:49.463Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
baseVariants in site definition with ports<p>I use docker on Mac OS X. On Mac OS X there is no possibility to map a domain name like mysite.local to somethin... |
72,398,803 | Generating an array of non-repeating integers<p>I'm trying to generate an array of 5 non-repeating integers in Java, but there are still repeats when I run it. Here's my code so far:</p>
<pre><code>public int[] generateCode(){
code[0] = (int)Math.round(Math.random()*8+1); // initialize first number so it won't be c... | <p>So, your <code>for-loop</code> is checking for repeated characters, BUT each time you generate a new value (in the <code>while-loop</code>) you're not checking to see if the value exits before <code>j</code>.</p>
<p>There are a number of possible ways you might address this issue, I prefer ones which uses <code>Coll... | Generating an array of non-repeating integers | java|arrays | 0 | 41 | 2 | 72,398,986 | 72,398,986 | 2 | true | 2022-05-26T22:54:24.963Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Generating an array of non-repeating integers<p>I'm trying to generate an array of 5 non-repeating integers in Java, but there are still repeats when I run i... |
72,345,142 | Weighted + ordered tag search using Postgres<p>After an AI file analysis across tens of thousands of audio files I end up with this kind of data structure in a Postgres DB:</p>
<pre><code>id | name | tag_1 | tag_2 | tag_3 | tag_4 | tag_5
1 | first song | rock | pop | 80s | female singer ... | <p>After a lot of trials and errors this is what I ended up with, using only Postgres:</p>
<ol>
<li>Turn all data set to integers, so it moves on to something like this (I also added columns to match the real data set more closely) :</li>
</ol>
<pre><code>id | bpm | tag_1 | tag_2 | tag_3 | tag_4 | tag_5
1 | 114 | 1 ... | Weighted + ordered tag search using Postgres | sql|postgresql | 1 | 41 | 1 | 72,402,574 | 72,402,574 | 2 | true | 2022-05-23T08:03:35.153Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Weighted + ordered tag search using Postgres<p>After an AI file analysis across tens of thousands of audio files I end up with this kind of data structure in... |
72,380,726 | Configure x-axis limits after chart creation<p>I know I can create a chart with custom x-axis limits by, for example:</p>
<pre class="lang-py prettyprint-override"><code>altair.Chart(source).encode(
x=altair.X("whatever", scale=altair.Scale(domain=(left_limit, right_limit))
)
</code></pre>
<p>But given a ... | <p>You can access and override the attributes of the chart object after creation like this:</p>
<pre><code>import altair as alt
from vega_datasets import data
source = data.cars.url
chart = alt.Chart(source).mark_circle().encode(
x=alt.X('Horsepower:Q'), #scale=alt.Scale(domain=[0, 250])),
y='Miles_per_Gallon... | Configure x-axis limits after chart creation | python-3.x|altair|vega-lite | 1 | 41 | 1 | 72,427,835 | 72,427,835 | 2 | true | 2022-05-25T15:49:15.770Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Configure x-axis limits after chart creation<p>I know I can create a chart with custom x-axis limits by, for example:</p>
<pre class="lang-py prettyprint-ove... |
72,291,474 | pointers all the same in list comprehension even though they shouldn't<p>I think I understand pointers, here is an example showing a normal behaviour:</p>
<pre class="lang-py prettyprint-override"><code>class A:
def __init__(self, n):
self.n = n
a = A(1)
b = A(1)
print(id(a))
print(id(b))
</code></pre>
<p>Outpu... | <p>In fact, it is purely coincidental that they have the same id, Python determines whether to destroy an object by reference counting. You don't save the reference of each <code>A(n)</code>, which causes it be destroied immediately after you get its id, so the next <code>A(n)</code> will use the same memory space as t... | pointers all the same in list comprehension even though they shouldn't | python|pointers|list-comprehension | 0 | 41 | 1 | 72,291,518 | 72,291,518 | 2 | true | 2022-05-18T14:54:27.517Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
pointers all the same in list comprehension even though they shouldn't<p>I think I understand pointers, here is an example showing a normal behaviour:</p>
<p... |
72,304,841 | How to remove dictionary from list of dictionary if value repeats in items<p>List of dictionary is below</p>
<pre><code>l = [
{'firstname': 'joe', 'surname': 'ABCD', 'tile' : 'DE'},
{'firstname': 'john', 'surname': 'DEF', 'tile' : 'BC'},
{'firstname': 'joe', 'surname': 'bloggs', 'tile' : 'DE'},
{'firstname': 'jane', 's... | <p>Try:</p>
<pre class="lang-py prettyprint-override"><code>l = [
{"firstname": "joe", "surname": "ABCD", "tile": "DE"},
{"firstname": "john", "surname": "DEF", "tile": "BC"},
{"first... | How to remove dictionary from list of dictionary if value repeats in items | python|dictionary | 1 | 41 | 2 | 72,305,089 | 72,305,089 | 2 | true | 2022-05-19T12:47:32.320Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to remove dictionary from list of dictionary if value repeats in items<p>List of dictionary is below</p>
<pre><code>l = [
{'firstname': 'joe', 'surname':... |
72,336,216 | Deserialize Json with class names that are not always the same, in C#<p>I'm trying to deserialize a response from a firebase realtime database get/json, to get user locations that are online</p>
<p><strong>example response:</strong></p>
<pre><code>{
"test1": {
"id": "test-1",
&qu... | <p>you can use a dictionary in your case</p>
<pre><code>using Newtosoft.Json;
Dictionary<string,Test> tests = JsonConvert.DeserializeObject<Dictionary<string,Test>>(json);
</code></pre>
<p>classes</p>
<pre><code>public class Location
{
public double lat { get; set; }
public double @long { get... | Deserialize Json with class names that are not always the same, in C# | c#|json|.net-core|json.net | 0 | 41 | 1 | 72,336,268 | 72,336,268 | 2 | true | 2022-05-22T09:16:26.807Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Deserialize Json with class names that are not always the same, in C#<p>I'm trying to deserialize a response from a firebase realtime database get/json, to g... |
72,265,381 | How to sort a dictionary that is already sorted in descending order, so that the people with similar averages appear in alphabetical order?<p>Imagine we have a dictionary of peoples' names and averages which are sorted by value (average) in descending order. I want to sort the dictionary in a way that people with simil... | <p>I would sugest to <strong>Sort</strong> by reverse <code>average</code> for descending order (so <code>-1 * n</code>), and then by <code>name</code> for alphabetic ordering. For example:</p>
<pre class="lang-py prettyprint-override"><code>names_strng = """
Ayda,19
Alex,18
Jack,17
George,17
Robbie,15
&... | How to sort a dictionary that is already sorted in descending order, so that the people with similar averages appear in alphabetical order? | python|sorting|dictionary|alphabetical | 1 | 41 | 1 | 72,265,447 | 72,265,447 | 2 | true | 2022-05-16T20:41:11.623Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to sort a dictionary that is already sorted in descending order, so that the people with similar averages appear in alphabetical order?<p>Imagine we have... |
72,329,062 | Treat a literal variable as a constant with Ryacas (or an alternative)<p>With <strong>Ryacas</strong>, one has:</p>
<pre><code>> yac_str("Simplify(2*x^2*4 + x^2*5)")
[1] "13*x^2"
</code></pre>
<p>Now, instead of <code>4</code> and <code>5</code>, I would like to give two letters treated as consta... | <p>I found the way with <strong>caracas</strong>.</p>
<pre class="lang-r prettyprint-override"><code>library(caracas)
def_sym(x, y, z, a, b)
as.character(sympy_func(x^2 + a*x^2 + 2*y + b*y + x*z + a*x*z, "Poly", domain = "RR[a,b]"))
# "Poly((1.0*a + 1.0)*x^2 + (1.0*a + 1.0)*x*z + (1.0*b + 2.0... | Treat a literal variable as a constant with Ryacas (or an alternative) | r|symbolic-math|yacas | 2 | 41 | 2 | 72,331,962 | 72,331,962 | 2 | true | 2022-05-21T11:18:28.577Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Treat a literal variable as a constant with Ryacas (or an alternative)<p>With <strong>Ryacas</strong>, one has:</p>
<pre><code>> yac_str("Simplify(2*... |
72,354,486 | making a variables in loop where every instance is different<p>I am working on a poject for school where I need to make a hashMap.
I create a new HashEntry for every new Key. However I found out that they are all the same instance in memory, so I get a hashMap full of the same value. Does Someone know how to create a n... | <p>I think that the easiest way to sort this problem out is to allocate it dynamically.</p>
<pre><code> struct HashEntry *hashEntry = malloc(sizeof(*hashEntry));
if(hashEntry)
{
*hashEntry = newHashEntry(NULL, tempValue, tempKey);
putHashMap(hashMap, length, hashEntry); //... | making a variables in loop where every instance is different | c | 0 | 41 | 1 | 72,354,599 | 72,354,599 | 2 | true | 2022-05-23T20:27:28.153Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
making a variables in loop where every instance is different<p>I am working on a poject for school where I need to make a hashMap.
I create a new HashEntry f... |
72,373,689 | Multilabel classification using ResNet - loading sample using the dataloader takes a long time<p>I need to implement a ResNet-based multiclass classifier, and I am using <a href="https://jovian.ai/droste-benedikt/02-article-pytorch-multilabel-classification-v2" rel="nofollow noreferrer">this notebook</a> as a starting ... | <p>It seems there is no error at calling train/val set and loader of provided code. There might be an error inside of <code>CarDataset()</code> class, or maybe setting <code>num_workers=0</code> could help.</p>
<p>Also, please avoid acquiring a sample via <code>next(iter(train_loader))</code>. This creates a new loader... | Multilabel classification using ResNet - loading sample using the dataloader takes a long time | pytorch|multilabel-classification|multiclass-classification | 0 | 41 | 1 | 72,374,375 | 72,374,375 | 2 | true | 2022-05-25T07:42:01.997Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Multilabel classification using ResNet - loading sample using the dataloader takes a long time<p>I need to implement a ResNet-based multiclass classifier, an... |
72,300,587 | How to pass a variable as an object instance in Django function<p>I have a function</p>
<pre><code>def update_field():
...
...
book.country = country_id
...
</code></pre>
<p>I have the same piece of code in several places and I need to make a separate function for it. For example</p>
<pre><code>def upda... | <p>setattr would do the job</p>
<pre><code>def update_field(obj, field_name):
...
...
setattr(obj, field_name, country_id)
...
</code></pre>
<p>If you would want to edit related model field you should do:</p>
<pre><code>def update_field(obj, field_name):
...
...
related_model_name, related_m... | How to pass a variable as an object instance in Django function | python|django|function | 1 | 41 | 1 | 72,300,630 | 72,300,630 | 2 | true | 2022-05-19T07:46:24.693Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
How to pass a variable as an object instance in Django function<p>I have a function</p>
<pre><code>def update_field():
...
...
book.country = cou... |
72,368,482 | free linked list that is inside a struct<p>I have an <code>ordinateur</code> of type <code>ordi</code></p>
<pre class="lang-c prettyprint-override"><code>typedef struct ordi
{
int numeroOrdi;
char *nomOrdi;
int CapaciteDisque;
lst_logi LogicielsInstalles;
} ordi;
</code></pre>
<p>this <code>ordinateur</... | <p>In the <code>struct ordi</code>, <code>LogicielsInstalles</code> should be a pointer, not a structure to account for computers with no installed software, and avoid an invalid <code>free</code> on <code>&ordinateur->LogicielsInstalles</code>.</p>
<p>Furthermore, your function <code>FormaterOrdinateur</code> d... | free linked list that is inside a struct | c|malloc|free | 1 | 41 | 1 | 72,368,716 | 72,368,716 | 2 | true | 2022-05-24T19:29:03.187Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
free linked list that is inside a struct<p>I have an <code>ordinateur</code> of type <code>ordi</code></p>
<pre class="lang-c prettyprint-override"><code>typ... |
72,363,622 | Combining two dataframes of dates and values<p>I have two dataframes loaded from a .csv file. One contains numeric values, the other dates (month-year) for when these numeric values occured. The dates and values are basically mapped to each other. I would like to combine/merge these dataframes to have the dates as the ... | <p>You can <a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.DataFrame.stack.html" rel="nofollow noreferrer"><code>stack</code></a>, <a href="http://pandas.pydata.org/pandas-docs/stable/reference/api/pandas.concat.html" rel="nofollow noreferrer"><code>concat</code></a> and <a href="http://pandas... | Combining two dataframes of dates and values | python|pandas | 1 | 41 | 2 | 72,363,678 | 72,363,678 | 2 | true | 2022-05-24T13:19:03.983Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Combining two dataframes of dates and values<p>I have two dataframes loaded from a .csv file. One contains numeric values, the other dates (month-year) for w... |
72,267,845 | Data in int* argument of function not returned caller<p>Compiled with g++ on WSL2, sample output of</p>
<pre><code>#include <stdlib.h>
#include <stdio.h>
#include <vector>
using std::vector;
vector <int> powers_2(const int npow) {
vector <int> v;
int j = 2;
for (int i=0; i<... | <p>There is a difference between passing function arguments <a href="https://www.tutorialspoint.com/cplusplus/cpp_function_call_by_value.htm" rel="nofollow noreferrer">by value</a>, <a href="https://www.tutorialspoint.com/cplusplus/cpp_function_call_by_pointer.htm" rel="nofollow noreferrer">by pointer</a> and <a href="... | Data in int* argument of function not returned caller | c++|pointers | 0 | 41 | 1 | 72,267,947 | 72,267,947 | 2 | true | 2022-05-17T03:22:36.697Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Data in int* argument of function not returned caller<p>Compiled with g++ on WSL2, sample output of</p>
<pre><code>#include <stdlib.h>
#include <std... |
72,255,930 | Unable to remove active box shadow after clicking outside of Angular component<p>I'm working on this blog which has a page which lists all the posts. So I added custom hover and active styles to each of the posts so when hovered it will show a different color and box-shadow intensity based on each post post.</p>
<p>Sup... | <p>Try to put a tabindex atribute to the div</p>
<pre><code><div
tabindex="0"
class="post"
[ngStyle]="hoverPostId === post.id || clickedPostId === post.id ? hoverActiveStyle(post.color) : defaultStyle(post.color)"
(mouseenter)="mouseEnter(post.id)"
(mouseleave)=&qu... | Unable to remove active box shadow after clicking outside of Angular component | javascript|angular | 2 | 41 | 1 | 72,256,085 | 72,256,085 | 2 | true | 2022-05-16T08:04:02.283Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Unable to remove active box shadow after clicking outside of Angular component<p>I'm working on this blog which has a page which lists all the posts. So I ad... |
72,253,915 | Array member becomes the same after push in my Ruby code<p>In my Ruby code, a long hex string is parsed and pushed into a data array (<code>avl_data_array.push(avl_data)</code>). After pushing, when I use <code>puts</code> to display the array, all the elements are the same...</p>
<p>The code is:</p>
<pre><code>data_he... | <blockquote>
<p>Why this happens?</p>
</blockquote>
<p>You never change <code>avl_data</code>. It is always the same object. Hence, you push the same object to the <code>Array</code> in <code>avl_data_array</code> over and over again.</p>
<p>Here is a reduced version of your code demonstrating the problem more clearly:... | Array member becomes the same after push in my Ruby code | ruby | 0 | 41 | 1 | 72,254,218 | 72,254,218 | 3 | true | 2022-05-16T03:33:08.897Z | Please answer the following Stackoverflow question on Programming. Answer it like you are a developer answering Stackoverflow questions.
Stackoverflow question:
Array member becomes the same after push in my Ruby code<p>In my Ruby code, a long hex string is parsed and pushed into a data array (<code>avl_data_array.pu... |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.