qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,118,088 | <p>I have a massive dataset and am trying to plot a sort of <code>boxplot</code> with the Q1, Q2, Q3 stats by category. I would like a boxplot visualization with the standard interquartile range box and thicker line outlining the median, but not the whiskers and outliers. I would also like to add the average by category to it.</p>
<p>Because my data is massive it would be easier to compute all of this and then plot the stats as <code>identity</code>. I found the code below which computes the stats to then plot them. However, it doesn't work when I delete <code>ymin</code> and <code>ymax</code> from the code. I would like a similar code that: (i) does not have the max and min, (ii) adds the average as a dot, (iii) computes and plots stats by category.</p>
<pre><code>y <- rnorm(100)
df <- data.frame(
x = 1,
y0 = min(y),
y25 = quantile(y, 0.25),
y50 = median(y),
y75 = quantile(y, 0.75),
y100 = max(y)
)
ggplot(df, aes(x)) +
geom_boxplot(
aes(ymin = y0, lower = y25, middle = y50, upper = y75, ymax = y100),
stat = "identity"
)
</code></pre>
| [
{
"answer_id": 74118264,
"author": "Ric Villalba",
"author_id": 6912817,
"author_profile": "https://Stackoverflow.com/users/6912817",
"pm_score": 2,
"selected": true,
"text": "x"
},
{
"answer_id": 74118706,
"author": "lijiaqi",
"author_id": 19341791,
"author_profile":... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118088",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11968604/"
] |
74,118,117 | <p>I need to pass a function from one stateful widget to another.</p>
<p><strong>Parent widget::</strong></p>
<p>the function that I am passing is the following</p>
<pre><code> void _setJobAddress(jobAddress) {
setState(() {
_jobAddress = jobAddress;
});
}
</code></pre>
<p>here is the button that opens the new view, this is how I am passing the function</p>
<pre><code>TextButton(
onPressed: () => {
Navigator.push(
context,
MaterialPageRoute(
builder: (context) =>
SearchLocationScreen(_setJobAddress)))
}
</code></pre>
<p>this is a little bit of the child view where I need to call the function::</p>
<pre><code>class SearchLocationScreen extends StatefulWidget {
const SearchLocationScreen({Key? key}) : super(key: key);
@override
State<SearchLocationScreen> createState() => _SearchLocationScreenState();
}
class _SearchLocationScreenState extends State<SearchLocationScreen> {
Function setJobAddess; // i tried adding this, but its not working
_SearchLocationScreenState(this.setJobAddess); // i tried adding this, but its not working
List<AutocompletePrediction> placePredictions = [];
</code></pre>
<p>How can I make this work so that when I click a button on the child widget, the parent function passed is called?</p>
<p>I tried the following:</p>
<pre><code>class SearchLocationScreen extends StatefulWidget {
const SearchLocationScreen(
this.setJobAddess, {
Key? key,
}) : super(key: key);
final setJobAddess;
@override
State<SearchLocationScreen> createState() => _SearchLocationScreenState();
}
class _SearchLocationScreenState extends State<SearchLocationScreen> {
//Function setJobAddess;
//_SearchLocationScreenState(this.setJobAddess);
List<AutocompletePrediction> placePredictions = [];
@override
void initState() {
widget.setJobAddess();
}
... a bunch of code that is not of importance goes here
Padding(
padding: const EdgeInsets.all(defaultPadding),
child: ElevatedButton.icon(
onPressed: () async {
print('setting job location');
widget.setJobAddess('TEXT');
Navigator.pop(context);
},
icon: Icon(Icons.home),
label: const Text("Set job location"),
style: ElevatedButton.styleFrom(
backgroundColor: secondaryColor10LightTheme,
foregroundColor: textColorLightTheme,
elevation: 0,
fixedSize: const Size(double.infinity, 40),
shape: const RoundedRectangleBorder(
borderRadius: BorderRadius.all(Radius.circular(10)),
),
),
),
),
</code></pre>
<p>I got the following error::</p>
<pre><code>
════════ Exception caught by widgets library ═══════════════════════════════════
The following NoSuchMethodError was thrown building Builder:
Closure call with mismatched arguments: function '_CreateUpdateJobViewState._setJobAddress'
Receiver: Closure: (dynamic) => void from Function '_setJobAddress@43263735':.
Tried calling: _CreateUpdateJobViewState._setJobAddress()
Found: _CreateUpdateJobViewState._setJobAddress(dynamic) => void
The relevant error-causing widget was
MaterialApp
lib/main.dart:20
When the exception was thrown, this was the stack
#0 Object.noSuchMethod (dart:core-patch/object_patch.dart:38:5)
#1 _objectNoSuchMethod (dart:core-patch/object_patch.dart:85:9)
#2 _SearchLocationScreenState.initState
package:ijob_clone_app/…/location/location_search_screen.dart:26
#3 StatefulElement._firstBuild
package:flutter/…/widgets/framework.dart:5015
#4 ComponentElement.mount
package:flutter/…/widgets/framework.dart:4853
... Normal element mounting (275 frames)
#279 Element.inflateWidget
package:flutter/…/widgets/framework.dart:3863
#280 MultiChildRenderObjectElement.inflateWidget
package:flutter/…/widgets/framework.dart:6435
#281 Element.updateChild
package:flutter/…/widgets/framework.dart:3592
#282 RenderObjectElement.updateChildren
package:flutter/…/widgets/framework.dart:5964
#283 MultiChildRenderObjectElement.update
package:flutter/…/widgets/framework.dart:6460
#284 Element.updateChild
package:flutter/…/widgets/framework.dart:3570
#285 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4904
#286 StatefulElement.performRebuild
package:flutter/…/widgets/framework.dart:5050
#287 Element.rebuild
package:flutter/…/widgets/framework.dart:4604
#288 StatefulElement.update
package:flutter/…/widgets/framework.dart:5082
#289 Element.updateChild
package:flutter/…/widgets/framework.dart:3570
#290 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4904
#291 Element.rebuild
package:flutter/…/widgets/framework.dart:4604
#292 ProxyElement.update
package:flutter/…/widgets/framework.dart:5228
#293 Element.updateChild
package:flutter/…/widgets/framework.dart:3570
#294 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4904
#295 Element.rebuild
package:flutter/…/widgets/framework.dart:4604
#296 ProxyElement.update
package:flutter/…/widgets/framework.dart:5228
#297 _InheritedNotifierElement.update
package:flutter/…/widgets/inherited_notifier.dart:107
#298 Element.updateChild
package:flutter/…/widgets/framework.dart:3570
#299 SingleChildRenderObjectElement.update
package:flutter/…/widgets/framework.dart:6307
#300 Element.updateChild
package:flutter/…/widgets/framework.dart:3570
#301 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4904
#302 StatefulElement.performRebuild
package:flutter/…/widgets/framework.dart:5050
#303 Element.rebuild
package:flutter/…/widgets/framework.dart:4604
#304 StatefulElement.update
package:flutter/…/widgets/framework.dart:5082
#305 Element.updateChild
package:flutter/…/widgets/framework.dart:3570
#306 SingleChildRenderObjectElement.update
package:flutter/…/widgets/framework.dart:6307
#307 Element.updateChild
package:flutter/…/widgets/framework.dart:3570
#308 SingleChildRenderObjectElement.update
package:flutter/…/widgets/framework.dart:6307
#309 Element.updateChild
package:flutter/…/widgets/framework.dart:3570
#310 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4904
#311 Element.rebuild
package:flutter/…/widgets/framework.dart:4604
#312 ProxyElement.update
package:flutter/…/widgets/framework.dart:5228
#313 Element.updateChild
package:flutter/…/widgets/framework.dart:3570
#314 ComponentElement.performRebuild
package:flutter/…/widgets/framework.dart:4904
#315 StatefulElement.performRebuild
package:flutter/…/widgets/framework.dart:5050
#316 Element.rebuild
package:flutter/…/widgets/framework.dart:4604
#317 BuildOwner.buildScope
package:flutter/…/widgets/framework.dart:2667
#318 WidgetsBinding.drawFrame
package:flutter/…/widgets/binding.dart:882
#319 RendererBinding._handlePersistentFrameCallback
package:flutter/…/rendering/binding.dart:378
#320 SchedulerBinding._invokeFrameCallback
package:flutter/…/scheduler/binding.dart:1175
#321 SchedulerBinding.handleDrawFrame
package:flutter/…/scheduler/binding.dart:1104
#322 SchedulerBinding._handleDrawFrame
package:flutter/…/scheduler/binding.dart:1015
#323 _invoke (dart:ui/hooks.dart:148:13)
#324 PlatformDispatcher._drawFrame (dart:ui/platform_dispatcher.dart:318:5)
#325 _drawFrame (dart:ui/hooks.dart:115:31)
════════════════════════════════════════════════════════════════════════════════
D/EGL_emulation(15747): app_time_stats: avg=25.04ms min=14.73ms max=497.29ms count=59
D/TrafficStats(15747): tagSocket(145) with statsTag=0xffffffff, statsUid=-1
D/TrafficStats(15747): tagSocket(121) with statsTag=0xffffffff, statsUid=-1
</code></pre>
| [
{
"answer_id": 74118228,
"author": "Gwhyyy",
"author_id": 18670641,
"author_profile": "https://Stackoverflow.com/users/18670641",
"pm_score": 1,
"selected": false,
"text": "class SearchLocationScreen extends StatefulWidget {\n const SearchLocationScreen(this.setJobAddess,{Key? key, }) :... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118117",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17281101/"
] |
74,118,119 | <p>I have the below dataframe:</p>
<pre><code> Customer Code 05-01-2021 06-01-2021 07-01-2021 08-01-2021 09-01-2021 10-01-2021 11-01-2021 ... 02-01-2022 03-01-2022 04-01-2022 05-01-2022 06-01-2022 07-01-2022 08-01-2022 09-01-2022
0 C04209 NaN NaN 132.25 579.0 1228.49 NaN 1978.08 ... 2060.65 1178.16 1563.33 2047.14 1053.51 4111.52 486.42 2337.64
1 C04210 NaN NaN 430.0 NaN NaN NaN NaN ... 4679.19 8637.2 591.1 5161.1 720.7 9461.29 6498.0 7595.0
</code></pre>
<p>which is correct but when I try to write to excel with <code>to_excel</code> command this is what i get:</p>
<pre><code>df.to_excel(writer, sheet_name=e, index=False)
writer.save()
</code></pre>
<p>the Excel file:</p>
<p><a href="https://i.stack.imgur.com/SZgQd.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/SZgQd.png" alt="enter image description here" /></a></p>
<p>As you can see everything gets shifted by 1 column to the left, does anyone know why and how to fix. Thanks in advance.</p>
| [
{
"answer_id": 74118228,
"author": "Gwhyyy",
"author_id": 18670641,
"author_profile": "https://Stackoverflow.com/users/18670641",
"pm_score": 1,
"selected": false,
"text": "class SearchLocationScreen extends StatefulWidget {\n const SearchLocationScreen(this.setJobAddess,{Key? key, }) :... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118119",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3242388/"
] |
74,118,137 | <ol>
<li>This code allows me to create a linked list and I want to be able to add elements
between two nodes.</li>
<li>I'm having trouble understanding how to set it up so I can insert a number between 40 and 30.</li>
</ol>
<hr />
<pre class="lang-java prettyprint-override"><code>public class DoublyLinkedList<E> {
private static class Node<E> {
//Node Fields
private E element;
private Node<E> prev;
private Node<E> next;
// Node Constructor
public Node(E e, Node<E> p, Node<E> n) {
this.element = e;
this.prev = p;
this.next = n;
}
// Node Methods
public E getElement() {
return element;
}
public Node<E> getPrev() {
return this.prev;
}
public Node<E> getNext() {
return this.next;
}
public void setPrev(Node<E> p) {
this.prev = p;
}
public void setNext(Node<E> n) {
this.next = n;
}
}
// DLinkedList Fields
private Node<E> header;
private Node<E> trailer;
int size;
// DLinkedList Constructor
public DoublyLinkedList() {
this.header = new Node<>(null, null, null);
this.trailer = new Node<>(null, this.header, null);
this.header.setNext(this.trailer);
}
// DLinkedList Methods
public int size() {
return this.size;
}
public E first() {
if (isEmpty()) {
return null;
}
return this.header.next.getElement();
}
public E last() {
if (isEmpty()) {
return null;
}
return this.trailer.prev.getElement();
}
public boolean isEmpty() {
return size == 0;
}
public void addFirst(E e) {
addBetween(e, this.header, this.header.getNext());
}
public void addLast(E e) {
addBetween(e, this.trailer.getPrev(), this.trailer);
}
public void addBetween(E e, Node<E> predecessor, Node<E> successor) {
Node<E> newest = new Node<>(e, predecessor, successor);
predecessor.setNext(newest);
successor.setPrev(newest);
this.size++;
}
public E removeFirst() {
if (this.isEmpty()) {
return null;
}
return this.remove(header.getNext());
}
public E removeLast() {
if (this.isEmpty()) {
return null;
}
return this.remove(trailer.getPrev());
}
public E remove(Node<E> e) {
e.next.setPrev(e.prev);
e.prev.setNext(e.next);
this.size--;
return e.getElement();
}
public String toString() {
StringBuilder sb = new StringBuilder("(");
Node<E> walk = this.header.next;
while (walk != this.trailer) {
sb.append(walk.element);
if (walk.next != this.trailer)
sb.append("--> ");
walk = walk.next;
}
sb.append(")");
return sb.toString();
}
// Node myList = new Node<E>(null, trailer, header);
// myList.e.addFirst
// Node myList2 = new Node<E>(null, 1, null);
}
class Main {
public static void main(String[] args) {
// create a DoublyLinkedList object
DoublyLinkedList Node = new DoublyLinkedList();
// Add nodes to the list
Node.addFirst(10);
Node.addFirst(20);
Node.addFirst(30);
Node.addFirst(40);
Node.addFirst(50);
Node.removeFirst();
Node.removeLast();
//Node.addBetween(Node, null, null);
// print the nodes of DoublyLinkedList
System.out.println(Node);
}
}
</code></pre>
| [
{
"answer_id": 74118228,
"author": "Gwhyyy",
"author_id": 18670641,
"author_profile": "https://Stackoverflow.com/users/18670641",
"pm_score": 1,
"selected": false,
"text": "class SearchLocationScreen extends StatefulWidget {\n const SearchLocationScreen(this.setJobAddess,{Key? key, }) :... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118137",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20277163/"
] |
74,118,142 | <p>very new to JavaScript and API building. I'm writing a simple address verification system and I'm running into an issue where the response sends the buffer data in addition to the response of the columns that I want to query. I know that I should be returning rows and fields, but do not know how to fit it into the code.</p>
<p>This is what I currently have for the main query:</p>
<pre><code>app.get("/addresses/api/find/", async (req, res) => {
try {
const address1 = req.query.Address1;
const address2 = req.query.Address2;
const city = req.query.City;
const state = req.query.State;
const zip = req.query.ZipCode;
console.log(req.body);
const findAddress = await pool.query ("SELECT * FROM addresses WHERE Address1 = ?",
[
address1,
]
);
res.json({
status: "Success: 200",
message: "There was a match to your address.",
findAddress
});
} catch (err) {
console.error(err.message)
}
})
</code></pre>
<p>And this is a part of what is returned when there is no exact match:</p>
<pre><code>{
"status": "Success: 200",
"message": "There was a match to your address.",
"findAddress": [
[],
[
{
"_buf": {
"type": "Buffer",
"data": [
1,
0,
0,
1,
6,
47,
0,
0,
2,
3,
100,
</code></pre>
<p>I'm still working on the logic to reject an empty set, but I have not gotten that far, yet.</p>
<p>Thank you.</p>
| [
{
"answer_id": 74118228,
"author": "Gwhyyy",
"author_id": 18670641,
"author_profile": "https://Stackoverflow.com/users/18670641",
"pm_score": 1,
"selected": false,
"text": "class SearchLocationScreen extends StatefulWidget {\n const SearchLocationScreen(this.setJobAddess,{Key? key, }) :... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118142",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20277117/"
] |
74,118,148 | <p>EDIT: I have corrected the code I had shared previously as there were some errors. I have tried the below suggestions <code>Set xmldoc = CreateObject("MSXML2.DOMDocument.3.0")</code> and <code>Set xmldoc = CreateObject("MSXML2.DOMDocument.6.0")</code>) with no success.</p>
<hr />
<p>To give some context, the SVG is generated, through an Excel file I prepare, from a third party software I feed the Excel file with, so the word <em>Item</em> is the keyword I use to mark those paths for which I want the text to appear, this removal is to clean up the resulting SVG.</p>
<hr />
<p>I would like to remove the string <em>Item</em> inside tspan, so from <code><tspan id="Item1-tspan" x="" y="">Item1</tspan></code> to <code><tspan id="Item1-tspan" x="" y="">1</tspan></code>.</p>
<p>I have tried all possible solutions, yet I am not able to replace text with XSLT through VBA. I would like to remove the word "Item" and I went through every single answer I found on StackOverflow and in othtr websites. I either do not get the wanted result or I get errors.</p>
<p>I call it with this simple macro:</p>
<p><strong>VBA</strong></p>
<pre><code>Sub AddTextToSVGReplace()
Dim StrFileName As String
Dim StrFolder As String
Dim StrFolderTarget As String
Dim xmldoc As Object
Dim xsldoc As Object
Dim newdoc As Object
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Select the folder where the vector file is stored"
If .Show = -1 Then
StrFolder = .SelectedItems(1) & "\"
End If
End With
With Application.FileDialog(msoFileDialogFolderPicker)
.Title = "Select the folder where the edited vector file should be stored"
If .Show = -1 Then
StrFolderTarget = .SelectedItems(1) & "\"
End If
End With
Set xmldoc = CreateObject("MSXML2.DOMDocument")
Set xsldoc = CreateObject("MSXML2.DOMDocument")
Set newdoc = CreateObject("MSXML2.DOMDocument")
StrFileName = Dir(StrFolder & "*.svg")
'Load XML
xmldoc.async = False
xmldoc.Load StrFileName
'Load XSL
xsldoc.async = False
xsldoc.Load StrFolder & "\" & "TextAdditionReplace.xsl"
'Transform
xmldoc.transformNodeToObject xsldoc, newdoc
newdoc.Save StrFolderTarget & "WithNames" & StrFileName
End Sub
</code></pre>
<p>This is the SVG file I would like to transform</p>
<p><strong>SVG (extract, only relevant part)</strong></p>
<pre><code><g id="symbols-svg">
<g id="Item1-svg" transform="translate(105, 210)">
<path d="M-5 0a5 5 0 1 0 10 0 5 5 0 1 0-10 0Z" stroke="rgb(200, 200, 200)" id="Item1" style="fill: rgb(0, 15, 60); stroke-width: 1; fill-opacity: 0.9; stroke-opacity: 0.5; stroke-linejoin: miter; stroke-linecap: butt; stroke: rgb(0, 50, 100);">
</path>
<text x="" y="" id="Item1-text" style="-inkscape-font-specification:'Calibri, Normal';font-family:Calibri;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:20px;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000">
<tspan id="Item1-tspan" x="" y="">Item1</tspan>
</text>
</g>
<g id="Item2-svg" transform="translate(250, 90)">
<path d="M-5 0a5 5 0 1 0 10 0 5 5 0 1 0-10 0Z" stroke="rgb(200, 200, 200)" id="Item2" style="fill: rgb(0, 15, 60); stroke-width: 1; fill-opacity: 0.9; stroke-opacity: 0.5; stroke-linejoin: miter; stroke-linecap: butt; stroke: rgb(0, 50, 100);">
</path>
<text x="" y="" id="Item2-text" style="-inkscape-font-specification:'Calibri, Normal';font-family:Calibri;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:20px;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000">
<tspan id="Item2-tspan" x="" y="">Item2</tspan>
</text>
</g>
</g>
</code></pre>
<p>This is the XSLT I am using</p>
<p><strong>XSLT</strong></p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<xsl:stylesheet xmlns:xsl="http://www.w3.org/1999/XSL/Transform"
xmlns:svg="http://www.w3.org/2000/svg"
xmlns="http://www.w3.org/2000/svg"
exclude-result-prefixes="svg"
version="1.0">
<xsl:output method="xml" encoding="utf-8" omit-xml-declaration="yes" indent="yes"/>
<xsl:strip-space elements="*"/>
<xsl:template match="svg:g[@id[starts-with(., 'Item')]]">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
<xsl:variable name="id" select="substring-before(@id, '-')"/>
<text x="" y="" id="{$id}-text" style="-inkscape-font-specification:'Calibri, Normal';font-family:Calibri;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:20px;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000">
<tspan id="{$id}-tspan" x="" y="">
<xsl:value-of select="$id"/>
</tspan>
</text>
</xsl:copy>
</xsl:template>
<xsl:template name="string-replace-all">
<xsl:param name="text" />
<xsl:param name="replace" />
<xsl:param name="by" />
<xsl:choose>
<xsl:when test="contains($text, $replace)">
<xsl:value-of select="substring-before($text,$replace)" />
<xsl:value-of select="$by" />
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text"
select="substring-after($text,$replace)" />
<xsl:with-param name="replace" select="$replace" />
<xsl:with-param name="by" select="$by" />
</xsl:call-template>
</xsl:when>
<xsl:otherwise>
<xsl:value-of select="$text" />
</xsl:otherwise>
</xsl:choose>
</xsl:template>
<!-- template call -->
<xsl:variable name="result">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="$text" />
<xsl:with-param name="replace" select="'Item'" />
<xsl:with-param name="by" select="''" />
</xsl:call-template>
</xsl:variable>
<xsl:template match="processing-instruction('xml-stylesheet')"/>
<xsl:template match="@* | node()">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
</xsl:copy>
</xsl:template>
</xsl:stylesheet>
</code></pre>
<p>Finally, this is the result I would like to have:</p>
<p><strong>Wanted SVG</strong></p>
<pre><code><g id="symbols-svg">
<g id="Item1-svg" transform="translate(105, 210)">
<path d="M-5 0a5 5 0 1 0 10 0 5 5 0 1 0-10 0Z" stroke="rgb(200, 200, 200)" id="Item1" style="fill: rgb(0, 15, 60); stroke-width: 1; fill-opacity: 0.9; stroke-opacity: 0.5; stroke-linejoin: miter; stroke-linecap: butt; stroke: rgb(0, 50, 100);">
</path>
<text x="" y="" id="Item1-text" style="-inkscape-font-specification:'Calibri, Normal';font-family:Calibri;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:20px;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000">
<tspan id="Item1-tspan" x="" y="">1</tspan>
</text>
</g>
<g id="Item2-svg" transform="translate(250, 90)">
<path d="M-5 0a5 5 0 1 0 10 0 5 5 0 1 0-10 0Z" stroke="rgb(200, 200, 200)" id="Item2" style="fill: rgb(0, 15, 60); stroke-width: 1; fill-opacity: 0.9; stroke-opacity: 0.5; stroke-linejoin: miter; stroke-linecap: butt; stroke: rgb(0, 50, 100);">
</path>
<text x="" y="" id="Item2-text" style="-inkscape-font-specification:'Calibri, Normal';font-family:Calibri;font-weight:normal;font-style:normal;font-stretch:normal;font-variant:normal;font-size:20px;font-variant-ligatures:normal;font-variant-caps:normal;font-variant-numeric:normal;font-variant-east-asian:normal;fill:#000000">
<tspan id="Item2-tspan" x="" y="">2</tspan>
</text>
</g>
</g>
</code></pre>
<p>With <code><xsl:with-param name="text" select="$text" /></code>(both <code>CreateObject("MSXML2.DOMDocument.3.0")</code> and <code>"MSXML2.DOMDocument.6.0")</code> I get error <code>'-2147467259 (80004005)' A reference to variable or parameter 'text' cannot be resolved. The variable or parameter may not be defined, or it may not be in scope. </code></p>
<p>With <code><xsl:with-param name="text" select="'Item'" /></code> nothing happens in both cases. Nor does it with <code><xsl:with-param name="text" select="'{Item}'" /></code>.</p>
<p>I also tried nesting as per below (it may look like blasphemy to experts)</p>
<pre><code> <xsl:template match="svg:tspan[@id[starts-with(., 'Item')]]">
<xsl:variable name="result">
<xsl:call-template name="string-replace-all">
<xsl:with-param name="text" select="'Item'" />
<xsl:with-param name="replace" select="'Item'" />
<xsl:with-param name="by" select="''" />
</xsl:call-template>
</xsl:variable>
</xsl:template>
</code></pre>
<p>I cannot think of any more combinations (apart of course from the correct one...).</p>
| [
{
"answer_id": 74120158,
"author": "Conal Tuohy",
"author_id": 7372462,
"author_profile": "https://Stackoverflow.com/users/7372462",
"pm_score": 2,
"selected": false,
"text": "Item"
},
{
"answer_id": 74147658,
"author": "Conal Tuohy",
"author_id": 7372462,
"author_pro... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118148",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18247317/"
] |
74,118,160 | <p>I would like to remove the numbers from the list of three in three positions and then store them in a new list. I thought of doing something like n+3 but don´t know how to implement it.</p>
<pre><code>[1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 1, 6, 1, 4, 7, 2, 4, 8, 4, 6, 9, 6, 5]
</code></pre>
<p>This is my list and I would like to create a new list like this:</p>
<pre><code>[1,2,3,4,5,6,7,8,9]
</code></pre>
<p>Thank you in advance</p>
| [
{
"answer_id": 74118201,
"author": "Flow",
"author_id": 14121161,
"author_profile": "https://Stackoverflow.com/users/14121161",
"pm_score": 0,
"selected": false,
"text": "my_list=[1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 1, 6, 1, 4, 7, 2, 4, 8, 4, 6, 9, 6, 5]\n\nnew_list=list(set(my_lis... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118160",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20277243/"
] |
74,118,216 | <p>In my query there is a value that will not match in the demand category table. Therefore, since one value does not match in the output of my query, other matching values do not appear.</p>
<p><strong>I want to do;</strong>
How can I list other matching values even if there is an unmatched value in the query?</p>
<p><strong>process Table</strong></p>
<pre><code>fk_unit_id fk_unit_position fk_demand_category
1 2 1
</code></pre>
<p><strong>unit table</strong></p>
<pre><code>unit_id
1
</code></pre>
<p><strong>unit_position table</strong></p>
<pre><code>unit_position
2
</code></pre>
<p><strong>demand_category table</strong></p>
<pre><code>demand_category
1
</code></pre>
<p><strong>Query:</strong></p>
<pre><code>SELECT unit_name,unit_position_name,demand_category_name From process
INNER JOIN unit ON process.fk_unit_id = unit_id and unit_id =1
INNER JOIN unit_position ON process.fk_unit_position_id = unit_position_id and unit_position_id = 2
INNER JOIN demand_category ON process.fk_demand_category_id = demand_category_id and demand_category_id =0 ;
</code></pre>
| [
{
"answer_id": 74118201,
"author": "Flow",
"author_id": 14121161,
"author_profile": "https://Stackoverflow.com/users/14121161",
"pm_score": 0,
"selected": false,
"text": "my_list=[1, 1, 2, 2, 2, 3, 3, 3, 4, 4, 4, 5, 5, 5, 1, 6, 1, 4, 7, 2, 4, 8, 4, 6, 9, 6, 5]\n\nnew_list=list(set(my_lis... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20233686/"
] |
74,118,232 | <pre class="lang-py prettyprint-override"><code>current_df = pd.DataFrame(
[
['honda crv', 9000, 9100, 9200],
['mazda cx5', 9300, 10000, 10100],
['mazda cx5', 29300, 310000, 510100],
],
columns=['car', 'john', 'peter', 'kate']
)
</code></pre>
<p>How do I transform this into dataframe with multiple index ['car', 'salesman']?</p>
<p>From this</p>
<p><img src="https://i.stack.imgur.com/6N80l.png" alt="Current dataframe" /></p>
<p>To this</p>
<p><img src="https://i.stack.imgur.com/rBh8g.png" alt="Desired dataframe" /></p>
| [
{
"answer_id": 74118257,
"author": "simon",
"author_id": 11243998,
"author_profile": "https://Stackoverflow.com/users/11243998",
"pm_score": 2,
"selected": true,
"text": "pd.DataFrame( current_df.set_index('car').stack() )\n"
},
{
"answer_id": 74118358,
"author": "Jason Baker... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15427694/"
] |
74,118,250 | <p>Currently I am trying to solve this task: Two arrays of five integers each are given. Find the lowest number in the first array that is not in the second array.</p>
<p>It seems to me that if the user enters such integers in the first array:</p>
<pre class="lang-none prettyprint-override"><code>0 1 2 3 4
</code></pre>
<p>And the integers of the second array:</p>
<pre class="lang-none prettyprint-override"><code>0 2 3 4 5
</code></pre>
<p>The lowest integer, according to the condition of the task, will be 1, because it is not in the second array.
So here is my code:</p>
<pre><code>#include <stdio.h>
#include <locale.h>
int main() {
setlocale(LC_ALL, "Rus");
int arr1[5]; //initialize arrays
int arr2[5];
printf("Enter integers\n");
for (int i = 0; i < 5; i++) {
int element;
scanf_s("%d", &element);
arr1[i] = element;
}
printf("Enter integers\n");
for (int i = 0; i < 5; i++) {
int element;
scanf_s("%d", &element);
arr2[i] = element;
}
int min1 = arr1[0];
int min2 = arr2[0];
for (int i = 0; i < 5; i++) { // algorithm for finding the minimum number of an array 1
if (min1 > arr1[i]) {
min1 = arr1[i];
}
if (min2 > arr2[i]) {
min2 = arr2[i];
}
}
}
</code></pre>
<p>Well, the code is very clear, but here's how to make this check, if the first array input <code>0 1 2 3 4</code> and the second <code>0 2 3 4 5</code> then how to remove this zero.</p>
| [
{
"answer_id": 74118620,
"author": "Craig Estey",
"author_id": 5382650,
"author_profile": "https://Stackoverflow.com/users/5382650",
"pm_score": 0,
"selected": false,
"text": "arr2"
},
{
"answer_id": 74118924,
"author": "Fe2O3",
"author_id": 17592432,
"author_profile"... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118250",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20276903/"
] |
74,118,266 | <p>I installed and configured the inertia on my laravel app and wanted to create also an admin along with the already established single page functionality on my app and wanted to group it under <code>/admin</code></p>
<pre><code> Route::prefix('/admin')->group(function(){
Route::get('/login',[AdminController::class, 'login'])->name('admin.login');
});
</code></pre>
<p>the above route is expected to be accessible at <code>"<domain>/admin/login"</code> but not working at all. Any help, suggestions, ideas is greatly appreciated.</p>
| [
{
"answer_id": 74118620,
"author": "Craig Estey",
"author_id": 5382650,
"author_profile": "https://Stackoverflow.com/users/5382650",
"pm_score": 0,
"selected": false,
"text": "arr2"
},
{
"answer_id": 74118924,
"author": "Fe2O3",
"author_id": 17592432,
"author_profile"... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118266",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1292042/"
] |
74,118,313 | <p>I have an enemy which does an attack. If the player hasn't pressed a button to defend himself at that moment, he will receive damage for this attack. So far I'm checking in Update if any attack animation is playing and start a Coroutine.</p>
<pre class="lang-cs prettyprint-override"><code>{
if ( enemy.CheckIfAnimationIsPlaying ( "Enemy_mainAttack" ) ||
enemy.CheckIfAnimationIsPlaying ( "Enemy_mainAttack2" ) ||
enemy.CheckIfAnimationIsPlaying ( "Enemy_firstAttack" ) )
{
StartCoroutine ( DefendTiming ( ) );
}
}
private IEnumerator DefendTiming ( )
{
float animationLength = enemy.animator.GetCurrentAnimatorStateInfo(0).length;
yield return new WaitForSeconds ( animationLength );
if ( !defendButtonPressed && !receivedDamage )
{
ReceiveDamage ( enemy.attack );
receivedDamage = true;
}
else
{
this.ReduceEndurance ( false, 3 );
defendButtonPressed = true;
}
}
</code></pre>
<p>But this approach doesn't work properly and looks not suitable. Thanks for help :)</p>
| [
{
"answer_id": 74118620,
"author": "Craig Estey",
"author_id": 5382650,
"author_profile": "https://Stackoverflow.com/users/5382650",
"pm_score": 0,
"selected": false,
"text": "arr2"
},
{
"answer_id": 74118924,
"author": "Fe2O3",
"author_id": 17592432,
"author_profile"... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118313",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14902477/"
] |
74,118,344 | <p>I am using some older code to write a raster stack with bylayer = T and I havent bothered to migrate it to terra yet so I am still using raster. This used to work fine:</p>
<p><code>raster::writeRaster(stack(rastList3), names(rastList3), bylayer = T, overwrite = TRUE, format = "GTiff")</code></p>
<p>Now it throws the hard to decipher error:
<em>"Error in if (tolower(e) %in% c(".tiff", ".tif")) { :
the condition has length > 1"</em></p>
<p>Replies to similar error message <a href="https://stackoverflow.com/questions/72848442/r-warning-lengthx-2-1-in-coercion-to-logical1">here</a> suggest it seems to have to do with R 4.2 but I am not fully sure that is what is happening. I can get it to write one layer at a time using</p>
<p><code>dsn <- here("Clipped_ENVData/Mask2022//")</code></p>
<p><code>nameT = paste(dsn, names(rastList3), ".tiff", sep = "")</code></p>
<p><code>writeRaster(rastList3[[3]], nameT[[3]], overwrite = TRUE)</code></p>
<p>but it wont write bylayer from the stack of 10 rasters :(</p>
<p>Does anyone know if there is a workaround in the writeRaster function that needs to be fixed or is it something broken in my code?</p>
| [
{
"answer_id": 74118620,
"author": "Craig Estey",
"author_id": 5382650,
"author_profile": "https://Stackoverflow.com/users/5382650",
"pm_score": 0,
"selected": false,
"text": "arr2"
},
{
"answer_id": 74118924,
"author": "Fe2O3",
"author_id": 17592432,
"author_profile"... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118344",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7159344/"
] |
74,118,366 | <p>I would like to generate a column with the average of differences between a subset of columns. Suppose I have the following dataset:</p>
<pre><code>set.seed(123)
df <- data.frame( y = runif(1:10),
x1 = runif(1:10),
x2 = runif(1:10),
x3 = runif(1:10))
df[, "x1"][ df[, "x1"] < 0.5 ] <- NA
df[, "x3"][ df[, "x3"] > 0.7 ] <- NA
df
y x1 x2 x3
1 0.2875775 0.9568333 0.8895393 NA
2 0.7883051 NA 0.6928034 NA
3 0.4089769 0.6775706 0.6405068 0.69070528
4 0.8830174 0.5726334 0.9942698 NA
5 0.9404673 NA 0.6557058 0.02461368
6 0.0455565 0.8998250 0.7085305 0.47779597
7 0.5281055 NA 0.5440660 NA
8 0.8924190 NA 0.5941420 0.21640794
9 0.5514350 NA 0.2891597 0.31818101
10 0.4566147 0.9545036 0.1471136 0.23162579
</code></pre>
<p>I would like to get a column with the average for the difference between Xs and Y. So, in the example, I would like to get ((x1 - y)+(x2 - y)+(x3 - y))/(Number of X's). This gets a little complicated because of the missing values, not all rows will be calculated the same.
For example, row 1 the value would compute ((x1 - y)+(x2-y))/2, and row 7 it should just compute (x2 - y)/1, because there is only one value. How can I get this column? Let me know if you need more clarification.</p>
| [
{
"answer_id": 74118397,
"author": "Anoushiravan R",
"author_id": 14314520,
"author_profile": "https://Stackoverflow.com/users/14314520",
"pm_score": 1,
"selected": false,
"text": "library(dplyr)\n\ndf %>%\n rowwise() %>%\n mutate(result = mean(c_across(x1:x3) - y, na.rm = TRUE))\n\n# ... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19991656/"
] |
74,118,372 | <p>I'm using GoTrue-JS to authenticate users on a Gatsby site I'm working on and I want the homepage to route users to either their user homepage or back to the login page.</p>
<p>I check the existence of a logged-in user in a Context layer then define a state (user) that is evaluated on the homepage with a useEffect hook with the state as the dependency.</p>
<p>The expected behavior is that the useEffect hook will trigger the check for a user once the function is completed and route the user. But what happens is that the hook seems to check without the user state getting changed which routes the user to the login page.</p>
<p>Here's an abridged version of the code:</p>
<p>context.js</p>
<pre><code>import React, {
useEffect,
createContext,
useState,
useCallback,
useMemo,
} from "react";
import GoTrue from 'gotrue-js';
export const IdentityContext = createContext();
const IdentityContextProvider = (props) => {
//create the user state
const [user, setUser] = useState(null);
//init GoTrue-JS
const auth = useMemo(() => {
return new GoTrue({
APIUrl: "https://XXXXXX.netlify.app/.netlify/identity",
audience: "",
setCookie: true,
});
},[]);
//get the user if they are signed in
useEffect(() => {
setUser(auth.currentUser());
},[auth]);
return (
<IdentityContext.Provider value={{ auth,user }}>
{props.children}
</IdentityContext.Provider>
)
}
export default IdentityContextProvider;
</code></pre>
<p>index.js</p>
<pre><code>import { navigate } from 'gatsby-link';
import { useContext, useEffect } from 'react'
import { IdentityContext } from '../contexts/IdentityContext';
export default function HomePage() {
const { user } = useContext(IdentityContext);
useEffect(() => {
if (user) {
navigate("/user/home");
console.log("there's a user");
} else {
navigate("/login");
console.log("no user");
}
}, [user]);
return null
}
</code></pre>
<p>When I remove the navigate functions I see no user, then there's a user in the log when I load the homepage. I thought the useEffect hook would only fire if the state I listed in the dependency array (<code>user</code>) was changed. If there's no user then <code>auth.currentUser()</code> will return null and if there is one, then I will get all the user data.</p>
| [
{
"answer_id": 74118397,
"author": "Anoushiravan R",
"author_id": 14314520,
"author_profile": "https://Stackoverflow.com/users/14314520",
"pm_score": 1,
"selected": false,
"text": "library(dplyr)\n\ndf %>%\n rowwise() %>%\n mutate(result = mean(c_across(x1:x3) - y, na.rm = TRUE))\n\n# ... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3411192/"
] |
74,118,389 | <p>Really confused here - this script works in one document, but not in another. I've tested out altering tab names, using an array vs. a bunch of if statements, really not sure where to go here.</p>
<p>Ultimately, all I want to do is add a row above row 30 on every tab in my document minus a few:</p>
<pre class="lang-js prettyprint-override"><code>function insertRow() {
// Retrieve the spreadsheet
const ss = SpreadsheetApp.getActiveSpreadsheet();
var allsheets = ss.getSheets();
var exclude = ["Sheet2", "Sheet5"];
for(var s in allsheets){
var sheet = allsheets[s];
// Stop iteration execution if the condition is meet.
if(exclude.indexOf(sheet.getName())==-1) continue;
sheets[i].insertRowBefore(row);
}
}
</code></pre>
| [
{
"answer_id": 74118432,
"author": "Tanaike",
"author_id": 7108653,
"author_profile": "https://Stackoverflow.com/users/7108653",
"pm_score": 2,
"selected": false,
"text": "sheets[i].insertRowBefore(row);"
},
{
"answer_id": 74118449,
"author": "Cooper",
"author_id": 721509... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118389",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19425874/"
] |
74,118,404 | <p>Suppose I have:</p>
<pre><code># ./Makefile
CLUSTER=dev
include Makefile.cluster.mk
CLUSTER=local
include Makefile.cluster.mk
</code></pre>
<p>And in:</p>
<pre><code># ./Makefile.cluster.mk
${CLUSTER}.cmd:
cmd ${CLUSTER}
</code></pre>
<p>So now I can call:</p>
<pre><code>make dev.cmd
make local.cmd
</code></pre>
<p>Great! Except the variable is evaluated too late. Running:</p>
<pre><code>$ make local.cmd # cmd local
$ make dev.cmd # Also cmd local !
</code></pre>
<p>Make sense: according to: <a href="https://www.gnu.org/software/make/manual/html_node/Reading-Makefiles.html" rel="nofollow noreferrer">https://www.gnu.org/software/make/manual/html_node/Reading-Makefiles.html</a>
rule steps are deferred evaluation (vs. immediate/on file load).</p>
<pre><code>immediate : immediate ; deferred
deferred
</code></pre>
<p>Is there a better/other way to compose a set of make commands without maintaining multiple copies of the same file?</p>
| [
{
"answer_id": 74118932,
"author": "John Bollinger",
"author_id": 2402272,
"author_profile": "https://Stackoverflow.com/users/2402272",
"pm_score": 1,
"selected": false,
"text": "%.cmd:\n cmd '$*'\n"
},
{
"answer_id": 74129925,
"author": "MadScientist",
"author_id"... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/48956/"
] |
74,118,431 | <p>I'm able to access the NFORC data in the abaqus output file correctly from abaqus output database but I'm not sure how to format the data so that it's usable since the <code>bulkDataBlocks</code> data is somewhat opaque.</p>
<p>The data is apparently in an array and the following code outputs the correct nodal forces for the elements within the specified set, but every attempt at trying to obtain the corresponding element fails for some reason.</p>
<pre><code># OUTPUT
[[ 437.9649 ]
[ -437.9649 ]
[ 285.99744 ]
[ -285.99744 ]
[ 26.090147 ]
[ -26.090147 ]
[ -20.221022 ]
[ 20.221022 ]
[ 19.118658 ]
[ -19.118658 ]
[ -1.9320803]
[ 1.9320803]
[ 1336.26 ]
[-1336.26 ]
[ 1444.7339 ]
[-1444.7339 ]
[ 285.6841 ]
[ -285.6841 ]
[ 233.1313 ]
[ -233.1313 ]
[ -3.2911508]
[ 3.2911508]
[ -18.943659 ]
[ 18.943659 ]
[ 10.187364 ]
[ -10.187364 ]
[ 5.255753 ]
[ -5.255753 ]
[ 1255.6117 ]
[-1255.6117 ]
[ 1291.9855 ]
[-1291.9855 ]
</code></pre>
<pre><code>from odbAccess import *
from sys import argv,exit
odb = openOdb('SPIE1_TIP_10MT_LC6A_REV9.odb', readOnly=True)
lastFrame = odb.steps['Step-1'].frames[-1]
mySet = odb.rootAssembly.elementSets['_FAST25-END_BRACKET_BOLTS_ZDIR_PF_']
nforc=lastFrame.fieldOutputs['NFORC1'].getSubset(region=mySet).bulkDataBlocks
for v in nforc:
print v.data
</code></pre>
| [
{
"answer_id": 74119181,
"author": "Satish Thorat",
"author_id": 15958062,
"author_profile": "https://Stackoverflow.com/users/15958062",
"pm_score": 1,
"selected": false,
"text": "bulkDataBlocks"
},
{
"answer_id": 74131212,
"author": "Mike S",
"author_id": 8658182,
"a... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118431",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8658182/"
] |
74,118,443 | <p>I have Vue Draggable working like a Kanban board with multiple columns, and I have made each column at least the height of the viewport so that each item can easily be dragged into the column next to it (for cases where one column is much longer than the next, for example).</p>
<p>I also have a button in the footer slot to add new cards to the column. This works well in that it is generally always at the bottom of the list, is not draggable, etc.</p>
<p>The issue arises when I drag an item from another list in <em>below</em> the footer (but still within the height of the draggable element). When I do this, the footer does not stay below the new item, which looks odd.</p>
<p>Once I drop the element, it snaps into place and the footer is one again at the bottom - it is only when the new card is being moved that it appears below the footer.</p>
<p>Is there any way to make sure that even during the move event and a new card being added to a list that the footer stays as the last element?</p>
<p>This issue seems to be captured in this comment on Github issues - <a href="https://github.com/SortableJS/Vue.Draggable/issues/673#issuecomment-554149705" rel="nofollow noreferrer">https://github.com/SortableJS/Vue.Draggable/issues/673#issuecomment-554149705</a> - but no solution is provided in that thread.</p>
<p>Any help greatly appreciated.</p>
<p><a href="https://i.stack.imgur.com/FoTJi.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FoTJi.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74119181,
"author": "Satish Thorat",
"author_id": 15958062,
"author_profile": "https://Stackoverflow.com/users/15958062",
"pm_score": 1,
"selected": false,
"text": "bulkDataBlocks"
},
{
"answer_id": 74131212,
"author": "Mike S",
"author_id": 8658182,
"a... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118443",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2424017/"
] |
74,118,461 | <p>I have been researching this today, it can often happen that a form is submitted twice if we don't put some safeguards in place. I found this issue on github:</p>
<p><a href="https://github.com/dotnet/aspnetcore/issues/23416" rel="nofollow noreferrer">https://github.com/dotnet/aspnetcore/issues/23416</a></p>
<pre class="lang-cs prettyprint-override"><code><button disabled="@_busy" Value="do-stuff" />
code{
private bool _busy = false;
public async Task Handler()
{
if(_busy) return;
_busy = true;
try
{
// do your thing
}
finally
{
_busy = false;
}
}
}
</code></pre>
<p>The above comment is a solution and comment next to it says:</p>
<blockquote>
<p>You can encapsulate this behavior in a component to avoid having to repeat it every time.</p>
</blockquote>
<p>How would I do that? If I have some forms (using Radzen currently) and there is a submit button pointing to <code>OnSubmit()</code> method - how could I introduce a component that I put on the component that has form, to avoid having to introduce this pattern every time in every form?</p>
| [
{
"answer_id": 74119181,
"author": "Satish Thorat",
"author_id": 15958062,
"author_profile": "https://Stackoverflow.com/users/15958062",
"pm_score": 1,
"selected": false,
"text": "bulkDataBlocks"
},
{
"answer_id": 74131212,
"author": "Mike S",
"author_id": 8658182,
"a... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3025663/"
] |
74,118,473 | <p>I'm new to JavaScript, coming from a Python background. I'm currently trying to understand the value of working directly with prototypes rather than classes.</p>
<h3>Class Approach</h3>
<p>For example, below we have a class for Dog</p>
<pre class="lang-js prettyprint-override"><code>// Class approach
class Dog1 {
genus = "canis";
vertebrate = true;
constructor(name, breed) {
this.name = name;
this.breed = breed;
}
bark() {
console.log("Bark!")
}
}
</code></pre>
<h3>Prototype Approach</h3>
<p>While the equivalent prototype version would be (I believe)</p>
<pre class="lang-js prettyprint-override"><code>// Prototype approach
function Dog2(name, breed) {
this.name = name;
this.breed = breed;
}
Dog2.prototype.bark = function() {
console.log("Bark!")
}
Dog2.prototype.genus = "canis"
Dog2.prototype.vertebrate = true
</code></pre>
<p>In general, I'm really struggling to see the value of the prototype method.</p>
<ol>
<li>Adding the method and "class" attribute occurs outside the constructor definition, which seems to <strong>inherently makes the code less reusable</strong>.</li>
<li>This may be because I am coming from Python, but <strong>the class approach just seems inherently cleaner and more intuitive</strong>.
<ol>
<li>For example, why do we have to add <code>bark</code> and <code>genus</code> to <code>Dog2.prototype</code> rather than to <code>Dog2</code> directly? I assume it is because <code>Dog2</code> is ultimately a function which is not permitted to have attributes, but which does have a prototype, so we just attach <code>bark</code> and <code>genus</code> to that? But then how can we be assured that the prototype can store attributes?</li>
</ol>
</li>
</ol>
<p>I know that classes are just syntactic sugar so I can use them, but I want to make sure I'm understanding everything correctly.</p>
<h3><code>.prototype</code> vs <code>.__proto__</code></h3>
<p>I'm also a little confused as to why the <code>prototype</code> attribute of an object doesn't actually point to its prototype, and what the difference is between <code>.prototype</code> and <code>.__proto__</code>. For example, <a href="https://zeekat.nl/articles/constructors-considered-mildly-confusing.html" rel="nofollow noreferrer">this article</a> has the below diagram for the line <code>function MyConstructor() {}</code>, where the prototype chain(s) are in green:</p>
<p><a href="https://i.stack.imgur.com/CSrUx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CSrUx.png" alt="enter image description here" /></a></p>
<p>Is the idea that <code>MyConstructor</code> itself is a function, and so its actual prototype <code>.__proto__</code> must be what it "subclasses" from, inheriting all function-related functionality, but that it is also a constructor, and so we must define the type of object that it actually constructs (i.e. the class that it is the constructor for), which is what its <code>.prototype</code> object is? So <code>MyConstructor.prototype</code> is the "class", and <code>MyConstructor</code> is the mold for that class that is used to create new instances?</p>
<p><strong>Any advice is greatly appreciated! </strong></p>
| [
{
"answer_id": 74118919,
"author": "Bergi",
"author_id": 1048572,
"author_profile": "https://Stackoverflow.com/users/1048572",
"pm_score": 3,
"selected": true,
"text": "class"
}
] | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118473",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13850111/"
] |
74,118,478 | <p>I have to write a function height that takes two functions <code>height_c</code> and <code>height_b</code>, where <code>height_b</code> is the base case that calculates the height of a tree.</p>
<p>Here's what I have to write,</p>
<pre><code>height :: Tree a -> Int
height = foldTree height_c height_b
height_c :: a -> Int -> Int -> Int
height_c = undefined
height_b :: Int
height_b = undefined
</code></pre>
<p>Also useful are the definitions of <code>foldTree</code> and <code>Tree</code>,</p>
<pre><code>data Tree a
= Tip
| Bin a (Tree a) (Tree a)
deriving (Show)
foldTree
:: (a -> b -> b -> b) -- combining function
-> b -- base case
-> Tree a -- input tree
-> b -- answer
foldTree c b (Bin x l r) = c x (foldTree c b l) (foldTree c b r)
foldTree c b Tip = b
</code></pre>
<p>I was thinking something like</p>
<pre><code>height_b Tip = 0
</code></pre>
<p>for the base case, simple enough.</p>
<p>Now in terms of <code>height_c</code> I'm a little lost on where to begin. I'm not exactly sure how <code>foldTree</code> even works so that's probably the part that is messing me up the most.</p>
| [
{
"answer_id": 74118919,
"author": "Bergi",
"author_id": 1048572,
"author_profile": "https://Stackoverflow.com/users/1048572",
"pm_score": 3,
"selected": true,
"text": "class"
}
] | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18327190/"
] |
74,118,483 | <p>This is a rock paper scissors program and I need help making it loop at least three times. Here is the code if you need it.</p>
<pre><code>import random
#welcome
Welcome = input("welcome please choose the following options (press enter)")
while True:
#Options (Rock, Paper, Scissor) Make sure to use capital letters
player1 = input("Rock, Paper, Scissors : ")
player2 = random.choice(["Rock", "Paper", "Scissors"])
print("Player 2 selected: ", player2)
#Calculating Win/Lose
if player1 == "Rock" and player2 == "Paper":
print("Player 2 Won")
elif player1 == "Paper" and player2 == "Scissor":
print("Player 2 Won")
elif player1 == "Scissor" and player2 == "Rock":
print("Player 2 Won")
elif player1 == player2:
print("Tie")
else:
print("Player 1 Won")
while True:
if input('Do you want to repeat(y/n)') == 'n':
break
</code></pre>
| [
{
"answer_id": 74118919,
"author": "Bergi",
"author_id": 1048572,
"author_profile": "https://Stackoverflow.com/users/1048572",
"pm_score": 3,
"selected": true,
"text": "class"
}
] | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20277492/"
] |
74,118,515 | <p>Problem: Find the ZIP's that are not repeated in df.ZIP (has to occur no more than once) and df.ST does not have values of '.'.<br>
So I subset the original dataframe and applied Groupby - this still brought few rows that didn't meet the subset criteria(df.ST != '.'). So I created a separate df_us by subsetting with copy() option. Groupby still give the same index.</p>
<pre><code>grouped = df[df.ST != '.'].groupby(['ZIP_CD'],sort=False) # grouping
df_size = pd.DataFrame({'ZIP':grouped.size().index, 'Count':grouped.size().values}) # Forming df around the group
df_count = df_size[df_size.Count==1] #df with Count=1
one_index = df_count.index.tolist() #gathering index
df_one = df.loc[one_index] #final df
df_us = df_data[df.ST != '.'].copy() # tried this too
</code></pre>
<p>The last code above still gives some index for values of '.' when I groupby. But df_us does not have any '.' at all. So this result in having same index column as above method - but for '.' values, rest of the row values are empty as df_us does not have them!</p>
<p>groupy is finding those index with '.' values no matter what I did.
Any solution?</p>
<p>update:
sample data =<br>
index ST ZIP_CD <br>
123 ca 94025<br>
124 Toronto .<br>
125 ga 30306<br>
126 Italy .<br>
127 ca 94025<br></p>
<p>So correct answer is</p>
<pre><code> ST ZIP_CD
0 123 ca 94025
</code></pre>
<p><strong>Update:</strong>
@Naveed's soln and mine below works fine. Do not know why the above code is flawed?</p>
| [
{
"answer_id": 74118919,
"author": "Bergi",
"author_id": 1048572,
"author_profile": "https://Stackoverflow.com/users/1048572",
"pm_score": 3,
"selected": true,
"text": "class"
}
] | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118515",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4504270/"
] |
74,118,560 | <p>I have not been able to come up with a better title, it's a really simple issue though, I just don't know what to call it exactly.</p>
<p>I have a database of horses simplified here:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>horse_name</th>
<th>stable_name</th>
</tr>
</thead>
<tbody>
<tr>
<td>Horse1</td>
<td>Stable1</td>
</tr>
</tbody>
</table>
</div>
<p>I am only interested in further analyzing records which feature stables that own many horses so I wanted to filter out the small stables (ones with less than 10 horses).</p>
<p>What I've tried:</p>
<p>Attempt 1:</p>
<p>Step 1: <code>df['Stable'].value_counts() > 10</code> -> gives me boolean values, I inteded to use this to only query the part of the database that satisfied this condition.</p>
<p>Step 2: <code>df[df['Stable'].value_counts() > 10]</code> -> I wrap this in another df, hoping I get the result that I want, but I don't, I get a key error.</p>
<p>Attempt 2:</p>
<p>Step 1: <code>df['Stable'].value_counts().sort_values(ascending=False).head(21)</code> -> a little clunky, but by trial and error, I figured out there are 21 stables with more than 10 horses, and this query returned just those stables. All I needed now is to filter the database out using this result.</p>
<p>Step 2: <code>df[df['Stable'].value_counts().sort_values(ascending=False).head(21)]</code> -> same issue, returns a key error.</p>
<p>I also tried: <code>df[df['Stable'] in df['Stable'].value_counts() > 10]</code> again, that didn't work, and I don't think I'll sleep today.</p>
<p>Can anyone explain why this is happening in a way that I can understand? And how should this be done instead?</p>
| [
{
"answer_id": 74118606,
"author": "Naveed",
"author_id": 3494754,
"author_profile": "https://Stackoverflow.com/users/3494754",
"pm_score": 2,
"selected": true,
"text": "# create a temporary column 'c' by grouping on stable\n# transform associates the result to all rows that are part of ... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118560",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18507015/"
] |
74,118,565 | <p>I have need to configure a regex to match nth item (whitespace separated). I have below so far which gets 3rd item from a line, however it is a group item. Is it possible to modify the regex to actually match the 3rd item as the first match in result?</p>
<p><a href="https://regex101.com/r/FKscLq/1" rel="nofollow noreferrer">https://regex101.com/r/FKscLq/1</a></p>
<p>Also is there an equivalent regex to match the nth number (whitespace separated)?</p>
<p>E.g. below string should match 2323 as 2nd number. String should return no matches for 3rd number.</p>
<p>Fiji 123545 27.10.1981 Westpac 2323 Bank 232dcc desc</p>
<p><strong>Edit:</strong> I have got the regex to match nth word now. See below, it works beautifully.
<a href="https://regex101.com/r/2F4J9o/1" rel="nofollow noreferrer">https://regex101.com/r/2F4J9o/1</a></p>
<p>I still need to get the nth number match though.</p>
| [
{
"answer_id": 74118606,
"author": "Naveed",
"author_id": 3494754,
"author_profile": "https://Stackoverflow.com/users/3494754",
"pm_score": 2,
"selected": true,
"text": "# create a temporary column 'c' by grouping on stable\n# transform associates the result to all rows that are part of ... | 2022/10/18 | [
"https://Stackoverflow.com/questions/74118565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/501302/"
] |
74,118,623 | <p>I'm looking to make API call in javascript using AJAX provided by jQuery, but I receive an unprocessable entity error (a pydantic error response from my fastapi server). The strange part is that a curl command DOES work. Its not clear to me why my server can distinguish between the faulty ajax call and the successful curl call.</p>
<pre class="lang-bash prettyprint-override"><code>curl -X 'POST' \
'http://127.0.0.1:8010/api/update' \
-H 'accept: application/json' \
-H 'Content-Type: application/json' \
-d '{"gsid":"634ad79ee29c42396b0d4055","ticker":"SPX230317C04200000","security_type":5,"security_subtype":2005,"option_flavor":2,"underlying":{"gsid":"634ad6d1d89536dac325f871","ticker":"SPX"},"denominated_ccy":{"gsid":"634ad6d1d89536dac325f86e","ticker":"USD"},"expiry_date":"2023-03-17","strike":4200,"option_exercise":1,"expiry_series_type":20,"expiry_time_of_day":1,"settlement_type":1,"primary_exchange":"CBO","multiplier":100,"issuer":0,"description":0,"website":0,"as_of_date":"1970-01-01T00:00-05:00","expiry_datetime":"1969-12-31T19:00-05:00","identifiers":[{"id_type":2,"value":""},{"id_type":3,"value":""},{"id_type":4,"value":""},{"id_type":5,"value":""}]}'
</code></pre>
<p>My API responds to this call correctly, with the following 200 success response:</p>
<pre class="lang-json prettyprint-override"><code>{
"success": true,
"created_security": false,
"gsid": "634ad79ee29c42396b0d4055",
"available_versions": [
"1970-01-01T00:00:00-05:00"
],
"message": "success"
}
</code></pre>
<p>AJAX call with jQuery</p>
<pre class="lang-js prettyprint-override"><code>data = {"gsid":"634ad79ee29c42396b0d4055","ticker":"SPX230317C04200000","security_type":5,"security_subtype":2005,"option_flavor":2,"underlying":{"gsid":"634ad6d1d89536dac325f871","ticker":"SPX"},"denominated_ccy":{"gsid":"634ad6d1d89536dac325f86e","ticker":"USD"},"expiry_date":"2023-03-17","strike":4200,"option_exercise":1,"expiry_series_type":20,"expiry_time_of_day":1,"settlement_type":1,"primary_exchange":"CBO","multiplier":100,"issuer":0,"description":0,"website":0,"as_of_date":"1970-01-01T00:00-05:00","expiry_datetime":"1969-12-31T19:00-05:00","identifiers":[{"id_type":2,"value":""},{"id_type":3,"value":""},{"id_type":4,"value":""},{"id_type":5,"value":""}]};
payload = JSON.stringify(data);
$.ajax({
url: 'http://127.0.0.1:8010/api/update',
type : "POST",
dataType: 'json',
processData: false,
success: function(data){
console.log('success: '+JSON.stringify(data));
},
error: function(data){
console.log('error: '+JSON.stringify(data));
},
data : payload,
});
</code></pre>
<p>Here I get the following 422 unprocessable entity response from my server:</p>
<pre class="lang-json prettyprint-override"><code>{"readyState":4,"responseText":"{\"status_code\":10422,\"message\":\"4 validation errors for Request body value is not a valid dict (type=type_error.dict) body value is not a valid dict (type=type_error.dict) body value is not a valid dict (type=type_error.dict) body value is not a valid dict (type=type_error.dict)\",\"data\":null}","responseJSON":{"status_code":10422,"message":"4 validation errors for Request body value is not a valid dict (type=type_error.dict) body value is not a valid dict (type=type_error.dict) body value is not a valid dict (type=type_error.dict) body value is not a valid dict (type=type_error.dict)","data":null},"status":422,"statusText":"Unprocessable Entity"}
</code></pre>
| [
{
"answer_id": 74118606,
"author": "Naveed",
"author_id": 3494754,
"author_profile": "https://Stackoverflow.com/users/3494754",
"pm_score": 2,
"selected": true,
"text": "# create a temporary column 'c' by grouping on stable\n# transform associates the result to all rows that are part of ... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4709998/"
] |
74,118,629 | <p>I've got a page (<code>routes/customers/+page.svelte</code>) in which I've got two buttons:</p>
<pre><code><div class="float-right block p-5">
<button on:click={() => addNewCustomer("individual")} class="btn btn-sm bg-primary btn-outline">+ Individual</button>
</div>
<div class="float-right block p-5">
<a href="#" on:click={() => addNewCustomer("business")} class="btn btn-sm bg-primary btn-outline">+ Business</a>
</div>
</code></pre>
<p>As you can see these buttons invoke <code>addNewCustomer</code>:</p>
<pre><code>const addNewCustomer = customerType => {
goto(`/customers/tmp&type=${customerType}`)
}
</code></pre>
<p>I also have <code>customers/tmp/+page.svelte</code>, and in the same location I've got <code>+page.js</code>.</p>
<p>In <code>+page.js</code> I just want to capture <code>type</code> passed in the URL:</p>
<pre><code>import { page } from '$app/stores';
export async function load({params}) {
const tmp = $page.url.searchParams.get('type');
console.log(params)
console.log(tmp)
}
</code></pre>
<p>but this doesn't seem to work. I'm getting and error:</p>
<pre><code>404
Not found: /customers/tmp&type=business
Error: Not found: /customers/tmp&type=business
at resolve (file:///ifflin-ui/node_modules/@sveltejs/kit/src/runtime/server/index.js:322:13)
at Object.handle (file:///flin-ui/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:318:66)
at respond (file:///ifflin-ui/node_modules/@sveltejs/kit/src/runtime/server/index.js:341:30)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///ifflin-ui/node_modules/@sveltejs/kit/src/exports/vite/dev/index.js:376:22
</code></pre>
<p>If I get rid of the query in the url (<code>/customers/tmp</code>) my page loads correctly.
What am I missing?</p>
<hr />
<p><strong>Update</strong></p>
<p>As it was mentioned I should be using <code>/customers/tmp?type=${customerType}</code> instead of <code>/customers/tmp&type=${customerType}</code> (notice the use of <code>?</code> instead of <code>&</code>, don't know who I missed that detail) yet after updating I still get the following error:</p>
<pre><code>500
Cannot read properties of undefined (reading 'get')
TypeError: Cannot read properties of undefined (reading 'get')
at load (/src/routes/customers/tmp/+page.js:4:26)
at load_data (file:///Users/hansgruber/Desktop/webdev/projects/dundermifflin-ui/node_modules/@sveltejs/kit/src/runtime/server/page/load_data.js:109:38)
at process.processTicksAndRejections (node:internal/process/task_queues:95:5)
at async file:///Users/hansgruber/Desktop/webdev/projects/dundermifflin-ui/node_modules/@sveltejs/kit/src/runtime/server/page/index.js:203:13
</code></pre>
<p>seems to be related to <code>get</code>:
<code>const tmp = page.url.get('type');</code>
I've tried the following as well
<code>const tmp2 = page.url.searchParams.get('type');</code>
but still getting an error</p>
| [
{
"answer_id": 74119128,
"author": "H.B.",
"author_id": 546730,
"author_profile": "https://Stackoverflow.com/users/546730",
"pm_score": 3,
"selected": true,
"text": "/customers/tmp&type=business\nvs\n/customers/tmp?type=business\n"
},
{
"answer_id": 74119761,
"author": "MrCuj... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118629",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2882913/"
] |
74,118,635 | <p>I would like to set the fill opacity of all paths whose id starts with <em>Invisible</em> to 0.0, below the SVG.</p>
<p><strong>Original SVG (extract)</strong></p>
<pre><code><g id="Section-svg">
<path d="M150 0 L75 200 L225 200 Z" stroke="rgb(100, 100, 100)" style="fill: rgb(100, 100, 100); stroke-width: 0.3; stroke-linejoin: round; stroke-linecap: round; stroke rgb(100, 100, 100);"/>
<g id="symbols-svg">
<g id="Invisible2-svg" transform="translate(250, 90)" >
<path d="M-5 0a5 5 0 1 0 10 0 5 5 0 1 0-10 0Z" stroke="rgb(200, 200, 200)" id="Invisible2" style="fill: rgb(0, 15, 60); stroke-width: 1; fill-opacity: 0.9; stroke-opacity: 0.5; stroke-linejoin: miter; stroke-linecap: butt; stroke: rgb(0, 50, 100);" />
</g>
<g id="Invisible3-svg" transform="translate(250, 90)" >
<path d="M-5 0a5 5 0 1 0 10 0 5 5 0 1 0-10 0Z" stroke="rgb(200, 200, 200)" id="Invisible3" style="fill: rgb(0, 15, 60); stroke-width: 1; fill-opacity: 0.9; stroke-opacity: 0.5; stroke-linejoin: miter; stroke-linecap: butt; stroke: rgb(0, 50, 100);" />
</g>
</g>
</g>
</code></pre>
<p>Here is the XSL I used , I tried editing what I could find at <a href="https://stackoverflow.com/questions/56733293/how-to-modify-a-svg-attribute-using-xslt">How to modify a SVG attribute using XSLT</a></p>
<p><strong>XSL for the relative task</strong></p>
<pre><code> <xsl:template match="svg:*[@id[starts-with(., 'Invisible')]]">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute name="fill-opacity">0.0</xsl:attribute>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:copy>
</xsl:template>
</code></pre>
<p>Yet I only get the wanted paths duplicated, and with <em>fill-opacity</em> not as a style but as something that does not have real effect on the path.</p>
<p><strong>Resulting (wrong) SVG</strong></p>
<pre><code><g id="Section-svg">
<path d="M150 0 L75 200 L225 200 Z" stroke="rgb(100, 100, 100)" style="fill: rgb(100, 100, 100); stroke-width: 0.3; stroke-linejoin: round; stroke-linecap: round; stroke rgb(100, 100, 100);"/>
<g id="symbols-svg">
<g id="Invisible2-svg" transform="translate(250, 90)" >
<path d="M-5 0a5 5 0 1 0 10 0 5 5 0 1 0-10 0Z" stroke="rgb(200, 200, 200)" id="Invisible2" style="fill: rgb(0, 15, 60); stroke-width: 1; fill-opacity: 0.9; stroke-opacity: 0.5; stroke-linejoin: miter; stroke-linecap: butt; stroke: rgb(0, 50, 100);" fill-opacity="0.0;" />
</g>
<g id="Invisible3-svg" transform="translate(250, 90)" >
<path d="M-5 0a5 5 0 1 0 10 0 5 5 0 1 0-10 0Z" stroke="rgb(200, 200, 200)" id="Invisible3" style="fill: rgb(0, 15, 60); stroke-width: 1; fill-opacity: 0.9; stroke-opacity: 0.5; stroke-linejoin: miter; stroke-linecap: butt; stroke: rgb(0, 50, 100);" fill-opacity="0.0;" />
</g>
</g>
</g>
</code></pre>
<p><strong>Wanted result SVG</strong></p>
<pre><code><g id="Section-svg">
<path d="M150 0 L75 200 L225 200 Z" stroke="rgb(100, 100, 100)" style="fill: rgb(100, 100, 100); stroke-width: 0.3; stroke-linejoin: round; stroke-linecap: round; stroke rgb(100, 100, 100);"/>
<g id="symbols-svg">
<g id="Invisible2-svg" transform="translate(250, 90)" >
<path d="M-5 0a5 5 0 1 0 10 0 5 5 0 1 0-10 0Z" stroke="rgb(200, 200, 200)" id="Invisible2" style="fill: rgb(0, 15, 60); stroke-width: 1; fill-opacity: 0.0; stroke-opacity: 0.5; stroke-linejoin: miter; stroke-linecap: butt; stroke: rgb(0, 50, 100);" />
</g>
<g id="Invisible3-svg" transform="translate(250, 90)" >
<path d="M-5 0a5 5 0 1 0 10 0 5 5 0 1 0-10 0Z" stroke="rgb(200, 200, 200)" id="Invisible3" style="fill: rgb(0, 15, 60); stroke-width: 1; fill-opacity: 0.0; stroke-opacity: 0.5; stroke-linejoin: miter; stroke-linecap: butt; stroke: rgb(0, 50, 100);" />
</g>
</g>
</g>
</code></pre>
<p>I also tried matching the path and giving it the style I would like it to have</p>
<p><strong>XSL</strong></p>
<pre><code> <xsl:template match="svg:path[@id[starts-with(., 'Invisible')]]">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<path style="fill: rgb(0, 15, 60); stroke-width: 0.1; fill-opacity: 0.0; stroke-opacity: 0.0; stroke-linejoin: miter; stroke-linecap: butt; stroke: rgb(0, 50, 100);">
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:copy>
</xsl:template>
</code></pre>
<p>but both NotePad++ and VBA said the resulting XSL is not well formed.</p>
<p>Nor did this work</p>
<p><strong>XSL</strong></p>
<pre><code> <xsl:template match="svg:*[@id[starts-with(., 'Invisible')]]">
<xsl:copy>
<xsl:apply-templates select="@* | node()"/>
<xsl:copy>
<xsl:apply-templates select="@*"/>
<xsl:attribute style="fill-opacity">0.0</xsl:attribute>
<xsl:apply-templates select="node()"/>
</xsl:copy>
</xsl:copy>
</xsl:template>
</code></pre>
<p>Could someone please advise?</p>
| [
{
"answer_id": 74118917,
"author": "Conal Tuohy",
"author_id": 7372462,
"author_profile": "https://Stackoverflow.com/users/7372462",
"pm_score": 0,
"selected": false,
"text": "xsl:copy"
},
{
"answer_id": 74124029,
"author": "michael.hor257k",
"author_id": 3016153,
"au... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118635",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18247317/"
] |
74,118,658 | <p>I trained a model and uploaded it to Google AI Platform. When I test the model from the command line I expect to get predictions back from my uploaded model, instead I get an error message. Here are the steps I followed:</p>
<ol>
<li>Installing Gcloud</li>
<li>Saving my model</li>
</ol>
<pre><code>gcloud ai-platform local train \
--module-name trainer.final_task \
--package-path trainer/ --
</code></pre>
<ol start="3">
<li>Created manually a bucket</li>
<li>Added created file from step 2 to bucket (<code>saved_model.pb</code>)</li>
<li>Created a model in Gcloud like <a href="https://cloud.google.com/ai-platform/prediction/docs/deploying-models#deploy_models_and_versions" rel="nofollow noreferrer">here</a> and linked it with the bucket from step 5 (Yes, I configured Python and Tensorflow locally as I configured it in the bucket.).</li>
</ol>
<p><a href="https://i.stack.imgur.com/ULMbo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ULMbo.png" alt="enter image description here" /></a></p>
<ol start="6">
<li>Tested it from a command line (this produces the error)</li>
</ol>
<pre><code>MODEL_NAME=ML6Mugs
VERSION=FinalModel6
gcloud ai-platform predict \
--region europe-west1 \
--model $MODEL_NAME \
--version $VERSION \
--json-instances check_deployed_model/test.json
</code></pre>
<p>What do I miss out? It's difficult to find something online about the issue. The only thing I found was <a href="https://github.com/GoogleCloudPlatform/cloudml-samples/issues/490" rel="nofollow noreferrer">this</a>.</p>
<p><strong>Architecture of my model</strong></p>
<pre class="lang-py prettyprint-override"><code>def model(input_layer):
"""Returns a compiled model.
This function is expected to return a model to identity the different mugs.
The model's outputs are expected to be probabilities for the classes and
and it should be ready for training.
The input layer specifies the shape of the images. The preprocessing
applied to the images is specified in data.py.
Add your solution below.
Parameters:
input_layer: A tf.keras.layers.InputLayer() specifying the shape of the input.
RGB colored images, shape: (width, height, 3)
Returns:
model: A compiled model
"""
input_shape=(input_layer.shape[1], input_layer.shape[2], input_layer.shape[3])
base_model = tf.keras.applications.MobileNetV2(weights='imagenet', input_shape=input_shape, include_top=False)
for layer in base_model.layers:
layer.trainable = False
model = models.Sequential()
model.add(base_model)
model.add(layers.GlobalAveragePooling2D())
model.add(layers.Dense(4, activation='softmax'))
model.compile(optimizer="rmsprop", loss='sparse_categorical_crossentropy', metrics=["accuracy"])
return model
</code></pre>
<p><strong>Error</strong></p>
<pre><code>ERROR: (gcloud.ai-platform.predict) HTTP request failed. Response: {
"error": {
"code": 400,
"message": "{\n \"error\": \"Could not find variable block_15_depthwise_BN/beta. This could mean that the variable has been deleted. In TF1, it can also mean the variable is uninitialized. Debug info: container=localhost, status error message=Container localhost does not exist. (Could not find resource: localhost/block_15_depthwise_BN/beta)\\n\\t [[{{function_node __inference__wrapped_model_15632}}{{node model/sequential/mobilenetv2_1.00_224/block_15_depthwise_BN/ReadVariableOp_1}}]]\"\n}",
"status": "INVALID_ARGUMENT"
}
}
</code></pre>
| [
{
"answer_id": 74129958,
"author": "Max Hager",
"author_id": 14606987,
"author_profile": "https://Stackoverflow.com/users/14606987",
"pm_score": 2,
"selected": true,
"text": "gs://your_bucket_name/saved_model.pb"
},
{
"answer_id": 74145990,
"author": "NSFF",
"author_id": ... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118658",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14606987/"
] |
74,118,717 | <p>I have a dataframe that stores a JSON object in one column. I want to process the JSON object to create a new dataframe (different number and type of columns, and each row will generate n new rows from the JSON object). I wrote this logic below that appends a dictionary (row) to a list while iterating through the original dataset.</p>
<pre class="lang-py prettyprint-override"><code>data = []
def process_row_data(row):
global data
for item in row.json_object['obj']:
# create a dictionary to represent each row of a new dataframe
parsed_row = {'a': item.a, 'b':item.b, ..... 'zyx':item.zyx}
data.append(parsed_row)
df.apply(lambda row: process_row_data(row), axis=1)
# create the new dataframe
df_final = pd.DataFrame.from_dict(data)
</code></pre>
<p>However, this solution doesn't seem to be scalable when the number of rows and the size of the <code>parsed_row</code> grow.</p>
<p>Is there a way to write this in a scalable way with PySpark?</p>
| [
{
"answer_id": 74239560,
"author": "Ahmed Mohamed",
"author_id": 18074007,
"author_profile": "https://Stackoverflow.com/users/18074007",
"pm_score": 3,
"selected": true,
"text": "# Import libraries\nimport pandas as pd\nimport json\n\n# Load the original dataframe\ndf = pd.read_csv('data... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6361137/"
] |
74,118,722 | <p>So I have a df</p>
<pre><code>df <- cbind.data.frame(
ID = c("123", "604", "789", "193", "872"),
r1 = c("HISPANIC", "WHITE", "ASIAN", "BLACK", "ASIAN"),
r2 = c(NA, NA, "WHITE", "HISPANIC", "OTHER"),
r3 = c(NA, NA, NA, "OTHER", "OTHER"))
</code></pre>
<pre><code> ID r1 r2 r3
1 123 HISPANIC <NA> <NA>
2 604 WHITE <NA> <NA>
3 789 ASIAN WHITE <NA>
4 193 BLACK HISPANIC OTHER
5 872 ASIAN OTHER OTHER
</code></pre>
<p>Id like to create a new column(FINALRACE) that recategorizes and combines r1:r3. Any row that contains HISPANIC remains hispanic, if column r2:r3 are NA then return column r1, and else return other</p>
<p>i've tried:</p>
<pre><code>df$FINALRACE <- ifelse(df == 'HISPANIC', 'HISPANIC',
ifelse(df$r2 == '', as.character(r1), 'OTHER'))
df<- df %>% mutate(FINALRACE = if_else(df == 'HISPANIC', 'HISPANIC',
ifelse(df$r2 == '', as.character(r1),'OTHER')))
</code></pre>
<p>ultimately would like df to look like:</p>
<pre><code> ID r1 r2 r3 FINALRACE
1 123 HISPANIC <NA> <NA> HISPANIC
2 604 WHITE <NA> <NA> WHITE
3 789 ASIAN WHITE <NA> OTHER
4 193 BLACK HISPANIC OTHER HISPANIC
5 872 ASIAN OTHER OTHER OTHER
</code></pre>
| [
{
"answer_id": 74118992,
"author": "jared_mamrot",
"author_id": 12957340,
"author_profile": "https://Stackoverflow.com/users/12957340",
"pm_score": 1,
"selected": false,
"text": "library(dplyr)\n#> \n#> Attaching package: 'dplyr'\n#> The following objects are masked from 'package:stats':... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118722",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20277624/"
] |
74,118,818 | <p>In the following code for the scrollcontroller, if i initialise the variable _scrollController as late, then I get issue as
LateInitializationError: Field '_scrollController@1084415195' has not been initialized.
and If i make it nullable, I get
Null check operator used on a null value</p>
<pre><code> class _MyScrollbarState extends State<MyScrollbar> {
ScrollController? _scrollController;
ScrollbarPainter? _scrollbarPainter;
Orientation? _orientation;
@override
void initState() {
super.initState();
WidgetsBinding.instance.addPostFrameCallback((_) {
_updateScrollPainter(_scrollController!.position);
});
}
</code></pre>
| [
{
"answer_id": 74118902,
"author": "john",
"author_id": 16146701,
"author_profile": "https://Stackoverflow.com/users/16146701",
"pm_score": 2,
"selected": true,
"text": "class _MyScrollbarState extends State<MyScrollbar> {\n late ScrollController _scrollController;\n late Scrollb... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19499418/"
] |
74,118,828 | <p>I am trying to create a parent Div, with 4 children Divs within the parent, all to fill the available space which will automatically adjust on different screen sizes no matter how much text is added. So far, I have been able to code the divs to fill horizontally but not vertically.</p>
<p>I have so far tried variants of Position, Flex, Width and Height to no avail. Any help would be greatly appreciated. You can gauge what I am trying to accomplish from the image added.</p>
<p>This may seem fairly straightforward although I work mostly with backend development and still learning CCS.</p>
<p><a href="https://i.stack.imgur.com/MyBNG.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MyBNG.png" alt="enter image description here" /></a></p>
<pre><code> <div class="d-flex col-lg-4 col-md-4 col-sm-12 col-12">
<div class="boxshadow" style="background-color: #fff; border-radius: 20px; margin: 10px; width: 100%; height: 350px; padding: 40px;">
<div class="row">
<div class="col-sm-12 col-md-6 col-lg-6">
<div class="boxshadow" style="display: flex; flex-flow: column; height: 100%; padding: 20px; margin: 5px;">
<h1>12</h1>
</div>
</div>
<div class="col-sm-12 col-md-6 col-lg-6">
<div class="boxshadow" style="display: flex; flex-flow: column; height: 100%; padding: 20px; margin: 5px;">
<h1>22</h1>
</div>
</div>
<div class="col-sm-12 col-md-6 col-lg-6">
<div class="boxshadow" style="display: flex; flex-flow: column; height: 100%; padding: 20px; margin: 5px;">
<h1>36</h1>
</div>
</div>
<div class="col-sm-12 col-md-6 col-lg-6">
<div class="boxshadow" style="display: flex; flex-flow: column; height: 100%; padding: 20px; margin: 5px;">
<h1>47</h1>
</div>
</div>
</div>
</div>
</div>
</code></pre>
<p>Aiming to do this:</p>
<p><a href="https://i.stack.imgur.com/hU2fA.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/hU2fA.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74119105,
"author": "coolAppl3",
"author_id": 18927044,
"author_profile": "https://Stackoverflow.com/users/18927044",
"pm_score": -1,
"selected": false,
"text": "display: grid;\ngrid-template-columns: repeat(2, 1fr);\n"
},
{
"answer_id": 74119147,
"author": "Ka... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118828",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5594386/"
] |
74,118,876 | <p>I was given a case describing projects -- their budgets, schedule, etc.</p>
<p>I've identified those that are over budget and over schedule ('Personal Findings' cell B14)</p>
<pre><code>=COUNTIFS('NYC P&R'!I:I,">0",'NYC P&R'!N:N,">0")
</code></pre>
<p>Now I need to find the average of each using this condition -- <em>Of those projects that are over budget and over schedule, what are the average number of days over schedule? What is the average over budget?</em></p>
<p>For the average number of days (with conditions), I've tried this input:</p>
<pre><code>=AVERAGEIFS('NYC P&R'!E:E,">0",'NYC P&R'!N:N,">0)")
</code></pre>
<p>But I'm then met with:
AVERAGEIFS expect all arguments after position 3 to be in pairs.</p>
<p>I don't know if I'm inputting the data wrong, using the function wrong, or need an entirely different function.</p>
<p>Any help would be greatly appreciated. Thank you in advance!</p>
<p><a href="https://docs.google.com/spreadsheets/d/1NuhHCZNnqpzpKR90aKBmarphGmdENe1T/edit?usp=sharing&ouid=113266681769336951800&rtpof=true&sd=true" rel="nofollow noreferrer">Link to Sheet Here</a></p>
| [
{
"answer_id": 74119007,
"author": "pgSystemTester",
"author_id": 11732320,
"author_profile": "https://Stackoverflow.com/users/11732320",
"pm_score": 3,
"selected": true,
"text": "AVERAGE_RANGE"
},
{
"answer_id": 74119612,
"author": "Karthik Sivasubramaniam",
"author_id":... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118876",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14744739/"
] |
74,118,888 | <p>Guys i have this function that check if there any switch offline, but i have 24 switchs at the company that i work, so i made a function to every Ip, if ping returns 'Success' the label color change to Green if not change to Red...</p>
<p>So I pass a param like ping1("123.45.67.899"); but I would like to pass the value of the label to change the color...</p>
<p>Anyone could help me ? currently I did 24 ping functions I changed the names of the labels which are from 25 to 49</p>
<pre><code> public void ping1(string ip)
{
Ping ping = new Ping();
PingReply reply = ping.Send(ip, 100);
if (reply.Status.ToString() == "Success")
{
label25.BackColor = Color.LightGreen;
}
else
{
label25.BackColor = Color.Red;
}
}
</code></pre>
| [
{
"answer_id": 74119016,
"author": "Mateus ",
"author_id": 17084062,
"author_profile": "https://Stackoverflow.com/users/17084062",
"pm_score": 2,
"selected": true,
"text": " public void ping0(string ip, Label lab)\n {\n Ping ping = new Ping();\n PingRe... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118888",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17084062/"
] |
74,118,893 | <p>I'm new to the <code>Jetpack Compose</code>, and I'm trying to implement a function inside a button but it gives the following error:</p>
<blockquote>
<p>@Composable invocations can only happen from the context of a
@Composable function in mContext.startActivity(Intent(mContext,
MainScreen()::class.java))</p>
</blockquote>
<pre class="lang-kotlin prettyprint-override"><code> @Composable
fun AdminAuth() {
Column(
modifier = Modifier
.fillMaxSize()
.padding(20.dp),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
var password by rememberSaveable { mutableStateOf("") }
var passawordVisibility by remember { mutableStateOf(false) }
val icon = if (passawordVisibility)
painterResource(id = R.drawable.ic_visibility)
else
painterResource(id = R.drawable.ic_visibility_off)
Text(text = "Insira a senha do usuário Master:", fontSize = 15.sp)
OutlinedTextField(
value = password,
onValueChange = {
password = it
},
placeholder = { Text(text = "Senha") },
label = { Text(text = "Senha") },
trailingIcon = {
IconButton(onClick = {
passawordVisibility = !passawordVisibility
}) {
Icon(
painter = icon,
contentDescription = "Ícone de visibilidade"
)
}
},
keyboardOptions = KeyboardOptions(
keyboardType = KeyboardType.Password
),
visualTransformation = if (passawordVisibility)
VisualTransformation.None
else PasswordVisualTransformation()
)
val mContext = LocalContext.current
OutlinedButton(
onClick = {
if (password.equals("Abac@xi123")) {
mContext.startActivity(Intent(mContext, MainScreen()::class.java))
}
},
modifier = Modifier
.fillMaxWidth()
.padding(35.dp),
) {
Text(text = "Entrar")
}
}
}
@Composable
@Preview
fun AdminAuthPreview() {
Column(
modifier = Modifier
.fillMaxSize()
.background(Color.White),
horizontalAlignment = Alignment.CenterHorizontally,
verticalArrangement = Arrangement.Center
) {
AdminAuth()
}
}
</code></pre>
| [
{
"answer_id": 74119187,
"author": "z.y",
"author_id": 19023745,
"author_profile": "https://Stackoverflow.com/users/19023745",
"pm_score": 2,
"selected": false,
"text": "startActivity"
},
{
"answer_id": 74119608,
"author": "Thracian",
"author_id": 5457853,
"author_pro... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118893",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20268016/"
] |
74,118,904 | <p>I tried to remove newline followed by tab with space using following regex in sed</p>
<pre><code>sed "s|\n[\t|\s]*| |" input.log > output.log
</code></pre>
<p>It does not work but if I use per then it replaces all new line as well. I want to replace only newline followed by tab or space multiple times (more than 1 time) with a space.</p>
<pre><code>perl -pe '/\n[\t|\s]*/ /' input.log > output.log
</code></pre>
<p>Sample data in below link:</p>
<p><a href="https://regex101.com/r/D9sHjG/1" rel="nofollow noreferrer">https://regex101.com/r/D9sHjG/1</a></p>
<p>I want to remove blue highlighted tabs after newline.
<a href="https://i.stack.imgur.com/5ypdD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5ypdD.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74119187,
"author": "z.y",
"author_id": 19023745,
"author_profile": "https://Stackoverflow.com/users/19023745",
"pm_score": 2,
"selected": false,
"text": "startActivity"
},
{
"answer_id": 74119608,
"author": "Thracian",
"author_id": 5457853,
"author_pro... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118904",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2214674/"
] |
74,118,910 | <p>I have two strings in C.</p>
<pre><code>char* lexeme = "this is an example";
char c = 'a';
</code></pre>
<p>I want to concat the two strings to have as a result this:</p>
<pre><code>"this is an examplea"
</code></pre>
<p>I've already tried using strcpy and strcat, but it gives an error because the second char is not of type char*</p>
| [
{
"answer_id": 74126129,
"author": "Lundin",
"author_id": 584518,
"author_profile": "https://Stackoverflow.com/users/584518",
"pm_score": 2,
"selected": false,
"text": "lexeme"
},
{
"answer_id": 74126262,
"author": "Ayxan Haqverdili",
"author_id": 10147399,
"author_pr... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118910",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19361846/"
] |
74,118,926 | <ul>
<li><p>My code not working I tried to add text to my code after adding my
navbar in background-color in Css.</p>
<p><!doctype html></p>
Home Page
<p>< !----Toggle---></p>
<p>< !----Icon Widgets---></p>
<pre><code> <ul class="navbar-nav ms-auto">
<li class="nav-item>
<<form>
<label for="search class="search bar></label>
</form>
<a class="nav-link" href=""><input type="text" placeholder="Search"></a>
<li class="nav-item">
<a class="nav-link" href=""><i class="fa-solid fa-bag-shopping"></i></a>
</li>
</ul>
</div>
</code></pre>
</li>
</ul>
| [
{
"answer_id": 74119078,
"author": "Ihyaulhaq Maulana",
"author_id": 19874423,
"author_profile": "https://Stackoverflow.com/users/19874423",
"pm_score": 2,
"selected": false,
"text": "<<form>"
},
{
"answer_id": 74119107,
"author": "Mohammad Aditya Noviansyah",
"author_id"... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118926",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18730427/"
] |
74,118,930 | <p>Good night, I'm having trouble comparing the common values of a list and a stack, could you help me to solve this problem? Thank you very much in advance.</p>
<p><strong>Note: I'm a beginner</strong></p>
<pre><code>public static void main(String[] args) {
Stack<Integer> pilha = new Stack<Integer>();
pilha.push(15);
pilha.push(20);
pilha.push(35);
pilha.push(45);
LinkedList<Integer> lista = new LinkedList<>();
lista.addLast(41);
lista.addLast(23);
lista.addLast(20);
lista.addLast(12);
System.out.println("Os numeros da Pilha são:" + pilha);
System.out.println("Os numeros da Pilha são:" + lista);
int sPilha = pilha.size();
int valor =0;
int valorLista = 0;
int verd = 0;
for(int cont =0; cont < sPilha; cont++) {
valor = pilha.pop();
valorLista = lista.pop();
if(valor == valorLista){
verd = valorLista;
System.out.println("Os valores em comum da lista são: " + valorLista);
}
}
}
</code></pre>
<p>}</p>
| [
{
"answer_id": 74119038,
"author": "Icarus",
"author_id": 11275562,
"author_profile": "https://Stackoverflow.com/users/11275562",
"pm_score": 1,
"selected": false,
"text": " for(int cont =0; cont < pilha.size(); cont++) {\n valor = pilha.get(cont);\n for(int ... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118930",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20277894/"
] |
74,118,971 | <p>I got this definition table. Every product has it's own <strong>ATTRIBUTE1, ATTRIBUTE2, ATTRIBUTE3, ATTRIBUTE4, ATTRIBUTE5, ATTRIBUTE6,</strong> that includes them in a specific deposit</p>
<pre><code>DEPOSIT_ID ATTRIBUTE1 ATTRIBUTE2 ATTRIBUTE3 ATTRIBUTE4 ATTRIBUTE5 ATTRIBUTE6
41 * 006|001 * 0M * *
40 * 003|006 41|29 !94|46 !E5|E6 *
39 * 003|006 45 !94 * *
38 * 003|006 10|59 * 18|P5 *
37 * 001 23 !94 * *
36 * 001 26|SSH !57 * *
35 * 001 24|25 !81|57|0M * *
34 * 001 22 !57 !Q1|O3 *
33 * 001 21 !81|57 B7 *
32 * 001 SSJ|62 !81|57 * 9FA
</code></pre>
<blockquote>
<p>"*" means that it can accept any valid attribute</p>
<p>"|" means it can be one or another (i.e: 006|001 means that it can be 006 or 001)</p>
<p>"!" means it cannot be that value (i.e: !81|57 means that it cannot be 81 or 57)</p>
</blockquote>
<pre><code>Note:
a "*" for ATTRIBUTE1 would be a value = "GH"
a "*" for ATTRIBUTE2 would be a value = "001"
a "*" for ATTRIBUTE3 would be a value = "41"
a "*" for ATTRIBUTE4 would be a value = "0M"
a "*" for ATTRIBUTE5 would be a value = "B7"
a "*" for ATTRIBUTE5 would be a value = "9FA"
</code></pre>
<h2>EVERY attribute has a set of values and the "*" means it can be any, that's why i posted some valid attributes for each ATTRIBUTE column</h2>
<p><strong>For example:</strong></p>
<p>Product "a" has these attributes (also called item configuration):</p>
<pre><code>{
attribute1: "GH"
attribute2: "001"
attribute3: "VT"
attribute4: "OM"
attribute5: "JU"
attribute6: "YU"
}
</code></pre>
<p><a href="https://i.stack.imgur.com/1gZym.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1gZym.png" alt="enter image description here" /></a></p>
<p>So, for that item configuration, product "a" belongs" to <strong>DEPOSIT_ID: 41</strong></p>
<hr />
<p>Suppose that i want to know which is the DEPOSIT ID for this item configuration:</p>
<pre><code>{
attribute1: "GH"
attribute2: "001"
attribute3: "23"
attribute4: "JU"
attribute5: "KO"
attribute6: "YU"
}
</code></pre>
<p>It should give me the deposit_id = 37.</p>
<p>What would it be the best to solve this by using JAVA or JAVASCRIPT or SQL?</p>
| [
{
"answer_id": 74119038,
"author": "Icarus",
"author_id": 11275562,
"author_profile": "https://Stackoverflow.com/users/11275562",
"pm_score": 1,
"selected": false,
"text": " for(int cont =0; cont < pilha.size(); cont++) {\n valor = pilha.get(cont);\n for(int ... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14012751/"
] |
74,118,980 | <p>I'm trying to change the date format from 2020.11.20 to 11/2020</p>
<p>My objective is to remove the day and leave just month/year.
If I change the type of the field EDATU from vbep-EDATU to string it doesn't work.</p>
<p>Any tips on how to achieve my goal?</p>
<pre><code>DATA: GR_COLUMNS TYPE REF TO CL_SALV_COLUMNS_TABLE,
GR_TABLE TYPE REF TO CL_SALV_TABLE.
TYPES: BEGIN OF IT_STR,
EDATU TYPE VBEP-EDATU,
vbeln type vbep-vbeln,
END OF IT_STR.
DATA: IT_FINAL TYPE STANDARD TABLE OF IT_STR.
FIELD-SYMBOLS: <F_DAT> TYPE IT_STR.
SELECT EDATU vbeln FROM VBEP INTO TABLE IT_FINAL up to 10 rows.
LOOP AT IT_FINAL ASSIGNING <F_DAT>.
<F_DAT>-EDATU = <F_DAT>-EDATU+4(2) && '/' && <F_DAT>-EDATU(4).
ENDLOOP.
TRY.
CALL METHOD CL_SALV_TABLE=>FACTORY
EXPORTING
LIST_DISPLAY = IF_SALV_C_BOOL_SAP=>FALSE
IMPORTING
R_SALV_TABLE = GR_TABLE
CHANGING
T_TABLE = IT_FINAL.
CATCH CX_SALV_MSG .
ENDTRY.
GR_COLUMNS = GR_TABLE->GET_COLUMNS( ).
CALL METHOD GR_TABLE->DISPLAY.
</code></pre>
| [
{
"answer_id": 74128908,
"author": "Gert Beukema",
"author_id": 983715,
"author_profile": "https://Stackoverflow.com/users/983715",
"pm_score": 3,
"selected": true,
"text": "gr_columns->get_column( columnname = 'EDATU' )->set_technical( abap_true ).\n"
},
{
"answer_id": 74159642... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118980",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19277005/"
] |
74,118,982 | <p>I have a domain purchased from Godaddy. Then a Virtual Machine setup on Azure with an web application installed on it.</p>
<p>So thus far I have:</p>
<ol>
<li>An Azure VM with an application running on it, lets say the ip for the VM is <strong>12.3.456.789</strong></li>
<li>A domain name I purchased from godaddy, e.g <strong>mydomain.com</strong>, I then created a subdomain for e.g <strong>sub.mydomain.com</strong></li>
<li>I then added an SSL certificate to this subdomain which worked fine, after I changed the DNS A record for the subdomain to the ip address of the VM <strong>12.3.456.789</strong>, also the application on the VM is accessed on port 4000. So <strong><a href="https://sub.mydomain.com:4000" rel="nofollow noreferrer">https://sub.mydomain.com:4000</a></strong></li>
</ol>
<p>The issue is that when I access my domain via https I get the ERR_SSL_PROTOCOL_ERROR in all browsers but when I access it via http then the application on it loads completely fine.</p>
<p>Any ideas on what I would have <strong>done wrong</strong> or left out in my setup?</p>
<p>Also if I did not provide enough information do let me know.</p>
| [
{
"answer_id": 74128908,
"author": "Gert Beukema",
"author_id": 983715,
"author_profile": "https://Stackoverflow.com/users/983715",
"pm_score": 3,
"selected": true,
"text": "gr_columns->get_column( columnname = 'EDATU' )->set_technical( abap_true ).\n"
},
{
"answer_id": 74159642... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74118982",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19264679/"
] |
74,119,015 | <p>Hi guys I'm using react hook form for multiple checkbox, Currently all checkbox can be selected.
Any idea how can I select checkbox one at a time?</p>
<pre><code> const formMethods = useForm<BookingSourcesForm>({
defaultValues: { bookingSources: [] },
});
const { fields, append } = useFieldArray<BookingSourcesForm>({
control: formMethods.control,
name: 'bookingSources',
});
{fields.map((field, index) => {
return (
<HStack align="center" justify="space-between" w="100%">
<Controller
name={`bookingSources.${index}.IsDefault` as const}
control={control}
render={({ field }) => (
<Checkbox
isChecked={field.value}
onChange={(e) => {
field.onChange(e.currentTarget.checked);
}}
/>
)}
/>
)
}
}
</code></pre>
| [
{
"answer_id": 74128908,
"author": "Gert Beukema",
"author_id": 983715,
"author_profile": "https://Stackoverflow.com/users/983715",
"pm_score": 3,
"selected": true,
"text": "gr_columns->get_column( columnname = 'EDATU' )->set_technical( abap_true ).\n"
},
{
"answer_id": 74159642... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119015",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20277928/"
] |
74,119,028 | <p>I've been trying to figure out if it's possible to store a variable in a Django database field. Here is an example:</p>
<pre><code>class Message(models.Model):
message = models.TextField()
</code></pre>
<p>And then in the HTML form field, someone inputs something like this:</p>
<pre><code>Hi {{ user.first_name }}, thanks for signing up to our {{ company.name }} newsletter.
</code></pre>
<p>That then gets saved to the database, and when an email goes out, those fields are automatically populated with the appropriate data.</p>
<p>Hope this makes sense. Thanks.</p>
| [
{
"answer_id": 74128908,
"author": "Gert Beukema",
"author_id": 983715,
"author_profile": "https://Stackoverflow.com/users/983715",
"pm_score": 3,
"selected": true,
"text": "gr_columns->get_column( columnname = 'EDATU' )->set_technical( abap_true ).\n"
},
{
"answer_id": 74159642... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119028",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2587406/"
] |
74,119,032 | <p>I'm using this find command to search all files in a directory ending with .err and .out. I'm using -exec with grep to search some content inside the files. But I can't figure out how to redirect each grep command to a file.</p>
<p>This my command:</p>
<pre><code>find ./Documents/ -type f \( -name "*.out" -o -name "*.err" \) -exec sh -c "grep out {}; grep err {}" \;
</code></pre>
<p>I have tried this but it does not work (the files created are empty):</p>
<pre><code>find ./Documents/ -type f \( -name "*.out" -o -name "*.err" \) -exec sh -c "grep out > file1 {}; grep err > file2 {}" \;
</code></pre>
<p>How can I solve this problem?</p>
| [
{
"answer_id": 74119578,
"author": "fauzimh",
"author_id": 2361379,
"author_profile": "https://Stackoverflow.com/users/2361379",
"pm_score": 0,
"selected": false,
"text": "find ./Documents/ -type f \\( -name \"*.out\" -o -name \"*.err\" \\) -exec sh -c \"grep 'out' {} >> file1; grep 'err... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119032",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20277987/"
] |
74,119,058 | <p>I've been trying to set up on JavaFX in VSCode. I added the JavaFX jar files to the referenced libraries and added the following statement to <code>launch.json</code> (obviously with my path to the lib folder):</p>
<pre class="lang-json prettyprint-override"><code>"vmArgs": "--module-path \"C:/path/to/javafx-sdk-19/lib\" --add-modules javafx.controls,javafx.fxml"
</code></pre>
<p>This is exactly what multiple youtube videos and other StackOverflow posts have said to do, but I still keep getting this error.</p>
<p>(I know that I can use Maven or Gradle in VScode but am completely unfamiliar with both and still want to try to make this work.)</p>
<p>Hopefully I didn't miss anything painfully obvious but thank you for any help.</p>
| [
{
"answer_id": 74119578,
"author": "fauzimh",
"author_id": 2361379,
"author_profile": "https://Stackoverflow.com/users/2361379",
"pm_score": 0,
"selected": false,
"text": "find ./Documents/ -type f \\( -name \"*.out\" -o -name \"*.err\" \\) -exec sh -c \"grep 'out' {} >> file1; grep 'err... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119058",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20277986/"
] |
74,119,074 | <p>I am new to flutter world</p>
<p>I tried to direct the `TextFormField in this way, and this error in the title appeared</p>
<p>I want to use Directionality <code>textDirection: TextDirection.rtl</code>,</p>
<p>but this what happened</p>
<pre><code>Widget _buildName() {
Directionality(
textDirection: TextDirection.rtl,
child: TextFormField(
textAlign: TextAlign.right,
decoration: InputDecoration(labelText: 'الاسم', hintText: 'أدخل اسمك'),
maxLength: 10,
validator: (String? value) {
if (value!.isEmpty) {
return 'يجب أن لا يكون الحقل فارغًا';
}
return null;
},
onSaved: (String? value) {
_name = value;
},
));
}
</code></pre>
| [
{
"answer_id": 74119578,
"author": "fauzimh",
"author_id": 2361379,
"author_profile": "https://Stackoverflow.com/users/2361379",
"pm_score": 0,
"selected": false,
"text": "find ./Documents/ -type f \\( -name \"*.out\" -o -name \"*.err\" \\) -exec sh -c \"grep 'out' {} >> file1; grep 'err... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119074",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13925240/"
] |
74,119,081 | <p><img src="https://i.stack.imgur.com/CWZoN.png" alt="enter image description here" />
I want a layout like this. ⬆️</p>
<p><img src="https://i.stack.imgur.com/Y8qdc.png" alt="enter image description here" />
But it's only like this layout...⬆️</p>
<p>The code I worked on is this</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-css lang-css prettyprint-override"><code>.grid-container {
width: 100%;
display: grid;
grid-template-columns: 1fr 1fr 1fr;
gap: 16px;
grid-gap: 16px;
}
.grid-item {
width: 100%;
height: 30px;
border: 1px solid black;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="grid-container">
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
<div class="grid-item"></div>
</div></code></pre>
</div>
</div>
</p>
<p>Are there any more properties I need to add to the <code>.grid-container</code> class?</p>
| [
{
"answer_id": 74119578,
"author": "fauzimh",
"author_id": 2361379,
"author_profile": "https://Stackoverflow.com/users/2361379",
"pm_score": 0,
"selected": false,
"text": "find ./Documents/ -type f \\( -name \"*.out\" -o -name \"*.err\" \\) -exec sh -c \"grep 'out' {} >> file1; grep 'err... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119081",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16090820/"
] |
74,119,101 | <p>At the moment my program creates a new log file every hour with file name as current date and current hour.</p>
<p><a href="https://i.stack.imgur.com/Fi909.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Fi909.png" alt="enter image description here" /></a></p>
<p>There are two disadvantages</p>
<ol>
<li><p>For instance, I run the program for 3 hours and 20 minutes and want to have the csv log data of that duration in a single file, but with the present logic it creates 4 separate csv files.</p>
</li>
<li><p>If the end of the previous session and start of the new session happens to be within the same hour, even though I want to have the separate csv log data of the new session, it just appends to the existing file.</p>
</li>
</ol>
<p>Is there any way that I can get rid of these two issues but at the same time keeping the file name as I am doing now?</p>
<pre><code>outputFilePath = csv_directory + CurrentDate + "\\" + CurrentDate + "_" + CurrentHour + ".csv";
if (File.Exists(outputFilePath) == false)
{
using (System.IO.StreamWriter file = new System.IO.StreamWriter(outputFilePath, true))
{
// Write File
// Column Header
// Data
}
}
else if (File.Exists(outputFilePath))
{
using (System.IO.StreamWriter file = new System.IO.StreamWriter(outputFilePath, true))
{
// Write File
// Data
}
}
</code></pre>
| [
{
"answer_id": 74119511,
"author": "jmcilhinney",
"author_id": 584183,
"author_profile": "https://Stackoverflow.com/users/584183",
"pm_score": 1,
"selected": false,
"text": "Main"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119101",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19549399/"
] |
74,119,123 | <p>I have 10,000 files(molecule1.pdbqt ... molecule10000.pdbqt). Only some of them contains second occurrence of a keyword <strong>TORSDOF</strong>. For a given file, I want to remove all lines following the second occurrence, if there, including the line containing the second occurrence of keyword <strong>TORSDOF</strong>, while preserving the file names. Can somebody please provide a sample snippet, if possible without loop(s). Thank you.</p>
<pre><code>$ cat inputExample.txt
ashu
vishu
jyoti
TORSDOF
Jatin
Vishal
Shivani
TORSDOF
Sushil
Kiran
</code></pre>
<pre><code>$ cat outputExample.txt
ashu
vishu
jyoti
TORSDOF
Jatin
Vishal
Shivani
</code></pre>
| [
{
"answer_id": 74119511,
"author": "jmcilhinney",
"author_id": 584183,
"author_profile": "https://Stackoverflow.com/users/584183",
"pm_score": 1,
"selected": false,
"text": "Main"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119123",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15188937/"
] |
74,119,133 | <p>Using cli to deploy the application. I've used several versions of nodes, operating systems, command lines: both shell and terminal but this error persists. I've already uploaded and downloaded the @ui5/cli version, at the moment I'm debugging inside the lib to see if I can find a light.</p>
<p>ui5/cli version 2.14.12</p>
<p>node version v16.17.1</p>
<p>ui5-azure-devops.yaml</p>
<pre><code>specVersion: '2.2'
metadata:
name: "ts.ui5"
resources:
configuration:
propertiesFileSourceEncoding: UTF-8
type: library
builder:
customTasks:
- name: deploy-to-abap
afterTask: uglify
configuration:
target:
url: env:UI5_HOST
client: env:UI5_CLIENT
auth: basic
credentials:
username: env:UI5_USERNAME
password: env:UI5_PASSWORD
app:
name: /SPROTS/LIBUI5
package: /SPROTS/TS_FIORI
transport: env:UI5_REQUEST
</code></pre>
<p>package.json</p>
<pre><code>{
"name": "ts.ui5",
"version": "1.0.0",
"private": true,
"devDependencies": {
"@sap/di.code-validation.js": "1.1.6",
"@sap/di.code-validation.xml": "1.1.16",
"@sap/ux-ui5-tooling": "^1.6.7",
"@ui5/builder": "^2.11.6",
"@ui5/fs": "^2.0.6",
"@ui5/logger": "^2.0.1",
"bower": "^1.8.0",
"grunt": "1.0.1",
"grunt-contrib-clean": "^1.0.0",
"grunt-contrib-connect": "^1.0.2",
"grunt-contrib-copy": "^1.0.0",
"grunt-eslint": "^20.0.0",
"grunt-karma": "^1.0.0",
"grunt-openui5": "^0.12.0",
"grunt-run": "0.8.1",
"karma": "^6.3.4",
"karma-chrome-launcher": "^3.1.0",
"karma-cli": "^2.0.0",
"karma-coverage": "^2.0.3",
"karma-jasmine": "^4.0.1",
"karma-junit-reporter": "^2.0.1",
"karma-openui5": "~0.2.3",
"karma-phantomjs-launcher": "^1.0.4",
"karma-qunit": "^1.2.1",
"karma-sinon": "^1.0.5",
"karma-ui5": "^2.3.4",
"puppeteer": "^10.2.0",
"qunit": "^2.16.0",
"qunitjs": "^2.0.0",
"rimraf": "3.0.2",
"ui5-middleware-code-coverage": "^2.0.3",
"ui5-middleware-livereload": "^0.5.1",
"ui5-task-zipper": "^0.5.1"
},
"main": "Gruntfile.js",
"scripts": {
"clean": "rm -rf dist",
"build": "rimraf dist && ui5 build -a --include-task=generateManifestBundle generateCachebusterInfo",
"build-for-deploy": "npm run build && npm run flatten && npm run clean-after-flatten",
"flatten": "cp -r dist/resources/com/sprots/libui5/* dist && cp dist/resources/com/sprots/libui5/.library dist && cp dist/resources/.Ui5RepositoryTextFiles dist",
"clean-after-flatten": "rm -rf dist/resources dist/test-resources",
"testsuite": "ui5 serve --open test-resources/qunit/testsuite.qunit.html",
"deploy-azure-devops": "ui5 build --config ui5-azure-devops.yaml -- -y --verbose",
"test": "karma start",
"unit-tests": "fiori run --open test/unit/unitTests.qunit.html",
"int-tests": "fiori run --open test/integration/opaTests.qunit.html"
},
"ui5": {
"dependencies": [
"ui5-middleware-livereload",
"ui5-middleware-code-coverage",
"@sap/ux-ui5-tooling",
"ui5-task-zipper"
]
},
"license": "UNLICENSED",
"dependencies": {
"@openui5/sap.ui.core": "1.60.*",
"@openui5/themelib_sap_belize": "1.60.*",
"@sap/ux-specification": "^1.102.4"
}
}
</code></pre>
<p>command: npm run deploy-azure-devops</p>
<p>error:</p>
<pre><code>2.3896516Z verb resources:adapters:Memory Writing to virtual path /resources/com/ts/libui5/controls/Price.js
2022-10-19T01:28:42.3900887Z verb resources:adapters:Memory Writing to virtual path /resources/com/ts/libui5/controls/Util.js
2022-10-19T01:28:42.3908566Z verb resources:adapters:Memory Writing to virtual path /resources/com/ts/libui5/controls/Payments.js
2022-10-19T01:28:42.3912429Z verb resources:adapters:Memory Writing to virtual path /resources/com/ts/libui5/controls/FreeChars.js
2022-10-19T01:28:42.3915881Z verb resources:adapters:Memory Writing to virtual path /resources/com/ts/libui5/controls/Decimals.js
2022-10-19T01:28:42.3919245Z verb resources:adapters:Memory Writing to virtual path /resources/com/ts/libui5/library.js
2022-10-19T01:28:42.3924201Z info builder:builder library ts.ui5 (10/10) Running task deploy-to-abap...
2022-10-19T01:28:42.3931619Z ERR! builder:builder Build failed in 710 ms
2022-10-19T01:28:42.3937076Z info builder:builder Executing cleanup tasks...
2022-10-19T01:28:42.3973034Z
2022-10-19T01:28:42.3978473Z ⚠️ Process Failed With Error
2022-10-19T01:28:42.3978901Z
2022-10-19T01:28:42.3981344Z Error Message:
2022-10-19T01:28:42.3982236Z task is not a function
2022-10-19T01:28:42.3982345Z
2022-10-19T01:28:42.3982552Z Stack Trace:
2022-10-19T01:28:42.3986007Z TypeError: task is not a function
2022-10-19T01:28:42.3986429Z at execTask (/opt/hostedtoolcache/node/16.17.1/x64/lib/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/types/AbstractBuilder.js:140:12)
2022-10-19T01:28:42.3987013Z at /opt/hostedtoolcache/node/16.17.1/x64/lib/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/types/AbstractBuilder.js:242:11
2022-10-19T01:28:42.3987547Z at async Object.build (/opt/hostedtoolcache/node/16.17.1/x64/lib/node_modules/@ui5/cli/node_modules/@ui5/builder/lib/builder/builder.js:404:4)
2022-10-19T01:28:42.3988105Z at async Object.handleBuild [as handler] (/opt/hostedtoolcache/node/16.17.1/x64/lib/node_modules/@ui5/cli/lib/cli/commands/build.js:153:2)
2022-10-19T01:28:42.3988810Z
2022-10-19T01:28:42.3989614Z If you think this is an issue of the UI5 Tooling, you might report it using the following URL: https://github.com/SAP/ui5-tooling/issues/new/choose
2022-10-19T01:28:42.4315991Z ##[error]Bash exited with code '1'.
</code></pre>
| [
{
"answer_id": 74119511,
"author": "jmcilhinney",
"author_id": 584183,
"author_profile": "https://Stackoverflow.com/users/584183",
"pm_score": 1,
"selected": false,
"text": "Main"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119133",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3724613/"
] |
74,119,135 | <p>So I am programming a Poker game im C++ and first it was done with terminal only where I would get the input from <code>cin</code> (check or fold or ...) and program reacts based on the input in a <code>while(true)</code> loop.</p>
<p>Now I want to do the same in Qt with GUI where after clicking 'start' the game is created and then in a <code>while(true)</code> loop we are waiting for a signal of fold or check or raise or call button and we react based on that.
How can I implement this? Basically:</p>
<pre class="lang-cpp prettyprint-override"><code>while (true) {
If (signal== button-fold) // do a;
else if (signal == button-check ) // do b;
}
</code></pre>
| [
{
"answer_id": 74123571,
"author": "Kupofty",
"author_id": 12134984,
"author_profile": "https://Stackoverflow.com/users/12134984",
"pm_score": 1,
"selected": false,
"text": "void GUI::on_pushButton_function1_clicked()\n{\n emit function1_asked();\n}\n"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119135",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15673997/"
] |
74,119,197 | <p>Combining Series into DataFrames
Using the aud_usd_lst and eur_aud_lst lists defined in the scaffold on the right, perform the following tasks:</p>
<ol>
<li>Create a series named aud_usd_series with non-missing quotes for the AUD/USD exchange rate. Specifically:</li>
</ol>
<p>The series should have dates as row labels. There should be no missing AUD/USD values.</p>
<ol start="2">
<li>Create a series named eur_aud_series with non-missing quotes for the EUR/AUD exchange rate. Specifically:</li>
</ol>
<p>The series should have dates as row labels. There should be no missing EUR/AUD values.</p>
<ol start="3">
<li>Combine the two series into a data frame named df, so it has the dates as row labels and 'AUD/USD', 'EUR/AUD' as column labels.</li>
</ol>
<pre class="lang-py prettyprint-override"><code>import pandas as pd
import numpy as np
from unanswered import *
aud_usd_lst = [
('2020-09-08', 0.7280),
('2020-09-09', 0.7209),
('2020-09-11', 0.7263),
('2020-09-14', 0.7281),
('2020-09-15', 0.7285),
]
eur_aud_lst = [
('2020-09-08', 1.6232),
('2020-09-09', 1.6321),
('2020-09-10', 1.6221),
('2020-09-11', 1.6282),
('2020-09-15', 1.6288),
]
</code></pre>
<p>Here is my Code:</p>
<pre class="lang-py prettyprint-override"><code>aud_usd_series = pd.Series(np.array(aud_usd_lst)[:,1], index=np.array(aud_usd_lst)[:,0])
aud_usd_series
eur_aud_series = eur_aud_series = pd.Series(np.array(eur_aud_lst)[:,1], index=np.array(eur_aud_lst)[:,0])
eur_aud_series
df = pd.DataFrame([aud_usd_series,eur_aud_series]).T
df.columns = ['AUD/USD','EUR/AUD']
df
</code></pre>
<p>I tried to run the code and it says</p>
<blockquote>
<p>TypeError: unsupported operand type(s) for -: 'float' and 'str'</p>
</blockquote>
<p>ANY Suggestion?</p>
| [
{
"answer_id": 74119586,
"author": "Josh",
"author_id": 20201963,
"author_profile": "https://Stackoverflow.com/users/20201963",
"pm_score": 1,
"selected": false,
"text": " date aud/usd eur/aud\n0 2020-09-08 0.7280 1.6232\n1 2020-09-09 0.7209 1.6321\n2 2020-09-11 0.... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119197",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20165694/"
] |
74,119,207 | <p>The C# 6 Language Specification (ECMA-334 6th ed.) section 6.2.3 states:</p>
<blockquote>
<p>If there is an explicit reference conversion from S to T
then there is an explicit reference conversion from S[ ] to IList<T>
and its base interfaces...</p>
</blockquote>
<p>However, the following doesn't compile for C# 10.x in VS 2022 (17.3.6) for .NET 6.0:</p>
<pre><code>private const int LENGTH = 4;
public class Source { }
public class Target { public static explicit operator Target(Source _) => new Target(); }
static void Main()
{
_ = (Target)new Source(); // Ok
_ = (IList<Target>)new Source[LENGTH]; // Error, can't convert Source[] to IList<Target>
}
</code></pre>
<p>The compiler emits:</p>
<blockquote>
<p>error CS0030: Cannot convert type 'stack_overflow.Program.Source[]' to 'System.Collections.Generic.IList<stack_overflow.Program.Target>'</p>
</blockquote>
| [
{
"answer_id": 74130360,
"author": "K. L.",
"author_id": 8044088,
"author_profile": "https://Stackoverflow.com/users/8044088",
"pm_score": 2,
"selected": true,
"text": "user-defined conversion"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119207",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1608430/"
] |
74,119,216 | <p>This is my input data, which is stored in dataframe df.
<a href="https://i.stack.imgur.com/iwlb0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iwlb0.png" alt="Input" /></a></p>
<p>Now i want to change all the values in column B to Yearly format. Here is my code:</p>
<pre><code>D = []
for i in df['B']:
for j in df['C']:
if j == 'Year':
D.append(int(i)/1)
elif j == 'Month':
D.append(int(i)/12)
elif j == 'Day':
D.append(int(i)/365)
print(len(df))
print(len(D))
</code></pre>
<p>While my original df only has len of 10, the output (list D) has len of 100. Anyone knows how to fix the issue here?</p>
| [
{
"answer_id": 74119245,
"author": "BENY",
"author_id": 7964527,
"author_profile": "https://Stackoverflow.com/users/7964527",
"pm_score": 1,
"selected": false,
"text": "map"
},
{
"answer_id": 74119271,
"author": "Raibek",
"author_id": 11040577,
"author_profile": "http... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19725432/"
] |
74,119,244 | <p>I'm trying to map a fixed set of ASCII characters to a fixed set of Unicode characters. I.e., for each digit 0-9, I want to get the circled digit equivalent.</p>
<pre><code>mapFrom="0123456789"
mapTo="➀➁➂➃➄➅➆➇➈"
today=20221018
#convert to "➁➁➁➀➀➇"
todayWithCircles=$(do_something_here) # <-- what's the "something"?
echo $todayWithCircles
# output: ➁➁➁➀➀➇
</code></pre>
<p>Given two fixed strings of equal length, what is the easiest way to map them-- based on their position in the string-- as described?</p>
| [
{
"answer_id": 74119775,
"author": "Shawn",
"author_id": 9952196,
"author_profile": "https://Stackoverflow.com/users/9952196",
"pm_score": 4,
"selected": true,
"text": "perl"
},
{
"answer_id": 74126409,
"author": "Unamata Sanatarai",
"author_id": 2119863,
"author_prof... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119244",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1024832/"
] |
74,119,247 | <p>I was looking to find how many times the phrase "X-DSPAM-Confidence:" shows up in a file and couldn't figure out why my code wasn't working.
I needed to strip the file to only show the lines that contained that phrase, and, in addition, count how many times that phrase shows up.
My code was able to strip it properly, but did not count the amount of times the phrase showed up. If anyone could help me figure out what I did wrong with my code that would be greatly appreciated.</p>
<p><a href="https://i.stack.imgur.com/F5P01.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F5P01.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74119775,
"author": "Shawn",
"author_id": 9952196,
"author_profile": "https://Stackoverflow.com/users/9952196",
"pm_score": 4,
"selected": true,
"text": "perl"
},
{
"answer_id": 74126409,
"author": "Unamata Sanatarai",
"author_id": 2119863,
"author_prof... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119247",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20278204/"
] |
74,119,253 | <p>below is output of the "RESULT":</p>
<pre><code>stdout:
- |-
ospf T1 VRF vrf1
ospf T2 VRF vrf2
ospf T3 VRF vrf3
stdout_lines:
- ospf T1 VRF vrf1
- ospf T2 VRF vrf2
- ospf T3 VRF vrf3
</code></pre>
<p>I want output in list and in dictionary:</p>
<p>1st output will be list. list will have following:</p>
<pre><code> - T1
- T2
- T3
</code></pre>
<p>2nd output will be list like below:</p>
<pre><code>ospf_vrf:
- vrf: vrf1
process: T1
- vrf: vrf2
process: T2
- vrf: vrf3
process: T3
</code></pre>
<p>3rd output will be dictionary.</p>
<p>how to do that?</p>
| [
{
"answer_id": 74120359,
"author": "Prasad Patil",
"author_id": 19977062,
"author_profile": "https://Stackoverflow.com/users/19977062",
"pm_score": 0,
"selected": false,
"text": "- hosts: localhost\n gather_facts: no\n vars:\n stdout_lines:\n - ospf T1 VRF vrf1\n - ospf T2... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119253",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17314281/"
] |
74,119,260 | <p>I'm programming a code where I use a matrix full of 0's and 1's, the idea is to represent a galaxy, so the 0's are like the void and the 1's will be solar systems (for now), later I intend to add more elements. So, I was wondering if there's a way to plot this elements sorta like a heat map (1 = red and 0 = blue). I'd appreciate any ideas or suggestions if you think there's a better way to pose the problem. Thanks in advance!</p>
| [
{
"answer_id": 74119287,
"author": "Flow",
"author_id": 14121161,
"author_profile": "https://Stackoverflow.com/users/14121161",
"pm_score": 1,
"selected": false,
"text": "plt.imshow"
},
{
"answer_id": 74146423,
"author": "amance",
"author_id": 17142551,
"author_profil... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119260",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12101114/"
] |
74,119,274 | <p>The code case is from rustlings 'quiz2.rs'. I known command in ‘for(string,command)’ is borrowed from vector iterator. The command is borrowed, but why the 'n' Append(n) is also borrowed?</p>
<pre class="lang-rust prettyprint-override"><code> pub fn transformer(input: Vec<(String, Command)>) -> Vec<String> {
// TODO: Complete the output declaration!
let mut output: Vec<String> = vec![];
for (string, command) in input.iter() {
// TODO: Complete the function body. You can do it!
match command {
Command::Uppercase => output.push(string.to_uppercase()),
Command::Trim => output.push(string.trim().to_string()),
Command::Append(n) => {
let can_mv_str = string.to_string() + &"bar".repeat(*n);
output.push(can_mv_str);
}
}
}
output
}
</code></pre>
| [
{
"answer_id": 74119909,
"author": "Kushagra Gupta",
"author_id": 9184849,
"author_profile": "https://Stackoverflow.com/users/9184849",
"pm_score": 2,
"selected": false,
"text": "ref"
},
{
"answer_id": 74119946,
"author": "Kevin Reid",
"author_id": 99692,
"author_prof... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2356917/"
] |
74,119,280 | <p>Given the following table with one column storing a unique identifier (<em>user_id</em> column) and four binary columns (<em>col1</em> to col_4_):</p>
<pre>
import pandas as pd
df = pd.DataFrame.from_dict({
'id': ['a', 'b', 'c', 'd', 'e']
,'col1': [1,1,0,1,0]
,'col2': [0,1,1,1,1]
,'col3': [0,0,1,0,0]
,'col4': [0,0,1,1,1]
})
</pre>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: center;">user_id</th>
<th style="text-align: center;">col1</th>
<th style="text-align: center;">col2</th>
<th style="text-align: center;">col3</th>
<th style="text-align: center;">col4</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">a</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">0</td>
</tr>
<tr>
<td style="text-align: center;">b</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">0</td>
</tr>
<tr>
<td style="text-align: center;">c</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">1</td>
</tr>
<tr>
<td style="text-align: center;">d</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">1</td>
</tr>
<tr>
<td style="text-align: center;">e</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">1</td>
<td style="text-align: center;">0</td>
<td style="text-align: center;">1</td>
</tr>
</tbody>
</table>
</div>
<p>How can I create an output table that shows how many user_ids had co-occurrence pairs of the binary columns?</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: center;">co-occurrence pair</th>
<th style="text-align: center;">count of user_id</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: center;">col1-col2</td>
<td style="text-align: center;">2</td>
</tr>
<tr>
<td style="text-align: center;">col1-col3</td>
<td style="text-align: center;">0</td>
</tr>
<tr>
<td style="text-align: center;">col1-col4</td>
<td style="text-align: center;">1</td>
</tr>
<tr>
<td style="text-align: center;">col2-col3</td>
<td style="text-align: center;">1</td>
</tr>
<tr>
<td style="text-align: center;">col2-col4</td>
<td style="text-align: center;">3</td>
</tr>
<tr>
<td style="text-align: center;">col3-col4</td>
<td style="text-align: center;">1</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74119372,
"author": "Raibek",
"author_id": 11040577,
"author_profile": "https://Stackoverflow.com/users/11040577",
"pm_score": 0,
"selected": false,
"text": "df_output = pd.DataFrame({\"co-occurrence pair\": [f\"{df.columns[i]}-{df.columns[j]}\" for i in range(1, len(df.co... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119280",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15856795/"
] |
74,119,286 | <p>I am currently trying to develop a prototype using jQuery that makes a whole stack of cards draggable within the window once dealt. I am noticing that the entire stack is not getting the <code>class=ui.draggable</code> property within my console on my website. I am not sure as to why only some of these cards within the array would be getting the property seemingly at random each time. Would appreciate any feedback on this!</p>
<pre><code>$('#deal').click(function () {
dealCard(randomCard());
});
$( function init() {
$(".drop").droppable( { drop: dropCard } );
} );
function dropCard(event, ui) {
$('#drop').html( 'The card "' + ui.draggable.attr('id') + '" was dropped.' );
}
var cardsInDeck = new Array();
var numberOfCardsInDeck = 51;
cardsInDeck[0] = "ClubAce";
cardsInDeck[1] = "Clubs2";
cardsInDeck[2] = "Clubs3";
cardsInDeck[3] = "Clubs4";
cardsInDeck[4] = "Clubs5";
cardsInDeck[5] = "Clubs6";
cardsInDeck[6] = "Clubs7";
cardsInDeck[7] = "Clubs8";
cardsInDeck[8] = "Clubs9";
cardsInDeck[9] = "Clubs10";
cardsInDeck[10] = "ClubsJack";
cardsInDeck[11] = "ClubsKing";
cardsInDeck[12] = "ClubsQueen";
cardsInDeck[13] = "DiamondsAce";
cardsInDeck[14] = "Diamonds2";
cardsInDeck[15] = "Diamonds3";
cardsInDeck[16] = "Diamonds4";
cardsInDeck[17] = "Diamonds5";
cardsInDeck[18] = "Diamonds6";
cardsInDeck[19] = "Diamonds7";
cardsInDeck[20] = "Diamonds8";
cardsInDeck[21] = "Diamonds9";
cardsInDeck[22] = "Diamonds10";
cardsInDeck[23] = "DiamondsQueen";
cardsInDeck[24] = "DiamondsJack";
cardsInDeck[25] = "DiamondsKing";
cardsInDeck[26] = "HeartsAce";
cardsInDeck[27] = "Hearts2";
cardsInDeck[28] = "Hearts3";
cardsInDeck[29] = "Hearts4";
cardsInDeck[30] = "Hearts5";
cardsInDeck[31] = "Hearts6";
cardsInDeck[32] = "Hearts7";
cardsInDeck[33] = "Hearts8";
cardsInDeck[34] = "Hearts9";
cardsInDeck[35] = "Hearts10";
cardsInDeck[36] = "HeartsJack";
cardsInDeck[37] = "HeartsKing";
cardsInDeck[38] = "HeartsQueen";
cardsInDeck[39] = "SpadesAce";
cardsInDeck[40] = "Spades2";
cardsInDeck[41] = "Spades3";
cardsInDeck[42] = "Spades4";
cardsInDeck[43] = "Spades5";
cardsInDeck[44] = "Spades6";
cardsInDeck[45] = "Spades7";
cardsInDeck[46] = "Spades8";
cardsInDeck[47] = "Spades9";
cardsInDeck[48] = "Spades10";
cardsInDeck[49] = "SpadesJack";
cardsInDeck[50] = "SpadesQueen";
cardsInDeck[51] = "SpadesKing";
function dealCard(i) {
if (numberOfCardsInDeck === 0) return false;
var img = document.createElement("img");
img.setAttribute("id", cardsInDeck[i]);
img.setAttribute("height", "100px");
img.src ="../Cards/" + cardsInDeck[i] + ".png";
document.body.appendChild(img);
console.log(cardsInDeck[i]);
removeCard(i);
$("#" + cardsInDeck[i]).draggable({ containment: 'document' });
}
function randomCard() {
return Math.floor(Math.random() * numberOfCardsInDeck);
}
function removeCard(c)
{
for (j=c; j <= numberOfCardsInDeck - 2; j++)
{
cardsInDeck[j] = cardsInDeck[j+1];
}
numberOfCardsInDeck--;
}
</code></pre>
| [
{
"answer_id": 74119372,
"author": "Raibek",
"author_id": 11040577,
"author_profile": "https://Stackoverflow.com/users/11040577",
"pm_score": 0,
"selected": false,
"text": "df_output = pd.DataFrame({\"co-occurrence pair\": [f\"{df.columns[i]}-{df.columns[j]}\" for i in range(1, len(df.co... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119286",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13856917/"
] |
74,119,298 | <p>I'm teaching myself React (using v18.1.0) and I'm struggling to understand why I am getting an undefined object off the properties I'm passing to a component through a NavLink using react-router-dom v.6.3.0.</p>
<p>I have a component that has a NavLink that is created when a certain variable (let's call it "var1") is not null, like so:</p>
<pre><code>[...]
{
var1 != null
?
<NavLink className="Menu-Button" to={{pathname : "/Component1"}} state = {{ props : var1 }}>ButtonContent</NavLink>
: <p/>
}
[...]
</code></pre>
<p>The component being routed to (let's call it "Component1") looks like this:</p>
<pre><code>import React from 'react';
import {useLocation} from 'react-router-dom';
const Component1= () => {
const location = useLocation();
const { props } = location;
console.log(props);
return(
[...]
)
};
export default Component1;
</code></pre>
<p>The output of that console.log is <code>undefined</code>. I've also tried using props.location instead of useLocation(), but I get the same issue. Where am I going wrong?</p>
<p>EDIT:</p>
<p>Including route config in App.js as requested by @Nick Vu:
N.B. Toolbar is a component that acts as a header / navigator</p>
<pre><code>[all the imports]
const App = () => {
return (
<BrowserRouter>
<Toolbar />
<Routes>
[all the existing routes that work fine]
<Route exact path='/Component1' element={<Component1 /> } />
</Routes>
</BrowserRouter>
);
}
export default App;
</code></pre>
| [
{
"answer_id": 74119377,
"author": "Nick Vu",
"author_id": 9201587,
"author_profile": "https://Stackoverflow.com/users/9201587",
"pm_score": 1,
"selected": false,
"text": "NavLink"
},
{
"answer_id": 74119785,
"author": "WT_W",
"author_id": 190321,
"author_profile": "h... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119298",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/190321/"
] |
74,119,358 | <p>I am trying to find a way to make my code appear as text in HTML but in the way you see the code on here</p>
<p><code>I want my code to appear like this on the website</code></p>
<p>right now when I run the code, I got it to appear as text but it looks like this:</p>
<p><h1>"this is a heading"</h1></p>
<p>But I want it to look like this:</p>
<p><code><h1>"this is a heading"</h1></code></p>
<p>basically, I'm trying to get the code that appears on my website to look like I took a screenshot of the code editor and put it on the site</p>
<p>If you don't understand what I'm trying to ask please ask me and I will try to elaborate further</p>
| [
{
"answer_id": 74119377,
"author": "Nick Vu",
"author_id": 9201587,
"author_profile": "https://Stackoverflow.com/users/9201587",
"pm_score": 1,
"selected": false,
"text": "NavLink"
},
{
"answer_id": 74119785,
"author": "WT_W",
"author_id": 190321,
"author_profile": "h... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119358",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19866356/"
] |
74,119,375 | <p>Im trying to create one secret with multiple file in it.</p>
<p>My value.yaml ( the format of the multiline is not yaml or json)</p>
<pre><code>secretFiles:
- name: helm-template-file
subPath: ".file1"
mode: "0644"
value: |
This is a multiline
value, aka heredoc.
</code></pre>
<p>Then my secret file template is secret.yaml:</p>
<pre><code>apiVersion: v1
kind: Secret
metadata:
name: {{ include "helm-template.fullname" . }}-file
namespace: {{ .Release.Namespace }}
labels:
app: {{ include "helm-template.name" . }}
chart: {{ include "helm-template.chart" . }}
type: Opaque
stringData:
{{- range .Values.secretFiles }}
{{ .subPath}}: |
{{ .value | indent 4}}
{{- end }}
</code></pre>
<p>The helm install gives error "error converting YAML to JSON: yaml: line 12: did not find expected comment or line break". How can I fix it? Thank you.</p>
| [
{
"answer_id": 74120725,
"author": "z.x",
"author_id": 8871891,
"author_profile": "https://Stackoverflow.com/users/8871891",
"pm_score": 1,
"selected": false,
"text": "secretFiles:\n - name: helm-template-file\n subPath: \".file1\"\n mode: \"0644\"\n value: |\n This is a m... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119375",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19774614/"
] |
74,119,376 | <p>I am trying to do basic regex thing but still cannot figure it out. I need to remove the region number code and only get the number onwards. For example:</p>
<blockquote>
<p>(+60)123456789 --> 0123456789</p>
</blockquote>
<p>I have try using this regex expression <code>replace(/\D+/g, '')</code> but the number <code>6</code> from the region code still there which make it <code>60123456789</code></p>
| [
{
"answer_id": 74120725,
"author": "z.x",
"author_id": 8871891,
"author_profile": "https://Stackoverflow.com/users/8871891",
"pm_score": 1,
"selected": false,
"text": "secretFiles:\n - name: helm-template-file\n subPath: \".file1\"\n mode: \"0644\"\n value: |\n This is a m... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119376",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16085728/"
] |
74,119,390 | <p>I have this set with elements added in the given order.</p>
<pre><code> Set<String> nations = new HashSet<String>();
nations.add("Australia");
nations.add("Japan");
nations.add("Taiwan");
nations.add("Cyprus");
nations.add("Cuba");
nations.add("India");
</code></pre>
<p>When I print the record -</p>
<pre><code>for (String s : nations) {
System.out.print(s + " ");
}
</code></pre>
<p>It always gives this output in the order</p>
<pre><code>Cuba Cyprus Japan Taiwan Australia India
</code></pre>
<p>As far as I know a Set is not sorted by default, but why do I get the same result in a particular sorted manner?</p>
<hr />
<p>Update : Here is the actual question -</p>
<pre><code>public static Function<String,String> swap = s -> {
if(s.equals("Australia"))
return "New Zealand";
else
return s;
};
Set<String> islandNations = Set.of("Australia", "Japan", "Taiwan", "Cyprus", "Cuba");
islandNations = islandNations.stream()
.map(swap)
.map(n -> n.substring(0, 1))
.collect(Collectors.toSet());
for(String s : islandNations){
System.out.print(s);
}
</code></pre>
<p>and answers one of these</p>
<ul>
<li>CTJN</li>
<li>TJNC</li>
<li>TCNJ</li>
</ul>
| [
{
"answer_id": 74119756,
"author": "IamGroot",
"author_id": 8327330,
"author_profile": "https://Stackoverflow.com/users/8327330",
"pm_score": 0,
"selected": false,
"text": "//add method implementation for HashSet\n public boolean add(E e) {\n return map.put(e, PRESENT)==null;\n ... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2790466/"
] |
74,119,411 | <p>We have a client application (with logged in user) and daemon services (just API no users) accessing a Web API.</p>
<p>The Web API methods need to check users role claims and scopes before executing the operation.</p>
<pre><code>services.AddAuthorization(options =>
{
options.AddPolicy("AssetPolicy", policy =>
{
// checks the scope
policy.Requirements.Add(new ApiScopeRequirement("AssetServicFullScope"));
});
// checks the user's claim
policy.RequireClaim("AssetAdmin", true);
});
</code></pre>
<p>However, using this policy in the Web API would only allow access to the client app. The daemon app would fail because its access token not having user claims.</p>
<p>We use OpenIddict to implement the authentication server.</p>
<p>The question is what is the best way to allow authentication of both client apps and daemon apps using ASP.NET Core policies?</p>
| [
{
"answer_id": 74121355,
"author": "Michal Trojanowski",
"author_id": 1712294,
"author_profile": "https://Stackoverflow.com/users/1712294",
"pm_score": 1,
"selected": false,
"text": "services.AddAuthorization(options =>\n{\n options.AddPolicy(\"AssetPolicy\", policy =>\n policy... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10053379/"
] |
74,119,425 | <p>I have a dataframe with a series of months and each row contains a value of either 1 or 0.
How do I find the index of the first occurrence of 1 and the last occurrence of 1 ?</p>
<p>I thought about grouping all of the column together to create 1 row that just has a list of all the 0s and 1s and then enumerating over it to get the min and max values but I was getting stuck on grouping everything and putting it into a column</p>
<p>Here's a sample of my dataset:</p>
<pre><code> Jan 2020 Feb2020 March 2020 April 2020 May 2020
User1 1 0 0 0 0
User2 0 1 1 0 1
User 3 1 1 1 1 1
</code></pre>
<p>Id like my output to look like this:</p>
<pre><code> Jan 2020 Feb2020 March 2020 April 2020 May 2020 First_occurance Last Occurance
User1 1 0 0 0 0 1 1
User2 0 1 1 0 1 2 5
User 3 1 1 1 1 1 1 5
</code></pre>
| [
{
"answer_id": 74121355,
"author": "Michal Trojanowski",
"author_id": 1712294,
"author_profile": "https://Stackoverflow.com/users/1712294",
"pm_score": 1,
"selected": false,
"text": "services.AddAuthorization(options =>\n{\n options.AddPolicy(\"AssetPolicy\", policy =>\n policy... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14546482/"
] |
74,119,436 | <p>I don't know how to make this work. Does anyone know how to fix this? I have tried multiple different solutions, but they don't work
<div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function submit() {
var user = "test";
if (document.getElementById('#user').input = user) {
//what I need help on
}
}
function openForm() {
document.getElementById("myForm").style.display = "block";
}
function closeForm() {
document.getElementById("myForm").style.display = "none";
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><button class="open-button" onclick="openForm()">Open Form</button>
<div class="form-popup" id="myForm">
<form action="#" class="form-container">
<h1>Login</h1>
<label for="username"><b>username</b></label>
<input type="text" placeholder="username" id="username" name="username" required>
<button type="submit" onclick="submit()" class="btn">Login</button>
// And here
<button type="button" class="btn cancel" onclick="closeForm()">Close</button>
</form>
</div></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74121355,
"author": "Michal Trojanowski",
"author_id": 1712294,
"author_profile": "https://Stackoverflow.com/users/1712294",
"pm_score": 1,
"selected": false,
"text": "services.AddAuthorization(options =>\n{\n options.AddPolicy(\"AssetPolicy\", policy =>\n policy... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119436",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20278177/"
] |
74,119,452 | <p>I have a collection of restaurants where each document includes data such as the name, location, reviews, etc, and I'm attempting to push data which includes two reviews to the restaurant located in the borough of Brooklyn. This document happens to not currently have an array field of "reviews". According to everything I've looked at, the $push function should automatically add the array to the document, but it does not. Here is the code:</p>
<pre><code>db.restaurants.updateOne(
{ borough: 'Brooklyn' },
{
$push: {
reviews: {
$each: [
{
name: 'Frank Zappa',
date: 'January 3, 2019',
rating: 3,
comments: 'This restaurant is not good',
},
{
name: 'Freddie Mercury',
date: 'January 3, 2019',
rating: 5,
comments: 'This restaurant is my favorite',
},
],
},
},
}
);
</code></pre>
<p>The next command after this is to push the same reviews to another restaurant that does already have the array field "reviews", and also slice to 2. The only difference in code between these two is the filter and the slice modifier. The second works perfectly, the first does not.</p>
<p>Am I misunderstanding how push should work? Using push is a requirement in this case, though I did also try addToSet with the same</p>
| [
{
"answer_id": 74121355,
"author": "Michal Trojanowski",
"author_id": 1712294,
"author_profile": "https://Stackoverflow.com/users/1712294",
"pm_score": 1,
"selected": false,
"text": "services.AddAuthorization(options =>\n{\n options.AddPolicy(\"AssetPolicy\", policy =>\n policy... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119452",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20278398/"
] |
74,119,456 | <p>I have an array and want to get just object <strong>{ id: 4, name: 'name4' },</strong></p>
<pre><code>const example = [
{
id: '1234',
desc: 'sample1',
items: [
{ id: 1, name: 'name1' },
{ id: 2, name: 'testItem2' }
]
},
{
id: '3456',
desc: 'sample2',
items: [
{ id: 4, name: 'name4' },
{ id: 5, name: 'testItem5' }
]
},
</code></pre>
<p>I try in this way.</p>
<pre><code>const name = 'name4';
example.forEach((item) => item.items.find((i) => i.name === name));
</code></pre>
<p>But get undefined.</p>
| [
{
"answer_id": 74119537,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 3,
"selected": true,
"text": "const example = [\n {\n id: '1234',\n desc: 'sample1',\n items: [\n { id: 1, name: 'name1'... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119456",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13861133/"
] |
74,119,458 | <p>for understanding, here is my test work on github <a href="https://github.com/ALLADMINdotRU/PHONE.git" rel="nofollow noreferrer">https://github.com/ALLADMINdotRU/PHONE.git</a></p>
<p>There is an HTML form with a save button.</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>Configuring a MySQL database connection</title>
<meta charset="utf-8" />
</head>
<body>
<h1>Connect config</h1>
<form action="postMySQLconfigSave" method="POST">
<label>IP server address</label>
<input IPaddressServerMySQL="IPaddressServerMySQL" /><br><br>
<label>Login</label>
<input LoginMySQL="LoginMySQL" /><br><br>
<label>Password</label>
<input PasswordMySQL="PasswordMySQL" /><br><br>
<input type="submit" value="Save" />
</form>
<a href="/users">Back to user list</a>
</body>
<html>
</code></pre>
<p>when you click on the save button, the postMySQLconfigSave function should be executed</p>
<pre><code>const fs = require("fs");
exports.postMySQLconfigSave = function(request, response){
fs.writeFileSync("./config/MySQLconfig.txt", "Hello world") ; //
console.log("Here was the code");
response.send("About the site");
};
</code></pre>
<p>but it doesn't work, why?
Although if you just write the route to it in the address bar, then everything is OK</p>
<p>routes</p>
<pre><code>const express = require("express");
const сontrollerMySQL = require("../../controllers/MySQL/controllerMySQL.js");
const сontrollerMySQLconfig = require("../../controllers/MySQL/controllerMySQLconfig.js");
const routerMySQL = express.Router(); // определяем Router
// определяем маршруты и их обработчики внутри роутера homeRouter
//routerMySQL.get("/create", сontrollerMySQL.about);
//routerMySQL.get("/config", сontrollerMySQL.index);
routerMySQL.get("/error", сontrollerMySQL.error);
routerMySQL.get("/connect", сontrollerMySQL.connect);
routerMySQL.get("/test", сontrollerMySQL.test);
routerMySQL.get("/config", сontrollerMySQLconfig.config);
routerMySQL.get("/postMySQLconfigSave", сontrollerMySQLconfig.postMySQLconfigSave);
module.exports = routerMySQL; //делаем доступным наш результат снаружи
</code></pre>
| [
{
"answer_id": 74119537,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 3,
"selected": true,
"text": "const example = [\n {\n id: '1234',\n desc: 'sample1',\n items: [\n { id: 1, name: 'name1'... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20229118/"
] |
74,119,472 | <p>I have a table:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">Key</th>
<th style="text-align: center;">Sequence</th>
<th style="text-align: right;">Longitude</th>
<th style="text-align: right;">Latitude</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">1001</td>
<td style="text-align: center;">1</td>
<td style="text-align: right;">18.2</td>
<td style="text-align: right;">14.2</td>
</tr>
<tr>
<td style="text-align: left;">1001</td>
<td style="text-align: center;">2</td>
<td style="text-align: right;">18.2</td>
<td style="text-align: right;">14.2</td>
</tr>
<tr>
<td style="text-align: left;">1001</td>
<td style="text-align: center;">3</td>
<td style="text-align: right;">18.2</td>
<td style="text-align: right;">14.2</td>
</tr>
<tr>
<td style="text-align: left;">2001</td>
<td style="text-align: center;">1</td>
<td style="text-align: right;">25.6</td>
<td style="text-align: right;">22.8</td>
</tr>
<tr>
<td style="text-align: left;">2001</td>
<td style="text-align: center;">2</td>
<td style="text-align: right;">25.6</td>
<td style="text-align: right;">22.8</td>
</tr>
<tr>
<td style="text-align: left;">2001</td>
<td style="text-align: center;">3</td>
<td style="text-align: right;">25.6</td>
<td style="text-align: right;">22.8</td>
</tr>
<tr>
<td style="text-align: left;">5004</td>
<td style="text-align: center;">1</td>
<td style="text-align: right;">25.6</td>
<td style="text-align: right;">22.8</td>
</tr>
<tr>
<td style="text-align: left;">5004</td>
<td style="text-align: center;">2</td>
<td style="text-align: right;">25.6</td>
<td style="text-align: right;">22.8</td>
</tr>
<tr>
<td style="text-align: left;">5004</td>
<td style="text-align: center;">3</td>
<td style="text-align: right;">25.6</td>
<td style="text-align: right;">22.8</td>
</tr>
<tr>
<td style="text-align: left;">6895</td>
<td style="text-align: center;">1</td>
<td style="text-align: right;">36.2</td>
<td style="text-align: right;">17.4</td>
</tr>
<tr>
<td style="text-align: left;">6895</td>
<td style="text-align: center;">2</td>
<td style="text-align: right;">36.2</td>
<td style="text-align: right;">17.4</td>
</tr>
<tr>
<td style="text-align: left;">6895</td>
<td style="text-align: center;">3</td>
<td style="text-align: right;">36.2</td>
<td style="text-align: right;">17.4</td>
</tr>
<tr>
<td style="text-align: left;">6650</td>
<td style="text-align: center;">1</td>
<td style="text-align: right;">18.2</td>
<td style="text-align: right;">14.2</td>
</tr>
<tr>
<td style="text-align: left;">6650</td>
<td style="text-align: center;">2</td>
<td style="text-align: right;">18.2</td>
<td style="text-align: right;">14.2</td>
</tr>
<tr>
<td style="text-align: left;">6650</td>
<td style="text-align: center;">3</td>
<td style="text-align: right;">18.2</td>
<td style="text-align: right;">14.2</td>
</tr>
</tbody>
</table>
</div>
<p>From the table I need to find out the keys (different keys) that have duplicate longitude and latitude. If a key having any of sequence has duplicate longitude and latitude all the sequences of the same key should be shown duplicate. (comparison between same key sequences does not happen).</p>
<p>The output table should be:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th style="text-align: left;">Key</th>
<th style="text-align: center;">Sequence</th>
<th style="text-align: right;">Longitude</th>
<th style="text-align: right;">Latitude</th>
<th style="text-align: right;">Duplicate</th>
</tr>
</thead>
<tbody>
<tr>
<td style="text-align: left;">1001</td>
<td style="text-align: center;">1</td>
<td style="text-align: right;">18.2</td>
<td style="text-align: right;">14.2</td>
<td style="text-align: right;">No</td>
</tr>
<tr>
<td style="text-align: left;">1001</td>
<td style="text-align: center;">2</td>
<td style="text-align: right;">18.2</td>
<td style="text-align: right;">14.2</td>
<td style="text-align: right;">No</td>
</tr>
<tr>
<td style="text-align: left;">1001</td>
<td style="text-align: center;">3</td>
<td style="text-align: right;">18.2</td>
<td style="text-align: right;">14.2</td>
<td style="text-align: right;">No</td>
</tr>
<tr>
<td style="text-align: left;">2001</td>
<td style="text-align: center;">1</td>
<td style="text-align: right;">25.6</td>
<td style="text-align: right;">22.8</td>
<td style="text-align: right;">No</td>
</tr>
<tr>
<td style="text-align: left;">2001</td>
<td style="text-align: center;">2</td>
<td style="text-align: right;">25.6</td>
<td style="text-align: right;">22.8</td>
<td style="text-align: right;">No</td>
</tr>
<tr>
<td style="text-align: left;">2001</td>
<td style="text-align: center;">3</td>
<td style="text-align: right;">25.6</td>
<td style="text-align: right;">22.8</td>
<td style="text-align: right;">No</td>
</tr>
<tr>
<td style="text-align: left;">5004</td>
<td style="text-align: center;">1</td>
<td style="text-align: right;">25.6</td>
<td style="text-align: right;">22.8</td>
<td style="text-align: right;">Yes</td>
</tr>
<tr>
<td style="text-align: left;">5004</td>
<td style="text-align: center;">2</td>
<td style="text-align: right;">25.6</td>
<td style="text-align: right;">22.8</td>
<td style="text-align: right;">Yes</td>
</tr>
<tr>
<td style="text-align: left;">5004</td>
<td style="text-align: center;">3</td>
<td style="text-align: right;">25.6</td>
<td style="text-align: right;">22.8</td>
<td style="text-align: right;">Yes</td>
</tr>
<tr>
<td style="text-align: left;">6895</td>
<td style="text-align: center;">1</td>
<td style="text-align: right;">36.2</td>
<td style="text-align: right;">17.4</td>
<td style="text-align: right;">No</td>
</tr>
<tr>
<td style="text-align: left;">6895</td>
<td style="text-align: center;">2</td>
<td style="text-align: right;">36.2</td>
<td style="text-align: right;">17.4</td>
<td style="text-align: right;">No</td>
</tr>
<tr>
<td style="text-align: left;">6895</td>
<td style="text-align: center;">3</td>
<td style="text-align: right;">36.2</td>
<td style="text-align: right;">17.4</td>
<td style="text-align: right;">No</td>
</tr>
<tr>
<td style="text-align: left;">6650</td>
<td style="text-align: center;">1</td>
<td style="text-align: right;">18.2</td>
<td style="text-align: right;">14.2</td>
<td style="text-align: right;">Yes</td>
</tr>
<tr>
<td style="text-align: left;">6650</td>
<td style="text-align: center;">2</td>
<td style="text-align: right;">18.2</td>
<td style="text-align: right;">14.2</td>
<td style="text-align: right;">Yes</td>
</tr>
<tr>
<td style="text-align: left;">6650</td>
<td style="text-align: center;">3</td>
<td style="text-align: right;">18.2</td>
<td style="text-align: right;">14.2</td>
<td style="text-align: right;">Yes</td>
</tr>
</tbody>
</table>
</div> | [
{
"answer_id": 74119537,
"author": "flyingfox",
"author_id": 3176419,
"author_profile": "https://Stackoverflow.com/users/3176419",
"pm_score": 3,
"selected": true,
"text": "const example = [\n {\n id: '1234',\n desc: 'sample1',\n items: [\n { id: 1, name: 'name1'... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119472",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,119,478 | <p>In Excel, I have a list of strings that within the cells contain the name of a State. I then have a list of the States and I want to have a formula that is able to search the string for a State name and then give me the name of the State.</p>
<p>I've used nested <code>=IF(COUNTIF(A1,"*Florida*")=1,"Florida"...)</code> in the past for similar exercises but I don't want to create a version for all 50 States. Is there a way to do this combining some kind of INDEX MATCH?</p>
<p>Image below is a snippet of the kind of data. For the most part, the State name follows the year but not always and the suffix isn't always Invitational so there's no way to use those two to book-end the part of the string that contains the State.</p>
<p>Any help would be appreciated!</p>
<p><a href="https://i.stack.imgur.com/wyo7d.png" rel="nofollow noreferrer">example data</a></p>
| [
{
"answer_id": 74120573,
"author": "Mian",
"author_id": 8678077,
"author_profile": "https://Stackoverflow.com/users/8678077",
"pm_score": 0,
"selected": false,
"text": "=IF(ISNUMBER(VALUE(LEFT(A1,1))),MID(A1,FIND(\" \",A1)+1,\nFIND(\"~\", SUBSTITUTE(A1,\" \",\"~\",LEN(A1)-LEN(SUBSTITUTE(... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119478",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20278392/"
] |
74,119,483 | <p>in my application i have 'bottom sheet dialog fragment' when i open it, it work fine, like below image:</p>
<p><a href="https://i.stack.imgur.com/F6eAa.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/F6eAa.png" alt="Here is the image" /></a></p>
<p>but when keyboard is visible the upper toolbar disappear, like below image show.</p>
<p><a href="https://i.stack.imgur.com/DtVKw.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DtVKw.png" alt="Second image" /></a></p>
<p>My Question is how to make toolbar always visible even when keybord is visible....</p>
<p>Here is my '"sheet bottom xml"'</p>
<pre><code><RelativeLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
android:id="@+id/lyt_parent"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_marginBottom="10dp"
android:orientation="vertical">
<com.google.android.material.appbar.AppBarLayout
android:id="@+id/app_bar_layout"
android:layout_width="match_parent"
android:layout_height="?attr/actionBarSize"
android:layout_alignParentTop="true"
android:background="@color/grey_5"
android:fitsSystemWindows="true"
android:theme="@style/ThemeOverlay.AppCompat.Dark"
app:layout_scrollFlags="scroll|exitUntilCollapsed">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="match_parent"
android:gravity="center_horizontal"
android:orientation="horizontal">
<ImageButton
android:id="@+id/bt_close"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:layout_weight="1"
app:srcCompat="@drawable/ic_close"
app:tint="@color/grey_80" />
<ImageButton
android:id="@+id/save"
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:layout_weight="1"
app:srcCompat="@drawable/ic_bookmark_border"
app:tint="@color/grey_80" />
<ImageButton
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
android:layout_weight="1"
app:srcCompat="@drawable/ic_repeat"
app:tint="@color/grey_80" />
<ImageButton
android:layout_width="?attr/actionBarSize"
android:layout_height="?attr/actionBarSize"
app:srcCompat="@drawable/ic_more_vert"
app:tint="@color/grey_80" />
</LinearLayout>
</com.google.android.material.appbar.AppBarLayout>
<androidx.core.widget.NestedScrollView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_above="@+id/app_bar_layout2"
android:layout_below="@+id/app_bar_layout"
android:clipToPadding="false"
android:fillViewport="true"
android:scrollbars="none"
android:scrollingCache="true"
app:layout_behavior=
"@string/appbar_scrolling_view_behavior">
<LinearLayout
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:background="@android:color/white"
android:orientation="vertical"
android:padding="@dimen/spacing_large">
<androidx.recyclerview.widget.RecyclerView
android:id="@+id/bottom_sheet_recycler_comment"
android:layout_width="match_parent"
android:layout_height="wrap_content"
tools:itemCount="10" />
<LinearLayout
android:id="@+id/lyt_spacer"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:orientation="vertical"
android:visibility="gone">
<TextView
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:gravity="center_horizontal"
android:text="No comments yet"
android:textSize="22dp"
android:textStyle="bold" />
</LinearLayout>
</LinearLayout>
</androidx.core.widget.NestedScrollView>
<LinearLayout
android:id="@+id/app_bar_layout2"
android:layout_width="match_parent"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:clipToPadding="false"
android:paddingBottom="10dp"
android:scrollbars="none"
android:scrollingCache="true"
app:layout_anchorGravity="bottom|center">
<EditText
android:id="@+id/post_view_enter_comment_edit_Text"
android:layout_width="0dp"
android:layout_height="wrap_content"
android:layout_gravity="center"
android:layout_margin="4dp"
android:layout_marginEnd="5dp"
android:layout_weight="1"
android:background="@drawable/edit_text_round_bg"
android:hint="Write comment..."
android:lineSpacingExtra="2dp"
android:maxLength="400"
android:maxLines="5"
android:textColor="@color/black"
android:textSize="17sp"/>
<ImageView
android:id="@+id/post_view_send_comment"
android:layout_width="40dp"
android:layout_height="wrap_content"
android:layout_gravity="bottom"
android:layout_marginVertical="5dp"
android:layout_marginEnd="10dp"
android:background="@drawable/shape_circle"
android:backgroundTint="@color/blue_grey_300"
android:clickable="true"
android:padding="4dp"
android:paddingStart="6dp"
android:src="@android:drawable/ic_menu_send" />
</LinearLayout>
</RelativeLayout>
</code></pre>
<p>And also here my "BottomFragment.java".</p>
<pre><code> public class FragmentBottomSheetDialogFull extends
BottomSheetDialogFragment {
private BottomSheetBehavior mBehavior;
private AppBarLayout app_bar_layout;
private RelativeLayout parent_lyt;
private RecyclerView recyclerView;
TopicRecyclerAdapter adapter;
ArrayList<String> topicsArrayList, selectedArray;
ConstraintLayout sheet_constraint_layout;
private String Post_id;
private String content;
private String topic;
public void setData(String post_id, String post_content,
String topic) {
this.Post_id = post_id;
this.content = post_content;
this.topic = topic;
}
@NonNull
@Override
public Dialog onCreateDialog(Bundle savedInstanceState) {
final BottomSheetDialog dialog = (BottomSheetDialog)
super.onCreateDialog(savedInstanceState);
final View view = View.inflate(getContext(),
R.layout.fragment_bottom_sheet_dialog_full, null);
setStyle(DialogFragment.STYLE_NORMAL,
R.style.DialogStyle);
dialog.setContentView(view);
mBehavior = BottomSheetBehavior.from((View)
view.getParent());
mBehavior.setPeekHeight(BottomSheetBehavior.PEEK_HEIGHT_AUTO);
app_bar_layout = (AppBarLayout)
view.findViewById(R.id.app_bar_layout);
parent_lyt = (RelativeLayout)
view.findViewById(R.id.lyt_parent);
mBehavior.setMaxHeight((Tools.getScreenHeight() / 2) +
100);
recyclerView =
view.findViewById(R.id.bottom_sheet_recycler_comment);
topicsArrayList = new ArrayList<>();
selectedArray = new ArrayList<>();
for (int i = 0; i < 50; i++) {
topicsArrayList.add("my " + i);
}
adapter = new TopicRecyclerAdapter(topicsArrayList,
selectedArray);
recyclerView.setLayoutManager(new
LinearLayoutManager(getContext()));
recyclerView.setAdapter(adapter);
adapter.notifyDataSetChanged();
mBehavior.setBottomSheetCallback(new
BottomSheetBehavior.BottomSheetCallback() {
@Override
public void onStateChanged(@NonNull View
bottomSheet, int newState) {
if (BottomSheetBehavior.STATE_HIDDEN ==
newState) {
dismiss();
}
}
@Override
public void onSlide(@NonNull View bottomSheet,
float slideOffset) {
}
});
((ImageButton)
view.findViewById(R.id.bt_close)).setOnClickListener(new
View.OnClickListener() {
@Override
public void onClick(View v) {
dismiss();
}
});
return dialog;
}
@Override
public void onStart() {
super.onStart();
mBehavior.setState(BottomSheetBehavior.STATE_EXPANDED);
}
private void hideView(View view) {
ViewGroup.LayoutParams params = view.getLayoutParams();
params.height = 0;
view.setLayoutParams(params);
// dismiss();
// dismissAllowingStateLoss();
}
private void showView(View view, int size) {
ViewGroup.LayoutParams params = view.getLayoutParams();
params.height = size;
view.setLayoutParams(params);
}
private int getActionBarSize() {
final TypedArray styledAttributes =
getContext().getTheme().obtainStyledAttributes(new int[]
{android.R.attr.actionBarSize});
int size = (int) styledAttributes.getDimension(0, 0);
return size;
}
}
</code></pre>
<p>What exactly i seek to achieve is shown in this image, the toolbar is stable despite keyboard is visible or not.</p>
<p><a href="https://i.stack.imgur.com/zlaFR.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zlaFR.jpg" alt="third image" /></a></p>
<p>Thanks for any help</p>
| [
{
"answer_id": 74120573,
"author": "Mian",
"author_id": 8678077,
"author_profile": "https://Stackoverflow.com/users/8678077",
"pm_score": 0,
"selected": false,
"text": "=IF(ISNUMBER(VALUE(LEFT(A1,1))),MID(A1,FIND(\" \",A1)+1,\nFIND(\"~\", SUBSTITUTE(A1,\" \",\"~\",LEN(A1)-LEN(SUBSTITUTE(... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14727758/"
] |
74,119,489 | <p>I meet the question in OS course. <a href="https://pdos.csail.mit.edu/6.828/2019/lec/pointers.c" rel="nofollow noreferrer">Here</a> is the code from 6.828 (Operating System) online course. It meant to let learners practice the pointers in C programming language.</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
void
f(void)
{
int a[4];
int *b = malloc(16);
int *c;
int i;
printf("1: a = %p, b = %p, c = %p\n", a, b, c);
c = a;
for (i = 0; i < 4; i++)
a[i] = 100 + i;
c[0] = 200;
printf("2: a[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\n",
a[0], a[1], a[2], a[3]);
c[1] = 300;
*(c + 2) = 301;
3[c] = 302;
printf("3: a[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\n",
a[0], a[1], a[2], a[3]);
c = c + 1;
*c = 400;
printf("4: a[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\n",
a[0], a[1], a[2], a[3]);
c = (int *) ((char *) c + 1);
*c = 500;
printf("5: a[0] = %d, a[1] = %d, a[2] = %d, a[3] = %d\n",
a[0], a[1], a[2], a[3]);
b = (int *) a + 1;
c = (int *) ((char *) a + 1);
printf("6: a = %p, b = %p, c = %p\n", a, b, c);
}
int
main(int ac, char **av)
{
f();
return 0;
}
</code></pre>
<p>I copy it to a file and compile it use gcc , then I got this output:</p>
<pre><code>$ ./pointer
1: a = 0x7ffd3cd02c90, b = 0x55b745ec72a0, c = 0x7ffd3cd03079
2: a[0] = 200, a[1] = 101, a[2] = 102, a[3] = 103
3: a[0] = 200, a[1] = 300, a[2] = 301, a[3] = 302
4: a[0] = 200, a[1] = 400, a[2] = 301, a[3] = 302
5: a[0] = 200, a[1] = 128144, a[2] = 256, a[3] = 302
6: a = 0x7ffd3cd02c90, b = 0x7ffd3cd02c94, c = 0x7ffd3cd02c91
</code></pre>
<p>I can easily understand the output of 1,2,3,4. But it's hard for me to understand the output of 5. Specially why a[1] = 128144 and a[2] = 256?<br />
It seems this output is the result of</p>
<pre><code>c = (int *) ((char *) c + 1);
*c = 500;
</code></pre>
<p>I have trouble understand the function of the code <code>c = (int *) ((char *) c + 1)</code>.
<code>c</code> is a pointer by definiton <code>int *c</code>. And before the output of 5th line, c points to the second address of array <code>a</code> by <code>c = a</code> and <code>c = c + 1</code>. Now what's the meaning of <code>(char *) c</code> and <code>((char *) c + 1)</code> ,then <code>(int *) ((char *) c + 1)</code>?</p>
| [
{
"answer_id": 74119616,
"author": "user20278560",
"author_id": 20278560,
"author_profile": "https://Stackoverflow.com/users/20278560",
"pm_score": 0,
"selected": false,
"text": "((char *) c + 1) - c + 1 = &c[1]. c[0] + 1 = c[1] (first element of the array c+1).\n"
},
{
"answer_i... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119489",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15375162/"
] |
74,119,497 | <p>I have following local block, observe the <code>domain</code> key</p>
<pre><code>locals {
organization = "xxxx"
domain = "cs"
env = {
prod = "prod"
stg = "stg"
dev = "dev"
}
}
locals {
s3_artifact_bucket_name = {
prod = join("-", [
local.s3_artifact_bucket_name_prefix,
local.env["prod"]
])
stg = join("-", [
local.s3_artifact_bucket_name_prefix,
local.env["stg"]
])
dev = join("-", [
local.s3_artifact_bucket_name_prefix,
local.env["dev"]
])
}
s3_artifact_bucket_name_prefix = join("-", [
local.organization,
local.domain,
local.s3_bucket_awsresource,
local.s3_artifact_bucket_purpose
])
s3_bucket_awsresource = join("-", [
"bucket",
var.cd_account_id
])
s3_artifact_bucket_purpose = "artifacts-iac"
}
</code></pre>
<p>local.domain ( cs) is being used to create some another local name.</p>
<p>now I want to add another local block with same domain but different value ( as there are 3 values for domain ) and create another local name for s3 bucket with <code>common</code> as value inside it.</p>
<pre><code>locals {
# placeholder for access logs bucket name
domain = "common"
s3_bucket_awsresource = join("-", [
"bucket",
var.cd_account_id
])
s3_bucket_purpose = "s3-access-logs"
access_logs_bucket_region = "us-east-1"
}
</code></pre>
<p>here in the next step I want to reference local.domain as <code>common</code> and not <code>cs</code></p>
<pre><code>locals {
s3_artifact_access_logs_bucket_name = join("-", [local.organization, local.domain, s3_bucket_awsresource, local.s3_bucket_purpose, local.access_logs_bucket_region])
}
</code></pre>
<p>I am afraid <code>local.domain</code> will point out to which domain key and value? is there a way to use <code>domain</code> as key but with different value.</p>
| [
{
"answer_id": 74119613,
"author": "Ben Whaley",
"author_id": 2430241,
"author_profile": "https://Stackoverflow.com/users/2430241",
"pm_score": 3,
"selected": true,
"text": "local"
},
{
"answer_id": 74119622,
"author": "Călin Bogdan",
"author_id": 3953035,
"author_pro... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119497",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13126651/"
] |
74,119,534 | <p>I'm in the process of learning to become a better Flutter developer. I've taken a couple of intro courses on Udemy, and I've even built/released my first app.</p>
<p>While building my app, I realized I don't understand architecture.</p>
<p>My ultimate goal is to learn how to build apps as a professional developer would.</p>
<p>In the countless hours of research I've done, I've realized that professional developers:</p>
<ul>
<li>Separate code into layers (ie. Presentation, Domain, Data)</li>
<li>Write their own tests</li>
<li>Likely a list of other things I don't know yet
understand.</li>
</ul>
<p>While trying to learn these materials, I continually face the same problem. Every time I try to learn something new, I encounter something I don't understand.</p>
<p>For example, I might be trying to learn an architectural pattern, and out of the blue, I read terms like "dependency injection," "lazy singleton," or "repository." Because I have no idea what those things are, I get stuck.</p>
<p>I've tried to dig into the source code of professional apps, but it's way over my head. There's a massive gap between "I finished a couple of Udemy courses" and "I work as a senior engineer."</p>
<p>So, if you're an advanced developer, I have three questions.</p>
<ol>
<li>If you had to teach a complete beginner to become a professional flutter developer, what material would you have them learn?</li>
<li>What reputable resources would you use to teach each topic?</li>
<li>In what order would you teach the material—to ensure the student could understand each new topic?</li>
</ol>
<p>I know this is a broad question, so I'll narrow the scope. Ideally, I want to build apps like the team at Very Good Ventures does. For context, they use flutter_bloc, a Presentation, Domain, and Data type architecture (see picture), and write their own tests. And, as I mentioned above, likely a list of other things I don't yet understand :)</p>
<p><a href="https://i.stack.imgur.com/gDQjR.png" rel="nofollow noreferrer">Architecture Pattern</a></p>
<p>Finally, I know I probably sound lazy. I certainly could read a million articles in an attempt to piece everything together. But, ideally, I was hoping to find a more effective path. So, that's why I'm asking the experts.</p>
<p>Thank you for your time,</p>
<p>Chris</p>
| [
{
"answer_id": 74119613,
"author": "Ben Whaley",
"author_id": 2430241,
"author_profile": "https://Stackoverflow.com/users/2430241",
"pm_score": 3,
"selected": true,
"text": "local"
},
{
"answer_id": 74119622,
"author": "Călin Bogdan",
"author_id": 3953035,
"author_pro... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119534",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19056920/"
] |
74,119,547 | <p>I just want to understand why do we really need thread safety with collections? I know that if there are two threads and first thread is iterating over the collection and second thread is modifying the collection then first thread will get <code>ConcurrentModificationException</code>.</p>
<p>But then what if, if I know that none of my threads will iterate over the collection using an iterator, so does it means that thread safety is only needed because we want to allow other threads to iterator over the collection using an iterator? Are there any other reasons and usecases?</p>
| [
{
"answer_id": 74119792,
"author": "Louis Wasserman",
"author_id": 869736,
"author_profile": "https://Stackoverflow.com/users/869736",
"pm_score": 1,
"selected": false,
"text": "List.get"
},
{
"answer_id": 74124645,
"author": "talex",
"author_id": 3656904,
"author_pro... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119547",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5111394/"
] |
74,119,595 | <p>So suppose I have a document like:</p>
<pre><code>{
_id: 1,
items: ["aaa", "bbb", "ccc", "ddd", "eee"...]
}
</code></pre>
<p>I would like to shuffle the items list <strong>once</strong>, with this order saved in the table - i.e. I don't want to call random or something for every query, since there are about 200,000 items in this array (not huge, but still, calling $rand every time I want to retrieve an item would be inefficient)</p>
<p>So I'm really looking for some kind of manual script that I can run once - it would then update this document, so it became something like:</p>
<pre><code>{
_id: 1,
items: ["ddd", "bbb", "aaa", "eee", "ccc"...]
}
</code></pre>
<p>If anyone knows if this is possible, I'd appreciate it. Thanks</p>
<p>Otherwise, I'd probably fetch the data, shuffle it using another language, then save it back into Mongo</p>
| [
{
"answer_id": 74119792,
"author": "Louis Wasserman",
"author_id": 869736,
"author_profile": "https://Stackoverflow.com/users/869736",
"pm_score": 1,
"selected": false,
"text": "List.get"
},
{
"answer_id": 74124645,
"author": "talex",
"author_id": 3656904,
"author_pro... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119595",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16559296/"
] |
74,119,611 | <p>I have insert a couple of rows into Snowflake table, however it returns only date format.</p>
<pre><code>INSERT INTO usage (Customer_ID,
Movie_Name,
Movie_Genre,
Movie_Length,
Start_Time,
End_Time)
values (1234,
'Shrek',
'Kids',
2.52,
to_timestamp('12-31-2013 13:33','mm-dd-yyyy HH24:MI'),
to_timestamp('12-31-2013 16:04','mm-dd-yyyy HH24:MI')
);
</code></pre>
<p>Can someone tell me what's wrong?</p>
| [
{
"answer_id": 74119792,
"author": "Louis Wasserman",
"author_id": 869736,
"author_profile": "https://Stackoverflow.com/users/869736",
"pm_score": 1,
"selected": false,
"text": "List.get"
},
{
"answer_id": 74124645,
"author": "talex",
"author_id": 3656904,
"author_pro... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119611",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11233604/"
] |
74,119,650 | <p>I have a dictionary with <strong>2 keys</strong> for each distinct value. I need to get a list of only the first key - <strong>{'Stuck', 'on', 'problem'}</strong>.</p>
<p>test_dict = {('Stuck','a') : 1, ('on', 'b') : 2, ('problem','c') : 3}</p>
<p>I've some indexing but nothing seems to work. Also did not find any. specific solution to this online.</p>
| [
{
"answer_id": 74119693,
"author": "larsks",
"author_id": 147356,
"author_profile": "https://Stackoverflow.com/users/147356",
"pm_score": 1,
"selected": false,
"text": "test_dict = {('Stuck','a') : 1, ('on', 'b') : 2, ('problem','c') : 3}\n\nanswer = []\nfor key in test_dict:\n answer... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119650",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8556711/"
] |
74,119,662 | <p>In my blazor app,</p>
<pre><code>...
<td>
<input type="text" style="border:none;" @bind="todo.Title" />
</td>
...
</code></pre>
<p>How can I get access in the @code section of the text changed value and the todo item that is related to it? Is a "after change is bound to the todo" event I can hook into to?</p>
<p>Currently, I can get the change event and it has the changed value but I don't have access to the todo item related to it. Or I can get access to todo item but I don't have access to what the text changed value is.</p>
<pre><code>@page "/todo"
<pagetitle>Todo</pagetitle>
<h1>Todo (@todos.Count(todo => !todo.IsDone))</h1>
<table>
@foreach (var todo in todos)
{
<tr>
<td>
<input type="checkbox" @bind="todo.IsDone" />
</td>
<td>
<input type="text" style="border:none;" @bind="todo.Title" />
@todo.RsDisplay
</td>
</tr>
}
</table>
<input placeholder="Something todo" @bind="newTodo" />
<button @onclick="AddTodo">Add todo</button>
@code {
private List<TodoItem> todos = new();
private string? newTodo;
private void AddTodo()
{
if (!string.IsNullOrWhiteSpace(newTodo))
{
todos.Add(new TodoItem { Title = newTodo, RsDisplay = "test" });
newTodo = string.Empty;
}
}
}
</code></pre>
| [
{
"answer_id": 74119742,
"author": "user20278560",
"author_id": 20278560,
"author_profile": "https://Stackoverflow.com/users/20278560",
"pm_score": -1,
"selected": false,
"text": "@Ajax.ActionLink(\"click me\", \"Click\", new {}, new AjaxOptions()\n{\n HttpMethod = \"post\"\n})\n"
}... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/139698/"
] |
74,119,704 | <p>I am learning about the concept <code>interface</code> in Java, specifically about its inheritance with <code>class</code>. From what I understood, this is a basic code syntax for an interface inheritance</p>
<pre><code>interface one{
void funcOne();
}
class Test implements one{
@Override public void funcOne(){
System.out.println("this is one");
}
}
</code></pre>
<p>But when I removed the phrase <code>@Override</code>, the code still worked fine. So what is the purpose of using that keyword?</p>
<ul>
<li>My confusion adds up when testing with <code>static</code> methods. For instance the code below would throw an error</li>
</ul>
<pre><code>interface one{
static void funcOne(){
System.out.println("hello");
}
}
class Test implements one{
@Override static void funcOne() {
System.out.println("This is one");
}
}
</code></pre>
<p>But it would not throw an error when <code>@Override</code> is removed.</p>
<p>When should I use the keyword <code>@Override</code>, and what does it have to do with <code>static</code> functions?</p>
| [
{
"answer_id": 74120014,
"author": "Cary Zheng",
"author_id": 20275037,
"author_profile": "https://Stackoverflow.com/users/20275037",
"pm_score": 3,
"selected": true,
"text": "public String tostring() {\n return ...;\n}\n"
}
] | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119704",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13134578/"
] |
74,119,712 | <pre><code>select top 100 *
from ProductionPeriodic.dbo.ScanDataRaw
where sdr_ID in (
select concat(rsw_dept, rsw_rsm_id_fk)
from [dbo].[RollSheetArchiveDetails] rsad
inner join dbo.RollSheetMain rsm on rsad.rsw_rsm_id_fk = rsm.rsm_id
where rsw_PoNo = 'UHB800008'
and rsm_status = 'R'
)
and sdr_ScanDate = '30/09/2022'
</code></pre>
<p>sdr_ScanDate is a string.</p>
<p>There are two values concatenated.</p>
<p>However, the query does not stop executing</p>
| [
{
"answer_id": 74120173,
"author": "Axell Padilla",
"author_id": 7681703,
"author_profile": "https://Stackoverflow.com/users/7681703",
"pm_score": 0,
"selected": false,
"text": "select distinct concat(rsw_dept, rsw_rsm_id_fk)"
},
{
"answer_id": 74120186,
"author": "Luke Kubat... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119712",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10487162/"
] |
74,119,717 | <p>I have two useEffects in my functional component, in which useEffect 1 is executed first and then useEffect 2 is executed based on the useState value in useEffect 1 but if you see the log below, useEffect 2 is executed in the middle of useEffect 1 (which hasn't finished yet)</p>
<p>Is this normal behaviour or am I doing anything wrong? Help in this regard is much appreciated. I am a beginner learning MERN Stack.</p>
<p>I want to get the response from API call first and then only execute useEffect 2.</p>
<p>Thanks in advance</p>
<pre><code>const Messenger = () => {
const user = useSelector((state) => state.user.currentUser);
const state = useRef(useLocation().state); // useRef to change value and persist it for every re-render
console.log(state)
const [conversations, setConversations] = useState([]);
// Get the conversations if any from DB
useEffect(() => {
console.log("useEffect 1")
console.log("get Conversations if any")
const getAllConversations = async () => {
try {
localStorage.setItem("user", user);
const res = await getConversationsAPI(user?._id)
console.log(res.data)
setConversations(res.data);
console.log("Set conversations:")
} catch (err) {
console.log(err);
}
localStorage.removeItem("user");
};
getAllConversations();
}, [user]);
useEffect(() => {
console.log("useEffect 2")
if (state?.current) {
console.log("Conversation already Exists useEffect")
for (let convo of conversations) {
console.log(convo)
if (convo?.members.some(mem => mem._id === state?.current?._id)) {
console.log("Conversation already exists..", state?.current._id)
state.current = null;
console.log(state.current)
};
};
};
}, [state, conversations]);
[Log] useEffect 1
[Log] get Conversations if any
[Log] Get Conversations API: User
[Log] Bef api: – "632d33562aafdba7835b30ac"
[Log] useEffect 2
[Log] Conversation already Exists useEffect
[Log] Aft api: – "632d33562aafdba7835b30ac"
[Log] [Object, Object] (2)
[Log] Set conversations:
[Log] useEffect 2
[Log] Conversation already Exists useEffect
[Log] {_id: "634cf4adb10c58cd8b248591", members: Array, createdAt: "2022-10-17T06:22:37.985Z", updatedAt: "2022-10-17T06:22:37.985Z", __v: 0}
[Log] Conv already exists..state – "632c208f8bb1b20a5604f210"
[Log] null
[Log] {_id: "634e3ff52834916e46595fff", members: Array, createdAt: "2022-10-18T05:56:05.990Z", updatedAt: "2022-10-18T05:56:05.990Z", __v: 0}
[Log] {current: null}
</code></pre>
| [
{
"answer_id": 74120173,
"author": "Axell Padilla",
"author_id": 7681703,
"author_profile": "https://Stackoverflow.com/users/7681703",
"pm_score": 0,
"selected": false,
"text": "select distinct concat(rsw_dept, rsw_rsm_id_fk)"
},
{
"answer_id": 74120186,
"author": "Luke Kubat... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119717",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8931404/"
] |
74,119,723 | <p>I am facing issue while fetching record, The timestamp value is changed after fetching from DB.</p>
<p>In my Oracle DB the column value is <em>"19-OCT-22 02.15.00.000000000 AM"</em> but after fetching it comes as <em>"2022.10.19 00:15:00"</em></p>
<pre><code>@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = "yyyy.MM.dd HH:mm:ss")
private Timestamp startDate;
</code></pre>
<p>I am using JPA repository with springboot to fetch the records.</p>
| [
{
"answer_id": 74134574,
"author": "Gagan Noor Singh",
"author_id": 11254238,
"author_profile": "https://Stackoverflow.com/users/11254238",
"pm_score": 1,
"selected": true,
"text": "@Column(name = \"STARTDATE\") \n@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = \"yyyy.MM.dd HH:mm:... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119723",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11254238/"
] |
74,119,810 | <p>If my question is vague, I apologize, it's a difficult question to put to words. If, for example, I needed parts of this URL:<br />
<code>https://stackoverflow.com/questions/449775/how-can-i-split-a-url-string-up-into-separate-parts-in-python</code></p>
<p>I needed the question number, and the question title, and let's assume the title is followed by some other changing characters, but still separated by a "/". The base URL, and the word "questions" never change. The data I want changes, but is unique and specific to each question. However all this information is always in the same place in the URL.</p>
<p>Is there a way to parse this URL in python and separate what I need?</p>
| [
{
"answer_id": 74134574,
"author": "Gagan Noor Singh",
"author_id": 11254238,
"author_profile": "https://Stackoverflow.com/users/11254238",
"pm_score": 1,
"selected": true,
"text": "@Column(name = \"STARTDATE\") \n@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = \"yyyy.MM.dd HH:mm:... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119810",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14459779/"
] |
74,119,816 | <p>I am writing this because I had difficulties in implementing a specific function during WPF implementation.</p>
<p>For data model
latitude and longitude (location in current window)</p>
<p>MainViewModel is
I am managing it as an observableCollection.</p>
<p>In xaml, the upper and longitude values for each model list were displayed,</p>
<p>The part that implements the button control in the form of an image to move according to the location information that is continuously updated in xaml is blocked, so I am posting this.</p>
<p>In addition, I want to display a line for the azimuth or each component, but I also want to implement this so that the line moves according to the changing value.</p>
<p>Is there a method that is usually used for these changing values or is there a method that is mainly used in practice?
In the case of Winform, I used the method of drawing a line using a Graphics object, but if anyone knows how to display it in real time by moving it in real time in C# WPF and binding the position value, I would appreciate it if you could share it.</p>
| [
{
"answer_id": 74134574,
"author": "Gagan Noor Singh",
"author_id": 11254238,
"author_profile": "https://Stackoverflow.com/users/11254238",
"pm_score": 1,
"selected": true,
"text": "@Column(name = \"STARTDATE\") \n@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = \"yyyy.MM.dd HH:mm:... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119816",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3046228/"
] |
74,119,822 | <p>I'm switching data from Firebase Realtime Database to Firestore because I need more querying capabilities. However, I'm having trouble with saving my customer's <code>stripeID</code> to their collection document. My Cloud Function is hitting perfectly because Stripe is creating the customer correctly, but it's not assigning to the collection reference. What do I need to fix so the collection reference could recognize the <code>stripeID</code> as well? Thank you!</p>
<p><strong>What I'm Seeing</strong></p>
<p><a href="https://i.stack.imgur.com/GqACj.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GqACj.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/D6GtD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D6GtD.png" alt="enter image description here" /></a></p>
<p><strong>Customer Model</strong></p>
<pre><code>struct Customer {
let uid: String
let stripeId: String
let fullname: String
let email: String
let username: String
let profileImageUrl: String
init(dictionary: [String : Any]) {
self.uid = dictionary["uid"] as? String ?? ""
self.stripeId = dictionary["stripeId"] as? String ?? ""
self.fullname = dictionary["fullname"] as? String ?? ""
self.email = dictionary["email"] as? String ?? ""
self.username = dictionary["username"] as? String ?? ""
self.profileImageUrl = dictionary["profileImageUrl"] as? String ?? ""
}
}
</code></pre>
<p><strong>AuthServices</strong></p>
<pre><code>struct CustomerCredentials {
let email: String
let password: String
let fullname: String
let username: String
let profileImage: UIImage
}
static func createCustomer(credentials: CustomerCredentials, completion: CollectionCompletion) {
Auth.auth().createUser(withEmail: credentials.email, password: credentials.password) { result, error in
if let error = error {
debugPrint(error.localizedDescription)
return
}
guard let uid = result?.user.uid else { return }
let values = ["uid" : uid,
"email" : credentials.email,
"fullname" : credentials.fullname,
"username" : credentials.username,
"profileImageUrl" : profileImageUrl]
REF_CUSTOMERS.document(uid).setData(values, completion: completion)
}
}
}
</code></pre>
<p><strong>RegistrationController</strong></p>
<pre><code>@objc func handleCreateAccount() {
let credentials = CustomerCredentials(email: email, password: password, fullname: fullname,
username: username, profileImage: profileImage)
AuthService.createCustomer(credentials: credentials) { error in
if let error = error {
Auth.auth().handleFireAuthError(error: error, vc: self)
self.showLoader(false)
return
}
Functions.functions().httpsCallable("createStripeCustomer").call(["email" : email]) { result, error in
if let error = error {
debugPrint(error.localizedDescription)
return
}
}
}
}
</code></pre>
| [
{
"answer_id": 74134574,
"author": "Gagan Noor Singh",
"author_id": 11254238,
"author_profile": "https://Stackoverflow.com/users/11254238",
"pm_score": 1,
"selected": true,
"text": "@Column(name = \"STARTDATE\") \n@JsonFormat(shape = JsonFormat.Shape.STRING, pattern = \"yyyy.MM.dd HH:mm:... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119822",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13916727/"
] |
74,119,844 | <p>I'm trying to do a http post request and I need to specify the body as form-data, because the server don't take the request as raw or params.</p>
<p>here is the code I tried</p>
<pre><code>** Future getApiResponse(url) async {
try {
// fetching data from the url
final response = await http.get(Uri.parse(url));
// checking status codes.
if (response.statusCode == 200 || response.statusCode == 201) {
responseJson = jsonDecode(response.body);
// log('$responseJson');
}
// debugPrint(response.body.toString());
} on SocketException {
throw FetchDataException(message: 'No internet connection');
}
return responseJson;
}
}
</code></pre>
<p>but its not working. here is the post man request</p>
<p><a href="https://i.stack.imgur.com/cvDTd.png" rel="nofollow noreferrer">enter image description here</a></p>
<p>its not working on parms. only in body. its because this is in form data I guess.
how do I call form data in flutter using HTTP post?</p>
| [
{
"answer_id": 74120025,
"author": "Khyati Modi",
"author_id": 11647876,
"author_profile": "https://Stackoverflow.com/users/11647876",
"pm_score": 1,
"selected": true,
"text": "final uri = 'yourURL';\nvar map = new Map<String, dynamic>();\nmap['device-type'] = 'Android';\nmap['username']... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119844",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20278822/"
] |
74,119,854 | <p>I am a beginner in react and while learning lifecycle methods I came to know getDerivedStateFromProps() is a method of mounting lifecycle but while going further I came to understand that this is not accessible to static methods can anyone please explain why it is like this?</p>
| [
{
"answer_id": 74120025,
"author": "Khyati Modi",
"author_id": 11647876,
"author_profile": "https://Stackoverflow.com/users/11647876",
"pm_score": 1,
"selected": true,
"text": "final uri = 'yourURL';\nvar map = new Map<String, dynamic>();\nmap['device-type'] = 'Android';\nmap['username']... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119854",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15989533/"
] |
74,119,870 | <p>In VSCode and trying to run the following:</p>
<pre><code>dart pub upgrade
</code></pre>
<p>I get the following error:</p>
<pre><code>Error: Error when reading 'pub': No such file or directory
</code></pre>
<p>However, my flutter file seems fine. Flutter Doctor output below:</p>
<pre><code>[✓] Flutter (Channel stable, 3.3.4, on macOS 12.6 21G115 darwin-x64, locale en-US)
[✓] Android toolchain - develop for Android devices (Android SDK version 28.0.3)
[✓] Xcode - develop for iOS and macOS (Xcode 14.0.1)
[✓] Chrome - develop for the web
[✓] Android Studio (version 4.1)
[✓] VS Code (version 1.72.2)
[✓] Connected device (3 available)
[✓] HTTP Host Availability
</code></pre>
<p>Any idea how I can resolve this? Thanks!</p>
| [
{
"answer_id": 74119943,
"author": "MrShakila",
"author_id": 19292778,
"author_profile": "https://Stackoverflow.com/users/19292778",
"pm_score": 1,
"selected": false,
"text": "dart pub cache clean"
},
{
"answer_id": 74119996,
"author": "Chiisom",
"author_id": 17456429,
... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119870",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9736475/"
] |
74,119,989 | <p>I'm new to Azure Cloud. I'm trying to assign user assigned managed identity to Azure Sql Server for Function App Resource. I have added User who can access Azure Sql Server. Simultaneously I had tried to turn on system identity.</p>
<p>What is exactly being happened is:</p>
<ol>
<li>When I turn on System Identity it shows Login for User '' error.</li>
<li>When I turn off System Identity it shows unable to load the proper Managed Identity.</li>
<li>I actually need User Assigned Identity. So for that I tried below command in SQL Server
I created a user namely UMI1 and added this user in User assigned managed identity.</li>
</ol>
<pre>
CREATE USER [UMI1] FROM EXTERNAL PROVIDER;
GO
ALTER ROLE db_datareader ADD MEMBER [UMI1];
ALTER ROLE db_datawriter ADD MEMBER [UMI1];
GO
</pre>
<p>Connection string contains User ID=UM1</p>
<p>So, I think I having problem in creating user in sql. Any reference or response regarding this issue would be helpful. Thank you in advance</p>
| [
{
"answer_id": 74148396,
"author": "Pravallika Kothaveerannagari",
"author_id": 19991670,
"author_profile": "https://Stackoverflow.com/users/19991670",
"pm_score": -1,
"selected": false,
"text": "SE [Pravusqltestdb]\nGO\nCREATE TABLE items (id INT NOT NULL, name VARCHAR(50) NOT NULL, num... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74119989",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11252956/"
] |
74,120,005 | <p>I'm facing an issue in iOS 15 where when setting the image to the right corner doesn't work while before iOS 15 it is working properly.<br />
What I want to achieve:
<a href="https://i.stack.imgur.com/BSuWX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BSuWX.png" alt="ExpectedResult" /></a></p>
<p>What I'm achieving:
<a href="https://i.stack.imgur.com/MyVLb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MyVLb.png" alt="ActualResult" /></a></p>
<p>Here is the complete code which I'm using for iOS 15:</p>
<pre><code>import UIKit
class ViewController: UIViewController {
override func viewDidLoad() {
super.viewDidLoad()
let btnDropdown = getDropdownButton()
btnDropdown.translatesAutoresizingMaskIntoConstraints = false
view.addSubview(btnDropdown)
NSLayoutConstraint.activate([
btnDropdown.heightAnchor.constraint(equalToConstant: 44),
btnDropdown.leadingAnchor.constraint(equalTo: view.layoutMarginsGuide.leadingAnchor),
btnDropdown.trailingAnchor.constraint(equalTo: view.layoutMarginsGuide.trailingAnchor),
btnDropdown.topAnchor.constraint(equalTo: view.layoutMarginsGuide.topAnchor, constant: 30)
])
}
fileprivate func getDropdownButton() -> UIButton {
var button: UIButton!
if #available(iOS 15.0, *),
let btnConfig = getButtonConfiguration() {
button = UIButton(configuration: btnConfig)
} else {
button = UIButton(type: .custom)
}
button.setTitle("Select Tags", for: .normal)
setupGeneralSettings(for: button)
return button
}
fileprivate func setupGeneralSettings(for button: UIButton) {
button.titleEdgeInsets = UIEdgeInsets(top: 0, left: 8, bottom: 0, right: 8)
button.contentEdgeInsets = UIEdgeInsets(top: 0, left: 8, bottom: 0, right: 8)
button.contentHorizontalAlignment = .left
button.layer.borderWidth = 1
button.layer.cornerRadius = 8
button.clipsToBounds = true
button.backgroundColor = .lightGray.withAlphaComponent(0.3)
button.titleLabel?.font = UIFont.systemFont(ofSize: 14, weight: .medium)
button.setTitleColor(UIColor.black, for: .normal)
}
@available(iOS 15.0, *)
fileprivate func getButtonConfiguration() -> UIButton.Configuration? {
var btnConfig = UIButton.Configuration.plain()
btnConfig.buttonSize = .medium
btnConfig.titleAlignment = .leading
btnConfig.imagePlacement = .trailing
btnConfig.image = UIImage(systemName: "arrowtriangle.down.circle")
btnConfig.contentInsets = NSDirectionalEdgeInsets(top: 0, leading: 8, bottom: 0, trailing: 8)
btnConfig.titleTextAttributesTransformer = UIConfigurationTextAttributesTransformer { incoming in
var outgoing = incoming
outgoing.font = UIFont.systemFont(ofSize: 14, weight: .medium)
return outgoing
}
return btnConfig
}
}
</code></pre>
<p><strong>NOTE:</strong> <em>When I say iOS 15, I mean that I'm using UIButton.Configuration because as the UIButton's titleEdgeInset, imageEdgeInset & contentEdgeInset is deprecated in iOS 15.
Also, I think there is something I'm missing in UIButton.Configuration by which the image will get to the right edge of the button but I'm not sure what it is.</em></p>
<p>Please let me know if there is any other information that's needed.<br />
Thanks in Advance!</p>
| [
{
"answer_id": 74122159,
"author": "Fabio",
"author_id": 5575955,
"author_profile": "https://Stackoverflow.com/users/5575955",
"pm_score": 0,
"selected": false,
"text": "let btnDropdown = UIButton()\nlet myImageView = UIImageView()\n"
},
{
"answer_id": 74126713,
"author": "Do... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74120005",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8528836/"
] |
74,120,012 | <p>I have a model class where Api is getting parsed</p>
<pre><code> class MovieDetail {
final int id;
final bool adult;
final int budget;
final List<Genre> genres;
final List<Company> companies;
final String releaseDate;
final int runtime;
...
</code></pre>
<p>this is the whole full code of movie response:</p>
<pre><code>import 'movie_detail.dart';
class MovieDetailResponse {
final MovieDetail movieDetail;
final String error;
MovieDetailResponse(this.movieDetail, this.error);
MovieDetailResponse.fromJson(Map<String, dynamic> json)
: movieDetail = MovieDetail.fromJson(json),
error = "";
MovieDetailResponse.withError(String errorValue)
: movieDetail = MovieDetail(null, null, null, null, null, "", null),
error = errorValue;
}
</code></pre>
<p>this is the exact part where it show the error:</p>
<pre><code> MovieDetailResponse.withError(String errorValue)
: movieDetail = MovieDetail(null, null, null, null, null, "", null),
error = errorValue;
</code></pre>
<p>I'm getting an error after upgrading flutter, here is the error log:</p>
<blockquote>
<p>The argument type 'Null' can't be assigned to the parameter type 'int'.
The argument type 'Null' can't be assigned to the parameter type 'bool'.
The argument type 'Null' can't be assigned to the parameter type 'int'.
The argument type 'Null' can't be assigned to the parameter type 'List'.
The argument type 'Null' can't be assigned to the parameter type 'List'.
The argument type 'Null' can't be assigned to the parameter type 'int'.</p>
</blockquote>
<p>so what can i do to define null when it returns null?</p>
| [
{
"answer_id": 74122159,
"author": "Fabio",
"author_id": 5575955,
"author_profile": "https://Stackoverflow.com/users/5575955",
"pm_score": 0,
"selected": false,
"text": "let btnDropdown = UIButton()\nlet myImageView = UIImageView()\n"
},
{
"answer_id": 74126713,
"author": "Do... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74120012",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13497264/"
] |
74,120,046 | <p>I have this array</p>
<pre><code>const array1 = [[1,2], [2,3], [1,2]]
</code></pre>
<p>I want to be able to get <code>[1,2]</code> as the output since it's a duplicate. I have tried:</p>
<pre><code>array1.some((element, index) => {
return array1.indexOf(element) !== index
});
</code></pre>
<p>and</p>
<pre><code>array1.filter((item, index) => array1.indexOf(item) !== index)
</code></pre>
<p>both of them doesn't work since I think it's an array of arrays. Any help is deeply appreciated.</p>
| [
{
"answer_id": 74120069,
"author": "CertainPerformance",
"author_id": 9515207,
"author_profile": "https://Stackoverflow.com/users/9515207",
"pm_score": 1,
"selected": false,
"text": "const array1 = [[1,2], [2,3], [1,2]];\nconst occurrencesByJSON = {};\nfor (const subarr of array1) {\n c... | 2022/10/19 | [
"https://Stackoverflow.com/questions/74120046",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7122016/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.