qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,213,969 | <p>Using the following <strong>boost::asio</strong> code I run a loop of 1M sequential http calls to a Docker node.js simple http service that generates random numbers, but after a few thousand calls I start getting async_connect errors. The node.js part is not producing any errors and I believe it works OK.</p>
<p>To avoid resolving the host in every call and trying to speed-up, I am caching the endpoint, which makes no difference, I have tested both ways.</p>
<p>Can anyone see what is wrong with my code below?
Are there any best practices for a stress-test tool using asio that I am missing?</p>
<pre><code>//------------------------------------------------------------------------------
// https://www.boost.org/doc/libs/1_70_0/libs/beast/doc/html/beast/using_io/timeouts.html
HttpResponse HttpClientAsyncBase::_http(HttpRequest&& req)
{
using namespace boost::beast;
namespace net = boost::asio;
using tcp = net::ip::tcp;
HttpResponse res;
req.prepare_payload();
boost::beast::error_code ec = {};
const HOST_INFO host = resolve(req.host(), req.port, req.resolve);
net::io_context m_io;
boost::asio::spawn(m_io, [&](boost::asio::yield_context yield)
{
size_t retries = 0;
tcp_stream stream(m_io);
if (req.timeout_seconds == 0) get_lowest_layer(stream).expires_never();
else get_lowest_layer(stream).expires_after(std::chrono::seconds(req.timeout_seconds));
get_lowest_layer(stream).async_connect(host, yield[ec]);
if (ec) return;
http::async_write(stream, req, yield[ec]);
if (ec)
{
stream.close();
return;
}
flat_buffer buffer;
http::async_read(stream, buffer, res, yield[ec]);
stream.close();
});
m_io.run();
if (ec)
throw boost::system::system_error(ec);
return std::move(res);
}
</code></pre>
<p>I have tried both sync/async implementations of a boost http client and I get the exact same problem.</p>
<p>The error I get is "You were not connected because a duplicate name exists on the network. If joining a domain, go to System in Control Panel to change the computer name and try again. If joining a workgroup, choose another workgroup name [system:52]"</p>
| [
{
"answer_id": 74215653,
"author": "sehe",
"author_id": 85371,
"author_profile": "https://Stackoverflow.com/users/85371",
"pm_score": 2,
"selected": false,
"text": "#include <boost/asio/spawn.hpp>\n#include <boost/beast.hpp>\n#include <fmt/ranges.h>\n#include <iostream>\nnamespace http =... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74213969",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4361245/"
] |
74,213,976 | <p>I am running this simple code:</p>
<pre><code>import requests
x = requests.get('https://w3schools.com/python/demopage.htm')
print(x.text)
</code></pre>
<p>However, I am getting this error</p>
<pre><code>requests.exceptions.ProxyError: HTTPSConnectionPool(host='w3schools.com', port=443): Max retries exceeded with url: /python/demopage.htm (Caused by ProxyError('Your proxy appears to only use HTTP and not HTTPS, try changing your proxy URL to be HTTP. See: https://urllib3.readthedocs.io/en/1.26.x/advanced-usage.html#https-proxy-error-http-proxy', SSLError(SSLError(1, '[SSL: WRONG_VERSION_NUMBER] wrong version number (_ssl.c:997)'))))
</code></pre>
<p>How can I solve this issue?</p>
| [
{
"answer_id": 74215653,
"author": "sehe",
"author_id": 85371,
"author_profile": "https://Stackoverflow.com/users/85371",
"pm_score": 2,
"selected": false,
"text": "#include <boost/asio/spawn.hpp>\n#include <boost/beast.hpp>\n#include <fmt/ranges.h>\n#include <iostream>\nnamespace http =... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74213976",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20160998/"
] |
74,214,043 | <p>So I'm trying to find the total budget of each account in the most current week. The sample data would look have 3 columns Account/Week/Budget. The desired outcome would be the "Current Budget" Column. So that when I sum the "Current Budget" column I would sum the most recent data of each account for what the projected budget is. If there is no data on the account for the current week (3), it would look at the previous week's data (2) instead.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Account</th>
<th>Week</th>
<th>Budget</th>
<th>Current budget</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>1</td>
<td>$24</td>
<td>null</td>
</tr>
<tr>
<td>2</td>
<td>1</td>
<td>$100</td>
<td>null</td>
</tr>
<tr>
<td>3</td>
<td>1</td>
<td>$30</td>
<td>null</td>
</tr>
<tr>
<td>1</td>
<td>2</td>
<td>$100</td>
<td>null</td>
</tr>
<tr>
<td>2</td>
<td>2</td>
<td>$24</td>
<td>null</td>
</tr>
<tr>
<td>3</td>
<td>2</td>
<td>$100</td>
<td>$100</td>
</tr>
<tr>
<td>1</td>
<td>3</td>
<td>$100</td>
<td>$100</td>
</tr>
<tr>
<td>2</td>
<td>3</td>
<td>$24</td>
<td>$24</td>
</tr>
</tbody>
</table>
</div>
<p>So far this is what I have. But I run into the issue where I would have last weeks budget for accounts that already have a week 3 budget.</p>
<blockquote>
<p><code>declare @currentweek = datepart(week, getdate())</code>
<code>declare @lastweek = @currentweek -1</code></p>
<p><code>select t.*,</code>
<code>case</code>
<code>when t.week = @currentweek then t.budget</code>
<code>when t.week = @lastweek then t.budget</code>
<code>else null</code>
from
table t</p>
</blockquote>
| [
{
"answer_id": 74215653,
"author": "sehe",
"author_id": 85371,
"author_profile": "https://Stackoverflow.com/users/85371",
"pm_score": 2,
"selected": false,
"text": "#include <boost/asio/spawn.hpp>\n#include <boost/beast.hpp>\n#include <fmt/ranges.h>\n#include <iostream>\nnamespace http =... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214043",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19057658/"
] |
74,214,062 | <p><a href="https://i.stack.imgur.com/IbAgy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IbAgy.png" alt="This is the question" /></a></p>
<p>My logic seems to work for every one of the examples, but when I try to submit it, it comes up as wrong because there is one test input (which is not revealed) that somehow results in my code spitting out "24hours and 10min" which is wrong and that the answer should be "0hours and 10min".</p>
<pre><code>import java.io.IOException;
import java.util.Scanner;
public class Main {
public static void main(String[] args) throws IOException {
Scanner sc = new Scanner(System.in);
int x = sc.nextInt();
int xminutes = sc.nextInt();
int y = sc.nextInt();
int yminutes = sc.nextInt();
int xm = x\*60 + xminutes;
if (y\<=x)y+=24;
int ym = y\*60 + yminutes;
System.out.println("O JOGO DUROU "+((ym-xm)/60)+" HORA(S) E "+ ((ym-xm)%60) +" MINUTO(S)");
}
}
</code></pre>
| [
{
"answer_id": 74215653,
"author": "sehe",
"author_id": 85371,
"author_profile": "https://Stackoverflow.com/users/85371",
"pm_score": 2,
"selected": false,
"text": "#include <boost/asio/spawn.hpp>\n#include <boost/beast.hpp>\n#include <fmt/ranges.h>\n#include <iostream>\nnamespace http =... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214062",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20343154/"
] |
74,214,071 | <p>I am using the Moq framework for my unit test.
This is my TestMethod:</p>
<pre><code>[TestFixture]
public class UpdateContactTests
{
private static readonly object[] TestValidContact =
{
new object[]
{
"Prueba", "nearlinx@gmail.com", "86456245",
new LookUpItem()
{
LookUpItemId = Guid.NewGuid(), Category = "ContactType", CategoryId = 1, Value = "Bulling Contact"
},
new Company()
{
Id = Guid.NewGuid(), Name = "Company", Email = "company@gmail.com", WebSite = "company.com",
Nda = false, Msa = false, Phone = "84876817"
}
}
};
[TestCaseSource(nameof(TestValidContact))]
[Test]
public void UpdateContact_ValidValues_UpdateContact(string name, string email, string phone, LookUpItem lookUpItem, Company company)
{
//arrange
var id = Guid.NewGuid();
var data =
new[]
{
new Contact { Id = Guid.NewGuid(), Name = "Test1", Email = "nearlinx@gmail.com", Phone = "86456245",
ContactType =
new LookUpItem()
{
LookUpItemId = Guid.NewGuid(), Category = "ContactType", CategoryId = 1, Value = "Bulling Contact"
},
Company =
new Company()
{
Id = Guid.NewGuid(), Name = "Company", Email = "company@gmail.com", WebSite = "company.com",
Nda = false, Msa = false, Phone = "84876817"
}},
new Contact { Id = id, Name = "Test2", Email = "nearlinx@gmail.com", Phone = "86456245",
ContactType =
new LookUpItem()
{
LookUpItemId = Guid.NewGuid(), Category = "ContactType", CategoryId = 1, Value = "Bulling Contact"
},
Company =
new Company()
{
Id = Guid.NewGuid(), Name = "Company", Email = "company@gmail.com", WebSite = "company.com",
Nda = false, Msa = false, Phone = "84876817"
}},
};
var contact = new Contact()
{
Id = id,
Name = name,
Email = email,
Phone = phone,
ContactType = lookUpItem,
Company = company
};
var _unitOfWork = new Mock<IUnitOfWork>();
_unitOfWork.Setup(mock => mock.Contact.Get(null, null, null)).Returns(data);
_unitOfWork.Setup(mock => mock.Company.Get(null, null, null)).Returns(new List<Company>());
_unitOfWork.Setup(mock => mock.LookUpItem.Get(null, null, null)).Returns(new List<LookUpItem>());
var contactService = new ContactService(_unitOfWork.Object);
//act
contactService.UpdateContact(contact);
//assert
Assert.That(data.First(m => m.Id == id).Name, Is.EqualTo(contact.Name));
_unitOfWork.Verify(mock => mock.Contact.Update(It.IsAny<Contact>()), Times.Once);
}
}
</code></pre>
<p>My problem is that when I run the test a <code>NullReferenceException</code> is thrown, I suppose it is because the list that has the object that I want to modify is not being assigned</p>
<p>I've never really used Moq and I don't know much about unit tests either, so what am I really doing wrong</p>
<p>Edit:
i change one of the setup because the one called when the update is done was another
instead of</p>
<pre><code>_unitOfWork.Setup(mock => mock.Contact.Get(null, null, null)).Returns(data);
</code></pre>
<p>is</p>
<pre><code>_unitOfWork.Setup(mock => mock.Contact.Where(c => c.Id == contact.Id,null,null).FirstOrDefault()).Returns(() => data.Where(c => c.Id == contact.Id));
</code></pre>
| [
{
"answer_id": 74215653,
"author": "sehe",
"author_id": 85371,
"author_profile": "https://Stackoverflow.com/users/85371",
"pm_score": 2,
"selected": false,
"text": "#include <boost/asio/spawn.hpp>\n#include <boost/beast.hpp>\n#include <fmt/ranges.h>\n#include <iostream>\nnamespace http =... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214071",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20343163/"
] |
74,214,079 | <p>I am beginner to Electron, and I am developing an educational game. When the user clicks the start button, I want the main process to fetch information from the storage folder (I am ok with data being open to users). The main process accomplishes that without a problem.</p>
<p>main.js</p>
<pre><code>ipcMain.on('load-sets', (event) => {
const directoriesInDIrectory = fs.readdirSync(folderName, { withFileTypes: true })
.filter((item) => item.isDirectory())
.map((item) => item.name);
event.sender.send("loaded-sets", directoriesInDIrectory);
})
</code></pre>
<p>Then, I use ipcRenderer in preload.js to receive the message.</p>
<p>preload.js</p>
<pre><code>ipcRenderer.on("loaded-sets", (event, package) => {
window.loaded_sets = [];
for (var i = 0; i < package.length; i++) {
window.loaded_sets[i] = package[i];
}
})
</code></pre>
<p>Finally, I expose the sets via contextBridge:</p>
<pre><code>contextBridge.exposeInMainWorld("api", {
LoadFiles,
quit,
sets: () => window.loaded_sets,
sentToRender,
})
</code></pre>
<p>However, when I run the following code in render.js:
<code>console.log(window.api.sets())</code></p>
<p>it outputs undefined.</p>
<p>I've already tried using postMessage and eventListeners associated with it. Also, I've tried to get the variable via another function:</p>
<pre><code>
function sentToRender() {
return window.loaded_sets;
</code></pre>
<p>The function was also exposed and could be called in the renderer process. Yet, the output was still undefined.</p>
<hr />
<p>For those wondering why I won't send the data straight to the renderer, the renderer returns error when I try require ipcRenderer and I heard that it is a good practice to navigate data through preload. Is there a solution?</p>
| [
{
"answer_id": 74215653,
"author": "sehe",
"author_id": 85371,
"author_profile": "https://Stackoverflow.com/users/85371",
"pm_score": 2,
"selected": false,
"text": "#include <boost/asio/spawn.hpp>\n#include <boost/beast.hpp>\n#include <fmt/ranges.h>\n#include <iostream>\nnamespace http =... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214079",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14207750/"
] |
74,214,092 | <p>I'm a total novice with VBA. The title describes what I'm looking to do. I need a script to sarch a column (in my case, Column A) and if the last 3 characters are ":01" I need a horizontal page break inserted above it. Bonus points if you can make it skip the FIRST instance of ":01" and only insert page breaks on every subsequent appearance of ":01 in the column after that.</p>
<p>I've been accomplshing what I need with a very clunky process, where I insert a row before Row A, then paste this formula into every cell in the column: =IF(RIGHT(B3, 3) = ":01", 1,"")</p>
<p>Then I'll select Special, choose only numbers, and then run this VBA:</p>
<pre><code>Sub AddPgBrk()
For Each Cell In Selection
ActiveWindow.ActiveSheet.HPageBreaks.Add _
Before:=Cell
Next Cell
End Sub
</code></pre>
<p>Then I delete Column A. It DOES work but I'd love to do it all in one step with a single VBA.</p>
<pre><code>I tried this, and it doesn't give me any errors, but it also doesn't do anything:
</code></pre>
<p>Sub AddPgBrk()</p>
<pre><code>Last = Cells(Columns.Count, "A").End(xlUp).Column
For i = Last To 1 Step -1
If (Right(Cells(i, "A"), 3)) = ":01" Then
ActiveWindow.ActiveSheet.HPageBreaks.Add _
Before:=Cell
End If
Next i
</code></pre>
<p>End Sub</p>
<pre><code>
Appreciate the look and assistance. Thanks everyone!
</code></pre>
| [
{
"answer_id": 74214366,
"author": "SJR",
"author_id": 7008044,
"author_profile": "https://Stackoverflow.com/users/7008044",
"pm_score": 1,
"selected": false,
"text": "Sub AddPgBrk()\n\nDim Last As Long, i As Long, n As Long, j As Long\n\nLast = Cells(Columns.Count, \"A\").End(xlUp).Row\... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214092",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2557004/"
] |
74,214,098 | <p>I must go through the records of a table and display them in multiple textboxes
I am using the table with four different alias to have four workareas on the same table and have four record pointers.</p>
<pre><code>USE Customers ALIAS customers1
USE customers AGAIN ALIAS customers2
USE customers AGAIN ALIAS customers3
USE customers AGAIN ALIAS customers4
Thisform.TxtNomCli.ControlSource = "customers.name"
Thisform.TxtIdent.ControlSource = "customers.identify"
Thisform.TxtAddress.ControlSource = "customers.address"
Thisform.TxtTele.ControlSource = "customers.phone"
Thisform.TxtNomCli2.ControlSource = "customers2.name"
Thisform.TxtIdent2.ControlSource = "customers2.identify"
Thisform.TxtDirec2.ControlSource = "customers2.address"
Thisform.TxtTele2.ControlSource = "customers2.phone"
Thisform.TxtNomCli3.ControlSource = "customers3.name"
Thisform.TxtIdent3.ControlSource = "customers3.identify"
Thisform.TxtDirec3.ControlSource = "customers3.address"
Thisform.TxtTele3.ControlSource = "customers3.phone"
Thisform.TxtNomCli4.ControlSource = "customers4.name"
Thisform.TxtIdent4.ControlSource = "customers4.identify"
Thisform.TxtDirec4.ControlSource = "customers4.address"
Thisform.TxtTele4.ControlSource = "customers4.phone"
</code></pre>
<p><a href="https://i.stack.imgur.com/JM2VP.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JM2VP.jpg" alt="main display" /></a></p>
<p>how to go through the records of the table, that in customers is in the first record, customers2 in the second record, customers3 in the third record and customers4 in the fourth record of the table?</p>
<p><a href="https://i.stack.imgur.com/gEwvl.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gEwvl.jpg" alt="table" /></a></p>
<p>How do I make each row of the textbox show the corresponding row of the table?</p>
| [
{
"answer_id": 74214366,
"author": "SJR",
"author_id": 7008044,
"author_profile": "https://Stackoverflow.com/users/7008044",
"pm_score": 1,
"selected": false,
"text": "Sub AddPgBrk()\n\nDim Last As Long, i As Long, n As Long, j As Long\n\nLast = Cells(Columns.Count, \"A\").End(xlUp).Row\... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214098",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8582484/"
] |
74,214,112 | <p>I am making a converting program in Python, and in this case it’s from feet to yards. I have having trouble with a specific line of code that is not showing an error message, yet refuses to actually work.</p>
<p>When I run the program and put the following numbers in the input (3, 2, 4, 1) the Yards should be 8, and the feet should be 0, but it stays on 7 yards, and doesn’t add the 3 extra feet into the yard amount.</p>
<pre><code>firstYard = int(input("Enter the Yards: "))
firstFeet = int(input("Enter the Feet: "))
secondYard = int(input("Enter the Yards: "))
secondFeet = int(input("Enter the Feet: "))
print("Yards: ")
print(int(firstYard + secondYard))
print(" Feet: ")
print(int(firstFeet + secondFeet) % 3)
if ((firstFeet + secondFeet) % 3) > 2:
** firstYard += 1
**
</code></pre>
<p>The last line is what I’m having trouble with.</p>
| [
{
"answer_id": 74214366,
"author": "SJR",
"author_id": 7008044,
"author_profile": "https://Stackoverflow.com/users/7008044",
"pm_score": 1,
"selected": false,
"text": "Sub AddPgBrk()\n\nDim Last As Long, i As Long, n As Long, j As Long\n\nLast = Cells(Columns.Count, \"A\").End(xlUp).Row\... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214112",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20341538/"
] |
74,214,122 | <p>Above code outputs basic Netflix movie name and images. Output comes just for a sec, then some error is coming on console related with maps, however it seems fine to be. what is the error here?
I used ReactJS here with useeffect hook, tried it for netflix clone</p>
<p><strong>Row.js:</strong></p>
<pre><code>function Row({ fetchUrl, title }) {
const baseURL = "https://image.tmdb.org/t/p/original/"
const [movies, setMovies] = useState([])
useEffect(() => {
async function fetchData() {
const request = await axios.get(fetchUrl)
setMovies(request.data.results)
return request
}
fetchData()
}, [fetchUrl])
return (
<div className="row">
<h2> {title} </h2>
{movies.map((movie) => (
<img src={`${baseURL}${movie.poster_path}`} alt={movie.name} />
))}
</div>
)
}
</code></pre>
<p><strong>requests.js:</strong></p>
<pre class="lang-js prettyprint-override"><code>const API_KEY = "ecfc81ae98ad1c0720b07e83400de828"
const requests = {
fetchTrending: `/trending/all/week?api_key=${API_KEY}&language=en-US`,
fetchNetflixOriginals: `discover/tv?api_key=${API_KEY}&with_networks=213`
}
</code></pre>
<p><strong>axios.js:</strong></p>
<pre><code>const instance = axios.create({
baseURL : "https://api.themoviedb.org/3",
});
</code></pre>
<p><strong>app.js:</strong></p>
<pre><code>function App() {
return (
<div ClassName="App">
<h1> Hey !! lets build Netflix</h1>
<Row title="Netflix Originals" fetchUrl={requests.netflixOriginals} />
<Row title="Trending" fetchUrl={requests.fetchTrending} />
</div>
)
}
</code></pre>
<p><strong>Error:</strong>
<a href="https://i.stack.imgur.com/E88By.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/E88By.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74214366,
"author": "SJR",
"author_id": 7008044,
"author_profile": "https://Stackoverflow.com/users/7008044",
"pm_score": 1,
"selected": false,
"text": "Sub AddPgBrk()\n\nDim Last As Long, i As Long, n As Long, j As Long\n\nLast = Cells(Columns.Count, \"A\").End(xlUp).Row\... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214122",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18410023/"
] |
74,214,125 | <p>I've been searching and every answer seems to be the same example (<a href="https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/" rel="nofollow noreferrer">https://kubernetes.io/docs/tasks/access-application-cluster/communicate-containers-same-pod-shared-volume/</a>). In a pod you can create an empty volume, then mount that into two containers and any content written in that mount will be seen on each container. While this is fine my use case is slightly different.</p>
<p>Container A
/opt/content</p>
<p>Container B
/data</p>
<p>Container A has an install of about 4G of data. What I would like to do is mount /opt/content into Container B at /content. This way the 4G of data is accessible to Container B at runtime and I don't have to copy content or specially build Container B.</p>
<p>My question, is this possible. If it is, what would be the proper pod syntax.</p>
<pre><code>apiVersion: v1
kind: Pod
metadata:
name: two-containers
spec:
restartPolicy: Never
volumes:
- name: shared-data
emptyDir: {}
containers:
- name: nginx-container
image: nginx
volumeMounts:
- name: shared-data
mountPath: /opt/content
- name: debian-container
image: debian
volumeMounts:
- name: shared-data
mountPath: /content
</code></pre>
| [
{
"answer_id": 74214366,
"author": "SJR",
"author_id": 7008044,
"author_profile": "https://Stackoverflow.com/users/7008044",
"pm_score": 1,
"selected": false,
"text": "Sub AddPgBrk()\n\nDim Last As Long, i As Long, n As Long, j As Long\n\nLast = Cells(Columns.Count, \"A\").End(xlUp).Row\... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214125",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17856333/"
] |
74,214,139 | <p>I have a problem where I need to merge 2 branches, both containing a README.md file.<a href="https://i.stack.imgur.com/sW2sw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sW2sw.png" alt="problem" /></a> If I try to merge the 2 branches with the readme to a 3rd branch, ofc the first one gets through without a problem. If I try the 2nd branch ofc it gives me a content conflict, because the 2nd readme would delete the email out of the 1st one. Now we were given a website which should have helped fix that with a mergetool, but if we try to change something via the mergetool the 2 lines seem to be "stuck" together, meaning if I change a line with local it changes both, same with remote. I'm pretty new to git etc. (like a few hours max) and I have no idea how to find a solution, so any help would be great^^</p>
<p>Trying to merge 2 README files, content conflict. Mergetool didn't work like i thought it would.</p>
| [
{
"answer_id": 74214366,
"author": "SJR",
"author_id": 7008044,
"author_profile": "https://Stackoverflow.com/users/7008044",
"pm_score": 1,
"selected": false,
"text": "Sub AddPgBrk()\n\nDim Last As Long, i As Long, n As Long, j As Long\n\nLast = Cells(Columns.Count, \"A\").End(xlUp).Row\... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214139",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20343196/"
] |
74,214,147 | <p>I use a Azure Datafactory Pipeline.
<a href="https://i.stack.imgur.com/3w5bm.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/3w5bm.png" alt="enter image description here" /></a></p>
<p>Within that pipeline i use 2 activities:</p>
<ol>
<li><p>Lookup to get a date value
This is the output:</p>
<p>"firstRow": {
"Date": "2022-10-26T00:00:00Z"</p>
</li>
<li><p>A dataflow which is getting the date from the lookup in 1 which is used in the source options SQL query in the where clause:</p>
</li>
</ol>
<p><a href="https://i.stack.imgur.com/5DkW8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5DkW8.png" alt="enter image description here" /></a></p>
<p>This is the query:</p>
<pre><code>"SELECT ProductID ,ProductName ,SupplierID,CategoryID ,QuantityPerUnit ,UnitPrice ,UnitsInStock,UnitsOnOrder,ReorderLevel,Discontinued,LastModifiedDate FROM Noordwind.Products where LastModifiedDate >= '{$DS_LastPipeLineRunDate}'"
</code></pre>
<p>When i fill the parameter by hand with for example '2022-10-26' then it works great, but when i let the parameter get's its value from the Lookup in step 1 the dataflow fails
Error message:</p>
<pre><code>{"message":"Job failed due to reason: Converting to a date or time failed due to an invalid character. Details:null","failureType":"UserError","target":"Products","errorCode":"DF-Executor-Conversion"}
</code></pre>
<p>This is the parameter in the pipeline view, but clicked on the dataflow:
<a href="https://i.stack.imgur.com/IMnBY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IMnBY.png" alt="enter image description here" /></a></p>
<p>I have tried casting the date al kind of things but not the right thing.
Can you help me.</p>
<p>UPDATE:
After a question from Rakesh:
This is the activity parameter
@activity('LookupLastPipelineRunDate').output.firstRow</p>
| [
{
"answer_id": 74214366,
"author": "SJR",
"author_id": 7008044,
"author_profile": "https://Stackoverflow.com/users/7008044",
"pm_score": 1,
"selected": false,
"text": "Sub AddPgBrk()\n\nDim Last As Long, i As Long, n As Long, j As Long\n\nLast = Cells(Columns.Count, \"A\").End(xlUp).Row\... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214147",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5188967/"
] |
74,214,163 | <p>I'm creating a flutter app that requires a user to complete certain tasks in order to stop an alarm clock. It's a more immersive alarm clock app that could help stimulate the brain in order to aid in the process of waking up.</p>
<p>The tasks are simple questions the user has to answer. I'm utilizing TextFeild() to allow the user to input their answer. However, when I go to debug my code is redirected to a file called box.dart this is where the error is stated.</p>
<p>Here is the box.dart file error:</p>
<pre><code>throw FlutterError.fromParts(<DiagnosticsNode>[
ErrorSummary('Cannot hit test a render box with no size.'),
describeForError('The hitTest() method was called on this RenderBox'),
ErrorDescription(
'Although this node is not marked as needing layout, '
'its size is not set.',
),
ErrorHint(
'A RenderBox object must have an '
'explicit size before it can be hit-tested. Make sure '
'that the RenderBox in question sets its size during layout.',
),
]);
}
</code></pre>
<p>Here is my full code:</p>
<pre><code>import 'package:flutter/material.dart';
import 'package:audioplayers/audioplayers.dart';
//import 'package:audioplayers/audio_cache.dart';
void main() {
runApp(const MyApp());
}
class MyApp extends StatelessWidget {
const MyApp({super.key});
@override
Widget build(BuildContext context) {
return MaterialApp(
debugShowCheckedModeBanner: false,
title: 'Time Attack',
theme: ThemeData(
primarySwatch: Colors.red,
),
home: const MyHomePage(),
);
}
}
class MyHomePage extends StatefulWidget {
const MyHomePage({super.key});
@override
State<MyHomePage> createState() => _MyHomePageState();
}
class _MyHomePageState extends State<MyHomePage> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
backgroundColor: Colors.red,
title: const Text('Time Attack'),
centerTitle: true,
),
floatingActionButton: FloatingActionButton(
onPressed: () async {
// ignore: avoid_print
print("alarm is playing");
final player = AudioCache();
//bool isPLaying = false;
await player.load('musicForapp.mp3');
AudioPlayer p = AudioPlayer();
p.audioCache = player;
await p.play(AssetSource('musicForapp.mp3'));
},
backgroundColor: Colors.red,
child: const Icon(Icons.punch_clock),
),
body: Padding(
padding: const EdgeInsets.all(170),
child: Column(
children: [
const Text(
"Click the Icon in the bottem right to simulate alarm",
style: TextStyle(
color: Colors.white,
fontSize: 30.0,
),
),
ElevatedButton(
style: ElevatedButton.styleFrom(backgroundColor: Colors.red),
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const TasksPage(),
),
);
}, //on pressed
child: const Text(
"Tasks page",
style: TextStyle(color: Colors.white),
),
)
],
),
),
),
);
} //widget build
}
class TasksPage extends StatefulWidget {
const TasksPage({super.key});
@override
State<TasksPage> createState() => _TasksPageState();
}
class _TasksPageState extends State<TasksPage> {
final _textcontroller = TextEditingController();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
backgroundColor: Colors.red,
title: const Text('Tasks'),
centerTitle: true,
),
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const SecondTask(),
),
);
},
backgroundColor: Colors.red,
child: const Text("Next"),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
const Text(
"How many states are there in the United States of America?",
style: TextStyle(
backgroundColor: Colors.white,
color: Colors.black,
fontSize: 30.0,
),
),
Expanded(
child: TextField(
controller: _textcontroller,
decoration: InputDecoration(
hintText: "Type your answer here!",
border: const OutlineInputBorder(),
suffixIcon: IconButton(
onPressed: () {
_textcontroller.clear();
},
icon: const Icon(Icons.clear),
),
),
),
),
],
),
),
),
),
);
} //widget build
}
class SecondTask extends StatefulWidget {
const SecondTask({super.key});
@override
State<SecondTask> createState() => _SecondTask();
}
class _SecondTask extends State<SecondTask> {
final _textcontroller2 = TextEditingController();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
backgroundColor: Colors.red,
title: const Text('Tasks'),
centerTitle: true,
),
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const Thirdtask(),
),
);
},
backgroundColor: Colors.red,
child: const Text("Next"),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
const Text(
"how many oceans are there?",
style: TextStyle(
backgroundColor: Colors.white,
color: Colors.black,
fontSize: 30.0,
),
),
Expanded(
child: TextField(
controller: _textcontroller2,
decoration: InputDecoration(
hintText: "Type your answer here!",
border: const OutlineInputBorder(),
suffixIcon: IconButton(
onPressed: () {
_textcontroller2.clear();
},
icon: const Icon(Icons.clear),
),
),
),
),
],
),
),
),
),
);
} //widget build
}
class Thirdtask extends StatefulWidget {
const Thirdtask({super.key});
@override
State<Thirdtask> createState() => _Thirdtask();
}
class _Thirdtask extends State<Thirdtask> {
final _textcontroller3 = TextEditingController();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
backgroundColor: Colors.red,
title: const Text('Tasks'),
centerTitle: true,
),
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const Finaltask(),
),
);
},
backgroundColor: Colors.red,
child: const Text("Next"),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
const Text(
"What is 8 x 7?",
style: TextStyle(
backgroundColor: Colors.white,
color: Colors.black,
fontSize: 30.0,
),
),
Expanded(
child: TextField(
controller: _textcontroller3,
decoration: InputDecoration(
hintText: "Type your answer here!",
border: const OutlineInputBorder(),
suffixIcon: IconButton(
onPressed: () {
_textcontroller3.clear();
},
icon: const Icon(Icons.clear),
),
),
),
),
],
),
),
),
),
);
} //widget build
}
class Finaltask extends StatefulWidget {
const Finaltask({super.key});
@override
State<Finaltask> createState() => _Finaltask();
}
class _Finaltask extends State<Finaltask> {
final _textcontroller4 = TextEditingController();
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
backgroundColor: Colors.red,
title: const Text('Tasks'),
centerTitle: true,
),
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const Congrats(),
),
);
},
backgroundColor: Colors.red,
child: const Text("Submit"),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: [
const Text(
"Riddle: What goes up but never comes back down?",
style: TextStyle(
backgroundColor: Colors.white,
color: Colors.black,
fontSize: 30.0,
),
),
Expanded(
child: TextField(
controller: _textcontroller4,
decoration: InputDecoration(
hintText: "Type your answer here!",
border: const OutlineInputBorder(),
suffixIcon: IconButton(
onPressed: () {
_textcontroller4.clear();
},
icon: const Icon(Icons.clear),
),
),
),
),
],
),
),
),
),
);
} //widget build
}
class Congrats extends StatefulWidget {
const Congrats({super.key});
@override
State<Congrats> createState() => _Congrats();
}
class _Congrats extends State<Congrats> {
@override
Widget build(BuildContext context) {
return MaterialApp(
home: Scaffold(
backgroundColor: Colors.black,
appBar: AppBar(
backgroundColor: Colors.red,
title: const Text('Good Job!'),
centerTitle: true,
),
floatingActionButton: FloatingActionButton(
onPressed: () {
Navigator.push(
context,
MaterialPageRoute(
builder: (_) => const MyHomePage(),
),
);
//player.clear('explosion.mp3'); (to stop alarm)
// ignore: avoid_print
print("Alarm has stoped");
},
backgroundColor: Colors.red,
child: const Text("Home"),
),
body: Padding(
padding: const EdgeInsets.all(8.0),
child: Center(
child: Row(
mainAxisAlignment: MainAxisAlignment.spaceEvenly,
children: const [
Expanded(
child: Text(
"Congratulations you completed your tasks, Click the home button to return home and stop the timer!",
style: TextStyle(
backgroundColor: Colors.white,
color: Colors.black,
fontSize: 30.0,
),
),
),
],
),
),
),
),
);
} //widget build
}
</code></pre>
| [
{
"answer_id": 74214366,
"author": "SJR",
"author_id": 7008044,
"author_profile": "https://Stackoverflow.com/users/7008044",
"pm_score": 1,
"selected": false,
"text": "Sub AddPgBrk()\n\nDim Last As Long, i As Long, n As Long, j As Long\n\nLast = Cells(Columns.Count, \"A\").End(xlUp).Row\... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15615382/"
] |
74,214,168 | <p>I am using Query to pull Columns A and B from another sheet like this:</p>
<pre><code>Query(Tank_List!A1:M716, "select A,E, SUM (E) Where B=1 Group by A,E",1)
</code></pre>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Column A</th>
<th>Column B</th>
<th>Column C</th>
</tr>
</thead>
<tbody>
<tr>
<td>Item 1</td>
<td>9240</td>
<td>9240</td>
</tr>
<tr>
<td>Item 2</td>
<td>11843</td>
<td>11843</td>
</tr>
<tr>
<td>Item 3</td>
<td>6372</td>
<td>6372</td>
</tr>
<tr>
<td>Item 4</td>
<td>8320</td>
<td>8320</td>
</tr>
<tr>
<td>Item 5</td>
<td>16365</td>
<td>16365</td>
</tr>
<tr>
<td>Item 6</td>
<td>1234</td>
<td>1234</td>
</tr>
</tbody>
</table>
</div>
<p>Instead of returning the actual Sum of ColB (The SUM of the Range of numbers from ColB) it returns just a copy of ColB on it's line.</p>
<p>I've tried several ways but the issue is SUM returns a single total for ColB or as above, the SUM of just the Row.</p>
<p>I am hoping for something like this:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Column A</th>
<th>Column B</th>
<th>Column C</th>
<th>Column D</th>
</tr>
</thead>
<tbody>
<tr>
<td>Item 1</td>
<td>9240</td>
<td>53374</td>
<td>ColC/ColB</td>
</tr>
<tr>
<td>Item 2</td>
<td>11843</td>
<td>53374</td>
<td>ColC/ColB</td>
</tr>
<tr>
<td>Item 3</td>
<td>6372</td>
<td>53374</td>
<td>ColC/ColB</td>
</tr>
<tr>
<td>Item 4</td>
<td>8320</td>
<td>53374</td>
<td>ColC/ColB</td>
</tr>
<tr>
<td>Item 5</td>
<td>16365</td>
<td>53374</td>
<td>ColC/ColB</td>
</tr>
<tr>
<td>Item 6</td>
<td>1234</td>
<td>53374</td>
<td>ColC/ColB</td>
</tr>
</tbody>
</table>
</div>
<p>Where I can do equations based on the original range numbers and the total SUM of that range. I imagine the answer will have to do with ArrayFormula, but I could not make it work myself.</p>
| [
{
"answer_id": 74214435,
"author": "Terio",
"author_id": 4840576,
"author_profile": "https://Stackoverflow.com/users/4840576",
"pm_score": 1,
"selected": false,
"text": "FILTER"
},
{
"answer_id": 74214550,
"author": "pgSystemTester",
"author_id": 11732320,
"author_pro... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214168",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20115992/"
] |
74,214,170 | <p>I´m new in JavaScript.
I´d like to convert the conditional If to a ternary operator, but I don´t know how.
I leave all the code below in case someone can help me.
Thanks in advance.</p>
<pre><code><body>
<img src="images/animal.jpg" width="200" height="200">
<button onclick="change()" type="button">Change</button>
<script>
let estadoCambio = true;
function change(){
if (!estadoCambio){
document.images[0].src="images/animal.jpg";
estadoCambio = true;
} else {
document.images[0].src="images/flor.jpg";
estadoCambio = false;
}
}
</script>
</body>
</code></pre>
<p>I tried using expressions like:</p>
<ul>
<li>condition ? (()=>{expresion1; expresion2})() : (()=>{expresion3; expresion4})()</li>
<li>condition ? [] : []</li>
</ul>
<p>But no one works.</p>
<p>I am looking to change it by order of my programming teacher.</p>
| [
{
"answer_id": 74214222,
"author": "Barmar",
"author_id": 1491895,
"author_profile": "https://Stackoverflow.com/users/1491895",
"pm_score": 1,
"selected": true,
"text": "[document.images[0].src, estadoCambio] = estadoCambio ? \n [\"images/flor.jpg\", false] : \n [\"images/animal.jp... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214170",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18543328/"
] |
74,214,178 | <p>The edited task reflects on browser only when I delete an existing task or add a new one.
The edited task is even reflected in the prompt as the pre-existing task, but the edited text is not reflected in the task.</p>
<pre><code>import * as React from 'react';
import Card from 'react-bootstrap/Card';
import Add from './Add';
import List from './List';
import Table from 'react-bootstrap/Table';
const Main = () => {
const [listData, setListData] = React.useState([]);
const listDataMani = (text) => {
const listDataObj = {
id: listData.length + 1,
text: text,
}
const finalList = [...listData, listDataObj]
setListData(finalList);
}
const listDataDelete = (id) => {
const finalData = listData.filter(function (el) {
if (el.id === id) {
return false;
} else {
return true;
}
})
setListData(finalData);
}
const editTaskHandler = (t, li) => {
let compData = listData; // this is the function to update text
for (let i = 0; i < listData.length; i++) {
if (listData[i].id === li) {
listData[i].text = t;
} else {
return;
}
}
setListData(compData);
}
return (
<><div className='container'>
<div className='col-lg-12'>
<div className='main-component'>
<div className='title'>
<Card style={{ marginTop: "10em" }}>
<Card.Body>
<Card.Title>My Todo List</Card.Title>
<Card.Subtitle className="mb-2 text-muted">Manages Time</Card.Subtitle>
<Add listDataMani={listDataMani} />
<Table striped bordered hover>
<thead>
<tr>
<th>#</th>
<th>Task Name</th>
<th>Action</th>
</tr>
</thead>
<tbody>
<List callback={listDataDelete} editTask={editTaskHandler} list={listData} />
</tbody>
</Table>
</Card.Body>
</Card>
</div>
</div>
</div>
</div></>
)
}
export default Main;
</code></pre>
<pre><code>import * as React from 'react';
const List =(props)=>{
const deleteHandler =(id)=>{
props.callback(id);
}
const editRequestHandler =(data)=>{
let editedText = prompt("Edit Your Task", data.text);
props.editTask(editedText, data.id);
}
return (
<>
{props.list.map((el)=>(<tr>
<td>{el.id}</td>
<td>{el.text}</td>
<td>
<button onClick={function(){
deleteHandler(el.id)
}}>X</button>
<button onClick={()=>{editRequestHandler(el)}}>✍</button>
</td>
</tr>))}
</>
)
}
export default List;
</code></pre>
<p>The edited task reflects on browser only when I delete an existing task or add a new one.
The edited task is even reflected in the prompt as the pre-existing task, but the edited text is not reflected in the task.</p>
| [
{
"answer_id": 74214218,
"author": "saguirrews",
"author_id": 11286403,
"author_profile": "https://Stackoverflow.com/users/11286403",
"pm_score": 1,
"selected": true,
"text": "const editTaskHandler = (t, li) => {\n setListData(\n listData.map((item) => {\n if (item.id === ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214178",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19084111/"
] |
74,214,226 | <p>I want to execute a function conditionally and rest of the other functions by default irrespective of the first condition being true or false.</p>
<p>Ex: `</p>
<pre><code>(defn- publish
[txn publisher domain-slug template first-published-at]
(if (= 2 2) (do (somefunc txn publisher)))
(firstfunc txn publisher domain-slug first-published-at)
(secondfunc txn publisher)
)
</code></pre>
<p>`</p>
<p>I want to execute all the three functions if true and execute the last two functions if false.</p>
| [
{
"answer_id": 74214641,
"author": "Gwang-Jin Kim",
"author_id": 9690090,
"author_profile": "https://Stackoverflow.com/users/9690090",
"pm_score": 2,
"selected": false,
"text": "when"
},
{
"answer_id": 74262233,
"author": "Aditya R Pai",
"author_id": 2828162,
"author_... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214226",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10757984/"
] |
74,214,228 | <p>I am new to typescript and vue 3 js. I wrote a single-file-component and want to use a Bootstrap 5 modal. But my VSCode shows a error on my declared variable type. The error says:</p>
<blockquote>
<p>"Modal" refers to a value, but is used here as a type. Did you mean
"type of modal"?</p>
</blockquote>
<pre><code><script setup lang="ts">
import { Modal } from "bootstrap";
let modal: Modal = null;
...
</script>
</code></pre>
<p>I install via npm bootstrap and all JS type from bootstrap with</p>
<pre><code>npm install --save-dev @types/bootstrap
</code></pre>
<p>Has anyone a idea?</p>
| [
{
"answer_id": 74214641,
"author": "Gwang-Jin Kim",
"author_id": 9690090,
"author_profile": "https://Stackoverflow.com/users/9690090",
"pm_score": 2,
"selected": false,
"text": "when"
},
{
"answer_id": 74262233,
"author": "Aditya R Pai",
"author_id": 2828162,
"author_... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214228",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/813556/"
] |
74,214,262 | <p>I have a <code>PostgreSQL 12.x</code> database. There is a column <code>data</code> in a table <code>typename</code> that contains <code>jsonb</code> values. The actual JSON data is not fixed to a particular structure; these are some examples:</p>
<pre class="lang-json prettyprint-override"><code>{"emt": {"key": " ", "source": "INPUT"}, "id": 1, "fields": {}}
{"emt": {"key": "Stack Overflow", "source": "INPUT"}, "id": 2, "fields": {}}
{"emt": {"key": "https://www.domain.tld/index.html", "source": "INPUT"}, "description": {"key": "JSONB datatype", "source": "INPUT"}, "overlay": {"id": 5, "source": "bOv"}, "fields": {"id": 1, "description": "Themed", "recs ": "1"}}
</code></pre>
<p>What I'm trying to do is to get all the JSON keys bound to objects that:</p>
<ol>
<li>Contain only two elements: <code>key</code> and <code>source</code></li>
<li><code>source</code> element must be bound to <code>"INPUT"</code></li>
</ol>
<p>Basically, for this example, the result should be: <code>emt</code>, <code>description</code>.</p>
<p>This is what I have so far, but it's not quite working as expected:</p>
<pre class="lang-sql prettyprint-override"><code>select distinct jsonb_object_keys(data) as keys
from typename
where jsonb_path_exists(data, '$.** ? (@.type() == "string" && @ like_regex "INPUT")');
-- where jsonb_typeof(data -> ???) = 'object'
-- and jsonb_path_exists(data, '$.???.key ? (@.type() == "string")')
-- and jsonb_path_exists(data, '$.???.source ? (@.type() == "string" && @ like_regex "INPUT")');
</code></pre>
| [
{
"answer_id": 74226501,
"author": "Ramin Faracov",
"author_id": 17296084,
"author_profile": "https://Stackoverflow.com/users/17296084",
"pm_score": 1,
"selected": false,
"text": "with tbl as (\nselect '{\"emt\": {\"key\": \" \", \"source\": \"INPUT\"}, \"id\": 1, \"fields\": {}}'::jsonb... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214262",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4695271/"
] |
74,214,266 | <p>So I am creating a E-Commerce API using the Django Rest Framework and I have been trying to send the name of the Item instead of the PK of the Item to create an order.</p>
<p>These are the models I am using:</p>
<pre><code>class Product(models.Model):
product_tag = models.CharField(max_length=10)
name = models.CharField(max_length=100)
description = models.CharField(max_length=500, null=True, blank=True)
category = models.ForeignKey(Category, on_delete=models.CASCADE)
price = models.IntegerField()
stock = models.IntegerField()
image = models.ImageField(default="default.png")
in_stock = models.BooleanField(default=True)
date_created = models.DateField(auto_now_add=True)
class Meta:
ordering = ["-date_created"]
def __str__(self):
return self.name
</code></pre>
<pre><code>class PlacedOrder(models.Model):
ordered_by = models.ForeignKey(User, on_delete=models.CASCADE)
first_name = models.CharField(max_length=100)
last_name = models.CharField(max_length=100)
phone = models.CharField(max_length=15)
address = models.CharField(max_length=100)
zipcode = models.CharField(max_length=100)
items = models.ManyToManyField(Product)
total_price = models.IntegerField()
created_at = models.DateTimeField(auto_now_add=True)
class Meta:
ordering = ["-created_at"]
def __str__(self):
return f"{self.ordered_by}"
</code></pre>
<p>This is my serializer that I am working with to create an order:</p>
<pre><code>class PlacedOrderSerializer(serializers.ModelSerializer):
ordered_by = serializers.ReadOnlyField(source="ordered_by.email")
class Meta:
model = PlacedOrder
fields = (
"id",
"created_at",
"ordered_by",
"first_name",
"last_name",
"phone",
"address",
"zipcode",
"items",
"total_price",
)
</code></pre>
<p>Here is the view I am using to create an order:</p>
<pre><code>class CreateOrder(generics.ListCreateAPIView):
permission_classes = [IsAuthenticated]
queryset = PlacedOrder.objects.all()
serializer_class = PlacedOrderSerializer
def perform_create(self, serializer):
serializer.save(ordered_by=self.request.user)
</code></pre>
<p>This is my input in POSTMAN:</p>
<pre><code>{
"first_name": "yes",
"last_name": "no",
"phone": "0100000000",
"address": "whatever address",
"zipcode": "254",
"items": [
1,
1,
2
],
"total_price": "69"
}
</code></pre>
<p>and this is the output:</p>
<pre><code>{
"id": 13,
"created_at": "2022-10-26T20:56:08.789574Z",
"ordered_by": "bal@bal.com",
"first_name": "yes",
"last_name": "no",
"phone": "0100000000",
"address": "whatever address",
"zipcode": "254",
"items": [
1,
2
],
"total_price": 69
}
</code></pre>
<p>I basically want it to take the name and quantity of the items instead of the PK of the product in the input.</p>
<p>I have tried using RelatedField but that makes it so that "items" just goes null to the backend without taking any products and makes a blank order.</p>
| [
{
"answer_id": 74226501,
"author": "Ramin Faracov",
"author_id": 17296084,
"author_profile": "https://Stackoverflow.com/users/17296084",
"pm_score": 1,
"selected": false,
"text": "with tbl as (\nselect '{\"emt\": {\"key\": \" \", \"source\": \"INPUT\"}, \"id\": 1, \"fields\": {}}'::jsonb... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20343259/"
] |
74,214,301 | <p>I've written so many pure CSS lines of code and I have never been in a situation where I do not know where the property is coming from.
The inline CSS works, but not the class/id.
Doctype is typed correctly.
I've spent a loooot of time researching, and nothing helped.
You are my only hope.</p>
<p>The html:</p>
<pre><code> <div className='insideContainer'>
<div className='default'>hello</div>
<div className='default'>hello</div>
<div className='default'>hello</div>
<div className='default'>hello</div>
<div className='default'>hello</div>
<div className='default'>hello</div>
<div className='default'>hello</div>
<div className='default'>hello</div>
<div className='default'>hello</div>
</div>
</code></pre>
<p>The CSS:</p>
<pre><code>.insideContainer {
width: 300px;
height: 400px;
border: 1px solid #888;
overflow: scroll;
margin: 0 auto;
}
.default {
background-color: 'blue';
width: 200px;
height: 50px;
margin: 5px;
display: 'flex';
justify-content: 'center';
align-items: 'center';
border: 1px solid #888;
}
</code></pre>
<p>The browser:</p>
<p><a href="https://i.stack.imgur.com/XWuyU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/XWuyU.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/BEISI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BEISI.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74214335,
"author": "kind user",
"author_id": 6695924,
"author_profile": "https://Stackoverflow.com/users/6695924",
"pm_score": 3,
"selected": true,
"text": "background-color: 'blue';\n"
},
{
"answer_id": 74214422,
"author": "DCR",
"author_id": 4398966,
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214301",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15946228/"
] |
74,214,318 | <p>I'm a beginner following this Django tutorial (<a href="https://www.w3schools.com/django/django_templates.php" rel="nofollow noreferrer">https://www.w3schools.com/django/django_templates.php</a>) and I'm getting the error bellow after making the html template and modifying the views.py file (name erased for privacy):</p>
<pre class="lang-none prettyprint-override"><code>Internal Server Error: /members
Traceback (most recent call last):
File "C:\Users\\myproject\lib\site-packages\django\core\handlers\exception.py", line 55, in inner
response = get_response(request)
File "C:\Users\\myproject\lib\site-packages\django\core\handlers\base.py", line 197, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "C:\Users\\myproject\myworld\members\views.py", line 5, in index
template = loader.get_template('myfirst.html')
File "C:\Users\\myproject\lib\site-packages\django\template\loader.py", line 19, in get_template
raise TemplateDoesNotExist(template_name, chain=chain)
django.template.exceptions.TemplateDoesNotExist: myfirst.html
[26/Oct/2022 16:51:01] "GET /members HTTP/1.1" 500 64964
</code></pre>
<p>Tried this:</p>
<pre><code>from django.http import HttpResponse
from django.shortcuts import loader
def index(request):
template = loader.get_template('myfirst.html')
return HttpResponse(template.render())
</code></pre>
<p>Expecting this:</p>
<pre class="lang-html prettyprint-override"><code><!DOCTYPE html>
<html>
<body><h1>Hello World!</h1>
<p>Welcome to my first Django project!</p>
</body>
</html>
</code></pre>
| [
{
"answer_id": 74214335,
"author": "kind user",
"author_id": 6695924,
"author_profile": "https://Stackoverflow.com/users/6695924",
"pm_score": 3,
"selected": true,
"text": "background-color: 'blue';\n"
},
{
"answer_id": 74214422,
"author": "DCR",
"author_id": 4398966,
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20207069/"
] |
74,214,358 | <p>Basically, I am trying to get it so that when the user types in a lowercase letter, let's say "a", the screen will output an uppercase "A" instead. This is in flutter web using a keyboard. Any ideas?</p>
| [
{
"answer_id": 74214923,
"author": "Antonin Liehn",
"author_id": 18290590,
"author_profile": "https://Stackoverflow.com/users/18290590",
"pm_score": 1,
"selected": false,
"text": "TextFormField"
},
{
"answer_id": 74222884,
"author": "Yeasin Sheikh",
"author_id": 10157127,... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14868799/"
] |
74,214,376 | <p>There is a PHP function that can highlight a word regardless of case or accents, but the string returned will be the original string with only the highlighting?
For example:</p>
<pre><code>Function highlight($string, $term_to_search){
// ...
}
echo highlight("my Striñg", "string")
// Result: "my <b>Striñg</b>"
</code></pre>
<p>Thanks in advance!</p>
<p><strong>What I tried</strong>:</p>
<p>I tried to do a function that removed all accents & caps, then did a "str_replace" with the search term but found that the end result logically had no caps or special characters when I expected it to be just normal text but highlighted.</p>
| [
{
"answer_id": 74214923,
"author": "Antonin Liehn",
"author_id": 18290590,
"author_profile": "https://Stackoverflow.com/users/18290590",
"pm_score": 1,
"selected": false,
"text": "TextFormField"
},
{
"answer_id": 74222884,
"author": "Yeasin Sheikh",
"author_id": 10157127,... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10718120/"
] |
74,214,378 | <p>when I enter the detail page in Laravel, it gives an error. I don't understand where the error is coming from. My codes are as follows.
where is the problem? actually it says it's empty, but it needs to pull data from $blog on controller side.</p>
<p>Controller:</p>
<pre><code>public function show($id)
{
$blog = Blog::where('id',$id)->first();
return view('front.detail',compact('blog'));
}
</code></pre>
<p>routes/web.php:</p>
<pre><code>Route::prefix('{lang?}')->middleware('locale')->group(function() {
Route::get('/', [MainController::class, 'index'])->name('home');
Route::get('/about', [MainController::class, 'about'])->name('about');
Route::resource('/blogs', MainController::class)->only([ 'show']);
});
</code></pre>
<p>detail.blade.php:</p>
<pre><code><li>
<h2><a href="">{{$blog->title}}</a></h2>
<p>{!! $blog->text !!}</p>
</li>
</code></pre>
| [
{
"answer_id": 74214401,
"author": "matiaslauriti",
"author_id": 1998801,
"author_profile": "https://Stackoverflow.com/users/1998801",
"pm_score": 0,
"selected": false,
"text": "find"
},
{
"answer_id": 74214644,
"author": "Ray C",
"author_id": 10257689,
"author_profil... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214378",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20343366/"
] |
74,214,379 | <pre><code>prime <- function(number){
if (number!=2){
for (num in 1:number){
while ((number%%num)==0){
counter <- 0
counter <- counter+1
}
}
return((counter-2)==0)
}else{
FALSE
}
}
</code></pre>
<p>My function was designed for prime test, prime numbers only divided by itself and 1. So I've looped all the numbers from 1 to n(number itself) and counted the number of the 0 remainder divisions. Result must be 2 (n/n and n/1 remainders are 0) so (counter-2)==0 returns TRUE if the number is the prime number. Only exception is 2. But my code doesn't working also stops the RStudio. Code line arrows disappearing, R stops return any value.<br />
What is wrong with this code?</p>
| [
{
"answer_id": 74214401,
"author": "matiaslauriti",
"author_id": 1998801,
"author_profile": "https://Stackoverflow.com/users/1998801",
"pm_score": 0,
"selected": false,
"text": "find"
},
{
"answer_id": 74214644,
"author": "Ray C",
"author_id": 10257689,
"author_profil... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20343329/"
] |
74,214,397 | <p>The syntax below absolutely works to stop a process on a remote computer:</p>
<pre><code>$hostname = 'PC1'
$process = 'program1*'
$Session = New-PSSession $Hostname
Invoke-Command -Session $Session -ScriptBlock {param($process) Stop-Process -ProcessName $process -Force} -ArgumentList $process
$Session | Remove-PSSession
</code></pre>
<p>However, in Jenkins, I parameterized hostname and process, so the user enters the input hostname and process, and Jenkins creates the two variables $env:hostname and $env:process. This is not working well, the argument is not being passed onto Stop-Process:</p>
<pre><code>$session = New-PSSession $env:hostname
Invoke-Command -Session $session -ScriptBlock {param($env:process) Stop-Process -ProcessName $env:process -Force} -ArgumentList $env:process
$Session | Remove-PSSession
</code></pre>
<p>The error I'm getting is</p>
<pre><code>Cannot bind argument to parameter 'Name' because it is null.
At C:\Users\user.name\AppData\Local\Temp\jenkins10480966582412717483.ps1:25 char:1
+ Invoke-Command -Session $session -ScriptBlock {param($env:process) St ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidData: (:) [Stop-Process], ParameterBindingValidationException
+ FullyQualifiedErrorId : ParameterArgumentValidationErrorNullNotAllowed,Microsoft.PowerShell.Commands.StopProcess
Command
+ PSComputerName : pc1
Build step 'PowerShell' marked build as failure
Finished: FAILURE
</code></pre>
<p>I know this has something to do with quotes, please give me a hand, thank you!</p>
| [
{
"answer_id": 74215758,
"author": "mklement0",
"author_id": 45375,
"author_profile": "https://Stackoverflow.com/users/45375",
"pm_score": 2,
"selected": true,
"text": "Invoke-Command"
},
{
"answer_id": 74221280,
"author": "Dennis",
"author_id": 8014824,
"author_profi... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214397",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6466972/"
] |
74,214,419 | <p>I have a function that produces an output like so when I pass it a name:</p>
<p><code>W2V('aamir')</code></p>
<pre><code>array([ 0.12135 , -0.99132 , 0.32347 , 0.31334 , 0.97446 , -0.67629 ,
0.88606 , -0.11043 , 0.79434 , 1.4788 , 0.53169 , 0.95331 ,
-1.1883 , 0.82438 , -0.027177, 0.70081 , 0.87467 , -0.095825,
-0.5937 , 1.4262 , 0.2187 , 1.1763 , 1.6294 , 0.91717 ,
-0.086697, 0.16529 , 0.19095 , -0.39362 , -0.40367 , 0.83966 ,
-0.25251 , 0.46286 , 0.82748 , 0.93061 , 1.136 , 0.85616 ,
0.34705 , 0.65946 , -0.7143 , 0.26379 , 0.64717 , 1.5633 ,
-0.81238 , -0.44516 , -0.2979 , 0.52601 , -0.41725 , 0.086686,
0.68263 , -0.15688 ], dtype=float32)
</code></pre>
<p>I have a data frame that has an index <code>Name</code> and a single column <code>Y</code>:</p>
<p><code>df1</code></p>
<pre>
Y
Name
aamir 0
aaron 0
... ...
zulema 1
zuzana 1
</pre>
<p>I wish to run my function on each value of <code>Name</code> and have it create columns like so:</p>
<pre>
0 1 2 3 4 5 6 7 8 9 ... 40 41 42 43 44 45 46 47 48 49
Name
aamir 0.12135 -0.99132 0.32347 0.31334 0.97446 -0.67629 0.88606 -0.11043 0.794340 1.47880 ... 0.647170 1.56330 -0.81238 -0.445160 -0.29790 0.52601 -0.41725 0.086686 0.68263 -0.15688
aaron -1.01850 0.80951 0.40550 0.09801 0.50634 0.22301 -1.06250 -0.17397 -0.061715 0.55292 ... -0.144960 0.82696 -0.51106 -0.072066 0.43069 0.32686 -0.00886 -0.850310 -1.31530 0.71631
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
zulema 0.56547 0.30961 0.48725 1.41000 -0.76790 0.39908 0.86915 0.68361 -0.019467 0.55199 ... 0.062091 0.62614 0.44548 -0.193820 -0.80556 -0.73575 -0.30031 -1.278900 0.24759 -0.55541
zuzana -1.49480 -0.15111 -0.21853 0.77911 0.44446 0.95019 0.40513 0.26643 0.075182 -1.34340 ... 1.102800 0.51495 1.06230 -1.587600 -0.44667 1.04600 -0.38978 0.741240 0.39457 0.22857
</pre>
<p>What I have done is real messy, but works:</p>
<pre><code>names = df1.index.to_list()
Lst = []
for name in names:
Lst.append(W2V(name).tolist())
wv_df = pd.DataFrame(index=names, data=Lst)
wv_df.index.name = "Name"
wv_df.sort_index(inplace=True)
df1 = df1.merge(wv_df, how='inner', left_index=True, right_index=True)
</code></pre>
<p>I am hoping there is a way to use .apply() or similar but I have not found how to do this. I am looking for an efficient way.</p>
<p>Update:</p>
<p>I modified my function to do like so:</p>
<pre><code>if isinstance(w, pd.core.series.Series):
w = w.to_string()
</code></pre>
<p>Although this appears to work at first, the data is wrong. If I pass <code>aamir</code> to my function you can see the result. Yet when I do it with apply the numbers are totally different:</p>
<pre><code>df1
Name Y
0 aamir 0
1 aaron 0
... ... ...
7942 zulema 1
7943 zuzana 1
df3 = df1.reset_index().drop('Y', axis=1).apply(W2V, axis=1, result_type='expand')
0 1 2 3 4 5 6 7 8 9 ... 40 41 42 43 44 45 46 47 48 49
0 0.075014 0.824769 0.580976 0.493415 0.409894 0.142214 0.202602 -0.599501 -0.213184 -0.142188 ... 0.627784 0.136511 -0.162938 0.095707 -0.257638 0.396822 0.208624 -0.454204 0.153140 0.803400
1 0.073664 0.868665 0.574581 0.538951 0.394502 0.134773 0.233070 -0.639365 -0.194892 -0.110557 ... 0.722513 0.147112 -0.239356 -0.046832 -0.237434 0.321494 0.206583 -0.454038 0.251605 0.918388
... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ... ...
7942 -0.002117 0.894570 0.834724 0.602266 0.327858 -0.003092 0.197389 -0.675813 -0.311369 -0.174356 ... 0.690172 -0.085517 -0.000235 -0.214937 -0.290900 0.361734 0.290184 -0.497177 0.285071 0.711388
7943 -0.047621 0.850352 0.729225 0.515870 0.439999 0.060711 0.226026 -0.604846 -0.344891 -0.128396 ... 0.557035 -0.048322 -0.070075 -0.265775 -0.330709 0.281492 0.304157 -0.552191 0.281502 0.750304
7944 rows × 50 columns
</code></pre>
<p>You can see that the first row is <code>aamir</code> and the first value (column 0) my function returns is 0.1213 (You can see this at the top of my post). Yet with apply that appears to be 0.075014</p>
<p>EDIT:</p>
<p>It appears it passes in <code>Name aamir</code> rather than <code>aamir</code>. How can I get it to just send the Name itself <code>aamir</code>?</p>
| [
{
"answer_id": 74215283,
"author": "Nicholas Hansen-Feruch",
"author_id": 11280068,
"author_profile": "https://Stackoverflow.com/users/11280068",
"pm_score": 0,
"selected": false,
"text": "df.reset_index().drop(0, axis=1).apply(my_func, axis=1, result_type='expand')\n"
},
{
"answ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214419",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1843635/"
] |
74,214,453 | <p>My code:</p>
<pre><code>list=[["Uno","Dos"],[1,2],["Tres","Cuatro"],[3,4]]
print(list)
list[4][0].insert(A)
New_list=[[],[],[],[]]
A=list[0][0]+str(list[1][0])
B=(list[0][0]+str(list[1][0]))[::-1]
C=list[0][1]+str(list[1][1])
D=(list[0][1]+str(list[1][1]))[::-1]
E=list[2][0]+str(list[3][0])
F=(list[2][0]+str(list[3][0]))[::-1]
G=list[2][1]+str(list[3][1])
H=(list[2][1]+str(list[3][1]))[::-1]
New_list[0][0].append(A)
print(New_list)
</code></pre>
<p>My expectation:</p>
<pre><code>[["Uno1","1onU"],["Dos2","2soD"],["Tres3","3serT"],["Cuatro4","4ortauC"]]
</code></pre>
<p>I've tried to use append and insert but every time I get an error message; usually "list index is out of range"</p>
<p>How can I add my values to New_list?</p>
| [
{
"answer_id": 74215283,
"author": "Nicholas Hansen-Feruch",
"author_id": 11280068,
"author_profile": "https://Stackoverflow.com/users/11280068",
"pm_score": 0,
"selected": false,
"text": "df.reset_index().drop(0, axis=1).apply(my_func, axis=1, result_type='expand')\n"
},
{
"answ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214453",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20343089/"
] |
74,214,560 | <p>I have problem in writting variable as key in array</p>
<pre class="lang-js prettyprint-override"><code> setOrderedItems((cartItem) => ({...cartItem, item.id: item.name}));
</code></pre>
<p>I've tried <code>{item.id}</code> and <code>${item.id}</code>, but nothing works.</p>
<pre class="lang-js prettyprint-override"><code> const [orderedItems, setOrderedItems] = useState([]);
const handleOnChange = (item, eventStatus) => {
if(eventStatus){
setOrderedItems((cartItem) => ({...cartItem, [item.id]: item.name}));
}
}
</code></pre>
<p>The item is a single item that has a structure.</p>
<pre class="lang-js prettyprint-override"><code> /* first item */ {id: 1, name: 'test1'}
/* second item */ {id: 1, name: 'test2'}
/* third item */ {id: 2, name: 'test3}
</code></pre>
<p>What I want to achive is <code>{1: ['test1', 'test2'], 2: 'test3'}</code></p>
| [
{
"answer_id": 74215283,
"author": "Nicholas Hansen-Feruch",
"author_id": 11280068,
"author_profile": "https://Stackoverflow.com/users/11280068",
"pm_score": 0,
"selected": false,
"text": "df.reset_index().drop(0, axis=1).apply(my_func, axis=1, result_type='expand')\n"
},
{
"answ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10015521/"
] |
74,214,606 | <p>I have a list like this.</p>
<pre><code>[['Year', 'Salary', 'Yearly Income'],
[2, 2500, 30000],
[2, 3000.0, 36000.0],
[2, 3600.0, 43200.0],
[2, 4320.0, 51840.0],
[2, 5184.0, 62208.0],
[2, 6220.8, 74649.6]
]
</code></pre>
<p>I need print Like this</p>
<p><a href="https://i.stack.imgur.com/Z9q6j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z9q6j.png" alt="enter image description here" /></a></p>
<p>How can I do that in Python?</p>
<p>here is my code</p>
<pre class="lang-py prettyprint-override"><code>work_experience = 0
year = 1
cnt =0
basic_salary = 2500
salary_list = [["Year", "Salary", "Yearly Income"]]
input_name = input("Please Enter Your Name: ")
print("Welcome ", input_name)
work_experience = int(input("How many years of work experience do you have? : "))
for years in range (int(work_experience / 2)):
# calculate incremented salary after 2 years
# Increment happens every 2 years with 20% and decimal precison of 2
basic_salary = round(basic_salary + (basic_salary * 0.2), 2)
for years in range (6):
# calculate yearly_income by multiplying current_salary with 12
yearly_income = round((basic_salary * 12), 2)
salary_list.append([year+1, basic_salary, yearly_income])
# update current salary
basic_salary = round(basic_salary + (basic_salary * 0.2), 2)
print(salary_list)
</code></pre>
| [
{
"answer_id": 74214662,
"author": "Regis",
"author_id": 5700242,
"author_profile": "https://Stackoverflow.com/users/5700242",
"pm_score": 1,
"selected": false,
"text": "for row in salary_list:\n print('\\t'.join([str(_) for _ in row]))\n"
},
{
"answer_id": 74214739,
"auth... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214606",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18212198/"
] |
74,214,615 | <p>I've updated my version of Python to 3.11, but Terminal is printing different versions, depending on what command I enter.</p>
<p>Entering <code>python3 --version</code> prints <code>Python 3.9.13</code>.</p>
<p>Entering <code>python --version</code> prints <code>Python 3.9.6</code>.</p>
<p>When I go to the actual Python framework, I can see that 3.11 is installed and is the current version, per the shortcut there. There are multiple versions of Python--Python 3.7, 3.8, etc.--there; perhaps this is the issue.</p>
<p>I've looked into uninstalling some or all versions of Python, but I worry that will just make it worse--I'm not the most experienced programmer.</p>
<p>I've also tried adding an alias to the .zshrc file per other posts, but it didn't work. I did save the file correctly, for what it's worth. Any advice is appreciated.</p>
<p>macOS Ventura 13.0</p>
<p>Fix: I created a new user on my computer, which isn't a true fix, but it allowed me to bypass this issue (messy PATH) with relative ease.</p>
| [
{
"answer_id": 74214708,
"author": "Muhammad Arslan Arain",
"author_id": 17028852,
"author_profile": "https://Stackoverflow.com/users/17028852",
"pm_score": 0,
"selected": false,
"text": " brew install python\n"
},
{
"answer_id": 74214818,
"author": "j l",
"author_... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214615",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20342490/"
] |
74,214,619 | <p>I´m trying to create a simple thing: a loop with a delay of x seconds between iterations, triggered by a Tkinter button command.</p>
<p>The obvious answer is to use <code>time.sleep()</code>, however, this actually freezes the <code>mainloop</code> process, avoiding other events to be captured.</p>
<p>I´ve searched and the recommendation is to use the <code>tkinter.after()</code> method, however, I still can't make the loop take time between iterations.</p>
<p>Any help? Simplified code is below.</p>
<pre class="lang-py prettyprint-override"><code>import tkinter as tk
import tkinter.scrolledtext as st
import time
# function to be activated by button
def do_some_action():
for i in range(10):
# just write some variable text to check if it is working
txt_bigtextlog.insert(tk.END,'Row text {} off 10\n'.format(i))
# tk.END to point the scrolling text to latest line
txt_bigtextlog.see(tk.END)
# I´ve tried w/o success (1000 is miliseconds):
# mywindowapp.after(1000)
# btn_action.after(1000)
time.sleep(1)
mywindowapp.update()
return()
# Create the application main window
mywindowapp = tk.Tk()
# create some label, just to visualize something
lbl_justsomelabel = tk.Label(text='Just some label here')
lbl_justsomelabel.grid(row=0,column=0,sticky='NSEW',padx=10,pady=10)
# create a button, just so simulate loop triggering
btn_action = tk.Button(text='Start process',command=do_some_action)
btn_action.grid(row=1,column=0,sticky='NSEW',padx=10,pady=10)
# create a scrolling text just to do some example iterable action
txt_bigtextlog = st.ScrolledText(mywindowapp,width = 30,height = 8)
txt_bigtextlog.grid(row=2,column = 0, columnspan=3,sticky='NSEW', pady = 10, padx = 10)
txt_bigtextlog.insert(tk.INSERT,'')
mywindowapp.mainloop()
</code></pre>
| [
{
"answer_id": 74215342,
"author": "Bryan Oakley",
"author_id": 7432,
"author_profile": "https://Stackoverflow.com/users/7432",
"pm_score": 2,
"selected": false,
"text": "def do_some_action(i=0):\n # just write some variable text to check if it is working\n txt_bigtextlog.insert(tk... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15685729/"
] |
74,214,624 | <p>when I generate a random set, I need to define each number in a different variable. I'm using <code>random.sample()</code> but the number are being repeated.</p>
<pre><code>import random
#Generate 3 random numbers between 1 and 30
random_listOne = random.sample(range(1, 30), 3)
print(random_listOne)
valueOne = random.sample(random_listOne, 1)
valueTwo = random.sample(random_listOne, 1)
valueThree = random.sample(random_listOne, 1)
print(valueOne)
print(valueTwo)
print(valueThree)
</code></pre>
<p>just two numbers from the set are being selected, sometimes only one.</p>
| [
{
"answer_id": 74215342,
"author": "Bryan Oakley",
"author_id": 7432,
"author_profile": "https://Stackoverflow.com/users/7432",
"pm_score": 2,
"selected": false,
"text": "def do_some_action(i=0):\n # just write some variable text to check if it is working\n txt_bigtextlog.insert(tk... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214624",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20343538/"
] |
74,214,663 | <p>I have this <code>js</code> file:</p>
<p><strong>test.js</strong>:</p>
<pre><code>const axios = require('axios');
console.log('test');
</code></pre>
<p>I have installed dependencies by running</p>
<pre><code>npm install
</code></pre>
<p>My folder structure looks like this:</p>
<pre><code>test
node_modules
package.json
package-lock.json
test.js
</code></pre>
<p>If I remove the first line <code>const axios = require('axios');</code>, and run:</p>
<pre><code>nodejs test.js
</code></pre>
<p>it runs fine and prints <code>test</code>.</p>
<p>However if the first line is present, I get this error:</p>
<pre><code>/home/username/test/node_modules/axios/index.js:1
import axios from './lib/axios.js';
^^^^^
SyntaxError: Unexpected identifier
</code></pre>
<p>How do I fix it?</p>
<p>PS</p>
<pre><code>node -v
v18.4.0
nodejs -v
v10.19.0
npm -v
8.12.1
</code></pre>
| [
{
"answer_id": 74214764,
"author": "Quentin",
"author_id": 19068,
"author_profile": "https://Stackoverflow.com/users/19068",
"pm_score": 2,
"selected": false,
"text": "nodejs test.js\n"
},
{
"answer_id": 74214839,
"author": "parsecer",
"author_id": 4759176,
"author_pr... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214663",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4759176/"
] |
74,214,664 | <p>I need to execute union statement which is framed dynamically and stored in string variable. I framed the union statement, but struck with executing the statement. Does anyone know how to execute union statement stored in string variable? I'm using pyspark in databricks notebook.</p>
<pre class="lang-py prettyprint-override"><code>df1 = df.filter((col("vchDataSection") == "AccountMasterInfo") & (col("bActive") == 1)).withColumn("dfs", concat(lit(".union(df"), col("iRuleid"), lit(")")))
df2 = df1.agg(concat_ws("",collect_list(col("dfs")))).withColumnRenamed("concat_ws(, collect_list(dfs))", "AccInfoRules").withColumn("replacestr",lit(""))
df3 = df2.select(overlay("AccInfoRules","replacestr",1,7).alias("overlayed"))
var_a = df3.collect()
var_a = var_a[0].__getitem__('overlayed')
var_b = var_a.replace(')', '', 1)
print(var_b)
o/p: df533.union(df534).union(df535).union(df536)
</code></pre>
| [
{
"answer_id": 74214764,
"author": "Quentin",
"author_id": 19068,
"author_profile": "https://Stackoverflow.com/users/19068",
"pm_score": 2,
"selected": false,
"text": "nodejs test.js\n"
},
{
"answer_id": 74214839,
"author": "parsecer",
"author_id": 4759176,
"author_pr... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214664",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2225726/"
] |
74,214,700 | <p>i wrote this code:</p>
<pre><code>admitted_List = [1, 5, 10, 50, 100, 500, 1000]
tempString = ""
finalList = []
for i in range(len(xkcd)-1):
if int(xkcd[i] + xkcd[i+1]) in admitted_List:
tempString += xkcd[i]
continue
else:
tempString += xkcd[i]
finalList.append(int(tempString))
tempString = ""
return (finalList)
</code></pre>
<p>that basically takes in (xkcd) a string of weights of roman numbers like '10010010010100511' and it should return me the list of weights like [100, 100, 100, 10, 100, 5, 1, 1] so that C C C XC V I I makes sense, of course the first 4 chars of the string make the number 1001 that in roman numbers means nothing so my number will be 100 and then the check should stop and begin a new number.</p>
<p>I tried the above algorithm.
Please excuse me if bad code or bad body question, I'm pretty new to python and stack overflow.</p>
| [
{
"answer_id": 74214764,
"author": "Quentin",
"author_id": 19068,
"author_profile": "https://Stackoverflow.com/users/19068",
"pm_score": 2,
"selected": false,
"text": "nodejs test.js\n"
},
{
"answer_id": 74214839,
"author": "parsecer",
"author_id": 4759176,
"author_pr... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214700",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18943770/"
] |
74,214,710 | <p>I have many lists of dictionaries with keys: origin/destination that I want to represent in a simpler and shorter way.</p>
<p>I was trying with some for loops and creating lists with the letters, but it has not worked for me.</p>
<p>Any idea how I could do this representation of the values?</p>
| [
{
"answer_id": 74214764,
"author": "Quentin",
"author_id": 19068,
"author_profile": "https://Stackoverflow.com/users/19068",
"pm_score": 2,
"selected": false,
"text": "nodejs test.js\n"
},
{
"answer_id": 74214839,
"author": "parsecer",
"author_id": 4759176,
"author_pr... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13955981/"
] |
74,214,719 | <p>I'm having really interesting issue. I have a data which comes from Graphql. I wanna add a object in an array that is in an array.</p>
<p>But i can't do it. I have a error that is the object is not extensible.</p>
<p>Let me give an example of my data:</p>
<pre class="lang-json prettyprint-override"><code>{
"data": {
"board": {
"id": "1",
"title": "Grocieries",
"color": "teal",
"lists": [
{
"id": "1",
"title": "To-Do",
"cards": [
{
"id": "1",
"title": "Write novel"
},
{
"id": "2",
"title": "Buy food"
},
{
"id": "3",
"title": "Paint a picture"
}
]
},
{
"id": "2",
"title": "In progress",
"cards": [
{
"id": "4",
"title": "Buy groceries"
},
{
"id": "5",
"title": "Pay the bills"
},
{
"id": "6",
"title": "Get the car fixed"
},
{
"id": "7",
"title": "Create a course"
}
]
},
{
"id": "3",
"title": "Done",
"cards": [
{
"id": "8",
"title": "Get the car fixed"
},
{
"id": "9",
"title": "Write novel"
},
{
"id": "30",
"title": "Buy fruits"
},
{
"id": "31",
"title": "Buy car"
}
]
}
]
}
}
}
</code></pre>
<p>Let me explain what i want to do:</p>
<p>I want to add an object in cards array which is inside of the list item which has id 1.</p>
<p>Actually it's not hard to do it programmatically. But i have that error:</p>
<p><a href="https://i.stack.imgur.com/AAHpP.png" rel="nofollow noreferrer">Error Image</a></p>
<p>My code:</p>
<pre><code><script>
import CardAdd from '../graphql/mutations/CardAdd';
import BoardQuery from '../graphql/queries/BoardWithListsAndCards';
export default {
methods: {
cardAdd(){
this.$apollo.mutate({
mutation: CardAdd,
variables: {
title: "Mutation added",
order: 1,
listId: 1,
ownerId: 1
},
update(store, { data: { cardAdd } }){
let data = store.readQuery({
query: BoardQuery,
variables: {
id: 1
}
});
data.board.lists.find(list => list.id == 1).cards.push(cardAdd);
}
});
}
}
}
</script>
</code></pre>
<p>Note: cardAdd is the object that i want to add in cards array.</p>
<p>I also tried to add with index.</p>
<p>Thank you already</p>
| [
{
"answer_id": 74214764,
"author": "Quentin",
"author_id": 19068,
"author_profile": "https://Stackoverflow.com/users/19068",
"pm_score": 2,
"selected": false,
"text": "nodejs test.js\n"
},
{
"answer_id": 74214839,
"author": "parsecer",
"author_id": 4759176,
"author_pr... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214719",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11346936/"
] |
74,214,740 | <p>I'm writing Jest tests for a React component, and using the <code>@testing-library/user-event</code> library to simulate user interaction. This works great, except in tests that use Jest's fake timers.</p>
<p>Here's a sample test:</p>
<pre class="lang-js prettyprint-override"><code>it(`fires onClick prop function when the button is clicked`, async () => {
// jest.useFakeTimers()
let propFn = jest.fn()
let app = RTL.render(
<SampleComp onClick={propFn} />
)
await userEvent.click(app.queryByText('Test button')!)
expect(propFn).toHaveBeenCalled()
// jest.useRealTimers()
})
</code></pre>
<p>And here's the component:</p>
<pre class="lang-js prettyprint-override"><code>function SampleComp({ onClick }) {
// a simple bridge for debugging
function _onClick(e) {
console.log(`_onClick invoked`)
return onClick(e)
}
return (
<button onClick={_onClick}>
Test button
</button>
)
}
</code></pre>
<p>Without fake timers, the test runs in a fraction of a second and passes. With the fake timers, the test times out and then fails:</p>
<pre><code> ● fires onClick prop function when the button is clicked
thrown: "Exceeded timeout of 5000 ms for a test.
Use jest.setTimeout(newTimeout) to increase the timeout value, if this is a long-running test."
</code></pre>
<p>It also fails to emit the debug line, so evidently the click event is never fired.</p>
<p>I've done a whole bunch of debugging, and have determined that the root cause is that the user-event library relies on a <code>setTimeout</code> internally to create a brief delay between events.</p>
<p>Yes, "events" <em>plural</em> -- recall that the value-proposition of the user-event library is:</p>
<blockquote>
<p><code>fireEvent</code> dispatches DOM events, whereas <code>user-event</code> simulates full <em>interactions</em>, which may fire multiple events and do additional checks along the way.<br>
-- <a href="https://testing-library.com/docs/user-event/intro/#differences-from-fireevent" rel="nofollow noreferrer">user-event docs</a></p>
</blockquote>
<p>In this case, user-event creates two events for me:</p>
<ol>
<li>a mouse movement<sup>1</sup></li>
<li>the actual click</li>
</ol>
<p><sup><sup>1</sup>Although user-event's internal event object for the first event has only a <code>target</code> and no <code>type</code>, it makes sense to me that the first event would be either mouse-move or mouse-over on the button. Regardless: I've verified that the list of actions user-event creates internally does have 2 items, and the second one is clearly marked as "[MouseLeft]".</sup></p>
<p>The delay is inserted between events by user-event's <a href="https://github.com/testing-library/user-event/blob/main/src/pointer/index.ts#L58" rel="nofollow noreferrer"><code>pointerAction</code> function</a>. In my case, user-event stalls out during the delay between events 1 and 2.</p>
<p>The timeout is created in <a href="https://github.com/testing-library/user-event/blob/main/src/utils/misc/wait.ts#L9" rel="nofollow noreferrer">user-event's <code>wait</code> module</a>:</p>
<pre class="lang-js prettyprint-override"><code>new Promise<void>(resolve => globalThis.setTimeout(() => resolve(), delay))
</code></pre>
<p>I've verified that this is the problem by monkeypatching that line inside my node_modules to simply resolve immediately without a timer, like so:</p>
<pre class="lang-js prettyprint-override"><code>new Promise<void>(resolve => resolve())
</code></pre>
<p>Unfortunately, my application code has some important timers, and it won't do to make the test suite wait for them in real time. And even if I could, I suspect folks who find this question later might not have that freedom.</p>
<p>It does not work to run Jest's fake timers to permit user-event to proceed, like so:</p>
<pre class="lang-js prettyprint-override"><code>it(`fires onClick prop function when the button is clicked`, async () => {
jest.useFakeTimers()
let propFn = jest.fn()
let app = RTL.render(
<SampleComp onClick={propFn} />
)
let userAction = userEvent.click(app.queryByText('Test button')!)
jest.runOnlyPendingTimers() // no good
jest.runAllTimers() // also no good
await userAction
expect(propFn).toHaveBeenCalled()
jest.useRealTimers()
})
</code></pre>
<p>So, how is one supposed to use Jest's fake timers in conjunction with the user-event library?</p>
<hr />
<p>In this case, versions do seem to matter: this test worked great with earlier versions of React, Jest, and user-event. Here are the versions I'm using now (where this breaks), as well as the versions I was using (where this works):</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">Library</th>
<th style="text-align: right;">Current<br>(breaks)</th>
<th style="text-align: right;">Previous<br>(worked)</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">jest</td>
<td style="text-align: right;"><a href="https://github.com/facebook/jest/tree/v27.5.1" rel="nofollow noreferrer">v27.5.1</a></td>
<td style="text-align: right;"><a href="https://github.com/facebook/jest/tree/v26.6.3" rel="nofollow noreferrer">v26.6.3</a></td>
</tr>
<tr>
<td style="text-align: left;">react</td>
<td style="text-align: right;"><a href="https://github.com/facebook/react/tree/v18.1.0" rel="nofollow noreferrer">v18.1.0</a></td>
<td style="text-align: right;"><a href="https://github.com/facebook/react/tree/v16.13.1" rel="nofollow noreferrer">v16.13.1</a></td>
</tr>
<tr>
<td style="text-align: left;">@testing-library/user-event</td>
<td style="text-align: right;"><a href="https://github.com/testing-library/user-event/tree/v14.3.0" rel="nofollow noreferrer">v14.3.0</a></td>
<td style="text-align: right;"><a href="https://github.com/testing-library/user-event/tree/v12.8.3" rel="nofollow noreferrer">v12.8.3</a></td>
</tr>
</tbody>
</table>
</div>
<p>I should note that it's not possible to change the package versions being used. I need a solution that works with the specific versions listed in the "Current" column.</p>
<p>Note: I think this problem is not specific to React, and folks using Vue or Svelte or anything else would have the same problem as long as they're using Jest's fake timers + user-event (which are both framework agnostic). So, I'm not tagging it as React.</p>
| [
{
"answer_id": 74214764,
"author": "Quentin",
"author_id": 19068,
"author_profile": "https://Stackoverflow.com/users/19068",
"pm_score": 2,
"selected": false,
"text": "nodejs test.js\n"
},
{
"answer_id": 74214839,
"author": "parsecer",
"author_id": 4759176,
"author_pr... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214740",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/814463/"
] |
74,214,750 | <p>It is well documented in the manual, that gdb writes the command history after exiting (<a href="https://sourceware.org/gdb/onlinedocs/gdb/Command-History.html" rel="nofollow noreferrer">https://sourceware.org/gdb/onlinedocs/gdb/Command-History.html</a>).
However, I would like to obtain the complete command history without exiting to fill it on demand into a scratch buffer for editing or convenient re-running from within neovim with <code>gdb -x FILE</code> in another gdb instance.</p>
<p>What ways exist to get the info out from a running gdb instance?</p>
| [
{
"answer_id": 74216567,
"author": "Employed Russian",
"author_id": 50617,
"author_profile": "https://Stackoverflow.com/users/50617",
"pm_score": 1,
"selected": false,
"text": "(gdb) show commands"
},
{
"answer_id": 74218396,
"author": "Andrew",
"author_id": 3228495,
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214750",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9306292/"
] |
74,214,752 | <p>I have the following shiny input panel:</p>
<pre><code>inputPanel(selectInput(inputId = "engagement_state", label = "Choose Engagement State:",
choices = states.of.engagement2, selected = states.of.engagement2[1]),
selectInput(inputId = "product", label = "Choose a Product:",
choices = unique.products, selected = unique.products[1]),
selectInput(inputId = "model_inputs", label = "Choose Input Variables:",
choices = model.variables, selected = model.variables, multiple = TRUE))
</code></pre>
<p>Using these inputs, I want to create a model. The dependent variable is input$engagement_state and the independent variables are the variables included input$model_inputs as well as another column that is added into the data shown below</p>
<pre><code>renderDataTable({
aggregated.engagement <- data[get(variable.product) != input$product, .(agg_engagement = mean(get(input$engagement_state), na.rm=T)), by=id][, agg_engagement := ifelse(agg_engagement == "NaN", 0, agg_engagement)]
model.data <- merge(data[get(variable.product) == input$product], aggregated.engagement, by='id')
inputs <- c(input$model_inputs, variable.product, "agg_engagement")
model.formula <- as.formula(paste0(input$engagement_state, "~", paste0(inputs, collapse = "+")))
if (input$engagement_state == variable.satisfaction) {
model <- lm(model.formula, model.data)
ci <- data.frame(cbind(Estimate = coef(model), confint(model, level = 0.95)))
displaytable <- rownames_to_columns(ci, "Coefficient")
pvalues <- rownames_to_column(data.frame(coef(summary(model))[,4]), "Coefficient")
displaytable <- merge(displaytable, pvalues, by='Coefficient') %>%
rename("5% CI" = "X2.5..", "95% CI" = "X97.5..", "P-Value" = "coef.summary.model.....4.")
datatable(displaytable)
}
if (input$engagement_state != variable.satisfaction) {
model <- glm(model.formula, family = 'binomial', model.data)
or <- data.frame(exp(cbind(OR = coef(model), confint(model, level=0.95))))
displaytable <- rownames_to_column(or, "Coefficient")
pvalues <- rownames_to_column(data.frame(coef(summary(model))[,4]), "Coefficient")
displaytable <- merge(displaytable, pvalues, by='Coefficient') %>%
rename("Odds Ratio" = "OR", "5% CI" = "X2.5..", "95% CI" = "X97.5..", "P-Value" = "coef.summary.model.....4.")
datatable(displaytable)
}
})
</code></pre>
<p>aggregated.engagement is based on the product that is selected in the inputs, and I then aggregated that variable with the rest of the inputs. Of the engagement state inputs, all are binary but one is on a scale from 0-10 (satisfaction) so for satisfaction there should be a linear model and for the rest of the states it should be a logit model.</p>
<p>After the model is created, I create a table including coefficients or odds ratios, confidence intervals and p-values and that's what should be output</p>
<p>Here's reproducible data:</p>
<pre><code>dput(data[1:100,])
structure(list(id = 1:100, Age = c(57L, 67L, 55L, 58L, 70L, 58L,
47L, 64L, 53L, 58L, 65L, 39L, 57L, 26L, 66L, 38L, 27L, 46L, 64L,
44L, 66L, 24L, 35L, 32L, 44L, 56L, 71L, 35L, 25L, 57L, 61L, 32L,
19L, 39L, 51L, 32L, 45L, 44L, 67L, 64L, 72L, 50L, 70L, 38L, 48L,
49L, 46L, 65L, 72L, 61L, 19L, 43L, 42L, 39L, 52L, 25L, 51L, 68L,
44L, 53L, 61L, 43L, 47L, 37L, 41L, 30L, 51L, 52L, 29L, 26L, 22L,
25L, 68L, 55L, 50L, 64L, 50L, 53L, 20L, 59L, 37L, 35L, 54L, 41L,
58L, 55L, 69L, 62L, 48L, 43L, 61L, 43L, 64L, 31L, 61L, 51L, 29L,
60L, 59L, 48L), Gender = structure(c(2L, 1L, 2L, 2L, 1L, 1L,
2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L,
2L, 2L, 2L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 2L, 1L, 1L, 2L, 1L,
1L, 2L, 2L, 1L, 2L, 2L, 2L, 1L, 2L, 2L, 1L, 2L, 2L, 1L, 1L, 1L,
1L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 1L, 1L, 2L, 1L, 1L, 1L, 2L, 2L,
1L, 1L, 2L, 1L, 2L, 1L, 1L, 1L, 2L, 2L, 2L, 2L, 2L, 1L, 1L, 1L,
2L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 2L, 1L, 2L), levels = c("Female",
"Male"), class = "factor"), Income = c(85000, 38000, 77000, 47000,
76000, 128000, 163000, 91000, 54000, 78000, 36000, 119000, 164000,
16000, 109000, 109000, 109000, 158000, 118000, 36000, 36000,
43000, 51000, 166000, 98000, 39000, 117000, 45000, 50000, 82000,
46000, 76000, 122000, 76000, 87000, 42000, 46000, 35000, 72000,
44000, 29000, 58000, 38000, 49000, 107000, 36000, 80000, 89000,
28000, 121000, 35000, 112000, 123000, 31000, 47000, 152000, 87000,
42000, 76000, 35000, 33000, 47000, 145000, 91000, 120000, 32000,
41000, 78000, 52000, 32000, 58000, 129000, 174000, 73000, 36000,
65000, 51000, 130000, 49000, 171000, 93000, 61000, 46000, 166000,
82000, 23000, 169000, 46000, 163000, 78000, 127000, 43000, 164000,
135000, 126000, 162000, 90000, 57000, 38000, 79000), Region = structure(c(2L,
1L, 2L, 3L, 3L, 4L, 4L, 1L, 4L, 1L, 1L, 1L, 2L, 1L, 4L, 3L, 3L,
1L, 1L, 2L, 1L, 3L, 4L, 2L, 4L, 2L, 4L, 2L, 2L, 2L, 2L, 1L, 2L,
3L, 3L, 2L, 1L, 1L, 4L, 2L, 1L, 4L, 3L, 4L, 4L, 4L, 1L, 3L, 3L,
4L, 1L, 1L, 1L, 2L, 1L, 2L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 4L, 2L,
1L, 4L, 3L, 3L, 4L, 1L, 3L, 2L, 1L, 4L, 3L, 2L, 2L, 1L, 1L, 1L,
1L, 3L, 2L, 1L, 2L, 4L, 4L, 4L, 1L, 1L, 2L, 1L, 1L, 4L, 1L, 2L,
2L, 4L, 2L), levels = c("Midwest", "Northeast", "South", "West"
), class = "factor"), Persona = structure(c(3L, 4L, 5L, 1L, 5L,
6L, 2L, 2L, 6L, 3L, 1L, 6L, 4L, 5L, 6L, 1L, 6L, 1L, 4L, 2L, 1L,
1L, 2L, 4L, 4L, 2L, 6L, 6L, 6L, 2L, 4L, 3L, 5L, 4L, 6L, 6L, 6L,
1L, 1L, 1L, 2L, 3L, 2L, 5L, 6L, 2L, 1L, 2L, 1L, 4L, 6L, 5L, 6L,
1L, 1L, 2L, 1L, 6L, 1L, 1L, 4L, 3L, 1L, 1L, 2L, 1L, 1L, 6L, 4L,
6L, 1L, 5L, 2L, 1L, 3L, 3L, 1L, 5L, 6L, 2L, 4L, 5L, 1L, 6L, 6L,
4L, 6L, 4L, 6L, 3L, 4L, 1L, 2L, 3L, 1L, 3L, 5L, 6L, 2L, 1L), levels = c("Ambivalent Adventurer",
"Consistent Compromiser", "Materialistic Meditator", "Outdoorsy Ombudsman",
"Precociously Preoccupied", "Technological Triumphalist"), class = "factor"),
Product = structure(c(18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L,
18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L, 18L), levels = c("All Buttons",
"App Map", "Buzzdial", "Cellularity", "Communic Nation",
"Maybe Mobile", "Mobile Mayhem", "MobilitEE", "Mobzilla",
"Next Text", "No Buttons", "Off the Hook", "Phonatics", "Phone Zone",
"Pocket Dialz", "Ring Ring", "Screenz", "Smartophonic", "Speed Dials",
"Triumphone"), class = "factor"), Awareness = c(0L, 0L, 0L,
0L, 1L, 1L, 1L, 0L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 1L, 1L,
0L, 1L, 0L, 0L, 0L, 1L, 1L, 0L, 1L, 0L, 0L, 1L, 1L, 0L, 1L,
0L, 0L, 0L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 0L,
0L, 0L, 0L, 1L, 1L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 0L,
0L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 0L, 1L, 1L, 1L, 1L, 1L, 0L,
0L, 1L, 0L, 1L, 1L, 1L, 1L, 0L, 1L, 1L, 1L, 0L, 1L, 1L, 0L,
0L, 0L, 1L, 0L, 0L, 1L, 1L), BP_User_Friendly_0_10 = c(NA,
NA, NA, NA, 5L, 8L, 5L, NA, 9L, 8L, NA, 5L, NA, NA, 5L, 2L,
2L, 4L, NA, 6L, NA, NA, NA, 4L, 7L, NA, 7L, NA, NA, 7L, 9L,
NA, 7L, NA, NA, NA, NA, 7L, 6L, 4L, NA, 7L, 1L, 7L, 8L, NA,
6L, NA, NA, NA, NA, 4L, 7L, 5L, 9L, 8L, 5L, NA, 4L, NA, 3L,
5L, NA, NA, NA, 5L, 7L, 5L, 7L, NA, 8L, NA, 5L, 7L, 3L, 7L,
7L, NA, NA, 5L, NA, 3L, 5L, 4L, 3L, NA, 1L, 5L, 9L, NA, 5L,
6L, NA, NA, NA, 7L, NA, NA, 5L, 9L), BP_Fast_0_10 = c(NA,
NA, NA, NA, 6L, 10L, 7L, NA, 8L, 4L, NA, 3L, NA, NA, 4L,
8L, 6L, 6L, NA, 9L, NA, NA, NA, 4L, 7L, NA, 6L, NA, NA, 10L,
10L, NA, 8L, NA, NA, NA, NA, 7L, 3L, 9L, NA, 4L, 3L, 6L,
8L, NA, 7L, NA, NA, NA, NA, 4L, 8L, 8L, 10L, 8L, 6L, NA,
4L, NA, 2L, 6L, NA, NA, NA, 5L, 6L, 5L, 4L, NA, 5L, NA, 4L,
7L, 7L, 8L, 7L, NA, NA, 7L, NA, 7L, 4L, 4L, 5L, NA, 4L, 7L,
5L, NA, 7L, 2L, NA, NA, NA, 7L, NA, NA, 6L, 7L), BP_Battery_Life_0_10 = c(NA,
NA, NA, NA, 7L, 6L, 7L, NA, 5L, 9L, NA, 8L, NA, NA, 6L, 8L,
9L, 9L, NA, 8L, NA, NA, NA, 5L, 7L, NA, 7L, NA, NA, 5L, 5L,
NA, 8L, NA, NA, NA, NA, 7L, 6L, 9L, NA, 1L, 5L, 5L, 7L, NA,
6L, NA, NA, NA, NA, 5L, 4L, 6L, 8L, 6L, 7L, NA, 5L, NA, 8L,
8L, NA, NA, NA, 8L, 7L, 7L, 7L, NA, 8L, NA, 5L, 7L, 8L, 4L,
4L, NA, NA, 10L, NA, 6L, 7L, 5L, 5L, NA, 8L, 9L, 5L, NA,
6L, 4L, NA, NA, NA, 8L, NA, NA, 4L, 7L), BP_Camera_0_10 = c(NA,
NA, NA, NA, 5L, 6L, 8L, NA, 10L, 7L, NA, 3L, NA, NA, 6L,
7L, 9L, 5L, NA, 8L, NA, NA, NA, 5L, 7L, NA, 8L, NA, NA, 8L,
3L, NA, 6L, NA, NA, NA, NA, 8L, 7L, 6L, NA, 8L, 9L, 5L, 5L,
NA, 6L, NA, NA, NA, NA, 7L, 4L, 4L, 9L, 5L, 6L, NA, 7L, NA,
7L, 7L, NA, NA, NA, 6L, 7L, 5L, 9L, NA, 8L, NA, 7L, 6L, 9L,
9L, 8L, NA, NA, 7L, NA, 4L, 8L, 6L, 4L, NA, 8L, 7L, 7L, NA,
5L, 7L, NA, NA, NA, 6L, NA, NA, 6L, 5L), BP_Sleek_0_10 = c(NA,
NA, NA, NA, 8L, 6L, 4L, NA, 6L, 9L, NA, 4L, NA, NA, 3L, 6L,
10L, 8L, NA, 5L, NA, NA, NA, 8L, 6L, NA, 8L, NA, NA, 6L,
8L, NA, 4L, NA, NA, NA, NA, 7L, 6L, 6L, NA, 6L, 5L, 7L, 8L,
NA, 2L, NA, NA, NA, NA, 7L, 8L, 7L, 9L, 3L, 7L, NA, 6L, NA,
6L, 6L, NA, NA, NA, 8L, 8L, 5L, 2L, NA, 10L, NA, 7L, 3L,
7L, 5L, 6L, NA, NA, 8L, NA, 5L, 9L, 6L, 9L, NA, 4L, 8L, 6L,
NA, 4L, 8L, NA, NA, NA, 8L, NA, NA, 7L, 10L), BP_Stylish_0_10 = c(NA,
NA, NA, NA, 8L, 5L, 8L, NA, 3L, 6L, NA, 5L, NA, NA, 4L, 3L,
2L, 7L, NA, 8L, NA, NA, NA, 6L, 6L, NA, 7L, NA, NA, 7L, 7L,
NA, 3L, NA, NA, NA, NA, 6L, 10L, 9L, NA, 7L, 8L, 9L, 3L,
NA, 9L, NA, NA, NA, NA, 7L, 6L, 9L, 5L, 6L, 8L, NA, 4L, NA,
8L, 4L, NA, NA, NA, 7L, 5L, 5L, 6L, NA, 4L, NA, 5L, 9L, 7L,
7L, 10L, NA, NA, 9L, NA, 8L, 9L, 7L, 6L, NA, 4L, 4L, 4L,
NA, 9L, 6L, NA, NA, NA, 5L, NA, NA, 6L, 6L), BP_Status_Symbol_0_10 = c(NA,
NA, NA, NA, 8L, 10L, 10L, NA, 7L, 9L, NA, 6L, NA, NA, 3L,
4L, 8L, 5L, NA, 10L, NA, NA, NA, 6L, 9L, NA, 9L, NA, NA,
6L, 7L, NA, 6L, NA, NA, NA, NA, 8L, 6L, 10L, NA, 5L, 7L,
6L, 6L, NA, 4L, NA, NA, NA, NA, 6L, 9L, 9L, 8L, 7L, 5L, NA,
9L, NA, 7L, 6L, NA, NA, NA, 4L, 6L, 9L, 9L, NA, 7L, NA, 8L,
4L, 5L, 6L, 3L, NA, NA, 5L, NA, 7L, 5L, 3L, 4L, NA, 6L, 8L,
7L, NA, 8L, 8L, NA, NA, NA, 3L, NA, NA, 8L, 4L), BP_Good_Screen_Size_0_10 = c(NA,
NA, NA, NA, 4L, 7L, 8L, NA, 3L, 7L, NA, 9L, NA, NA, 5L, 7L,
8L, 5L, NA, 7L, NA, NA, NA, 9L, 6L, NA, 4L, NA, NA, 8L, 6L,
NA, 6L, NA, NA, NA, NA, 8L, 4L, 6L, NA, 9L, 7L, 10L, 9L,
NA, 3L, NA, NA, NA, NA, 8L, 8L, 9L, 6L, 6L, 8L, NA, 10L,
NA, 9L, 7L, NA, NA, NA, 8L, 2L, 2L, 10L, NA, 8L, NA, 4L,
7L, 8L, 9L, 10L, NA, NA, 9L, NA, 7L, 5L, 7L, 7L, NA, 9L,
7L, 4L, NA, 5L, 6L, NA, NA, NA, 6L, NA, NA, 5L, 8L), BP_Boring_0_10 = c(NA,
NA, NA, NA, 3L, 7L, 3L, NA, 6L, 3L, NA, 5L, NA, NA, 4L, 2L,
7L, 3L, NA, 4L, NA, NA, NA, 4L, 3L, NA, 6L, NA, NA, 2L, 3L,
NA, 6L, NA, NA, NA, NA, 3L, 7L, 6L, NA, 5L, 2L, 4L, 0L, NA,
5L, NA, NA, NA, NA, 5L, 6L, 5L, 2L, 2L, 3L, NA, 2L, NA, 2L,
5L, NA, NA, NA, 6L, 1L, 5L, 5L, NA, 6L, NA, 4L, 7L, 2L, 2L,
4L, NA, NA, 10L, NA, 9L, 5L, 8L, 2L, NA, 4L, 3L, 4L, NA,
8L, 5L, NA, NA, NA, 2L, NA, NA, 6L, 5L), BP_Bulky_0_10 = c(NA,
NA, NA, NA, 4L, 4L, 1L, NA, 6L, 5L, NA, 7L, NA, NA, 6L, 2L,
4L, 4L, NA, 7L, NA, NA, NA, 4L, 5L, NA, 2L, NA, NA, 2L, 3L,
NA, 4L, NA, NA, NA, NA, 4L, 7L, 7L, NA, 4L, 4L, 5L, 5L, NA,
6L, NA, NA, NA, NA, 5L, 0L, 10L, 0L, 4L, 4L, NA, 6L, NA,
5L, 4L, NA, NA, NA, 4L, 6L, 8L, 3L, NA, 6L, NA, 3L, 4L, 5L,
6L, 3L, NA, NA, 5L, NA, 3L, 2L, 7L, 2L, NA, 4L, 6L, 5L, NA,
3L, 3L, NA, NA, NA, 6L, NA, NA, 5L, 6L), BP_Fragile_0_10 = c(NA,
NA, NA, NA, 5L, 3L, 3L, NA, 5L, 4L, NA, 6L, NA, NA, 4L, 5L,
3L, 8L, NA, 4L, NA, NA, NA, 4L, 6L, NA, 4L, NA, NA, 4L, 0L,
NA, 7L, NA, NA, NA, NA, 5L, 7L, 7L, NA, 5L, 4L, 2L, 5L, NA,
9L, NA, NA, NA, NA, 4L, 5L, 5L, 5L, 0L, 2L, NA, 6L, NA, 0L,
4L, NA, NA, NA, 1L, 4L, 3L, 7L, NA, 1L, NA, 1L, 4L, 5L, 0L,
5L, NA, NA, 6L, NA, 4L, 4L, 6L, 7L, NA, 8L, 4L, 0L, NA, 4L,
4L, NA, NA, NA, 5L, NA, NA, 3L, 6L), BP_Expensive_0_10 = c(NA,
NA, NA, NA, 5L, 2L, 6L, NA, 7L, 3L, NA, 3L, NA, NA, 4L, 1L,
3L, 3L, NA, 6L, NA, NA, NA, 5L, 6L, NA, 2L, NA, NA, 5L, 3L,
NA, 9L, NA, NA, NA, NA, 5L, 7L, 2L, NA, 6L, 2L, 8L, 6L, NA,
3L, NA, NA, NA, NA, 4L, 4L, 6L, 6L, 6L, 4L, NA, 4L, NA, 1L,
5L, NA, NA, NA, 6L, 8L, 5L, 4L, NA, 1L, NA, 6L, 6L, 1L, 4L,
4L, NA, NA, 3L, NA, 5L, 10L, 8L, 6L, NA, 1L, 2L, 5L, NA,
3L, 7L, NA, NA, NA, 2L, NA, NA, 7L, 6L), Consideration = c(NA,
NA, NA, NA, 1L, 1L, 1L, NA, 1L, 1L, NA, 0L, NA, NA, 0L, 0L,
0L, 1L, NA, 0L, NA, NA, NA, 1L, 1L, NA, 1L, NA, NA, 1L, 1L,
NA, 1L, NA, NA, NA, NA, 1L, 1L, 1L, NA, 1L, 1L, 1L, 0L, NA,
1L, NA, NA, NA, NA, 1L, 1L, 1L, 0L, 1L, 0L, NA, 0L, NA, 1L,
0L, NA, NA, NA, 1L, 1L, 1L, 1L, NA, 1L, NA, 1L, 1L, 1L, 1L,
1L, NA, NA, 1L, NA, 1L, 1L, 1L, 1L, NA, 1L, 1L, 1L, NA, 1L,
1L, NA, NA, NA, 0L, NA, NA, 1L, 1L), Consumption = c(NA,
NA, NA, NA, 1L, 1L, 1L, NA, 1L, 1L, NA, NA, NA, NA, NA, NA,
NA, 1L, NA, NA, NA, NA, NA, 1L, 1L, NA, 1L, NA, NA, 0L, 1L,
NA, 1L, NA, NA, NA, NA, 1L, 0L, 1L, NA, 1L, 0L, 1L, NA, NA,
1L, NA, NA, NA, NA, 0L, 1L, 1L, NA, 1L, NA, NA, NA, NA, 0L,
NA, NA, NA, NA, 1L, 1L, 1L, 1L, NA, 1L, NA, 0L, 1L, 1L, 1L,
1L, NA, NA, 0L, NA, 1L, 1L, 1L, 0L, NA, 1L, 1L, 1L, NA, 1L,
1L, NA, NA, NA, NA, NA, NA, 1L, 1L), Satisfaction = c(NA,
NA, NA, NA, 4L, 6L, 4L, NA, 4L, 4L, NA, NA, NA, NA, NA, NA,
NA, 5L, NA, NA, NA, NA, NA, 3L, 4L, NA, 5L, NA, NA, NA, 5L,
NA, 6L, NA, NA, NA, NA, 4L, NA, 4L, NA, 4L, NA, 5L, NA, NA,
4L, NA, NA, NA, NA, NA, 6L, 6L, NA, 5L, NA, NA, NA, NA, NA,
NA, NA, NA, NA, 6L, 4L, 5L, 5L, NA, 4L, NA, NA, 5L, 3L, 5L,
4L, NA, NA, NA, NA, 4L, 4L, 5L, NA, NA, 4L, 4L, 5L, NA, 6L,
3L, NA, NA, NA, NA, NA, NA, 3L, 4L), Advocacy = c(NA, NA,
NA, NA, 0L, 1L, 0L, NA, 1L, 1L, NA, NA, NA, NA, NA, NA, NA,
1L, NA, NA, NA, NA, NA, 1L, 0L, NA, 1L, NA, NA, NA, 1L, NA,
1L, NA, NA, NA, NA, 1L, NA, 1L, NA, 0L, NA, 1L, NA, NA, 0L,
NA, NA, NA, NA, NA, 1L, 1L, NA, 0L, NA, NA, NA, NA, NA, NA,
NA, NA, NA, 1L, 1L, 1L, 1L, NA, 1L, NA, NA, 1L, 1L, 0L, 0L,
NA, NA, NA, NA, 1L, 1L, 1L, NA, NA, 1L, 1L, 1L, NA, 1L, 1L,
NA, NA, NA, NA, NA, NA, 1L, 1L), age_group = c("50-64", "65+",
"50-64", "50-64", "65+", "50-64", "34-49", "50-64", "50-64",
"50-64", "65+", "34-49", "50-64", "18-34", "65+", "34-49",
"18-34", "34-49", "50-64", "34-49", "65+", "18-34", "34-49",
"18-34", "34-49", "50-64", "65+", "34-49", "18-34", "50-64",
"50-64", "18-34", "18-34", "34-49", "50-64", "18-34", "34-49",
"34-49", "65+", "50-64", "65+", "50-64", "65+", "34-49",
"34-49", "34-49", "34-49", "65+", "65+", "50-64", "18-34",
"34-49", "34-49", "34-49", "50-64", "18-34", "50-64", "65+",
"34-49", "50-64", "50-64", "34-49", "34-49", "34-49", "34-49",
"18-34", "50-64", "50-64", "18-34", "18-34", "18-34", "18-34",
"65+", "50-64", "50-64", "50-64", "50-64", "50-64", "18-34",
"50-64", "34-49", "34-49", "50-64", "34-49", "50-64", "50-64",
"65+", "50-64", "34-49", "34-49", "50-64", "34-49", "50-64",
"18-34", "50-64", "50-64", "18-34", "50-64", "50-64", "34-49"
), income_group = c("75,000 - 99,999", "Under 50,000", "75,000 - 99,999",
"Under 50,000", "75,000 - 99,999", "100,000 - 149,999", "150,000 or Higher",
"75,000 - 99,999", "50,000 - 74,999", "75,000 - 99,999",
"Under 50,000", "100,000 - 149,999", "150,000 or Higher",
"Under 50,000", "100,000 - 149,999", "100,000 - 149,999",
"100,000 - 149,999", "150,000 or Higher", "100,000 - 149,999",
"Under 50,000", "Under 50,000", "Under 50,000", "50,000 - 74,999",
"150,000 or Higher", "75,000 - 99,999", "Under 50,000", "100,000 - 149,999",
"Under 50,000", "50,000 - 74,999", "75,000 - 99,999", "Under 50,000",
"75,000 - 99,999", "100,000 - 149,999", "75,000 - 99,999",
"75,000 - 99,999", "Under 50,000", "Under 50,000", "Under 50,000",
"50,000 - 74,999", "Under 50,000", "Under 50,000", "50,000 - 74,999",
"Under 50,000", "Under 50,000", "100,000 - 149,999", "Under 50,000",
"75,000 - 99,999", "75,000 - 99,999", "Under 50,000", "100,000 - 149,999",
"Under 50,000", "100,000 - 149,999", "100,000 - 149,999",
"Under 50,000", "Under 50,000", "150,000 or Higher", "75,000 - 99,999",
"Under 50,000", "75,000 - 99,999", "Under 50,000", "Under 50,000",
"Under 50,000", "100,000 - 149,999", "75,000 - 99,999", "100,000 - 149,999",
"Under 50,000", "Under 50,000", "75,000 - 99,999", "50,000 - 74,999",
"Under 50,000", "50,000 - 74,999", "100,000 - 149,999", "150,000 or Higher",
"50,000 - 74,999", "Under 50,000", "50,000 - 74,999", "50,000 - 74,999",
"100,000 - 149,999", "Under 50,000", "150,000 or Higher",
"75,000 - 99,999", "50,000 - 74,999", "Under 50,000", "150,000 or Higher",
"75,000 - 99,999", "Under 50,000", "150,000 or Higher", "Under 50,000",
"150,000 or Higher", "75,000 - 99,999", "100,000 - 149,999",
"Under 50,000", "150,000 or Higher", "100,000 - 149,999",
"100,000 - 149,999", "150,000 or Higher", "75,000 - 99,999",
"50,000 - 74,999", "Under 50,000", "75,000 - 99,999")), row.names = c(NA,
-100L), class = c("data.table", "data.frame"), .internal.selfref = <pointer: 0x14000a4e0>)
>
</code></pre>
| [
{
"answer_id": 74216567,
"author": "Employed Russian",
"author_id": 50617,
"author_profile": "https://Stackoverflow.com/users/50617",
"pm_score": 1,
"selected": false,
"text": "(gdb) show commands"
},
{
"answer_id": 74218396,
"author": "Andrew",
"author_id": 3228495,
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214752",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17548328/"
] |
74,214,759 | <p>How can I make a while loop print something blank amount of times based on the user input. For example:</p>
<pre><code>age = int(input('Enter your age: '))
while age…
</code></pre>
<p>And I just don’t know what to do from there. To be clear, how could I output something 8 times if the user inputs 8 (6 times if the user inputs six…)?</p>
<p>Edit:
I want to run a while loop based on the USER INPUT, if they enter 3, it will print something 3 times. I don’t know what they will enter.</p>
| [
{
"answer_id": 74216567,
"author": "Employed Russian",
"author_id": 50617,
"author_profile": "https://Stackoverflow.com/users/50617",
"pm_score": 1,
"selected": false,
"text": "(gdb) show commands"
},
{
"answer_id": 74218396,
"author": "Andrew",
"author_id": 3228495,
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214759",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,214,766 | <p>I'm trying to create a capture group that could precede or follow another capture group.</p>
<p>Given:</p>
<pre><code>TAKE 4 MG BY MOUTH
INHALE 14 PUFFS
4 PUFFS INHALE
</code></pre>
<p>Wanted:</p>
<pre><code>qty unit rte
--- ---- ---
4 MG BY MOUTH
14 PUFFS INHALE
4 PUFFS INHALE
</code></pre>
<p>My attempt, <code>(?:(?'qty'\d+)\s(?'unit'(PUFFS|MG))).*(?'rte'(BY MOUTH|INHALE))</code>, works only when the <code>rte</code> follows the <code>qty</code>/<code>unit</code> group. What is this concept called? A "look-around"?</p>
<p>Example: <a href="https://regex101.com/r/IRTYgU/1" rel="nofollow noreferrer">https://regex101.com/r/IRTYgU/1</a></p>
| [
{
"answer_id": 74216567,
"author": "Employed Russian",
"author_id": 50617,
"author_profile": "https://Stackoverflow.com/users/50617",
"pm_score": 1,
"selected": false,
"text": "(gdb) show commands"
},
{
"answer_id": 74218396,
"author": "Andrew",
"author_id": 3228495,
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/134367/"
] |
74,214,767 | <p>Is this possible in javascript?</p>
<pre><code>let a, b; // Both objects, eg vectors
let bl = false; // This is a bool that could be true or false
// Is this possible, or how could it be done
(bl ? a : b) = {x: 5, y: -2, z: 3};
</code></pre>
<p>Ie, I want to set either <code>a</code> or <code>b</code> to this vector conditionally depending on <code>bl</code>.</p>
<p>Or is the only way:</p>
<pre><code>let tmp = {x: 5, y: -2, z: 3};
if(bl) a = tmp;
else b = tmp;
</code></pre>
<p>I just feel there should be a more elegant way of doing this.</p>
| [
{
"answer_id": 74216567,
"author": "Employed Russian",
"author_id": 50617,
"author_profile": "https://Stackoverflow.com/users/50617",
"pm_score": 1,
"selected": false,
"text": "(gdb) show commands"
},
{
"answer_id": 74218396,
"author": "Andrew",
"author_id": 3228495,
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214767",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/886773/"
] |
74,214,776 | <p>My given instructions:
Write a program that continually generates 2 numbers between -5 and 5. After each number is generated, display each pair from smallest to biggest along with the sum of the pair.
The program stops when the program generates a pair that is the negative of the other (for example, -5 and 5 or -2 and 2)
At the end of the program display the sum of all the numbers that were generated.</p>
<p>Here's my code:
My problem is I don't know how to display each pair from smallest to biggest along with the sum of the pair. I also am not sure about displaying the sum of all the numbers that were generated.</p>
<p>`</p>
<pre><code>import random
i = 0
while i < 1:
number1= random.randint(-5,5)
number2= random.randint(-5,5)
print("(", number1, ",", number2, ")")
if number1 == -number2:
break
if number2 == -number1:
break
</code></pre>
<p>`</p>
| [
{
"answer_id": 74214814,
"author": "Dariush Mazlumi",
"author_id": 8956917,
"author_profile": "https://Stackoverflow.com/users/8956917",
"pm_score": 0,
"selected": false,
"text": "# random is a python built-in library which has multiple functions regarding random events\nimport random\n\... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214776",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20277384/"
] |
74,214,807 | <p>I have to check each row of the table for special symbols and add a column with the number of symbols without using cycles,but i have to use regular expressions</p>
<p>I write a regular expression:</p>
<pre><code>rexp = '("|#|%|\[|\])'
len(re.findall(rexp, 'asdfasf[sadfsaf%sadfad]]'))
</code></pre>
<p>And I try to solve it like this:</p>
<pre><code>def special_symbols(x):
if len(re.findall(rexp, x['game_description'])) >0:
return len(re.findall(rexp, x['game_description']))
else:
return 0
games_df['n_special_symbols'] = games_df.apply(special_symbols, axis =1)
</code></pre>
<p>But I have an error:</p>
<blockquote>
<p>expected string or bytes-like object</p>
</blockquote>
<p>How can I fix it?</p>
| [
{
"answer_id": 74214814,
"author": "Dariush Mazlumi",
"author_id": 8956917,
"author_profile": "https://Stackoverflow.com/users/8956917",
"pm_score": 0,
"selected": false,
"text": "# random is a python built-in library which has multiple functions regarding random events\nimport random\n\... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15152033/"
] |
74,214,811 | <p>When I use ":n" or "m:" as arguments to np.r_, I get unexpected results that I don't understand.</p>
<p>Here's my code</p>
<pre><code>import numpy as np
B = np.arange(180).reshape(6,30)
C = B[:, np.r_[10:15, 20:26]]
D = C[:, np.r_[0:3,8:11]]
</code></pre>
<p>Now all of that worked as expected. C prints as:</p>
<pre><code>array([[ 10, 11, 12, 13, 14, 20, 21, 22, 23, 24, 25],
[ 40, 41, 42, 43, 44, 50, 51, 52, 53, 54, 55],
[ 70, 71, 72, 73, 74, 80, 81, 82, 83, 84, 85],
[100, 101, 102, 103, 104, 110, 111, 112, 113, 114, 115],
[130, 131, 132, 133, 134, 140, 141, 142, 143, 144, 145],
[160, 161, 162, 163, 164, 170, 171, 172, 173, 174, 175]])
</code></pre>
<p>and D is:</p>
<pre><code>array([[ 10, 11, 12, 23, 24, 25],
[ 40, 41, 42, 53, 54, 55],
[ 70, 71, 72, 83, 84, 85],
[100, 101, 102, 113, 114, 115],
[130, 131, 132, 143, 144, 145],
[160, 161, 162, 173, 174, 175]])
</code></pre>
<p>However, when I remove the "0" and the "11," I don't understand what happens, and I haven't been able to find any explanation in any Numpy indexing or r_ documentation. Here's the new line of code:</p>
<pre><code>E = C[:, np.r_[:3, 8:]]
</code></pre>
<p>It's just the same expression that defined the D array with "unnecessary" indices removed. However, the results are mystifying:</p>
<pre><code>array([[ 10, 11, 12, 10, 11, 12, 13, 14, 20, 21, 22],
[ 40, 41, 42, 40, 41, 42, 43, 44, 50, 51, 52],
[ 70, 71, 72, 70, 71, 72, 73, 74, 80, 81, 82],
[100, 101, 102, 100, 101, 102, 103, 104, 110, 111, 112],
[130, 131, 132, 130, 131, 132, 133, 134, 140, 141, 142],
[160, 161, 162, 160, 161, 162, 163, 164, 170, 171, 172]])
</code></pre>
<p>I expected E to be identical to D, with just six columns. What's going on? Is this behavior documented somewhere, or is this a bug?</p>
| [
{
"answer_id": 74240985,
"author": "user2983936",
"author_id": 2983936,
"author_profile": "https://Stackoverflow.com/users/2983936",
"pm_score": 0,
"selected": false,
"text": "<ndarray>.r_[n:last]"
},
{
"answer_id": 74246883,
"author": "hpaulj",
"author_id": 901925,
"... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214811",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2983936/"
] |
74,214,838 | <p>I need to subset rows of df based on two columns (c1 and c2 columns) which have strings.
I need to be able to return rows where one value in c1 is associated with only 2 different values in c2. col4-6 are irrelevant for subsetting and just need to be returned.</p>
<pre><code>Code to recreate df
df = pd.DataFrame({"": [0,1,2,3,4,5,6,7,8],
"c1": ["ABC", "ABC", "dfg", "dfg", "dfg","dfg","ghj","ghj","ghj"],
"c2": ["delta", "delta", "alpha", "bravo", "alpha","bravo","bravo","delta","alpha"],
"c3": [1, 2, 2, 3, 5,6,3,3,3],
"col4": [786, 787, 777, 775, 767,715,772,712,712],
"col5": [10, 11, 13, 12, 13,12,14,12,12],
"col6": [1,2,4, 3, 4,3, 5, 8,8]})
</code></pre>
<pre><code> df
c1 c2 c3 col4 col5 col6
0 ABC delta 1 786 10 1
1 ABC delta 2 787 11 2
2 dfg alpha 2 777 13 4
3 dfg bravo 3 775 12 3
4 dfg alpha 5 767 13 4
5 dfg bravo 6 715 12 3
6 ghj bravo 3 772 14 5
7 ghj delta 3 712 12 8
8 ghj alpha 3 712 12 8
</code></pre>
<p>Answer df should be:</p>
<pre><code> finaldf
c1 c2 c3 col4 col5 col6
2 dfg alpha 2 777 13 4
3 dfg bravo 3 775 12 3
4 dfg alpha 5 767 13 4
5 dfg bravo 6 715 12 3
</code></pre>
<p>What if the rows where one value in c1 is associated with 2 and 3 different values in c2 is of interest like in df below?</p>
<pre><code> finaldf
c1 c2 c3 col4 col5 col6
2 dfg alpha 2 777 13 4
3 dfg bravo 3 775 12 3
4 dfg alpha 5 767 13 4
5 dfg bravo 6 715 12 3
6 ghj bravo 3 772 14 5
7 ghj delta 3 712 12 8
8 ghj alpha 3 712 12 8
</code></pre>
<p>I think some kind of groupby and transform operation could help achieve this.</p>
| [
{
"answer_id": 74240985,
"author": "user2983936",
"author_id": 2983936,
"author_profile": "https://Stackoverflow.com/users/2983936",
"pm_score": 0,
"selected": false,
"text": "<ndarray>.r_[n:last]"
},
{
"answer_id": 74246883,
"author": "hpaulj",
"author_id": 901925,
"... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214838",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16319191/"
] |
74,214,843 | <p>I have a .txt file with millions of Data points, and I want to organize them into Classes and Vectors. So the data is usable. However this will take a very long time and I don't want to do it every time I start my program. Is there a way to store the created classes and the data inside them so I only have to go through this process once?</p>
<p>This is my first attempt at a practical program, so I apologize if this is a stupid question. If you could just point me in the right direction I would really appreciate it.</p>
| [
{
"answer_id": 74215011,
"author": "Clifford",
"author_id": 168986,
"author_profile": "https://Stackoverflow.com/users/168986",
"pm_score": 2,
"selected": true,
"text": "new"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214843",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20343653/"
] |
74,214,846 | <p>I have a file (x.txt) with a single column containing a hundred values.</p>
<pre><code>228.71
245.58
253.71
482.72
616.73
756.74
834.72
858.62
934.61
944.60
....
</code></pre>
<p>I want to input each of these values to an existing script I have such that my command on the terminal is:</p>
<pre><code>script_name 228.71 245.58 253.71........... and so on.
</code></pre>
<p>I am trying to create a bash script such that each row is read automatically from the file and taken into the script. I have been trying this for a while now but could not get a solution.</p>
<p>Is there a way to do this?</p>
| [
{
"answer_id": 74215011,
"author": "Clifford",
"author_id": 168986,
"author_profile": "https://Stackoverflow.com/users/168986",
"pm_score": 2,
"selected": true,
"text": "new"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214846",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20341516/"
] |
74,214,871 | <p>How to export a just-imported variable which I modify along the javascript file? My attempt is below:</p>
<pre><code>import { foo } from "bar"
foo = 2
export foo;
</code></pre>
<p>I try the code above, but I receive the log as follows:</p>
<pre><code>SyntaxError: Unexpected token 'export'
</code></pre>
| [
{
"answer_id": 74215011,
"author": "Clifford",
"author_id": 168986,
"author_profile": "https://Stackoverflow.com/users/168986",
"pm_score": 2,
"selected": true,
"text": "new"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214871",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19299349/"
] |
74,214,880 | <p>I am currently working with a data set that resembles the following:</p>
<pre><code> date value ID
10/20/21 123 1
10/21/21 121 1
10/22/21 122 1
10/23/21 125 1
10/24/21 127 1
10/25/21 126 1
10/26/21 125 1
10/27/21 128 1
10/28/21 129 1
10/20/21 155 2
10/21/21 156 2
10/22/21 152 2
10/23/21 154 2
10/24/21 157 2
10/25/21 158 2
10/26/21 159 2
10/27/21 160 2
10/28/21 162 2
</code></pre>
<p>The value column should always be increasing in value as time goes forward. If it does not (or rather if the value is less than the value prior to itself) then that value should be replaced with an NA.</p>
<p>The result I'm trying to achieve would look like this:</p>
<pre><code> date value ID
10/20/21 123 1
10/21/21 NA 1
10/22/21 NA 1
10/23/21 125 1
10/24/21 127 1
10/25/21 NA 1
10/26/21 NA 1
10/27/21 128 1
10/28/21 129 1
10/20/21 155 2
10/21/21 156 2
10/22/21 NA 2
10/23/21 NA 2
10/24/21 157 2
10/25/21 158 2
10/26/21 159 2
10/27/21 160 2
10/28/21 162 2
</code></pre>
<p>I have tried solving this using a simple lag() function, but this only works for the previous value of each row and doesn't work when more than one number in succession needs to be replaced with an NA.</p>
<p>Is there an efficient way to achieve this result?</p>
| [
{
"answer_id": 74215011,
"author": "Clifford",
"author_id": 168986,
"author_profile": "https://Stackoverflow.com/users/168986",
"pm_score": 2,
"selected": true,
"text": "new"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9749276/"
] |
74,214,883 | <p>I have been trying to display the selected item of a picker from one page to another when button click event is fired. I am a beginner in Xamarin forms..</p>
<p>I tried to bind the itemsSource of the picker but that does seems to work...</p>
| [
{
"answer_id": 74215011,
"author": "Clifford",
"author_id": 168986,
"author_profile": "https://Stackoverflow.com/users/168986",
"pm_score": 2,
"selected": true,
"text": "new"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17214962/"
] |
74,214,885 | <p>I am getting a SqlException 0x80131904 while trying to fetch all records from a table. The error message is: Invalid object name 'SiteToSites'</p>
<p>I have looked here on Stack Overflow for this error and found lots of posts on it and answers. I've checked out the answers, but none address what I'm seeing.</p>
<p>There's a table in the database named SiteToSite. I am using EF Core 6, in a .NET 6 ASP.NET MVC app.</p>
<p>In a service class I have the following to get all the records from a table named SiteToSite:</p>
<pre><code> public IEnumerable<SiteToSite> GetAll()
{
return _context.SiteToSites.OrderBy(s => s.SiteToSiteID);
}
</code></pre>
<p>In the controller I have the following command to call GetAll():</p>
<pre><code> public IActionResult Step1()
{
IList<SiteToSite> sites;
sites = siteToSiteService.GetAll().ToList();
var firstSite = sites.First() ?? new SiteToSite();
return View(firstSite);
}
</code></pre>
<p>The fourth line in the Step1 action method is where the error is raised.</p>
<p>In the DbContext class here's how the DbSet for SiteToSite is defined:</p>
<pre><code>public virtual DbSet<SiteToSite> SiteToSites { get; set; } = null!;
</code></pre>
<p>I don't see what's wrong. There is a <code>SiteToSites</code> defined in the DbContext class. The table exists. The properties in the model class match the columns in the SQL database. And furthermore, I've got the same logic for a different table and model class, with its own GetAll() method in its service class and controller. So, why am I getting the 0x80131904 error with this class, but not with the other class?</p>
<p>I'm using VS 2022 and EFCore 6</p>
| [
{
"answer_id": 74215626,
"author": "Maxime Poulain",
"author_id": 5931584,
"author_profile": "https://Stackoverflow.com/users/5931584",
"pm_score": 0,
"selected": false,
"text": "SiteToSites"
},
{
"answer_id": 74229721,
"author": "Chen",
"author_id": 18789859,
"author... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214885",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/197791/"
] |
74,214,891 | <p>I have the following simple MWE.</p>
<pre><code>set.seed(2022102517)
df <- data.frame(letter =factor(colors()[1:8], levels = colors()[1:8]), value = rnorm(8))
library(ggplot2)
ggplot(data = df, aes(x = letter, y = value, group = 1)) + geom_line()
</code></pre>
<p>Which gives me a line plot for "value" for each "letter" as follows:</p>
<p><a href="https://i.stack.imgur.com/0pRwz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/0pRwz.png" alt="enter image description here" /></a></p>
<p>Note the ordering.</p>
<p>Now, what I would like to do is to have a small square in front of each colorname of different (assigned) color (from fill.col) (in the x-axis). So, basically, wherever we have a letter on x-axis, then add a filled color box to the left of each letter, where the colors are picked up from,say, fill.col.</p>
<pre><code>fill.col <- c("#005A32", "#FC8D62", "#D95F02", "#8DA0CB", "#7570B3", "#E78AC3", "#E7298A", "#A6D854")
</code></pre>
<p>I tried the following (from the solution provided below):</p>
<pre><code>library(tidyverse)
library(RColorBrewer)
library(ggtext)
df %>%
mutate(new_letter = paste("<span style = 'color: ",
fill.col,
";'>",
"\u25a0",
"</span>",
" ",
letter,
sep = ""),
new_letter = fct_reorder(new_letter, as.character(letter))) %>%
ggplot(aes(new_letter, value, group = 1)) +
geom_line() +
theme(axis.text.x = element_markdown(size = 12))
</code></pre>
<p>which gives me:</p>
<p><a href="https://i.stack.imgur.com/GzasT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GzasT.png" alt="enter image description here" /></a></p>
<p>It appears to me that in this case, we are reordering "letter" by the alphabet, though the color attachments appear to be correct here. Is it possible to keep the original order so that I can have control on the display? Thanks for further help and clarifications!</p>
| [
{
"answer_id": 74215065,
"author": "jared_mamrot",
"author_id": 12957340,
"author_profile": "https://Stackoverflow.com/users/12957340",
"pm_score": 1,
"selected": false,
"text": "set.seed(2022102517)\ndf <- data.frame(letter =letters[1:8], value = rnorm(8))\nlibrary(ggplot2)\nggplot(data... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214891",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3236841/"
] |
74,214,907 | <p>I have 2 dataframes A and B. I need to check if A has all the values in B (the order is important) and if yes I need the position.</p>
<p>A:</p>
<pre><code>index X Y
0 0 0
1 1 0
2 1 1
3 0 1
4 0 0
5 1 1
6 2 2
7 2 1
8 2 2
</code></pre>
<p>B:</p>
<pre><code>index X Y
0 0 0
1 1 1
2 2 2
</code></pre>
<p>How can I check if A contains B? In this case the answer should be yes and the starting index is 4.</p>
<p>Since I also need to check the order of values, the following cases will be False. (dataframe A doesn't contain them):</p>
<p>C:</p>
<pre><code>index X Y
0 0 0
1 0 0
</code></pre>
<p>A contains C? => False</p>
<p>D:</p>
<pre><code>index X Y
0 0 0
1 0 1
</code></pre>
<p>A contains D? => False</p>
<p>E:</p>
<pre><code>index X Y
0 1 1
1 0 0
</code></pre>
<p>A contains E? => False</p>
| [
{
"answer_id": 74215115,
"author": "chrslg",
"author_id": 20037042,
"author_profile": "https://Stackoverflow.com/users/20037042",
"pm_score": 3,
"selected": true,
"text": "def findIndex(A,B):\n a=A.values # ndarray of data in A\n b=B.values # same for B\n af=a.flatten() # same n... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214907",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4180266/"
] |
74,214,967 | <p>I switched from react-paypal-button-v2 to react-paypal-js.</p>
<p>Before i could disable payments inside my options with disableFunding: 'card'
but it no longer working with react-paypal-js</p>
<p>So I'm kinda confused where to set it up.
Inside my initialOptions or in my PayPalButton as a props?</p>
<pre><code>const initialOptions = {
'client-id': 'test',
currency: 'EUR',
intent: 'capture',
};
<PayPalScriptProvider options={initialOptions}>
<PayPalButtons/>
</PayPalScriptProvider>
</code></pre>
<p>Edit:</p>
<pre><code>const initialOptions = {
'client-id': 'test',
currency: 'EUR',
intent: 'capture',
'disable-funding': 'card',
};
</code></pre>
<p>It's not working for me and without single quotes it's not working bcs I can't use that for an opject with hyphen</p>
| [
{
"answer_id": 74215115,
"author": "chrslg",
"author_id": 20037042,
"author_profile": "https://Stackoverflow.com/users/20037042",
"pm_score": 3,
"selected": true,
"text": "def findIndex(A,B):\n a=A.values # ndarray of data in A\n b=B.values # same for B\n af=a.flatten() # same n... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20199710/"
] |
74,214,972 | <p>I wanted to recursively reverse elements in the list for range <code>i</code> to <code>j</code>.</p>
<pre><code>def revlist(l, i, j):
if not l: # this will be true if l == []
return l
return l[-1:] + revlist(l[:-1]) # recursive case
</code></pre>
<p>For example list <code>[1, 2, 3, 4, 5, 6, 7, 8, 9]</code> for <code>i = 2</code> and <code>j = 5</code> will be <code>[1, 5, 4, 3, 2, 6, 7, 8, 9]</code>.</p>
<p>How to do this?</p>
| [
{
"answer_id": 74215012,
"author": "Michael M.",
"author_id": 13376511,
"author_profile": "https://Stackoverflow.com/users/13376511",
"pm_score": 0,
"selected": false,
"text": ".reverse()"
},
{
"answer_id": 74215202,
"author": "Grismar",
"author_id": 4390160,
"author_... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214972",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20236195/"
] |
74,214,985 | <p>A merge with a commits squashed introduced a bug to my master branch. I would like the to undo the merge request and then break it into its individual commits and then apply them in order to figure out which commit introduced the bug. What would be the best way to do this? I have tried using <code>git reset HEAD~</code> which unstaged all of the changes from the merge, however this just tell me the files that changed. I have also looked into using a interactive rebase, but I am not sure how to properly do it for my use case. Any advice on tackling this issue?</p>
| [
{
"answer_id": 74215177,
"author": "Schwern",
"author_id": 14660,
"author_profile": "https://Stackoverflow.com/users/14660",
"pm_score": 2,
"selected": true,
"text": "git reflog"
},
{
"answer_id": 74215194,
"author": "Ivan Yuzafatau",
"author_id": 1889110,
"author_pro... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74214985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7298643/"
] |
74,215,016 | <p>I have a dataset containing all character values, I want to change some to factor and some to numeric depending on what is contained in the original character value (if a number is contained then convert column to numeric, if a letter is contained, factor). I have this for loop where I am sequencing along my dataset but I can't get i to return the actual cell value.</p>
<pre><code>l <- c("1", "2", "3", "4", "5", "6", "7", "8", "9", "0")
for (i in df) {
if(i[c(1)] %in% l) {
as.numeric(i)
} else {
as.factor(i)
}
}
</code></pre>
<p>I also have tried with grepl and ifelse:</p>
<pre><code>for (i in seq_along(df[c(0),])) {
ifelse((grepl(l, df[i])), as.numeric(i), as.factor(i))
}
</code></pre>
<p>this is a reproducible example of the dataset:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: center;">col1</th>
<th style="text-align: center;">col2</th>
<th style="text-align: center;">col3</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">true</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">-25.4</td>
</tr>
<tr>
<td style="text-align: center;">false</td>
<td style="text-align: center;">2</td>
<td style="text-align: center;">123.23</td>
</tr>
<tr>
<td style="text-align: center;">false</td>
<td style="text-align: center;">3</td>
<td style="text-align: center;">321</td>
</tr>
<tr>
<td style="text-align: center;">true</td>
<td style="text-align: center;">4</td>
<td style="text-align: center;">-24</td>
</tr>
</tbody>
</table>
</div>
<p>--for this example I would want col1 to be a factor and col2, col3 to be numeric</p>
| [
{
"answer_id": 74215088,
"author": "Jon Spring",
"author_id": 6851825,
"author_profile": "https://Stackoverflow.com/users/6851825",
"pm_score": 0,
"selected": false,
"text": "dplyr::across"
},
{
"answer_id": 74215145,
"author": "Dollar Tune-bill",
"author_id": 18308393,
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215016",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11445124/"
] |
74,215,021 | <p>I have two tables (main_table, codes_table). I need to join the two tables on column code. Example data below:</p>
<p>main_table</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>customer</th>
<th>code</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Fred</td>
<td>Acme Residential</td>
</tr>
<tr>
<td>2</td>
<td>Sue</td>
<td>Acme Business</td>
</tr>
<tr>
<td>3</td>
<td>Bud</td>
<td>Acme & Old State</td>
</tr>
</tbody>
</table>
</div>
<p>codes_table</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>id</th>
<th>code</th>
<th>group</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Acme</td>
<td>X19CD</td>
</tr>
<tr>
<td>2</td>
<td>Acme Business</td>
<td>G933C</td>
</tr>
</tbody>
</table>
</div>
<p>My data is in Google Big Query and I am hoping to use native SQL. I am trying to come up with SQL that would allow me to join main_table to codes_table such that I would get the following output:</p>
<p>Results</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>cust_id</th>
<th>customer</th>
<th>code</th>
<th>group</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>Fred</td>
<td>Acme Residential</td>
<td>X19CD</td>
</tr>
<tr>
<td>2</td>
<td>Sue</td>
<td>Acme Business</td>
<td>G933C</td>
</tr>
<tr>
<td>3</td>
<td>Bud</td>
<td>Acme & Old State</td>
<td>X19CD</td>
</tr>
</tbody>
</table>
</div>
<p>Appreciate any thoughts on how one can accomplish this with SQL.</p>
<p>Essentially the code in the customer table could be various permutations of "Acme ". The issue I have had that trying the various ways I have to join to two tables ends up getting both code_table rows as they both start with "Acme". What I am trying to do is join the two where the main_table.code matches the most characters from the code_table.code.</p>
| [
{
"answer_id": 74215088,
"author": "Jon Spring",
"author_id": 6851825,
"author_profile": "https://Stackoverflow.com/users/6851825",
"pm_score": 0,
"selected": false,
"text": "dplyr::across"
},
{
"answer_id": 74215145,
"author": "Dollar Tune-bill",
"author_id": 18308393,
... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215021",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20343731/"
] |
74,215,037 | <p>I basically have a data frame with a column of letters and a column of colors:</p>
<pre><code>x <- data.frame(col1=c("a","b","a","c","d","d","c","a","b","c"),
col2=c("red","orange","yellow","red","red","yellow","orange","yellow","red","orange"))
col1 col2
a red
b orange
a yellow
c red
d red
d yellow
c orange
a yellow
b red
c orange
</code></pre>
<p>My goal is to create a second data frame that counts the number of occurences of each color in <code>col2</code> of <code>x</code> for each letter in <code>col1</code>. Basically:</p>
<pre><code>Letters Occurences Red Orange Yellow
a 3 1 0 2
b 2 1 1 0
c 3 1 2 0
d 2 1 0 1
</code></pre>
<p>Right now, I just brute forced it since there are only 3 factors of <code>col2</code>. I used:</p>
<pre><code>df <- data.frame(Letters = levels(factor(x$col1)))
df$Occurences <- table(x$col1)
df$red <- table(factor(x$col1[x$col2=="red"],levels=levels(factor(x$col1))))
df$orange <- table(factor(x$col1[x$col2=="orange"],levels=levels(factor(x$col1))))
df$yellow <- table(factor(x$col1[x$col2=="yellow"],levels=levels(factor(x$col1))))
</code></pre>
<p>Is there an easier way to do this, as opposed to doing each column of <code>df</code> one by one? Especially with a data set that has a lot more than 3 factors?</p>
| [
{
"answer_id": 74215070,
"author": "Jilber Urbina",
"author_id": 1315767,
"author_profile": "https://Stackoverflow.com/users/1315767",
"pm_score": 2,
"selected": true,
"text": "pivot_wider"
},
{
"answer_id": 74215371,
"author": "onyambu",
"author_id": 8380272,
"author... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215037",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17399178/"
] |
74,215,057 | <p>I am trying to create a script in Google Sheets that will allow me to have a datestamp entered in a cell when a checkbox is checked in the row that cell is in. I have gotten the first part done thanks to web searches, but the second part of the task I am having issues with.</p>
<p>Once the checkbox has been checked the datestamp does indeed go in the cell, but when I uncheck the checkbox it just updates the date in the cell, but does not remove it.</p>
<p>I am sure I am just missing something easy, but as I do not normally code, and only have a somewhat firm grasp on formulas even, this is a bit out of my ability to troubleshoot. If anyone could look at this and help me figure out what variables would be tied to what I am doing, and which ones I have gotten wrong (ideally with comments so I can understand what each line of code is trying to do), I would appreciate it.</p>
<p>Here is the script:</p>
<pre><code>function onEdit() {
var s = SpreadsheetApp.getActiveSheet();
if( s.getName() == "Writing Team Tasks" ) { //checks that we're on the correct sheet
var r = s.getActiveCell();
if( r.getColumn() == 5 ) { //checks that the cell being edited is in column A
var nextCell = r.offset(0, 4); { //offset for the non-adjacent column
if( r.getValue() === "") { //checks if the cell being edited is empty or not?
nextCell.setValue("");
}
else
{
nextCell.setValue(new Date());
}
}
}
}
}
</code></pre>
<p>I am hoping to have a script that will enter a date stamp when a checkbox is checked, and then remove the datestamp if the checkbox becomes unchecked. Currently, I am able to do all of that, except remove the datestamp.</p>
| [
{
"answer_id": 74215159,
"author": "Cooper",
"author_id": 7215091,
"author_profile": "https://Stackoverflow.com/users/7215091",
"pm_score": 2,
"selected": true,
"text": "function onEdit(e) {\n const sh = e.range.getSheet();\n if (sh.getName() == \"Writing Team Tasks\" && e.range.column... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20343703/"
] |
74,215,099 | <p>Can anyone help me to solve this issue?</p>
<p>I have Google Chrome version 107.0.5304.6, and I'm using WebDriverManager to get the same chromeDriver version. I download Google Chrome version 106 and run my tests and this issue didn't happen, but my Google Chrome updates automatically from version 106 to 107 and the warning happens again.</p>
| [
{
"answer_id": 74264890,
"author": "waqar jan",
"author_id": 20380185,
"author_profile": "https://Stackoverflow.com/users/20380185",
"pm_score": 1,
"selected": false,
"text": "<dependency>\n <groupId>org.seleniumhq.selenium</groupId>\n <artifactId>selenium-devtools-v88</artifactId>... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215099",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20343854/"
] |
74,215,109 | <p>Rounding under Visual Studio 2019 does not work as expected as outlined <a href="https://learn.microsoft.com/en-us/dotnet/api/system.math.round?view=net-6.0" rel="nofollow noreferrer">in the documentation</a> in certain cases for me.</p>
<p>Under Visual Studio 2019, when I run Math.Round(1.275, 2) I get 1.27. Based on the default rounding it should round to the nearest even digit 1.28. If I run Math.Round(0.275, 2) I get 0.28.</p>
| [
{
"answer_id": 74215168,
"author": "shrindle",
"author_id": 20343860,
"author_profile": "https://Stackoverflow.com/users/20343860",
"pm_score": 3,
"selected": true,
"text": "Math.Round"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215109",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10007576/"
] |
74,215,110 | <pre><code>Fixpoint n_copies (n x : nat) : list nat :=
match n with
| 0 => []
| S n' => x :: n_copies n' x
end.
Theorem exercise3
: forall x n, num_occ x (n_copies n x) = n.
Proof.
</code></pre>
<p>I tried:</p>
<pre><code>intros x n. induction n. simpl.
- congruence.
- destruct (eq_dec x n).
+ induction e.
+
</code></pre>
<p>but i cant think a solution for another "+", and i have this notice:</p>
<pre><code>1 goal
x : nat
IHn : num_occ x (n_copies x x) = x
______________________________________(1/1)
num_occ x (n_copies (S x) x) = S x
</code></pre>
<p>I think that i have to take of the S of both sides, but i don't know how.</p>
| [
{
"answer_id": 74215168,
"author": "shrindle",
"author_id": 20343860,
"author_profile": "https://Stackoverflow.com/users/20343860",
"pm_score": 3,
"selected": true,
"text": "Math.Round"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215110",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20335902/"
] |
74,215,133 | <p>So I have a global variable called char words[10]. I would like to pass it as a parameter as in a function.</p>
<p>This is the code I have so far and it does not compile obviously. I just do not know how exactly to pass the words variable to the function read_words.</p>
<pre><code>
#include <stdio.h>
char *words[10];
void read_words(*words){
}
int main(){
read_words(*words);
}
</code></pre>
| [
{
"answer_id": 74215168,
"author": "shrindle",
"author_id": 20343860,
"author_profile": "https://Stackoverflow.com/users/20343860",
"pm_score": 3,
"selected": true,
"text": "Math.Round"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20227611/"
] |
74,215,152 | <p>So i have been following this tuitorial and for soem reason I can not import my text from xml to kotlin file.
I have tried diffrent things but it still wont work.</p>
<p>I did add id 'kotlin-android-extensions' to my gradle:module:app but still wot go though.</p>
<p>Here is my code</p>
<p>todoAdapter.kt
`</p>
<pre><code>package com.example.todo
import android.view.LayoutInflater
import android.view.View
import android.view.ViewGroup
import androidx.appcompat.view.menu.ActionMenuItemView
import androidx.recyclerview.widget.RecyclerView
class todoAdapter(
private val todos : MutableList<Todo>
):RecyclerView.Adapter<todoAdapter.TodoViewHolder>() {
class TodoViewHolder(itemView:View): RecyclerView.ViewHolder(itemView)
override fun onCreateViewHolder(parent: ViewGroup, viewType: Int): TodoViewHolder {
val view = LayoutInflater.from(parent.context).inflate(R.layout.item_todo,parent,false);
return TodoViewHolder(view);
}
override fun onBindViewHolder(holder: TodoViewHolder, position: Int) {
val curTodo = todos[position]
holder.itemView.tv (this bracket is not included in the code, the reason i onyl wrote tv is that if i wrote full it would be a red text and not get thr refrence)
}
override fun getItemCount(): Int {
return todos.size;
}
}
</code></pre>
<p>`</p>
<p>item_todo.xml</p>
<p>`</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
android:layout_width="match_parent"
android:layout_height="70dp"
android:paddingStart="14dp"
android:paddingEnd="14dp">
<TextView
android:id="@+id/tvTodoTitle"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:text="Example"
android:textSize="20sp"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent" />
<CheckBox
android:id="@+id/tvCheckboxTodo"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
</code></pre>
<p>`</p>
<p>I have tried using the apply but that funciton too doesnt seem to work , I just wanna know where I am doing htinsg wrong. Please expalin begnier level as I am still lenring</p>
| [
{
"answer_id": 74215168,
"author": "shrindle",
"author_id": 20343860,
"author_profile": "https://Stackoverflow.com/users/20343860",
"pm_score": 3,
"selected": true,
"text": "Math.Round"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215152",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20343894/"
] |
74,215,173 | <p>I have the table structure below
<a href="https://i.stack.imgur.com/fxBks.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fxBks.png" alt="enter image description here" /></a></p>
<p>I want to be able to select the following groups</p>
<ul>
<li>farmers who grow between 1 and 3 commodities</li>
<li>farmers who grow between 4 and 6 commodities</li>
<li>farmers who grow more than 6 commodities</li>
</ul>
<p>My resultant query should look like below</p>
<p><a href="https://i.stack.imgur.com/ZrpA1.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ZrpA1.png" alt="enter image description here" /></a></p>
<p>I am completely lost as to how to go about this query. I tried</p>
<pre><code>SELECT count(*) AS total,
(SELECT count(farmer_id) from farmer_commodities HAVING count(commodity_id) < 3) AS grow1_3,
(SELECT count(farmer_id) from farmer_commodities HAVING count(commodity_id) BETWEEN 4 AND 6) AS grow4_6,
(SELECT count(farmer_id) from farmer_commodities HAVING count(commodity_id) > 6) as grow_above_6
from farmer_commodities
</code></pre>
| [
{
"answer_id": 74215267,
"author": "Gauravsa",
"author_id": 2549110,
"author_profile": "https://Stackoverflow.com/users/2549110",
"pm_score": 0,
"selected": false,
"text": "select grow1_3_commodities, grow4_6_commodities, grow_above_6_commodities from (\n (select farmer_id, count(com... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2976827/"
] |
74,215,210 | <p>I have created a database in Access 2019</p>
<p>I have created a basic form to display the data from the above table</p>
<p>I would like to filter the data to show only certain countries – like below</p>
<p>The where clause is hard code and so my question is how can I dynamically change the filter clause say from ‘Aus’ to ‘UK’.<br />
a) I have tried using a parameter ‘CountryName’ as see in the Fill, GetData (CountryName), but I am unable to use the parameter in the Query Builder. How can this be done if possible?</p>
<p>b) Is there a way to change the Fill Query Property (CommandText) by code as I am unable to see the correct properties to use – see below</p>
| [
{
"answer_id": 74215267,
"author": "Gauravsa",
"author_id": 2549110,
"author_profile": "https://Stackoverflow.com/users/2549110",
"pm_score": 0,
"selected": false,
"text": "select grow1_3_commodities, grow4_6_commodities, grow_above_6_commodities from (\n (select farmer_id, count(com... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20343717/"
] |
74,215,229 | <p>How do I take 2 numbers from input where the first number indicates how many lists there should be and the second indicates how many strings there will be and then assigning that string to the number of that list? For example if I have an input of:</p>
<pre><code>3 3 # first 3 indicates how many lists and the second 3 indicates how many strings
1 Cat # assigning Cat to the first list
2 Dog # assigning Dog to the second list
3 Tiger # assigning Tiger to the third list
</code></pre>
<p>It would ouput:</p>
<pre><code>[Cat]
[Dog]
[Tiger]
</code></pre>
<p>Another input could be:</p>
<pre><code>3 4 # 3 indicates how many lists and 4 indicates how many strings
1 Cat # assigning Cat to first list
1 Lion # assigning Lion also to first list
2 Dog # assigning Dog to second list
3 Tiger # assigning Tiger to third list
</code></pre>
<p>And that would output:</p>
<pre><code>[Cat, Lion]
[Dog]
[Tiger]
</code></pre>
<p>Right now all I have is this:</p>
<pre><code>lst = input().split()
number = int(lst[0])
string = int(lst[1])
for k in range(number):
lst1 = []
for i in range(string):
string1 = input()
</code></pre>
<p>From here I'm confused on how to assign the string to the list that the user inputs. After I figure that out I know I'll have use the append method to add to the list if the user decides to have 2 or more strings in a list but if someone could help me out on how to actually assign it, I'd appreciate it.</p>
| [
{
"answer_id": 74215267,
"author": "Gauravsa",
"author_id": 2549110,
"author_profile": "https://Stackoverflow.com/users/2549110",
"pm_score": 0,
"selected": false,
"text": "select grow1_3_commodities, grow4_6_commodities, grow_above_6_commodities from (\n (select farmer_id, count(com... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215229",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20343843/"
] |
74,215,238 | <p>If we set the state with the same value component won't re-render, but it's not applicable when I set the state in the function body.</p>
<p>For example, if I set the same state on the button click and the button clicked, the component does not re-rendering on the button click</p>
<pre><code>function Test1() {
const [name, setName] = useState("Shiva");
const onButtonClick = () => {
console.log("Clicked");
setName("Shiva");
};
console.log("Redering");
return (
<div>
<span>My name is {name}</span>
<button onClick={onButtonClick}>Click Me</button>
</div>
);
}
</code></pre>
<p>But, when I set the same state before the return statement React goes infinite renderings</p>
<pre><code>function Test2() {
const [name, setName] = useState("Shiva");
// ... come stuff
setName("Shiva");
console.log("Rendering");
return (
<div>
<span>My name is {name}</span>
</div>
);
}
</code></pre>
<p>What actually happening internally?</p>
| [
{
"answer_id": 74243080,
"author": "Wazeed",
"author_id": 6394979,
"author_profile": "https://Stackoverflow.com/users/6394979",
"pm_score": 2,
"selected": false,
"text": "React"
},
{
"answer_id": 74244136,
"author": "Dilshan",
"author_id": 11306028,
"author_profile": ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215238",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11074422/"
] |
74,215,245 | <p>I am currently trying to map through every planet in the star wars api and print out the individual planet name but I am stuck. API LINK (<a href="https://swapi.dev/" rel="nofollow noreferrer">https://swapi.dev/</a>)</p>
<p>Thankyou for any help or advice</p>
<p>I tried using axios and Use Effect but am not sure where my errors may be. Below is what i have in my AllPlanets React Component.</p>
<p>`</p>
<pre><code>import React from "react";
import axios from "axios";
import { useState, useEffect } from "react";
const AllPlanets = () => {
const [data, setData] = useState("");
useEffect(() => {
axios
.get(`https://swapi.dev/api/planets`)
.then((res) => setData(res.data))
.catch((error) => console.log(error));
});
return (
<div>
{data && (
<div className="flex">
{data.map((planet, idx) => (
<p>{planet.name}</p>
))}
</div>
)}
</div>
);
};
export default AllPlanets;
</code></pre>
<p>`</p>
| [
{
"answer_id": 74215282,
"author": "Ori Drori",
"author_id": 5157454,
"author_profile": "https://Stackoverflow.com/users/5157454",
"pm_score": 2,
"selected": false,
"text": "results"
},
{
"answer_id": 74215302,
"author": "tao",
"author_id": 1891677,
"author_profile": ... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215245",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20217596/"
] |
74,215,253 | <p>I have a task that's becoming quite difficult for me.</p>
<p>I have to create a variable (pr_test_1) to test whether a variable for a procedure (I10_PR1) is in a list of procedures, and this code is working great:</p>
<pre><code>df <- df %>%
mutate(pr_test_1=ifelse(I10_PR1 %in% abl_pr, 1,0))
</code></pre>
<p>However, I have 25 variables for procedures (I10_PR1 to I10_PR25) and I have to create one for each (pr_test_1 to pr_test_25).</p>
<p>I don't seem to find the right syntax to get a for loop to work.</p>
<p>Any help will be greatly appreciated!</p>
| [
{
"answer_id": 74215339,
"author": "ejneer",
"author_id": 8827325,
"author_profile": "https://Stackoverflow.com/users/8827325",
"pm_score": 1,
"selected": false,
"text": "dplyr::across"
},
{
"answer_id": 74215382,
"author": "Roasty247",
"author_id": 3723262,
"author_p... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19141802/"
] |
74,215,300 | <p>I need a regex which should validate a value which</p>
<ol>
<li>can be a 3 digit number OR</li>
<li>can be a 4 digit number but the first digit should be 0 OR</li>
<li>can be a alpha numeric value with length 5</li>
</ol>
<p>I did this regex which seems to working but I believe there is a better way of writing this. This is my regex. Please suggest a better way</p>
<pre><code>(^[0-9]{3}$)|(^0[0-9]{3}$)|(^[0-9a-zA-Z]{5}$)
</code></pre>
| [
{
"answer_id": 74215336,
"author": "Naveed",
"author_id": 3494754,
"author_profile": "https://Stackoverflow.com/users/3494754",
"pm_score": 0,
"selected": false,
"text": "/^(0?\\d{3}|[\\D\\d]{5})/\n"
},
{
"answer_id": 74215338,
"author": "bobble bubble",
"author_id": 5527... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215300",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1422000/"
] |
74,215,318 | <p>I'm a beginner programmer just starting out and learning and I'm wondering why my code finishes after the first line. If anyone can let me know what is wrong with it, would be greatly appreciated.</p>
<p>I wanted it to print my if statements properly but I'm not sure what's going on.</p>
<pre><code>x = 10
try:
(input("Type in a number:"))
except ValueError:
print('Correct!')
if x > 10:
print('X is bigger than the number given')
if x < 10:
print('X is smaller than the number given')
</code></pre>
| [
{
"answer_id": 74215336,
"author": "Naveed",
"author_id": 3494754,
"author_profile": "https://Stackoverflow.com/users/3494754",
"pm_score": 0,
"selected": false,
"text": "/^(0?\\d{3}|[\\D\\d]{5})/\n"
},
{
"answer_id": 74215338,
"author": "bobble bubble",
"author_id": 5527... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215318",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20344028/"
] |
74,215,326 | <p>Here's the table I am dealing with -</p>
<p>Table Name: Filters</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Filter Type</th>
<th>Value</th>
<th>ID</th>
</tr>
</thead>
<tbody>
<tr>
<td>vendor</td>
<td>ABCS</td>
<td>1001</td>
</tr>
<tr>
<td>product</td>
<td>109</td>
<td>1001</td>
</tr>
<tr>
<td>vendor</td>
<td>BVHG</td>
<td>1002</td>
</tr>
<tr>
<td>product</td>
<td>108</td>
<td>1003</td>
</tr>
</tbody>
</table>
</div>
<p>And I need to pull out count of unique IDs that repeat in both vendor and product. Need help!</p>
<p>Tried using AND clause for filter criteria, but did not work</p>
<p>my attempt below -</p>
<pre><code>Select ID from Filters
Where Filter_type = 'vendor' AND Filter_type = 'product'
</code></pre>
| [
{
"answer_id": 74215336,
"author": "Naveed",
"author_id": 3494754,
"author_profile": "https://Stackoverflow.com/users/3494754",
"pm_score": 0,
"selected": false,
"text": "/^(0?\\d{3}|[\\D\\d]{5})/\n"
},
{
"answer_id": 74215338,
"author": "bobble bubble",
"author_id": 5527... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215326",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20344020/"
] |
74,215,353 | <p>I am working on conditional statements where my float variables are supposed to be in between a range.</p>
<p>If they are above or below the given range then they need to print out whether it's too much or too little.
and if everything within range then it's supposed to print out great! etc</p>
<p>My code works when everything is out of bounds and if everything is in bounds, but if only 1 or 2 things are not within bounds, it still prints out that everything is great alongside that it's too much or too little.</p>
<p>What am I missing?</p>
<p>`</p>
<pre><code>#include <stdio.h>
int main()
{
float salt, pepper, garlic, thyme;
printf("Lets cook!\n");
printf("====================\n");
printf("\n");
printf("Amount of salt added? ");
scanf("%f", &salt);
printf("Amount of pepper added? ");
scanf("%f", &pepper);
printf("Amount of garlic added? ");
scanf("%f", &garlic);
printf("Amount of thyme added? ");
scanf("%f", &thyme);
if (pepper < 1.5)
{
printf("Needs more pepper\n");
}
else if(pepper > 3.5)
{
printf("Too much pepper!\n");
}
if(salt <5.5)
{
printf("Needs more salt\n");
}
else if(salt > 13)
{
printf("Too salty!\n");
}
if (garlic < 2)
{
printf("Needs more garlic\n");
}
else if(garlic > 4)
{
printf("Too much garlic!\n");
}
if (thyme < 0.5)
{
printf("Needs more thyme\n");
}
else if(thyme > 1.25)
{
printf("Too much thyme!\n");
}
else
{
printf("Delicious!\n");
}
return 0;
}
</code></pre>
<p>`</p>
<p>When I only have 2 of the conditional statements triggered it still triggers the else:</p>
<h1>Lets cook!</h1>
<p>Amount of salt added? 15
Amount of pepper added? 5
Amount of garlic added? 3
Amount of thyme added? 1
Too much pepper!
Too salty!
Delicious</p>
<p>But if all conditional statements are triggered the else doesn't populate:</p>
<h1>Lets cook!</h1>
<p>Amount of salt added? 15
Amount of pepper added? 15
Amount of garlic added? 15
Amount of thyme added? 15
Too much pepper!
Too salty!
Too much garlic!
Too much thyme!</p>
<p>And if everything is between the range, the else triggers (like how I want it to):</p>
<h1>Lets cook!</h1>
<p>Amount of salt added? 6
Amount of pepper added? 2
Amount of garlic added? 3
Amount of thyme added? 1
Delicious!</p>
<p>How do I get the else to not trigger when only some of them are not within range?</p>
| [
{
"answer_id": 74215436,
"author": "Bob__",
"author_id": 4944425,
"author_profile": "https://Stackoverflow.com/users/4944425",
"pm_score": 2,
"selected": true,
"text": "else"
},
{
"answer_id": 74215510,
"author": "Kingsley",
"author_id": 1730895,
"author_profile": "ht... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215353",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20344038/"
] |
74,215,360 | <p>Hi I am trying to get the value from local storage by using observable but it is not working.</p>
<p>My previous code was:</p>
<pre class="lang-js prettyprint-override"><code>const isManager= JSON.parse(localStorage.getItem('isManager'));
console.log('isManager', isManager);
this.doNavigation(isManager);
</code></pre>
<p>But I change it in to this for continously reading value:</p>
<pre><code>of(JSON.parse(localStorage.getItem('isManager'))).pipe(
takeWhile(() => this.alive),
map((isManager: boolean) => {
console.log('isManager', isManager);
this.doNavigation(isManager);
})
);
</code></pre>
<p>The problem is that it is not going inside the map body and there is a value present in local stroage regarding this field.</p>
| [
{
"answer_id": 74215753,
"author": "Adrian Brand",
"author_id": 1679126,
"author_profile": "https://Stackoverflow.com/users/1679126",
"pm_score": 1,
"selected": false,
"text": "const isManager = localStorage.getItem('isManager') === 'true';\n// You need to convert the string stored in lo... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215360",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20338231/"
] |
74,215,373 | <p>I am building my own personal web page, and while doing the "header" I wasn't able to align my "a" tags to the logo... I've been trying everything, but there are no solutions.</p>
<p>This is my code. If I am wrong in some part, please explain me to not commit the same mistake.</p>
<p>HTML</p>
<p>`</p>
<pre><code> <div class="mainBox">
<!--Logo-->
<div class="navBox">
<a href="web.url.com"><img src="Images/Logo3Final.png" alt="logo" id="logo"></a>
</div>
<div class="navBox">
<a href="#about">/*About Me*/</a>
</div>
<div class="navBox">
<a href="#contact">/*Contact*/</a>
</div>
<div class="navBox">
<a href="#expertise">/*Expertise*/</a>
</div>
<div class="navBox">
<a href="#projects">/*Projects*/</a>
</div>
</div>
</code></pre>
<p>`</p>
<p>CSS</p>
<pre><code>
`#logo{
max-width: 200px;
max-height: 220px;
right: -100px;
}
/*MENU*/
.mainBox{
position: relative;
display: flex;
width: 95%;
height: 25vh;
justify-content: space-evenly;
align-items: center;
}
.navBox{
padding-top: 25px;
padding-left: 10px;
padding-right: 10px;
width: 20%;
height: 20vh;
text-align: center;
top: 50%;
background: transparent;
}
.navBox a:hover{
padding-top: 50%;
background: transparent;
color: var(--text-color);
text-decoration: none;
}
a:visited, a:active, a:link{
text-decoration: none;
color: var(--text-color);
}
.navBox a{
vertical-align: middle;
color: var(--text-color);
padding-top: 0.5rem;
text-align: initial;
}
</code></pre>
<p>I try changing position values, I tried giving padding-top, top, margin, nesting into antoher div. But I can not achieve what I will like to be.</p>
<p>Here is a ScreenShot of my page.</p>
<p><a href="https://i.stack.imgur.com/ISrJd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ISrJd.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74215753,
"author": "Adrian Brand",
"author_id": 1679126,
"author_profile": "https://Stackoverflow.com/users/1679126",
"pm_score": 1,
"selected": false,
"text": "const isManager = localStorage.getItem('isManager') === 'true';\n// You need to convert the string stored in lo... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20344033/"
] |
74,215,379 | <p>I am trying to convert an amount from iterated object using else if statements and then the return number will be added/render to the points.</p>
<p>Also if a user ordered another it will be added to the existing points.</p>
<p>Or is there a better way to do this other than else if statements?</p>
<p>The ordered amount is num from the object and converted into a return points</p>
<p>(ordered amount is 29) = return 1;</p>
<p>(ordered amount is 276) = return 10;</p>
<p>(ordered amount is 522) = return 20;</p>
<p>(ordered amount is 1114) = return 48;</p>
<p>This is my code below</p>
<pre><code>const [points, setPoints] = useState(0)
const handlePoints = (value) => {
{userOrdered.map((ordered) => {
if (ordered.amount === 29) {
return setPoints(points.quantity + 1);
} else if (ordered.amount === 276) {
return setPoints(points.quantity + 10);
} else if (ordered.amount === 522) {
return setPoints(points.quantity + 20);
} else if (ordered.amount === 1114) {
return setPoints(points.quantity + 48);
}
})
}
}
<Typography onChange={handlePoints}>{points}</Typography>
</code></pre>
| [
{
"answer_id": 74215482,
"author": "Louys Patrice Bessette",
"author_id": 2159528,
"author_profile": "https://Stackoverflow.com/users/2159528",
"pm_score": 2,
"selected": true,
"text": "newPoints"
},
{
"answer_id": 74215683,
"author": "adsy",
"author_id": 1086398,
"au... | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215379",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18428268/"
] |
74,215,390 | <p>Today, I was creating a calculator, but when I click on the numbers nothing happenes.</p>
<ul>
<li>There are no messages in the console at all after the clicks</li>
</ul>
<p>Code in GitHub: <a href="https://github.com/GuillermoSalvador/A%5C" rel="nofollow noreferrer">https://github.com/GuillermoSalvador/A\</a></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 display = document.querySelector("#display");
const buttons = document.querySelectorAll("buttons");
buttons.forEach((item)=>{
item.onclick=()=>{
if(item.id=="clear"){
display.innerText="";
}else if(item.id=="backspace"){
let string = display.innerText.toString();
display.innerText=string.substr(0,string.length-1)
} else if (display.innerText !=""&& item.id=="equal"){
display.innerText = eval(display.innerText);
} else if(display.innerText == "" && item.id=="equal"){
display.innerText = "Null";
setTimeout(()=>(display.innerText = ""), 2000);
}else{
display.innerText+=item.id;
}
};
});</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="es">
<head>
<meta charset="UTF-8">
<meta http-equiv="X-UA-Compatible" content="IE=edge">
<meta name="viewport"
content="width=device-width, initial-scale=1.0">
<title>Document</title>
<link rel="stylesheet" href="./css/style.css">
</head>
<body>
<div class ="container">
<div class="calculator dark">
<div class="theme-toggler">
<i class="toggler-icon"></i>
</div>
<div class="display-screen">
<div id="display"></div>
</div>
<div class="buttons">
<table>
<tr>
<td><button class="btn-operator" id="clear">C</button></td>
<td><button class="btn-operator" id="/">/</button></td>
<td><button class="btn-operator" id="*">*</button></td>
<td><button class="btn-operator" id="backspace"> < </button></td>
</tr>
<tr>
<td><button class="btn-number" id="7">7</button></td>
<td><button class="btn-number" id="8">8</button></td>
<td><button class="btn-number" id="9">9</button></td>
<td><button class="btn-operator" id="-">-</button></td>
</tr>
<tr>
<td><button class="btn-number" id="4">4</button></td>
<td><button class="btn-number" id="5">5</button></td>
<td><button class="btn-number" id="6">6</button></td>
<td><button class="btn-operator" id="+">+</button></td>
</tr>
<tr>
<td><button class="btn-number" id="1">1</button></td>
<td><button class="btn-number" id="2">2</button></td>
<td><button class="btn-number" id="3">3</button></td>
<td rowspan="2"><button class="btn-equal" id="equal">=</button></td>
</tr>
<tr>
<td><button class="btn-operator" id=".">.</button></td>
<td><button class="btn-number" id="0">0</button></td>
<td><button class="btn-number" id="00">00</button></td>
</tr>
</table>
</div>
</div>
</div>
<script src="script.js"></script>
</body>
</html></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74215475,
"author": "Chris Schaller",
"author_id": 1690217,
"author_profile": "https://Stackoverflow.com/users/1690217",
"pm_score": 1,
"selected": false,
"text": "button"
}
] | 2022/10/26 | [
"https://Stackoverflow.com/questions/74215390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20344008/"
] |
74,215,394 | <p>I have made a font and I'm going to use it on my website.
But I want to make users can't download my font and use it.
What should I do to implement this challenge?</p>
<p>I have tried to find any solutions by using Typekit but I haven't found any solution.</p>
| [
{
"answer_id": 74226508,
"author": "herrstrietzel",
"author_id": 15015675,
"author_profile": "https://Stackoverflow.com/users/15015675",
"pm_score": 0,
"selected": false,
"text": "let string = 'abcdefghijklmnopqrstuvwxyz';\n// string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n//string = '012345678... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74215394",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20344068/"
] |
74,215,396 | <p>I have a panadas dataframe shown below :</p>
<pre><code>masterid price
1001 12
1001 12
1001 11
1001 14
1002 15
1003 10
1003 10
1003 10
1004 16
1004 17
</code></pre>
<p>I want to count the times when the price changes for a particular master id</p>
<p>Example : For masterid 1001 the price changed from 12 - 11 and from 11 -14 ( 2 times )</p>
<p>Expected output :</p>
<pre><code>masterid price
1001 2
1002 0
1003 0
1004 1
</code></pre>
<p>I have tried using <code>(df['price'].ne(df['price'].shift())</code> but not sure how to use group by in this case. Thanks in advance</p>
| [
{
"answer_id": 74226508,
"author": "herrstrietzel",
"author_id": 15015675,
"author_profile": "https://Stackoverflow.com/users/15015675",
"pm_score": 0,
"selected": false,
"text": "let string = 'abcdefghijklmnopqrstuvwxyz';\n// string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n//string = '012345678... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74215396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17103465/"
] |
74,215,426 | <p>Hi I am trying to run the load testing and integration tests simultaneously and I wanted to run the load tests only when we are in "stg" environment but not in any other environments. But my variable value is coming in run time as $(environment) as below</p>
<pre><code>variables:
- name: loadenv
value: $(environment)
</code></pre>
<p>My condition before the load testing code block is</p>
<pre><code> ${{if eq(variables['loadenv'], 'stg') }}:
loadTestParams:
executor: jmeter
</code></pre>
<p>This works fine if I hardcode the value: stg whereas in runtime, I am not able to get the variables if it is like this $(environment).
Can anyone please help to solve this issue?</p>
<p>I have tried the same thing with parameters but no luck</p>
| [
{
"answer_id": 74226508,
"author": "herrstrietzel",
"author_id": 15015675,
"author_profile": "https://Stackoverflow.com/users/15015675",
"pm_score": 0,
"selected": false,
"text": "let string = 'abcdefghijklmnopqrstuvwxyz';\n// string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n//string = '012345678... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74215426",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18401283/"
] |
74,215,435 | <p>Dears,</p>
<p>How to get character's equivalent from another TextInput using PySimpleGUI?
Let me explain: Suppose I have those sets of data , set A and Set B, my query is once I write one characters in TextInput 1 from Set A I'll get automatically it's equivalent in Set B;
For example Set A : A, B, C, D, ........, Z
Set B : 1, 2, 3,4, ..........,26</p>
<p>So if I write ABC in TextInut A --> I'll get : 123 in TextInput B</p>
<p>Thanks in advance</p>
<pre><code>import PySimpleGUI as sg
</code></pre>
<p><a href="https://i.stack.imgur.com/N7KwA.png" rel="nofollow noreferrer">enter image description here</a></p>
| [
{
"answer_id": 74226508,
"author": "herrstrietzel",
"author_id": 15015675,
"author_profile": "https://Stackoverflow.com/users/15015675",
"pm_score": 0,
"selected": false,
"text": "let string = 'abcdefghijklmnopqrstuvwxyz';\n// string = 'ABCDEFGHIJKLMNOPQRSTUVWXYZ';\n//string = '012345678... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74215435",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20301481/"
] |
74,215,506 | <p>I have multiple csv files on which I have to remove 2 rows because they are only NaNs. I want to load the first one, perform the cleaning and then load the second one do the cleaning and concatenate with the first one and so on.</p>
<p>This is the code:</p>
<pre class="lang-py prettyprint-override"><code>df_result = None
for file in tqdm(files):
df = pd.read_csv(file)
df = clean_csv(df)
df = df.to_numpy()
try:
df_result = pd.concat([df_result,df],axis = 'index',ignore_index=True)
except:
df_result = df
</code></pre>
<p>with clean_csv:</p>
<pre class="lang-py prettyprint-override"><code>def clean_csv(df):
df_1 = df.drop(labels = [0,1])
df_1 = df_1.drop('Start Time', axis = 1)
return df_1
</code></pre>
| [
{
"answer_id": 74215553,
"author": "Always Sunny",
"author_id": 1138192,
"author_profile": "https://Stackoverflow.com/users/1138192",
"pm_score": 1,
"selected": false,
"text": "list"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74215506",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20344144/"
] |
74,215,546 | <p>On our aws mac host, xcodebuild fails to launch our app on the ios simulator. Here is the command:</p>
<p>xcodebuild ONLY_ACTIVE_ARCH=NO CODE_SIGN_IDENTITY="" CODE_SIGNING_REQUIRED=NO ENABLE_TESTABILITY=YES -sdk iphonesimulator -destination 'platform=iOS Simulator,name=iPhone 14,OS=16.0' -workspace XXXXX.xcworkspace -scheme Stage -configuration Debug test -verbose</p>
<p>and here is the error message:</p>
<pre><code>iOSSimulator: F9291ED3-BEA6-4772-AF51-DBE1322E857B: Failed to launch app with identifier: XXXXX and options: {
"activate_suspended" = 0;
arguments = (
);
environment = {
"CA_ASSERT_MAIN_THREAD_TRANSACTIONS" = 0;
"CA_DEBUG_TRANSACTIONS" = 0;
"DYLD_FRAMEWORK_PATH" = "/Users/ec2-user/Library/Developer/Xcode/DerivedData/XXXXX-clanoahlzfruqucjqmwowignexic/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/Library/Frameworks";
"DYLD_INSERT_LIBRARIES" = "/Users/ec2-user/Library/Developer/Xcode/DerivedData/XXXXX-clanoahlzfruqucjqmwowignexic/Build/Products/Debug-iphonesimulator/Stage.app/Frameworks/libXCTestBundleInject.dylib:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneOS.platform/Library/Developer/CoreSimulator/Profiles/Runtimes/iOS.simruntime/Contents/Resources/RuntimeRoot/usr/lib/libMainThreadChecker.dylib";
"DYLD_LIBRARY_PATH" = "/Users/ec2-user/Library/Developer/Xcode/DerivedData/XXXXX-clanoahlzfruqucjqmwowignexic/Build/Products/Debug-iphonesimulator:/Applications/Xcode.app/Contents/Developer/Platforms/iPhoneSimulator.platform/Developer/usr/lib";
"LLVM_PROFILE_FILE" = "/var/folders/sz/hvcsl7r53m3_n5l152_210c80000gn/T/com.XXXXX.pm-stage/5B3CB5FD-748E-4FAF-B84D-C47CE86F09B9-35456-0000112C6005E8EB/773D2FD5-5D40-4A63-8E37-F3C33A6FB45B-%p%c.profraw";
"MTC_CRASH_ON_REPORT" = 1;
NSApplicationQuitWithoutSuddenTermination = YES;
NSUnbufferedIO = YES;
NSZombieEnabled = YES;
"OS_ACTIVITY_DT_MODE" = YES;
"OS_ACTIVITY_MODE" = disable;
"RUN_DESTINATION_DEVICE_NAME" = "iPhone 14";
"RUN_DESTINATION_DEVICE_PLATFORM_IDENTIFIER" = "com.apple.platform.iphonesimulator";
"RUN_DESTINATION_DEVICE_UDID" = "F9291ED3-BEA6-4772-AF51-DBE1322E857B";
"SQLITE_ENABLE_THREAD_ASSERTIONS" = 1;
XCInjectBundleInto = unused;
XCTestBundlePath = "PlugIns/UnitTests.xctest";
XCTestConfigurationFilePath = "";
XCTestSessionIdentifier = "590D832A-0830-4798-A990-1555B39E090B";
"__XCODE_BUILT_PRODUCTS_DIR_PATHS" = "/Users/ec2-user/Library/Developer/Xcode/DerivedData/XXXXX-clanoahlzfruqucjqmwowignexic/Build/Products/Debug-iphonesimulator";
"__XPC_DYLD_FRAMEWORK_PATH" = "/Users/ec2-user/Library/Developer/Xcode/DerivedData/XXXXX-clanoahlzfruqucjqmwowignexic/Build/Products/Debug-iphonesimulator";
"__XPC_DYLD_LIBRARY_PATH" = "/Users/ec2-user/Library/Developer/Xcode/DerivedData/XXXXX-clanoahlzfruqucjqmwowignexic/Build/Products/Debug-iphonesimulator";
"__XPC_LLVM_PROFILE_FILE" = "/var/folders/sz/hvcsl7r53m3_n5l152_210c80000gn/T/com.XXXXX.pm-stage/5B3CB5FD-748E-4FAF-B84D-C47CE86F09B9-35456-0000112C6005E8EB/773D2FD5-5D40-4A63-8E37-F3C33A6FB45B-%p%c.profraw";
};
stderr = "/dev/ttys003";
stdout = "/dev/ttys003";
"terminate_running_process" = 1;
"wait_for_debugger" = 0;
} (error = Error Domain=NSPOSIXErrorDomain Code=3 "No such process" UserInfo={NSLocalizedDescription=Application launch for 'com.XXXXX.pm-stage' did not return a valid pid nor a launch error.})
2022-10-27 00:15:47.875 xcodebuild[35456:2529897] IDETestOperationsObserverDebug: Failure collecting logarchive: Error Domain=NSCocoaErrorDomain Code=4099 "The connection to service named com.apple.testmanagerd.control was invalidated: failed at lookup with error 3 - No such process." UserInfo={NSDebugDescription=The connection to service named com.apple.testmanagerd.control was invalidated: failed at lookup with error 3 - No such process.}
2022-10-27 00:16:04.141 xcodebuild[35456:2529810] [MT] IDETestOperationsObserverDebug: 35.913 elapsed -- Testing started completed.
2022-10-27 00:16:04.141 xcodebuild[35456:2529810] [MT] IDETestOperationsObserverDebug: 0.000 sec, +0.000 sec -- start
2022-10-27 00:16:04.141 xcodebuild[35456:2529810] [MT] IDETestOperationsObserverDebug: 35.913 sec, +35.913 sec -- end
Testing failed:
Application launch for 'com.XXXXX.pm-stage' did not return a valid pid nor a launch error.
Stage encountered an error (Failed to install or launch the test runner. If you believe this error represents a bug, please attach the result bundle at /Users/ec2-user/Library/Developer/Xcode/DerivedData/XXXXX-clanoahlzfruqucjqmwowignexic/Logs/Test/Test-Stage-2022.10.27_00-14-24-+0000.xcresult. (Underlying Error: Application launch for 'com.XXXXX.pm-stage' did not return a valid pid nor a launch error. No such process))
** TEST FAILED **
</code></pre>
<p>anything like this happened to anyone before? Any idea what could be the issue?</p>
| [
{
"answer_id": 74215553,
"author": "Always Sunny",
"author_id": 1138192,
"author_profile": "https://Stackoverflow.com/users/1138192",
"pm_score": 1,
"selected": false,
"text": "list"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74215546",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/588589/"
] |
74,215,549 | <p>Lets say I have a list called l1:
<code>l1 = [1, 2, 3, 4, 5, 6, 7, 8, 9, 10]</code>
And I want to print it as
<code>[1, 2, 3, 4, 5]</code>
<code>[6, 7, 8, 9, 10]</code>
How would I do that in python on 3.9</p>
<p>I tried to us a \n, but that has not worked for me.</p>
| [
{
"answer_id": 74215553,
"author": "Always Sunny",
"author_id": 1138192,
"author_profile": "https://Stackoverflow.com/users/1138192",
"pm_score": 1,
"selected": false,
"text": "list"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74215549",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18176304/"
] |
74,215,568 | <p>version 22 R1</p>
<p>Is there any way to make a logical OR query to the contract-based API? As far as I can tell it's not possible but, I wanted to check with the community. So, a filter like this:</p>
<pre><code>/Default/20.200.001/salesorder?$filter=OrderNbr eq 'SO006538' or OrderNbr eq 'SO006537'
</code></pre>
<p>is coming back with a HTTP 500 response "Only AND logical operator is supported".</p>
<p>I also tried this, which is coming back with a syntax error:</p>
<pre><code>/Default/20.200.001/salesorder?$filter=OrderNbr in ('SO006537','SO006538')
</code></pre>
<p>TIA!</p>
| [
{
"answer_id": 74215553,
"author": "Always Sunny",
"author_id": 1138192,
"author_profile": "https://Stackoverflow.com/users/1138192",
"pm_score": 1,
"selected": false,
"text": "list"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74215568",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6668657/"
] |
74,215,575 | <p><strong>I'm trying to open a modal with javascript, if the ajax form is executed, can someone help me?</strong>
<em>i am using bootstrap library and jquery</em>
<em>basically if the form is sent so that no error occurs then the modal should open just as the form is sent to the database</em></p>
<blockquote>
<p>index.html</p>
</blockquote>
<pre><code><html>
<head>
<link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/css/bootstrap.min.css" integrity="sha384-ggOyR0iXCbMQv3Xipma34MD+dH/1fQ784/j6cY/iJTQUOhcWr7x9JvoRxT2MZw1T" crossorigin="anonymous">
<script src="https://cdn.jsdelivr.net/npm/popper.js@1.14.7/dist/umd/popper.min.js" integrity="sha384-UO2eT0CpHqdSJQ6hJty5KVphtPhzWj9WO1clHTMGa3JDZwrnQq4sF86dIHNDz0W1" crossorigin="anonymous"></script>
<script src="https://cdn.jsdelivr.net/npm/bootstrap@4.3.1/dist/js/bootstrap.min.js" integrity="sha384-JjSmVgyd0p3pXB1rRibZUAYoIIy6OrQ6VrjIEaFf/nJGzIxFDsf4x0xIM+B07jRM" crossorigin="anonymous"></script>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="js/main.js"></script>
</head>
<body>
<form method="post">
<input type="text" id="nome" name="nome" placeholder="Digite o nome" />
<br/>
<input type="email" id="email" name="email" placeholder="Digite o email" />
<br/>
<input type="button" id="btn_gravar" value="Salvar" name="salvar" />
</form>
<div id="resposta"></div>
<script src="https://code.jquery.com/jquery-3.6.0.min.js"></script>
<script src="js/main.js"></script>
<button type="button" class="btn btn-primary" data-toggle="modal" data-target="#exampleModal">
Launch demo modal
</button>
<!-- Modal -->
<div class="modal fade" id="exampleModal" tabindex="-1" role="dialog" aria-labelledby="exampleModalLabel" aria-hidden="true">
<div class="modal-dialog" role="document">
<div class="modal-content">
<div class="modal-header">
<h5 class="modal-title" id="exampleModalLabel">Modal title</h5>
<button type="button" class="close" data-dismiss="modal" aria-label="Close">
<span aria-hidden="true">&times;</span>
</button>
</div>
<div class="modal-body">
...
</div>
<div class="modal-footer">
<button type="button" class="btn btn-secondary" data-dismiss="modal">Close</button>
<button type="button" class="btn btn-primary">Save changes</button>
</div>
</div>
</div>
</div>
</body>
</html>
</code></pre>
<p><em>here is my javascript form for the request from both backend and front</em></p>
<blockquote>
<p>main.js</p>
</blockquote>
<pre><code>$("#btn_gravar").on("click",function(){
var txt_nome = $("#nome").val();
var txt_email = $("#email").val();
console.log(txt_email + " - " + txt_nome);
$.ajax({
url: "create.php",
type: "post",
data:{
nome: txt_nome, email: txt_email
},
beforeSend : function(){
$("#resposta").html("Enviando...");
}
}).done(function(e){
$("#resposta").html("Dados registrado amigo com sucesso...");
$("#exampleModal").modal("show");//<--this line that was to open the modal
})
})
$("#btn_atualizar").on("click",function(){
var txt_nome = $("#nome").val();
var txt_email = $("#email").val();
var txt_id = $("#id").val();
console.log(txt_email + " - " + txt_nome);
$.ajax({
url: "update.php",
type: "post",
data:{
nome: txt_nome, email: txt_email, id: txt_id
},
beforeSend : function(){
$("#resposta").html("Enviando...");
}
}).done(function(e){
$("#resposta").html("Dados atualizado com sucesso...");
window.location="read.php";
})
})
</code></pre>
| [
{
"answer_id": 74216022,
"author": "Paul Mahardika",
"author_id": 14963473,
"author_profile": "https://Stackoverflow.com/users/14963473",
"pm_score": 1,
"selected": false,
"text": " <script src=\"js/main.js\"></script>\n"
},
{
"answer_id": 74220211,
"author": "Daniel J'eszens... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74215575",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19866317/"
] |
74,215,579 | <p>I have a table as below:</p>
<pre><code> after before
a 200 630
b 750 852
c 457 76738
d 3205 32235
e 12408 188561
f 1192 497130
</code></pre>
<p>I'd like to add a percent result and expected result as below:</p>
<p>(<em>percent = after/(after+before)</em>)</p>
<pre><code> after before percent
a 200 630 0.240963855
b 750 852 0.468164794
c 457 76738 0.005920073
d 3205 32235 0.090434537
e 12408 188561 0.061740866
f 1192 497130 0.002392028
</code></pre>
<pre><code>def get_percent(x):
" for each value in row, return a percentage by after/(after+before) corresponds to "
return np.array()
</code></pre>
<p>Thank you.</p>
<pre><code> after before percent
a 200 630 0.240963855
b 750 852 0.468164794
c 457 76738 0.005920073
d 3205 32235 0.090434537
e 12408 188561 0.061740866
f 1192 497130 0.002392028
</code></pre>
| [
{
"answer_id": 74216022,
"author": "Paul Mahardika",
"author_id": 14963473,
"author_profile": "https://Stackoverflow.com/users/14963473",
"pm_score": 1,
"selected": false,
"text": " <script src=\"js/main.js\"></script>\n"
},
{
"answer_id": 74220211,
"author": "Daniel J'eszens... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74215579",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20340256/"
] |
74,215,580 | <p>Let's say I have this array of objects.</p>
<pre><code> const movieTitles = [
{
movieId: "4820",
movieName: "The Planet Of The Apes",
},
{
movieId: "0489",
movieName: "Interstellar",
},
{
movieId: "6238",
movieName: "The Dark Knight",
},
];
</code></pre>
<p>And an outside variable (that matches with the object with the Interstellar movie)
<code>const matchId = "0489";</code></p>
<p>My questions are:</p>
<ol>
<li><p>How could I check the array for the correct object that contains the <code>matchId</code> variable?</p>
</li>
<li><p>How could I get that object and use it's properties (like <code>movieName</code>) once the ids have been confirmed to be the same?</p>
</li>
<li><p>If the variable dynamically changed, how could I check whatever the variable is against the array of objects to check whether it does or doesn't match?</p>
</li>
</ol>
<p>Thanks for the help in advance!</p>
| [
{
"answer_id": 74215662,
"author": "Prawesh Lamsal",
"author_id": 7844824,
"author_profile": "https://Stackoverflow.com/users/7844824",
"pm_score": 1,
"selected": false,
"text": "function hasItem(checkItem){\nlet isAvailable = movieTitles.filter((item)=> item.movieId==checkItem)\nreturn ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74215580",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16762836/"
] |
74,215,591 | <p>I am creating a login form which is limited to only 3 attempts then redirects the user. However, it quickly iterates from 3 to 0 at only 1 failed try then redirects the user. I have been trying but have been stuck at this.</p>
<p>Javascript loginUser code which runs upon submit:</p>
<pre><code> function loginUser() {
var form = document.getElementById("myForm");
var username = document.getElementById("username").value;
var password = document.getElementById("password").value;
google.script.run.withSuccessHandler(function(output) {
var atmp = 3;
while(atmp > 0) {
if(output == 'TRUE') {
console.log("Success");
form.reset();
break;
}
else if (output == 'FALSE') {
console.log("Denied");
atmp--;
form.reset();
Swal.fire({
icon: 'error',
title: 'Wrong Username/Password! Please, try again.',
showCancelButton: false,
});
}
} if (atmp == 0) {
console.log("3 Failed attempts!");
// Redirect code here...
}
}).checkLogin(username, password);
}
</code></pre>
<p>Code.gs checkLogin function:</p>
<pre><code> function checkLogin(username, password) {
var url = 'sheetLinkHere';
var ss= SpreadsheetApp.openByUrl(url);
var webAppSheet = ss.getSheetByName("users");
var find = webAppSheet.getDataRange().getDisplayValues().find(([, , c, d]) => c == username && d == password);
return find ? 'TRUE' : 'FALSE';
}
</code></pre>
<p>I tried placing the while loop at different parts of the code but still wont work for me.</p>
| [
{
"answer_id": 74215982,
"author": "Cat",
"author_id": 8223070,
"author_profile": "https://Stackoverflow.com/users/8223070",
"pm_score": -1,
"selected": false,
"text": "const\n realPassword = \"Melon\",\n input = document.querySelector('input'),\n feedback = document.querySelector('sp... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74215591",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20344208/"
] |
74,215,595 | <pre><code>solution = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
</code></pre>
<pre><code>enter number >1
enter number >1
enter number >2
enter number >3
enter number >5
enter number >8
enter number >3
Try again
</code></pre>
<h1>What I tried</h1>
<pre><code>guess = int(input("Enter the next Fibonacci number >"))
solution = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]
while guess not in solution or guess < 50:
guess = int(input("Enter the next Fibonacci number >"))
# Use if condition to compare
if guess not in solution[0:] and guess not in solution:
print("Try again")
break
</code></pre>
| [
{
"answer_id": 74215637,
"author": "jkgfinai",
"author_id": 11221320,
"author_profile": "https://Stackoverflow.com/users/11221320",
"pm_score": 2,
"selected": false,
"text": "solution = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]\n\ni = 0\nwhile i < len(solution):\n guess = int(input(\"Enter t... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74215595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20341924/"
] |
74,215,598 | <p>I think depending on my understand that callback functions are placed in the callback queue and don't execute until callstack is empty, so in the following code, why does the callback function of the event listener is executed on button clicking while <code>console.log(index)</code> is running ? Should the background color changed after the execution of all functions <code>console.log()</code> existed in the callstack first?</p>
<pre><code><button>Click me</button>
<script>
for (let index = 0; index < 100000; index++) {
console.log(index)
}
document.querySelector('button').addEventListener('click',()=>{
document.querySelector('body').style.backgroundColor = 'red'
})
</script>
</code></pre>
| [
{
"answer_id": 74215637,
"author": "jkgfinai",
"author_id": 11221320,
"author_profile": "https://Stackoverflow.com/users/11221320",
"pm_score": 2,
"selected": false,
"text": "solution = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]\n\ni = 0\nwhile i < len(solution):\n guess = int(input(\"Enter t... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74215598",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15245032/"
] |
74,215,617 | <p>When I do a git commit, I would include a note proceeded by -m. I'm always wondering what exactly does -m mean. I know there are other similar type of notations used when doing command line stuff, such as -a, -b, and etc. What exactly does the slash line mean?</p>
| [
{
"answer_id": 74215637,
"author": "jkgfinai",
"author_id": 11221320,
"author_profile": "https://Stackoverflow.com/users/11221320",
"pm_score": 2,
"selected": false,
"text": "solution = [1, 1, 2, 3, 5, 8, 13, 21, 34, 55]\n\ni = 0\nwhile i < len(solution):\n guess = int(input(\"Enter t... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74215617",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16369867/"
] |
74,215,622 | <p>Good morning! I have to do this for an exercise:</p>
<p>Since the Square and Cube geometric figures are drawn from points,
write a program that defines the Point, Square, and Cube classes.
Proceed using inheritance;</p>
<p>So I think I did well? Anyway, I hope...
However, there is a part that does not seem to work, the volume</p>
<pre class="lang-cpp prettyprint-override"><code>#include <iostream>
#include <conio.h>
#include <ctype.h>
#include <stdio.h>
using namespace std;
//########### Définition de la classe Point ###########
class Point {
public:
Point(int x, int y) {
this->x = x;
this->y = y;
}
int getX() {
return x;
}
int getY() {
return y;
}
private:
int x, y;
};
//########### Définition de la classe Carré ###########
class Square : public Point {
public:
Square(int x, int y, int side) : Point(x, y) {
this->side = side;
}
int getArea() {
return side * side;
}
private:
int side;
};
//########### Définition de la classe Cube ###########
class Cube : public Square {
public:
Cube(int x, int y, int side) : Square(x, y, side) {
}
int getVolume() {
return side * side * side;
}
private:
int side;
};
int main() {
Cube cube(1, 1, 2);
cout << cube.getX() << endl; // 1
cout << cube.getY() << endl; // 1
cout << cube.getArea() << endl; // 4
cout << cube.getVolume() << endl; // 8
return 0;
}
</code></pre>
<p>But I don't know why it returns 0 in the volume :'c
It should be simple though! It's just an int of the side * side * side;</p>
<p>But when i run it it shows me
1
1
4
0</p>
<p>Why does this happend to the cube.getVolume()?</p>
| [
{
"answer_id": 74215675,
"author": "paddy",
"author_id": 1553090,
"author_profile": "https://Stackoverflow.com/users/1553090",
"pm_score": 2,
"selected": false,
"text": "Cube"
},
{
"answer_id": 74215759,
"author": "Rifat",
"author_id": 7291498,
"author_profile": "http... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74215622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20140450/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.