qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,226,765 | <p>I am trying to use a polynomial expression that would fit my function (signal). I am using <code>numpy.polynomial.polynomial.Polynomial.fit</code> function to fit my function(signal) using the coefficients. Now, after generating the coefficients, I want to put those coefficients back into the polynomial equation - get the corresponding y-values - and plot them on the graph. But I am not getting what I want (orange line) . What am I doing wrong here?
<a href="https://i.stack.imgur.com/7qMd2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7qMd2.png" alt="enter image description here" /></a></p>
<p>Thanks.</p>
<pre><code>import math
def getYValueFromCoeff(f,coeff_list): # low to high order
y_plot_values=[]
for j in range(len(f)):
item_list= []
for i in range(len(coeff_list)):
item= (coeff_list[i])*((f[j])**i)
item_list.append(item)
y_plot_values.append(sum(item_list))
print(len(y_plot_values))
return y_plot_values
from numpy.polynomial import Polynomial as poly
import numpy as np
import matplotlib.pyplot as plt
no_of_coef= 10
#original signal
x = np.linspace(0, 0.01, 10)
period = 0.01
y = np.sin(np.pi * x / period)
#poly fit
test1= poly.fit(x,y,no_of_coef)
coeffs= test1.coef
#print(test1.coef)
coef_y= getYValueFromCoeff(x, test1.coef)
#print(coef_y)
plt.plot(x,y)
plt.plot(x, coef_y)
</code></pre>
| [
{
"answer_id": 74227711,
"author": "Emile Zankoul",
"author_id": 13755144,
"author_profile": "https://Stackoverflow.com/users/13755144",
"pm_score": 1,
"selected": false,
"text": "agent.doctor"
},
{
"answer_id": 74227901,
"author": "Yossi Benagou",
"author_id": 18366972,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74226765",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20005047/"
] |
74,226,792 | <p><a href="https://i.stack.imgur.com/3Bs7R.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3Bs7R.png" alt="enter image description here" /></a></p>
<p>In the JSON -photo, I have highlighted the part I need to access in my code and display it in my app.</p>
<p>I tried using JSONArray array = response.getJSONArray("weather[0]"), but that led me literally no where haha</p>
<p>So far i have nothing on the matter. Also here is my code.</p>
<pre><code>public void getWeather(View view) {
String apiKey="40bb658a709ebb7b1c210655e7f5cfe6";
String city=et.getText().toString();
String url="https://api.openweathermap.org/data/2.5/weather?q="+city+"&appid=40bb658a709ebb7b1c210655e7f5cfe6&units=metric";
RequestQueue queue= Volley.newRequestQueue(getApplicationContext());
JsonObjectRequest request=new JsonObjectRequest(Request.Method.GET, url, null, new Response.Listener<JSONObject>() {
@Override
public void onResponse(JSONObject response) {
try {
JSONObject object = response.getJSONObject("sys");
String country = object.getString("country");
tvcountry.setText(country);
JSONObject object1= response.getJSONObject("main");
String temperature=object1.getString("temp");
tvTemp.setText("Current: " + temperature + " C");
JSONObject object2 = response.getJSONObject("main");
String feelsLike = object2.getString("feels_like");
tvFeels_Like.setText("Feels like: " + feelsLike + " C");
JSONObject object3 = response.getJSONObject("main");
String maxtemp = object3.getString("temp_max");
tvMaxTemp.setText("Max: " + maxtemp + " C");
JSONObject object4 = response.getJSONObject("main");
String mintemp = object4.getString("temp_min");
tvMinTemp.setText("Min: " + mintemp + " C");
JSO
} catch (JSONException e) {
Toast.makeText(getApplicationContext(),e.getMessage(), Toast.LENGTH_LONG).show();
}
}
}, new Response.ErrorListener() {
@Override
public void onErrorResponse(VolleyError error) {
Toast.makeText(SecondPage.this, error.toString(), Toast.LENGTH_SHORT).show();
}
});
queue.add(request);
}
</code></pre>
<p>Thank you in advance</p>
| [
{
"answer_id": 74227711,
"author": "Emile Zankoul",
"author_id": 13755144,
"author_profile": "https://Stackoverflow.com/users/13755144",
"pm_score": 1,
"selected": false,
"text": "agent.doctor"
},
{
"answer_id": 74227901,
"author": "Yossi Benagou",
"author_id": 18366972,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74226792",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20351877/"
] |
74,226,819 | <p>I'm having a problem with the scroll on my site and I can't understand what's the cause.
Only on Chrome sometimes the scroll doesn't work. I've tried to disable every code I wrote and still there's the problem.
On safari the scroll works fine.</p>
<p><a href="https://mirkomina.com/" rel="nofollow noreferrer">https://mirkomina.com/</a></p>
<p>It doesn't seem that something specific is triggering the problem, I mean I can't find a specific spot where leaving the cursor triggers the problem.</p>
<p>I've tried to delete all the code I wrote and disable scripts.</p>
| [
{
"answer_id": 74227711,
"author": "Emile Zankoul",
"author_id": 13755144,
"author_profile": "https://Stackoverflow.com/users/13755144",
"pm_score": 1,
"selected": false,
"text": "agent.doctor"
},
{
"answer_id": 74227901,
"author": "Yossi Benagou",
"author_id": 18366972,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74226819",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20267578/"
] |
74,226,881 | <p>I want to merge these two tables into one. The idea is to create a table by month and show: month, number of unique customers who bought, number of invoices, number of products, total income, total income from product A</p>
<p>I'm having trouble adding the total income from product A per month since the table has two rows while the other results have four.</p>
<p>Example of table:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>CustomerID</th>
<th>InvoiceID</th>
<th>ProductId</th>
<th>Date</th>
<th>Income</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>101</td>
<td>A</td>
<td>1/11/2016</td>
<td>600</td>
</tr>
<tr>
<td>2</td>
<td>103</td>
<td>B</td>
<td>12/10/2015</td>
<td>300</td>
</tr>
</tbody>
</table>
</div>
<p>My query so far:</p>
<pre><code>SELECT
MONTH(date) AS month,
COUNT (DISTINCT customerId) AS numOfCustomers,
SUM(income) AS sumOfIncome,
COUNT(invoiceId) AS numOfInvoice,
COUNT(productId) AS numOfProduct
FROM
x
WHERE
YEAR(date) = 2016
GROUP BY
MONTH(date)
SELECT
MONTH(date) AS month,
SUM(income) AS sumOfIncomeA
FROM
x
WHERE
(productId) = 'A'
AND YEAR(date) = 2016
GROUP BY
MONTH(date)
</code></pre>
| [
{
"answer_id": 74227257,
"author": "nbk",
"author_id": 5193536,
"author_profile": "https://Stackoverflow.com/users/5193536",
"pm_score": 0,
"selected": false,
"text": "FULL OUTER JOIN"
},
{
"answer_id": 74227890,
"author": "Tim Jarosz",
"author_id": 2452207,
"author_p... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74226881",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13572976/"
] |
74,226,890 | <p>I try reduce space between circles shape in a legend. How i do that?
I want to leave the circles almost 'glued'.</p>
<p>For example:</p>
<pre><code>pd = ggplot(iris, aes(Sepal.Length,
Sepal.Width))
head(iris$Species)
scale_pd = pd + geom_point(aes(fill = Species), pch = 21,
alpha = 0.6,
size = 4)+
labs(title="Iris dispersion",
subtitle="Sepal length x Sepal Width per species",
caption="",
x="Sepal Width (cm)",
y = "Sepal length (cm)") +
theme_classic() +
scale_fill_manual(name="Specie",
labels=c("Setosa","Versicolor","Virginica"),
values=c("#023047","#ffb703","#ef476f"))
</code></pre>
<p>I tried used</p>
<pre><code>guide_legend(override.aes = list(shape = c(22, 22, 22),
size = 10), keyheight = .1)
</code></pre>
<p>but does't work</p>
| [
{
"answer_id": 74226962,
"author": "TarJae",
"author_id": 13321647,
"author_profile": "https://Stackoverflow.com/users/13321647",
"pm_score": 1,
"selected": false,
"text": "guide_legend()"
},
{
"answer_id": 74226991,
"author": "Allan Cameron",
"author_id": 12500315,
"... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74226890",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19874904/"
] |
74,226,902 | <p>My code keeps printing out the same numbers even thou i answer the question correctly.
This is supposed to be a math game were the code randomizes operations of 2 numbers that the user has to guess</p>
<pre><code>import random
print("Enter A for addition:")
print("Enter B for subtraction:")
print("Enter C for multiplication:")
print("Enter D for division:")
print("Enter E for exit:")
options=str(input("Hello,Please enter an option:"))
num1 = random.randrange(1, 21)
num2 = random.randrange(1, 21)
if options== 'E':
print("Enter E(In caplocks to quit):")
exit()
while options== 'A':
real1=num1+num2
print("What is",num1,"+",num2,":")
answer_question=int(input("Hello,Please enter an the answer to the question:"))
if answer_question == (real1):
print("You are correct!")
else:
print("You are incorrect!!!!")
</code></pre>
| [
{
"answer_id": 74226972,
"author": "BobaJFET",
"author_id": 13189532,
"author_profile": "https://Stackoverflow.com/users/13189532",
"pm_score": 1,
"selected": false,
"text": "import random\n\nprint(\"Enter A for addition:\")\nprint(\"Enter B for subtraction:\")\nprint(\"Enter C for multi... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74226902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20352046/"
] |
74,226,968 | <p>I am working on a program using threads to treat demands of remote clients in C++. The server will <strong>wait for clients</strong> to connect, and launch a thread doing some things.<br/>
For the server to shut down, the user must do an external interrupt <kbd>Crtl</kbd>+<kbd>C</kbd>, and the code will handle the signal (using <a href="https://en.cppreference.com/w/cpp/header/csignal" rel="nofollow noreferrer"><csignal></a>) in order to shut everything properly.<br/><br/></p>
<p>The waiting itself is made with a <code>while</code> loop, the server waits for a connection, and launches the thread. It's during this loop that I want to handle the signal. Here it is:</p>
<pre><code>std::signal(SIGINT, interruptHandler);
while(intStatus != 2){
ClientSocket client;
client.csock = accept(sock,reinterpret_cast<SOCKADDR*>(&(client.csin)),&(client.crecsize));
tArray.push_back(new pthread_t);
pthread_create(tArray.back(), NULL, session, &client);
}
std::cout<<"Waiting for Clients to exit..."<<std::endl;
for(pthread_t* thread : tArray)
pthread_join(*thread,NULL);
</code></pre>
<ul>
<li><code>std::sig_atomic_t intStatus</code> is a global variable edited by <code>interruptHandler</code> when it's called.<br/></li>
<li><code>ClientSocket</code> is a <code>struct</code> containing informations about the client:
<ul>
<li><code>csoc</code> the socket of the client</li>
<li><code>csin</code> the adress of the socket</li>
<li><code>crecsize</code> gives the size of the data to send (I think)</li>
</ul>
</li>
<li>I am using <a href="https://learn.microsoft.com/en-us/windows/win32/api/winsock2/" rel="nofollow noreferrer"><winsock2.h></a> to connect between server and clients. <code>sock</code> is the socket of the server.<br/></li>
<li>I am using <a href="https://pubs.opengroup.org/onlinepubs/7908799/xsh/pthread.h.html" rel="nofollow noreferrer"><pthread.h></a> to manage threads. They are stored in <code>std::list<pthread_t*> tArray</code>.<br/><br/></li>
</ul>
<p>The problem is : because <code>accept()</code> pauses the process, and of course the loop must end to see if <kbd>Crtl</kbd>+<kbd>C</kbd> has been sent, the server can only shut down when an additional client connects. <br/><br/></p>
<p>Is there a way for <code>interruptHandler()</code> to break the <code>while</code> and let the program go ahead with the <code>for</code> loop and next? Should I change the algorithm? On a last resort I know we can set up tags in Assembly for the program to jump to. Is there a way to do this in C++ too?<br/><br/></p>
<p>By the way, I am using <pthread.h> and <winsock2.h> because I have too (it's a student project). Thanks for helping.</p>
| [
{
"answer_id": 74227083,
"author": "Blindy",
"author_id": 108796,
"author_profile": "https://Stackoverflow.com/users/108796",
"pm_score": 1,
"selected": false,
"text": "accept"
},
{
"answer_id": 74236802,
"author": "julian_mzt",
"author_id": 19169319,
"author_profile"... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74226968",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19169319/"
] |
74,226,969 | <p>One specific example is I see multiple versions of jQuery on my website. How do I know what's pulling in jQuery? I don't see it in my source code, so it must be another integration that's pulling it in.</p>
<p>It's not just jQuery though. I'd also like to track down where additional scripts are coming from.</p>
<p>I looked in web inspector and see multiple iterations of jQuery being loaded. I then searched the source code of my site for "jquery" in an attempt to find the source with no results.</p>
| [
{
"answer_id": 74227083,
"author": "Blindy",
"author_id": 108796,
"author_profile": "https://Stackoverflow.com/users/108796",
"pm_score": 1,
"selected": false,
"text": "accept"
},
{
"answer_id": 74236802,
"author": "julian_mzt",
"author_id": 19169319,
"author_profile"... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74226969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6191843/"
] |
74,226,988 | <p>In Rails models we usually have attributes and relations tests, like:</p>
<pre class="lang-rb prettyprint-override"><code>describe 'attributes' do
it { is_expected.to have_db_column(:identifier).of_type(:uuid) }
it { is_expected.to have_db_column(:content).of_type(:jsonb) }
it { is_expected.to have_db_column(:created_at).of_type(:datetime) }
end
describe 'relations' do
it { is_expected.to belong_to(:user).class_name('User') }
end
</code></pre>
<p>And using a TDD style it seems to be some useful tests, however I have been dwelling if these are really necessary tests, and I would like to know if there is some common knowledge about it, is it good practice to create these tests? or are we just testing rails?</p>
| [
{
"answer_id": 74227338,
"author": "BenFenner",
"author_id": 14837782,
"author_profile": "https://Stackoverflow.com/users/14837782",
"pm_score": 1,
"selected": false,
"text": "test/models/car_test.rb"
},
{
"answer_id": 74227860,
"author": "Schwern",
"author_id": 14660,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74226988",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7219974/"
] |
74,226,990 | <p>I have the following domain classes <code>Trip</code> and <code>Employee</code>:</p>
<pre><code>@Data
@NoArgsConstructor
@AllArgsConstructor
public class Trip {
private Date startTime;
private Date endTime;
List<Employee> empList;
}
</code></pre>
<pre><code>@Data
@NoArgsConstructor
@AllArgsConstructor
public class Employee {
private String name;
private String empId;
}
</code></pre>
<p>I have a list of <code>Trip</code> instances. And I want to create a map of type <code>Map<String,List<Trip>></code> associating <em>id</em> of each <em>employee</em> <code>empId</code> with a list of <em>trips</em> using Stream API.</p>
<p><em>Here's my attempt:</em></p>
<pre><code>public static void main(String[] args) {
List<Trip> trips = new ArrayList<>();
Map<Stream<String>, List<Trip>> x = trips.stream()
.collect(Collectors.groupingBy(t -> t.getEmpList()
.stream().map(Employee::getEmpId)
));
}
</code></pre>
<p>How can I generate the map of the required type?</p>
<p>When the type of map is <code>Map<String,List<Trip>></code> it gives me a compilation error:</p>
<pre><code>Unresolved compilation problem: Type mismatch:
cannot convert from Map<Object,List<Trip>> to Map<String,List<Trip>>
</code></pre>
| [
{
"answer_id": 74227463,
"author": "Alexander Ivanchenko",
"author_id": 17949945,
"author_profile": "https://Stackoverflow.com/users/17949945",
"pm_score": 2,
"selected": false,
"text": "Trip"
},
{
"answer_id": 74227727,
"author": "Vivek",
"author_id": 2065799,
"autho... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74226990",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14935397/"
] |
74,227,007 | <p>I need to create a program that takes user input n and the finds the first n numbers that aren't divisible by any other prime numbers except 2, 3, and 5. This is what I've got so far:</p>
<pre><code>def is_divisible(i):
for k in range(7, i):
if is_prime(k) == 1 and i % k == 0:
return 1
else:
return 0
def is_prime(k):
for j in range(2, k):
if k % j == 0:
return 0
else:
return 1
while True:
while True:
while True:
try:
n = input("How many numbers do you want to find: ")
n = n.replace(" ", "")
n = int(n)
break
except:
print("Input only natural numbers")
continue
if n == 0:
print("Input only natural numbers")
continue
else:
break
count = 0
i = 0
while count < n:
if i % 2 == 0 and i % 3 == 0 and i % 5 == 0 and is_divisible(i) == 0:
print(i)
count += 1
i += 1
else:
i += 1
repeat = input("To repeat press (1), to end press anything else: ")
if str(repeat) == "1":
continue
else:
print("Bye!")
break
</code></pre>
<p>If asked to find 10 numbers the program outputs:</p>
<pre><code>30
60
90
120
150
180
240
270
300
330
</code></pre>
<p>The program didn't print 210 (which is divisible by 7) so the algorithm seems, at least, partly correct, but 330 is printed (which is divisible by 11) and I can't figure out why. If I manually change i to 330 and k to 11, the is_prime function correctly finds that 11 is a prime number, but the is_divisible function still returns 0. I can't figure out what's wrong. Any help will be greatly appreciated!</p>
<p>Thanks!</p>
| [
{
"answer_id": 74227196,
"author": "Ben Borchard",
"author_id": 4054720,
"author_profile": "https://Stackoverflow.com/users/4054720",
"pm_score": 0,
"selected": false,
"text": "is_divisible"
},
{
"answer_id": 74227364,
"author": "Mark",
"author_id": 2203038,
"author_p... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227007",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20351918/"
] |
74,227,011 | <p>Can I write a method which is an extension of a base class, but with a different return type, if it's supported by the shared interface, without inserting type declaration in class 'a'?</p>
<p>In practice classes a & b are in javascript files, and they're failing lint-ts-typing checks.</p>
<p>typescript definition file</p>
<pre><code>interface x {
abc(): string | number;
}
</code></pre>
<p>javascript file</p>
<pre><code>
class a implements x {
abc() {
return 234;
}
}
class b extends a implements x {
abc() {
return '123';
}
}
</code></pre>
<p>throws the following: <code>Property 'abc' in type 'b' is not assignable to the same property in base type 'a'. Type '() => string' is not assignable to type '() => number'. Type 'string' is not assignable to type 'number'.</code></p>
<p><a href="https://www.typescriptlang.org/play?#code/FASwdgLgpgTgZgQwMZQAQA9UG9ir6hAIyQAoBKALlQGcIZwBzVAH1TAFcBbQ2AbmAC%20wYEgA2CatQKoQnAA6ionKJCmYc%20AsXLZcm-DCgR2MMKgBMAZgAs-TUKEjxk1IVRR00MABMpCXZpEpGQB%20niGxqaoAOQAjFbRdvgOQA" rel="nofollow noreferrer">playground link</a></p>
| [
{
"answer_id": 74227196,
"author": "Ben Borchard",
"author_id": 4054720,
"author_profile": "https://Stackoverflow.com/users/4054720",
"pm_score": 0,
"selected": false,
"text": "is_divisible"
},
{
"answer_id": 74227364,
"author": "Mark",
"author_id": 2203038,
"author_p... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227011",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1152266/"
] |
74,227,022 | <p>I have this search method that gives me some headache</p>
<pre><code>var query = await dbContext.Tasks; // Gets the error here!
</code></pre>
<p>How can I fix this?</p>
<p>Here is my code:</p>
<pre><code> public static async Task<IEnumerable<BKR.BOL.Task>> Search(string Name, string Description)
{
MyDbContext dbContext = new BKR.DAL.Context.MyDbContext();
var query = await dbContext.Tasks; // Gets the error here!
if (!string.IsNullOrEmpty(Name))
{
query = query.Where(x => x.Name == Name).ToList();
}
if (!string.IsNullOrEmpty(Description))
{
query = query.Where(x => x.Description == Description).ToList();
}
return MapToBOL(query, dbContext);
}
</code></pre>
<pre><code>public static List<BKR.BOL.Task> MapToBOL(IList<DAL.Task> data, MyDbContext db)
{
var query = from d in data
select new Task(d, db)
{
TaskId = d.TaskId,
TaskTypeId = d.TaskTypeId,
TaskStatusId = d.TaskStatusId,
CustomerId = d.CustomerId,
ResourceId = d.ResourceId,
Deleted = d.Deleted,
Name = d.Name,
Description = d.Description,
StartTime = d.StartTime,
EndTime = d.EndTime,
CreatedBy = d.CreatedBy,
CreationTime = d.CreationTime,
ChangedBy = d.ChangedBy,
ChangedTime = d.ChangedTime
};
return query.ToList();
}
</code></pre>
| [
{
"answer_id": 74227196,
"author": "Ben Borchard",
"author_id": 4054720,
"author_profile": "https://Stackoverflow.com/users/4054720",
"pm_score": 0,
"selected": false,
"text": "is_divisible"
},
{
"answer_id": 74227364,
"author": "Mark",
"author_id": 2203038,
"author_p... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227022",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6848045/"
] |
74,227,057 | <p>How can I explode multiple array columns with variable lengths and potential nulls?</p>
<p>My input data looks like this:</p>
<pre><code>+----+------------+--------------+--------------------+
|col1| col2| col3| col4|
+----+------------+--------------+--------------------+
| 1|[id_1, id_2]| [tim, steve]| [apple, pear]|
| 2|[id_3, id_4]| [jenny]| [avocado]|
| 3| null|[tommy, megan]| [apple, strawberry]|
| 4| null| null|[banana, strawberry]|
+----+------------+--------------+--------------------+
</code></pre>
<p>I need to explode this such that:</p>
<ol>
<li>Array items with the same index are mapped to the same row</li>
<li>If there is only 1 entry in a column, it applies to every exploded row</li>
<li>If an array is null, it applies to every row</li>
</ol>
<p>My output should look like this:</p>
<pre><code>+----+----+-----+----------+
|col1|col2|col3 |col4 |
+----+----+-----+----------+
|1 |id_1|tim |apple |
|1 |id_2|steve|pear |
|2 |id_3|jenny|avocado |
|2 |id_4|jenny|avocado |
|3 |null|tommy|apple |
|3 |null|megan|strawberry|
|4 |null|null |banana |
|4 |null|null |strawberry|
+----+----+-----+----------+
</code></pre>
<p>I have been able to achieve this using the following code, but I feel like there must be a more straightforward approach:</p>
<pre><code>df = spark.createDataFrame(
[
(1, ["id_1", "id_2"], ["tim", "steve"], ["apple", "pear"]),
(2, ["id_3", "id_4"], ["jenny"], ["avocado"]),
(3, None, ["tommy", "megan"], ["apple", "strawberry"]),
(4, None, None, ["banana", "strawberry"])
],
["col1", "col2", "col3", "col4"]
)
df.createOrReplaceTempView("my_table")
spark.sql("""
with cte as (
SELECT
col1,
col2,
col3,
col4,
greatest(size(col2), size(col3), size(col4)) as max_array_len
FROM my_table
), arrays_extended as (
select
col1,
case
when col2 is null then array_repeat(null, max_array_len)
else col2
end as col2,
case
when size(col3) = 1 then array_repeat(col3[0], max_array_len)
when col3 is null then array_repeat(null, max_array_len)
else col3
end as col3,
case
when size(col4) = 1 then array_repeat(col4[0], max_array_len)
when col4 is null then array_repeat(null, max_array_len)
else col4
end as col4
from cte),
arrays_zipped as (
select *, explode(arrays_zip(col2, col3, col4)) as zipped
from arrays_extended
)
select
col1,
zipped.col2,
zipped.col3,
zipped.col4
from arrays_zipped
""").show(truncate=False)
</code></pre>
| [
{
"answer_id": 74228475,
"author": "Vaebhav",
"author_id": 9108912,
"author_profile": "https://Stackoverflow.com/users/9108912",
"pm_score": 1,
"selected": false,
"text": "selectExpr"
},
{
"answer_id": 74229055,
"author": "PieCot",
"author_id": 5359797,
"author_profil... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11137562/"
] |
74,227,075 | <p>I have a Student model and a Teacher model and I have created a custom user form that takes in an email field and whether the user is a student or a teacher. I would like to make it so that if the user selects that they are a teacher in the sign-up form, their new account details are stored in the Teacher model. If they don't, then their details are stored in the Student model. Is this possible to do directly or do I have to store the data initially in the User model and then transfer it to the Student and Teacher models?</p>
<p>This is my code (I wasn't expecting it to work but I just tried it anyways and it didn't):</p>
<pre><code>class CustomSignUpForm(UserCreationForm):
email = forms.EmailField()
is_teacher = forms.BooleanField(label='I am a teacher')
class Meta:
if is_teacher == True:
model = Teacher
else:
model = Student
fields = ['username', 'email', 'password1', 'password2', 'is_teacher']
</code></pre>
| [
{
"answer_id": 74227565,
"author": "Nealium",
"author_id": 10229768,
"author_profile": "https://Stackoverflow.com/users/10229768",
"pm_score": 2,
"selected": true,
"text": "save()"
},
{
"answer_id": 74228862,
"author": "Swift",
"author_id": 8874154,
"author_profile": ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227075",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20352073/"
] |
74,227,093 | <p>After upload, this code gets the error on ip2proxy not found on the server. I have already installed ip2proxy extension.</p>
<pre><code>use Illuminate\Http\Request;
use Illuminate\Routing\Controller as BaseController;
use IP2ProxyLaravel;
class Controller extends BaseController
{
public function lookup(Request $request)
{
$get_ip = "89.39.104.204";
$records = IP2ProxyLaravel::get($get_ip, 'bin');
if ($records['isProxy']) {
return view('proxy');
} else {
return view('non-proxy');
}
}
}
</code></pre>
| [
{
"answer_id": 74227565,
"author": "Nealium",
"author_id": 10229768,
"author_profile": "https://Stackoverflow.com/users/10229768",
"pm_score": 2,
"selected": true,
"text": "save()"
},
{
"answer_id": 74228862,
"author": "Swift",
"author_id": 8874154,
"author_profile": ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227093",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16661390/"
] |
74,227,099 | <p>I'm making something to prank my friend when he finishes a game I'm making his computer will shut off. But I don't know where to start.</p>
| [
{
"answer_id": 74227565,
"author": "Nealium",
"author_id": 10229768,
"author_profile": "https://Stackoverflow.com/users/10229768",
"pm_score": 2,
"selected": true,
"text": "save()"
},
{
"answer_id": 74228862,
"author": "Swift",
"author_id": 8874154,
"author_profile": ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17473661/"
] |
74,227,106 | <p>In a SPO Modern List, in <strong>"Edit in Grid View"</strong> Mode, I need to <strong>disable one column</strong> from being edited using JSON.</p>
<p>Are you able to help me craft the JSON or point me to the specific element to modify?</p>
<p>Thank you!</p>
<p>Charlie</p>
| [
{
"answer_id": 74227565,
"author": "Nealium",
"author_id": 10229768,
"author_profile": "https://Stackoverflow.com/users/10229768",
"pm_score": 2,
"selected": true,
"text": "save()"
},
{
"answer_id": 74228862,
"author": "Swift",
"author_id": 8874154,
"author_profile": ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10011128/"
] |
74,227,114 | <p>I have a powershell script I run in our CI/CD pipeline that checks some information through a Invoke-WebRequest call to a service. I receive a JSON back from that service and it parses information from that json.</p>
<p>This is a pseudo representation of that call</p>
<pre><code>$response = Invoke-WebRequest -Uri $uri -Headers @{ Authorization = "Basic "+
[System.Convert]::ToBase64String([System.Text.Encoding]::ASCII.GetBytes(":$accessToken")) } -
UseBasicParsing
$items= $response | Select-Object -Property Content | Format-Table -HideTableHeaders -
Wrap | Out-String | ConvertFrom-Json
$items= $items.value
</code></pre>
<p>Then later I use a foreach to loop through $items and grab a column for each one. When I run this locally everything happens as expected. When I run this through a pipeline though the column I'm looping through in $items has a random new line in the middle of one of the items causing an error in my script.</p>
<p>Here is my pipeline yaml call to this script</p>
<pre><code>- job: validation
condition: and(succeeded(), eq({conditional that is expected to pass}))
steps:
- powershell: .\script.ps1
displayName: Validation script
env:
SYSTEM_ACCESSTOKEN: $(System.AccessToken)
</code></pre>
| [
{
"answer_id": 74227565,
"author": "Nealium",
"author_id": 10229768,
"author_profile": "https://Stackoverflow.com/users/10229768",
"pm_score": 2,
"selected": true,
"text": "save()"
},
{
"answer_id": 74228862,
"author": "Swift",
"author_id": 8874154,
"author_profile": ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10783460/"
] |
74,227,118 | <p>I have a LazyColumn connected to a Room database query. I'm expanding on the "Room With a View" sample (<a href="https://developer.android.com/codelabs/android-room-with-a-view-kotlin#0" rel="nofollow noreferrer">https://developer.android.com/codelabs/android-room-with-a-view-kotlin#0</a>), but I'm using LazyColumn instead of a RecyclerView to display a list of table entries.</p>
<p>After inserting an entry (Word), I want the LazyColumn to scroll automatically to the row with the newly inserted entry (or at least make it visible). Note that the list query is sorted alphabetically, the new row will not appear at the end of the list.</p>
<pre><code>// table:
@Entity(tableName = "word_table")
class Word(
@PrimaryKey @ColumnInfo(name = "word") val text: String
)
// DAO:
@Query("SELECT * FROM word_table ORDER BY word COLLATE NOCASE ASC")
fun getAlphabetizedWords(): Flow<List<Word>>
@Insert(onConflict = OnConflictStrategy.IGNORE)
suspend fun insert(word: Word)
// repository:
val allWords: Flow<List<Word>> = wordDao.getAlphabetizedWords()
suspend fun insert(word: Word) {
wordDao.insert(word)
}
// viewModel:
val allWords: LiveData<List<Word>> = repository.allWords.asLiveData()
fun insert(word: Word) = viewModelScope.launch {
repository.insert(word)
}
// simplified composable:
@Composable
fun WordList() {
val list by mWordViewModel.allWords.observeAsState(listOf())
LazyColumn() {
items(list) { word ->
Row() {
Text(word.text)
}
}
}
}
</code></pre>
<p>Otherwise everything is working fine, the repository and view model are implemented following general guidelines. Any ideas?</p>
| [
{
"answer_id": 74227565,
"author": "Nealium",
"author_id": 10229768,
"author_profile": "https://Stackoverflow.com/users/10229768",
"pm_score": 2,
"selected": true,
"text": "save()"
},
{
"answer_id": 74228862,
"author": "Swift",
"author_id": 8874154,
"author_profile": ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227118",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1767034/"
] |
74,227,120 | <p>I have one NumberConstraint as follows:</p>
<pre><code>@Constraint(validatedBy = { StringConstraintValidator.class, })
@Documented
@Retention(RetentionPolicy.RUNTIME)
@Target({ ElementType.FIELD, ElementType.PARAMETER, })
public @interface StringConstraint {
String message() default "'${validatedValue}' ist not valid Number. " +
"A String is composed of 7 characters (digits and capital letters). Valid example: WBAVD13.";
Class<?>[] groups() default {};
Class<? extends Payload>[] payload() default {};
}
</code></pre>
<p>and it is validated by StringConstraintValidator as follows:</p>
<pre><code>@Component
public class StringConstraintValidator implements ConstraintValidator<StringConstraint, String> {
private static final String REGEX_String = "^[A-Z0-9]{7}$";
@Override
public void initialize(final StringConstraint annotation) {
// noop
}
@Override
public boolean isValid(final String value, final ConstraintValidatorContext context) {
return isValid(value);
}
public boolean isValid(final String value) {
// Number is not always null Checked via @NotNull
LoggingContext.get().setString(value);
if (value == null) {
return false;
}
return Pattern.compile(REGEX_STRING).matcher(value).matches();
}
}
</code></pre>
<p>I can apply this StringConstraint on single field of request object as follows:</p>
<pre><code>@StringConstraint
private String number;
</code></pre>
<p>but if my request object contains a List of Strings then how can I use this constraint on entire List or do I have to define new on List type ?? Something like <code>ConstraintValidator<StringConstraint, List ???></code></p>
<p>My request object is:</p>
<pre><code> @JsonProperty(value = "items", required = true)
@Schema(description = "List of items.", required = true)
private List<String> items= new ArrayList<>();
</code></pre>
<p>So i want to apply my validator on all the strings in the list. How can i apply <code>@StringConstraint</code> on my list ?</p>
| [
{
"answer_id": 74227269,
"author": "Ahmed Mohamed",
"author_id": 18074007,
"author_profile": "https://Stackoverflow.com/users/18074007",
"pm_score": 1,
"selected": false,
"text": "import javax.validation.Constraint;\nimport javax.validation.Payload;\nimport java.lang.annotation.*;\n\n@Do... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227120",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6329331/"
] |
74,227,159 | <p>I am trying to create a figure with ggplot and would like to add category names between colorbar breaks (values). I am using a graduated colorbar using the <code>scale_color_fermenter</code> function, which I think makes it a bit tricky to do this.</p>
<p>Below is an example code</p>
<pre><code>library('ggplot2')
ggplot(mtcars, aes(x=mpg, y=carb, color=disp)) +
geom_point(size=3)+
scale_color_fermenter(breaks = c(100,300,400), palette = "Blues") #graduate colorbar
</code></pre>
<p>The resulting figure looks like this</p>
<p><a href="https://i.stack.imgur.com/SrHCB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SrHCB.png" alt="enter image description here" /></a></p>
<p>I want to add categories (A, B, C, etc.) between the colorbar breaks (i.e., create categories for <code>disp</code>), such that</p>
<pre><code>0<=A<100
100<=B<300
300<=C<400
400<=D<500
</code></pre>
<p>The resulting figure looks like this (or similar)</p>
<p><a href="https://i.stack.imgur.com/uJbmc.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uJbmc.png" alt="enter image description here" /></a></p>
<p>I know I can add extra breaks and change the label. Something like the following</p>
<pre><code>scale_color_fermenter(breaks=c(50,100,200,300,350,400,450,500),
labels=c('A','100','B','300','C','400','D','500'))
</code></pre>
<p>But this would mess up the colorbar class (i.e., colorbar will have more colors), which is something I do not want.</p>
| [
{
"answer_id": 74227300,
"author": "zephryl",
"author_id": 17303805,
"author_profile": "https://Stackoverflow.com/users/17303805",
"pm_score": 2,
"selected": false,
"text": "library(ggplot2)\n\nggplot(mtcars, aes(x = mpg, y = carb, color = disp)) + \n geom_point(size = 3)+ \n scale_col... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227159",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4502415/"
] |
74,227,161 | <p>I would like to be able to obtain a (non-convergent) sequence of numbers by a simple calculation that would look like this: <code>0, 1, -1, 2, -2, 3, -3, 4, -4 ...</code></p>
<p>By simple calculation I mean being able to do it with a single variable that would start from 1 (or 0) without having to rearrange this sequence.</p>
<p>I made several (unsuccessful) attempts in Lua, here is what it should look like in principle (this example only alternates 0s and 1s):</p>
<pre><code>do
local n = 0
for i = 1, 10 do print(n)
n = n==0 and 1 or -n + (n/n)
end
end
</code></pre>
<p>Is this possible and how?</p>
<p><strong>Update:</strong></p>
<p>I just succeeded like this:</p>
<pre><code>local n, j = 0, 2
for i = 1, 10 do print(n)
n = n==0 and 1 or j%2==0 and -(n+(n/math.abs(n))) or -n
j = j + 1
end
</code></pre>
<p>But I have to help myself with a second variable, I would have liked to know if with only <code>n</code> it would be possible to do it?</p>
| [
{
"answer_id": 74227318,
"author": "Lucas S.",
"author_id": 3124208,
"author_profile": "https://Stackoverflow.com/users/3124208",
"pm_score": 1,
"selected": false,
"text": "n"
},
{
"answer_id": 74231379,
"author": "LMD",
"author_id": 7185318,
"author_profile": "https:... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227161",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19700322/"
] |
74,227,167 | <p>I am familiar with the approach of calling a Haskell function from C as defined here:</p>
<p><a href="https://wiki.haskell.org/Calling_Haskell_from_C" rel="nofollow noreferrer">https://wiki.haskell.org/Calling_Haskell_from_C</a></p>
<p>However, instead of creating an executable, what I want to do is create a <code>.o</code> that will be later linked with other <code>.o</code> files. My scenario is something like this:</p>
<p><strong>Safe.hs</strong></p>
<pre><code>{-# LANGUAGE ForeignFunctionInterface #-}
module Safe where
import Foreign.C.Types
fibonacci :: Int -> Int
fibonacci n = fibs !! n
where fibs = 0 : 1 : zipWith (+) fibs (tail fibs)
fibonacci_hs :: CInt -> CInt
fibonacci_hs = fromIntegral . fibonacci . fromIntegral
foreign export ccall fibonacci_hs :: CInt -> CInt
</code></pre>
<p>But the C file is different, doesn't have a <code>main</code> function</p>
<p><strong>test.c</strong></p>
<pre><code>#include <HsFFI.h>
#ifdef __GLASGOW_HASKELL__
#include "Safe_stub.h"
#endif
int foo()
{
int i;
// some dummy values for argc and argv
hs_init(&argc, &argv);
i = fibonacci_hs(42);
hs_exit();
return i;
}
</code></pre>
<p>Now to link them together into a .o file I tried something like this:</p>
<pre><code>ghc -fPIE -c -O Safe.hs
</code></pre>
<p>emits a <code>Safe_stub.h</code>, <code>Safe.o</code> and <code>Safe.hi</code> files.</p>
<p>Next, I compile the <code>test.c</code> file into an object file</p>
<pre><code>ghc --make -fPIE -no-hs-main -optc-O -c test.c -o test.o
</code></pre>
<p>gives me the <code>test.o</code> object file that I am looking for.</p>
<p>Now, I attempt to link the two object files produced and I use ghc's linker (that internally uses gcc):</p>
<pre><code>ghc -no-hs-main -optc-nostartfiles -optc-static-pie test.o Safe.o -o result.o
</code></pre>
<p>Here is what I get</p>
<pre><code>/usr/lib/gcc/x86_64-linux-gnu/11/../../../x86_64-linux-gnu/crt1.o:function _start: error: undefined reference to 'main'
collect2: error: ld returned 1 exit status
`x86_64-linux-gnu-gcc' failed in phase `Linker'. (Exit code: 1)
</code></pre>
<p>So, it seems somewhere the object files have a reference to <code>main</code>. Is it a matter of passing some flags? Or what am I doing wrong? Thanks in advance!</p>
<p><strong>EDIT</strong></p>
<p>A suggestion was made to use plain <code>ld -r</code> to link the object files. The problem with that approach is that if vanilla <code>ld</code> is used, it will not link in the Haskell runtime needed to actually make the object file useful and callable by another C program as a library.</p>
<p>If it wasn't clear from my post, I want to create a .o file that can be used as a C library that calls into the Haskell code.</p>
| [
{
"answer_id": 74228019,
"author": "amalloy",
"author_id": 625403,
"author_profile": "https://Stackoverflow.com/users/625403",
"pm_score": 1,
"selected": false,
"text": "main"
},
{
"answer_id": 74238093,
"author": "Abhiroop Sarkar",
"author_id": 1942289,
"author_profi... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227167",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1942289/"
] |
74,227,168 | <p>I have some data looking like this:</p>
<pre><code>1. matrix
a b c d e
f 4 5 6 7 8
g 1 2 3 4 5
h 3 2 1 6 7
2. column/vector
v <- c(5,4,8,6,0)
</code></pre>
<p>How can I print all the rows that contain the data in vector?</p>
<p>I've seen there's a function called filter that could work, or maybe lapply / grep?</p>
| [
{
"answer_id": 74228019,
"author": "amalloy",
"author_id": 625403,
"author_profile": "https://Stackoverflow.com/users/625403",
"pm_score": 1,
"selected": false,
"text": "main"
},
{
"answer_id": 74238093,
"author": "Abhiroop Sarkar",
"author_id": 1942289,
"author_profi... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20352124/"
] |
74,227,230 | <p>I am trying to make a textView invisible when pressing a button. But, if the textView is already invisible I want it to become visible.</p>
<p>Currently I am trying sonething like this:</p>
<pre><code>public void ShowAndHide(View view){
if(textView == View.VISIBLE){
textView.setVisibility(View.INVISIBLE);
}
else {
textView.setVisibility(View.VISIBLE);
}
}
</code></pre>
<p>Where "textView" is a TextView which I have defined by id:</p>
<pre><code>TextView textView;
textView = (TextView) findViewById(R.id.showMe_txt);
</code></pre>
<p>Anyone who knows why this does not work? Coming from a C# background and this is my first dabble with Java so quite unfamiliar.</p>
| [
{
"answer_id": 74227392,
"author": "Ashish Suman",
"author_id": 13179338,
"author_profile": "https://Stackoverflow.com/users/13179338",
"pm_score": 1,
"selected": false,
"text": "if(textView.getVisibility() == View.VISIBLE){"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227230",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20351789/"
] |
74,227,268 | <p>I want to make a date picker that does not select previous dates using Django.</p>
<pre><code>class DateInput(forms.DateInput):
input_type = 'date'
class TimeInput(forms.TimeInput):
input_type = 'time'
"""class used for booking a time slot."""
class BookingForm(forms.ModelForm):
class Meta:
model = Booking
fields = ['check_in_date', 'check_in_time', 'check_out_time',
'person', 'no_of_rooms']
widgets = {
'check_in_date': DateInput(),
'check_in_time': TimeInput(),
'check_out_time': TimeInput(),
}
"""Function to ensure that booking is done for future and check out is after check in"""
def clean(self):
cleaned_data = super().clean()
normal_book_date = cleaned_data.get("check_in_date")
normal_check_in = cleaned_data.get("check_in_time")
normal_check_out_time = cleaned_data.get("check_out_time")
str_check_in = str(normal_check_in)
format = '%H:%M:%S'
try:
datetime.datetime.strptime(str_check_in, format).time()
except Exception:
raise ValidationError(
_('Wrong time entered.'),
code='Wrong time entered.',
)
# now is the date and time on which the user is booking.
now = timezone.now()
if (normal_book_date < now.date() or
(normal_book_date == now.date() and
normal_check_in < now.time())):
raise ValidationError(
"You can only book for future.", code='only book for future'
)
if normal_check_out_time <= normal_check_in:
raise ValidationError(
"Check out should be after check in.", code='check out after check in'
)
</code></pre>
<p>The above code is written in forms.py file. As you can see, I made a date picker but the problem is that the user can select any date but I want him to select only current or future dates. Perhaps, it can be done using JavaScript or bootstrap but I want to know can we do it in Django?</p>
| [
{
"answer_id": 74227392,
"author": "Ashish Suman",
"author_id": 13179338,
"author_profile": "https://Stackoverflow.com/users/13179338",
"pm_score": 1,
"selected": false,
"text": "if(textView.getVisibility() == View.VISIBLE){"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227268",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10261048/"
] |
74,227,284 | <h2>Background</h2>
<p>The Django <code>LiveServerTestCase</code> class has a <code>live_server_url</code> method with a <code>@classproperty</code> decorator. (<code>django.utils.functional.classproperty</code>.) The class starts its test server before any tests run, and thus knows the test server's URL before any tests run.</p>
<p>I have a similar <code>MyTestCase</code> class that has a <code>live_server_url</code> <code>@property</code>. It starts a new test server before each test, and thus its <code>live_server_url</code> property can't be a <code>@classproperty</code> because it doesn't know its port until it is instantiated.</p>
<p>To make the API for both consistent, so that all the test utility functions etc. in the code base can be used with both classes, the tests could be written to never reference <code>live_server_url</code> in <code>setUpClass()</code>, before all the tests run. But this would slow down many tests.</p>
<p>Instead, I want <code>MyTestCase.live_server_url</code> to raise a helpful error if it is referenced from the class object rather than an instance object.</p>
<p>Since <code>MyTestCase.live_server_url</code> is a <code>@property</code>, <code>MyTestCase().live_server_url</code> returns a string, but <code>MyTestCase.live_server_url</code> returns a property object. This causes cryptic errors like <code>"TypeError: unsupported operand type(s) for +: 'property' and 'str'"</code>.</p>
<h2>Actual question</h2>
<p>If I could define a <code>@classproperty</code> and <code>@property</code> on the same class, then I would define a <code>MyTestCase.live_server_url</code> <code>@classproperty</code> that raises an error with a helpful message like "live_server_url can only be called on an instance of MyTestCase, not on the MyTestCase class".</p>
<p>But when you define 2 methods with the same name in a Python class then the earlier one gets discarded, so I can't do that.</p>
<p>How can I make the behavior of <code>MyTestCase.live_server_url</code> different depending on whether it is called on the class or on an instance?</p>
| [
{
"answer_id": 74227392,
"author": "Ashish Suman",
"author_id": 13179338,
"author_profile": "https://Stackoverflow.com/users/13179338",
"pm_score": 1,
"selected": false,
"text": "if(textView.getVisibility() == View.VISIBLE){"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227284",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/724752/"
] |
74,227,306 | <p>In my borderless <code>HTML table</code> I replaced the <code>heading</code> of a <code>column</code> with a compound heading, consisting of three parts (see image). I did this by inserting a second table into the corresponding <code>heading element</code>. However, <strong>I am at a loss to remove the outer border of that table</strong>. In the image, the blue background color of the <code>heading element</code> remains visible. The table should be flush with the <code>heading element</code>, so that the blue of the <code>heading element</code> no longer is visible. How can this be achieved?</p>
<p><a href="https://i.stack.imgur.com/VC6Yj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VC6Yj.png" alt="enter image description here" /></a></p>
<p>Here is the <code>HTML code</code> of the table in the image:</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>table {
color: white;
border-collapse: collapse;
border: none;
}
th {
padding: 10px;
text-align: center;
}
td {
background-color: olive;
padding: 10px;
text-align: center;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><table>
<tr>
<th style="background-color:green">A</th>
<th style="background-color:blue">
<table>
<tr>
<th style="background-color:maroon" colspan="2">B</th>
</tr>
<tr>
<th style="background-color:red">x</th>
<th style="background-color:orange">y</th>
</tr>
</table>
</th>
<th style="background-color:purple">C</th>
</tr>
<tr>
<td>100</td>
<td>200</td>
<td>300</td>
</tr>
<tr>
<td>400</td>
<td>500</td>
<td>600</td>
</tr>
<tr>
<td>250</td>
<td>550</td>
<td>670</td>
</tr>
</table></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74227393,
"author": "Johannes",
"author_id": 5641669,
"author_profile": "https://Stackoverflow.com/users/5641669",
"pm_score": 2,
"selected": true,
"text": "body > table > tbody > tr:first-child > th:nth-child(2) {\n padding: 0;\n}\n"
},
{
"answer_id": 74227408,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227306",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1841607/"
] |
74,227,334 | <p>I want to use pivot longer on my df but not all of my columns are as.characters, as i have 10+ columns i need to change does anyone know how to do this in one argument to save me writing it out for all of the years?</p>
<p>My df looks like this;</p>
<pre><code>fisheries_df
`Series Name` `Country Name` `1997` `1998` `1999` `2000` `2001` `2002` `2003` `2004` `2005` `2006` `2007` `2008` `2009` `2010` `2011` `2012`
1 Total fisheri… Albania 1110.8 2807.5 3057.9 3635 3597.2 4516.8 4274.6 6118.5 6473 7.71e3 7.51e3 7.36e3 8.13e3 7.85e3 7.35e3 1.23e4
2 Total fisheri… Algeria 91907… 92620 102649 11351… 134082 13480… 141376 11405… 12662… 1.46e5 1.48e5 1.42e5 1.30e5 9.52e4 1.04e5 1.08e5
3 Total fisheri… Cyprus 25788 20482 41060 70223 56606 142941 49561 82269 64933 3.35e4 5.65e3 5.40e3 5.11e3 5.55e3 5.85e3 5.66e3
</code></pre>
<p>the code and error message im using to pivot the df is below, assuming the character issue is my problem here;</p>
<pre><code>fisheries_longer = pivot_longer(fisheries_df, c(3:26), c('year'))
Error in `stop_vctrs()`:
! Can't combine `1997` <character> and `2006` <double>.
Run `rlang::last_error()` to see where the error occurred.
</code></pre>
| [
{
"answer_id": 74227393,
"author": "Johannes",
"author_id": 5641669,
"author_profile": "https://Stackoverflow.com/users/5641669",
"pm_score": 2,
"selected": true,
"text": "body > table > tbody > tr:first-child > th:nth-child(2) {\n padding: 0;\n}\n"
},
{
"answer_id": 74227408,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18338223/"
] |
74,227,355 | <p>My goal is that when the button is clicked, the button color changes to orange and stays orange until the result of the if condition is declared. Then I want the button color to be green if the condition is met and red if not. However, when I click the button, the button color does not change until the condition result is clear, and when the condition is certain, the button color becomes either green or red. So the button color never turns orange.</p>
<p>I have shown my button usage below;</p>
<pre><code>Button
{
...
...
onClicked: {
background.color = "orange"
if(some_condition))
background.color = "green"
else
background.color = "red"
}
}
</code></pre>
<p>NOTE: I am sending data to a device in an if condition and waiting for its response(this takes about 1-2 seconds). I expect the button to be orange until the answer comes, green if my condition is true after the answer, and red if it is false. But the color of the button does not turn orange.</p>
<p>Do you have any suggestions?</p>
| [
{
"answer_id": 74229832,
"author": "SMR",
"author_id": 11603485,
"author_profile": "https://Stackoverflow.com/users/11603485",
"pm_score": 1,
"selected": false,
"text": "Image"
},
{
"answer_id": 74241721,
"author": "Stephen Quan",
"author_id": 881441,
"author_profile"... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227355",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5100678/"
] |
74,227,379 | <p>I have a data frame, there's a column as color code from 1-5</p>
<pre><code>| color code |
| 1 |
| 3 |
| 3 |
| 5 |
| 2 |
</code></pre>
<p>each color code means
1=Yellow, 2=White, 3=Black, 4=Blue, 5=Brown</p>
<p>How do I create a new column assign each color code a color name like below?</p>
<pre><code>| color code |color name|
| 1 | Yellow |
| 3 | Black |
| 3 | White |
| 5 | Brown |
| 2 | White |
</code></pre>
| [
{
"answer_id": 74229832,
"author": "SMR",
"author_id": 11603485,
"author_profile": "https://Stackoverflow.com/users/11603485",
"pm_score": 1,
"selected": false,
"text": "Image"
},
{
"answer_id": 74241721,
"author": "Stephen Quan",
"author_id": 881441,
"author_profile"... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20047081/"
] |
74,227,386 | <p>I have a section in which user can filter different data on drop-down select ,</p>
<p>I have an array of data as follows.</p>
<pre><code>const data = [
{
name: 'Trump',
country: 'USA',
age: 70,
IQ: 140,
},
{
name: 'ID Amini',
country: 'Uganda',
age: 50,
},
{
name: 'Kenyatta',
country: 'Kenya',
age: 60,
},
{
name: 'Obama',
country: 'USA',
age: 45,
IQ: 141
}
]
</code></pre>
<p><strong>My aim is also to be able to get all objects which do not contain IQ as you can see in the above array there are objects which do not contain IQ.</strong></p>
<p>Live demo : <a href="https://codepen.io/makumba/pen/PoeMjoY" rel="nofollow noreferrer">demo</a></p>
<p>Here is what I have tried so far.</p>
<pre><code>let filter = ['empty']; // passed dynamically u can pass eg Obama, kenyata etc etc
let filterTyped ='IQ' // passed dynamically als here u can pass name, country etc etc
let filtredData = filter.forEach((item) =>{
let dataFilter = data.find((element) =>{
//return all objects which does not contain IQ if Item is empyt
if(item === 'empty'){
return element[filterTyped] ==undefined;
}
// return found object
return element[filterTyped] ==item;
})
console.log('Filtred', dataFilter)
if(!dataFilter) return;
})
</code></pre>
<p>Any idea how to solve this issue?</p>
| [
{
"answer_id": 74227465,
"author": "Mr. Polywhirl",
"author_id": 1762224,
"author_profile": "https://Stackoverflow.com/users/1762224",
"pm_score": 2,
"selected": false,
"text": "hasOwnProperty"
},
{
"answer_id": 74227545,
"author": "Aid Hadzic",
"author_id": 5963060,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9964622/"
] |
74,227,427 | <p><strong>Given a situation where the same AWS account will host the <code>Dev</code> and <code>UAT</code> cloud deployments simultaneously, what is the best way to instantiate and segregate those 2 pseudo-environments?</strong></p>
<p>I say "pseudo" because the cdk <code>Environment</code> only takes in an account id & region. There is no other separation mechanism.</p>
<p>I could hand down the prefix manually into resource names by passing variables to the <code>Construct</code> constructor call which is passed in by the <code>Stack</code> constructor</p>
<pre><code>main(args) {
app App = ...
Stack(app, "stackid", bucketPrefix = args[0])
</code></pre>
<p>But I'm asking if there is a cdk/aws native way that enables this instead.</p>
<p>Thank you in advance for your consideration and response.</p>
| [
{
"answer_id": 74228339,
"author": "fedonev",
"author_id": 1103511,
"author_profile": "https://Stackoverflow.com/users/1103511",
"pm_score": 1,
"selected": false,
"text": "DevMyStack"
},
{
"answer_id": 74263927,
"author": "lynkfox",
"author_id": 11591758,
"author_prof... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227427",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1876739/"
] |
74,227,430 | <p>I have a dataframe containing 1440 rows and 8 columns. I have a column names 'number' taking values from 0 to 12. And I have another column named "correct" which takes value of True or False.</p>
<p>What I would like to do is a line chart with on my x axis'number' which as I said are ranging from 0 to 12 and on my y axis the number of "correct" taking the value True.</p>
<p>What I want is to regroup all of the cases when the 'number' is 0 and number of true, for example.</p>
<p>I tried to create a small example but I think I'm not precise enough.</p>
<p>I tried a lot of things with grouby and other things</p>
| [
{
"answer_id": 74227886,
"author": "Jon Smith",
"author_id": 20236532,
"author_profile": "https://Stackoverflow.com/users/20236532",
"pm_score": 1,
"selected": false,
"text": "where"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227430",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20352334/"
] |
74,227,444 | <p>I'm trying to access my application on my phone by running it on my local network. When starting the React app there are two urls. One is localhost and the other one on my network.</p>
<p><a href="https://i.stack.imgur.com/TMdh8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TMdh8.png" alt="enter image description here" /></a></p>
<p>I can access the application with the On Your Network URL when using the device that I'm running the app on, however, the problem is that I can't access it from any other device.</p>
<p>I tried to change the port, aswell as running: <code>npm start --port 3000 --host 0.0.0.0</code> (with 0.0.0.0 being my ip address).</p>
<p>I get an error saying:</p>
<p>This site can't be reached.
0.0.0.0 (with 0.0.0.0 again being my ip address) took to long to respond.</p>
| [
{
"answer_id": 74227886,
"author": "Jon Smith",
"author_id": 20236532,
"author_profile": "https://Stackoverflow.com/users/20236532",
"pm_score": 1,
"selected": false,
"text": "where"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227444",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13744373/"
] |
74,227,448 | <p>I need a code that will let me match a partial string of a school name <code>gr.schoolname</code> to <code>c.displayvalue</code> of our codeset <code>PSSDPriorSchools</code>. The <code>gr.schoolname</code> is just the school name, the <code>PSSDPriorSchools</code> is the school name with the (school division) following it.
I need to match the <code>gr.schoolname</code> to the <code>c.displayvalue</code> of the <code>PSSDPriorSchools</code> to be able to retrieve the c.code that corresponds with the <code>c.displayvalue</code>.</p>
<pre class="lang-sql prettyprint-override"><code>Select
s.ID as ID,s.LASTFIRST as LASTFIRST,s.STUDENT_NUMBER as STUDENT_NUMBER,
decode(upper(gr.schoolname), c.code, c.displayvalue) as credit_schools
from
STUDENTS s,
codeset c,
storedgrades gr
where
gr.schoolname= C.displayvalue
and c.codetype = 'PSSD_PriorSchools'
and gr.studentid=s.id
</code></pre>
<p>BUT our <code>gr.schoolname</code> only contains the first part of the string of <code>c.displayvalue</code>.</p>
<p>For example if I need to decode Pilot Mound School to a <code>c.code</code> number of 1301.</p>
<p>In our code set the <code>displayvalue</code> of this school contains a school division at the end like this:</p>
<pre><code>Pilot Mound School (PRAIRIE SPIRIT SCHOOL DIVISION).
</code></pre>
<p>So I need a code that would do this:</p>
<pre class="lang-sql prettyprint-override"><code>Select
s.ID as ID,s.LASTFIRST as LASTFIRST,s.STUDENT_NUMBER as STUDENT_NUMBER,
decode(upper(***( gr.schoolname= text before the first ' (') of c.displayvalue)***, c.code, c.displayvalue) as credit_schools
where
gr.schoolname= C.displayvalue
and c.codetype = 'PSSD_PriorSchools'
and gr.studentid=s.id
</code></pre>
<p>I tried it as <code>decode(gr.schoolname,(SUBSTR(gr.schoolname, 0, INSTR(c.displayvalue, '(')-1)),c.code,c.displayvalue)</code>
but I can not get it to work.</p>
<p>PSSDPriorSchools looks like:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Code</th>
<th>Display Value</th>
<th>Description Reported Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>1001</td>
<td>Harrow School (WINNIPEG SCHOOL DIVISION)</td>
<td>1001</td>
</tr>
<tr>
<td>1002</td>
<td>Educational Support Services (ST. JAMES-ASSINIBOIA SCHOOL DIVISION)</td>
<td>1002</td>
</tr>
<tr>
<td>1003</td>
<td>Woodland Colony School (PORTAGE LA PRAIRIE SCHOOL DIVISION)</td>
<td>1003</td>
</tr>
<tr>
<td>1006</td>
<td>Mafeking School (SWAN VALLEY SCHOOL DIVISION)</td>
<td>1006</td>
</tr>
<tr>
<td>1007</td>
<td>George Fitton School (BRANDON SCHOOL DIVISION)</td>
<td>1007</td>
</tr>
</tbody>
</table>
</div>
<p>and I need to decode the <code>Schoolname</code> to match the <code>c.displayvalue</code> so I can get the c.code</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Id</th>
<th>LastfirstAscending</th>
<th>Student Number</th>
<th>Schoolname</th>
</tr>
</thead>
<tbody>
<tr>
<td>2986</td>
<td>Abellera, Ana Carissa Evangelista</td>
<td>12945</td>
<td>St. Claude School Complex</td>
</tr>
<tr>
<td>2987</td>
<td>Abellera, John Allen Evangelista</td>
<td>12947</td>
<td>Prairie Mountain High School</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74227886,
"author": "Jon Smith",
"author_id": 20236532,
"author_profile": "https://Stackoverflow.com/users/20236532",
"pm_score": 1,
"selected": false,
"text": "where"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227448",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3380817/"
] |
74,227,462 | <p>Is it possible for me to convert</p>
<pre><code>"Thu Oct 27 2022 02:00:00 GMT-0600 (Mountain Daylight Time)"
</code></pre>
<p>to this?</p>
<pre><code>"Thu Oct 27 2022 02:00:00 GMT-0400 (New_York or whatever its actually called)"
</code></pre>
<p>I am using a component called react-datepicker</p>
<p>My datePicker is returning a date like this, Im in Colorado.</p>
<pre><code>"Thu Oct 27 2022 02:00:00 GMT-0600 (Mountain Daylight Time)"
</code></pre>
<p>When i convert this to UTC i get</p>
<pre><code>"2022-10-27T08:00:00Z"
</code></pre>
<p>My component is ALWAYS going to return me a time in my local timezone, which is Denver. I would like to be able to select a time, have it return me the first date, then somehow convert that to the second date in New york time.</p>
<pre><code>"Thu Oct 27 2022 02:00:00 GMT-0400 (New_York or whatever its actually called)"
</code></pre>
<p>This way when I convert to utc I can get the output below</p>
<pre><code>"2022-10-27T06:00:00Z"
</code></pre>
<p>Can anyone help me with this?</p>
| [
{
"answer_id": 74227886,
"author": "Jon Smith",
"author_id": 20236532,
"author_profile": "https://Stackoverflow.com/users/20236532",
"pm_score": 1,
"selected": false,
"text": "where"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227462",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17697574/"
] |
74,227,476 | <p>im having the dataframe:</p>
<pre><code>test = pd.DataFrame({'Date': [2020 - 12 - 30, 2020 - 12 - 30, 2020 - 12 - 30, 2020 - 12 - 31, 2020 - 12 - 31, 2021 - 0o1 - 0o1, 2021 - 0o1 - 0o1], 'label': ['Positive', 'Positive', 'Negative', 'Negative','Negative', 'Positive', 'Positive'], 'score': [70, 80, 50, 50, 30, 90, 70]})
</code></pre>
<p>Output:</p>
<pre><code> Date label score
2020-12-30 Positive 70
2020-12-30 Positive 80
2020-12-30 Negative 50
2020-12-31 Negative 50
2020-12-31 Negative 30
2021-01-01 Positive 90
2021-01-01 Positive 70
</code></pre>
<p>My goal is to group by the date and count the labels. In addition the score should be calculating only the mean with the labels/score which are higher at that day. For example if there is more positive than negative at the day it should calculate the mean of the positive scores without the negative scores and the other way around.</p>
<p>I though about the function <code>new_df = test.groupby(['Date', 'label']).agg({'label' : 'count', 'score' : 'mean'})</code></p>
<p>Output should be like that. Maybe .pivot function would help?</p>
<pre><code> Date label new_score count_pos count_neg
2020-12-30 Positive 150 2 1
2020-12-31 Negative 80 0 2
2021-01-01 Positive 160 2 0
new_score = 70 + 80 = 150 of the two days with positive label
count_pos = count "Positive" at day X
count_neg = count "Negative" at day X
</code></pre>
<p>Im a beginner in python and any help or hints how to tackle this task is appreciated!</p>
<p>Thanks!</p>
| [
{
"answer_id": 74227659,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 2,
"selected": false,
"text": "x = df.pivot_table(\n index=[\"Date\", \"label\"],\n columns=\"label\",\n values=\"score\",\n ag... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11038026/"
] |
74,227,489 | <p>In my <code>CoordinatesViewModel</code> file i have function <code>addWaypoint</code> that gets called when user presses the button. In <code>LocationManager</code> file i have function that gets users location and then stops receiving location updates. To access location from <code>LocationManager</code> file i use <code>.sink</code> (i am new to Swift so i don’t know if <code>.sink</code> is the right way about doing this). Now the problem i noticed is that <code>.sink</code> sometimes runs twice or more so the same result gets added to array. This usually happens the second time i press the button.</p>
<p>Here is the example what i get from <code>print</code> into console when i run the app:</p>
<pre><code>hello from ViewModel
hello from LocationManager
hello from ViewModel
</code></pre>
<p>LocationManager:</p>
<pre><code> private let manager = CLLocationManager()
@Published var userWaypoint: CLLocation? = nil
override init(){
super.init()
manager.desiredAccuracy = kCLLocationAccuracyBest
manager.requestWhenInUseAuthorization()
manager.delegate = self
}
func getCurrentUserWaypoint(){
wasWaypointButtonPressed = true
manager.requestWhenInUseAuthorization()
manager.startUpdatingLocation()
}
extension LocationManager: CLLocationManagerDelegate{
func locationManager(_ manager: CLLocationManager, didUpdateLocations locations: [CLLocation]) {
guard let userWaypoint = locations.last else {return}
print("hello from LocationManager")
DispatchQueue.main.async {
self.userWaypoint = userWaypoint
}
self.manager.stopUpdatingLocation()
}
}
</code></pre>
<p>CoordinatesViewModel:</p>
<pre><code>private let locationManager: LocationManager
var cancellable: AnyCancellable?
@Published var waypoints: [CoordinateData] = []
init() {
locationManager = LocationManager()
}
func addWaypoint(){
locationManager.getCurrentUserWaypoint()
cancellable = locationManager.$userWaypoint.sink{ userWaypoint in
if let userWaypoint = userWaypoint{
print("hello from ViewModel")
DispatchQueue.main.async{
let newWaypoint = CoordinateData(coordinates: userWaypoint.coordinate)
self.waypoints.append(newWaypoint)
}
}
}
}
</code></pre>
| [
{
"answer_id": 74227659,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 2,
"selected": false,
"text": "x = df.pivot_table(\n index=[\"Date\", \"label\"],\n columns=\"label\",\n values=\"score\",\n ag... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8018832/"
] |
74,227,513 | <p>So I want to keep a subtotal but I want to subtract the number from the subtotal if it's smaller than the one to its right.</p>
<p>Example:</p>
<pre><code> for i in list:
if i < i+1:
num += int(i)
else:
num -= int(i)
return num
</code></pre>
<p>I wanted this code to give me 397 but it adds the 10, doesn't subtract it</p>
| [
{
"answer_id": 74227606,
"author": "John Gordon",
"author_id": 494134,
"author_profile": "https://Stackoverflow.com/users/494134",
"pm_score": 1,
"selected": false,
"text": "mylist = [100, 100, 100, 10, 100, 5, 1, 1]\n\nfor i in range(len(mylist)):\n curval = mylist[i]\n if i < len... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20339851/"
] |
74,227,543 | <p>I'm on spring framework version 5.3.23, spring boot version 2.7.0</p>
<p>I know I can extend <code>CachingConfigurerSupport</code> to provide a <code>CacheErrorHandler</code> for handling cache layer errors. However, the interface of the bean creation is:</p>
<pre><code>interface CachingConfigurer {
public CacheErrorHandler errorHandler();
}
</code></pre>
<p>My problem is: we need to inject some other beans into this <code>CacheErrorHandler</code> bean. The interface does not allow me to do that. Is there another way to configure a <code>CacheErrorHandler</code> bean with injection? If I simply declare a regular <code>CacheErrorHandler</code> bean, would it be automatically discovered by the cache configuration?</p>
<p>Thanks.</p>
| [
{
"answer_id": 74227606,
"author": "John Gordon",
"author_id": 494134,
"author_profile": "https://Stackoverflow.com/users/494134",
"pm_score": 1,
"selected": false,
"text": "mylist = [100, 100, 100, 10, 100, 5, 1, 1]\n\nfor i in range(len(mylist)):\n curval = mylist[i]\n if i < len... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2504079/"
] |
74,227,547 | <p>I have the following cycle:</p>
<pre><code>comprehensive_merged_function = np.zeros(shape=(0, 1))
for i in range(256):
comprehensive_merged_function = np.append(comprehensive_merged_function, utils.dec_to_bin(i, 8))
comprehensive_merged_function = np.array([list(s) for s in comprehensive_merged_function]).astype(int)
</code></pre>
<p>which is giving me the following array:</p>
<pre><code>[[0 0 0 0 0 0 0 0]
[0 0 0 0 0 0 0 1]
[0 0 0 0 0 0 1 0]
...
[1 1 1 1 1 1 0 1]
[1 1 1 1 1 1 1 0]
[1 1 1 1 1 1 1 1]]
</code></pre>
<p>I would to like to append each row (out of the 256) with 8 times (-1), to obtain the following desired result:</p>
<pre><code> [[0 0 0 0 0 0 0 0 -1 -1 -1 -1 -1 -1 -1 -1]
[0 0 0 0 0 0 0 1 -1 -1 -1 -1 -1 -1 -1 -1]
[0 0 0 0 0 0 1 0 -1 -1 -1 -1 -1 -1 -1 -1]
...
[1 1 1 1 1 1 0 1 -1 -1 -1 -1 -1 -1 -1 -1]
[1 1 1 1 1 1 1 0 -1 -1 -1 -1 -1 -1 -1 -1]
[1 1 1 1 1 1 1 1 -1 -1 -1 -1 -1 -1 -1 -1]]
</code></pre>
<p>I tried the following:</p>
<pre><code>comprehensive_merged_function = np.zeros(shape=(0, 1))
appending_indexes = np.array([-1, -1, -1, -1, -1, -1, -1, -1])
for i in range(256):
comprehensive_merged_function = np.append(comprehensive_merged_function, utils.dec_to_bin(i, 8))
comprehensive_merged_function = np.row_stack(comprehensive_merged_function, appending_indexes)
comprehensive_merged_function = np.array([list(s) for s in comprehensive_merged_function]).astype(int)
</code></pre>
<p>and I received the following error:</p>
<pre><code>Traceback (most recent call last):
File "compression comprehensive testing.py", line 262, in <module>
comprehensive_merged_function = np.row_stack(comprehensive_merged_function, appending_indexes)
File "<__array_function__ internals>", line 4, in vstack
TypeError: _vhstack_dispatcher() takes 1 positional argument but 2 were given
</code></pre>
<p>Of course I tried many other different ways to do this, but the results were worse and I haven`t presenthed them here to avoid overloading the post.</p>
<p>Any help of how can I get the desired result will be greatly appreciated.</p>
| [
{
"answer_id": 74227606,
"author": "John Gordon",
"author_id": 494134,
"author_profile": "https://Stackoverflow.com/users/494134",
"pm_score": 1,
"selected": false,
"text": "mylist = [100, 100, 100, 10, 100, 5, 1, 1]\n\nfor i in range(len(mylist)):\n curval = mylist[i]\n if i < len... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19277540/"
] |
74,227,550 | <p>I have a columns in a dataframe like this:</p>
<pre><code> column_name
{"trials": {"value": ["8"]}, "results": {"value": "malfuction details."}, "trials_nic": {"value": ["7"]}, "custom_cii": {"value": ["yes"]}}
</code></pre>
<p>When I apply type to this column I get <code>"str"</code></p>
<pre><code>df['column_name'].apply(type)
</code></pre>
<p>output: <code><class 'str'></code></p>
<p>How can I flat this column to get each <code>key:value</code> pair in a new column?</p>
| [
{
"answer_id": 74227606,
"author": "John Gordon",
"author_id": 494134,
"author_profile": "https://Stackoverflow.com/users/494134",
"pm_score": 1,
"selected": false,
"text": "mylist = [100, 100, 100, 10, 100, 5, 1, 1]\n\nfor i in range(len(mylist)):\n curval = mylist[i]\n if i < len... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227550",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18333836/"
] |
74,227,555 | <p>I need to validate a string whose length is exactly 6 OR 8. How could I make the rule for this validation?</p>
<p>The number must be 6 OR 8, it cannot be between 6 and 8.</p>
| [
{
"answer_id": 74227806,
"author": "Lessmore",
"author_id": 1804223,
"author_profile": "https://Stackoverflow.com/users/1804223",
"pm_score": 1,
"selected": false,
"text": "mb_strlen"
},
{
"answer_id": 74227817,
"author": "Sumit kumar",
"author_id": 11545457,
"author_... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227555",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18730485/"
] |
74,227,568 | <p>I have a list that has names and I want to get the list element which has some part of my string</p>
<p>for example:</p>
<pre><code>names = ["David Benj Jacob", "Alex"]
</code></pre>
<p>so if I search with "David Jacob" then how can I get the first element of the list "David Benj Jacob"?</p>
<p><strong>I tried</strong>
if "David Jacob" in names</p>
| [
{
"answer_id": 74227654,
"author": "jprebys",
"author_id": 3268228,
"author_profile": "https://Stackoverflow.com/users/3268228",
"pm_score": 3,
"selected": true,
"text": "names = [\"David Benj Jacob\", \"Alex\"]\nsubstr = \"David Jacob\"\n\nvalid_names = []\nfor name in names:\n if al... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20304185/"
] |
74,227,590 | <p><em>Oracle 18c; SQL Developer 18.1.0.095 Build 095.1630:</em></p>
<p>Using this sample data:</p>
<pre><code>create table assets (asset_id varchar2(10));
begin
insert into assets (asset_id) values ('01');
insert into assets (asset_id) values ('02');
insert into assets (asset_id) values ('02');
end;
/
commit;
</code></pre>
<p>In SQL Developer, I can run a query that only is a partial WHERE clause expression; it doesn't have a SELECT or FROM clause.</p>
<p>I select the following query using my mouse and hit <code>CTRL+Enter</code>:</p>
<pre><code>asset_id) in
(
select
asset_id
from
assets
where
asset_id = '02'
)
</code></pre>
<p>Result:</p>
<p><a href="https://i.stack.imgur.com/Lrgiu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Lrgiu.png" alt="enter image description here" /></a></p>
<hr />
<p>Why did that query run successfully, despite it missing a SELECT and FROM clause?</p>
| [
{
"answer_id": 74227654,
"author": "jprebys",
"author_id": 3268228,
"author_profile": "https://Stackoverflow.com/users/3268228",
"pm_score": 3,
"selected": true,
"text": "names = [\"David Benj Jacob\", \"Alex\"]\nsubstr = \"David Jacob\"\n\nvalid_names = []\nfor name in names:\n if al... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227590",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5576771/"
] |
74,227,598 | <p>I know this is a common question, but after hours of searching for an answer, I decided to ask for help.</p>
<p>I'm trying to pass a state variable to a component, but the component was rendered before the value was set</p>
<p>my code:</p>
<pre><code>import React, { useState, useEffect } from "react";
import { useLocation } from "react-router-dom";
import Seguradora from "../../components/seguradora/seguradora.component";
const CorretorasShow = () => {
const obj = useLocation();
const [names, setNames] = useState([]);
useEffect(() => {
const url =
"http://localhost:3001/corretoras/63338f415c502044e953d408" +
obj.state._id;
const fetchData = async () => {
try {
const response = await fetch(url);
const json = await response.json();
setNames(json.seguradora); // <<<<<< setState
} catch (error) {
console.log("error", error);
}
};
fetchData();
}, []);
return (
<div>
<Seguradora props={names} /> //<<<<< state varible
</div>
);
};
</code></pre>
<p>I've tried useMemo, useRef and ternary operator to no avail.
I'm not an expert programmer and I'm new to reactJS so I may have done something wrong with these workarounds</p>
| [
{
"answer_id": 74227660,
"author": "Jovana",
"author_id": 11365465,
"author_profile": "https://Stackoverflow.com/users/11365465",
"pm_score": 1,
"selected": true,
"text": "names"
},
{
"answer_id": 74227706,
"author": "Caio Amorim",
"author_id": 17854639,
"author_profi... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20352373/"
] |
74,227,609 | <p>i have been trying to display a JLabel added to a JPanel with no sucess for some time now.<br />
Main program :</p>
<pre><code>import javax.swing.*;
import java.awt.*;
public class Main{
public static void main(String[] args){
int screenWidth = 5000;
//int screenWidth = (int)Toolkit.getDefaultToolkit().getScreenSize().getWidth();
MyFrame frame = new MyFrame(screenWidth);
JLabel header = new JLabel("Choisissez un nombre");
header.setBounds(100,100,screenWidth-100,40);
header.setFont(new Font("Arial",Font.BOLD,40));
JPanel panel1 = new JPanel();
panel1.setBounds(100,140,screenWidth-100,100);
JLabel desc = new JLabel("entrez un nombre entre 1 et 100 : ");
desc.setFont(new Font("Arial",Font.BOLD,40));
panel1.add(desc);
frame.add(header);
frame.add(panel1);
frame.setVisible(true);
}
}
</code></pre>
<p><code>MyFrame</code> class :</p>
<pre><code>import javax.swing.JFrame;
public class MyFrame extends JFrame{
MyFrame(int screenWidth){
this.setSize(screenWidth/5,screenWidth/10);
this.setTitle("Le juste nombre");
this.setLayout(null);
this.setDefaultCloseOperation(JFrame.EXIT_ON_CLOSE);
}
}
</code></pre>
| [
{
"answer_id": 74228034,
"author": "Conffusion",
"author_id": 3659670,
"author_profile": "https://Stackoverflow.com/users/3659670",
"pm_score": 1,
"selected": false,
"text": "this.setLayout(null);\n"
},
{
"answer_id": 74228037,
"author": "MadProgrammer",
"author_id": 9924... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227609",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20352410/"
] |
74,227,630 | <p>I have a Dataframe as shown below as dataframe1:</p>
<p><strong>dataframe1</strong></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>PATH</th>
</tr>
</thead>
<tbody>
<tr>
<td>ABC</td>
<td>[[orange, apple, kiwi, peach], [strawberry, orange, kiwi, peach]]</td>
</tr>
<tr>
<td>ABC</td>
<td>[[apple, plum, peach], [apple, pear, peach]]</td>
</tr>
<tr>
<td>BCD</td>
<td>[[blueberry, plum, peach], [pear, apple, peach]]</td>
</tr>
<tr>
<td>BCD</td>
<td>[[plum, apple, peach], [banana, raspberry, peach]]</td>
</tr>
</tbody>
</table>
</div>
<p>I would like to concatenate the value of column 'PATH' by column 'ID' and have the following results:</p>
<p><strong>dataframe2 (ideal output, the output is the list of lists)</strong></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>PATH</th>
</tr>
</thead>
<tbody>
<tr>
<td>ABC</td>
<td>[[orange, apple, kiwi, peach], [strawberry, orange, kiwi, peach], [apple, plum, peach], [apple, pear, peach]]</td>
</tr>
<tr>
<td>BCD</td>
<td>[[blueberry, plum, peach], [pear, apple, peach], [plum, apple, peach], [banana, raspberry, peach]]</td>
</tr>
</tbody>
</table>
</div>
<p>I used the following code:</p>
<pre class="lang-py prettyprint-override"><code>df2 = df1.groupby('id')['PATH'].apply(list)
</code></pre>
<p>but got the results with [[[ ]]] as shown which is list of list of lists...and is not what I want.</p>
<p><strong>dataframe3 (wrong output)</strong></p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID</th>
<th>PATH</th>
</tr>
</thead>
<tbody>
<tr>
<td>ABC</td>
<td>[[[orange, apple, kiwi, peach], [strawberry, orange, kiwi, peach], [apple, plum, peach], [apple, pear, peach]]]</td>
</tr>
<tr>
<td>BCD</td>
<td>[[[blueberry, plum, peach], [pear, apple, peach], [plum, apple, peach], [banana, raspberry, peach]]]</td>
</tr>
</tbody>
</table>
</div>
<p>How can I get the results like in dataframe2?</p>
| [
{
"answer_id": 74228034,
"author": "Conffusion",
"author_id": 3659670,
"author_profile": "https://Stackoverflow.com/users/3659670",
"pm_score": 1,
"selected": false,
"text": "this.setLayout(null);\n"
},
{
"answer_id": 74228037,
"author": "MadProgrammer",
"author_id": 9924... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227630",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10396920/"
] |
74,227,665 | <p>I need method of checking whether a number exists is a list/series, and if it does not returning the next highest number in the list.</p>
<p>For example:- in the list <code>nums = [1,2,3,5,7,8,20]</code> if I were to enter the number <code>4</code> the function would return <code>5</code> and anything <code>> 8 < 20</code> would return <code>20</code> and so on.</p>
<p>Below is a very basic example of the premise:</p>
<pre><code>nums = [1,2,3,5,7,8,20]
def coerce_num(x):
if x in nums:
return print("yes")
else:
return ("next number in list")
coerce_num(9)
</code></pre>
<p>If there was a method to do this with pandas dataframe, that would be even better.</p>
| [
{
"answer_id": 74227736,
"author": "Muhammad Akhlaq Mahar",
"author_id": 17416783,
"author_profile": "https://Stackoverflow.com/users/17416783",
"pm_score": 0,
"selected": false,
"text": "coerce_num(x + 1)"
},
{
"answer_id": 74227903,
"author": "sj95126",
"author_id": 138... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227665",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11370582/"
] |
74,227,687 | <p>Why do most modern browsers (except Firefox) not support setting a CSS variable in <code>a:visited</code>?</p>
<p>This is not working in Chromium based browsers, Safari, etc.:</p>
<pre class="lang-css prettyprint-override"><code>a:visited {
--bg-color: red;
}
</code></pre>
<p>But all browsers support setting variables in <code>a:hover</code>:</p>
<pre class="lang-css prettyprint-override"><code>a:hover {
--bg-color: red;
}
</code></pre>
<p>Here's a demo: <a href="https://codepen.io/mamiu/pen/YzvXXqw" rel="nofollow noreferrer">https://codepen.io/mamiu/pen/YzvXXqw</a></p>
| [
{
"answer_id": 74227847,
"author": "Tybo",
"author_id": 16596400,
"author_profile": "https://Stackoverflow.com/users/16596400",
"pm_score": 1,
"selected": false,
"text": "a { \nbackground-color: grey;\n}\n\na:visited {\nbackground-color: green;\n}\n"
},
{
"answer_id": 74228049,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227687",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2524925/"
] |
74,227,701 | <p>I'd like to get the last row satisfying a condition in a <code>data.table</code>.</p>
<p>For this I need to use a join because this is by far the fastest way.</p>
<pre><code>mydt <- data.table(condition = c(F,F,T,F,F,T,F,F,F,F), row = 1:10).
> mydt
condition row
<lgcl> <int>
1: FALSE 1
2: FALSE 2
3: TRUE 3
4: FALSE 4
5: FALSE 5
6: TRUE 6
7: FALSE 7
8: FALSE 8
9: FALSE 9
10: FALSE 10
</code></pre>
<p>Basically I'd like the previous <code>row</code> where <code>condition</code> is TRUE. Here the sixth element should be <code>3</code>, all the rest NA's.</p>
<p>I tried to compute this over both TRUE and FALSE because for some reason I can't use <code>on = .(condition == T)</code></p>
<pre><code>mydt[
mydt,
on = .(condition == condition, row < row),
.(result = row),
mult = "last"]$result
# [1] 1 2 3 4 5 6 7 8 9 10
# expected result: NA, 1, NA, 2, 4, 3, 5, 6, 7, 8, 9
# OR expected result (only for TRUE): NA, NA, NA, NA, NA, 3, NA, NA, NA, NA, NA
</code></pre>
<p>Any help? thanks</p>
<hr />
<p><strong>EDIT</strong> The below accomplishes the expected result in <code>dplyr</code> but I am still after a <code>data.table</code> <code>join</code> solution</p>
<pre><code>mydt %>% as.data.frame() %>% group_by(condition) %>% mutate(prev_result = lag(row))
condition row prev_result
<lgl> <int> <int>
1 FALSE 1 NA
2 FALSE 2 1
3 TRUE 3 NA
4 FALSE 4 2
5 FALSE 5 4
6 TRUE 6 3
7 FALSE 7 5
8 FALSE 8 7
9 FALSE 9 8
10 FALSE 10 9
</code></pre>
| [
{
"answer_id": 74227893,
"author": "Andre Wildberg",
"author_id": 9462095,
"author_profile": "https://Stackoverflow.com/users/9462095",
"pm_score": 2,
"selected": false,
"text": "data.table"
},
{
"answer_id": 74228102,
"author": "Mikko Marttila",
"author_id": 4550695,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5224236/"
] |
74,227,753 | <p>I want to create the movement buttons for some text to move it around the page in four directions. However when I press some of them more than once, they stop working. I need them to move exactly with 100px.</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>$("#up").click(function() {
$("#text").css("bottom", "+=100px")
})
$("#left").click(function() {
$("#text").css("right", "+=100px")
})
$("#down").click(function() {
$("#text").css("top", "+=100px")
})
$("#right").click(function() {
$("#text").css("left", "+=100px")
})</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>.controls {
position: absolute;
display: flex;
}
.text {
position: relative;
bottom: 0;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="text" style="text-align: center;" id="text">
Hello world
</div>
<br>
<br>
<div class="controls">
<button id="left">left</button>
<button id="down">down</button>
<button id="right">right</button>
<button id="up">up</button>
</div>
<script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74227893,
"author": "Andre Wildberg",
"author_id": 9462095,
"author_profile": "https://Stackoverflow.com/users/9462095",
"pm_score": 2,
"selected": false,
"text": "data.table"
},
{
"answer_id": 74228102,
"author": "Mikko Marttila",
"author_id": 4550695,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13646793/"
] |
74,227,756 | <p>In the example code at the bottom, I'm trying to format the text rendered inside the shinyBS package <code>popify()</code> function as shown in the image below (reduce bullet indentation and right justify the text). I believe this code uses shiny html. How could this be done?</p>
<p><a href="https://i.stack.imgur.com/Za89X.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Za89X.png" alt="enter image description here" /></a></p>
<p>Code:</p>
<pre><code>library(shiny)
library(shinyBS)
app = shinyApp(
ui =
fluidPage(
sidebarLayout(
sidebarPanel(sliderInput("bins","Number of bins:",min = 1,max = 50,value = 30)),
mainPanel(
plotOutput("distPlot"),
uiOutput("uiExample"))
)
),
server =
function(input, output, session) {
output$distPlot <- renderPlot({
x <- faithful[, 2]
bins <- seq(min(x), max(x), length.out = input$bins + 1)
hist(x, breaks = bins, col = 'darkgray', border = 'white')
})
output$uiExample <- renderUI({
tagList(
tags$span("Little circle >>"),
tags$span(
popify(icon("info-circle", verify_fa = FALSE),
"Placeholder",
paste(
"This table below presents a whole bunch of great information so strap in:",
"<ul>",
"<li>Blah blah blah blah blah blah blah blah blah blah blah.</li>",
"<li>Blah blah blah blah blah blah blah blah blah blah blah.</li>",
"<li>Blah blah blah blah blah blah blah blah blah blah blah blah blah.</li>",
"<li>Blah blah blah blah blah blah blah blah blah blah blah blah.</li>",
"<li>Blah blah blah blah blah blah blah blah blah blah",
"Blah blah blah blah blah blah.</li>",
"</ul>")
)
)
)
})
}
)
runApp(app)
</code></pre>
| [
{
"answer_id": 74241802,
"author": "lz100",
"author_id": 13002643,
"author_profile": "https://Stackoverflow.com/users/13002643",
"pm_score": 2,
"selected": true,
"text": " tags$style(\n '\n .popover ul {padding: 1px; text-align: right;}\n ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227756",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19657749/"
] |
74,227,773 | <p>For last 2 days I stuck with a line chart issue with EPPlus. My objective is to create a line chart with EPPlus and line style will be dash line like below image. picture attached.</p>
<p><a href="https://i.stack.imgur.com/VSCxF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VSCxF.png" alt="enter image description here" /></a></p>
<p>I search a lot Google for 2 days still got no relevant hint to have dash line in chart. I am not sure that at all EPPlus support dash line. I am using EPPlus version 6.0 and .NET Framework version 4.8. This is a sample code which generate chart in excel sheet with one line but I need that line will be dash line. please someone see my code and tell me what is missing in my code for which I could not have dash line style of line chart.</p>
<pre><code>ExcelPackage.LicenseContext = LicenseContext.NonCommercial;
var newFile = new FileInfo(filepath);
using (ExcelPackage xlPackage = new ExcelPackage(newFile))
{
ExcelWorksheet worksheet = xlPackage.Workbook.Worksheets.Add("test");
worksheet.Cells["A1"].Value = 1;
worksheet.Cells["A2"].Value = 2;
worksheet.Cells["A3"].Value = 3;
worksheet.Cells["A4"].Value = 4;
worksheet.Cells["A5"].Value = 5;
worksheet.Cells["A6"].Value = 6;
worksheet.Cells["B1"].Value = 10000;
worksheet.Cells["B2"].Value = 10100;
worksheet.Cells["B3"].Value = 10200;
worksheet.Cells["B4"].Value = 10150;
worksheet.Cells["B5"].Value = 10250;
worksheet.Cells["B6"].Value = 10200;
//ExcelChart chart = worksheet.Drawings.AddChart("LineChart", eChartType.XYScatterSmooth);
ExcelChart chart = worksheet.Drawings.AddChart("LineChart", eChartType.XYScatterSmoothNoMarkers);
chart.Series.Add(ExcelRange.GetAddress(1, 2, worksheet.Dimension.End.Row, 2),
ExcelRange.GetAddress(1, 1, worksheet.Dimension.End.Row, 1));
var Series = chart.Series[0];
//chart.Axis[0].MinorGridlines.Fill.Color = Color.Red;
//chart.Axis[0].MinorGridlines.LineStyle = eLineStyle.LongDashDot;
chart.Axis[0].RemoveGridlines();
chart.Axis[1].RemoveGridlines();
chart.Axis[0].Border.LineStyle = eLineStyle.SystemDash;
//chart.XAxis.Border.LineStyle = eLineStyle.Dash;
chart.Series[0].Header = "Blah";
//chart.Series[0].Border.LineStyle = eLineStyle.DashDot;
//chart.Axis[0].Border.LineStyle = eLineStyle.Dash;
xlPackage.Save();
MessageBox.Show("Done");
}
</code></pre>
<p>I also check this post but could not implement it in my code <a href="https://stackoverflow.com/questions/16744629/office-open-xml-drawing-dashed-line-in-chart">Office Open XML: Drawing Dashed Line in Chart</a></p>
<p>Please push me to right direction to achieve my goal. Thanks in advance.</p>
| [
{
"answer_id": 74241802,
"author": "lz100",
"author_id": 13002643,
"author_profile": "https://Stackoverflow.com/users/13002643",
"pm_score": 2,
"selected": true,
"text": " tags$style(\n '\n .popover ul {padding: 1px; text-align: right;}\n ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/508127/"
] |
74,227,783 | <p>When routing to a child module in my angular application, I can route to it without entering the full URL & i'm not sure why</p>
<p>E.G. I want to route to <code>admin/garage/1</code>, which works, but if I route to <code>garage/1</code>, it takes me to the same place (which I dont expect it to)</p>
<p><code>localhost:4200/admin/garages/1</code> takes me to ViewGarageComponent, but <code>localhost:4200/garages/1</code> also takes me there, I dont expect localhost:4200/garages/1 to take me there as it is in the admin/ child routes</p>
<p>admin module router (i expect all these routes to be <code>admin/</code>)</p>
<pre><code>const adminRoutes: Routes = [
{ path: 'admin', redirectTo: 'home', pathMatch: 'full' },
{ path: 'home', component: AdminComponent },
{ path: 'garages', component: GarageListComponent },
{ path: 'garage/:garageId', component: ViewGarageComponent },
];
@NgModule({
imports: [RouterModule.forChild(adminRoutes)],
exports: [RouterModule],
})
export class AdminRoutingModule {}
</code></pre>
<p>admin module</p>
<pre><code>@NgModule({
imports: [
CommonModule,
AdminRoutingModule,
MatProgressSpinnerModule,
MatToolbarModule,
MatIconModule
],
declarations: [
AdminComponent,
ViewGarageComponent,
CreateGarageComponent,
GarageListComponent,
HeaderComponent
]
})
export class AdminModule { }
</code></pre>
<p>app module router</p>
<pre><code>const routes: Routes = [
{ path: '', redirectTo: '/sign-in', pathMatch: 'full' },
{ path: 'sign-in', component: SignInComponent },
{ path: 'register-user', component: SignUpComponent },
{ path: 'dashboard', component: DashboardComponent, canActivate: [AuthGuard] },
{ path: 'schedule', component: SyncScheduleComponent, canActivate: [AuthGuard] },
{ path: 'forgot-password', component: ForgotPasswordComponent },
{ path: 'verify-email-address', component: VerifyEmailComponent },
{
path: 'admin',
loadChildren: () => import('./admin/admin.module').then(m => m.AdminModule), canActivate: [AdminAuthGuard]
}
];
@NgModule({
imports: [RouterModule.forRoot(routes)],
exports: [RouterModule],
})
</code></pre>
| [
{
"answer_id": 74241802,
"author": "lz100",
"author_id": 13002643,
"author_profile": "https://Stackoverflow.com/users/13002643",
"pm_score": 2,
"selected": true,
"text": " tags$style(\n '\n .popover ul {padding: 1px; text-align: right;}\n ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227783",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12886234/"
] |
74,227,788 | <p>I am trying to update Col1 with values from Col2,Col3... if values are found in any of them. A row would have only one value, but it can have "-" but that should be treated as NaN</p>
<pre><code>df = pd.DataFrame(
[
['A',np.nan,np.nan,np.nan,np.nan,np.nan],
[np.nan,np.nan,np.nan,'C',np.nan,np.nan],
[np.nan,np.nan,"-",np.nan,'B',np.nan],
[np.nan,np.nan,"-",np.nan,np.nan,np.nan]
],
columns = ['Col1','Col2','Col3','Col4','Col5','Col6']
)
print(df)
Col1 Col2 Col3 Col4 Col5 Col6
0 A NaN NaN NaN NaN NaN
1 NaN NaN NaN C NaN NaN
2 NaN NaN NaN NaN B NaN
3 NaN NaN NaN NaN NaN NaN
</code></pre>
<p>I want the output to be:</p>
<pre><code> Col1
0 A
1 C
2 B
3 NaN
</code></pre>
<p>I tried to use the update function:</p>
<pre><code>for col in df.columns[1:]:
df[Col1].update(col)
</code></pre>
<p>It works on this small <code>DataFrame</code> but when I run it on a larger <code>DataFrame</code> with a lot more <code>rows</code> and <code>columns</code>, I am losing a lot of values in between. Is there any better function to do this preferably without a loop. Please help I tried with many other methods, including using <code>.loc</code> but no joy.</p>
| [
{
"answer_id": 74227966,
"author": "Naveed",
"author_id": 3494754,
"author_profile": "https://Stackoverflow.com/users/3494754",
"pm_score": 3,
"selected": true,
"text": "\n# convert the values in the row to series, and sort, NaN moves to the end\ndf2=df.apply(lambda x: pd.Series(x).sort_... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227788",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,227,808 | <p>This is my code for a circular progress bar I made on a Next.js page. I want it to work where if I change the value of
"progressEndValue = 67," it would refresh the page and update the value on the progress bar. However, when I do this I get:
"Server Error
ReferenceError: document is not defined</p>
<p>This error happened while generating the page. Any console logs will be displayed in the terminal window."</p>
<p>"</p>
<pre><code>let circularProgress = document.querySelector(".circular-progress"),
| ^
53 | progressValue = document.querySelector(".progress-value");
54 |
55 | let progressStartValue = 0,
</code></pre>
<p>"
I need help to get this to work.</p>
<pre><code>
``
import { SearchIcon } from "@heroicons/react/outline";
import { useState } from "react";
import News from "./News";
import { AnimatePresence, motion } from "framer-motion";
import '../pages/_app';
import dynamic from 'next/dynamic'
<div className="text-gray-700 space-y-3 bg-gray-100 pt-2 rounded-xl w-[90%] xl:w-[75%]">
<h4 className="font-bold text-xl px-4">Capacity</h4>
<div class="container">
<div class="circular-progress">
<span class="progress-value">0%</span>
</div>
<span className="text">Test 1</span>
<div class="circular-progress">
<span className="progress-value">0%</span>
</div>
<span className="text">Test 2</span>
<div class="circular-progress">
<span className="progress-value">0%</span>
</div>
<span className="text">Test 3</span>
</div>
<button className="text-blue-300 pl-4 pb-3 hover:textblue-400">Show More</button>
</div>
</div>
)
}
let circularProgress = document.querySelector(".circular-progress"),
progressValue = document.querySelector(".progress-value");
let progressStartValue = 0,
progressEndValue = 67,
speed = 40;
let progress = setInterval(() =>{
progressStartValue++;
progressValue.textContent = `${progressStartValue}%`
circularProgress.style.background = `conic-gradient(#E0115F ${progressStartValue * 3.6}deg, #ededed 0deg)`
if(progressStartValue == progressEndValue){
clearInterval(progress);
}
console.log(progressStartValue);
}, speed);
</code></pre>
<p>I tried to use Dynamic from Next.js but I don't know how to work it.</p>
<p>This is the working code:</p>
<pre><code>import { SearchIcon } from "@heroicons/react/outline";
import { useState } from "react";
import News from "./News";
import { AnimatePresence, motion } from "framer-motion";
import dynamic from 'next/dynamic'
export default function Widgets({newsResults}) {
const[articleNum, setArticleNum] = useState(3);
return (
<div className="xl:w-[600px] hidden lg:inline ml-8 space-y-5">
<div className="w-[90%] xl:w-[75%] sticky top-0 bg-white py-1.5 z-50">
<div className="flex items-center p-3 rounded-full bg-red-300 relative">
<SearchIcon className="h-5 z-50 text-gray-500 "/>
<input className="absolute inset-0 rounded-full pl-11 border-gray-500 text-gray-700 focus:shadow-lg focus:bg-white bg-gray-100" type="text" placeholder="Search" />
</div>
</div>
{/* <div className="text-gray-700 space-y-3 bg-gray-100 rounded-xl pt-2 w-[90%] xl:w-[75%]">
<h4 className="font-bold text-xl px-4">Whats happening</h4>
<AnimatePresence>
{newsResults.slice(0,articleNum).map((article)=>(
<motion.div key={article.title} initial={{opacity: 0 }} animate={{opacity: 1}} exit={{opacity: 0}} transition={{duration: 1}}>
<News key={article.title} article={article}/>
</motion.div>
))}
</AnimatePresence>
<button onClick={()=>setArticleNum(articleNum + 3)} className="text-rose-300 pl-4 pb-3 hover:text-rose-400">Show more</button>
</div> */}
<div className="text-gray-700 space-y-3 bg-gray-100 pt-2 rounded-xl w-[90%] xl:w-[75%]">
<h4 className="font-bold text-xl px-4">Capacity</h4>
<div class="container">
<div class="circular-progress">
<span class="progress-value">0%</span>
</div>
<span className="text">test1</span>
<div class="circular-progress">
<span className="progress-value">0%</span>
</div>
<span className="text">test2</span>
<div class="circular-progress">
<span className="progress-value">0%</span>
</div>
<span className="text">test3</span>
<button className="text-rose-300 pl-4 pb-3 hover:text-rose-400">Show more</button>
</div>
</div>
</div>
)
}
</code></pre>
| [
{
"answer_id": 74227966,
"author": "Naveed",
"author_id": 3494754,
"author_profile": "https://Stackoverflow.com/users/3494754",
"pm_score": 3,
"selected": true,
"text": "\n# convert the values in the row to series, and sort, NaN moves to the end\ndf2=df.apply(lambda x: pd.Series(x).sort_... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227808",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20140123/"
] |
74,227,812 | <p><code>insert overwrite table test_data_type select name, decabs(cast(salary as double)) from test_data_type;</code></p>
<p>Hi here the data type of the salary is decimal(10,6) and i am trying to remove the trailing zeroes and insert the data into the same table, here the select is working but when i try to insert the data it is inserting with trailing zeros.
eg:- 10.21010
expected output in the table - 10.2101</p>
<p>Any suggestion thanks.</p>
| [
{
"answer_id": 74227966,
"author": "Naveed",
"author_id": 3494754,
"author_profile": "https://Stackoverflow.com/users/3494754",
"pm_score": 3,
"selected": true,
"text": "\n# convert the values in the row to series, and sort, NaN moves to the end\ndf2=df.apply(lambda x: pd.Series(x).sort_... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19567849/"
] |
74,227,813 | <p>I have an Excel file with three columns (Prefix, Feature, Values). All three are strings in Excel, but I need to turn the 'Values' entry from a string into a list when Prefix and Column equal the loop values.</p>
<p>Data looks like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Prefix</th>
<th>Feature</th>
<th>Value</th>
</tr>
</thead>
<tbody>
<tr>
<td>Prefix_1</td>
<td>Feature1</td>
<td>Value1,Value2,Value3</td>
</tr>
<tr>
<td>Prefix_1</td>
<td>Feature2</td>
<td>Value4,Value5</td>
</tr>
<tr>
<td>Prefix_1</td>
<td>Feature3</td>
<td>Value6,Value7,Value8,Value9</td>
</tr>
<tr>
<td>Prefix_2</td>
<td>Feature4</td>
<td>Value10</td>
</tr>
</tbody>
</table>
</div>
<p>It loops through all prefixes, then through all features, and I want to return the values in a list.</p>
<pre><code>parametric_values = str(filtered_input.loc[filtered_input.Feature==column,'Value']).split(',')
</code></pre>
<p><code>filtered_input</code> is a dataframe that is filtered to only the relevant prefixes and column is the value from the loop.</p>
<p>I would have expected parametric_values to be <code>['Value1','Value2','Value3']</code> for the first loop, but it returned as <code>['0 Value1', 'Value2', 'Value3\nName: Value', ' dtype: object']</code></p>
<p>I'm not sure why it returned a 0 to start with or the name and dtype object. What would I need to change with my code to get it to just return the values in the list?</p>
| [
{
"answer_id": 74227966,
"author": "Naveed",
"author_id": 3494754,
"author_profile": "https://Stackoverflow.com/users/3494754",
"pm_score": 3,
"selected": true,
"text": "\n# convert the values in the row to series, and sort, NaN moves to the end\ndf2=df.apply(lambda x: pd.Series(x).sort_... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227813",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4039994/"
] |
74,227,882 | <p>I fully admit it was not my best question Title.</p>
<p>I am trying to create a field that is a mean.</p>
<p>I have data below with an ID column that ranges from 1-5. The mean of any single value in the ID column is derived from values in the Value column for the single ID value and the two immediate prior values.</p>
<p>For ID 5, the mean would be all values in the Value column with an ID of 5, 4, and 3.</p>
<p>I am looking for something concise that calculates a mean for a single value in the ID column, based on a named range of values in the ID column, and populates the result only in the single value.</p>
<p>The only way I've found to do it so far is to filter the main dataset for the specific named range, get a mean for all rows of the filtered dataset, filter again to keep only the single ID value, then merge it back into the main dataset. That's long and messy and I have a lot of data.</p>
<p>Code is below to create an initial dataframe, then each step to get to the end result of df6.</p>
<p>Solutions with tidyverse would be vastly preferrable.</p>
<p>My initial thought was to use ifelse or case_when, but I quickly found that isolating specific values in the ID column and taking the mean of another column gets me the mean of everything in that other column and not the mean of the values specified by case or ifelse. I had thought about rowwise, which(), or a group_by that specifies values within a column, but could not get those to work.</p>
<pre><code>df1 <- data.frame(
`ID` = as.character(sample(1:5, 20, replace = TRUE)),
Value = sample(1:50, 20, replace = FALSE))
df1 %>%
mutate(MeanAll = mean(Value)) %>%
arrange(ID) -> df2
df1 %>%
filter(ID %in% c('5', '4', '3')) %>%
mutate(MeanID5 = mean(Value)) %>%
filter(ID == '5') %>%
distinct(ID, MeanID5) -> df3
df1 %>%
filter(ID %in% c('4', '3', '2')) %>%
mutate(MeanID4 = mean(Value)) %>%
filter(ID == '4') %>%
distinct(ID, MeanID4)-> df4
df1 %>%
filter(ID %in% c('3', '2','1')) %>%
mutate(MeanID3 = mean(Value)) %>%
filter(ID == '3') %>%
distinct(ID, MeanID3)-> df5
df1 %>%
left_join(df2, by = c('ID', 'Value')) %>%
left_join(df3, by = c('ID')) %>%
left_join(df4, by = c('ID')) %>%
left_join(df5, by = c('ID')) %>%
arrange(ID, Value) -> df6
</code></pre>
| [
{
"answer_id": 74227966,
"author": "Naveed",
"author_id": 3494754,
"author_profile": "https://Stackoverflow.com/users/3494754",
"pm_score": 3,
"selected": true,
"text": "\n# convert the values in the row to series, and sort, NaN moves to the end\ndf2=df.apply(lambda x: pd.Series(x).sort_... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227882",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7475830/"
] |
74,227,894 | <p>Compiles ok but Getting undefined in state. Appreciate any advice!</p>
<pre><code>customer_data = customer_data?.listCustomers[0];
console.log(customer_data?.sunday_open); /// returns 08:00:00
const [accountInfo, setAccountInfo] = useState({ "sunday_open_hours": customer_data?.sunday_open.split(":")[0],
"sunday_open_mins" : customer_data?.sunday_open.split(":")[1]});
console.log(accountInfo)
</code></pre>
<p>this code:</p>
<pre><code>console.log(accountInfo)
</code></pre>
<p>returns:</p>
<pre><code>{sunday_open_hours: undefined, sunday_open_mins: undefined}
</code></pre>
| [
{
"answer_id": 74228062,
"author": "DINO",
"author_id": 1836657,
"author_profile": "https://Stackoverflow.com/users/1836657",
"pm_score": 2,
"selected": true,
"text": "export default function App() {\n const [accountInfo, setAccountInfo] = useState({}) \n useEffect(() => {\n if (cus... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227894",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/884345/"
] |
74,227,895 | <p>How can I share the context that the test project created while running with the context of the web api? If the web api creates its context from environment variable, that will be different to that the unit test project creates. (In addition, I concat a guid to the database name, so as each test class have different database name that can run asynchron.)</p>
<p>Thank you.</p>
<p>This is how web api creates context in Program.cs</p>
<pre><code>var connectionString = Environment.GetEnvironmentVariable("ConnectionString");
builder.Services.AddDbContext<Context>(options =>
options.UseSqlServer(connectionString));
</code></pre>
<p>And this is how test project creates:</p>
<pre><code>public TestBase()
{
var connectionString = Environment.GetEnvironmentVariable("ConnectionString");
connectionString = connectionString.Replace("dbName", "dbName" + Guid.NewGuid());
var options = new DbContextOptionsBuilder<Context>()
.UseSqlServer(connectionString).Options;
context = new Context(options);
context.Database.Migrate();
}
</code></pre>
| [
{
"answer_id": 74228062,
"author": "DINO",
"author_id": 1836657,
"author_profile": "https://Stackoverflow.com/users/1836657",
"pm_score": 2,
"selected": true,
"text": "export default function App() {\n const [accountInfo, setAccountInfo] = useState({}) \n useEffect(() => {\n if (cus... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227895",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7355988/"
] |
74,227,922 | <p>I'm looking to do a simple import into Google sheets. My goal is to use an ImportHTML for <a href="https://www.recenter.tamu.edu/data/housing-activity/#!/activity/State/Texas" rel="nofollow noreferrer">this</a> table. However, i'm getting a very strange result, and was wondering if anyone had any solutions.</p>
<p>Thanks!</p>
<p>Current Code:</p>
<pre><code>=IMPORTHTML(A1, "table", 0)
</code></pre>
<p>Where Cell A1 is simply the link provided above (<a href="https://www.recenter.tamu.edu/data/housing-activity/#!/activity/State/Texas" rel="nofollow noreferrer">https://www.recenter.tamu.edu/data/housing-activity/#!/activity/State/Texas</a>)</p>
| [
{
"answer_id": 74229686,
"author": "Tanaike",
"author_id": 7108653,
"author_profile": "https://Stackoverflow.com/users/7108653",
"pm_score": 1,
"selected": false,
"text": "=SAMPLE(\"https://assets.recenter.tamu.edu/WebData/mls/sta/geo_state_id_26.data\")"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227922",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20178110/"
] |
74,227,973 | <p>How to concatenate four integer values into 1 integer?
For example:</p>
<pre><code>num1 = (some digit 1-9) 8
num2 = 5
num3 = 2
num4 = 6
</code></pre>
<p>I would like the output to be 8526. num1-4 are randomly generated.</p>
<pre><code>while (user > 0) {
int digit = user % 10;
user /= 10;
return user;
}
</code></pre>
| [
{
"answer_id": 74228030,
"author": "abelenky",
"author_id": 34824,
"author_profile": "https://Stackoverflow.com/users/34824",
"pm_score": 2,
"selected": false,
"text": "int numeric_concat(int num1, int num2, int num3, int num4)\n{\n num1 = 10*num1 + num2; // Num1 is now 86\n num1 =... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20352716/"
] |
74,227,977 | <p>I have this JSON file that stores Dokkan Passives for my Discord Bot for people to use and I recently added a Slash command where the user can Delete a passive based on the name they pass through it. If the name matches an entry in the JSON file then it can go ahead and delete the whole member from the JSON file, this is what I'm trying to do.</p>
<p>This is what part of my JSON File looks like</p>
<pre><code>{
"userPassiveStorage": "Storage for user created passives using /passivecreator",
"members": [
{
"membersJSONList": [],
"Error": null,
"UserName": ".",
"PassiveName": "TestTUR",
"Rarity": "TUR",
"UnitHP": 10000,
"UnitATK": 19234,
"UnitDEF": 14235,
"UnitLeaderName": "A TUR Passive",
"UnitLeaderSkill": 200,
"UnitPassiveATK": 250,
"UnitPassiveDEF": 150,
"DmgReduction": 30,
"Support": 30,
"Links": "No active Links"
},
{
"membersJSONList": [],
"Error": null,
"UserName": ".",
"PassiveName": "TEQ Jiren",
"Rarity": "LR",
"UnitHP": 20863,
"UnitATK": 21525,
"UnitDEF": 14338,
"UnitLeaderName": "Universe 11",
"UnitLeaderSkill": 170,
"UnitPassiveATK": 200,
"UnitPassiveDEF": 200,
"DmgReduction": 30,
"Support": 0,
"Links": "No active Links"
}
]
}
</code></pre>
<p>I will explain what I'm trying to get this command to do</p>
<ol>
<li>User passes in the name of the passive they are trying to delete (This is the "PassiveName" property in the JSON file)</li>
<li>Load the JSON and search for the passive based on that name</li>
<li>If there is no entry that matches their search query then stop the command</li>
<li>If there is a match, load that specific passive</li>
<li>Delete it from the JSON file</li>
</ol>
<p>This is my current method within a class where I can Load passives & hopefully Delete passives at the same time, it takes in a parameter object which loads in the already searched passive if Step 4 was successful</p>
<pre><code> public bool DeleteSpecificPassive(DokkanUserPassiveBuilder classObj)
{
try
{
//var path = @"C:\Users\samue\Documents\Bot\bin\Debug\UserPassivesStorage.json";
var path = @"D:\Visual Studio Projects\DiscordBotTest\bin\Debug\UserPassivesStorage.json";
var json = File.ReadAllText(path);
var jsonObj = JObject.Parse(json);
var members = jsonObj["members"].ToObject<List<DokkanUserPassiveBuilder>>();
if (members.Contains(classObj))
{
members.Remove(classObj);
jsonObj["members"] = JArray.FromObject(members);
File.WriteAllText(path, jsonObj.ToString());
return true;
}
else
{
return false;
}
}
catch (Exception ex)
{
Console.WriteLine(ex);
Error = ex.ToString();
return false;
}
}
</code></pre>
<p>For some reason, when I type in a correct passive name like "TEQ Jiren", even though it exists in the list, the if statement comparing the user input with the JSON file doesn't work and goes to the else block instead. So how can I get it so that the user input and the member in the class are compared and if it exists in the List then delete it and rewrite the JSON file?</p>
<p>If you want to view the full class for the bigger picture the Discord Bot is in my GitHub repo where I carry out these commands -></p>
<p>[DokkanUserPassivesBuilder.cs] (<a href="https://github.com/samjesus8/CoolerDiscordBot/blob/master/Builders/DokkanUserPassiveBuilder.cs" rel="nofollow noreferrer">https://github.com/samjesus8/CoolerDiscordBot/blob/master/Builders/DokkanUserPassiveBuilder.cs</a>)</p>
| [
{
"answer_id": 74228030,
"author": "abelenky",
"author_id": 34824,
"author_profile": "https://Stackoverflow.com/users/34824",
"pm_score": 2,
"selected": false,
"text": "int numeric_concat(int num1, int num2, int num3, int num4)\n{\n num1 = 10*num1 + num2; // Num1 is now 86\n num1 =... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11057786/"
] |
74,227,979 | <p>Allocate a dynamic variable using malloc() increment that count until a seg fault occurs. Then print out the memory addresses until the fault occurs so that the faulting address is output.</p>
<p>Note address should be printed before the access that causes the seg fault.</p>
<p>This is what I have tried so far. So far it seems it runs indefinitely.</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
int main(){
char * ptr = malloc(1);
while(1){
printf(" Address is %p\n", ptr++);
}
return 0;
}
</code></pre>
| [
{
"answer_id": 74228284,
"author": "Cheatah",
"author_id": 210623,
"author_profile": "https://Stackoverflow.com/users/210623",
"pm_score": 2,
"selected": false,
"text": "SIGSEGV"
},
{
"answer_id": 74228416,
"author": "Cheatah",
"author_id": 210623,
"author_profile": "... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74227979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12882705/"
] |
74,228,006 | <p>How to integrate Replace in this Private Sub?</p>
<p>I need to replace all words "NONE" with "":</p>
<pre><code>Private Sub UpdateSKU()
Dim str As String
str = Me.Combo216.Column(1) & Space(1) & Me.Combo224.Column(1) & Space(1)
Me.Text423.Value = str
End Sub
</code></pre>
<p>I have tried</p>
<pre><code>Private Function NONE(a As String)
If InStr(a, "NONE") > 0 Then
MsgBox "Original: " & a & vbCrLf & "Adjusted: " & Replace(a, "NONE", "")
End If
End Function
</code></pre>
<p>But I can't get it to work.</p>
| [
{
"answer_id": 74228284,
"author": "Cheatah",
"author_id": 210623,
"author_profile": "https://Stackoverflow.com/users/210623",
"pm_score": 2,
"selected": false,
"text": "SIGSEGV"
},
{
"answer_id": 74228416,
"author": "Cheatah",
"author_id": 210623,
"author_profile": "... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228006",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20334367/"
] |
74,228,014 | <p>I have a table with the following column:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>server</th>
</tr>
</thead>
<tbody>
<tr>
<td>SLQ-ABCD-001</td>
</tr>
<tr>
<td>SLQ-ABCA-002</td>
</tr>
<tr>
<td>SLP-DBMSA-003</td>
</tr>
<tr>
<td>SLD-ABC-004</td>
</tr>
<tr>
<td>SLS-123456-005</td>
</tr>
</tbody>
</table>
</div>
<p>I would like to be able to filter the rows based on a substring of this column, specifically, the string between those hyphens; there will always be three characters before the first hyphen and three characters after the second hyphen.</p>
<p>Here's what I have tried:</p>
<ol>
<li><code>AND substring(server, 5, (len(server)-8)) in ('ABC', 'DBMSA')</code></li>
<li><code>AND substring(server, charindex('-', server)+1,(charindex('-',server, charindex('-', server)+1)-(charindex('-', server)+1))) in ('ABC', 'DBMSA')</code></li>
</ol>
<p>Both of these work perfectly fine (expected substrings obtained) when used in the SELECT clause but give the error below</p>
<blockquote>
<p>Invalid length parameter passed to the LEFT or SUBSTRING function.</p>
</blockquote>
<p>I am not able to use the more simpler way, AND server like '%ABC%' as I have more than one combination of characters I'm looking for and also, because that comma separated list will be dynamically parsed in that query for this use case.</p>
<p>Is there any way this type of filter can be achieved in SQL Server?</p>
<p><strong>EDIT</strong></p>
<p>After @DaleK helped me realize that the issue might be I might have some bad data (server names with length < 8) and that I might have missed them when I tested the expression in the SELECT clause since I might have some other filters in my WHERE clause, here's how I had managed to get around that</p>
<pre><code>SELECT *
from
(SELECT *
from my_original_table
where
--all my other filters that helped me eliminate the bad data
) my_filtered_table
where substring(server, 5, (len(server)-8)) in ('ABC', 'DBMSA');
</code></pre>
<p>As for the "question being duplicate" part, I think the error in <a href="https://stackoverflow.com/questions/73138288/why-is-it-that-a-change-in-query-plan-suddenly-seems-to-break-a-query">that question</a> is encountered in SELECT statement where as in my case, the expression worked fine in the SELECT statement and only errored when used in the WHERE clause.</p>
<p>For solution, the one provided by @Isolated seems to work perfectly fine!</p>
| [
{
"answer_id": 74228284,
"author": "Cheatah",
"author_id": 210623,
"author_profile": "https://Stackoverflow.com/users/210623",
"pm_score": 2,
"selected": false,
"text": "SIGSEGV"
},
{
"answer_id": 74228416,
"author": "Cheatah",
"author_id": 210623,
"author_profile": "... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228014",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8438946/"
] |
74,228,060 | <p>I am trying to sort a vector of strings {"Josh 67", "Emily 42", "Rich 14", "Janet 1"} based on the age provided along with the names. I don't wanna use any loops and want to use STL Algorithms and lambda function to sort it.</p>
<pre><code>auto SortString = [](string a, string b)
{
return a > b;
};
vector<string> SortedByAge(vector<string> unsorted)
{
sort(unsorted.begin(), unsorted.end(), SortString);
return unsorted;
}
int main()
{
vector<string> result = SortedByAge({"Josh 67", "Emily 42", "Rich 14", "Janet 1"});
for(auto x : result)
{
cout << x << endl;
}
}
</code></pre>
<p>This is the code I have so far, however, it does not seem to be working. I would appreciate any help.</p>
| [
{
"answer_id": 74228165,
"author": "Vlad from Moscow",
"author_id": 2877241,
"author_profile": "https://Stackoverflow.com/users/2877241",
"pm_score": 1,
"selected": false,
"text": "sscanf"
},
{
"answer_id": 74228573,
"author": "Maria23",
"author_id": 7123378,
"author_... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228060",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15619607/"
] |
74,228,069 | <p>I have a SQL Table with columns of</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Timestamp</th>
<th>Region</th>
</tr>
</thead>
<tbody>
<tr>
<td>2022-10-06 01:00:00.0000000</td>
<td>East</td>
</tr>
<tr>
<td>2022-10-06 03:00:00.0000000</td>
<td>East</td>
</tr>
<tr>
<td>2022-10-06 05:00:00.0000000</td>
<td>West</td>
</tr>
<tr>
<td>2022-10-06 01:00:00.0000000</td>
<td>East</td>
</tr>
<tr>
<td>2022-10-07 05:00:00.0000000</td>
<td>West</td>
</tr>
<tr>
<td>2022-10-08 05:00:00.0000000</td>
<td>East</td>
</tr>
<tr>
<td>2022-10-09 01:00:00.0000000</td>
<td>West</td>
</tr>
<tr>
<td>2022-10-09 01:00:00.0000000</td>
<td>East</td>
</tr>
</tbody>
</table>
</div>
<p>So I want to group the table by 'Day' and 'Region'</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Timestamp</th>
<th>Region</th>
<th>Count</th>
</tr>
</thead>
<tbody>
<tr>
<td>2022-10-06</td>
<td>East</td>
<td>3</td>
</tr>
<tr>
<td>2022-10-06</td>
<td>West</td>
<td>1</td>
</tr>
<tr>
<td>2022-10-07</td>
<td>West</td>
<td>1</td>
</tr>
<tr>
<td>2022-10-08</td>
<td>East</td>
<td>1</td>
</tr>
<tr>
<td>2022-10-09</td>
<td>West</td>
<td>1</td>
</tr>
<tr>
<td>2022-10-09</td>
<td>East</td>
<td>1</td>
</tr>
</tbody>
</table>
</div>
<p>So I try this with SQL</p>
<pre><code>SELECT
[region],
CONCAT( datepart(YEAR, [Timestamp]), '-', datepart(MONTH, [Timestamp]), '-', datepart(DAY, [Timestamp])) AS dayEvent,
FROM Table
GROUP BY [region], [dayEvent]
</code></pre>
<p>But I get error saying 'Timestamp is invalid in the select list because it is not contained in either an aggregate function or the GROUP BY clause.'</p>
<p>Can u please tell me how can I fix this?</p>
| [
{
"answer_id": 74228258,
"author": "DannySlor",
"author_id": 19174570,
"author_profile": "https://Stackoverflow.com/users/19174570",
"pm_score": 1,
"selected": false,
"text": "cast(Timestamp as date)"
},
{
"answer_id": 74228281,
"author": "Stu",
"author_id": 15332650,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228069",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14396579/"
] |
74,228,080 | <p>I am trying to write a regular expression that removes all non alphanumeric characters from a string, except for those that are surrounded by alphanumeric characters.</p>
<p>For example, consider the following three examples.</p>
<p>1.</p>
<p><code>it's</code> -> <code>it's</code></p>
<p>2.</p>
<p><code>its.</code> -> <code>its</code></p>
<p>3.</p>
<p><code>It's a: beautiful day? I'm =sure it is. The coca-cola (is frozen right?</code></p>
<p><code>It's a beautiful day I'm sure it is The coca-cola is frozen right</code></p>
<p>I am using Python's re module, and can match the opposite of what I am looking for with the following expression.</p>
<p><code>(?<=[a-zA-Z])[^a-zA-Z ](?=[a-zA-Z])</code></p>
<p>Any ideas?</p>
| [
{
"answer_id": 74228131,
"author": "Ryszard Czech",
"author_id": 11329890,
"author_profile": "https://Stackoverflow.com/users/11329890",
"pm_score": 1,
"selected": true,
"text": "[^a-zA-Z\\s](?!(?<=[a-zA-Z].)[a-zA-Z])\n"
},
{
"answer_id": 74228546,
"author": "The fourth bird"... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228080",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14722297/"
] |
74,228,088 | <p>Using Node & Axios</p>
<p><strong>What I Want to Do</strong></p>
<p>In my <code>server.js</code> file, I want to call an api for a token that always changes, use axios (or other solution) to create a global token variable, and provide the global token to an app.get request header within an object, again, all within my server.js file.</p>
<p><strong>What I'm Trying</strong></p>
<p>I get the data using...</p>
<pre><code>var data = '<tsRequest>\r\n\t<credentials name="name" password="pword">\r\n\t\t<site contentUrl="" />\r\n\t</credentials>\r\n</tsRequest>';
var config = {
method: 'post',
url: 'https://url.uni.edu/api/3.13/auth/signin',
headers: {
'Content-Type': 'text/plain'
},
data : data
};
</code></pre>
<p>I try to create the global token variable (this is where I'm struggling)...</p>
<pre><code>const token= axios(config)
.then((response) => {
console.log(response.data.credentials.token);
}).catch((err) => {
console.log(err);
});
console.log(token)
</code></pre>
<p>I have a functioning app.get request where instead of manually providing the token, I want to use the <strong>const token</strong>...</p>
<pre><code>app.get('/gql', async (req, res) => {
var someObject = {
'method': 'POST',
'url': 'https://diffurl.uni.edu/api/metadata/graphql',
'headers': {
'X-Some-Auth': token,
'Content-Type': 'application/json'
},
</code></pre>
<p><strong>The Current Results</strong></p>
<p>What I have for the <strong>var data =</strong> and the <strong>var config =</strong> and the <strong>axios(config)</strong> all work to return the token via console.log, but I have 2 issues using axios.</p>
<p><strong>The Axios Issues</strong></p>
<ol>
<li><p>In my hopes of creating a global token variable, I only understand how to get a <strong>console.log</strong> result instead of returning a 'useful data object'.
In just about every piece of documentation or help found, the example uses console.log, which is not a practical example for learners to move beyond just returning the data in their console.
What do I need to provide in axios to create a global token object in addition to or instead of console.log?</p>
</li>
<li><p>I realize 1. is my current blocker, but if I run my app, I get the following:</p>
</li>
</ol>
<pre><code>Promise { <pending> }
Express server running on port 1234
abc123 [the console.logged token via axios]
</code></pre>
<p>I'm not sure what the <code>Promise { <pending> }</code> means, how do I fix that?</p>
<p><strong>Beyond The Axios Issues</strong></p>
<p>If the axios problem is fixed, am I passing the <code>const token</code> correctly into my <code>app.get... var someObject... headers</code>?</p>
<p>Thank you for any help you can provide.</p>
| [
{
"answer_id": 74228131,
"author": "Ryszard Czech",
"author_id": 11329890,
"author_profile": "https://Stackoverflow.com/users/11329890",
"pm_score": 1,
"selected": true,
"text": "[^a-zA-Z\\s](?!(?<=[a-zA-Z].)[a-zA-Z])\n"
},
{
"answer_id": 74228546,
"author": "The fourth bird"... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1597177/"
] |
74,228,106 | <p>I am working on an Ubuntu 22.04 desktop using AWS CLI. I am trying to upload ALL files located in a specific local directory to our S3 bucket using AWS CLI but I'm getting an error. Here is my command and the error:</p>
<pre><code>ms@ms01:~$ aws s3 cp /home/ms/Downloads/TWU/mp3/ s3://abc.org/v2/ –-recursive
</code></pre>
<p>The error I'm getting is: <strong>Unknown options: --recursive</strong></p>
<p>Any help/direction would be appreciated. Thanks.</p>
| [
{
"answer_id": 74228394,
"author": "John Rotenstein",
"author_id": 174777,
"author_profile": "https://Stackoverflow.com/users/174777",
"pm_score": 2,
"selected": false,
"text": "--recursive"
},
{
"answer_id": 74570897,
"author": "amirhossein nazary",
"author_id": 18032364... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228106",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2635634/"
] |
74,228,111 | <p>I can't figure out how to create a dictionary that will be based on an input of a list of whole numbers (<em>no problem with getting the input</em>) and have the list indexes as keys and input data as values.</p>
<p>For example if the input is <code>[75, 48, 23, 89]</code> then the end result should be <code>[(0, 75), (1, 48), (2, 23), (3, 89)]</code>.</p>
| [
{
"answer_id": 74228124,
"author": "lmiguelvargasf",
"author_id": 3705840,
"author_profile": "https://Stackoverflow.com/users/3705840",
"pm_score": 1,
"selected": false,
"text": "enumerate"
},
{
"answer_id": 74228174,
"author": "crawler-lab.de",
"author_id": 15032441,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228111",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20352757/"
] |
74,228,155 | <p>I have a 2D transformation problem in OpenGL. My program draws two letters on screen and, by pressing assigned keys, letters have to move up (GLUT_KEY_UP) down (GLUT_KEY_DOWN) left (GLUT_KEY_LEFT) right (GLUT_KEY_RIGHT) and rotate CW (GLUT_KEY_HOME) and CCW (GLUT_KEY_END). (On keys GLUT_KEY_PAGE_UP and GLUT_KEY_PAGE_DOWN both letters rotate around their own centers simultaniously in oposite directions, pressing e.g. GLUT_KEY_UP after GLUT_KEY_PAGE_UP moves both letters in a correct direction).</p>
<p>I can't make the letters do the correct movement (up, down, left or right) after the objects had been rotated with GLUT_KEY_HOME or GLUT_KEY_END:</p>
<pre class="lang-cpp prettyprint-override"><code>case GLUT_KEY_HOME: //rotate clockwise around the center of the model
glMatrixMode(GL_MODELVIEW);
setRotationMatrix(-angle, modelSizeX, modelSizeY);
glMultMatrixf(rotationMatrix); // multiply current Modelview Matrix by rotate-and-translate matrix
display();
break;
</code></pre>
<p>Function that 'sets' the rotation matrix inserts angle and rotation point into Identity matrix [4x4]:</p>
<pre class="lang-cpp prettyprint-override"><code>void setRotationMatrix(float theta, float x0, float y0)
{
theta = theta * (2 * acos(0.0)) / 180; // convert theta from degrees to radian
rotationMatrix[0] = cos(theta);
rotationMatrix[1] = sin(theta);
rotationMatrix[4] = -sin(theta);
rotationMatrix[5] = cos(theta);
rotationMatrix[12] = ((x0 * 0.5f) * (1 - cos(theta)) + (y0 * 0.5f) * sin(theta));
rotationMatrix[13] = ((y0 * 0.5f) * (1 - cos(theta)) - (x0 * 0.5f) * sin(theta));
}
</code></pre>
<p>After the objects have been rotated, if I press KEY_UP, they move not 'up' (in normal direction against x axis ) but in the direction normal to the horizontal plane of the object after rotation (slightly sideways).</p>
<pre class="lang-cpp prettyprint-override"><code>case GLUT_KEY_UP:
glMatrixMode(GL_MODELVIEW);
glTranslated(0, delta, 0);
display();
break;
</code></pre>
<p>how do I make it move straightly to the 'north', meaning, not the 'north' of the object but the 'north' of my coordinate system?</p>
<pre class="lang-cpp prettyprint-override"><code>#include <Windows.h>
#include <GL/glut.h>
#include <vector>
#include <fstream>
#include <cmath>
using namespace std;
#define EscKey 27
#define PlusKey 43
#define MinusKey 45
struct Point
{
int x, y;
};
double pi = 2 * acos(0.0);
void reshape(int w, int h);
void display();
void drawInitials();
void processNormalKeys(unsigned char key, int x, int y);
void processSpecialKeys(int key, int x, int y);
void setRotationMatrix(float theta, float x0, float y0);
void readFromFile();
void lineto(Point p);
void moveto(Point p);
void drawM();
void drawJ();
vector <Point> point;
vector <int> code;
Point currentPoint;
int modelSizeX = 202; int modelSizeY = 89;
int letterMSizeX = 107; int letterJSizeX = 78;
int delta = 5; // movement size
float zoomRate = 0.1; // scale-and-translate rate: 0.1 = resize by 10%
float angle = 1, rotaterR = 1 * pi / 180, rotater, angleCount = 0.0; // saved rotation angle
GLfloat modelviewStateMatrix[16];
int windowSizeX, windowSizeY;
boolean separate = false;
float rotationMatrix[16] = { 1.0f, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
0.0f, 0.0f, 0.0f, 1.0f };
float plusKeyMatrix[16] = { 1.0f + zoomRate, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f + zoomRate, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
-(modelSizeX * zoomRate * 0.5f), -(modelSizeY * zoomRate * 0.5f), 0.0f, 1.0f };
float minusKeyMatrix[16] = { 1.0f - zoomRate, 0.0f, 0.0f, 0.0f,
0.0f, 1.0f - zoomRate, 0.0f, 0.0f,
0.0f, 0.0f, 1.0f, 0.0f,
modelSizeX * zoomRate * 0.5f, modelSizeY * zoomRate * 0.5f, 0.0f, 1.0f };
void readFromFile()
{
fstream f("initials_points_2.txt", ios::in);
int pointNumber;
Point p;
f >> pointNumber;
for (int i = 0; i < pointNumber;i++)
{
f >> p.x >> p.y;
point.push_back(p);
}
int movesNumber, m;
f >> movesNumber;
for (int i = 0; i < movesNumber; i++)
{
f >> m; code.push_back(m);
}
f.close();
}
void moveto(Point p)
{
currentPoint.x = p.x; currentPoint.y = p.y;
}
void lineto(Point p)
{
glBegin(GL_LINES);
glVertex2i(currentPoint.x, currentPoint.y);
glVertex2i(p.x, p.y);
glEnd();
currentPoint.x = p.x; currentPoint.y = p.y;
}
void setRotationMatrix(float theta, float x0, float y0)
{
theta = theta * (2 * acos(0.0)) / 180; // convert theta from degrees to radian
rotationMatrix[0] = cos(theta);
rotationMatrix[1] = sin(theta);
rotationMatrix[4] = -sin(theta);
rotationMatrix[5] = cos(theta);
rotationMatrix[12] = ((x0 * 0.5f) * (1 - cos(theta)) + (y0 * 0.5f) * sin(theta));
rotationMatrix[13] = ((y0 * 0.5f) * (1 - cos(theta)) - (x0 * 0.5f) * sin(theta));
}
void drawM()
{
int i = 1;
moveto(point[0]);
while (code[i] > 0 && i < code.size())
{
lineto(point[code[i] - 1]);
i++;
}
glBegin(GL_LINES);
glVertex3f(0.0, 0.0, 0.0);
glVertex3f(letterMSizeX, 0.0, 0.0);
glVertex3f(letterMSizeX, 0.0, 0.0);
glVertex3f(letterMSizeX, modelSizeY, 0.0);
glVertex3f(letterMSizeX, modelSizeY, 0.0);
glVertex3f(0.0, modelSizeY, 0.0);
glVertex3f(0.0, modelSizeY, 0.0);
glVertex3f(0.0, 0.0, 0.0);
glEnd();
glColor3f(0.0, 1.0, 0.0);
glBegin(GL_LINES);
glVertex2i(0, 0); glVertex2i(letterMSizeX, modelSizeY);
glVertex2i(letterMSizeX, 0); glVertex2i(0, modelSizeY);
glEnd();
}
void drawJ()
{
glColor3f(1.0, 0.0, 0.0);
int i = 14;
moveto(point[-1 * (code[i]) - 1]);
i++;
while (i < code.size())
{
lineto(point[code[i] - 1]);
i++;
}
glBegin(GL_LINES);
glVertex3f((modelSizeX - letterJSizeX), 0.0, 0.0);
glVertex3f((modelSizeX - letterJSizeX), modelSizeY, 0.0);
glVertex3f((modelSizeX - letterJSizeX), modelSizeY, 0.0);
glVertex3f(modelSizeX, modelSizeY, 0.0);
glVertex3f(modelSizeX, modelSizeY, 0.0);
glVertex3f(modelSizeX, 0.0, 0.0);
glVertex3f(modelSizeX, 0.0, 0.0);
glVertex3f((modelSizeX - letterJSizeX), 0.0, 0.0);
glEnd();
glColor3f(0.0, 1.0, 0.0);
glBegin(GL_LINES);
glVertex2i(letterMSizeX + 17, 0); glVertex2i(modelSizeX, modelSizeY);
glVertex2i(letterMSizeX + 17, modelSizeY); glVertex2i(modelSizeX, 0);
glEnd();
}
void drawInitials()
{
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
setRotationMatrix(-rotater, letterMSizeX, modelSizeY);
glMultMatrixf(rotationMatrix); // multiply current Modelview Matrix by rotate-and-translate matrix
drawM();
glTranslatef(-letterMSizeX * 0.5, -modelSizeY * 0.5, 0);
glPopMatrix();
glPushMatrix();
glTranslatef((modelSizeX - letterJSizeX), 0, 0);
setRotationMatrix(rotater, letterJSizeX, modelSizeY);
glMultMatrixf(rotationMatrix); // multiply current Modelview Matrix by rotate-and-translate matrix
glTranslatef(-(modelSizeX - letterJSizeX), 0, 0);
drawJ();
glPopMatrix();
}
void processNormalKeys(unsigned char key, int x, int y)
{
switch (key)
{
case EscKey:
exit(0);
break;
case PlusKey: // "zoom in"
glMatrixMode(GL_MODELVIEW);
glMultMatrixf(plusKeyMatrix); // multiply current Modelview Matrix by scale-and-translate matrix
display();
break;
case MinusKey: // "zoom out"
glMatrixMode(GL_MODELVIEW);
glMultMatrixf(minusKeyMatrix); // multiply current Modelview Matrix by scale-and-translate matrix
display();
break;
}
}
void processSpecialKeys(int key, int x, int y) {
switch (key) {
case GLUT_KEY_UP:
glMatrixMode(GL_MODELVIEW);
glTranslated(0, delta, 0);
display();
break;
case GLUT_KEY_DOWN:
glMatrixMode(GL_MODELVIEW);
glTranslated(0, -delta, 0);
display();
break;
case GLUT_KEY_LEFT:
glMatrixMode(GL_MODELVIEW);
glTranslated(-delta, 0, 0);
display();
break;
case GLUT_KEY_RIGHT:
glMatrixMode(GL_MODELVIEW);
glTranslated(delta, 0, 0);
display();
break;
case GLUT_KEY_HOME: //rotate clockwise around the center of the model
glMatrixMode(GL_MODELVIEW);
setRotationMatrix(-angle, modelSizeX, modelSizeY);
glMultMatrixf(rotationMatrix); // multiply current Modelview Matrix by rotate-and-translate matrix
display();
break;
case GLUT_KEY_END: //rotate counterclockwise around the center of the model
glMatrixMode(GL_MODELVIEW);
setRotationMatrix(angle, modelSizeX, modelSizeY);
glMultMatrixf(rotationMatrix); // multiply current Modelview Matrix by rotate-and-translate matrix
display();
break;
case GLUT_KEY_PAGE_UP:
rotater -= rotaterR;
if (rotater <= -2 * pi)
rotater += 2 * pi;
display();
break;
case GLUT_KEY_PAGE_DOWN:
rotater += rotaterR;
if (rotater >= 2 * pi)
rotater -= 2 * pi;
display();
break;
}
}
int main(int argc, char* argv[])
{
currentPoint.x = 0; currentPoint.y = 0;
readFromFile();
glutInit(&argc, argv);
glutInitDisplayMode(GLUT_SINGLE | GLUT_RGB);
glutInitWindowSize(800, 600);
glutInitWindowPosition(100, 150);
glutCreateWindow("OpenGL lab");
glutDisplayFunc(display);
glutReshapeFunc(reshape);
glutKeyboardFunc(processNormalKeys);
glutSpecialFunc(processSpecialKeys);
glutMainLoop();
return 0;
}
void reshape(int w, int h)
{
glViewport(0, 0, w, h);
glMatrixMode(GL_PROJECTION);
glLoadIdentity();
windowSizeX = w;
windowSizeY = h;
gluOrtho2D(-modelSizeX, modelSizeX * 2, -modelSizeY, modelSizeY * 2); // World size
}
void display()
{
glClearColor(1, 1, 1, 0);
glClear(GL_COLOR_BUFFER_BIT);
glMatrixMode(GL_MODELVIEW);
glPushMatrix();
glLoadIdentity();
glColor3f(0.0, 0.0, 1.0);
glBegin(GL_LINES);
glVertex2i(-windowSizeX, 0); glVertex2i(windowSizeX, 0);
glVertex2i(0, -windowSizeY); glVertex2i(0, windowSizeY);
glEnd();
glPopMatrix();
glColor3d(1, 0, 0);
drawInitials();
glPointSize(5);
glBegin(GL_POINTS);
glVertex3f(modelSizeX * 0.5, modelSizeY * 0.5, 0.0);
glVertex3f(letterMSizeX * 0.5, modelSizeY * 0.5, 0.0);
glVertex3f(letterJSizeX * 0.5 + letterMSizeX + 17, modelSizeY * 0.5, 0.0);
glEnd();
glFlush();
}
</code></pre>
<p>vertices file: <a href="https://github.com/vespertinetale/LR3/blob/df2af8755a80c473d2b6dd0e2bf560388d6a2696/initials_points_2.txt" rel="nofollow noreferrer">initials_points_2.txt</a></p>
<p>I was trying to:</p>
<ul>
<li>encapsulate _HOME/_END rotation with glPushMatrix()/glPopMatrix()</li>
<li>revert the rotation after the drawal of the object by multiplying MODELVIEW matrix with (-angle, same point)</li>
<li>was trying to drop glMultMatrix() and use glTranslate(), glRotate()</li>
</ul>
<p>none of them had worked as I intended</p>
| [
{
"answer_id": 74228124,
"author": "lmiguelvargasf",
"author_id": 3705840,
"author_profile": "https://Stackoverflow.com/users/3705840",
"pm_score": 1,
"selected": false,
"text": "enumerate"
},
{
"answer_id": 74228174,
"author": "crawler-lab.de",
"author_id": 15032441,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228155",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5959176/"
] |
74,228,163 | <p>Let's say that I created some Rust source code that combines lots of duplicate string literals. Are they de-duplicated during the compilation process?</p>
| [
{
"answer_id": 74228124,
"author": "lmiguelvargasf",
"author_id": 3705840,
"author_profile": "https://Stackoverflow.com/users/3705840",
"pm_score": 1,
"selected": false,
"text": "enumerate"
},
{
"answer_id": 74228174,
"author": "crawler-lab.de",
"author_id": 15032441,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/395287/"
] |
74,228,265 | <p>I would like to return only the id of each div and keep them in an array :</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>const projects = [...document.getElementsByClassName("nav-project")];
console.log(projects);
//expected output : [one, two, three, four, five]</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="nav-project" id="one">a</div>
<div class="nav-project" id="two">b</div>
<div class="nav-project" id="three">c</div>
<div class="nav-project" id="four">d</div>
<div class="nav-project" id="five">e</div></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74228283,
"author": "aloisdg",
"author_id": 1248177,
"author_profile": "https://Stackoverflow.com/users/1248177",
"pm_score": 3,
"selected": true,
"text": "map()"
},
{
"answer_id": 74228296,
"author": "Ori Drori",
"author_id": 5157454,
"author_profile":... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228265",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9011747/"
] |
74,228,293 | <p>I have a data frame with months (by year), and ID number. I am trying to calculate the attrition rate, but I am getting stuck on obtaining unique ID counts when a month equals a certain month in pandas.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>ID.</th>
<th>Month</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Sept. 2022</td>
</tr>
<tr>
<td>2</td>
<td>Oct. 2022</td>
</tr>
</tbody>
</table>
</div>
<p>etc... with possible duplicates in ID and 1.75 years worth of data.</p>
<pre><code>import pandas as pd
path = some path on my computer
data = pd.read_excel(path)
if data["Month"] == "Sept. 2022":
ID_SEPT = data["ID."].unique()
return ID_SEPT
</code></pre>
<p>I am trying to discover what I am doing incorrect here in this if-then statement. Ideally I am trying to collect all the unique ID values per each month per year to then calculate the attrition rate. Is there something obvious I am doing wrong here?</p>
<p>Thank you.</p>
<p>I tried an id-then statement and I was expecting unique value counts of ID per month.</p>
| [
{
"answer_id": 74228343,
"author": "Adam Prime",
"author_id": 10968521,
"author_profile": "https://Stackoverflow.com/users/10968521",
"pm_score": 1,
"selected": false,
"text": "for (columnName, columnData) in data.iteritems():\n if columnName = 'Month'\n [code]\n"
},
{
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228293",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20352873/"
] |
74,228,314 | <p>I am using C# for the first time and my goal is to create an application that outputs text to a window. The windows structure is defined in a .XAML file and the text in question is to be added to a RichTextBox. Depending on the content of the string to be appended I want the text color to be different. I.E if the string contains the word "passed" I want the text to be green and red if it contains "failed". I have found a method that almost works but instead changes the color of all the text in the box instead of just the desired line.</p>
<p>The name of the RichTextBox is "TextResults" as shown below:
<a href="https://i.stack.imgur.com/tssK2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tssK2.png" alt="enter image description here" /></a></p>
<p>I have used the ForeGround property and assigned it to a SolidColorBrush object</p>
<pre><code> if (dispText[1].Contains("passed")) textResults.Foreground = new SolidColorBrush(Colors.Green);
else if (dispText[1].Contains("failed")) textResults.Foreground = new SolidColorBrush(Colors.Red);
else textResults.Foreground = new SolidColorBrush(Colors.Black);
textScript.AppendText(dispText[0] + Environment.NewLine);
textResults.AppendText(dispText[1] + Environment.NewLine);
</code></pre>
<p>The problem is, this method applies the color to all strings in the RichTextBox, so assuming the final string contains "failed", all the text goes red.
<a href="https://i.stack.imgur.com/r190i.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/r190i.png" alt="Output" /></a></p>
<p>I have looked online at lots of different methods and none seem to help, this is my first stack overflow post so apologies if I have committed any sins in this post. Any help would be much appreciated.</p>
| [
{
"answer_id": 74228343,
"author": "Adam Prime",
"author_id": 10968521,
"author_profile": "https://Stackoverflow.com/users/10968521",
"pm_score": 1,
"selected": false,
"text": "for (columnName, columnData) in data.iteritems():\n if columnName = 'Month'\n [code]\n"
},
{
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228314",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20352816/"
] |
74,228,334 | <p>I have an array with lists:</p>
<pre><code>[ [ 1, 2 ], [ 3, 5 ], [ 2, 5 ], [ 3, 5 ], [ 1, 2 ] ]
</code></pre>
<p>The output im expecting is:</p>
<pre><code>[ [ 1, 2 ], [ 3, 5 ] ]
</code></pre>
<p>Im not able to iterate and find duplicates when we have lists in an array.</p>
| [
{
"answer_id": 74228343,
"author": "Adam Prime",
"author_id": 10968521,
"author_profile": "https://Stackoverflow.com/users/10968521",
"pm_score": 1,
"selected": false,
"text": "for (columnName, columnData) in data.iteritems():\n if columnName = 'Month'\n [code]\n"
},
{
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228334",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12186851/"
] |
74,228,353 | <pre><code>#include <stdio.h>
#include <stdlib.h>
typedef struct node{
int number;
struct node* next;
}
node;
int main(void){
node* list = NULL;
node *n = malloc(sizeof(node));
if(n==NULL){
return 1;
}
n->number = 2;
n-> next = NULL;
list = n;
n = malloc(sizeof(node));
if(n == NULL){
free(list);
return 1;
}
n->number = 3;
n->next = NULL;
list->next = n;
n = malloc(sizeof(node));
if(n == NULL){
free(list->next);
free(list);
}
n->number = 4;
n->next = NULL;
list->next->next =n;
n = malloc(sizeof(node));
if(n!=NULL){
n->number = 0;
n->next = NULL;
n->next = list;
list = n;
}
for( node* tmp = list; tmp != NULL; tmp->next){
printf("%i\n" , tmp->number);
}
while(list!=NULL){
node*tmp = list->next;
free(list);
list=tmp;
}
}
</code></pre>
<p>was trying linked list.
expected when running the code:
0
1
2
3
4
$
//asdoihasidashiofdhiohdfgdiwheifiopioioiophfaifjasklfhafiashfauiosfhwuiohwefuiowhfaslfidasdaskdasjdlaksdjqwfiqpweiojfkldfjsdfklwhefiowefweopfiosfkosid;fjwdfp;fdasiopfjew[0fowejfwepfojmofejmiwrfgj;wdfjewio;fijwefjsdp;jfkl;wjw</p>
| [
{
"answer_id": 74228343,
"author": "Adam Prime",
"author_id": 10968521,
"author_profile": "https://Stackoverflow.com/users/10968521",
"pm_score": 1,
"selected": false,
"text": "for (columnName, columnData) in data.iteritems():\n if columnName = 'Month'\n [code]\n"
},
{
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20352913/"
] |
74,228,364 | <p>How to detect in Deno that remote has closed (aborted) the TCP/IP (HTTP) connection?</p>
<pre><code>const server = Deno.listen({ port: 8080 });
for await (const conn of server) {
conn.on('abort', () => { // <-- API I expect but doesn't exist
// ...
});
const httpConn = Deno.serveHttp(conn);
for await (const requestEvent of httpConn) {
//
}
}
</code></pre>
| [
{
"answer_id": 74229800,
"author": "jsejcksn",
"author_id": 438273,
"author_profile": "https://Stackoverflow.com/users/438273",
"pm_score": -1,
"selected": false,
"text": "ReadableStream"
},
{
"answer_id": 74233491,
"author": "Marcos Casagrande",
"author_id": 1119863,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228364",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/289827/"
] |
74,228,368 | <p>I have a 25 x 25 numpy array filled with 0s. I want to randomly replace 0s within the array with 1s, with the number of 0s to be replaced defined by the user and ranging from 1 to 625. How can I do this without replacement becoming an issue given there are two coordinate values, x and y?</p>
<p>Code for generating a 25 x 25 array:</p>
<pre><code> import numpy as np
Array = np.zeros((25,25))
</code></pre>
<p>Expected result on a 4 x 4 array:</p>
<p>Before</p>
<pre><code>0,0,0,0
0,0,0,0
0,0,0,0
0,0,0,0
</code></pre>
<p>After (replace 1)</p>
<pre><code>0,0,0,0
0,0,1,0
0,0,0,0
0,0,0,0
</code></pre>
<p>After (replace 16)</p>
<pre><code>1,1,1,1
1,1,1,1
1,1,1,1
1,1,1,1
</code></pre>
| [
{
"answer_id": 74228684,
"author": "user19077881",
"author_id": 19077881,
"author_profile": "https://Stackoverflow.com/users/19077881",
"pm_score": 0,
"selected": false,
"text": "import random\n\nimport numpy as np\n\nSIZE = 25\n\nhowmany = 500\n\narray = np.zeros((SIZE, SIZE), dtype=int... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228368",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11709754/"
] |
74,228,369 | <p>I would like to create a "menu" of items you could find at a grocery store. My goal is to generate every permutation of picking 5 pieces of fruit (with replacement), and find the total cost of the 5 fruit. Here's what I have currently.</p>
<pre><code>fruit = data.frame(c("apple", "banana", "orange", "pear", "strawberry"))
price = data.frame(c(0.99, 1.59, 0.70, 1.29, 2.99))
## Rename column headers
colnames(fruit)[1] = "Fruit"
colnames(price)[1] = "Price"
menu = cbind(fruit, price)
## Turn fruit dataframe into a vector
fruit_vector = as.vector(fruit[[1]])
## Generate all permutations
permutations = data.frame(expand.grid(Fruit_1 = fruit_vector,
Fruit_2 = fruit_vector,
Fruit_3 = fruit_vector,
Fruit_4 = fruit_vector,
Fruit_5 = fruit_vector))
</code></pre>
<p>Here's the part that I'm stuck on: I would like to create a 6th column in my dataframe that takes all 5 fruit from a row and sums their prices for a single total price.</p>
<p>Is there a way to call on information from my "menu" data frame that matches the price of an apple to 0.99, the price of a banana to 1.59, etc.?</p>
<p>Thoughts (other than the questionable food prices)?</p>
<p>I thought about making individual columns to have the price of fruit_1, the price of fruit_2, etc, and them sum them up into an 11th column, but I feel like that is less efficient, and that still doesn't solve my issue of seeing an apple and having R automatically identify that as 0.99.</p>
| [
{
"answer_id": 74228684,
"author": "user19077881",
"author_id": 19077881,
"author_profile": "https://Stackoverflow.com/users/19077881",
"pm_score": 0,
"selected": false,
"text": "import random\n\nimport numpy as np\n\nSIZE = 25\n\nhowmany = 500\n\narray = np.zeros((SIZE, SIZE), dtype=int... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228369",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20352864/"
] |
74,228,380 | <p>I'm running a query on Mongodb to get the combine data from two different collections: User and Store.</p>
<p>User collection has a property named as <code>store_ids</code>, which is an array that contains a list of ObjectIds of each store that the User has access to.</p>
<p>I'm trying to add the <code>name</code> of each store in the query result.</p>
<p>Example:</p>
<p>User Document:</p>
<pre><code>{
_id: '58ebf8f24d52e9ab59b5538b',
store_ids: [
ObjectId("58dd4bb10e2898b0057be648"),
ObjectId("58ecd57d1a2f48e408ea2a30"),
ObjectId("58e7a0766de7403f5118afea"),
]
}
</code></pre>
<p>Store Documents:</p>
<pre><code>
{
_id: "58dd4bb10e2898b0057be648",
name: "Store A",
},
{
_id: "58ecd57d1a2f48e408ea2a30",
name: "Store B",
},
{
_id: "58e7a0766de7403f5118afea",
name: "Store C"
}
</code></pre>
<p>I'm looking for a query that returns an output like this:</p>
<pre><code>{
_id: '58ebf8f24d52e9ab59b5538b',
stores: [
{
_id: ObjectId("58dd4bb10e2898b0057be648"),
name: "Store A"
},
{
id: ObjectId("58ecd57d1a2f48e408ea2a30"),
name: "Store B"
},
{
_id: ObjectId("58e7a0766de7403f5118afea"),
name: "Store C"
}
]
}
</code></pre>
<p>I've already tried operations like <code>$map</code> and <code>$set</code>. I don't know if I'm applying them in the right way because they didn't work for my case.</p>
| [
{
"answer_id": 74228684,
"author": "user19077881",
"author_id": 19077881,
"author_profile": "https://Stackoverflow.com/users/19077881",
"pm_score": 0,
"selected": false,
"text": "import random\n\nimport numpy as np\n\nSIZE = 25\n\nhowmany = 500\n\narray = np.zeros((SIZE, SIZE), dtype=int... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228380",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11025002/"
] |
74,228,434 | <p>I have trouble to deserialize part of invoice XML.</p>
<p>Tag cac:InvoiceLine is repeating.</p>
<p>I need help to make list/array for element InvoiceLine and do foreach loop and extract values from child elements.</p>
<p>This is example of XML file</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<env:DocumentEnvelope xmlns:env="urn:eFaktura:MinFinrs:envelop:schema">
<env:DocumentHeader>
<env:SalesInvoiceId>4372797</env:SalesInvoiceId>
<env:PurchaseInvoiceId>3935145</env:PurchaseInvoiceId>
<env:DocumentId>3ff1e4d7-9025-4908-b05b-26094758bd7d</env:DocumentId>
<env:CreationDate>2022-10-06</env:CreationDate>
<env:SendingDate>2022-10-06</env:SendingDate>
<env:DocumentPdf mimeCode="application/pdf"></env:DocumentPdf>
</env:DocumentHeader>
<env:DocumentBody>
<Invoice xmlns:cec="urn:oasis:names:specification:ubl:schema:xsd:CommonExtensionComponents-2"
xmlns:cac="urn:oasis:names:specification:ubl:schema:xsd:CommonAggregateComponents-2"
xmlns:cbc="urn:oasis:names:specification:ubl:schema:xsd:CommonBasicComponents-2"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:sbt="http://mfin.gov.rs/srbdt/srbdtext"
xmlns="urn:oasis:names:specification:ubl:schema:xsd:Invoice-2">
<cbc:CustomizationID>urn:cen.eu:en16931:2017#compliant#urn:mfin.gov.rs:srbdt:2022#conformant#urn:mfin.gov.rs:srbdtext:2022</cbc:CustomizationID>
<cbc:ID>24</cbc:ID>
<cbc:IssueDate>2022-10-06</cbc:IssueDate>
<cbc:DueDate>2022-10-20</cbc:DueDate>
<cbc:InvoiceTypeCode>380</cbc:InvoiceTypeCode>
<cbc:Note>PROD</cbc:Note>
<cbc:DocumentCurrencyCode>RSD</cbc:DocumentCurrencyCode>
<cac:InvoicePeriod>
<cbc:StartDate>2022-09-01</cbc:StartDate>
<cbc:EndDate>2022-09-30</cbc:EndDate>
<cbc:DescriptionCode>35</cbc:DescriptionCode>
</cac:InvoicePeriod>
<cac:AdditionalDocumentReference>
<cbc:ID>24</cbc:ID>
<cbc:DocumentType>PRILOG 1</cbc:DocumentType>
<cac:Attachment>
<cbc:EmbeddedDocumentBinaryObject mimeCode="application/pdf" encodingCode="base64" filename="24.pdf"></cbc:EmbeddedDocumentBinaryObject>
</cac:Attachment>
</cac:AdditionalDocumentReference>
<cac:AccountingSupplierParty>
<cac:Party>
<cbc:EndpointID schemeID="9948">123456789</cbc:EndpointID>
<cac:PartyIdentification>
<cbc:ID>81906</cbc:ID>
</cac:PartyIdentification>
<cac:PartyName>
<cbc:Name>SUPPLIER NAME</cbc:Name>
</cac:PartyName>
<cac:PostalAddress>
<cbc:StreetName>SUPPLIER STREET</cbc:StreetName>
<cbc:CityName>SUPPLIER TOWN</cbc:CityName>
<cbc:PostalZone>SUPPLIER ZIP CODE</cbc:PostalZone>
<cac:AddressLine>
<cbc:Line>STREET,TOWN, ZIP</cbc:Line>
</cac:AddressLine>
<cac:Country>
<cbc:IdentificationCode>RS</cbc:IdentificationCode>
</cac:Country>
</cac:PostalAddress>
<cac:PartyTaxScheme>
<cbc:CompanyID>RS123456789</cbc:CompanyID>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:PartyTaxScheme>
<cac:PartyLegalEntity>
<cbc:RegistrationName>SUPPLIER NAME</cbc:RegistrationName>
<cbc:CompanyID>98765432</cbc:CompanyID>
</cac:PartyLegalEntity>
<cac:Contact>
<cbc:ElectronicMail>xxx@xxx.rs</cbc:ElectronicMail>
</cac:Contact>
</cac:Party>
</cac:AccountingSupplierParty>
<cac:AccountingCustomerParty>
<cac:Party>
<cbc:EndpointID schemeID="9948">111111111</cbc:EndpointID>
<cac:PartyIdentification />
<cac:PartyName>
<cbc:Name>CUSTOMER NAME</cbc:Name>
</cac:PartyName>
<cac:PostalAddress>
<cbc:StreetName>CUSTOMER street</cbc:StreetName>
<cbc:CityName>CUSTOMER town</cbc:CityName>
<cbc:PostalZone>CUSTOMER zip</cbc:PostalZone>
<cac:AddressLine>
<cbc:Line>street, town, zip</cbc:Line>
</cac:AddressLine>
<cac:Country>
<cbc:IdentificationCode>RS</cbc:IdentificationCode>
</cac:Country>
</cac:PostalAddress>
<cac:PartyTaxScheme>
<cbc:CompanyID>RS111111111</cbc:CompanyID>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:PartyTaxScheme>
<cac:PartyLegalEntity>
<cbc:RegistrationName>CUSTOMER NAME</cbc:RegistrationName>
<cbc:CompanyID>22222222</cbc:CompanyID>
</cac:PartyLegalEntity>
<cac:Contact>
<cbc:ElectronicMail>yyy@yyy.rs</cbc:ElectronicMail>
</cac:Contact>
</cac:Party>
</cac:AccountingCustomerParty>
<cac:Delivery>
<cbc:ActualDeliveryDate>2022-09-30</cbc:ActualDeliveryDate>
</cac:Delivery>
<cac:PaymentMeans>
<cbc:PaymentMeansCode>30</cbc:PaymentMeansCode>
<cbc:PaymentID>223985-2209</cbc:PaymentID>
<cac:PayeeFinancialAccount>
<cbc:ID>100-000000-11</cbc:ID>
</cac:PayeeFinancialAccount>
</cac:PaymentMeans>
<cac:TaxTotal>
<cbc:TaxAmount currencyID="RSD">967.2</cbc:TaxAmount>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="RSD">9464</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="RSD">946.4</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID>S</cbc:ID>
<cbc:Percent>10</cbc:Percent>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
<cac:TaxSubtotal>
<cbc:TaxableAmount currencyID="RSD">104</cbc:TaxableAmount>
<cbc:TaxAmount currencyID="RSD">20.8</cbc:TaxAmount>
<cac:TaxCategory>
<cbc:ID>S</cbc:ID>
<cbc:Percent>20</cbc:Percent>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:TaxCategory>
</cac:TaxSubtotal>
</cac:TaxTotal>
<cac:LegalMonetaryTotal>
<cbc:LineExtensionAmount currencyID="RSD">9568</cbc:LineExtensionAmount>
<cbc:TaxExclusiveAmount currencyID="RSD">9568</cbc:TaxExclusiveAmount>
<cbc:TaxInclusiveAmount currencyID="RSD">10535.2</cbc:TaxInclusiveAmount>
<cbc:AllowanceTotalAmount currencyID="RSD">0</cbc:AllowanceTotalAmount>
<cbc:PrepaidAmount currencyID="RSD">0</cbc:PrepaidAmount>
<cbc:PayableAmount currencyID="RSD">10535.2</cbc:PayableAmount>
</cac:LegalMonetaryTotal>
<cac:InvoiceLine>
<cbc:ID>1</cbc:ID>
<cbc:InvoicedQuantity unitCode="MTQ">65</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="RSD">3971.5</cbc:LineExtensionAmount>
<cac:Item>
<cbc:Name>line 1 description</cbc:Name>
<cac:SellersItemIdentification>
<cbc:ID>1</cbc:ID>
</cac:SellersItemIdentification>
<cac:ClassifiedTaxCategory>
<cbc:ID>S</cbc:ID>
<cbc:Percent>10</cbc:Percent>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:ClassifiedTaxCategory>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="RSD">61.1</cbc:PriceAmount>
<cbc:BaseQuantity unitCode="MTQ">1</cbc:BaseQuantity>
</cac:Price>
</cac:InvoiceLine>
<cac:InvoiceLine>
<cbc:ID>2</cbc:ID>
<cbc:InvoicedQuantity unitCode="MTQ">65</cbc:InvoicedQuantity>
<cbc:LineExtensionAmount currencyID="RSD">2535</cbc:LineExtensionAmount>
<cac:Item>
<cbc:Name>line 2 description</cbc:Name>
<cac:SellersItemIdentification>
<cbc:ID>3</cbc:ID>
</cac:SellersItemIdentification>
<cac:ClassifiedTaxCategory>
<cbc:ID>S</cbc:ID>
<cbc:Percent>10</cbc:Percent>
<cac:TaxScheme>
<cbc:ID>VAT</cbc:ID>
</cac:TaxScheme>
</cac:ClassifiedTaxCategory>
</cac:Item>
<cac:Price>
<cbc:PriceAmount currencyID="RSD">39</cbc:PriceAmount>
<cbc:BaseQuantity unitCode="MTQ">1</cbc:BaseQuantity>
</cac:Price>
</cac:InvoiceLine>
</Invoice>
</env:DocumentBody>
</env:DocumentEnvelope>
</code></pre>
<p>I generated classes in Visual Studio</p>
<p>1 Copy XML data to the clipboard</p>
<p>2 In VS, Edit > Paste Special > "Paste Xml as classes"</p>
<p>This is my code for get all other values from xml.</p>
<pre><code>
static void Main(string[] args)
{
XmlSerializer serializer =
new XmlSerializer(typeof(XmlStr.DocumentEnvelope));
// Declare an object variable of the type to be deserialized.
XmlStr.DocumentEnvelope envelope;
using (Stream reader = new FileStream(@"C:\\Users\\Desktop\\24.xml", FileMode.Open))
{
// Call the Deserialize method to restore the object's state.
envelope = (XmlStr.DocumentEnvelope)serializer.Deserialize(reader);
}
// Write out the properties of the object.
Console.WriteLine(envelope.DocumentBody.Invoice.ID.Value);
}
</code></pre>
<p>When I use code below, I get error</p>
<p>System.InvalidOperationException: 'There is an error in XML document (2, 2).'</p>
<p>Inner Exception</p>
<p>InvalidOperationException: <code><DocumentEnvelope xmlns='urn:eFaktura:MinFinrs:envelop:schema'></code> was not expected.</p>
<pre><code>XmlSerializer serializer =
new XmlSerializer(typeof(zaglavlje.InvoiceLine[]));
// Declare an object variable of the type to be deserialized.
zaglavlje.InvoiceLine[] envelope;
using (Stream reader = new FileStream(@"C:\\Users\\Desktop\\24.xml", FileMode.Open))
{
// Call the Deserialize method to restore the object's state.
envelope = (zaglavlje.InvoiceLine[])serializer.Deserialize(reader);
}
// Write out the properties of the object.
//Console.WriteLine(envelope);
</code></pre>
<p>I would like to get InvoiceLine like this</p>
<p><strong>First loop</strong><br>
ID: 1<br>
InvoicedQuantity: 65<br>
LineExtensionAmount: 3971.5<br>
Item.Name: line 1 description<br>
Price.PriceAmount: 61.1<br>
BaseQuantity: 1<br>
<strong>Second loop<br></strong>
ID: 2<br>
InvoicedQuantity: 65<br>
LineExtensionAmount: 2535<br>
Item.Name: line 2 description<br>
Price.PriceAmount: 39<br>
BaseQuantity: 1<br></p>
| [
{
"answer_id": 74229518,
"author": "jdweng",
"author_id": 5015238,
"author_profile": "https://Stackoverflow.com/users/5015238",
"pm_score": 2,
"selected": true,
"text": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Xml;\nusing Sys... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228434",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20352658/"
] |
74,228,466 | <pre><code>`let teams = [ {key: cityTeam, value:playerScore[0]},
{key: 'Green Bay', value:computerScore[0]},
{key: "Chicago", value:chicagoScore[0]},
{key: "Los Angeles", value:laScore[0]},
{key: "New York", value:nyScore[0]},
{key: "Miami", value:miamiScore[0]},
{key: "Houston", value:houstonScore[0]},
{key: "Seattle", value:seattleScore[0]},
{key: "Toronto", value:torontoScore[0]},
{key: "Dallas", value:dallasScore[0]},
{key: "Mexico City", value:mexicoCityScore[0]},
{key: "Detroit", value:detroitScore[0]},
`your text`{key: "Ottawa", value:ottawaScore[0]},
{key: "San Francisco", value:sfScore[0]},
{key: "Denver", value:denverScore[0]},
{key: "Toluca", value:tolucaScore[0]} ]`
</code></pre>
<p>I tried to sort these with all sorts of methods from a for loop from a .sort to a .values Sort
(I tried all that I could)
I wanted the array to be ranked in descending order from highest to lowest SCORE, but it either did it by the names or didn't sort at all, I spent days trying to solve this and it's not working. And then, it has to print out the top 6 and every time there is a change in ranking, it will change to positioning and print out the new result.</p>
| [
{
"answer_id": 74229518,
"author": "jdweng",
"author_id": 5015238,
"author_profile": "https://Stackoverflow.com/users/5015238",
"pm_score": 2,
"selected": true,
"text": "using System;\nusing System.Collections.Generic;\nusing System.Linq;\nusing System.Text;\nusing System.Xml;\nusing Sys... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20352952/"
] |
74,228,480 | <p>I have this df:</p>
<pre><code>table
C1 C10 C11 C12 C13 C14 C15 C16 C17 C18 C2 C3 C4 C5 C6 C7 C8 C9
Mest 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Dlk1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
Meg3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
</code></pre>
<p>I'd like to order the columns, I've tried:</p>
<pre><code>colnames(table) <- stringr::str_sort(colnames(table),numeric = TRUE)
</code></pre>
<p>but It only changes the name of columns in alphabetic order leaving the column in the same position:</p>
<pre><code>table
C1 C2 C3 C4 C5 C6 C7 C8 C9 C10 C11 C12 C13 C14 C15 C16 C17 C18
Mest 1 1 1 1 0 0 0 0 0 0 0 0 0 0 0 0 0 0
Dlk1 0 0 0 0 0 0 0 0 0 0 0 0 1 0 0 0 0 0
Meg3 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0 0
</code></pre>
| [
{
"answer_id": 74228507,
"author": "Matt",
"author_id": 12967938,
"author_profile": "https://Stackoverflow.com/users/12967938",
"pm_score": 1,
"selected": false,
"text": "dplyr"
},
{
"answer_id": 74228544,
"author": "r2evans - GO NAVY BEAT ARMY",
"author_id": 3358272,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10952047/"
] |
74,228,483 | <p>I'm following the course of 32 hours Learn <em>Blockchain, Solidity, ..</em> in Javascript and I'm stucked with an error <a href="https://stackoverflow.com/questions/72462523/typeerror-cannot-read-property-length-of-undefined-while-deploying-using-ha">that others have</a> but they solve because typos ecc.
I'm pretty sure at this point that the problem is not there but so what is the problem? I have my configuration file:</p>
<p>namedAccounts: {
deployer: {
default: 0,
1:0, // I even with this but nothing change
},
},</p>
<p>And I'm running everything in the hardhat default network, and when from the <code>00-deploy-mock.js</code> the script calls the function <code>getNamedAccounts()</code>:</p>
<pre><code>module.exports = async function ({getNamedAccounts,deployments}){
const {deploy,log} = deployments
const {deployer} = await getNamedAccounts()
log(deployer)
if(developmentChains.includes(network.name)){
log("Local network " + network.name +" deploying mocks....")
await deploy("VRFCoordinatorV2Mock",{
from: deployer,
log: true,
args: [BASE_FEE,GAS_PRICE_LINK]
})
log("Mocks deployed !")
log("--------------------------------------------------")
}
}
</code></pre>
<p><code>log(deployer)</code> prints <code>undefined</code>. and It returns the error:</p>
<p><code>TypeError: Cannot read properties of undefined (reading 'length')</code></p>
<p>The same process but using ganache instead run fine.
I have the hardhat-deploy plugin installed and i'm using the command <code>hardhat deploy</code>.</p>
<p>Any ideas ?</p>
| [
{
"answer_id": 74228507,
"author": "Matt",
"author_id": 12967938,
"author_profile": "https://Stackoverflow.com/users/12967938",
"pm_score": 1,
"selected": false,
"text": "dplyr"
},
{
"answer_id": 74228544,
"author": "r2evans - GO NAVY BEAT ARMY",
"author_id": 3358272,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11140292/"
] |
74,228,498 | <p>I'm creating a method to check wether a number is even or odd (just to understand generic types).
Here's my code</p>
<pre><code>public class Main {
public static void main(String[] args) {
System.out.println(checkEven(5));
}
static <T extends Number> boolean checkEven(T x){
if(x % 2 == 0) return true; //int this line I get the message
return false;
}
}
</code></pre>
<p>Intellij says "Operator '%' cannot be applied to 'T', 'int'"
What's wrong?</p>
<p></p>
| [
{
"answer_id": 74228513,
"author": "Louis Wasserman",
"author_id": 869736,
"author_profile": "https://Stackoverflow.com/users/869736",
"pm_score": -1,
"selected": false,
"text": "int"
},
{
"answer_id": 74228820,
"author": "f1sh",
"author_id": 214525,
"author_profile":... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228498",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16129964/"
] |
74,228,515 | <p>I have excel file with data from where i merge information with different word files using mysql (Mailings).
In word documents i have tables, rows of which should be removed / deleted depending from the situation.</p>
<p>I found very useful macros, which scan all the tables in the word document, including tables with merged cells. And, if the whole row is empty (no data), macros delete the row.
But there are a lot of useless data in the cells, which is constant and not reflecting in excel for merging. only data in the first cell of the row is variable and enough to be used to decide regarding the row faith, to be delete or not.</p>
<p>below is the code. How to change the condition from whole empty row to first cell empty to delete the row?</p>
<pre><code>Sub ClearEmptyRowsInTables 'чистилка таблиц
Dim tb, tCells, ii, rPre, RowIsEmpty
For Each tb In ActiveDocument.Tables 'переберём все таблицы
Set tCells = tb.Range.Cells ' массив всех ячеек этой таблицы
rPre = 0: RowIsEmpty = False 'начальные установки: предыдущий Row = 0 и он не пустой
For ii = tCells.Count To 1 Step -1 'перебираем ячейки в обратном порядке
If tCells(ii).RowIndex <> rPre Then ' если строка этой ячейки не совпадает со строкой ранее проверенной
If RowIsEmpty Then 'если ранее проверенная строка пустая
tCells(ii + 1).Range.Rows.Delete 'удалим её
End If
rPre = tCells(ii).RowIndex 'сохраняем строку текущей ячейки как проверяемую
RowIsEmpty = False
If tCells(ii).Range.Text = Chr(13) & Chr(7) Then RowIsEmpty = True 'проверяем текущую ячейку на пустоту
Else 'если это та же строка -
If RowIsEmpty Then ' и она ещё пустая - проверим текущую ячейку и поменяем признак пустоты строки, если надо
If tCells(ii).Range.Text <> Chr(13) & Chr(7) Then RowIsEmpty = False
End If
End If
Next
Next
End Sub
</code></pre>
| [
{
"answer_id": 74228513,
"author": "Louis Wasserman",
"author_id": 869736,
"author_profile": "https://Stackoverflow.com/users/869736",
"pm_score": -1,
"selected": false,
"text": "int"
},
{
"answer_id": 74228820,
"author": "f1sh",
"author_id": 214525,
"author_profile":... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9663565/"
] |
74,228,526 | <p>When I run my bitbucket pipeline for my project im getting an error during flutter test:</p>
<pre><code>/root/.pub-cache/hosted/pub.dartlang.org/firebase_core-1.24.0/lib/src/firebase_app.dart:18:25: Error: Member not found: 'FirebaseAppPlatform.verifyExtends'.
FirebaseAppPlatform.verifyExtends(_delegate);
^^^^^^^^^^^^^
</code></pre>
<p>When I run flutter test in my terminal I don't have these issues.</p>
<p>My pipeline script is:</p>
<ul>
<li>Build Setup</li>
<li>flutter clean</li>
<li>flutter pub get</li>
<li>flutter pub run build_runner build</li>
<li>bash <(curl -s <a href="https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh" rel="noreferrer">https://raw.githubusercontent.com/objectbox/objectbox-dart/main/install.sh</a>)</li>
<li>flutter test</li>
</ul>
| [
{
"answer_id": 74230249,
"author": "Cương Nguyễn",
"author_id": 12172908,
"author_profile": "https://Stackoverflow.com/users/12172908",
"pm_score": 6,
"selected": true,
"text": "firebase_core_platform_interface"
},
{
"answer_id": 74580648,
"author": "nahoang",
"author_id"... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228526",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18005129/"
] |
74,228,541 | <p>I have two tables and i need to find the number of comments on a most commented post.
<a href="https://i.stack.imgur.com/zdj3w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zdj3w.png" alt="enter image description here" /></a></p>
<p>I can get all post ordered with a number of comments but I want to add that to subquery.</p>
<p>My code at the moment:</p>
<pre><code>SELECT TOP 1 p.PostID, COUNT(*) AS num_comments
FROM Comment p
GROUP BY p.PostID
ORDER BY num_comments DESC
</code></pre>
<p>But then I have a one column with PostID as well and I don't want to put that on table below.
How can i get only the value of mostCommentsPerPost ?</p>
<p><a href="https://i.stack.imgur.com/GlTpe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GlTpe.png" alt="enter image description here" /></a></p>
<p>Sorry If i dont explain my problem well enough, this is my first post.</p>
<p>Thanks!</p>
| [
{
"answer_id": 74228587,
"author": "rib",
"author_id": 3928418,
"author_profile": "https://Stackoverflow.com/users/3928418",
"pm_score": 0,
"selected": false,
"text": "SELECT sq.postId, sq.Cnt\nFROM (\n SELECT PostId, count(*) AS Cnt\n FROM Comment\n GROUP BY PostId\n) AS sq\nOR... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10820715/"
] |
74,228,549 | <p>I'm trying to understand the documentation here:</p>
<p><a href="https://code.kx.com/q/ref/xbar/#domain-and-range" rel="nofollow noreferrer">https://code.kx.com/q/ref/xbar/#domain-and-range</a></p>
<p>I've got some standard minute data</p>
<pre><code>t o h l c v n vw sym
-----------------------------------------------------------------------------------
2015.12.01D14:30:00.000000000 44.14 44.14 44.02 44.1 126762 337 44.10188 XLK
2015.12.01D14:31:00.000000000 44.09 44.12 44.08 44.11 17104 123 44.09911 XLK
2015.12.01D14:32:00.000000000 44.12 44.12 44.1 44.1 232106 663 44.1154 XLK
2015.12.01D14:33:00.000000000 44.1 44.11 44.1 44.11 72177 260 44.10674 XLK
</code></pre>
<p>Which I'm trying to group by 5-min intervals:</p>
<pre><code>select max o by t.date, 5 xbar t.time from xlk
date time | o
-----------------------| -------
2015.12.01 14:30:00.000| 44.14
2015.12.01 14:31:00.000| 44.09
2015.12.01 14:32:00.000| 44.12
</code></pre>
<p>So first, these didn't come out as 5-min bars, so that's an issue. My real question is though, can I do an <code>xbar</code> directly on the <code>t</code> column (rather than do a joint <code>by</code> clause)?</p>
<p>If yes - is this cryptic documentation I've linked telling me how to do this?</p>
| [
{
"answer_id": 74228618,
"author": "Thomas Smyth - Treliant",
"author_id": 5620913,
"author_profile": "https://Stackoverflow.com/users/5620913",
"pm_score": 3,
"selected": true,
"text": "t.minute"
},
{
"answer_id": 74228790,
"author": "terrylynch",
"author_id": 3895697,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/222151/"
] |
74,228,554 | <p>I have a list of IDs <code>myIdList</code> and a map <code>myObjectMap</code> associating the ID with a corresponding object, <code>Map<String,Object></code>.</p>
<p>I need to go through my list of IDs, and for each ID - if it's present in the map, add the object associated with it to a new list of objects, otherwise add the ID to a list of missing IDs.</p>
<p>I can easily do this using a simple for each loop:</p>
<pre><code>List<String> myIdList = Arrays.asList("a", "b", "c");
Map<String,Object> myObjectMap = new HashMap<>();
List<Object> objectList = new ArrayList<>();
List<String> missingObjIds = new ArrayList<>();
for(String id : myIdList) {
Object obj = myObjectMap.get(id);
if(obj == null) {
missingObjIds.add(id);
} else {
objectList.add(obj);
}
}
</code></pre>
<p>I would like to do this in a less verbose way using the Stream API, but I'm not sure how.</p>
<p>I've tried partitioning the stream, but that got me either a map with 2 lists of IDs (which would necessitate going through the list again to retrieve the mapped objects) or a list of objects with nulls for all the missing objects and no way to get the missing IDs.</p>
<p>I'm sure there has to be a way to do it. Any ideas?</p>
| [
{
"answer_id": 74228618,
"author": "Thomas Smyth - Treliant",
"author_id": 5620913,
"author_profile": "https://Stackoverflow.com/users/5620913",
"pm_score": 3,
"selected": true,
"text": "t.minute"
},
{
"answer_id": 74228790,
"author": "terrylynch",
"author_id": 3895697,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228554",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/266261/"
] |
74,228,563 | <p>I was wondering if there was any way to plot this PDF and CDF in R. I found these on a different question a user asked, and was curious.</p>
<p><img src="https://i.stack.imgur.com/KN4ib.png" alt="pdfcdf" /></p>
<p>I know that I have to create a function and then plot this, but I'm struggling with the different parameters and am unsure how to translate this to R. I have only ever plotted PDF/CDF using a normal distribution, or from datasets.</p>
| [
{
"answer_id": 74228666,
"author": "Allan Cameron",
"author_id": 12500315,
"author_profile": "https://Stackoverflow.com/users/12500315",
"pm_score": 2,
"selected": false,
"text": "ifelse"
},
{
"answer_id": 74230990,
"author": "jay.sf",
"author_id": 6574038,
"author_pr... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14737412/"
] |
74,228,575 | <p>I have access to a Godaddy account where the company has all their domains. One of those I need to point to another web server running Apache. The person that used to work here before me solved this pointing to the new server IP using the record:</p>
<pre><code>A @ the.ip.addr.ess 1 hour
</code></pre>
<p>and in the webserver end I get it with Apache and as far as the webserver goes, it runs flawlessly. I even have some subdomains using the same A record structure.</p>
<p>But...now I have two issues. First, I lost email reception. I can send via smtp and webmail but anything sent to my domain gets bounced back after 24 hours, even if sent to an alias or forwarder.</p>
<p>The second issue is that I need to verify the domain with Firebase and even thou I created the TXT record, it cannot be found by Google. I'm sure it's because of the same reason.</p>
<p>What can I do? I understand a little about DNS and records, but not enough for this. I just want all html traffic to reach my webserver as it is now and keep the emails and other domain services working as they were.</p>
<p>As contacting Godaddy support, they said it is not their purview as it is external. I think they just don't know. Go figure.</p>
| [
{
"answer_id": 74228666,
"author": "Allan Cameron",
"author_id": 12500315,
"author_profile": "https://Stackoverflow.com/users/12500315",
"pm_score": 2,
"selected": false,
"text": "ifelse"
},
{
"answer_id": 74230990,
"author": "jay.sf",
"author_id": 6574038,
"author_pr... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2343396/"
] |
74,228,586 | <p>I am working on a Django project on the IntelliJ IDEA IDE. I am writing unit tests in the <code>test.py</code> file for the <code>User</code> model class. When running the <code>test.py</code> file with the command <code>python manage.py test</code> it throws 2 errors on the <code>test_username_cannot_be_blank</code> method and the test_valid_user method. The error is the same for both methods</p>
<blockquote>
<p>AttributeError: 'User' object has no attribute 'fullclean'.</p>
</blockquote>
<p>IDEA is also giving me a Instance attribute user defined outside <strong>init</strong> warnig on line 9 of the test.py file ("self.user = User.objects.create_user()") is where the compiler warning occurs.</p>
<p>What exactly is causing of the <code>AttributeError</code> and the compiler warning?</p>
<p><a href="https://i.stack.imgur.com/I0lvs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/I0lvs.png" alt="error traceback" /></a></p>
<pre><code># test.py file
from django.test import TestCase
from django.core.exceptions import ValidationError
from .models import User
class UserModelTestCase(TestCase):
def setUp(self):
self.user = User.objects.create_user(
'@johndoe',
first_name='John',
last_name='Doe',
email='johndoe@example.org',
password='Password123',
bio='The quick brown fox jumps over the lazy dog.'
)
def test_valid_user(self):
self._assert_user_is_valid()
def test_username_cannot_be_blank(self):
self.user.username = ''
self._assert_user_is_invalid()
def _assert_user_is_valid(self):
try:
self.user.fullclean()
except ValidationError:
self.fail('user should be valid')
def _assert_user_is_invalid(self):
with self.assertRaises(ValidationError):
self.user.fullclean()
</code></pre>
<pre><code># models.py file
from django.db import models
from django.contrib.auth.models import AbstractUser
class User(AbstractUser):
bio = models.TextField()
</code></pre>
<p>Looked on stackoverflow but could'nt find any solution to the problem.</p>
| [
{
"answer_id": 74228608,
"author": "lmiguelvargasf",
"author_id": 3705840,
"author_profile": "https://Stackoverflow.com/users/3705840",
"pm_score": 3,
"selected": true,
"text": "full_clean"
},
{
"answer_id": 74228624,
"author": "almosthavoc",
"author_id": 8760155,
"au... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74228586",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15008436/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.