qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,222,745 | <p>I'm trying to add a line-through, in all browsers it works fine, except Safari.</p>
<p>It gets misalignment.</p>
<p><a href="https://i.stack.imgur.com/8qaR0.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8qaR0.png" alt="misalignment" /></a></p>
<p>I'm not even using css, just an <code>s</code>tag inside the html</p>
<pre><code><span class="price--old">
<s>{value}</s>
</span>
</code></pre>
| [
{
"answer_id": 74226135,
"author": "user18309290",
"author_id": 18309290,
"author_profile": "https://Stackoverflow.com/users/18309290",
"pm_score": 0,
"selected": false,
"text": "onPress"
},
{
"answer_id": 74272326,
"author": "Vu Phung",
"author_id": 12040727,
"author... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74222745",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8641849/"
] |
74,222,769 | <p>I have this table on the picture below.
I'm trying to select all rows with DestinationSystemID "11" where other rows with the same SupplierPartyID does not also have DestinationSystemID "16".</p>
<p>For example in the table below the following rows should be selected because they have rows with DestinationSystem 11, but not 16:</p>
<ul>
<li>7300009017706</li>
<li>7300009043088</li>
<li>7330509000502</li>
</ul>
<p>The following should not be selected because it has both DestinationSystemID 11 and 16:</p>
<ul>
<li>7318270000006</li>
</ul>
<p>I hope you understand what I'm trying to ask here.</p>
<p><a href="https://i.stack.imgur.com/gJE5W.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/gJE5W.png" alt="Table" /></a></p>
<p>I have tried searching for solutions but can not query the question correctly to find a solution.</p>
| [
{
"answer_id": 74226135,
"author": "user18309290",
"author_id": 18309290,
"author_profile": "https://Stackoverflow.com/users/18309290",
"pm_score": 0,
"selected": false,
"text": "onPress"
},
{
"answer_id": 74272326,
"author": "Vu Phung",
"author_id": 12040727,
"author... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74222769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20349250/"
] |
74,222,774 | <p>I have a method that I receive a FormCollection. And I need to pass to my application layer a list of it.</p>
<p>What I'm doing and works:</p>
<pre><code>var formIndexes = form.AllKeys.Select((e, i) => new { Name = e, Index = i }).Where(o => o.Name.Contains("StatusId")).ToList();
var formValues = formIndexes.Select(e => new { Value = form[e.Index], Name = e.Name }).ToList();
</code></pre>
<p>but formValues is a Generic.List and I need to convert to a List or a Dictionary.</p>
<p>Error:
<strong>cannot convert from 'System.Collections.Generic.List<<anonymous type: string Value, string Name>>' to 'System.Collections.Generic.Dictionary<string, string>'</strong></p>
<p><strong>[SOLVED]</strong></p>
<p>As @DanielA.White said, I solved doing:</p>
<pre><code>formIndexes.Select(e => new { Value = form[e.Index], Name = e.Name }).ToDictionary(a => a.Name, b => b.Value);
</code></pre>
| [
{
"answer_id": 74222874,
"author": "Liquid Core",
"author_id": 2212907,
"author_profile": "https://Stackoverflow.com/users/2212907",
"pm_score": 0,
"selected": false,
"text": " [HttpPost] \n public ActionResult Submit(FormCollection fc)\n {\n ViewBag.Id = ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74222774",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12491649/"
] |
74,222,780 | <p>I know that a <code>union</code> allows to store different data types in the same memory location. You can define a union with many members, but only one member can contain a value at any given time. Consider this program:</p>
<pre><code> #include <stdio.h>
union integer {
short s;
int i;
long l;
};
int main() {
union integer I;
scanf("%hi", &I.s);
scanf("%d", &I.i);
scanf("%ld", &I.l);
printf("%hi - %d - %ld ", I.s, I.i, I.l );
}
</code></pre>
<p>Suppose we enter the values <code>11</code>, <code>55</code>, <code>13</code> the program will give as output</p>
<p><code>13 - 13 - 13</code>, no problem here. However, if i were to create three different variables of type <code>struct integer</code></p>
<pre><code> #include <stdio.h>
union integer {
short s;
int i;
long l;
};
int main() {
union integer S;
union integer I;
union integer L;
scanf("%hi", &S.s);
scanf("%d", &I.i);
scanf("%ld", &L.l);
printf("%hi - %d - %ld ", S.s, I.i, L.l );
}
</code></pre>
<p>than all the values will be preserved.
How come? By using three variables am i actually using three unions, each holding just one value?</p>
| [
{
"answer_id": 74222874,
"author": "Liquid Core",
"author_id": 2212907,
"author_profile": "https://Stackoverflow.com/users/2212907",
"pm_score": 0,
"selected": false,
"text": " [HttpPost] \n public ActionResult Submit(FormCollection fc)\n {\n ViewBag.Id = ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74222780",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19681418/"
] |
74,222,812 | <p>I am trying to solve <a href="https://leetcode.com/problems/plus-one/" rel="nofollow noreferrer">Plus One on Leetcode</a></p>
<p>The description is as follows:</p>
<p>You are given a large integer represented as an integer array digits, where each digits[i] is the ith digit of the integer. The digits are ordered from most significant to least significant in left-to-right order. The large integer does not contain any leading 0's.</p>
<p>Increment the large integer by one and return the resulting array of digits.</p>
<p>Example 1:</p>
<p>Input: digits = [1,2,3]
Output: [1,2,4]
Explanation: The array represents the integer 123.
Incrementing by one gives 123 + 1 = 124.
Thus, the result should be [1,2,4].</p>
<p>My code is:</p>
<pre><code>class Solution {
public int[] plusOne(int[] digits) {
long temp=0;int c=0;
for(int i:digits)
{
temp=temp*10+i;
//System.out.println(temp);
}
//System.out.println(temp);
temp+=1;
//System.out.println(temp);
long copy=temp;
while(copy>0)
{
copy/=10;
c++;
}
int[] result=new int[c];
for(int i=c-1;i>=0;i--)
{
//System.out.println((int)temp%10);
result[i]=(int)temp%10;
// System.out.println(result[i]);
temp/=10;
}
return result;
}
</code></pre>
<p>}</p>
<p>The problem is when I am trying to extract the number in the unit's digit it is givig 9 instead of 1.</p>
<p>Expected output:[9,8,7,6,5,4,3,2,1,1]</p>
<p>My Output:[9,8,7,6,5,4,3,2,1,9]</p>
| [
{
"answer_id": 74232212,
"author": "DevilsHnd",
"author_id": 4725875,
"author_profile": "https://Stackoverflow.com/users/4725875",
"pm_score": 2,
"selected": true,
"text": "for"
},
{
"answer_id": 74232297,
"author": "oleg.cherednik",
"author_id": 3461397,
"author_prof... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74222812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16542113/"
] |
74,222,826 | <p>While doing a code Kata, I've run into a slight logical problem that I can't figure out a solution to. It isn't a hard-and-fast requirement of completing the task but it has me intrigued as to how it could be handled.</p>
<p>The Kata is simulating applying pricing discounts and a supermarket checkout (<a href="http://codekata.com/kata/kata09-back-to-the-checkout/" rel="nofollow noreferrer">see full Kata here</a>) through a collection of pricing rules. To play around with some inheritance and interface capabilities, I've added a "Buy X, get Y free" rule. It works fine when the <code>Y</code> in question is <code>1</code>, but starts getting a little hazy after that...</p>
<p>For example, I experimented with the idea of "Buy <code>3</code>, get <code>2</code> free". I tried doing this by grouping the items in groups of 5, and working out the discount of each group by subtracting the price of two of the items:</p>
<pre><code> public override double CalculateDiscount(Item[] items)
{
//per the example described above
//_groupSize = 5, _buy = 3
//meaning 2 out of every group of 5 items should be free
var discountGroups = new List<IEnumerable<Item>>();
for (var i = 0; i < items.Length / _groupSize; i++)
{
discountGroups.Add(items.Skip(i * _groupSize).Take(_groupSize));
}
return discountGroups
.Sum(group => group
.Skip(_buy)
.Sum(item => item.Price)
);
}
</code></pre>
<p>What I found is that the above code works as expected (if each item has a <code>Price</code> property of <code>1.00</code>, the above would return <code>2.00</code>). An edge case that I am looking to solve is that it doesn't take affect until the fifth item is added (so the price as you ad each item would go <code>1.00</code>, <code>2.00</code>, <code>3.00</code>, <code>4.00</code>, <code>3.00</code>).</p>
<p>What I would ideally like is that, once you have three items in your collection, the next two items are free, whether you choose to take just one or two of them shouldn't affect the price. I understand this isn't hugely realistic to the domain, but I was interested in trying to solve it as a technical problem.</p>
<p>I've had a few cracks at it but haven't successfully gotten any closer than the above code. I figure that what I need to do is group the array into the minimum number of bought items required, then a variable number of free items. I could probably hard-code something to solve the issue once, but this gets complicated if I were to simulate buying 3 items and getting 2 free, then buying 3 items but only taking one free one.</p>
<p>Any advice on how to go about this would be really appreciated!</p>
<p>Thanks,
Mark</p>
| [
{
"answer_id": 74232212,
"author": "DevilsHnd",
"author_id": 4725875,
"author_profile": "https://Stackoverflow.com/users/4725875",
"pm_score": 2,
"selected": true,
"text": "for"
},
{
"answer_id": 74232297,
"author": "oleg.cherednik",
"author_id": 3461397,
"author_prof... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74222826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5020874/"
] |
74,222,880 | <p>I have a <code>Function</code> and <code>BiFunction</code> and I would like to chain them</p>
<pre><code>Function<Integer, String> function = n -> "" + n;
BiFunction<String, Boolean, List<Character>> biFunction =
(str, isOK) -> Collections.EMPTY_LIST;
</code></pre>
<p>Is there a way to chain these two Functions such as the returned value from <code>Function</code> is used as an input to <code>BiFunction</code>?</p>
<p><em>Pseudocode:</em></p>
<pre><code>public List<Character> myMethod(int n, boolean isOK) {
return function.andThen(biFunction).apply([output_of_function], isOK)
}
</code></pre>
<p>I couldn't find a way to provide the integer <code>n</code> to <code>Function</code> nor to supply <code>BiFunction</code> with the output of the first <code>Function</code>.</p>
<p>Is it doable?</p>
| [
{
"answer_id": 74232212,
"author": "DevilsHnd",
"author_id": 4725875,
"author_profile": "https://Stackoverflow.com/users/4725875",
"pm_score": 2,
"selected": true,
"text": "for"
},
{
"answer_id": 74232297,
"author": "oleg.cherednik",
"author_id": 3461397,
"author_prof... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74222880",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5537770/"
] |
74,222,886 | <p>It shows qml on main screen. I want to repeat the same image on other screens. They will all be exactly the same. It will be renewed on all screens according to the change in Main. Is something like this possible ?</p>
<p>code in main.qml</p>
<pre><code>PlaybackControl {
id: playbackControl
anchors {
right: parent.right
left: parent.left
bottom: parent.bottom
}
mediaPlayer: mediaPlayer
mediaPlayer2: mediaPlayer2
}
</code></pre>
<p><strong>Edit:</strong>
I want to run a qml to run concurrently on each window. I added new images. state1 main screen. There are 6 windows on the main screen. When I drag one of the screens out. I want the control bar below to appear on the screen that comes out. It will appear at the bottom of every screen that is removed. When I change the slider on one screen, it will change simultaneously on all screens. When I make the control bar a component and use it as an initial item in more than one stackview, it shows the last inial item I called without duplicating the source.</p>
<p><a href="https://i.stack.imgur.com/D9EW7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/D9EW7.png" alt="state1" /></a>
<a href="https://i.stack.imgur.com/oe8zI.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oe8zI.png" alt="state2" /></a></p>
| [
{
"answer_id": 74232212,
"author": "DevilsHnd",
"author_id": 4725875,
"author_profile": "https://Stackoverflow.com/users/4725875",
"pm_score": 2,
"selected": true,
"text": "for"
},
{
"answer_id": 74232297,
"author": "oleg.cherednik",
"author_id": 3461397,
"author_prof... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74222886",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15508720/"
] |
74,222,941 | <p>I have an if-else statement, and in the else block I want it to first recurse to the function, except for the last two elements of the list, and then return two elements.</p>
<p>In the following function, after the if-else statement, I have 2 lines of code. however this doesnt compile. I believe the compiler reads these two lines as a single line of code. How do you fix that?</p>
<pre><code>doubleEveryOther :: [Integer] -> [Integer] --outputs the input list, but every 2nd element(from the right) is doubled
doubleEveryOther [] = []
doubleEveryOther x = if (length x <2)
then
x
else
doubleEveryOther init (init x) -- These two lines
[2*last(init x), last x] -- These two lines
</code></pre>
<p>The compiler says:</p>
<pre><code> * Couldn't match expected type: [Integer]
with actual type: [a0] -> [a0]
* Probable cause: `init' is applied to too few arguments
In the first argument of `doubleEveryOther', namely `init'
In the expression: doubleEveryOther init (init x)
In the expression:
[doubleEveryOther init (init x), 2 * last (init x), last x]
|
19 | [doubleEveryOther init (init x), 2*last(init x), last x]
|
</code></pre>
| [
{
"answer_id": 74223227,
"author": "Noughtmare",
"author_id": 15207568,
"author_profile": "https://Stackoverflow.com/users/15207568",
"pm_score": 2,
"selected": false,
"text": "++"
},
{
"answer_id": 74223277,
"author": "Willem Van Onsem",
"author_id": 67579,
"author_p... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74222941",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14490971/"
] |
74,222,963 | <p>I provide the simple list as below :</p>
<pre><code>var records = new List<BookRecord> {
new() {
Author = "Peter",
BookName = "Book A"
},
new() {
Author = "",
BookName = "Book B"
},
new() {
Author = "Peter",
BookName = "Book C"
},
new() {
Author = "James",
BookName = ""
},
new() {
Author = "",
BookName = "Book D"
},
new() {
Author = "James",
BookName = ""
},
new() {
Author = "",
BookName = "Peter"
}
};
</code></pre>
<p>I want to group only author is not empty (or other condition) , and the remain need to keep into result , so my expected result will be :</p>
<pre><code>[
{"Author":"Peter","BookName":"Book A"},
{"Author":"","BookName":"Book B"},
{"Author":"James","BookName":""},
{"Author":"","BookName":"Book D"},
{"Author":"","BookName":"Peter"}
]
</code></pre>
<p>and need to in ordering (that mean "james" should be row 3 and the last one must be <code>{"Author":"","BookName":"Peter"}</code></p>
<p>can I know how to do it ?</p>
<p>Thank you</p>
| [
{
"answer_id": 74223095,
"author": "Dmitry Bychenko",
"author_id": 2319407,
"author_profile": "https://Stackoverflow.com/users/2319407",
"pm_score": 2,
"selected": true,
"text": "Author"
},
{
"answer_id": 74223233,
"author": "Neil Thompson",
"author_id": 20347839,
"au... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74222963",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17194305/"
] |
74,222,979 | <p>How can I export and store column business name on snowflake ? Eg: "LOAN REPAYMENT METHOD CODE" would be the business friendly name for column "LOAN_RPYMT_MTHD_CD" . I can very well start my column comments with the business name Eg: <em>"LOAN REPAYMENT METHOD CODE - The method by which loan will be repaid . Lumpsum, installments etc.. "</em> so that it shows up in the COMMENT property.
However I am wondering is there a "dedicated" property in a snowflake table where I can export this to from my data modeling tool (powerdesigner) so that it shows up in INFORMATION_SCHEMA.columns</p>
<p>Thanks
Sunil</p>
| [
{
"answer_id": 74223309,
"author": "Michael Golos",
"author_id": 12607126,
"author_profile": "https://Stackoverflow.com/users/12607126",
"pm_score": 1,
"selected": false,
"text": "alter table t1 alter LOAN_RPYMT_MTHD_CD comment 'LOAN REPAYMENT METHOD CODE';\n"
},
{
"answer_id": 7... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74222979",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17244809/"
] |
74,222,993 | <p>I'm trying to create an abstract class ThingieSection. It's derived types will specify the type of ThingieSection. In the constructor of ThingieSection I want a parameter that's a list of Thingie which is also generic.</p>
<p>I'm having a problem in that when the derived class is calling it's base class's constructor, it thinks that the type of the List parameter should be the type of the object. Here's an example:</p>
<pre><code>using System.Collections.Generic;
public abstract class ThingieSection<T>
{
public string Title { get; private set; }
public string TextStuff { get; private set; }
public List<T> Thingies { get; private set; }
protected ThingieSection(string title, string textStuff, List<Thingie<T>> Thingies)
{
}
public abstract string Generate();
}
public abstract class Thingie<T>
{
public string TextStuff { get; private set; }
protected Thingie(T workFlowEntity, string category)
{
}
public abstract string Generate();
}
public class ProviderClassyChangesProposedThingieSection : ThingieSection<ProviderClassyChangesProposedSummaryThingie>
{
public ProviderClassyChangesProposedThingieSection(string title, string content, List<Thingie<Classy>> thingies) : base(title, content, thingies)
{
}
public override string Generate() => throw new System.NotImplementedException();
}
public class ProviderClassyChangesProposedSummaryThingie : Thingie<Classy>
{
public ProviderClassyChangesProposedSummaryThingie(Classy workFlowEntity, string category) : base(workFlowEntity, category)
{
}
public override string Generate() => throw new System.NotImplementedException();
}
public abstract partial class Classy
{
}
</code></pre>
<p>I've tried separating the types by changing</p>
<pre><code>public abstract class ThingieSection<T>
</code></pre>
<p>to</p>
<pre><code>public abstract class ThingieSection<T1>
</code></pre>
<p>and</p>
<pre><code>public List<T> Thingies { get; private set; }
</code></pre>
<p>to</p>
<pre><code>public List<T2> Thingies { get; private set; }
</code></pre>
<p>and the ThingieSection constructor<br />
to</p>
<pre><code>ThingieSection(string title, string textStuff, List<Thingie<T2>> Thingies)
</code></pre>
<p>but it didn't work either.</p>
| [
{
"answer_id": 74223207,
"author": "Victor Wilson",
"author_id": 1429535,
"author_profile": "https://Stackoverflow.com/users/1429535",
"pm_score": 2,
"selected": true,
"text": "using System.Collections.Generic;\nnamespace ThingsAndStuff\n{\n\n public abstract class ThingieSection<T, U... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74222993",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1786805/"
] |
74,223,008 | <p>I have a Dataframe that look like this:</p>
<p>df_1:</p>
<pre><code> Phase_1 Phase_2 Phase_3
0 8 4 2
1 4 6 3
2 8 8 3
3 10 5 8
...
</code></pre>
<p>I'd like to add a column called "Coeff" that compute <code>(Phase_max - Phase_min) / Phase_max</code></p>
<p>For the first row: Coeff= (Phase_1 - Phase_3)/ Phase_1 = (8-2)/8 = 0.75</p>
<p>Expected OUTPUT:</p>
<p>df_1</p>
<pre><code> Phase_1 Phase_2 Phase_3 Coeff
0 8 4 2 0.75
1 4 6 3 0.5
2 8 8 3 0.625
3 10 5 8 0.5
</code></pre>
<p>What is the best way to compute this without using loop? I want to apply it on large dataset.</p>
| [
{
"answer_id": 74223207,
"author": "Victor Wilson",
"author_id": 1429535,
"author_profile": "https://Stackoverflow.com/users/1429535",
"pm_score": 2,
"selected": true,
"text": "using System.Collections.Generic;\nnamespace ThingsAndStuff\n{\n\n public abstract class ThingieSection<T, U... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223008",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15382800/"
] |
74,223,024 | <p>There is something in Python that has been bugging me for a long time. I can't figure out how to pass parameters from one function to the functions that are defined inside of that function. I have tried researching this issue, but with no luck. Not even W3Schools didn't show a solution.</p>
<pre><code>def func1(arg1):
def func2(arg1):
print(arg1)
func2()
var1 = 123
func1(var1)
</code></pre>
<p>Here func1 and func2 should have the same parameters but don't.</p>
| [
{
"answer_id": 74223057,
"author": "Elio Rahi",
"author_id": 19338748,
"author_profile": "https://Stackoverflow.com/users/19338748",
"pm_score": 0,
"selected": false,
"text": "def func1(arg1):\n def func2(): <-- Removed parameter \n print(arg1)\n func2()\nvar1 = 123\nfunc1(v... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223024",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19973965/"
] |
74,223,035 | <p>I can't find answer anywhere regarding C# documentation comment, so please explain:</p>
<p>If I have a separate class and a method inside [someFunc()], then using /// Visual Studio will insert a documentation comment for the method.</p>
<pre><code>namespace someNs
{
internal class someClass
{
/// <summary>
///
/// </summary>
public void someFunc()
{
}
}
}
</code></pre>
<p>But, if I have a method inside "static void Main(string[] args)"
Then using /// does not work.</p>
<pre><code>namespace someNs
{
internal class Program
{
static void Main(string[] args)
{
void someFunc()
{
}
}
}
}
</code></pre>
<p>Please explain why is it like that and is it possible some way to add the documentation comments?</p>
<p>Thank you.</p>
| [
{
"answer_id": 74223107,
"author": "InBetween",
"author_id": 767890,
"author_profile": "https://Stackoverflow.com/users/767890",
"pm_score": 3,
"selected": false,
"text": "someFunc()"
},
{
"answer_id": 74230176,
"author": "Hao Yu-MSFT",
"author_id": 19818478,
"author_... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223035",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/292861/"
] |
74,223,050 | <p>I am using react functional component and i have state which stores array</p>
<pre><code>const [channelList, setChannelList] = useState([]);
</code></pre>
<p>This function updates the state after submisson of an input form and state updates sucessfully</p>
<pre><code>const handleFormSubmit = (event) => {
event.preventDefault();
const channelName = inputChannelNameRef.current.value;
const channelId = inputChannelIdRef.current.value;
setChannelList([
...channelList,
{
rowId: channelList.length + 1,
channelName: channelName,
channelId: channelId,
template: deleteBtn, // delete button component which perform row delete action
},
]);
console.log(channelList.length);
};
</code></pre>
<p>This function is called on clicking the delete button through passing row ID</p>
<pre><code>const deleteRow = (rowId) => {
console.log(channelList.length); // logging zero every time
}
</code></pre>
<p>This deleteRow() function was not working so i console.log the state length then i found that it is returning 0 every time but my rows are showing perfectly fine. Why it is giving zero when it has number of objects in it. In function handleFormSubmit() i am getting length of channelList perfectly fine.</p>
| [
{
"answer_id": 74223107,
"author": "InBetween",
"author_id": 767890,
"author_profile": "https://Stackoverflow.com/users/767890",
"pm_score": 3,
"selected": false,
"text": "someFunc()"
},
{
"answer_id": 74230176,
"author": "Hao Yu-MSFT",
"author_id": 19818478,
"author_... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223050",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14156427/"
] |
74,223,061 | <p>I'm new in php/laravel.</p>
<p>I'm trying to get one user with the userName of the user connected except if it's "Chuck NORRIS"</p>
<p>This, is working. I'm getting the user connected information</p>
<pre><code> $oneUser= User::where('name', $userName)->get();
</code></pre>
<p>This, is not working. I'm getting the user Chuck NORRIS if he's the one connected</p>
<pre><code> $oneUser= User::where('name', $userName)->where($userName, '!=', "Chuck NORRIS")->get();
</code></pre>
| [
{
"answer_id": 74223210,
"author": "Delano van londen",
"author_id": 19923550,
"author_profile": "https://Stackoverflow.com/users/19923550",
"pm_score": 1,
"selected": false,
"text": "if($userName != \"Chuck NORRIS\") {\n $oneUser= User::where('name', $userName)->get();\n}\nelse{\nretur... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223061",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19389219/"
] |
74,223,078 | <p>I am trying to start a Powershell window that starts an ssh session with the following command:</p>
<p><code>pwsh.exe -noexit -Command {ssh <username>@<host>}</code></p>
<p>This works when executed from a pwsh.exe window itself:
<a href="https://i.stack.imgur.com/v8b2Y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/v8b2Y.png" alt="enter image description here" /></a>
but when executed from cmd, the run window (Win+R) or Task Scheduler (what I need it for), it just displays the command that should have been executed and starts pwsh:
<a href="https://i.stack.imgur.com/GQgwn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GQgwn.png" alt="enter image description here" /></a></p>
<p>That is, the command that doesn't work <em>outside</em> of PowerShell is:</p>
<pre><code>pwsh.exe -noexit -Command {ssh username@host}
</code></pre>
<p>The commands have of course been tested with actual websites where, again, 1 works and 2 doesn't.<br />
Any help would be greatly appreciated! Thank you!</p>
| [
{
"answer_id": 74223364,
"author": "MySurmise",
"author_id": 14236974,
"author_profile": "https://Stackoverflow.com/users/14236974",
"pm_score": 1,
"selected": false,
"text": "pwsh.exe -noexit -Command \"ssh username@host\""
},
{
"answer_id": 74223450,
"author": "GreenGrassTu... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223078",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14236974/"
] |
74,223,124 | <p>I am facing an issue where I need to render a lot of grid elements on a component, starting out the grid will have 2,500 items(50 horizontally and 50 vertically) and this grid view needs to be scrollable in both directions and diagonally as well, I was able to do this by applying this prop <code>directionalLockEnabled={false}</code> to the regular react-native <code>ScrollView</code> but since I have a lot of items being rendered the <code>ScrollView</code> performance is suffering greatly, I wanted to replace this with a <code>FlatList</code> but couldn’t find a way to make it scrollable in all directions.</p>
<p>My question is if there is a way to make the <code>ScrollView</code> performant or to use <code>FlatList</code> and make it scrollable in all directions? or a better way to implement this?</p>
| [
{
"answer_id": 74223364,
"author": "MySurmise",
"author_id": 14236974,
"author_profile": "https://Stackoverflow.com/users/14236974",
"pm_score": 1,
"selected": false,
"text": "pwsh.exe -noexit -Command \"ssh username@host\""
},
{
"answer_id": 74223450,
"author": "GreenGrassTu... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8923417/"
] |
74,223,143 | <p>I have a data frame with boolean data per column. I want to know the length (count) of each period when there were consecutive FALSE values but with the possibility of having TRUE value in between, if it doesn't exceed 10 raws in a row. If there are more than 10 TRUE values in a row, then the counting should start from 0 from the next FALSE values. Eventually I want to have the number of such periods per column and length of each period. I know there are plenty posts on finding number of consecutive TRUE values, but nothing on the possibility of using conditions.</p>
<p>I tried to use rleid function together with rowid from the data.table package, but all I got was the same of consecutive TRUE values. Here is the code I used to test on a random vector:</p>
<pre><code>rowid(rleid(a))*a
</code></pre>
<p>From there on I am stuck.</p>
<p>Ideally from the vector</p>
<pre><code>a <- c(FALSE, FALSE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, FALSE, TRUE, TRUE, TRUE, TRUE,TRUE, TRUE,TRUE, TRUE,TRUE, TRUE, FALSE, FALSE)
</code></pre>
<p>I want to get a vector: 9, 2</p>
| [
{
"answer_id": 74223507,
"author": "nicola",
"author_id": 3987294,
"author_profile": "https://Stackoverflow.com/users/3987294",
"pm_score": 0,
"selected": false,
"text": "rle"
},
{
"answer_id": 74223512,
"author": "G. Grothendieck",
"author_id": 516548,
"author_profil... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20349423/"
] |
74,223,149 | <p>I'm still very inexperienced in javascript, nevertheless I'd like to try my hand at it and would be very happy to get some support. I have the following scenario:</p>
<p>I have a table, with several rows and 3 columns. Column 1 would be a name, column 2 would be a number (ID), column 3 would be a value.</p>
<p>I have a value (ID) in a WebApp that I would like to search for in the table in column 2 and would like to display only that row. What is the best way to start? What exact topics should I look at more closely to implement this? I would be very happy to receive an answer!</p>
<pre><code><div id="datatable" align="center">
<table>
<tr id="class1">
<td>Person 1</td>
<td>1234561</td>
<td>800</td>
</tr>
<tr id="class1">
<td>Person 2</td>
<td>1234562</td>
<td>1800</td>
</tr>
<tr id="class1">
<td>Person 3</td>
<td>1234563</td>
<td>1400</td>
</tr>
</table>
</div>
</code></pre>
<p>I have already searched online for similar scripts, however this doesn't seem to be needed that often! So I would like to tackle this myself now. But how to start?</p>
| [
{
"answer_id": 74223507,
"author": "nicola",
"author_id": 3987294,
"author_profile": "https://Stackoverflow.com/users/3987294",
"pm_score": 0,
"selected": false,
"text": "rle"
},
{
"answer_id": 74223512,
"author": "G. Grothendieck",
"author_id": 516548,
"author_profil... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223149",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20349486/"
] |
74,223,173 | <p>I'm writing a text formatter that needs to clear out special characters from Chinese pinyins and replace them with their latin counterparts. But I've suddenly stumbled upon this problem
So, let's say I have this syllable</p>
<pre><code>shu
</code></pre>
<p>I need to check if it contains one letter of the list below:</p>
<pre><code>üǖǘǚǚü̆ǜ
</code></pre>
<p>I have a RegExp like this
<code>[üǖǘǚǚü̆ǜ]{1}</code></p>
<p>It shouldn't match simple "u" but it does.</p>
<p><a href="https://i.stack.imgur.com/s7INU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/s7INU.png" alt="enter image description here" /></a></p>
<p>How can I get around this?</p>
| [
{
"answer_id": 74223270,
"author": "Slava",
"author_id": 7499554,
"author_profile": "https://Stackoverflow.com/users/7499554",
"pm_score": 3,
"selected": true,
"text": "(?:ü|ǖ|ǘ|ǚ|ǚ|ü̆|ǜ){1}\n"
},
{
"answer_id": 74223284,
"author": "Cristiano Schiaffella",
"author_id":... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223173",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1512726/"
] |
74,223,189 | <p>First post here so i hope it's understandable for you guys (and girls). Don't hesitate to give advice if there are ways i could have done it with more clarity.</p>
<p>I'm trying to create a navbar composed of 3 clickable pictures. I want every of the 3 pictures to be the same size but my code doesn't work and the picture gets too big. Can't figure out why ?</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> #navbar {
display: flex;
flex-direction: row ;
justify-content: space-around;
width: 100%;
margin: 0% auto 10% 20%;
}
.bouton {
width: 30%;
height: 30%;
object-fit: contain;</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code> <div id="navbar">
<div class="bouton"><img src="https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.svg" id="tattoo"></div>
<div class="bouton"><img src="https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.svg" id="iIllustration" ></div>
<div class="bouton"><img src="https://cdn.sstatic.net/Sites/stackoverflow/company/img/logos/so/so-icon.svg" id="objet"></div>
</div> </code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74223270,
"author": "Slava",
"author_id": 7499554,
"author_profile": "https://Stackoverflow.com/users/7499554",
"pm_score": 3,
"selected": true,
"text": "(?:ü|ǖ|ǘ|ǚ|ǚ|ü̆|ǜ){1}\n"
},
{
"answer_id": 74223284,
"author": "Cristiano Schiaffella",
"author_id":... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223189",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20260740/"
] |
74,223,216 | <p>Good day, can I please get assistance.</p>
<p>I was trying host my Laravel project on my computer but I cannot quite get it right...</p>
<p>I tried running this command "php artisan serve --host=192.168.1.94" to host my project to be accessible to my android app but it's not working because I usually you "php -S 127.0.0.1:8000 -t public/" to start the project. How do I then host using the second one or what solution is there for it?? Thanks in advance!</p>
| [
{
"answer_id": 74223270,
"author": "Slava",
"author_id": 7499554,
"author_profile": "https://Stackoverflow.com/users/7499554",
"pm_score": 3,
"selected": true,
"text": "(?:ü|ǖ|ǘ|ǚ|ǚ|ü̆|ǜ){1}\n"
},
{
"answer_id": 74223284,
"author": "Cristiano Schiaffella",
"author_id":... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223216",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20349514/"
] |
74,223,218 | <p>I'm trying to write a script which asks a user for input and validates the input in a loop, but I'm getting the error: <code>TypeError: 'str' object cannot be interpreted as an integer</code>.</p>
<p>I've tried a <code>while</code> and a <code>for</code> loop. Even without loop and just with an <code>if</code> and an <code>else</code>.</p>
<p>Here's what I have so far:</p>
<pre><code>def majuscule(word):
for j in word:
if (chr(j) >= chr(0)) and (chr(j) <= chr(64)) and (chr(j) >= chr(91)) and (chr(j) <= chr(96)) and (chr(j) >= chr(123)):
word = input("What's your word ?")
else:
print('Valide word')
</code></pre>
| [
{
"answer_id": 74223270,
"author": "Slava",
"author_id": 7499554,
"author_profile": "https://Stackoverflow.com/users/7499554",
"pm_score": 3,
"selected": true,
"text": "(?:ü|ǖ|ǘ|ǚ|ǚ|ü̆|ǜ){1}\n"
},
{
"answer_id": 74223284,
"author": "Cristiano Schiaffella",
"author_id":... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223218",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20349505/"
] |
74,223,219 | <p>I have a sheet of creditors and there is a checkbox on each entry next to total price column. When I receive the payment I check the checkbox. Now I am trying to query all the unpaid creditors to another sheet but I don't know how to query creditor name when the checkbox is on another row. I can query same row entries.
here is how it looks like</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>Name</th>
<th>Items</th>
<th>Payment Received (Checkbox)</th>
</tr>
</thead>
<tbody>
<tr>
<td>Jack</td>
<td>chips</td>
<td>TRUE</td>
</tr>
<tr>
<td>Joe</td>
<td>beer</td>
<td>FALSE</td>
</tr>
<tr>
<td>Katrine</td>
<td>chips</td>
<td></td>
</tr>
<tr>
<td></td>
<td>fruits</td>
<td>FALSE</td>
</tr>
<tr>
<td>Bob</td>
<td>coke</td>
<td></td>
</tr>
<tr>
<td></td>
<td>vegies</td>
<td>TRUE</td>
</tr>
<tr>
<td>Adrine</td>
<td>chips</td>
<td></td>
</tr>
<tr>
<td></td>
<td>beer</td>
<td>FALSE</td>
</tr>
</tbody>
</table>
</div>
<p>I tried QUERY. But didn't help. It just shows same row items. What happens here is first column customers buy the items on second column and if customer pays then third column becomes TRUE and if it is a credit, then it is FALSE. And if customer buys more than 1 item, then the TRUE value will be next to the last item of second column. So what I am trying to achieve is, I am trying to query or whatever somehow filter those customers who haven't paid their payment. –</p>
| [
{
"answer_id": 74223270,
"author": "Slava",
"author_id": 7499554,
"author_profile": "https://Stackoverflow.com/users/7499554",
"pm_score": 3,
"selected": true,
"text": "(?:ü|ǖ|ǘ|ǚ|ǚ|ü̆|ǜ){1}\n"
},
{
"answer_id": 74223284,
"author": "Cristiano Schiaffella",
"author_id":... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13254522/"
] |
74,223,234 | <p>How do you create a variable that would define a positive number and a negative number and then use it to relate to this specific list of numbers
Side note: I do not have to categorize 0 in this code</p>
<p>So far all I've managed to do is figure out the positive or negative number in a list, not both:</p>
<pre><code>num = [ int(input("enter number: ")) for x in range (10) ]
for x in num:
if num>0:
print("num is positive")
</code></pre>
<p>However as expected this would substitute the number that is positive with this string and would not define which number is positive. I'm also not sure how to use a count for the negative and positive number.</p>
| [
{
"answer_id": 74223260,
"author": "Riccardo Bucco",
"author_id": 5296106,
"author_profile": "https://Stackoverflow.com/users/5296106",
"pm_score": 1,
"selected": false,
"text": "n_positive = n_negative = 0\nfor n in num:\n if n > 0:\n n_positive = n_positive + 1\n elif n < ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20349564/"
] |
74,223,245 | <p>In Roblox, is there a limit of simultaneous connected users in one place or a game ?</p>
<p>Thanks !</p>
| [
{
"answer_id": 74225305,
"author": "Kylaaa",
"author_id": 2860267,
"author_profile": "https://Stackoverflow.com/users/2860267",
"pm_score": 2,
"selected": true,
"text": "Game Settings > Places > the three dots button > Max Players"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223245",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1879453/"
] |
74,223,251 | <p>Why is Case 1 and infinite loop, whereas Case 2 isn't, as <code>obj</code> in the <code>useState()</code> isn't?</p>
<p><strong>Case 1: Infinite loop</strong></p>
<pre><code>const [count, setCount] = useState(0)
const [obj,setObj] = useState({a:1, b:2})
useEffect(( )=>
{setCount((prevCount) => prevCount + 1)
},[{a:1, b: 2 }])
</code></pre>
<p><strong>Case 2: Not an infinite loop</strong></p>
<pre><code>const [count, setCount] = useState(0)
const [obj,setObj] = useState({a:1, b:2})
useEffect(( )=>
{setCount((prevCount) => prevCount + 1)
},[obj])
</code></pre>
| [
{
"answer_id": 74223754,
"author": "Preet Mishra",
"author_id": 8838309,
"author_profile": "https://Stackoverflow.com/users/8838309",
"pm_score": 1,
"selected": false,
"text": "useState"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223251",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20349298/"
] |
74,223,267 | <p>I am trying to use concat inside a mapping function. In this code snipped you see my function which first checks if there are any chips in the chips array. If not, a chip is created. This part works fine. If there are chips and the ID of the chip matches the ID of my target, I only change the displayed text and don't create another chip. This is also fine, but I would expect, that if this isn't the case, that I would be able to concat another chip, but this doesn't work. I also get not errors and when I log the last part it shows that a chip gets added to the array.</p>
<p>Am I missing something really simple here ? I would like to provide more code, but my project has lots of imports and stuff which would make this a very long post. Thanks for any help :)</p>
<pre><code>const onAddBtnClick = (e) => {
setChipsActive(true);
setChips(
chips.length === 0
? chips.concat({
key: chips.length,
label: e.target.value.toUpperCase(),
id: e.target.name,
})
: chips.map((obj) => {
if (obj.id === e.target.name) {
return { ...obj, label: e.target.value.toUpperCase() };
} else {
chips.concat({
key: chips.length,
label: e.target.value.toUpperCase(),
id: e.target.name,
});
}
return obj;
}),
);
};
</code></pre>
| [
{
"answer_id": 74223374,
"author": "Junghard",
"author_id": 6486943,
"author_profile": "https://Stackoverflow.com/users/6486943",
"pm_score": 1,
"selected": false,
"text": "concat"
},
{
"answer_id": 74233275,
"author": "SirThanksALot",
"author_id": 19358592,
"author_p... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223267",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19358592/"
] |
74,223,274 | <p>Looking for the best practice in c# program for using constant depends on running env (dev/prod)</p>
<p>I used const values but the problem is when switching environment.</p>
<p>Looking for a good DP/OOP idea.</p>
| [
{
"answer_id": 74223374,
"author": "Junghard",
"author_id": 6486943,
"author_profile": "https://Stackoverflow.com/users/6486943",
"pm_score": 1,
"selected": false,
"text": "concat"
},
{
"answer_id": 74233275,
"author": "SirThanksALot",
"author_id": 19358592,
"author_p... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223274",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20349581/"
] |
74,223,278 | <p>Is it possible with only CSS to have the following effect:
I have two divs. One follows the other.<br />
Now, if the user starts scrolling down the page (to see other content, more divs if you want..) the second div should "go up" (could also stay fixed and the first div goes down, I mean it would look the same) and overlap the first.<br />
But only overlap for let's say 50px. After that, the behaviour is normal again, meaning that if you scroll further, those divs move out of the browser window eventually.</p>
<p>Have I made myself clear? I can add two coloured boxed to showcase if that helps. I played around a bit and tried parallex/position fixed/sticky mixes, but none seem to work with a given height restriction. I just wonder if this is possible without javascript.</p>
<p><a href="https://i.stack.imgur.com/nayxh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nayxh.png" alt="Visual representation" /></a></p>
| [
{
"answer_id": 74223374,
"author": "Junghard",
"author_id": 6486943,
"author_profile": "https://Stackoverflow.com/users/6486943",
"pm_score": 1,
"selected": false,
"text": "concat"
},
{
"answer_id": 74233275,
"author": "SirThanksALot",
"author_id": 19358592,
"author_p... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223278",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11124740/"
] |
74,223,299 | <p>I am trying to preset a default value in the below <code>p-dropdown</code>.</p>
<p><strong>[ item.component.html ]</strong></p>
<pre class="lang-js prettyprint-override"><code><ng-template pTemplate="body" let-newItem>
<tr>
<td>
<p-tableCheckbox [value]="newItem"></p-tableCheckbox>
</td>
<td>{{ newItem.Key }}</td>
<td>{{ newItem.Value }}</td>
<td>
<p-dropdown
[options]="itemLists"
optionLabel="name"
optionValue="id"
placeholder="Select an item"
[filter]="true"
filterBy="name"
(onChange)="selectItem($event.value)"
></p-dropdown>
</td>
</tr>
</ng-template>
</code></pre>
<p>I am getting json data from API and the data looks like</p>
<pre class="lang-json prettyprint-override"><code>[
{
name: "clutch",
id: 1
},
{
name: "hat",
id: 2
},
{
name: "jeans",
id: 3
},
]
</code></pre>
<p>This is a part of the .ts file.</p>
<p><strong>[ item.component.ts ]</strong></p>
<pre class="lang-js prettyprint-override"><code>export class ItemComponent implements OnInit {
itemLists: any[] = [];
selectedId: any[] = [];
constructor(
private itemService: ItemService
){}
ngOnInit(): void {
this.getItems();
}
getItems() {
this.itemService.getItemLists().subscribe(
(res) => {
this.itemLists = res;
},
(err) => {
console.log(err);
}
);
}
selectItem(id: any){
this.selectedId.push(id);
}
}
</code></pre>
<p>When users open the template and go to the p-dropdown, I want "hat" to be already selected by default. How can I make this? Any help, please</p>
| [
{
"answer_id": 74223374,
"author": "Junghard",
"author_id": 6486943,
"author_profile": "https://Stackoverflow.com/users/6486943",
"pm_score": 1,
"selected": false,
"text": "concat"
},
{
"answer_id": 74233275,
"author": "SirThanksALot",
"author_id": 19358592,
"author_p... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223299",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20111546/"
] |
74,223,372 | <p>I want the <strong>step by step explanation</strong> of the following code:</p>
<pre><code>print(1 | 0 ^ 1 & ~0)
</code></pre>
<p>I tried with the output bit (output with first and second bit) and <strong>got the answer as 0</strong>. The tilde function got me hooked up for some time I found it a bit hard. <strong>The answer is 1</strong>.</p>
| [
{
"answer_id": 74223613,
"author": "James Newman",
"author_id": 14504673,
"author_profile": "https://Stackoverflow.com/users/14504673",
"pm_score": 3,
"selected": true,
"text": "|"
},
{
"answer_id": 74223645,
"author": "Daniel Martin",
"author_id": 107331,
"author_pro... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,223,390 | <p>I'm should use <code>until</code> loop to get first 10 commands from history line by line.</p>
<p>Tried something like:</p>
<pre><code>counter=0
until [ $counter -gt 10 ]
do
echo !$counter
((counter++))
done
</code></pre>
<p>But output is <code>docounter</code> ten times.</p>
<p>The main issue is how to get inside loop specific line from history.</p>
| [
{
"answer_id": 74223613,
"author": "James Newman",
"author_id": 14504673,
"author_profile": "https://Stackoverflow.com/users/14504673",
"pm_score": 3,
"selected": true,
"text": "|"
},
{
"answer_id": 74223645,
"author": "Daniel Martin",
"author_id": 107331,
"author_pro... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223390",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2262562/"
] |
74,223,425 | <p>I want to create one list with one Id and multiple ProviderId values like</p>
<pre><code>Id ProviderId
1 "val1"
1 "val2"
</code></pre>
<p>I have a model class as per below :</p>
<pre><code>public class Model
{
[JsonProperty]
public string Id { get; set; }
[JsonProperty]
public List<PrefDictionary> ProviderId { get; set; }
}
</code></pre>
<p>Now I have created one list as per below :</p>
<pre><code>List<PrefDictionary> PrefData = data.Select(p => new PrefDictionary()
{
_1 = p.PrefDictionary._1,
_2 = p.PrefDictionary._2
}).ToList();
</code></pre>
<p>Here in data I am getting whole json format data and one node is like this below for PrefDictionary.</p>
<pre><code>data = {
Id : 1,
PrefDictionary{
1: "Val1",
2: "Val2"
}}
</code></pre>
<p>Now then I have created one more list as per below :</p>
<pre><code>List<Model> PP = data.Select(p => new Model()
{
Id = p.Id,
ProviderId = PrefData.Select(x => new PrefDictionary()
{
_1 = x._1,
_2 = x._2
}).ToList(),
}).ToList();
}
</code></pre>
<p>But the problem is I am getting empty in second column list in first I am getting Id but not getting any value in second column.</p>
| [
{
"answer_id": 74223613,
"author": "James Newman",
"author_id": 14504673,
"author_profile": "https://Stackoverflow.com/users/14504673",
"pm_score": 3,
"selected": true,
"text": "|"
},
{
"answer_id": 74223645,
"author": "Daniel Martin",
"author_id": 107331,
"author_pro... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223425",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17029269/"
] |
74,223,429 | <p>I have a Blazor Component Library.
In the library my js code generates a huge string which is about 160 000 characters. Simplified JS below (actualy this is base64 string)</p>
<pre><code>export function showPrompt(message): Uint8Array {
alert(message);
let str = "";
for(let i = 0; i < 164232; i++)
str += "A";
return new TextEncoder().encode(str);
}
</code></pre>
<p>My C# code is:</p>
<pre><code>async void CallJS() {
string? str = null;
IJSStreamReference? jsStream = await Prompt("After you will press ok, long string will be generated");
if (jsStream != null) {
using Stream referenceStream = await jsStream.OpenReadStreamAsync();
byte[] byteArray = new byte[referenceStream.Length];
int byteArrayCount = await referenceStream.ReadAsync(byteArray);
str = System.Text.Encoding.Default.GetString(byteArray, 0, byteArrayCount);
}
length = str?.Length ?? 0;
}
</code></pre>
<p>When I use this component in Blazor Server App, C# gets only 32 thousands chars. As I understand this is due to Signal-R limitation. I've found this topic: <a href="https://stackoverflow.com/questions/68371516/pass-large-js-blob-to-blazor-byte">Pass large JS blob to Blazor byte[]</a> and tried the solution, but even with the code below, c# receives only 50 000 characters.</p>
<pre><code> services.AddSignalR(o => {
o.EnableDetailedErrors = true;
o.MaximumReceiveMessageSize = long.MaxValue;
});
</code></pre>
<p>How to pass a huge string from JS to C# in Blazor?</p>
| [
{
"answer_id": 74223613,
"author": "James Newman",
"author_id": 14504673,
"author_profile": "https://Stackoverflow.com/users/14504673",
"pm_score": 3,
"selected": true,
"text": "|"
},
{
"answer_id": 74223645,
"author": "Daniel Martin",
"author_id": 107331,
"author_pro... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/834019/"
] |
74,223,459 | <p>Suppose I have interface foo and bar, then have multiple classes that implements both of them:</p>
<pre><code>public interface InterfaceFoo{
int getFoo()
}
public interface InterfaceBar{
int getBar()
}
public class FooBarOne implements InterfaceFoo, InterfaceBar{
public int getFoo() { ... }
public int getBar() { ... }
}
public class FooBarTwo implements InterfaceFoo, InterfaceBar{
public int getFoo() { ... }
public int getBar() { ... }
}
</code></pre>
<p>Then I create beans for both of these classes:</p>
<pre><code>@Configuration
@ComponentScan
public class Config {
@Bean
fooBarOne getFooBarOne() { return new FooBarOne(); }
@Bean
fooBarTwo getFooBarTwo() { return new FooBarTwo();}
}
</code></pre>
<p>Finally another bean which @Autowries in a list of all implementations of foo</p>
<pre><code>@Configuration
@ComponentScan
public class FooConfig {
@Bean
@Autowired
public List<InterfaceFoo> fooFetcher(List<<InterfaceFoo>> listFoos) {
return listFoos;
}
}
</code></pre>
<p>My question is, how does Spring identify/autowire beans when they have multiple implementations of an interface? The above pseudo code seems to work, however, if I change the return type of the bean from the concrete class to an ibar, it is not picked up by the autowire:</p>
<pre><code>@Configuration
@ComponentScan
public class Config {
@Bean
InterfaceBar getFooBarOne() { return new FooBarOne(); }
@Bean
InterfaceBar getFooBarTwo() { return new FooBarOne(); }
}
</code></pre>
<p>From the example above, spring does not pick these beans up when autowiring for implementations of ifoo. Switching the return type to ifoo works, which implies to me that spring looks at the return type of the bean rather than that of the returned object? Even though fooBarOne and fooBarTwo both implement foo and bar, do I need to return either the concrete class or interface ifoo if I want the autowire for List to pick it up?</p>
| [
{
"answer_id": 74223613,
"author": "James Newman",
"author_id": 14504673,
"author_profile": "https://Stackoverflow.com/users/14504673",
"pm_score": 3,
"selected": true,
"text": "|"
},
{
"answer_id": 74223645,
"author": "Daniel Martin",
"author_id": 107331,
"author_pro... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223459",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7298643/"
] |
74,223,461 | <p>The following demo code:</p>
<pre><code>mydict = {}
mylist = []
mydict["s"] = 1
mydict["p"] = "hasprice"
mydict["o"] = 3
print(mydict)
mylist.append(mydict)
mydict["s"] = 22
mydict["p"] = "hasvat"
mydict["o"] = 66
print(mydict)
mylist.append(mydict)
print(mylist)
</code></pre>
<p>prints out the following result:</p>
<pre><code>[{'s': 22, 'p': 'hasvat', 'o': 66}, {'s': 22, 'p': 'hasvat', 'o': 66}]
</code></pre>
<p>and the only explanation that comes to my mind is that mydict is assigned by reference and therefore the list items all point to a same memory object. Is this the reason?</p>
<p>How can I properly append multiple different dictionaries to the list?</p>
<p>I am building each mydict dictionary within a loop and then wanted to append it to the list which I will finally write to a JSON file.</p>
| [
{
"answer_id": 74223545,
"author": "David Rubio",
"author_id": 5704012,
"author_profile": "https://Stackoverflow.com/users/5704012",
"pm_score": 2,
"selected": false,
"text": "mydict = {}\nmylist = []\n\nmydict[\"s\"] = 1\nmydict[\"p\"] = \"hasprice\"\nmydict[\"o\"] = 3\nprint(mydict)\nm... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223461",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7800760/"
] |
74,223,495 | <p>I have a Dataframe with hundreds of columns and very long column-names. <strong>I want to remove any text in the column-names after the ":" or "."</strong> This is basically splitting on multiple delimiters.</p>
<p>I tried to extract column-names in a list and use the split method at ":" and "." and then keep only the portion of the text before ":" or "." but the split did not work as I wanted. I do not know why. any idea how to fix it and achieve my goal.</p>
<pre><code>data = {'Name of the injured. Bla bla bla': ['Bill', 'John'],
'Age of the injured: bla bla': [50,40],
}
df_data = pd.DataFrame.from_dict(data)
print(df_data)
cols = df_data.columns.values
new_cols = [( x.split(':') or x.split('.') ) for x in cols]
print(new_cols)
</code></pre>
<p>This is the outcome that I need:</p>
<p><a href="https://i.stack.imgur.com/rn6MH.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rn6MH.png" alt="enter image description here" /></a></p>
<p>Thanks,
GR</p>
| [
{
"answer_id": 74223675,
"author": "Naveed",
"author_id": 3494754,
"author_profile": "https://Stackoverflow.com/users/3494754",
"pm_score": 0,
"selected": false,
"text": "import re\n\n# using re.split, split the col on multiple delimiters\n# list comprehension to form a list of columns\n... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223495",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16179815/"
] |
74,223,504 | <p>I'm trying to train multiple "documents" (here mostly log format), and the Doc2Vec is taking longer if I'm specifying more than one core (which i have).</p>
<p>My data looks like this:</p>
<pre><code>print(len(train_corpus))
7930196
</code></pre>
<pre><code>print(train_corpus[:5])
[TaggedDocument(words=['port', 'ssh'], tags=[0]),
TaggedDocument(words=['session', 'initialize', 'by', 'client'], tags=[1]),
TaggedDocument(words=['dfs', 'fsnamesystem', 'block', 'namesystem', 'addstoredblock', 'blockmap', 'update', 'be', 'to', 'blk', 'size'], tags=[2]),
TaggedDocument(words=['appl', 'selfupdate', 'component', 'amd', 'microsoft', 'windows', 'kernel', 'none', 'elevation', 'lower', 'version', 'revision', 'holder'], tags=[3]),
TaggedDocument(words=['ramfs', 'tclass', 'blk', 'file'], tags=[4])]
</code></pre>
<p>I have 8 cores available:</p>
<pre><code>print(os.cpu_count())
8
</code></pre>
<p>I am using gensim 4.1.2, on Centos7. Using this approch (stackoverflow.com/a/37190672/130288), It looks like my BLAS library is OpenBlas, so I setted <strong>OPENBLAS_NUM_THREADS=1</strong> on my bashrc (and could be visible from Jupyter, using !echo $OPENBLAS_NUM_THREADS=1 )</p>
<p>This is my test code :</p>
<pre><code>dict_time_workers = dict()
for workers in range(1, 9):
model = Doc2Vec(vector_size=20,
min_count=1,
workers=workers,
epochs=1)
model.build_vocab(train_corpus, update = False)
t1 = time.time()
model.train(train_corpus, epochs=1, total_examples=model.corpus_count)
dict_time_workers[workers] = time.time() - t1
</code></pre>
<p>And the variable <code>dict_time_workers</code> is equal too :</p>
<pre><code>{1: 224.23211407661438,
2: 273.408652305603,
3: 313.1667754650116,
4: 331.1840877532959,
5: 433.83785605430603,
6: 545.671571969986,
7: 551.6248495578766,
8: 548.430994272232}
</code></pre>
<p>As you can see, the time taking is increasing instead of decreasing. Results seems to be the same with a bigger epochs parameters.
Nothing is running on my Centos7 except this.</p>
<p>If I look at what's happening on my threads using <strong>htop</strong>, I see that the right number of thread are used for each training. But, the more threads are used, less the percentage of usage is (for example, with only one thread, 95% is used, for 2 they both used around 65% of their max power, for 6 threads are 20-25% ...). I suspected an IO issue, but <strong>iotop</strong> showed me that nothing bad is happening at the same disk.</p>
<p>The post seems now to be related to this post
<a href="https://stackoverflow.com/questions/57532018/not-efficiently-to-use-multi-core-cpu-for-training-doc2vec-with-gensim">Not efficiently to use multi-Core CPU for training Doc2vec with gensim</a> .</p>
| [
{
"answer_id": 74226976,
"author": "gojomo",
"author_id": 130288,
"author_profile": "https://Stackoverflow.com/users/130288",
"pm_score": 3,
"selected": true,
"text": "workers"
},
{
"answer_id": 74289457,
"author": "Naindlac",
"author_id": 19580452,
"author_profile": ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19580452/"
] |
74,223,570 | <p>I have a column of times that are stored as strings. What I would like to do is take "3:00pm" and convert it to a datetime object that's 15:00 (24 hour clock).</p>
<p>I could always write a custom function that parses out the string, identifies whether it's am or pm, and create a mapping, but I was wondering if there's any built in functionality in Python or Pandas to do this efficiently.</p>
<p>Thanks so much!</p>
| [
{
"answer_id": 74223648,
"author": "Gonçalo Peres",
"author_id": 7109869,
"author_profile": "https://Stackoverflow.com/users/7109869",
"pm_score": 1,
"selected": false,
"text": " Time Value\n0 7:00pm 48\n1 8:00pm 48\n2 11:00am 8\n3 5:00pm 8\n4 12:00pm ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10901843/"
] |
74,223,581 | <p>I am trying to run a flutter app locally on my web browser (chrome). I do the following steps:</p>
<pre><code>flutter channel stable
flutter config --enable-web
flutter run -d chrome
</code></pre>
<p>when I run it, it starts fine, and opens chrome but it doesn't load anything, and then throws this error:</p>
<pre><code>"FirebaseOptions cannot be null when creating the default app."
at Object.throw_ [as throw] (http://localhost:63723/dart_sdk.js:5080:11)
at Object.assertFailed (http://localhost:63723/dart_sdk.js:5005:15)
at firebase_core_web.FirebaseCoreWeb.new.initializeApp (http://localhost:63723/packages/firebase_core_web/firebase_core_web.dart.lib.js:252:42)
at initializeApp.next (<anonymous>)
at http://localhost:63723/dart_sdk.js:40641:33
at _RootZone.runUnary (http://localhost:63723/dart_sdk.js:40511:59)
at _FutureListener.thenAwait.handleValue (http://localhost:63723/dart_sdk.js:35438:29)
at handleValueCallback (http://localhost:63723/dart_sdk.js:35999:49)
at _Future._propagateToListeners (http://localhost:63723/dart_sdk.js:36037:17)
at [_completeWithValue] (http://localhost:63723/dart_sdk.js:35872:23)
at async._AsyncCallbackEntry.new.callback (http://localhost:63723/dart_sdk.js:35906:35)
at Object._microtaskLoop (http://localhost:63723/dart_sdk.js:40778:13)
at _startMicrotaskLoop (http://localhost:63723/dart_sdk.js:40784:13)
at http://localhost:63723/dart_sdk.js:36261:9
</code></pre>
<p>how would I fix this?</p>
<p>edit:</p>
<pre><code>void main() async{
WidgetsFlutterBinding.ensureInitialized();
setPathUrlStrategy();
await Firebase.initializeApp();
</code></pre>
| [
{
"answer_id": 74223648,
"author": "Gonçalo Peres",
"author_id": 7109869,
"author_profile": "https://Stackoverflow.com/users/7109869",
"pm_score": 1,
"selected": false,
"text": " Time Value\n0 7:00pm 48\n1 8:00pm 48\n2 11:00am 8\n3 5:00pm 8\n4 12:00pm ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223581",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18084427/"
] |
74,223,627 | <p>I am hoping to make a plot from a large tibble, which only contains specific terms. Specifically, I have a column titled "media" where there are 7 types of media. I want to plot only the media types that contain "SW" (I have both DW and DW75). I was able to plot each media individually as well as all media together, but not calling specific terms from the media column.</p>
<p>Each unique chemical listed under "chem" should be its own plot. This is the script I used to plot the combined plots.</p>
<pre><code>PlotChem<-function(MatrixDataCompiled){
ggplot(data=MatrixDataCompiled,aes(x=LogConc, color = Media))+
theme_bw()+
geom_point(aes(y = LogArea))+
geom_smooth(aes(y = LogArea), method = lm, se = TRUE)+
ggtitle(paste("Calibration curve for",MatrixDataCompiled$Chem[1]))
}
for(i in unique(MatrixDataCompiled$Chem)){
ChemDataComplied<-MatrixDataCompiled[MatrixDataCompiled$Chem==i,]
loglm75<-lm(data=ChemDataComplied,LogArea~LogConc)
PlotChem(ChemDataComplied)
ggsave(PlotChem(ChemDataComplied),filename=paste(ChemDataComplied$Chem[1],"Chemical Cal Curve.png"))
}
``
</code></pre>
| [
{
"answer_id": 74223648,
"author": "Gonçalo Peres",
"author_id": 7109869,
"author_profile": "https://Stackoverflow.com/users/7109869",
"pm_score": 1,
"selected": false,
"text": " Time Value\n0 7:00pm 48\n1 8:00pm 48\n2 11:00am 8\n3 5:00pm 8\n4 12:00pm ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223627",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20349772/"
] |
74,223,662 | <p>I have a two scenarios which occur in my code:</p>
<ol>
<li>A string that consist of just names and the last item does not have a designation (", CPA, CFA"). For instance, <strong>"John, Jan, Joe"</strong> and I use the code below to replace the last comma with and so I get <strong>"John, Jan and Joe"</strong></li>
<li>A string that consist of names and a CPA/CFA designation (", CPA, CFA") at the end such as <strong>"John, Jan, Joe, CPA, CFA"</strong>. In this scenario I need to replace the third to the end commma with and to get <strong>"John, Jan, and Joe, CPA, CFA"</strong>. I just need to handle the case of that third to the end comma. <strong>I will note these are just sample strings and really it could include more names</strong> (i.e., it could "jake, jan, joe, john, jessie") but ultimately I am just checking if that last name has the designations(extra commas) and if so it should account for it by only adding the and to replace the third to last comma.</li>
</ol>
<p>My goal is to properly add the and to the last item in the comma separated list to follow standard English practices. The designation commas for the last item throw off my Regex expression I was using to add that last and in replacement of the comma.</p>
<p>My code:</p>
<pre><code>if(str1.EndsWith(", CPA, CFA"))
{
//need to figure out
}
else
{
Regex.Replace(str1, ", ([^,]+)$", " and $1");
}
</code></pre>
| [
{
"answer_id": 74223648,
"author": "Gonçalo Peres",
"author_id": 7109869,
"author_profile": "https://Stackoverflow.com/users/7109869",
"pm_score": 1,
"selected": false,
"text": " Time Value\n0 7:00pm 48\n1 8:00pm 48\n2 11:00am 8\n3 5:00pm 8\n4 12:00pm ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223662",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5021945/"
] |
74,223,753 | <p>I am trying to read other website data using angular website with backend asp.net c#, other website has following login authentication after login need to read the data.</p>
<p>I have following authentical pages</p>
<ol>
<li>first page i have to enter username</li>
</ol>
<p><a href="https://i.stack.imgur.com/PgbLo.png" rel="nofollow noreferrer">https://i.stack.imgur.com/PgbLo.png</a></p>
<ol start="2">
<li>second page i have to enter password then click login</li>
</ol>
<p><a href="https://i.stack.imgur.com/xAr4E.png" rel="nofollow noreferrer">https://i.stack.imgur.com/xAr4E.png</a></p>
<ol start="3">
<li>after login it will redirect to home page which content information of person details</li>
</ol>
<p><a href="https://i.stack.imgur.com/2I4UX.png" rel="nofollow noreferrer">https://i.stack.imgur.com/2I4UX.png</a></p>
<p>I need to display third point page information Name, mobile, and address in my angular website.</p>
<p>Third page url will be looks like : <a href="http://www.xyz.com/1" rel="nofollow noreferrer">www.xyz.com/1</a></p>
<p>the above 1 digit in the url is id of information base on id information of third page will appear</p>
<p>I found some code using c# but how to manage logins</p>
<pre><code>System.Net.WebClient wc = new System.Net.WebClient();
byte[] raw = wc.DownloadData("http://www.yoursite.com/resource/file.htm");
string webData = System.Text.Encoding.UTF8.GetString(raw);
</code></pre>
<p>and other way</p>
<pre><code> System.Net.WebClient wc = new System.Net.WebClient();
string webData =
wc.DownloadString("http://www.yoursite.com/resource/file.htm");
System.Net.WebClient wc = new System.Net.WebClient();
</code></pre>
| [
{
"answer_id": 74360006,
"author": "stefan.seeland",
"author_id": 1258111,
"author_profile": "https://Stackoverflow.com/users/1258111",
"pm_score": 0,
"selected": false,
"text": "<!DOCTYPE html>\n<html>\n<body>\n<form action=\"/action_page.php\">\n <label for=\"name\">name:</label><br>\... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223753",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19918004/"
] |
74,223,766 | <p>For example 2211 needs to display 6 but I can't find a command that helps me with it.
I have already tried with cut but that can only cut one at a time.</p>
| [
{
"answer_id": 74223852,
"author": "ricard0",
"author_id": 5817105,
"author_profile": "https://Stackoverflow.com/users/5817105",
"pm_score": 2,
"selected": false,
"text": "#!/bin/bash\n\nnumber=\"2211\"\n\nresult=0\nfor (( i=0; i<${#number}; i++ )); do\n echo \"number[${i}]=${number:$i... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223766",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20349656/"
] |
74,223,786 | <p>I have the following tuple:</p>
<pre><code>my_list = (1000, 3000, 7000, 15000 ,79000)
</code></pre>
<p>For any given number I give to a <code>selected</code> variable, I want to return both the the value in the tuple minus the <code>interval</code> and the selected value. By interval I mean the delta/difference between the selected value and the prior one I want to output. See FAB's comment for further clarification. I'm talking about location/index when saying interval.</p>
<p>Let's say, for example:</p>
<pre><code>selected = 79000
interval = 2
</code></pre>
<p>Expected output: (7000, 79000)</p>
<p>or</p>
<pre><code>selected = 7000
interval = 1
</code></pre>
<p>Expected output: (3000, 7000)</p>
<p>Note that the order of the values in tehe expected output follows that of the values in the tuple. So never would a larger number be output before a smaller one.</p>
<p>The ouptput I expect both values to be in is either a tuple e.g. (3000, 15000) or a list [3000, 15000].</p>
| [
{
"answer_id": 74223855,
"author": "KillerRebooted",
"author_id": 18554284,
"author_profile": "https://Stackoverflow.com/users/18554284",
"pm_score": 0,
"selected": false,
"text": "my_list = (1, 2, 3, 4 ,5)\n\nselected = 5\ninterval = 2\nselected_location = my_list.index(selected) #Here,... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223786",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11147107/"
] |
74,223,805 | <pre class="lang-sql prettyprint-override"><code>SELECT DISTINCT *
FROM institutions
LEFT JOIN units ON Unit_Institution = Institution_Key
LEFT JOIN sites ON Site_Institution = Institution_Key OR Site_Key = Unit_Site
</code></pre>
<p>This request has extremely bad performance (despite indexes) because of the <code>OR</code>. Removing one side of it (no matter which one) divides the query cost by thousands.
What can I provide the MySQL engine to get solve this performance issue ?</p>
<p>Many thanks.</p>
| [
{
"answer_id": 74224365,
"author": "Zakaria Matlaoui",
"author_id": 20167795,
"author_profile": "https://Stackoverflow.com/users/20167795",
"pm_score": 1,
"selected": false,
"text": "SELECT DISTINCT <ALIAS>.<FIELD_NAME>,*\nFROM INSTITUTIONS INS\nLEFT JOIN UNITS UNI ON UNI.UNIT_INSTITUTI... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223805",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19800284/"
] |
74,223,807 | <p>In rows that have values like:</p>
<pre><code>' ,some value, some value,'
</code></pre>
<p>or</p>
<pre><code>'some value, some value, '
</code></pre>
<p>Using pyspark, I need to remove the empty space and <code>,</code> from either the beginning or the end of the string. How is this done with <code>regexp_replace</code>?</p>
| [
{
"answer_id": 74224365,
"author": "Zakaria Matlaoui",
"author_id": 20167795,
"author_profile": "https://Stackoverflow.com/users/20167795",
"pm_score": 1,
"selected": false,
"text": "SELECT DISTINCT <ALIAS>.<FIELD_NAME>,*\nFROM INSTITUTIONS INS\nLEFT JOIN UNITS UNI ON UNI.UNIT_INSTITUTI... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223807",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1291414/"
] |
74,223,812 | <p>I have a script that gets information about servers and stores it in a variable.</p>
<pre><code>➜ echo $report
Hostname : or-05-arm
CheckDate: 11:47 27-10-2022
CPU Usage: [..........] 0% [0.00/2]
RAM Usage: [###.......] 31% [1.8G/5.8G]
HDD Avail: 26G
Uptime : up 19 weeks
Hostname : contabo-3
CheckDate: 14:47 27-10-2022
CPU Usage: [#####.....] 50% [3.01/6]
RAM Usage: [###.......] 30% [4.7G/15.6G]
HDD Avail: 136G
Uptime : up 1 week
Hostname : contabo-2
CheckDate: 14:47 27-10-2022
CPU Usage: [#####.....] 53% [3.16/6]
RAM Usage: [##........] 25% [3.9G/15.6G]
HDD Avail: 176G
Uptime : up 1 week
</code></pre>
<p>Using awk and a column, I display the contents of the report variable on the screen in three columns.</p>
<pre><code>➜ echo $report | awk '{a[NR%7] = a[NR%7] (NR<=7 ? "" : ",") $0} END{for (i = 1; i <= 7; i++) print a[i%7]}' | column -t -s ','
Hostname : or-05-arm Hostname : contabo-3 Hostname : contabo-2
CheckDate: 11:47 27-10-2022 CheckDate: 14:47 27-10-2022 CheckDate: 14:47 27-10-2022
CPU Usage: [..........] 0% [0.00/2] CPU Usage: [#####.....] 50% [3.01/6] CPU Usage: [#####.....] 53% [3.16/6]
RAM Usage: [###.......] 31% [1.8G/5.8G] RAM Usage: [###.......] 30% [4.7G/15.6G] RAM Usage: [##........] 25% [3.9G/15.6G]
HDD Avail: 26G HDD Avail: 136G HDD Avail: 176G
Uptime : up 19 weeks Uptime : up 1 week Uptime : up 1 week
</code></pre>
<p>This works as long as no more than three servers are stored in the variable.
If there are more than three servers, then the output does not fit on the screen.</p>
<p>How to make 3 servers appear on the screen, then three more on the next line, and so on?</p>
| [
{
"answer_id": 74224365,
"author": "Zakaria Matlaoui",
"author_id": 20167795,
"author_profile": "https://Stackoverflow.com/users/20167795",
"pm_score": 1,
"selected": false,
"text": "SELECT DISTINCT <ALIAS>.<FIELD_NAME>,*\nFROM INSTITUTIONS INS\nLEFT JOIN UNITS UNI ON UNI.UNIT_INSTITUTI... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223812",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20349657/"
] |
74,223,818 | <p>I want to do a custom research inside my code in VsCode. For example: I want to search for the word 'SetState' inside 'useEffect'. Is there a method to do this kind of search?</p>
<p>Is there any plugin or method to do so?</p>
<p>I am trying to look for UseState inside useEffect in my Typescript code. I know how to find each one individually, but together, couldn't figure out</p>
| [
{
"answer_id": 74224365,
"author": "Zakaria Matlaoui",
"author_id": 20167795,
"author_profile": "https://Stackoverflow.com/users/20167795",
"pm_score": 1,
"selected": false,
"text": "SELECT DISTINCT <ALIAS>.<FIELD_NAME>,*\nFROM INSTITUTIONS INS\nLEFT JOIN UNITS UNI ON UNI.UNIT_INSTITUTI... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223818",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20350014/"
] |
74,223,826 | <p>Im trying to create a bottom navigation for mobile view and i would like to disable/remove the selected css style when the icon is clicked/pressed.</p>
<p>So whenever i click on an icon, the default style would make the text and icon larger. I want it to be the same size.</p>
<p>Please help. My code is down below.</p>
<pre><code>import { useState } from 'react';
import Box from '@mui/material/Box';
import BottomNavigation from '@mui/material/BottomNavigation';
import BottomNavigationAction from '@mui/material/BottomNavigationAction';
import AccessTimeIcon from '@mui/icons-material/AccessTime';
import AddIcon from '@mui/icons-material/Add';
import FitnessCenterIcon from '@mui/icons-material/FitnessCenter';
import { useNavigate } from 'react-router-dom';
import { styles } from './styles';
const BottomNav = () => {
const [value, setValue] = useState(0);
const navigate = useNavigate();
return (
<Box
sx={{
width: '100%',
position: 'fixed',
bottom: 0
}}
>
<BottomNavigation
showLabels
value={value}
onChange={(event, newValue) => {
setValue(newValue);
}}
>
<BottomNavigationAction
disableRipple
// onClick={}
label='History'
icon={<AccessTimeIcon sx={styles.icon} />}
/>
<BottomNavigationAction
disableRipple
label='Workout'
icon={<AddIcon sx={styles.icon} />}
/>
<BottomNavigationAction
disableRipple
label='Exercise'
icon={
<FitnessCenterIcon style={styles.icon} sx={{ rotate: '135deg' }} />
}
/>
</BottomNavigation>
</Box>
);
};
export default BottomNav;
</code></pre>
| [
{
"answer_id": 74224365,
"author": "Zakaria Matlaoui",
"author_id": 20167795,
"author_profile": "https://Stackoverflow.com/users/20167795",
"pm_score": 1,
"selected": false,
"text": "SELECT DISTINCT <ALIAS>.<FIELD_NAME>,*\nFROM INSTITUTIONS INS\nLEFT JOIN UNITS UNI ON UNI.UNIT_INSTITUTI... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14786327/"
] |
74,223,840 | <p>I'm stuck with this presumably easy task.</p>
<p>I have a data set that I want to group by on a certain variable and then for each of these groups, I want to get the count for several vars. I think that's a job for <code>map</code>, but I can't get my head around how that should look like. My idea was sth. like:</p>
<pre><code>library(tidyverse)
count_vars <- c("vs", "am", "gear")
mtcars |>
group_split(cyl) |>
map2(.x = _,
.y = !!!count_vars,
.f = ~.x |>
count(.y))
</code></pre>
<p>But this apparently doesn't work.</p>
<p>The expected outcome would be a list with one element per group and within each of these elements I would have another set of lists (one for each count var). I'd also be fine in getting a data frame within each group where the counts for each var are just row binded.</p>
<p>Any ideas?</p>
<p>Note: I do not want to have nested counts like in a simple <code>count(as, vs, gear)</code> command, instead I want to have three different "tables", one for each variable.</p>
<p>An example (doing it only for two vars could look like:</p>
<pre><code>[[1]][1]
# A tibble: 2 × 2
vs n
<dbl> <int>
1 0 1
2 1 10
[[1]][2]
# A tibble: 2 × 2
am n
<dbl> <int>
1 0 3
2 1 8
[[2]][1]
# A tibble: 2 × 2
vs n
<dbl> <int>
1 0 3
2 1 4
[[2]][2]
# A tibble: 2 × 2
am n
<dbl> <int>
1 0 4
2 1 3
[[3]][1]
# A tibble: 1 × 2
vs n
<dbl> <int>
1 0 14
[[3]][2]
# A tibble: 2 × 2
am n
<dbl> <int>
1 0 12
2 1 2
</code></pre>
| [
{
"answer_id": 74224006,
"author": "Seth",
"author_id": 19316600,
"author_profile": "https://Stackoverflow.com/users/19316600",
"pm_score": 0,
"selected": false,
"text": "mtcars %>%\n group_by(cyl) %>%\n count(vs, am, gear)\n"
},
{
"answer_id": 74224326,
"author": "akrun",
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223840",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2725773/"
] |
74,223,867 | <p>I want to dismiss a view controller that is not currently on top.</p>
<p>I present a view controller and when I present it I want the previous one closed.</p>
<p>To give more details, this is the path I follow A -> B -> C when I reach the C I want B to be closed.</p>
| [
{
"answer_id": 74224006,
"author": "Seth",
"author_id": 19316600,
"author_profile": "https://Stackoverflow.com/users/19316600",
"pm_score": 0,
"selected": false,
"text": "mtcars %>%\n group_by(cyl) %>%\n count(vs, am, gear)\n"
},
{
"answer_id": 74224326,
"author": "akrun",
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223867",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19391210/"
] |
74,223,918 | <p>So let's assume I have the following structure of response:</p>
<pre class="lang-json prettyprint-override"><code>"TestObject": [
{
"Created": "2022-10-27T07:17:30.671Z",
"Name": "NOTTEST",
"FlowInfo": {
"Type": "TESTTYPE",
"ActionRequired": false
}
},
{
"Created": "2022-10-27T09:54:54.582Z",
"Name": "TEST",
"FlowInfo": {
"Type": "TESTTYPE",
"ActionRequired": false
}
},{
"Created": "2022-10-27T09:55:55.582Z",
"Name": "TEST",
"FlowInfo": {
"Type": "TESTTYPE",
"ActionRequired": false
}
}],
}
</code></pre>
<p>I need to change "ActionRequired" to true for first occurrence in list with "Name"="TEST", all others objects with "Name"="TEST" should stay with false.</p>
<p>Here is my code snippet</p>
<pre class="lang-cs prettyprint-override"><code>var b = testObject
.OrderBy(d => d.Created)
.Where(d => d.Name == "TEST")
.Select(d => new ObjectFlowInfo {
ActionNeeded = true,
});
</code></pre>
| [
{
"answer_id": 74224006,
"author": "Seth",
"author_id": 19316600,
"author_profile": "https://Stackoverflow.com/users/19316600",
"pm_score": 0,
"selected": false,
"text": "mtcars %>%\n group_by(cyl) %>%\n count(vs, am, gear)\n"
},
{
"answer_id": 74224326,
"author": "akrun",
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223918",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19133539/"
] |
74,223,946 | <p>I would like to be able to retrieve all users in my Azure Active Directory and cache it so I could filter my users on demande. I know about the nextLink used for Pagination. I'm fairly new in the React world and Javascript so I need some help understanding how to cycle through all pages to get all my users. Here's the code I have right now :</p>
<pre><code> export async function searchADUser(searchQuery?: string, filter: string, orderBy: string = 'displayName')
{
const searchedUser = await graphClient!
.api('/users')
.header('ConsistencyLevel', 'eventual')
.filter(`${filter}`)
.search(`"${searchQuery}"`)
.orderby(`${orderBy}`)
.get();
const nextLink = searchedUser["@odata.nextLink"]
return searchedUser;
</code></pre>
<p>I was able to access the nextLink url using the ["@odata.nextLink"]. So my question is how to get all users ? Do I just loop until nextLink is null or there is a better way.</p>
<p>Thank you</p>
| [
{
"answer_id": 74224006,
"author": "Seth",
"author_id": 19316600,
"author_profile": "https://Stackoverflow.com/users/19316600",
"pm_score": 0,
"selected": false,
"text": "mtcars %>%\n group_by(cyl) %>%\n count(vs, am, gear)\n"
},
{
"answer_id": 74224326,
"author": "akrun",
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223946",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/336475/"
] |
74,223,977 | <p>I have this very simple table:</p>
<pre><code>CREATE TABLE MyTable
(
Id INT(6) PRIMARY KEY,
Name VARCHAR(200) /* NOT UNIQUE */
);
</code></pre>
<p>If I want the Name(s) that is(are) the most frequent and the corresponding count(s), I can neither do this</p>
<pre><code>SELECT Name, total
FROM table2
WHERE total = (SELECT MAX(total) FROM (SELECT Name, COUNT(*) AS total
FROM MyTable GROUP BY Name) table2);
</code></pre>
<p>nor this</p>
<pre><code>SELECT Name, total
FROM (SELECT Name, COUNT(*) AS total FROM MyTable GROUP BY Name) table1
WHERE total = (SELECT MAX(total) FROM table1);
</code></pre>
<p>Also, (let's say the maximum count is 4) in the second proposition, if I replace the third line by</p>
<pre><code>WHERE total = 4;
</code></pre>
<p>it works.<br />
Why is that so?</p>
<p>Thanks a lot</p>
| [
{
"answer_id": 74224006,
"author": "Seth",
"author_id": 19316600,
"author_profile": "https://Stackoverflow.com/users/19316600",
"pm_score": 0,
"selected": false,
"text": "mtcars %>%\n group_by(cyl) %>%\n count(vs, am, gear)\n"
},
{
"answer_id": 74224326,
"author": "akrun",
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74223977",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19905443/"
] |
74,224,009 | <p>In C# I'm converting a method that returns a dynamic object from .NET Framework to Core 6. The method takes the json output from MediaInfo from any type of video or audio file. We were using JavaScriptSerializer but that's not available in .Net Core.</p>
<p>Here is an example of the json for a video file.</p>
<pre><code>{"media": {"@ref": "d:\inetpub\ftproot\wbt\clicksafety\courses\references\clip_38_cvt.mp4","track": [{"@type": "general","videocount": "1","audiocount": "1","fileextension": "mp4","format": "mpeg-4","format_profile": "base media","codecid": "isom","codecid_compatible": "isom/iso2/avc1/mp41","vidSize": "6351654","vidSeconds": "48.048","overallbitrate": "1057551","vidFrameRate": "29.970","framecount": "1440","streamsize": "27456","headersize": "27448","datasize": "6324206","footersize": "0","isstreamable": "yes","file_created_date": "utc 2022-10-27 13:54:05.474","file_created_date_local": "2022-10-27 09:54:05.474","file_modified_date": "utc 2022-10-27 13:54:05.477","file_modified_date_local": "2022-10-27 09:54:05.477","encoded_application": "lavf58.45.100"},{"@type": "video","streamorder": "0","id": "1","format": "avc","format_profile": "high","format_level": "3.1","f
ormat_settings_cabac": "yes","format_settings_refframes": "4","codecid": "avc1","vidSeconds": "48.048","bitrate": "1000000","vidWidth": "1024","vidHeight": "576","sampled_vidWidth": "1024","sampled_vidHeight": "576","pixelaspectratio": "1.000","vidAspect": "1.778","vidRotation": "0.000","vidFrameRate_mode": "cfr","vidFrameRate_mode_original": "vfr","vidFrameRate": "29.970","framecount": "1440","colorspace": "yuv","chromasubsampling": "4:2:0","bitdepth": "8","scantype": "progressive","streamsize": "5991992","encoded_library": "x264 - core 161","encoded_library_name": "x264","encoded_library_version": "core 161","encoded_library_settings": "cabac=1 / ref=3 / deblock=1:0:0 / analyse=0x3:0x113 / me=hex / subme=7 / psy=1 / psy_rd=1.00:0.00 / mixed_ref=1 / me_range=16 / chroma_me=1 / trellis=1 / 8x8dct=1 / cqm=0 / deadzone=21,11 / fast_pskip=1 / chroma_qp_offset=-2 / threads=3 / lookahead_threads=1 / sliced_threads=0 /
nr=0 / decimate=1 / interlaced=0 / bluray_compat=0 / constrained_intra=0 / bframes=3 / b_pyramid=2 / b_adapt=1 / b_bias=0 / direct=1 / weightb=1 / open_gop=0 / weightp=2 / keyint=250 / keyint_min=25 / scenecut=40 / intra_refresh=0 / rc_lookahead=40 / rc=abr / mbtree=1 / bitrate=1000 / ratetol=1.0 / qcomp=0.60 / qpmin=0 / qpmax=69 / qpstep=4 / ip_ratio=1.41 / aq=1:1.00","extra": {"codecconfigurationbox": "avcc"}},{"@type": "audio","streamorder": "1","id": "2","format": "aac","format_settings_sbr": "no (explicit)","format_additionalfeatures": "lc","codecid": "mp4a-40-2","vidSeconds": "47.416","vidSeconds_lastframe": "-0.046","bitrate_mode": "cbr","bitrate": "56050","channels": "2","channelpositions": "front: l r","channellayout": "l r","samplesperframe": "1024","vidAudio": "11025","samplingcount": "522761","vidFrameRate": "10.767","framecount": "511","compression_mode": "lossy","streamsize": "332206","streamsize_proportion": "0.05230","default": "yes","alternategroup": "1"}]}}
</code></pre>
<p>MediaInfo's json has a root and two or three children. However, the children's properties are always different in number and name from file to file depending on the file type and what created the audio or video. So, no... POCOs don't work here.</p>
<p>We deserialize string into a dynamic object because we only need a small number of those properties. We need to keep returning a dynamic from the method because it's called by a large number of programs. So, not interested in using anything but dynamic objects. The string is deserialized with:</p>
<pre><code>dynamic o = JsonSerializer.Deserialize<dynamic>(jsonString);
</code></pre>
<p>Normally, we'd reference a value like o["media"]["track"][1]["vidHeight"]. In this case it error's out with "has some invalid arguments". Looking at "o" in the debugger, it shows a ValueKind Object and I'm not able to reference any of the properties directly.</p>
<pre><code>ValueKind = Object : "{"media": {"@ref": "d:.......... etc.
</code></pre>
<p>Newtonsoft deserializes this string fine using:</p>
<pre><code>o = JsonConvert.DeserializeObject<dynamic>(jsonString);
</code></pre>
<p>But we'd like to go the System.Text.Json route and not have the dependency on Newtonsoft. It also requires us to add .ToString() to the references like:</p>
<pre><code>o["media"]["track"][1]["vidHeight"].ToString();
</code></pre>
<p>While that doesn't look like a big deal, the dynamic object's properties are referenced in hundreds of locations in many different Windows Services, API's, Web Services, HTTP Handlers, programs, etc. that we'd like to avoid if possible.</p>
<p>So, how can I deserialize these strings with System.Text.Json into a dynamic object and reference them the same way, o["nameofwhatever"], as we did when using JavaScriptSerializer?</p>
| [
{
"answer_id": 74224203,
"author": "Guru Stron",
"author_id": 2501279,
"author_profile": "https://Stackoverflow.com/users/2501279",
"pm_score": 2,
"selected": false,
"text": "dynamic"
},
{
"answer_id": 74225206,
"author": "vernou",
"author_id": 2703673,
"author_profil... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224009",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5056011/"
] |
74,224,013 | <p>If I have a pandas dataframe A that looks like:</p>
<pre><code>index id some_number some_other_number
1 42 1.2 32
2 54 1.3 33
3 66 3.4 64
4 77 4.7 12
</code></pre>
<p>and another, dfB, with this:</p>
<pre><code>index id some_number some_other_number
1 42 1.2 32
2 99 1.3 33
3 11 3.4 64
4 77 4.7 12
</code></pre>
<p>What is the fastest way to update dfA such that if the id in the id column is present in dfB we get:</p>
<pre><code>index id some_number some_other_number id_is_in_dfB
1 42 1.2 32 True
2 54 1.3 33 False
3 66 3.4 64 False
4 77 4.7 12 True
</code></pre>
<p>At the moment i do:</p>
<pre><code>dfA["id_is_in_dfB"]=dfA["id"].isin(dfB["id"])
</code></pre>
<p>I was wondering if there are alternative quicker approaches?</p>
| [
{
"answer_id": 74224155,
"author": "Anisha Choudhury",
"author_id": 15240087,
"author_profile": "https://Stackoverflow.com/users/15240087",
"pm_score": -1,
"selected": false,
"text": "dfB['id_is_in_dfB'] = dfA['id']==dfB['id']\n"
},
{
"answer_id": 74232081,
"author": "dankal4... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224013",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6195489/"
] |
74,224,057 | <pre><code>import numpy as np
import h5py
x1 = [0, 1, 2, 3, 4]
y1 = ['a', 'b', 'c', 'd', 'e']
z1 = [5, 6, 7, 8, 9]
namesList = ['ID', 'Name', 'Path']
ds_dt = np.dtype({'names': namesList, 'formats': ['S32'] * 4})
rec_arr = np.rec.fromarrays([x1, y1, z1], dtype=ds_dt)
test = [[], [], []]
hdf5_file = h5py.File("test.h5", "w")
structure = hdf5_file.create_group('structure')
structure.create_dataset('images', data=test, compression='gzip', maxshape=(None,3))
structure['images'].resize((structure['images'].shape[0] + rec_arr.shape[0]), axis=0)
structure['images'][-rec_arr.shape[0]:] = rec_arr
</code></pre>
<p>I am starting with an empty dataset and I am trying to add data to that data set. When I view the file, nothing has been added and the dataset is empty. How do I fix this?</p>
| [
{
"answer_id": 74224155,
"author": "Anisha Choudhury",
"author_id": 15240087,
"author_profile": "https://Stackoverflow.com/users/15240087",
"pm_score": -1,
"selected": false,
"text": "dfB['id_is_in_dfB'] = dfA['id']==dfB['id']\n"
},
{
"answer_id": 74232081,
"author": "dankal4... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224057",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19401660/"
] |
74,224,065 | <p>Faced this problem, I need to link to code, but don't know how to do it. Tried just initialising the property with my view class type and also through delegation, but nothing works. How to access selectedImageView? Can you tell me please?<a href="https://i.stack.imgur.com/1LKwY.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1LKwY.png" alt="enter image description here" /></a></p>
<p><a href="https://i.stack.imgur.com/cBL3h.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/cBL3h.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74224155,
"author": "Anisha Choudhury",
"author_id": 15240087,
"author_profile": "https://Stackoverflow.com/users/15240087",
"pm_score": -1,
"selected": false,
"text": "dfB['id_is_in_dfB'] = dfA['id']==dfB['id']\n"
},
{
"answer_id": 74232081,
"author": "dankal4... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19726662/"
] |
74,224,114 | <p>My dataframe:</p>
<pre><code>import pandas as pd
import numpy as np
df = pd.DataFrame({'c1': [10, 11, 12, 13], 'c2': [100, 110, 120, 130], 'c3': [100, 110, 120, 130], 'c4': ['A', np.nan, np.nan, 'B']})
</code></pre>
<p>I need to replace row c2 and c3 from another dataframe using column 'c4'</p>
<p>replacer df:</p>
<pre><code>df_replacer = pd.DataFrame({'c2': [11, 22], 'c3': [99, 299], 'c4': ['A', 'B']})
</code></pre>
<p>Below is how I am doing: (Is there a cleaner way to do?)</p>
<pre><code>df = df.merge(df_replacer, on=['c4'], how='left')
df.loc[~df.c4.isna(), 'c2_x'] = df['c2_y']
df.loc[~df.c4.isna(), 'c3_x'] = df['c3_y']
df = df.rename({'c2_x': 'c2', 'c3_x':'c3'}, axis=1)
df = df[['c1', 'c2', 'c3', 'c4']]
</code></pre>
| [
{
"answer_id": 74224155,
"author": "Anisha Choudhury",
"author_id": 15240087,
"author_profile": "https://Stackoverflow.com/users/15240087",
"pm_score": -1,
"selected": false,
"text": "dfB['id_is_in_dfB'] = dfA['id']==dfB['id']\n"
},
{
"answer_id": 74232081,
"author": "dankal4... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224114",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17900863/"
] |
74,224,163 | <p>We are getting below error on Azure devops pipeline via Self hosted agent release when Azure web app is on Private network. No Error seen when the web app on azure is on Public.</p>
<p>Error: Error: Failed to deploy web package to App Service. Error: tunneling socket could not be established, statusCode=503</p>
<p>Made Azure web app to private and error comes. Moved to public no error seen.</p>
| [
{
"answer_id": 74259898,
"author": "Andy Li-MSFT",
"author_id": 7466674,
"author_profile": "https://Stackoverflow.com/users/7466674",
"pm_score": 1,
"selected": false,
"text": "xxx.scm.azurewebsites.net"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224163",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20350155/"
] |
74,224,232 | <p>I'm trying to add two different styles for horizontal an vertical scrollbars.</p>
<p>I want both horizontal and vertical scrolls in my document but with different thicknesses. I want to hide the vertical scrollbar but keep it scrollable.</p>
<p>How do I achieve that?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code><div class="scroll-container" style="width: 200px; height: 200px; overflow: scroll;">
<div style="width:300px; height:300px;">
<h1>Hello World</h1>
</div>
</div></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74224306,
"author": "Daniel Smith",
"author_id": 14930500,
"author_profile": "https://Stackoverflow.com/users/14930500",
"pm_score": 1,
"selected": false,
"text": "::-webkit-scrollbar {\n width: 4px;\n border: 1px solid #d5d5d5;\n}\n\n::-webkit-scrollbar-track {\n borde... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224232",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7584658/"
] |
74,224,255 | <p>I have a document where is a wrapper. This wrapper has two boxes. Box1 has div1 in which has some position (I can get the top position). On a click of a button the function returns the position of a div1, so that I'd be able to create div2 on the same level (pixels from top of the document), however something goes wrong. How should I approach it in order to create this div2 on the same level as div1 with JS? I've tried to do</p>
<pre><code>const div2 = documentElement("div");
div2.style.position = "absolute";
div2.style.top = div1Top;
getElementById("box2").appendChild(div2);
</code></pre>
<p>but it doesn't work the way I want. Is there an issue with my whole project or just the code above should be written differently?</p>
<p><a href="https://i.stack.imgur.com/qjDj4.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qjDj4.jpg" alt="enter image description here" /></a></p>
<p>HTML:</p>
<pre><code><div id="wrapper" className='flex flex-row'>
<div id="box1">
<div id="div1">
</div>
<button type="button" onClick={create}>
Create div2
</button>
</div>
<div id="box2">
</div>
</div>
</code></pre>
<p>JS:</p>
<pre><code>async function create() {
const div2 = document.createElement("div");
div2.style.position = "absolute";
div2.style.top = top;
document.getElementById("box2").appendChild(div2);
}
</code></pre>
<p>Thanks a lot in advance</p>
| [
{
"answer_id": 74224306,
"author": "Daniel Smith",
"author_id": 14930500,
"author_profile": "https://Stackoverflow.com/users/14930500",
"pm_score": 1,
"selected": false,
"text": "::-webkit-scrollbar {\n width: 4px;\n border: 1px solid #d5d5d5;\n}\n\n::-webkit-scrollbar-track {\n borde... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224255",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18805560/"
] |
74,224,263 | <p>I want to add an animation in my app after creating account in signup tab</p>
<pre><code> Padding(
padding: const EdgeInsets.symmetric(horizontal: 25.0),
child: GestureDetector(
onTap: signUp,
child: Container(
padding: EdgeInsets.all(20),
decoration: BoxDecoration(
color: Colors.lightBlueAccent,
borderRadius: BorderRadius.circular(12),
),
child: Center(
child: Text(
'Sign Up',
style: TextStyle(
color: Colors.white,
fontWeight: FontWeight.bold,
fontSize: 18,
),
),
),
),
),
),
</code></pre>
<p>I just want to add some animation in may mobile app. i just want put some animation like thank you for registered using JSON. Thank you in advance!!</p>
| [
{
"answer_id": 74224306,
"author": "Daniel Smith",
"author_id": 14930500,
"author_profile": "https://Stackoverflow.com/users/14930500",
"pm_score": 1,
"selected": false,
"text": "::-webkit-scrollbar {\n width: 4px;\n border: 1px solid #d5d5d5;\n}\n\n::-webkit-scrollbar-track {\n borde... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20167830/"
] |
74,224,269 | <p>I'm a beginner with regex and I'd like (for string.match() under lua) a regex that would recognize a positive or negative number prefixed by a special character (example : "!").
Example :</p>
<pre><code>"!1" -> "1"
"!-2" -> "-2"
"!+3" -> "+3"
"!" -> ""
</code></pre>
<p>I tried</p>
<pre><code>!(^[-+]?%d+)
</code></pre>
<p>but it does not work...</p>
| [
{
"answer_id": 74224399,
"author": "LMD",
"author_id": 7185318,
"author_profile": "https://Stackoverflow.com/users/7185318",
"pm_score": 3,
"selected": true,
"text": "^"
},
{
"answer_id": 74226102,
"author": "DaveInDev",
"author_id": 20346889,
"author_profile": "https... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20346889/"
] |
74,224,299 | <p>good morning. I'm facing the next issue below:</p>
<p><strong>TypeError: page.$(...).toBeVisible is not a function</strong></p>
<p>The line in question --> <code>await expect(await page.$(homeIcon()).toBeVisible())</code></p>
<p>This is the login-page.js:</p>
<pre><code>const {expect} = require("@playwright/test");
const delay = ms => new Promise(resolve => setTimeout(resolve, ms))
const pageTitle = async () => await page.$('//h2[contains(text(),\'My Profile\')]')
const homeIcon = async () => await page.$('//body/div[@id=\'__next\']/div[1]/div[1]/div[2]/div[1]')
const HomeTitle = async () => await page.$('//h2[contains(text(),\'Pre-Owned Activation\')]')
class LoginPage {
async navigateToHomePage(){
await page.goto('http://XX.XXX.XXX.51/')
await delay(2000)
}
async verifyHeaderIconHome(){
await expect(await page.$(homeIcon()).toBeVisible())
}
async verifyTitle(){
await expect(page.$(HomeTitle)).toBeVisible()
}
}
module.exports = { LoginPage };
</code></pre>
<p>Below is my login-step.js</p>
<pre><code>const { Given, When, Then } = require('@cucumber/cucumber');
const { LoginPage } = require('../page-objects/login-page')
const loginPage = new LoginPage()
Given('I navigate to the page', async function () {
await loginPage.navigateToHomePage()
});
When('I can see the header icon Home', async function () {
await loginPage.verifyHeaderIconHome()
});
Then('I am logged in the Onstar page', async function () {
await loginPage.verifyTitle()
});
</code></pre>
<p>By the way, this is my package.json:</p>
<pre><code>{
"name": "example-playwright",
"version": "1.0.0",
"description": "E2E Automation Framework",
"main": "index.js",
"scripts": {
"allure:generate": "npx allure generate ./allure-results --clean",
"allure:open": "npx allure open ./allure-report",
"allure:serve": "npx allure serve",
"test": "./node_modules/.bin/cucumber-js --require cucumber.js --require step-definitions/**/*.js --require features/**/*.js",
"posttest": "npm run allure:generate",
"allure": "allure serve reports/allure-results"
},
"author": "RGM",
"license": "ISC",
"dependencies": {
"@cucumber/cucumber": "^8.7.0",
"chai": "^4.3.6",
"prettier": "^2.7.1"
},
"jest": {
"verbose": true,
"moduleDirectories": [
"node_modules",
"src"
],
"preset": "ts-jest/presets/js-with-ts",
"testEnvironment": "node",
"allowJs": true,
"transform": {
"^.+\\.jsx?$": "babel-jest"
},
"transformIgnorePatterns": [
"<rootDir>/node_modules/(?!variables/.*)"
]
},
"devDependencies": {
"@babel/core": "^7.19.6",
"@babel/preset-env": "^7.19.4",
"@playwright/test": "^1.27.1",
"@testing-library/jest-dom": "^5.16.5",
"allure-commandline": "^2.18.1",
"babel-jest": "^29.2.2",
"experimental-allure-playwright": "^0.0.3",
"jest": "^29.2.2",
"playwright": "^1.27.1"
}
}
</code></pre>
<p>Can anobody help me with this? Thanks in advance!!!</p>
| [
{
"answer_id": 74224399,
"author": "LMD",
"author_id": 7185318,
"author_profile": "https://Stackoverflow.com/users/7185318",
"pm_score": 3,
"selected": true,
"text": "^"
},
{
"answer_id": 74226102,
"author": "DaveInDev",
"author_id": 20346889,
"author_profile": "https... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224299",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/8291902/"
] |
74,224,319 | <p>I need to build a regular expression to capture one or more windows paths inside a text. It's for a syntax highlighter.</p>
<p>Imagine this text:</p>
<pre><code>Hey, Bob!
I left you the report for tomorrow in D:\Files\Shares\report.pdf along
with the other reports.
There's also this pptx here D:\Files\Internal\source.pptx where you have
the original if you need to change anything.
Cheers!
Alice.
</code></pre>
<p>This one is easy to capture with <code>/[a-zA-Z]:\\[^\s]*/mg</code>. See it in regex101 here <a href="https://regex101.com/r/VcBV7M/1" rel="nofollow noreferrer">https://regex101.com/r/VcBV7M/1</a></p>
<p><a href="https://i.stack.imgur.com/ayFdS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ayFdS.png" alt="Capturing sample 1" /></a></p>
<h1>Nevertheless</h1>
<p>when the path has spaces like here:</p>
<pre><code>I left you the report for tomorrow in D:\Shared files\october report.pdf along
with the other reports.
</code></pre>
<p>then we run into problems: What is the path? <code>D:\Shared</code> or <code>D:\Shared files\october</code> or <code>D:\Shared files\october report.pdf</code> or <code>D:\Shared files\october report.pdf along</code>...</p>
<p>For a human it's simple to infer. For a computer it's impossible so I was thinking into forcing the users to use quotes or brackets to indicate the begin and end of the filename or path.</p>
<h1>Question</h1>
<p>How can I write a regex that given this:</p>
<pre><code>Hey, Bob!
I left you the report for tomorrow in "D:\Shared files\october report.pdf" along
with the other reports [Don't forget to add your punctuation]. See
also D:\Multifiles\charlie.docx for more info.
There's also this pptx here [D:\Internal files\source for report.pptx] where you have
the original if you need to change "anything like the boss wants".
Cheers!
Alice.
</code></pre>
<p>captures this?</p>
<pre><code>D:\Shared files\october report.pdf
D:\Multifiles\charlie.docx
D:\Internal files\source for report.pptx
</code></pre>
<p>but not</p>
<pre><code>Don't forget to add your punctuation
anything like the boss wants
</code></pre>
<p>Non-working sample: <a href="https://regex101.com/r/RGVPz6/2" rel="nofollow noreferrer">https://regex101.com/r/RGVPz6/2</a></p>
| [
{
"answer_id": 74224399,
"author": "LMD",
"author_id": 7185318,
"author_profile": "https://Stackoverflow.com/users/7185318",
"pm_score": 3,
"selected": true,
"text": "^"
},
{
"answer_id": 74226102,
"author": "DaveInDev",
"author_id": 20346889,
"author_profile": "https... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1315009/"
] |
74,224,331 | <p>I have a requirement where i need to add an alphabet A to Z sequentially to a string.
example :
OGCP223000 + A
OGCP223000 + B,etc</p>
<p>So that I get</p>
<p>OGCP223000A,OGCP223000B till OGCP223000Z, and start again every time I run the SP.
So one time I call the stored procedure I want A, and the next time I want B, and the time after that i want C, and so on
Please help</p>
<p>I used numbers by creating a sequence in SQL server, but could not for Alphabets</p>
| [
{
"answer_id": 74226283,
"author": "HABO",
"author_id": 92546,
"author_profile": "https://Stackoverflow.com/users/92546",
"pm_score": 0,
"selected": false,
"text": "sequence"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224331",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20350272/"
] |
74,224,382 | <p>I need to create an IntelliJ Maven project using Java code.
The command to create new Maven project is:</p>
<pre class="lang-none prettyprint-override"><code>mvn archetype:generate -DgroupId=ToolsQA -DartifactId=DemoMavenProject -DarchetypeArtifactId=maven-archetype-quickstart -DinteractiveMode=false
</code></pre>
<p>I need to write program code that runs this command through the command line.</p>
<p>Steps:</p>
<ul>
<li>run the command line</li>
<li>enter to C direction</li>
<li>enter the command that create new maven project.</li>
</ul>
<p>Thanks!</p>
<p><a href="https://i.stack.imgur.com/yWatk.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/yWatk.png" alt="I tried this code, and its not workung" /></a></p>
<p><a href="https://i.stack.imgur.com/VFz5y.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VFz5y.png" alt="I get the exception:" /></a></p>
| [
{
"answer_id": 74226283,
"author": "HABO",
"author_id": 92546,
"author_profile": "https://Stackoverflow.com/users/92546",
"pm_score": 0,
"selected": false,
"text": "sequence"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224382",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20149054/"
] |
74,224,393 | <p>So I was watching a course and stumbled on a method called <code>Object.assign()</code> which merges two objects together. But since objects are orderless, I was wondering in which order the properties of the objects would be merged. Kudos to any good answers.</p>
| [
{
"answer_id": 74226283,
"author": "HABO",
"author_id": 92546,
"author_profile": "https://Stackoverflow.com/users/92546",
"pm_score": 0,
"selected": false,
"text": "sequence"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224393",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,224,396 | <p>I am trying to write a statement to find matching values from two different tables and set table 1 suppression to 1 if person_id from table 2 matches person_id from table 1 in SQL.</p>
<p>Table 1 = id_num, person_id, phone_number, supression</p>
<p>table 2 = person_id, uid</p>
<p>So if person_id from table 2 matches person_id from table 1 it should set each record to 1 in suppression column in table 1.</p>
| [
{
"answer_id": 74226283,
"author": "HABO",
"author_id": 92546,
"author_profile": "https://Stackoverflow.com/users/92546",
"pm_score": 0,
"selected": false,
"text": "sequence"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224396",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10700002/"
] |
74,224,411 | <p>Suppose I have the following lists:</p>
<p><code>x = [0.5, 0.9, 0.1, 0.3, 0.6]</code></p>
<p><code>y = [0.4, 0.3, 0.6, 0.1, 0.9]</code></p>
<p>I want to write a function that iterates through the list and compares each value in order.</p>
<blockquote>
<pre><code> def compare_numbers(prob,thresh):
output = []
for x, y in zip(prob, thresh):
if x >= y:
output.append(1)
else:
output.append(0)
return output
</code></pre>
</blockquote>
<blockquote>
<pre><code> compare_numbers(x,y)
</code></pre>
</blockquote>
<p>This gives me Type Error: <code> 'float' object is not iterable'</code></p>
<p>Why is this?</p>
<p>I would expect the output to look like this:
<code>[1, 1, 0, 1, 0]</code></p>
<p>Is there anyway I could write this function such that if the "threshold" value was only one digit it would still work?</p>
<p>My current code to make the latter function is:</p>
<blockquote>
<pre><code>def compare_numbers(prob, thresh):
output = []
for n in prob:
if n >= thresh:
output.append(1)
else:
output.append(0)
return output
</code></pre>
</blockquote>
<blockquote>
<pre><code>compare_numbers(x,y)
</code></pre>
</blockquote>
<p>Yet this returns the Type Error: <code>TypeError: '>=' not supported between instances of 'int' and 'list'</code> when thresh is a list.</p>
| [
{
"answer_id": 74224468,
"author": "Franfrancisco9",
"author_id": 20350367,
"author_profile": "https://Stackoverflow.com/users/20350367",
"pm_score": 2,
"selected": true,
"text": " def compare_numbers(prob, thresh):\n output = []\n for n in range(len(prob)):\n if prob[n] ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224411",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18989838/"
] |
74,224,429 | <p>My problem is with using an Axios response in Vue.js; it seems that the data is not saved to the array (<code>newBox</code>).</p>
<p>I want to save API-returned values to an array for use with <code>v-for</code> in the component.</p>
<pre class="lang-html prettyprint-override"><code><script setup>
import {
RouterLink,
RouterView
} from 'vue-router';
import {
onMounted,
onUnmounted
} from 'vue'
import Box from './components/Box.vue';
import axios from "axios"
import {
propsToAttrMap
} from '@vue/shared';
var newBox = new Array();
onMounted(() => {
getPosts();
})
async function getPosts() {
try {
const url = `https://someurl.ir/api/v1/api.php`
const response = await axios.get(url)
this.newBox = response.data
}))
} catch (err) {
if (err.response) {
// client received an error response (5xx, 4xx)
console.log("Server Error:", err)
}
}
}
</script>
<template>
<div class="NewBoxRibbon">
<Box v-for="title in newBox" :msg="title" />
</div>
<RouterView />
</template>
<style scoped>
.NewBoxRibbon{
scrollbar-width: 0px;
width: 100%;
height: 450px;
background-color: aquamarine;
overflow-x: auto;
white-space: nowrap;
}
::-webkit-scrollbar {
width: 0;
/* Remove scrollbar space */
background: transparent;
/* Optional: just make scrollbar invisible */
}
</style>
</code></pre>
<p>I used <code>fetch</code> and it too seems that in function <code>getPosts</code> it couldn't modify the array <code>newBox</code>...</p>
<p>Even when I define a variable and try to modify it in the function <code>getPosts</code>, can't do!!</p>
| [
{
"answer_id": 74224600,
"author": "Boussadjra Brahim",
"author_id": 8172857,
"author_profile": "https://Stackoverflow.com/users/8172857",
"pm_score": 3,
"selected": true,
"text": "newBox"
},
{
"answer_id": 74225038,
"author": "Tim",
"author_id": 20317091,
"author_pro... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224429",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4096520/"
] |
74,224,465 | <p>Here is my dataset</p>
<pre><code>mydata<-data.frame(
id=1:20,
sex=sample(c(rep("M",6),rep("F",14))),
Age=round(rnorm(20, 30,2)),
Weight=round(rnorm(20, 65,5),2)
)
</code></pre>
<p>I want my function to allow me to specify on which variable I want to do the filtering but also the criterion, i.e. <code>the operator (== or > or <=...)</code> and the <code>value (M or 65...)</code></p>
<p>This is the function I am trying to create. I know in advance that it won't work, it's to give an idea of what I want to create.</p>
<p>If I don't put the variable, value and operator of selection my function must return the original database otherwise the filtered database</p>
<pre><code> my_func<-function(select_var, select_crit){
mydata<-mydata<-if(is.null(select_var)&is.null(select_crit)){mydata}else{
mydata[ which(mydata[select_var]select_crit), ]
}
return(mydata)
}
</code></pre>
<p>For example I want to be able to select all the male with my function like this</p>
<pre><code>my_func(select_var="sex",select_crit="M"),
</code></pre>
<p>And all the induvidual > 30 (in age) like this:</p>
<p><code>my_func(select_var="Age",select_crit=">30")</code></p>
<p>or to select with the operator <code>%in%</code></p>
<p><code>my_func(select_var="Age",select_crit=%in%c(30:40))</code></p>
| [
{
"answer_id": 74224600,
"author": "Boussadjra Brahim",
"author_id": 8172857,
"author_profile": "https://Stackoverflow.com/users/8172857",
"pm_score": 3,
"selected": true,
"text": "newBox"
},
{
"answer_id": 74225038,
"author": "Tim",
"author_id": 20317091,
"author_pro... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11652655/"
] |
74,224,466 | <p>I'm working with Microsoft.Graph SDK and I need to get email SentItems programmatically in a class library.</p>
<p>I'm using the following code to create a client:</p>
<pre><code>private static Graph.GraphServiceClient CreateClient()
{
var scopes = new[] { "User.Read" };
// Multi-tenant apps can use "common",
// single-tenant apps must use the tenant ID from the Azure portal
var tenantId = "xxx";
// Value from app registration
var clientId = "xxxx";
var pca = Microsoft.Identity.Client.PublicClientApplicationBuilder
.Create(clientId)
.WithTenantId(tenantId)
.Build();
// DelegateAuthenticationProvider is a simple auth provider implementation
// that allows you to define an async function to retrieve a token
// Alternatively, you can create a class that implements IAuthenticationProvider
// for more complex scenarios
var authProvider = new Graph.DelegateAuthenticationProvider(async (request) =>
{
// Use Microsoft.Identity.Client to retrieve token
var result = await pca.AcquireTokenByIntegratedWindowsAuth(scopes).ExecuteAsync();
request.Headers.Authorization =
new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", result.AccessToken);
});
return new Graph.GraphServiceClient(authProvider);
}
</code></pre>
<p>then I'm trying to use the client the next waay:</p>
<pre><code>var sentEmails = graphClient.Users[authMail].MailFolders.SentItems.Request().GetAsync().Result;
</code></pre>
<p>but I'm getting the following exception when executing the request:</p>
<blockquote>
<p>Exception thrown: 'Microsoft.Identity.Client.MsalUiRequiredException'
in System.Private.CoreLib.dll Exception thrown:
'System.AggregateException' in System.Private.CoreLib.dll</p>
</blockquote>
<p>I thought that another option could be to get an auth token. I can get an auth token with the next code:</p>
<pre><code>private static async Task<string> GetGraphToken()
{
var resource = "https://graph.microsoft.com/";
var instance = "https://login.microsoftonline.com/";
var tenant = "xxx";
var clientID = "xxxx";
var secret = "xxxxx";
var authority = $"{instance}{tenant}";
var authContext = new AuthenticationContext(authority);
var credentials = new ClientCredential(clientID, secret);
var authResult = authContext.AcquireTokenAsync(resource, credentials).Result;
return authResult.AccessToken;
}
</code></pre>
<p>And it just works, but then I don't know how to use it to do an API request programmatically.</p>
<p>Any of the two variants is OK for me, getting rid of the exceptions in the first case, or finding a way to use the token to make a programmatic SDK API call in the second.</p>
<p>What can I try next?</p>
<h2>Edit 1</h2>
<p>I'm trying with the next approach, but the same exception is thrown:</p>
<pre><code>var accessToken = GetToken();
var client = new Graph.GraphServiceClient(
new Graph.DelegateAuthenticationProvider(
(requestMessage) =>
{
requestMessage.Headers.Authorization = new System.Net.Http.Headers.AuthenticationHeaderValue("Bearer", accessToken);
return Task.FromResult(0);
}));
var mails = client.Users[authMail].MailFolders.SentItems.Messages.Request().GetAsync().Result;
</code></pre>
| [
{
"answer_id": 74231363,
"author": "Tiny Wang",
"author_id": 14574199,
"author_profile": "https://Stackoverflow.com/users/14574199",
"pm_score": 1,
"selected": false,
"text": "Mail.ReadBasic.All, Mail.Read, Mail.ReadWrite"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224466",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2807741/"
] |
74,224,485 | <p>I have a vector of vectors of strings. I want to find the lengths of the longest string in each column. All the subvectors are of the same length and have an element stored in it, so it would be rather easy to find it with two for loops and reversed indices.</p>
<pre><code>vector<vector<string>> myvec = {
{ "a", "aaa", "aa"},
{"bb", "b", "bbbb"},
{"cc", "cc", "ccc"}
};
</code></pre>
<p>But is it possible to do it with iterators without using indices?</p>
| [
{
"answer_id": 74224974,
"author": "Nelfeal",
"author_id": 3854570,
"author_profile": "https://Stackoverflow.com/users/3854570",
"pm_score": 2,
"selected": false,
"text": "std::vector<std::size_t> max_lengths(myvec.front().size(), 0);\nfor (auto const& strings : myvec) {\n std::transf... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224485",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5019596/"
] |
74,224,513 | <p>I have a rather large JSON file I am attempting to parse and set definitions for in C#. I am getting an error from the Newtonsoft JSON Deserializer.</p>
<pre><code>Newtonsoft.Json.JsonSerializationException: 'Error converting value 151 to type 'QA_Test1.json.states'. Path 'MyFlow.states[1]', line 8378, position 15.'
- InnerException {"Could not cast or convert from System.Int64 to QA_Test1.json.states."} System.Exception {System.ArgumentException}
</code></pre>
<p>Because this element is an array [] and has a nested list, side by side with anonymous integers. I'm stuck here</p>
<pre><code>"states": [
{ .. some more json data
},
12,
14,
9,
10
]
</code></pre>
<p>The first problem (1) I don't even need the integer data, I need the nested data but the Newtonsoft Deserializer is still trying to deserialize the integer data without a def.</p>
<p>The second problem (2) The "variables" element has anonymous elements also, I want to get the names example anonomousVarName1 and get the properties of that item. But I wont know what they are. So having a definition I am finding difficult.</p>
<pre><code>"states": [
{ .. some more json data
},
12, // problem 1
14,
9,
10
],
"variables": {
"anonomousVarName1": {
"blah": ".VariableImpl",
"blah": 407
},
"blah": false,
"blah": null
},
"anonomousVarName2": {
{
"blah": ".VariableImpl",
"blah": 407
},
"blah": false,
"blah": null
}
}
</code></pre>
<p>My definition</p>
<pre><code>public class state_connections
{
[JsonProperty("states")]
public List<states> states { get; set; }
[JsonProperty("variables")]
public Dictionary<string, variables> variables { get; set; } // added resolution for problem 2
}
</code></pre>
<p>Problem #1 remains a huge issue
problem #2 is resolved by using</p>
<pre><code>Dictionary<string, variables> variables {get; set;}
</code></pre>
<p>Accessing the Dictionary variables</p>
<pre><code>connections_def file = JsonConvert.DeserializeObject<connections_def>(_data_file, new JsonSerializerSettings() { TypeNameHandling = TypeNameHandling.All, MaxDepth = 200, NullValueHandling = NullValueHandling.Ignore });
foreach(var variable in file.automatonFlow.variables)
{
Console.WriteLine();
Console.WriteLine($"Variable Key Name: {variable.Key}");
Console.WriteLine("--- properties ---");
Console.WriteLine($" @class: {variable.Value.@class}");
Console.WriteLine($" @id: {variable.Value.id}");
Console.WriteLine($" defaultValue: {variable.Value.defaultValue}");
Console.WriteLine($" id: {variable.Value.long_id}");
Console.WriteLine($" name: {variable.Value.name}");
Console.WriteLine($" notes: {variable.Value.notes}");
Console.WriteLine($" secure: {variable.Value.secure}");
Console.WriteLine($" stateId: {variable.Value.stateId}");
Console.WriteLine($" type: {variable.Value.type}");
}
</code></pre>
| [
{
"answer_id": 74224974,
"author": "Nelfeal",
"author_id": 3854570,
"author_profile": "https://Stackoverflow.com/users/3854570",
"pm_score": 2,
"selected": false,
"text": "std::vector<std::size_t> max_lengths(myvec.front().size(), 0);\nfor (auto const& strings : myvec) {\n std::transf... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224513",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2225375/"
] |
74,224,538 | <p>I have 100 file that looks like this</p>
<pre><code>>file.csv
gene1,55
gene2,23
gene3,33
</code></pre>
<p>I want to insert the filename and make it look like this:</p>
<pre><code>file.csv
gene1,55,file.csv
gene2,23,file.csv
gene3,33,file.csv
</code></pre>
<p>Now, I can almost get there using awk</p>
<p><code>awk '{print $0,FILENAME}' *.csv > concatenated_files.csv</code></p>
<p>But this prints the filenames with a space, instead of a comma. Is there a way to replace the space with a comma?</p>
| [
{
"answer_id": 74224654,
"author": "Workhorse",
"author_id": 1871399,
"author_profile": "https://Stackoverflow.com/users/1871399",
"pm_score": 0,
"selected": false,
"text": "for d in *.csv; do (awk '{print FILENAME (NF?\",\":\"\") $0}' \"$d\" > ${d}.all_files.csv); done"
},
{
"an... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224538",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1871399/"
] |
74,224,539 | <p>I am trying to create a list of buttons with values that are stored in a state and user is only allowed to use 1 item (I dont want to use radio input because I want to have more control over styling it).</p>
<pre class="lang-js prettyprint-override"><code>import React from "react";
import { useEffect, useState } from "react";
import "./styles.css";
const items = [
{ id: 1, text: "Easy and Fast" },
{ id: 2, text: "Easy and Cheap" },
{ id: 3, text: "Cheap and Fast" }
];
const App = () => {
const [task, setTask] = useState([]);
const clickTask = (item) => {
setTask([...task, item.id]);
console.log(task);
// how can I make sure only 1 item is added to task
// and remove the other items
// only one option is selectable all the time
};
const chosenTask = (item) => {
if (task.find((v) => v.id === item.id)) {
return true;
}
return false;
};
return (
<div className="App">
{items.map((item) => (
<li key={item.id}>
<label>
<button
type="button"
className={chosenTask(item) ? "chosen" : ""}
onClick={() => clickTask(item)}
onChange={() => clickTask(item)}
/>
<span>{item.text}</span>
</label>
</li>
))}
</div>
);
};
export default App;
</code></pre>
<p><a href="https://codesandbox.io/s/react-fiddle-forked-cvhivt?file=/src/App.js" rel="nofollow noreferrer">https://codesandbox.io/s/react-fiddle-forked-cvhivt?file=/src/App.js</a></p>
<p>I am trying to only allow 1 item to be added to the state at all the time, but I dont know how to do this?</p>
<p>Example output is to have <code>Easy and Fast</code> in task state and is selected. If user click on <code>Easy and Cheap</code>, select that one and store in task state and remove <code>Easy and Fast</code>. Only 1 item can be in the task state.</p>
| [
{
"answer_id": 74224654,
"author": "Workhorse",
"author_id": 1871399,
"author_profile": "https://Stackoverflow.com/users/1871399",
"pm_score": 0,
"selected": false,
"text": "for d in *.csv; do (awk '{print FILENAME (NF?\",\":\"\") $0}' \"$d\" > ${d}.all_files.csv); done"
},
{
"an... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224539",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4576720/"
] |
74,224,541 | <p>Django newbie here!
I am coming from .NET background I am frustrated as to how to do the following simple thing:</p>
<p>My simplified models are as follows</p>
<pre><code>class Circle(BaseClass):
name = models.CharField("Name", max_length=2048, blank=False, null=False)
active = models.BooleanField(default=False)
...
class CircleParticipant(BaseClass):
circle = models.ForeignKey(Circle, on_delete=models.CASCADE, null=True, blank=True)
user = models.ForeignKey(User, on_delete=models.SET_NULL, null=True, blank=True)
status = models.CharField("Status", max_length=256, blank=False, null=False)
...
class User(AbstractBaseUser, PermissionsMixin):
email = models.EmailField(verbose_name="Email", unique=True, max_length=255, validators=[email_validator])
first_name = models.CharField(verbose_name="First name", max_length=30, default="first")
last_name = models.CharField(verbose_name="Last name", max_length=30, default="last")
...
</code></pre>
<p>My goal is to get a single <code>circle</code> with <code>participants</code> that include the <code>users</code> as well. With the extra requirement to do all that in a single DB trip.</p>
<p>in SQL terms I want to accomplish this:</p>
<pre><code>SELECT circle.name, circle.active, circle_participant.status, user.email. user.first_name. user.last_name
FROM circle
JOIN circle_participant on circle.id = circle_participant.id
JOIN user on user.id = circle_participant.id
WHERE circle.id = 43
</code></pre>
<p>I've tried the following:</p>
<pre><code>Circle.objects.filter(id=43) \
.prefetch_related(Prefetch('circleparticipant_set', queryset=CircleParticipant.objects.prefetch_related('user')))
</code></pre>
<p>This is supposed to be working but when I check the <code>query</code> property on that statement it returns</p>
<pre><code>SELECT "circle"."id", "circle"."created", "circle"."updated", "circle"."name", "circle"."active", FROM "circle" WHERE "circle"."id" = 43
</code></pre>
<p>(additional fields omitted for brevity.)</p>
<p>Am I missing something or is the <code>query</code> property incorrect?</p>
<p>More importantly how can I achieve fetching all that data with a single DB trip.</p>
<p>For reference here's how to do it in .NET Entity Framework</p>
<pre><code>dbContext.Circle
.Filter(x => x.id == 43)
.Include(x => x.CircleParticipants) // This will exist in the entity/model
.ThenInclude(x => x.User)
</code></pre>
| [
{
"answer_id": 74225001,
"author": "Willem Van Onsem",
"author_id": 67579,
"author_profile": "https://Stackoverflow.com/users/67579",
"pm_score": 1,
"selected": false,
"text": ".prefetch_related"
},
{
"answer_id": 74225178,
"author": "Nick ODell",
"author_id": 530160,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224541",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1571349/"
] |
74,224,545 | <p>I have a textbox whose text input is constantly being read via a timer that runs every 100ms. I want to find a way (perhaps creating an event) that allows me to keep reading the previously inputted data until I have hit "Enter" on my keyboard or used my mouse in some way.</p>
<p>The current behavior is whenever I try to input a new number into this textbox, the value I put in gets read in "chunks" if it's a larger value. What I mean is that if I input any value higher than two digits eg. "10" and beyond, the value gets read as "1" then "10." And it gets worse for values that are in the hundreds</p>
<p>[Ex] 350 gets read as first "3" then "35" then finally "350."</p>
<p>This is of course because of the timer event happening so quickly, but it needs to be 100ms for the overall system.</p>
<p>I'm wondering if someone has an elegant way of allowing me to enter a number that is greater than 10 that will be read in as the full value instead of being broken up. I think this will have to be a "text_changed" event or something similar but I'm having difficultly implementing this</p>
| [
{
"answer_id": 74225001,
"author": "Willem Van Onsem",
"author_id": 67579,
"author_profile": "https://Stackoverflow.com/users/67579",
"pm_score": 1,
"selected": false,
"text": ".prefetch_related"
},
{
"answer_id": 74225178,
"author": "Nick ODell",
"author_id": 530160,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224545",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5970509/"
] |
74,224,570 | <p>I'm trying to understand why the command "git describe --tags --abbrev=0" doesn't return me the last tag I've created with Git.</p>
<p>That's what I've done.</p>
<p>Step 1: Tag creation</p>
<p>I've executed the following commands:</p>
<pre><code> git tag 1.0.1
git tag 1.0.2
git tag 1.0.3
git tag 1.0.4
git tag 1.0.5
git tag 1.0.6
git tag 1.0.7
git tag 1.0.8
git tag 1.0.9
git tag 1.0.10
git tag 1.0.11
git tag 1.0.12
</code></pre>
<p>Step 2 - Getting the list of all tags:</p>
<p>I've executed the following command:</p>
<pre><code> git tag
</code></pre>
<p>The result is the following:</p>
<pre><code> 1.0.0
1.0.1
1.0.10
1.0.11
1.0.12
1.0.2
1.0.3
1.0.4
1.0.5
1.0.6
1.0.7
1.0.8
1.0.9
</code></pre>
<p>Step 3 - Getting the last tag:</p>
<p>I've executed the following command:</p>
<pre><code> git describe --tags --abbrev=0
</code></pre>
<p>The result is the following:</p>
<pre><code> 1.0.1
</code></pre>
<p>Shouldn't it be "1.0.12"?</p>
| [
{
"answer_id": 74224610,
"author": "Fastnlight",
"author_id": 20153035,
"author_profile": "https://Stackoverflow.com/users/20153035",
"pm_score": 1,
"selected": false,
"text": "git describe"
},
{
"answer_id": 74224803,
"author": "Marek R",
"author_id": 1387438,
"autho... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224570",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5110683/"
] |
74,224,588 | <p>I'm new to C# and HTML and trying to write an expiration date calculator for our labs using Blazor. I have the logic all figured out behind the output besides the specific date format according to the if...else statement ---BUT--- my actual question is if someone could give me an idea on how to write the part of my code so when a user clicks the "Submit" button on this Blazor application, it will output what the logic had calculated.</p>
<p>I've looked through several pages on SO but none of them are quite what I'm looking for. I believe this may take an onClick event that's probably binded somehow to the function I wrote in the "@ code" part but if someone could explain the proper way of doing it, that would be awesome!</p>
<p>Thank you :)
(P.S the entire portion of the code that I am in charge of is below, the first part is HTML and after @ code it's C#)</p>
<p>EDIT: When the first "if" statement executes, the DateTime should be formatted as "mm/yyyy" in numeric terms like "09/2022".
If the first "if" statement doesn't pass, meaning one of the parameters was not met, then the date should be formatted as "yyyy/mm/dd" like "2022/10/28"</p>
<p>`</p>
<pre><code><!DOCTYPE html>
<html>
<body>
<!--
Code to create mix date textbox for input
-->
Mix Date:
<input type="tel" id="date" name="mix date" placeholder="DD/MM/YYYY" pattern="[0-9]{2}/[1-12]{2}/[0-9]{4}">
<br>
<br>
<!--
Creates the two checkboxes
-->
<form action="/action_page.php">
<input type="checkbox" id="mbefore" name="mbefore" value="false" @onclick="boxcheck2">
<label for="mbefore"> Made Before September 10th, 2022</label><br>
<input type="checkbox" id="pproduct" name="pproduct" value="false" @onclick="boxcheck1">
<label for="pproduct"> Plate Product</label><br>
</form>
<!--
Code to create shelf life textbox
-->
<br>
<label for="slife">Shelf Life:</label>
<input type="text" id="slife" name="slife" @bind="shelfLife"/>
<br>
<br>
<!--
Code to create submit button
-->
<button onclick="myFunction()">Submit</button>
<!--
Calculated expiration date (need to figure out how to get above to output into below textbox) and with the correct formatting depending on if..else conditions
Def an onlcick action
-->
<br>
<br>
<label for="exp">Expiration Date:</label>
<input type="text" id="exp" name="exp">
<p id="demo"></p>
</body>
</html>
@code {
private double shelfLife;
private DateTime mixDate;
private DateTime expDate;
private bool checkbox1;
private bool checkbox2;
private void boxcheck1()
{
checkbox1 = !checkbox1;
}
private void boxcheck2()
{
checkbox2 = !checkbox2;
}
private void myFunction() {
DateTime nMix = Convert.ToDateTime(mixDate);
if ((checkbox1 == true) && (checkbox2 == true) && (shelfLife > 90)) {
DateTime expDate = (mixDate + TimeSpan.FromDays(shelfLife)) + TimeSpan.FromDays(30);
Console.WriteLine(expDate);
}
else if ((checkbox1 == false) || (checkbox2 == false) || (shelfLife <90)) {
DateTime expDate = (mixDate + TimeSpan.FromDays(shelfLife)) - TimeSpan.FromDays(1);
Console.WriteLine(expDate);
}
else {
Console.WriteLine ("Please Try Again. Information Not Satisfactory");
}
}
}
</code></pre>
<p>`</p>
| [
{
"answer_id": 74224610,
"author": "Fastnlight",
"author_id": 20153035,
"author_profile": "https://Stackoverflow.com/users/20153035",
"pm_score": 1,
"selected": false,
"text": "git describe"
},
{
"answer_id": 74224803,
"author": "Marek R",
"author_id": 1387438,
"autho... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20333944/"
] |
74,224,599 | <p>I am thinking about this question.
How could I add a new value to this object without getting an error?</p>
<pre><code>data = {
'attributes': processed_data['attributes'],
'categories': processed_data['categories'],
'filters': processed_data['filters'],
'min_price': processed_data['min_price'],
'max_price': processed_data['max_price'],
'session_id': processed_data['session_id'],
'new_value': process_data['new_value'], # this value will not always exist
'client_id': session.clientId
}
</code></pre>
<p>in javascript I would use the ternary operator
but I don't know how I could proceed in python</p>
| [
{
"answer_id": 74224610,
"author": "Fastnlight",
"author_id": 20153035,
"author_profile": "https://Stackoverflow.com/users/20153035",
"pm_score": 1,
"selected": false,
"text": "git describe"
},
{
"answer_id": 74224803,
"author": "Marek R",
"author_id": 1387438,
"autho... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224599",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20190509/"
] |
74,224,619 | <p>Below is a sample data frame of what I am working with.</p>
<pre class="lang-r prettyprint-override"><code>df <- data.frame(
Sample = c('A', 'A', 'B', 'C'),
Length = c('100', '110', '99', '102'),
Molarity = c(5,4,6,7)
)
</code></pre>
<p>df</p>
<pre><code> Sample Length Molarity
1 A 100 5
2 A 110 4
3 B 99 6
4 C 102 7
</code></pre>
<p>I would like the result listed below but am unsure how to approach the problem.</p>
<pre><code> Sample Length Molarity
1 A 100,110 9
2 B 99 6
3 C 102 7
</code></pre>
| [
{
"answer_id": 74224629,
"author": "akrun",
"author_id": 3732271,
"author_profile": "https://Stackoverflow.com/users/3732271",
"pm_score": 3,
"selected": true,
"text": "library(dplyr)\ndf %>%\n group_by(Sample) %>%\n summarise(Length = toString(Length), Molarity = sum(Molarity))\n"
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224619",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11537219/"
] |
74,224,623 | <p>I'm trying to write a program to check it the two strings are balanced. For example, <code>s1</code> and <code>s2</code> are balanced if all the characters in the <code>s1</code> are present in <code>s2</code>. My compiler showing correct, but while evaluating in website it's showing error in balance one while unbalance working.</p>
<pre><code>def balance(s1,s2):
flag=True
if (len(s1) == len(s2)):
for i in s1:
if i in s2:
continue
else:
flag = False
return flag
s1 = input()
s2 = input()
if balance(s1, s2) == True:
print("Balance")
else:
print("Unbalanced")
</code></pre>
| [
{
"answer_id": 74224695,
"author": "KillerRebooted",
"author_id": 18554284,
"author_profile": "https://Stackoverflow.com/users/18554284",
"pm_score": 0,
"selected": false,
"text": "s1 = \"123\""
},
{
"answer_id": 74224706,
"author": "Tommaso Bianconcini",
"author_id": 635... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12186116/"
] |
74,224,631 | <p>I got a chain of events per user and need to select an specific event but need to select those who's maximun event is that in specific. Let me explain with a table.</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>User</th>
<th>Event</th>
</tr>
</thead>
<tbody>
<tr>
<td>XYZ</td>
<td>Event 1</td>
</tr>
<tr>
<td>XYZ</td>
<td>Event 2</td>
</tr>
<tr>
<td>XYZ</td>
<td>Event 3</td>
</tr>
<tr>
<td>XYZ</td>
<td>Event 4</td>
</tr>
</tbody>
</table>
</div>
<p>I need to select those who are in the event 3 and haven't pass to the event 4. It is a process in the database so I need those who are stuck in the event 3.</p>
<p>I was trying the fuction rank () but didn't work out.</p>
| [
{
"answer_id": 74224695,
"author": "KillerRebooted",
"author_id": 18554284,
"author_profile": "https://Stackoverflow.com/users/18554284",
"pm_score": 0,
"selected": false,
"text": "s1 = \"123\""
},
{
"answer_id": 74224706,
"author": "Tommaso Bianconcini",
"author_id": 635... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224631",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20325690/"
] |
74,224,633 | <p>Is there a way to return a result from a walker without reporting it using jaseci.</p>
<p>because when you report stuff in general it queues up in the final report which we don't need.</p>
<pre><code>report: [
{"response": "xyz"}
];
instead of
report: [
"jdsjdbjs",
"dndkfndkfn",
{"response": "xyz"}
];
</code></pre>
<p>it messes up with picking out records</p>
| [
{
"answer_id": 74224713,
"author": "Yiping Kang",
"author_id": 20302229,
"author_profile": "https://Stackoverflow.com/users/20302229",
"pm_score": 3,
"selected": true,
"text": "has anchor"
},
{
"answer_id": 74224781,
"author": "marsninja",
"author_id": 20295394,
"auth... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224633",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13159002/"
] |
74,224,660 | <p>Exception Type: IntegrityError</p>
<p>Exception Value:</p>
<p>NOT NULL constraint failed: Cart.cart_id</p>
<pre class="lang-py prettyprint-override"><code>#mymodel:
class Cart(models.Model):
cart_id=models.CharField(max_length=250,blank=True)
def _cart_id(request):
cart=request.session.session_key
if not cart:
cart=request.session.create()
def add_cart(request,product_id):
product=Product.objects.get(id=product_id)
try:
cart=Cart.objects.get(cart_id=_cart_id(request))
except Cart.DoesNotExist:
cart=Cart.objects.create(cart_id=_cart_id(request))
cart.save()
</code></pre>
| [
{
"answer_id": 74224713,
"author": "Yiping Kang",
"author_id": 20302229,
"author_profile": "https://Stackoverflow.com/users/20302229",
"pm_score": 3,
"selected": true,
"text": "has anchor"
},
{
"answer_id": 74224781,
"author": "marsninja",
"author_id": 20295394,
"auth... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224660",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20350428/"
] |
74,224,701 | <p>I have an if statement in a for loop, and I want it to create a variable with the lifetime of that iteration of the for loop.</p>
<pre class="lang-rust prettyprint-override"><code> for condition_raw in conditions_arr {
println!("{}", condition_raw);
let matching = !condition_raw.contains('!');
if matching {
let index = condition_raw.find('=').unwrap_or_default();
} else {
let index = condition_raw.find('!').unwrap_or_default();
}
let key = &condition_raw[..index];
}
</code></pre>
<p><code>let key = &condition_raw[..index];</code> currently throws cannot find value <code>index</code> in this scope
not found in this scope rustc E0425</p>
| [
{
"answer_id": 74224748,
"author": "Brandon Kauffman",
"author_id": 14256876,
"author_profile": "https://Stackoverflow.com/users/14256876",
"pm_score": 1,
"selected": false,
"text": "let index: usize = if matching {\n condition_raw.find('=').unwrap_or_default()\n } else... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224701",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14256876/"
] |
74,224,749 | <p>i am retrieving information from the database and using {%if%} and {%endif%} condition so if that field is blank it does not cause any problem but when that field does not have any value it creates a new blank line in place of that looks bad in styling I saw an answer use this {%if -%} {%- endif %}it doesn't work and throws the error all I want if field is blank do not create any new blank line and render second line below that without creating any whitespace
any suggestion will be helpfull</p>
| [
{
"answer_id": 74224785,
"author": "Swift",
"author_id": 8874154,
"author_profile": "https://Stackoverflow.com/users/8874154",
"pm_score": 0,
"selected": false,
"text": "{% spaceless %}\n Space less content here\n{% endspaceless %}\n"
},
{
"answer_id": 74224949,
"author": ... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224749",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14777930/"
] |
74,224,777 | <p>How to make <code>CircularProgressIndicator</code> in Jetpack Compose smaller or bigger than default size?</p>
<pre><code>CircularProgressIndicator(
modifier = Modifier
.size(32.dp),
)
</code></pre>
| [
{
"answer_id": 74224827,
"author": "Htue Ko",
"author_id": 9056898,
"author_profile": "https://Stackoverflow.com/users/9056898",
"pm_score": 0,
"selected": false,
"text": "CircularProgressIndicator(\n modifier = Modifier\n .progressSemantics()\n .size(32.dp),\n)\n"
},
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224777",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9056898/"
] |
74,224,782 | <p>I have a very simple background page for a Chrome extension:</p>
<pre><code>chrome.runtime.onInstalled.addListener((reason) => {
console.log(reason);
});
</code></pre>
<p>The background page runs when my extension is loaded:
<a href="https://i.stack.imgur.com/nvb2Z.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nvb2Z.png" alt="enter image description here" /></a></p>
<p>The extension also has a popup that runs <a href="https://developer.chrome.com/docs/extensions/reference/runtime/#method-getBackgroundPage" rel="nofollow noreferrer">getBackgroundPage()</a>, using:</p>
<pre><code>const serviceWorkerWindow = await chrome.runtime.getBackgroundPage();
</code></pre>
<p>This fails with:</p>
<pre><code>Uncaught (in promise) Error: You do not have a background page.
</code></pre>
<p>How do I make <code>getBackgroundPage()</code> work?</p>
| [
{
"answer_id": 74224827,
"author": "Htue Ko",
"author_id": 9056898,
"author_profile": "https://Stackoverflow.com/users/9056898",
"pm_score": 0,
"selected": false,
"text": "CircularProgressIndicator(\n modifier = Modifier\n .progressSemantics()\n .size(32.dp),\n)\n"
},
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224782",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/123671/"
] |
74,224,823 | <p>I have three different methods. But the return statement of the three methods is almost identicall.</p>
<p>So I have this three methods:</p>
<pre><code>def filter_verdi_total_number_fruit(self):
regex = r"(\d*(?:\.\d+)*)\s*\W+(?:" + '|'.join(re.escape(word)
for word in self.extractingText.list_fruit) + ')'
return re.findall(regex, self.extractingText.text_factuur_verdi[0])
def filter_verdi_fruit_name(self):
regex = r"(?:\d*(?:\.\d+)*)\s*\W+(" + '|'.join(re.escape(word)
for word in self.extractingText.list_fruit) + ')'
return re.findall(regex, self.extractingText.text_factuur_verdi[0])
def filter_verdi_total_fruit_cost(self):
fruits_groups = (
f"(?:{fruit})" for fruit in self.extractingText.list_fruit)
fruits_combined_with_capture = f'(?:{"|".join(fruits_groups)})'
fruits_pattern = self.regex_fruit_cost(fruits_combined_with_capture)
return re.findall(fruits_pattern, self.extractingText.text_factuur_verdi[0])
</code></pre>
<p>and I have a method that combines the three methods:</p>
<pre><code>def show_extracted_data_from_file(self, file_name):
self.extractingText.extract_text_from_image(file_name)
total_fruit = self.filter_verdi_total_number_fruit()
fruit_name = self.filter_verdi_fruit_name()
fruit_total_cost = self.filter_verdi_total_fruit_cost()
return "\n".join("{} \t {} \t {}".format(a, b, c) for a, b, c in zip(total_fruit, fruit_name, fruit_total_cost))
</code></pre>
<p>But as you can see the return statement: <code>self.extractingText.text_factuur_verdi[0]</code></p>
<p>is the same in all three methods.</p>
<p>Question: how can I improve this?</p>
| [
{
"answer_id": 74224897,
"author": "Matt Pitkin",
"author_id": 1862861,
"author_profile": "https://Stackoverflow.com/users/1862861",
"pm_score": 0,
"selected": false,
"text": " def findall(self, inputstr):\n return re.findall(inputstr, self.extractingText.text_factuur_verdi[0])... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224823",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7713770/"
] |
74,224,847 | <p>hello i need help i use vue.js and i need "fullpage.js" but it is only supported for vue3</p>
<p>how can i use fullpage in vue.js?</p>
<p>alternatively how can I use pure JS?</p>
<p>(<a href="https://alvarotrigo.com/fullPage/" rel="nofollow noreferrer">https://alvarotrigo.com/fullPage/</a>)</p>
<p>here is my script so far in code:</p>
<pre><code><script>
import Bio from "../components/Bio.vue";
import Counter from "../components/Counter.vue";
import Gallery from "../components/Gallery.vue";
import About from "../components/About.vue";
import Clients from "../components/Clients.vue";
import Clientslogo from "../components/Clientslogo.vue";
import Services from "../components/Services.vue";
export default {
name: "Home",
components: { Bio, Counter, Gallery, About, Clients, Clientslogo, Services, },
data() {
return {
welcomeScreen: {
title: "Welcome!",
blogPost:
"Weekly blog articles with all things programming including HTML, CSS, JavaScript and more. Register today to never miss a post!",
welcomeScreen: true,
photo: "coding",
},
};
},
computed: {
blogPostsFeed() {
return this.$store.getters.blogPostsFeed;
},
blogPostsCards() {
return this.$store.getters.blogPostsCards;
},
user() {
return this.$store.state.user;
},
},
};
</script>
</code></pre>
| [
{
"answer_id": 74224999,
"author": "Ahmed Mohamed",
"author_id": 18074007,
"author_profile": "https://Stackoverflow.com/users/18074007",
"pm_score": 2,
"selected": false,
"text": "npm install vue-fullpage.js --save\n# or\nyarn add vue-fullpage.js\n"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224847",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19122605/"
] |
74,224,850 | <p>I can clearly See combinations of Friday and Monday in this query:</p>
<pre><code>SELECT DISTINCT TO_CHAR(DATE_CASE_CLOSED, 'Day') AS DAY_CLOSED, TO_CHAR(DATE_REPORT_SUBMITTED, 'Day') AS DAY_SUBMITTED
from V_MY_DATA
</code></pre>
<p><a href="https://i.stack.imgur.com/BcxJR.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BcxJR.png" alt="enter image description here" /></a></p>
<p>But when I then do this, I get no records:</p>
<pre><code>select * from V_MY_DATA
WHERE TO_CHAR(DATE_CASE_CLOSED, 'Day') = 'Friday'
</code></pre>
<p>Update: Seems the result is a char (padded).....</p>
| [
{
"answer_id": 74224999,
"author": "Ahmed Mohamed",
"author_id": 18074007,
"author_profile": "https://Stackoverflow.com/users/18074007",
"pm_score": 2,
"selected": false,
"text": "npm install vue-fullpage.js --save\n# or\nyarn add vue-fullpage.js\n"
}
] | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1754307/"
] |
74,224,883 | <p>The following code is from the <a href="https://developer.android.com/training/permissions/requesting" rel="nofollow noreferrer">Android Developer Docs</a>. It explains how to request permissions.</p>
<blockquote>
<pre><code>// Register the permissions callback, which handles the user's response to the
// system permissions dialog. Save the return value, an instance of
// ActivityResultLauncher. You can use either a val, as shown in this snippet,
// or a lateinit var in your onAttach() or onCreate() method.
val requestPermissionLauncher =
registerForActivityResult(RequestPermission()
) { isGranted: Boolean ->
if (isGranted) {
// Permission is granted. Continue the action or workflow in your
// app.
} else {
// Explain to the user that the feature is unavailable because the
// features requires a permission that the user has denied. At the
// same time, respect the user's decision. Don't link to system
// settings in an effort to convince the user to change their
// decision.
}
}
</code></pre>
</blockquote>
<p>I tried to use the code in my application. When <code>isGranted</code> is true I tried render my main ui. But it does not work, because I get the following error:</p>
<blockquote>
<p>@Composable invocations can only happen from the context of a @Composable function</p>
</blockquote>
<p>I am wondering why this happens, because I call the launcher from a composable context. Is it necessary to mark every function in the call stack as <code>@Composable</code>? And if so, how to make the closure passed to <code>registerForActivityResult</code> composable?</p>
| [
{
"answer_id": 74224995,
"author": "Nikola Despotoski",
"author_id": 557179,
"author_profile": "https://Stackoverflow.com/users/557179",
"pm_score": 3,
"selected": true,
"text": "registerForActivity"
},
{
"answer_id": 74233364,
"author": "ceving",
"author_id": 402322,
... | 2022/10/27 | [
"https://Stackoverflow.com/questions/74224883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/402322/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.