qid int64 4 22.2M | question stringlengths 18 48.3k | answers list | date stringlengths 10 10 | metadata list |
|---|---|---|---|---|
74,322,940 | <p>I have a dataset of only categorical data formatted as factors. We'll call it "mydata".</p>
<p>I want to create a dataframe or tibble of nested contingency tables for all combinations of factors in mydata for review in exploratory data analysis and to easily pass to chisq.test(). I envision this looking like:</p>
<pre><code>| na | var1 | var2 | var3 |
| var1| tibble | tibble | tibble |
| var2| tibble | tibble | tibble |
| var3| tibble | tibble | tibble |
</code></pre>
<p>I've tried a few different attempts with dplyr::nest() and purr::map2(). My preference is to keep this tidy if possible.</p>
<p>The closes I've come is below.</p>
<pre><code>mydata <- tibble(var1 = factor(c("a", "b", "c", "c", "b")),
var2 = factor(c("Yes", "No", "Yes", "Yes", "No")),
var3 = factor(c(1, 1, 1, 2, 2))) %>%
pivot_longer(cols = everything(),
names_to = "variable",
values_to = "measure") %>%
nest_by(variable) %>%
mutate(test_map = map2(data, data, table))
</code></pre>
<p>I feel like this is almost there but the resulting contingency tables include all factor levels instead of just the factor levels for the corresponding target variables (e.g. var1:var1, var1:var2, etc.)</p>
<pre><code> mydata$test_map
$measure
a b c No Yes 1 2
a 1 0 0 0 0 0 0
b 0 2 0 0 0 0 0
c 0 0 2 0 0 0 0
No 0 0 0 0 0 0 0
Yes 0 0 0 0 0 0 0
1 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0
$measure
a b c No Yes 1 2
a 0 0 0 0 0 0 0
b 0 0 0 0 0 0 0
c 0 0 0 0 0 0 0
No 0 0 0 2 0 0 0
Yes 0 0 0 0 3 0 0
1 0 0 0 0 0 0 0
2 0 0 0 0 0 0 0
$measure
a b c No Yes 1 2
a 0 0 0 0 0 0 0
b 0 0 0 0 0 0 0
c 0 0 0 0 0 0 0
No 0 0 0 0 0 0 0
Yes 0 0 0 0 0 0 0
1 0 0 0 0 0 3 0
2 0 0 0 0 0 0 2
</code></pre>
| [
{
"answer_id": 74323018,
"author": "Barmar",
"author_id": 1491895,
"author_profile": "https://Stackoverflow.com/users/1491895",
"pm_score": 4,
"selected": true,
"text": "x = SetObject(1,2,3)\ny = SetObject(4,5,6)\n\nobject_set = dict([(x, x),(y, y)])\n\nprint(f\"{object_set=}\")\n\nz = SetObject(1,2,7)\nprint(f\"{z=}\")\nif z in object_set:\n print(\"Is in set\")\n z = object_set[z]\n\nprint(f\"{z=}\")\n"
},
{
"answer_id": 74365925,
"author": "jsbueno",
"author_id": 108205,
"author_profile": "https://Stackoverflow.com/users/108205",
"pm_score": 2,
"selected": false,
"text": "def getinstance(set_, member):\n set2 = set_ - set((member,))\n return (set_ - set2).pop()\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74322940",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/6716054/"
] |
74,322,962 | <p>I am working with Xamarin ListView and Picker, trying to create an android app that calculates a student's GPA in one page(view).
I have a class <code>GPADetails</code> that takes care of the Picker properties. This class contains a "List"...</p>
<p><code>public ObservableRangeCollection<string> UnitList{get;set;}</code></p>
<p>...of units binded to the <code>ItemSource</code> of the Picker. it also contains a "property field"...</p>
<p><code>private string selectedUnit=null;</code></p>
<p><code>public string SelectedUnit { get => selectedUnit;</code></p>
<p><code>set => SetProperty(ref selectedUnit, value); }</code>
...that is binded to the <code>SelectedItem</code> property of the picker.</p>
<p>The ListView is being populated by binding a "List"...</p>
<p><code>public ObservableRangeCollection<GPADetails> GPADetailsList {get;set;}</code><br />
...of multiple objects of type <code>GPADetails</code> class to the <code>ItemSource</code> of the ListView.(so that the user can pick different units for different subjects)
Here's the function that populates the listView</p>
<pre><code>public void DisplayTemplates()
{
GPADetailsList.Clear();
//Instantiates template object equivalent to the number of courses
for (int i = 0; i < int.Parse(NumberOfCourses); i++)
{
GPADetailsList.Add(
new GPADetails
{
//initializing picker properties with picker items
UnitList = UnitItems,
SelectedUnit = null,
TemplateID = i,
});
}
}
</code></pre>
<p>Heres the Xaml of the ListView and the picker...
...</p>
<pre><code><ListView x:Name="listView" ItemsSource="{Binding GPADetailsList}" SelectionMode="None" >
<ListView.ItemTemplate>
<DataTemplate>
<ViewCell>
<StackLayout >
<Editor Placeholder="Course Code" PlaceholderColor="White" HorizontalOptions="StartAndExpand">
</Editor>
<Picker x:Name="PickerUnit" Title="Pick a Unit" TitleColor="white"
HorizontalOptions="EndAndExpand"
VerticalOptions="Fill" HorizontalTextAlignment="Center" VerticalTextAlignment="Center" FontSize="15"
ItemsSource="{Binding UnitList}"
SelectedItem="{Binding SelectedUnit, Mode=TwoWay }"
>
</Picker>
</StackLayout>
</ViewCell>
</DataTemplate>
</ListView.ItemTemplate>
</ListView>
</code></pre>
<p>...</p>
<p>Now here's where I'm having problems. Each time the user selects a unit on the page, the <code>selectedItem</code> property of the picker is triggered. And the <code>SelectedUnit</code> property of the <code>GPADetails</code> class detects the property changed.
I want so store the <code>SelectedItem</code> of each Picker that is under the ListView in an array.
Using a property <code>TemplateID</code> of class <code>GPADetails</code>, I'm able to track which picker has been selected.
So I use <code>TemplateID</code> as the index of my array.
But I keep having problems because my C# is weak.</p>
<p>I tried doing this in the <code>SelectedUnit</code> property in class <code>GPADetails</code> by using a condition in the set accessor and initializing the array at the selected index with the <code>selectedUnit</code>. Heres the code..</p>
<pre><code>private string selectedUnit;
public string SelectedUnit
{
get { return selectedUnit; }
set
{
SetProperty(ref selectedUnit, value);
if (selectedUnit != null)
SelectedUnitList[TemplateID] = selectedUnit;
}
}
</code></pre>
<p>But with that, i can only assign one value to the array, if i try to assign another, the previously assigned index goes back to the
default value, null.</p>
<p>P.S. I don't know if I asked this right, but any help would be appreciated, thanks dev fam...</p>
| [
{
"answer_id": 74323018,
"author": "Barmar",
"author_id": 1491895,
"author_profile": "https://Stackoverflow.com/users/1491895",
"pm_score": 4,
"selected": true,
"text": "x = SetObject(1,2,3)\ny = SetObject(4,5,6)\n\nobject_set = dict([(x, x),(y, y)])\n\nprint(f\"{object_set=}\")\n\nz = SetObject(1,2,7)\nprint(f\"{z=}\")\nif z in object_set:\n print(\"Is in set\")\n z = object_set[z]\n\nprint(f\"{z=}\")\n"
},
{
"answer_id": 74365925,
"author": "jsbueno",
"author_id": 108205,
"author_profile": "https://Stackoverflow.com/users/108205",
"pm_score": 2,
"selected": false,
"text": "def getinstance(set_, member):\n set2 = set_ - set((member,))\n return (set_ - set2).pop()\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74322962",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19111991/"
] |
74,322,965 | <p>So I'm curious.. Why is it that I need to do <code>+1</code> and <code>-1</code> when truncating a side of the array.
I get that an array is index based and starts at 0 but is that really the reason to why I need to do it? What's the actual logic behind it? I've noticed that if I don't do it, it just never exists the loop because it gets to a point where it just keeps dividing the values to the same value over and over again.</p>
<pre><code>private static int[] values = { 1, 3, 5, 7, 10, 13, 15, 17 };
public static int FindValue(int valueToFind)
{
int l = 0;
int r = values.Length - 1;
while (l <= r)
{
var mid = (l + r) / 2;
if (values[mid] == valueToFind)
return mid;
if (values[mid] < valueToFind)
l = mid + 1;
else
r = mid - 1;
}
return -1;
}
</code></pre>
| [
{
"answer_id": 74323313,
"author": "trincot",
"author_id": 5459839,
"author_profile": "https://Stackoverflow.com/users/5459839",
"pm_score": 3,
"selected": true,
"text": "l = mid + 1;"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74322965",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5500630/"
] |
74,322,967 | <p>I have a input file xml called offerings and I have the course xml both are in combined xml and the file should have all the titles that are in the course xml . In this case the number of titles present in offerings xml is 3 i.e</p>
<ul>
<li>Launch Class Link - HDU_VILT01 - 1</li>
<li>Launch Class Link - HDU_VILT01 - 3</li>
<li>Launch Class Link - HDU_VILT01 - 5</li>
</ul>
<p>but in Course xml there 6 Instructor_Led_Webinar_Lesson_Data titles
So i need to loop in and show a validation that no matching lesson found. can anyone help in looping in Streaming mode.</p>
<p>Updated Source xml</p>
<pre><code><?xml version='1.0' encoding='utf-8'?>
<FileAndCourses>
<Maps>
<Locations>
<Location>
<InternalValue>7070</InternalValue>
<ExternalValue>Laval</ExternalValue>
</Location>
<Location>
<InternalValue>7000</InternalValue>
<ExternalValue>TORSSC</ExternalValue>
</Location>
</Locations>
<Rooms>
<Room>
<InternalValue>LOCATION-6-3881</InternalValue>
<ExternalValue>Ottawa District Training Center</ExternalValue>
</Room>
</Rooms>
</Maps>
<Instructors>
<Instructor>
<InstructorID>119417764</InstructorID>
<WorkdayUserName>AXH4006</WorkdayUserName>
</Instructor>
</Instructors>
<AllCourses
xmlns:xsd="http://www.w3.org/2001/XMLSchema"
xmlns:env="http://schemas.xmlsoap.org/soap/envelope/"
xmlns:wd="urn:com.workday/bsvc">
<wd:Learning_Course>
<wd:Learning_Blended_Course_Reference>
<wd:ID wd:type="WID">88388986cbbf10128d2b24f4f5c40000</wd:ID>
<wd:ID wd:type="Learning_Course_ID">00151744</wd:ID>
<wd:ID wd:type="Learning_Course">Designing Kitchens Part II</wd:ID>
</wd:Learning_Blended_Course_Reference>
<wd:Learning_Course_Data>
<wd:ID>00151744</wd:ID>
<wd:Effective_Date>2014-10-04</wd:Effective_Date>
<wd:Inactive>0</wd:Inactive>
<wd:Course_Title>Designing Kitchens Part II</wd:Course_Title>
<wd:Description>Designing Kitchens Part II</wd:Description>
<wd:Course_Number>00151744</wd:Course_Number>
<wd:Topic_Reference>
<wd:ID wd:type="WID">9d1f49654c8310154e239c7090fc0000</wd:ID>
<wd:ID wd:type="Learning_Topic">Product Knowledge - US</wd:ID>
</wd:Topic_Reference>
<wd:Language_Reference>
<wd:ID wd:type="WID">da594226446c11de98360015c5e6daf6</wd:ID>
<wd:ID wd:type="User_Language_ID">en_US</wd:ID>
</wd:Language_Reference>
<wd:Minimum_Enrollment_Capacity>0</wd:Minimum_Enrollment_Capacity>
<wd:Maximum_Enrollment_Capacity>0</wd:Maximum_Enrollment_Capacity>
<wd:Waitlist_Capacity>0</wd:Waitlist_Capacity>
<wd:Unlimited_Capacity>1</wd:Unlimited_Capacity>
<wd:Learning_Pricing_Data>
<wd:Pricing_Enabled>0</wd:Pricing_Enabled>
<wd:Price_in_Training_Credits>0</wd:Price_in_Training_Credits>
</wd:Learning_Pricing_Data>
<wd:Time_Value_Reference>
<wd:ID wd:type="WID">f31be4fd5caa10001d7c625e27014929</wd:ID>
<wd:ID wd:type="Learning_Time_Unit_ID">HOURS</wd:ID>
</wd:Time_Value_Reference>
<wd:Total_Course_Duration>18</wd:Total_Course_Duration>
<wd:Enable_Auto_Enrollment_from_Waitlist>0</wd:Enable_Auto_Enrollment_from_Waitlist>
<wd:Legacy_Course>1</wd:Legacy_Course>
<wd:Allowed_Instructor_Reference>
<wd:ID wd:type="WID">88388986cbbf10124df56ab318140000</wd:ID>
<wd:ID wd:type="Learning_Instructor_ID">100735117</wd:ID>
</wd:Allowed_Instructor_Reference>
<wd:Allowed_Instructor_Reference>
<wd:ID wd:type="WID">b7f5fd27bc071018bbed7a460ce30000</wd:ID>
<wd:ID wd:type="Learning_Instructor_ID">119417764</wd:ID>
</wd:Allowed_Instructor_Reference>
<wd:Allowed_Instructor_Reference>
<wd:ID wd:type="WID">88388986cbbf10124df57b8e81f30002</wd:ID>
<wd:ID wd:type="Learning_Instructor_ID">104034590</wd:ID>
</wd:Allowed_Instructor_Reference>
<wd:All_Locations>0</wd:All_Locations>
<wd:Exclude_from_Recommendations>1</wd:Exclude_from_Recommendations>
<wd:Exclude_from_Search_and_Browse>0</wd:Exclude_from_Search_and_Browse>
<wd:Disable_Express_Interest>1</wd:Disable_Express_Interest>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>1</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Launch Class Link - HDU_VILT01 - 1</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>2</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Launch Class Link - HDU_VILT01 - 2</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>3</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Launch Class Link - HDU_VILT01 - 3</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>4</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Launch Class Link - HDU_VILT01 - 4</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>5</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Launch Class Link - HDU_VILT01 - 5</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>6</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Launch Class Link - HDU_VILT01 - 6</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>7</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Media_Lesson_Data>
<wd:Media_Reference>
<wd:ID wd:type="WID">88388986cbbf10128d2b23247d3f0004</wd:ID>
<wd:ID wd:type="Media_ID">MEDIA-6-4195</wd:ID>
<wd:ID wd:type="Workdrive_Item_ID">MEDIA-6-4195</wd:ID>
</wd:Media_Reference>
<wd:Learning_Course_Lesson_Title>Welcome to HDU Distance Learning</wd:Learning_Course_Lesson_Title>
<wd:Provide_Course_Grade>0</wd:Provide_Course_Grade>
</wd:Media_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>8</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>0</wd:Make_Lesson_Mandatory>
<wd:Media_Lesson_Data>
<wd:Media_Reference>
<wd:ID wd:type="WID">358e28e73d5d10109aef5b042fc20000</wd:ID>
<wd:ID wd:type="Media_ID">cninv000000000020562.zip</wd:ID>
<wd:ID wd:type="Workdrive_Item_ID">cninv000000000020562.zip</wd:ID>
</wd:Media_Reference>
<wd:Learning_Course_Lesson_Title>Course Feedback HDUv3</wd:Learning_Course_Lesson_Title>
<wd:Provide_Course_Grade>0</wd:Provide_Course_Grade>
</wd:Media_Lesson_Data>
</wd:Course_Lesson_Data>
</wd:Learning_Course_Data>
</wd:Learning_Course>
<wd:Learning_Course>
<wd:Learning_Blended_Course_Reference>
<wd:ID wd:type="WID">88388986cbbf10128d2c78dc802e0001</wd:ID>
<wd:ID wd:type="Learning_Course_ID">00170024CA</wd:ID>
<wd:ID wd:type="Learning_Course">Design Basics (Designer Training 4) - Virtual ILT</wd:ID>
</wd:Learning_Blended_Course_Reference>
<wd:Learning_Course_Data>
<wd:ID>00170024CA</wd:ID>
<wd:Effective_Date>2019-02-26</wd:Effective_Date>
<wd:Inactive>0</wd:Inactive>
<wd:Course_Title>Design Basics (Designer Training 4) - Virtual ILT</wd:Course_Title>
<wd:Description>&lt;p>In this 5 module virtual course the designer will learn the basics of drafting and laying out basic designs for Contractors and DIY customers.&lt;/p></wd:Description>
<wd:Course_Number>00170024CA</wd:Course_Number>
<wd:Topic_Reference>
<wd:ID wd:type="WID">9d1f49654c8310154e4430e071ef0000</wd:ID>
<wd:ID wd:type="Learning_Topic">Customer Service and Selling Skills - CAN</wd:ID>
</wd:Topic_Reference>
<wd:Language_Reference>
<wd:ID wd:type="WID">da5948c0446c11de98360015c5e6daf6</wd:ID>
<wd:ID wd:type="User_Language_ID">en_CA</wd:ID>
</wd:Language_Reference>
<wd:Minimum_Enrollment_Capacity>4</wd:Minimum_Enrollment_Capacity>
<wd:Maximum_Enrollment_Capacity>10</wd:Maximum_Enrollment_Capacity>
<wd:Waitlist_Capacity>0</wd:Waitlist_Capacity>
<wd:Unlimited_Capacity>0</wd:Unlimited_Capacity>
<wd:Learning_Pricing_Data>
<wd:Pricing_Enabled>0</wd:Pricing_Enabled>
<wd:Price_in_Training_Credits>0</wd:Price_in_Training_Credits>
</wd:Learning_Pricing_Data>
<wd:Time_Value_Reference>
<wd:ID wd:type="WID">f31be4fd5caa10001d7c6231be3b4927</wd:ID>
<wd:ID wd:type="Learning_Time_Unit_ID">MINUTES</wd:ID>
</wd:Time_Value_Reference>
<wd:Total_Course_Duration>900</wd:Total_Course_Duration>
<wd:Enable_Auto_Enrollment_from_Waitlist>0</wd:Enable_Auto_Enrollment_from_Waitlist>
<wd:Legacy_Course>1</wd:Legacy_Course>
<wd:Allowed_Instructor_Reference>
<wd:ID wd:type="WID">88388986cbbf10124df5cfa198ca0000</wd:ID>
<wd:ID wd:type="Learning_Instructor_ID">718700459</wd:ID>
</wd:Allowed_Instructor_Reference>
<wd:Allowed_Instructor_Reference>
<wd:ID wd:type="WID">88388986cbbf10124df5c99611170000</wd:ID>
<wd:ID wd:type="Learning_Instructor_ID">713400041</wd:ID>
</wd:Allowed_Instructor_Reference>
<wd:Allowed_Instructor_Reference>
<wd:ID wd:type="WID">88388986cbbf10124df5c72adbc60000</wd:ID>
<wd:ID wd:type="Learning_Instructor_ID">702300581</wd:ID>
</wd:Allowed_Instructor_Reference>
<wd:All_Locations>0</wd:All_Locations>
<wd:Exclude_from_Recommendations>1</wd:Exclude_from_Recommendations>
<wd:Exclude_from_Search_and_Browse>0</wd:Exclude_from_Search_and_Browse>
<wd:Disable_Express_Interest>1</wd:Disable_Express_Interest>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>1</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Session 1</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>2</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Session 2</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>3</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Session 3</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>4</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Session 4</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>5</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Instructor_Led_Webinar_Lesson_Data>
<wd:Title>Session 5</wd:Title>
<wd:Webinar_Lesson_Unit_Track_Attendance>1</wd:Webinar_Lesson_Unit_Track_Attendance>
<wd:Webinar_Lesson_Unit_Track_Grades>0</wd:Webinar_Lesson_Unit_Track_Grades>
</wd:Instructor_Led_Webinar_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>6</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>1</wd:Make_Lesson_Mandatory>
<wd:Media_Lesson_Data>
<wd:Media_Reference>
<wd:ID wd:type="WID">88388986cbbf10128d2c770c4c2b0003</wd:ID>
<wd:ID wd:type="Media_ID">MEDIA-6-4222</wd:ID>
<wd:ID wd:type="Workdrive_Item_ID">MEDIA-6-4222</wd:ID>
</wd:Media_Reference>
<wd:Learning_Course_Lesson_Title>Log in Instructions (Adobe Connect - Designer 4_DesignBasics) (updated May 2022)</wd:Learning_Course_Lesson_Title>
<wd:Provide_Course_Grade>0</wd:Provide_Course_Grade>
</wd:Media_Lesson_Data>
</wd:Course_Lesson_Data>
<wd:Course_Lesson_Data>
<wd:Lesson_Order>7</wd:Lesson_Order>
<wd:Make_Lesson_Mandatory>0</wd:Make_Lesson_Mandatory>
<wd:Media_Lesson_Data>
<wd:Media_Reference>
<wd:ID wd:type="WID">358e28e73d5d1010910342e9c79a0000</wd:ID>
<wd:ID wd:type="Media_ID">cninv000000000019226.zip</wd:ID>
<wd:ID wd:type="Workdrive_Item_ID">cninv000000000019226.zip</wd:ID>
</wd:Media_Reference>
<wd:Learning_Course_Lesson_Title>Course Evaluation - vILT (L1)</wd:Learning_Course_Lesson_Title>
<wd:Provide_Course_Grade>0</wd:Provide_Course_Grade>
</wd:Media_Lesson_Data>
</wd:Course_Lesson_Data>
</wd:Learning_Course_Data>
</wd:Learning_Course>
</AllCourses>
<Offerings>
<Offering>
<Lesson>
<Offering-ID>C2212001 DL 3Wks Mon 4pm-7pm EASTERN</Offering-ID>
<Course-Number>00151744</Course-Number>
<Min-Seats>10</Min-Seats>
<Max-Seats>20</Max-Seats>
<Webinar>Y</Webinar>
<Title>Launch Class Link - HDU_VILT01 - 1</Title>
<Start-Date>11/28/2022</Start-Date>
<Start-Time>04:00PM</Start-Time>
<End-Date>11/28/2022</End-Date>
<End-Time>07:00PM</End-Time>
<Facilitator-LDAP>AXH4006</Facilitator-LDAP>
<Location/>
<Room/>
<Language>en_US</Language>
<Webinar-URL>https://hdu.adobeconnect.com</Webinar-URL>
</Lesson>
<Lesson>
<Offering-ID>C2212001 DL 3Wks Mon 4pm-7pm EASTERN</Offering-ID>
<Course-Number>00151744</Course-Number>
<Min-Seats>10</Min-Seats>
<Max-Seats>20</Max-Seats>
<Webinar>Y</Webinar>
<Title>Launch Class Link - HDU_VILT01 - 3</Title>
<Start-Date>12/05/2022</Start-Date>
<Start-Time>04:00PM</Start-Time>
<End-Date>12/05/2022</End-Date>
<End-Time>07:00PM</End-Time>
<Facilitator-LDAP>AXH4006</Facilitator-LDAP>
<Location/>
<Room/>
<Language>en_US</Language>
<Webinar-URL>https://hdu.adobeconnect.com</Webinar-URL>
</Lesson>
<Lesson>
<Offering-ID>C2212001 DL 3Wks Mon 4pm-7pm EASTERN</Offering-ID>
<Course-Number>00151744</Course-Number>
<Min-Seats>10</Min-Seats>
<Max-Seats>20</Max-Seats>
<Webinar>Y</Webinar>
<Title>Launch Class Link - HDU_VILT01 - 5</Title>
<Start-Date>12/12/2022</Start-Date>
<Start-Time>04:00PM</Start-Time>
<End-Date>12/12/2022</End-Date>
<End-Time>07:00PM</End-Time>
<Facilitator-LDAP>AXH4006</Facilitator-LDAP>
<Location/>
<Room/>
<Language>en_US</Language>
<Webinar-URL>https://hdu.adobeconnect.com</Webinar-URL>
</Lesson>
</Offering>
</Offerings>
</FileAndCourses>
</code></pre>
<p>Expected output</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<OfferingsWithCourse>
<Error>No offering for 00151744 title Launch Class Link - HDU_VILT01 - 2</Error>
<Error>No offering for 00151744 title Launch Class Link - HDU_VILT01 - 4</Error>
<Error>No offering for 00151744 title Launch Class Link - HDU_VILT01 - 6</Error>
</OfferingsWithCourse>
</code></pre>
<p>but getting this output</p>
<pre><code><?xml version="1.0" encoding="UTF-8"?>
<OfferingsWithCourse>
<Error>No offering for 00170024CA title Session 1</Error>
<Error>No offering for 00170024CA title Session 2</Error>
<Error>No offering for 00170024CA title Session 3</Error>
<Error>No offering for 00170024CA title Session 4</Error>
<Error>No offering for 00170024CA title Session 5</Error>
<Error>No offering for 00151744 title Launch Class Link - HDU_VILT01 - 2</Error>
<Error>No offering for 00151744 title Launch Class Link - HDU_VILT01 - 4</Error>
<Error>No offering for 00151744 title Launch Class Link - HDU_VILT01 - 6</Error>
</OfferingsWithCourse>
</code></pre>
<p>I want have validate only the input file course number 00151744 not the courses on Source data ,can you please help me?</p>
| [
{
"answer_id": 74323313,
"author": "trincot",
"author_id": 5459839,
"author_profile": "https://Stackoverflow.com/users/5459839",
"pm_score": 3,
"selected": true,
"text": "l = mid + 1;"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74322967",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19505439/"
] |
74,322,973 | <pre><code><a href="https://123.com/'.$_SESSION["usersId"].' " target="_blank"><img src="./images/w.jpg"></a>
</code></pre>
<p>Hello, I'm new to coding and I was wondering how can I make a custom link with an user ID directly taken from my database. The name usersId is a column in a mySQL table and I take that usersId from a session. Can you please help me fix the problem</p>
<p>I tried to use a $_SESSION to insert the user id in the link but it seem that it didn't work and when I open a session on my website it just removes the $_SESSION and give me a link without the user id at the end.</p>
| [
{
"answer_id": 74323023,
"author": "rehdadth",
"author_id": 19181018,
"author_profile": "https://Stackoverflow.com/users/19181018",
"pm_score": -1,
"selected": true,
"text": "$_SESSION[\"userId\"] = your_mysql_object[\"userId\"]\n"
},
{
"answer_id": 74323113,
"author": "HKTE",
"author_id": 12412262,
"author_profile": "https://Stackoverflow.com/users/12412262",
"pm_score": 1,
"selected": false,
"text": "<a href=\"https://123.com/<?= htmlentities($_SESSION['usersId']) ?>\" target=\"_blank\">\n <img src=\"./images/w.jpg\">\n</a>\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74322973",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20195280/"
] |
74,322,985 | <p>In my .Net 6 WebPI service, I am queueing work to a background task queue, very closely based on the example here, but I could post parts of my implementation if that would help:
<a href="https://learn.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-6.0&tabs=visual-studio#queued-background-tasks" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/aspnet/core/fundamentals/host/hosted-services?view=aspnetcore-6.0&tabs=visual-studio#queued-background-tasks</a></p>
<p>I am running into unexpected behavior where control is not returned to the caller, even after the <code>return Ok(..)</code> completes in the controller. Instead the request only completes after the <code>await Task.Delay(1000);</code> line is reached on the queued work item. The request returns to the client as soon as this line is reached, and does not need to wait for the <code>Delay</code> to finish.</p>
<p>I'm guessing this is because of the <code>await</code> either starting a new async context, or someone un-sticking the async context of the original request. My intention is for the request to complete immediately after queuing the work item.</p>
<p>Any insight into what is happening here would be greatly appreciated.</p>
<p>Controller:</p>
<pre><code> public async Task<ActionResult> Test()
{
var resultMessage = await _testQueue.DoIt();
return Ok(new { Message = resultMessage });
}
</code></pre>
<p>Queueing Work:</p>
<pre><code> public TestAdapter(ITaskQueue taskQueue)
{
_taskQueue = taskQueue;
}
public async Task<string> DoIt()
{
await _taskQueue.QueueBackgroundWorkItemAsync(async (_cancellationToken) =>
{
await Task.Delay(1000);
var y = 12;
});
return "cool";
}
</code></pre>
<p>IoC:</p>
<pre><code> services.AddHostedService<QueueHostedService>();
services.AddSingleton<ITTaskQueue>(ctx =>
{
return new TaskQueue(MaxQueueCount);
});
</code></pre>
<p>TaskQueue:</p>
<pre><code> private readonly Channel<BackgroundTaskContext> _queue;
public TaskQueue(int capacity)
{
var options = new BoundedChannelOptions(capacity)
{
FullMode = BoundedChannelFullMode.Wait
};
_queue = Channel.CreateBounded<BackgroundTaskContext>(options);
}
public async ValueTask QueueBackgroundWorkItemAsync(
Func<CancellationToken, ValueTask> workItem)
{
if (workItem == null)
{
throw new ArgumentNullException(nameof(workItem));
}
await _queue.Writer.WriteAsync(new BackgroundTaskContext(workItem, ...));
}
</code></pre>
| [
{
"answer_id": 74323023,
"author": "rehdadth",
"author_id": 19181018,
"author_profile": "https://Stackoverflow.com/users/19181018",
"pm_score": -1,
"selected": true,
"text": "$_SESSION[\"userId\"] = your_mysql_object[\"userId\"]\n"
},
{
"answer_id": 74323113,
"author": "HKTE",
"author_id": 12412262,
"author_profile": "https://Stackoverflow.com/users/12412262",
"pm_score": 1,
"selected": false,
"text": "<a href=\"https://123.com/<?= htmlentities($_SESSION['usersId']) ?>\" target=\"_blank\">\n <img src=\"./images/w.jpg\">\n</a>\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74322985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1806378/"
] |
74,323,002 | <p>I'm reading an HTML file, trying to get some information out of it. I've tried HTML parsers, but can't figure out how to use them to get key text out. The original reads the html file, but this version is a minimal working example for StackOverflow purposes.</p>
<pre><code>#!/usr/bin/env perl
use 5.036;
use warnings FATAL => 'all';
use autodie ':default';
use Devel::Confess 'color';
sub regex_test ( $string, $regex ) {
if ($string =~ m/$regex/s) {
say "$string matches $regex";
} else {
say "$string doesn't match $regex";
}
}
# the HTML text is $s
my $s = ' rs577952184 was merged into
<a target="_blank"
href="rs59222162">rs59222162</a>
';
regex_test ( $s, 'rs\d+ was merged into.*\<a target="_blank".+href="rs(\d+)/');
</code></pre>
<p>however, this doesn't match.</p>
<p>I think that the problem is the newline after "merged into" isn't matching.</p>
<p>How can I alter the above regex to match <code>$s</code>?</p>
| [
{
"answer_id": 74323150,
"author": "Dan Bonachea",
"author_id": 3528321,
"author_profile": "https://Stackoverflow.com/users/3528321",
"pm_score": 3,
"selected": true,
"text": "/"
},
{
"answer_id": 74323179,
"author": "Polar Bear",
"author_id": 12313309,
"author_profile": "https://Stackoverflow.com/users/12313309",
"pm_score": 1,
"selected": false,
"text": "use strict;\nuse warnings;\nuse feature 'say';\n\nmy $s = ' rs577952184 was merged into\n \n <a target=\"_blank\"\n href=\"rs59222162\">rs59222162</a>\n \n';\n\nmy $re = qr/rs\\d+ was merged into\\s+<a target=\"_blank\"\\s+href=\"rs(\\d+)\">rs\\d+<\\/a>/;\n\nregex_test($s,$re);\n\nexit 0;\n\nsub regex_test {\n my $string = shift;\n my $regex = shift;\n \n say $string =~ m/$regex/s \n ? \"$string matches $regex\"\n : \"$string doesn't match $regex\";\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323002",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3973175/"
] |
74,323,055 | <p>I'm doing a homework for class right now and it requires me to use private variables from a superclass in one of its subclasses, but I don't know how to. I found a lot of info on changing the superclass which would work, but the assignment says that I'm not allowed to edit the superclass, just its subclasses. Is this even possible?</p>
<p>For context, the assignment is on weekly earnings of different employees and printing out their info(first and last name, employee id, position, and earnings). The first name, last name, and employee id are private and I need to override a method in the superclass in the subclass.</p>
<p>Code from superclass:</p>
<pre><code>public String toString(){
return "Name: " + firstName + " " + lastName + ", ID: " + employeeId;
}
</code></pre>
<p>Code from subclass(that I'm writing)</p>
<pre><code>// Override public String toString() here
/*public String toString(){
return ("Name: " + firstName + " " + lastName + ", ID: " + employeeId + " Position: Boss");
}*/
</code></pre>
<p>I tried using get and set within the subclass, but that obviously doesn't work.</p>
| [
{
"answer_id": 74323749,
"author": "Christoph Dahlen",
"author_id": 20370596,
"author_profile": "https://Stackoverflow.com/users/20370596",
"pm_score": 0,
"selected": false,
"text": "Field field = super\n .getClass()\n .getDeclaredField(\"firstName\");\nfield.setAccessible(true);\nString firstname = (String) field.get(super);\n"
},
{
"answer_id": 74434698,
"author": "bvanvelsen - ACA Group",
"author_id": 1080166,
"author_profile": "https://Stackoverflow.com/users/1080166",
"pm_score": 1,
"selected": false,
"text": "toString()"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323055",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20421255/"
] |
74,323,065 | <p>Frontend is Vue and my backend is an express rest api that pulls data from mysql. I want to secure both the frontend (login form) and backend api, but without limiting use of the api to just my frontend. I may want to use this api for other projects in the future.</p>
<p>What I'm strugging with is understanding how to have a user log in on the frontend but also give them access to the api without preventing future access to the api from other projects. I know I could set a JWT, but recently there seems to be a lot of "DON'T USE JWT!" articles out there, and I can understand why they might think this. Using cookies and sessions doesn't seem practical either without needing to create a session/cookie for each frontend and backend. Then I thought maybe using cookie/sessions for frontend, and having the frontend be authenticated with an API key to the backend API. This might allow other web applications to access the api while protecting it from unauthorized access.</p>
<p>Apologies for the lack of knowledge and seemingly rambling. I've been stuck on this aspect of my project for a while now. I know it's due to my poverty of knowledge on the subject. Any resources and points in the right direction will be greatly appreciated.</p>
| [
{
"answer_id": 74323749,
"author": "Christoph Dahlen",
"author_id": 20370596,
"author_profile": "https://Stackoverflow.com/users/20370596",
"pm_score": 0,
"selected": false,
"text": "Field field = super\n .getClass()\n .getDeclaredField(\"firstName\");\nfield.setAccessible(true);\nString firstname = (String) field.get(super);\n"
},
{
"answer_id": 74434698,
"author": "bvanvelsen - ACA Group",
"author_id": 1080166,
"author_profile": "https://Stackoverflow.com/users/1080166",
"pm_score": 1,
"selected": false,
"text": "toString()"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323065",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/355754/"
] |
74,323,183 | <pre><code>import networkx as nx
import numpy as np
import matplotlib.pyplot as plt
import pylab
plt.rcParams['figure.figsize'] = [10, 10]
G = nx.DiGraph()
G.add_edges_from([('A', 'B'),('C','D'),('G','D')], weight=1)
G.add_edges_from([('D','A'),('D','E'),('B','D'),('D','E')], weight=2)
G.add_edges_from([('B','C'),('E','F')], weight=3)
G.add_edges_from([('C','F')], weight=4)
nodeopt = {
'node_color': 'white',
'node_size': 3500,
'node_shape': 'o',
'linewidths': 1,
'edgecolors' : 'black'
}
label_opt = {
'font_size': 13,
'font_color' : 'black',
}
edge_opt = {
'width': 3,
'edge_color' : 'black',
'arrowstyle' : '-|>',
'arrows' : True,
'arrowsize' : 12,
'connectionstyle' : 'arc3,rad=0.2'
}
##FOR PRINTING WEIGHTS ON THE EDGES
edge_labels=dict([((u,v,),d['weight'])
for u,v,d in G.edges(data=True)])
## EDIT THE EDGE COLORS
red_edges = []
edge_colors = ['black' if not edge in red_edges else 'red' for edge in G.edges()]
#red_edges = [('C','D'),('D','A')]
#edge_colors = ['black' if not edge in red_edges else 'red' for edge in G.edges()]
## FOR CREATING LABELS OF THE NODES
node_labels = {node:node for node in G.nodes()};
pos=nx.spring_layout(G)
nx.draw_networkx_nodes(G,pos,**nodeopt)
nx.draw_networkx_labels(G, pos, labels=node_labels, **label_opt)
nx.draw_networkx_edges(G, pos, **edge_opt)
nx.draw_networkx_edge_labels(G,pos,edge_labels=edge_labels)
pylab.show()
</code></pre>
<p>Hello above is the code I am working. I was able to get the weighted edges but for some reason my graphs are not shown as directed despite using "nx.DiGraph()", would anyone be able to help?</p>
<p>For the case of G.add_edges_from([('C','F')], weight=4), I want an arrow from node C to F with a weight 4</p>
| [
{
"answer_id": 74323327,
"author": "Ben Grossmann",
"author_id": 2476977,
"author_profile": "https://Stackoverflow.com/users/2476977",
"pm_score": 2,
"selected": true,
"text": "node_size"
},
{
"answer_id": 74323354,
"author": "Cindy Burker",
"author_id": 16912990,
"author_profile": "https://Stackoverflow.com/users/16912990",
"pm_score": 2,
"selected": false,
"text": " nodeopt = {\n 'node_size' : 1400,\n 'node_color': 'white',\n 'node_shape': 'o',\n 'linewidths': 1,\n 'edgecolors' : 'black'\n}\n\nlabel_opt = {\n 'font_size': 13,\n 'font_color' : 'black',\n}\n\nedge_opt = {\n 'width': 3,\n 'edge_color' : 'black',\n 'arrowstyle' : '-|>',\n 'arrows' : True,\n 'arrowsize' : 22,\n 'connectionstyle' : 'arc3,rad=0.2',\n 'node_size' : 1400\n \n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323183",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16912990/"
] |
74,323,193 | <p>I am looking for an elegant way to replace a string after a particular word in a text with Java.
Example:
"Today we have an IKAR ME123 from Greece."
I want to replace the word after "IKAR" with my custom string, lets say XXXX , then the text should look:
"Today we have an IKAR XXXX from Greece."
Is there a nice way of doing it ,without have to write some ugly regular expression or 200 lines of code ?I've looked on Stackoverflow , and even though i found "similar" questions , non adressed that particular situation !</p>
<p>Thanks in advance</p>
| [
{
"answer_id": 74323383,
"author": "Jesse Barnum",
"author_id": 260516,
"author_profile": "https://Stackoverflow.com/users/260516",
"pm_score": 0,
"selected": false,
"text": "public class ReplaceText {\n public static void main(String[] args) {\n String input = \"Today we have an IKAR ME123 from Greece\";\n String replacement = \"XXXX\";\n System.out.println( replaceBetween( input, \"IKAR \", \" from\", replacement ) );\n }\n\n private static String replaceBetween( String input, String start, String end, String replacement ) {\n return input.substring( 0, input.lastIndexOf( start ) + start.length() ) + replacement + input.substring( input.lastIndexOf( end ) );\n }\n}\n"
},
{
"answer_id": 74323612,
"author": "Christoph Dahlen",
"author_id": 20370596,
"author_profile": "https://Stackoverflow.com/users/20370596",
"pm_score": 1,
"selected": false,
"text": "\"Today we have an IKAR ME123 from Greece.\"\n .replaceFirst(\"IKAR \\\\w+\",\"IKAR XXXX\");\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2557930/"
] |
74,323,210 | <p>Sorry for the vague title, but I don't know how to word this type of problem better. Here is a simple example to explain it. I have to tables: OrderItemList and OrderHistoryLog.</p>
<pre><code>OrderItemList:
|------------------------------|
| OrderNo | ItemNo | Loc | Qty |
|------------------------------|
| 100 | A | 1 | 1 |
| 101 | A | 1 | 2 |
| 102 | A | 1 | 1 |
| 103 | A | 2 | 1 |
| 104 | A | 2 | 1 |
OrderHistoryLog:
|------------------------------|
| OrderNo | ItemNo | Loc | Qty |
|------------------------------|
| 50 | A | 1 | 5 |
| 51 | A | 1 | 2 |
| 100 | A | 1 | 1 |
| 102 | A | 1 | 3 |
| 103 | A | 2 | 1 |
</code></pre>
<p>I need to show the records in the OrderItemList along with a LocHistQty field, which is the sum(Qty) from the OrderHistoryLog table for a given Item and Location, <em>but only for the orders that are present in the OrderItemList</em>.</p>
<p>For the above example, the result should be:</p>
<pre><code>Result:
|------------------------------------------------------
| OrderNo | ItemNo | Loc | Qty | HistQty | LocHistQty |
|------------------------------|-----------------------
| 100 | A | 1 | 1 | 1 | 4 |
| 101 | A | 1 | 2 | 0 | 4 |
| 102 | A | 1 | 1 | 3 | 4 |
| 103 | A | 2 | 1 | 1 | 1 |
| 104 | A | 2 | 1 | 0 | 1 |
</code></pre>
<p>It is the last field, LocHistQty that I could use some help with. Here is what I started with (does not work):</p>
<pre><code>select OI.OrderNo, OI.ItemNo, OI.Loc, OI.Qty, IFNULL(OL.Qty, 0) as HistQty, OL2.LocHistQty
from OrderItemList OI
left join OrderItemLog OL on OL.OrderNo = OI.OrderNo and OL.ItemNo = OI.ItemNo
join
(
select ItemNo, Loc, sum(qty) as LocHistQty
from zOrderItemLog
group by ItemNo, Loc
) as OL2
on OL2.ItemNo = OI.ItemNo and OL2.Loc = OI.Loc
order by OrderNo
</code></pre>
<p>The issue is with the above SQL is that LocHistQty contains the summary of the Qty for all orders (=11 for Loc 1 and 1 for Loc 2), not only the ones in OrderItemList.</p>
<p>Lastly, the real data is voluminous and query performance is important.</p>
<p>Help would be much appreciated.</p>
| [
{
"answer_id": 74323304,
"author": "Barmar",
"author_id": 1491895,
"author_profile": "https://Stackoverflow.com/users/1491895",
"pm_score": 3,
"selected": true,
"text": "OrderItemList"
},
{
"answer_id": 74323333,
"author": "Arcade",
"author_id": 20421318,
"author_profile": "https://Stackoverflow.com/users/20421318",
"pm_score": 1,
"selected": false,
"text": "SELECT \n OrderNo,\n ItemNo,\n Loc,\n Qty,\n (SELECT \n Qty\n FROM\n OrderHistoryLog AS A\n WHERE\n A.OrderNo = B.OrderNo AND A.Loc = B.Loc) AS HistQty,\n (SELECT \n SUM(Qty)\n FROM\n OrderHistoryLog AS D\n WHERE\n D.OrderNo = B.OrderNo AND D.Loc = B.Loc) AS LocHistQty\nFROM\n OrderItemList AS B;\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323210",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1446482/"
] |
74,323,221 | <p>I use the Terraform EKS module, <a href="https://github.com/terraform-aws-modules/terraform-aws-eks" rel="nofollow noreferrer">terraform-aws-modules/eks/aws</a> (version: 18.30.1). I would like to enable Secrets encryption for EKS cluster. I added lines as follows in my code.</p>
<pre><code> create_kms_key = true
kms_key_description = "KMS Secrets encryption for EKS cluster."
kms_key_enable_default_policy = true
</code></pre>
<p>After I terraform apply, the "Secrets encryption" is still off. I read the document. No clue what is missing.</p>
| [
{
"answer_id": 74323899,
"author": "javierlga",
"author_id": 6182194,
"author_profile": "https://Stackoverflow.com/users/6182194",
"pm_score": 0,
"selected": false,
"text": "cluster_encryption_config"
},
{
"answer_id": 74436150,
"author": "user20208419",
"author_id": 20208419,
"author_profile": "https://Stackoverflow.com/users/20208419",
"pm_score": 2,
"selected": true,
"text": " create_kms_key = true\n cluster_encryption_config = [{\n resources = [\"secrets\"]\n }]\n\n kms_key_description = \"KMS Secrets encryption for EKS cluster.\"\n kms_key_enable_default_policy = true\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323221",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20208419/"
] |
74,323,236 | <p>I have the following list of lists:</p>
<pre><code>lst = [['a',102, True],['b',None, False], ['c',100, False]]
</code></pre>
<p>I'd like to remove any lists where the value in the second position is None. How can I do this (in a list comprehension)</p>
<p>I've tried a few different list comprehension but can't seem to figure it out. Thanks!</p>
| [
{
"answer_id": 74323255,
"author": "Community",
"author_id": -1,
"author_profile": "https://Stackoverflow.com/users/-1",
"pm_score": 0,
"selected": false,
"text": "lst = [item for item in lst if item[1] is not None]\n"
},
{
"answer_id": 74323262,
"author": "Michael M.",
"author_id": 13376511,
"author_profile": "https://Stackoverflow.com/users/13376511",
"pm_score": 2,
"selected": true,
"text": "lst = (('a',102, True),('b',None, False), ('c',100, False))\nlst = tuple([el for el in lst if el[1] is not None])\nprint(lst) # => (('a', 102, True), ('c', 100, False))\n"
},
{
"answer_id": 74323332,
"author": "Arifa Chan",
"author_id": 19574157,
"author_profile": "https://Stackoverflow.com/users/19574157",
"pm_score": 0,
"selected": false,
"text": "filter"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323236",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12458212/"
] |
74,323,241 | <p>I want to extract content from two different tags using PHP. I want to associate h2 tags with the div tags' content that immediately follows them -- like a parent-child relationship.</p>
<pre><code><h1>Title 1</h1>
<div class="items">some data and divs here 1</div>
<h1>Title 2</h1>
<div class="items">some data and divs here 2</div>
<div class="items">some data and divs here 3</div>
<h1>Title 3</h1>
<div class="items">some data and divs here 4</div>
<div class="items">some data and divs here 5</div>
<div class="items">some data and divs here 6</div>
</code></pre>
<p>The number of items between two H1 tag is different.</p>
<p>I know how to scrape all tags with simple_html_dom or Goutte\Client to get:</p>
<pre><code><h1>Title 1</h1>
<h1>Title 2</h1>
<h1>Title 3</h1>
</code></pre>
<p>Or</p>
<pre><code><div class="items">some data and divs here 1</div>
<div class="items">some data and divs here 2</div>
<div class="items">some data and divs here 3</div>
<div class="items">some data and divs here 4</div>
<div class="items">some data and divs here 5</div>
<div class="items">some data and divs here 6</div>
</code></pre>
<p>But I am unable to associate the title to the data. I cannot figure out how to have an array like this:</p>
<pre><code>array (
0 =>
array (
'item' => 'Title 1',
'data' => 'some data and divs here 1',
),
1 =>
array (
'item' => 'Title 2',
'data' => 'some data and divs here 2',
),
2 =>
array (
'item' => 'Title 2',
'data' => 'some data and divs here 3',
),
3 =>
array (
'item' => 'Title 3',
'data' => 'some data and divs here 4',
),
4 =>
array (
'item' => 'Title 3',
'data' => 'some data and divs here 5',
),
5 =>
array (
'item' => 'Title 3',
'data' => 'some data and divs here 6',
),
)
</code></pre>
<p>I've tried to implement something like <code>sibling</code>, but didn't find a way.</p>
| [
{
"answer_id": 74323463,
"author": "IT goldman",
"author_id": 3807365,
"author_profile": "https://Stackoverflow.com/users/3807365",
"pm_score": 0,
"selected": false,
"text": "h1"
},
{
"answer_id": 74323857,
"author": "mickmackusa",
"author_id": 2943403,
"author_profile": "https://Stackoverflow.com/users/2943403",
"pm_score": 2,
"selected": true,
"text": "$doc = new DOMDocument();\n$doc->loadHTML($html);\n$xpath = new DOMXpath($doc);\n$domNodeList = $xpath->query('/html/body/h1');\n\n$result = [];\nforeach($domNodeList as $element) {\n // Save the h1\n $item = $element->nodeValue;\n\n // Loop the siblings unit the next h1\n while ($element = $element->nextSibling) {\n if ($element->nodeName === \"h1\") {\n break;\n }\n // if Node is a DOMElement\n if ($element->nodeType === 1) {\n $result[] = ['item' => $item, 'data' => $element->nodeValue];\n }\n }\n}\nvar_export($result);\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323241",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20421318/"
] |
74,323,281 | <p>I need to have the counts of re-purchase same product by the same customer in tow scenarios: in certain days and within certain duration.</p>
<p>Here is the sample data:</p>
<pre><code>create table tbl
(
Customer varchar(5),
StartDay date,
EndDay date,
Product varchar(5),
Cost decimal(10,2)
);
insert into tbl values
('A', '1/1/2019', '1/4/2019', 'Shoe', 10.00),
('B', '2/4/2021', '2/7/2021', 'Hat', 10.00),
('A', '1/7/2019', '1/8/2019', 'Shoe', 10.00),
('B', '5/8/2018', '5/9/2018', 'Shoe', 10.00),
('A', '2/1/2019', '2/3/2019', 'Shoe', 10.00),
('C', '6/6/2020', '6/6/2020', 'Hat', 10.00),
('C', '11/9/2021', '12/9/2021', 'Cloth', 10.00),
('A', '3/3/2019', '3/17/2019', 'Cloth', 10.00),
('C', '7/8/2020', '7/12/2020', 'Hat', 10.00),
('E', '7/2/2020', '9/1/2020', 'Hat', 10.00),
('A', '3/3/2019', '3/7/2019', 'Shoe', 10.00),
('A', '7/5/2022', '7/9/2022', 'Hat', 10.00),
('C', '6/6/2020', '6/8/2020', 'Shoe', 10.00),
('B', '8/2/2018', '8/9/2018', 'Shoe', 10.00),
('A', '1/1/2019', '1/11/2019', 'Cloth', 10.00),
('E', '9/3/2020', '10/1/2020', 'Hat', 10.00),
('E', '7/2/2020', '7/8/2020', 'Shoe', 10.00);
</code></pre>
<p>Duration is the difference between the last EndDay and the next StartDay for same customer purchasing same product.</p>
<p>For example:</p>
<p>For customer A, the EndDay at the first time he purchased "Shoe" was '1/4/2019. And the StartDay at the second time he purchased the 'shoe' was '1/7/2019'. So the duration was within 30 days.</p>
<p>For customer B, the EndDay at the first time he purchased "Shoe" was '5/8/2018. And the StartDay at the second time he purchased the 'shoe' was '8/2/201'. So the duration was within 60 - 90 days.</p>
<p>Expected outcome for first scenario:
<a href="https://i.stack.imgur.com/oTJf5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oTJf5.png" alt="enter image description here" /></a></p>
<p>Expected outcome for second scenario:
<a href="https://i.stack.imgur.com/vLKDn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vLKDn.png" alt="s" /></a></p>
<p>Thank you very much for your help in advance!!</p>
| [
{
"answer_id": 74323463,
"author": "IT goldman",
"author_id": 3807365,
"author_profile": "https://Stackoverflow.com/users/3807365",
"pm_score": 0,
"selected": false,
"text": "h1"
},
{
"answer_id": 74323857,
"author": "mickmackusa",
"author_id": 2943403,
"author_profile": "https://Stackoverflow.com/users/2943403",
"pm_score": 2,
"selected": true,
"text": "$doc = new DOMDocument();\n$doc->loadHTML($html);\n$xpath = new DOMXpath($doc);\n$domNodeList = $xpath->query('/html/body/h1');\n\n$result = [];\nforeach($domNodeList as $element) {\n // Save the h1\n $item = $element->nodeValue;\n\n // Loop the siblings unit the next h1\n while ($element = $element->nextSibling) {\n if ($element->nodeName === \"h1\") {\n break;\n }\n // if Node is a DOMElement\n if ($element->nodeType === 1) {\n $result[] = ['item' => $item, 'data' => $element->nodeValue];\n }\n }\n}\nvar_export($result);\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323281",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19558526/"
] |
74,323,319 | <p>I made some scraping files and to run them at the same time I usually open multiple terminals in VS code and write " python filename.py " for each file, there's any method to automate this process to call each file and run it?</p>
| [
{
"answer_id": 74323463,
"author": "IT goldman",
"author_id": 3807365,
"author_profile": "https://Stackoverflow.com/users/3807365",
"pm_score": 0,
"selected": false,
"text": "h1"
},
{
"answer_id": 74323857,
"author": "mickmackusa",
"author_id": 2943403,
"author_profile": "https://Stackoverflow.com/users/2943403",
"pm_score": 2,
"selected": true,
"text": "$doc = new DOMDocument();\n$doc->loadHTML($html);\n$xpath = new DOMXpath($doc);\n$domNodeList = $xpath->query('/html/body/h1');\n\n$result = [];\nforeach($domNodeList as $element) {\n // Save the h1\n $item = $element->nodeValue;\n\n // Loop the siblings unit the next h1\n while ($element = $element->nextSibling) {\n if ($element->nodeName === \"h1\") {\n break;\n }\n // if Node is a DOMElement\n if ($element->nodeType === 1) {\n $result[] = ['item' => $item, 'data' => $element->nodeValue];\n }\n }\n}\nvar_export($result);\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323319",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17583849/"
] |
74,323,336 | <p>I have a templated class, for which I want to specialize one of the methods for integral types. I see a lot of examples to do this for templated functions using <code>enable_if</code> trait, but I just can't seem to get the right syntax for doing this on a class method.</p>
<p>What am I doing wrong?</p>
<pre><code>#include <iostream>
using namespace std;
template<typename T>
class Base {
public:
virtual ~Base() {};
void f() {
cout << "base\n";
};
};
template<typename Q>
void Base<std::enable_if<std::is_integral<Q>::value>::type>::f() {
cout << "integral\n";
}
template<typename Q>
void Base<!std::enable_if<!std::is_integral<Q>::value>::type>::f() {
cout << "non-integral\n";
}
int main()
{
Base<int> i;
i.f();
Base<std::string> s;
s.f();
return 0;
}
</code></pre>
<p>the above code does not compile:</p>
<pre><code>main.cpp:16:60: error: type/value mismatch at argument 1 in template parameter list for ‘template class Base’
16 | void Base<std::enable_if<!std::is_integral<Q>::value>::type>::f() {
| ^
main.cpp:16:60: note: expected a type, got ‘std::enable_if<(! std::is_integral<_Tp>::value)>::type’
main.cpp:21:61: error: type/value mismatch at argument 1 in template parameter list for ‘template class Base’
21 | void Base<!std::enable_if<!std::is_integral<Q>::value>::type>::f() {
| ^
main.cpp:21:61: note: expected a type, got ‘! std::enable_if<(! std::is_integral<_Tp>::value)>::type’
main.cpp:21:6: error: redefinition of ‘template void f()’
21 | void Base<!std::enable_if<!std::is_integral<Q>::value>::type>::f() {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
main.cpp:16:6: note: ‘template void f()’ previously declared here
16 | void Base<std::enable_if<!std::is_integral<Q>::value>::type>::f() {
| ^~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
</code></pre>
| [
{
"answer_id": 74323362,
"author": "lorro",
"author_id": 6292621,
"author_profile": "https://Stackoverflow.com/users/6292621",
"pm_score": 1,
"selected": false,
"text": "class"
},
{
"answer_id": 74323440,
"author": "fabian",
"author_id": 2991525,
"author_profile": "https://Stackoverflow.com/users/2991525",
"pm_score": 2,
"selected": false,
"text": "f"
},
{
"answer_id": 74323481,
"author": "463035818_is_not_a_number",
"author_id": 4117728,
"author_profile": "https://Stackoverflow.com/users/4117728",
"pm_score": 3,
"selected": true,
"text": "!"
},
{
"answer_id": 74323500,
"author": "Jarod42",
"author_id": 2684539,
"author_profile": "https://Stackoverflow.com/users/2684539",
"pm_score": 3,
"selected": false,
"text": "if constexpr"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323336",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/501717/"
] |
74,323,366 | <p>I am working on a JavaScript function to create a pop up based on some data.
The data in result is not important, and can be omitted for this purpose, but I am including it becasue of some additional questions</p>
<p>The idea is that I want to send a portion of the result array to each pop up when the corresponding button is clicked</p>
<p>I first tried it with <code>v_popup["dataarray"] = result.slice(counter, indices[i] + counter);</code> but in the pop up the array is always empty</p>
<p>Next I tried to create a <code>var sub_array = result.slice(counter, indices[i] + counter);</code> but this was always empty</p>
<p>Last attempt I just sent the entire array to pop-up and added low and high limit as variables. But again, the limits are always 93 and 94 in every instance of the pop up.</p>
<p>If I breakpoint on <code>var high = indices[i] + counter;</code> I can see the <code>low</code> and <code>high</code> variables are storing correct incremental limits each time, but for some reason if I breakpoint inside the onlick function, on <code>v_popup["high"] = high;</code> the <code>low</code> and <code>high</code> are always 93 and 94</p>
<p>Is it because there is only one function that gets created for all of the buttons,</p>
<p>Does this function not get created until I click on the button? Does it not get created while the for loop is running?</p>
<p>Also, do I need a different variable for each instance of the button, such as <code>v_popup["dataarray1"]</code>, <code>v_popup["dataarray2"]</code>,...etc</p>
<p>Next, how can I just copy a sliced array into the variable, so I don't need to set the limits</p>
<p>Final question, this works when I close the pop up between clicking on each button, but if the pop-up is left open, the <code>window["dataarray"]</code> variable becomes undefined, even though <code>v_popup["dataarray"] = result</code> is executed on every button click. Why is this, and how can I fix it?</p>
<pre><code>function addTable(result, indices) {
counter = 0;
indices = [2,3,6,2,4,4,1,5,3,1,1,1,2,4,12,1,4,4,2,1,4,1,12,13,1,]; //for testing
for (var i = 0; i < indices.length; i++) {
let btn = document.createElement("button");
btn.innerHTML = result[counter][0];
btn.className = "button-28";
var low = counter;
var high = indices[i] + counter;
btn.onclick = function () {
var v_popup = window.open("popup.html", 'popUpWindow', 'height=300,width=700,left=50,top=50,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no, status=no')
v_popup["dataarray"] = result;
v_popup["low"] = low;
v_popup["high"] = high;
var sub_array = result.slice(counter, indices[i] + counter); //for test
}
counter += indices[i];
}
}
</code></pre>
| [
{
"answer_id": 74323535,
"author": "IT goldman",
"author_id": 3807365,
"author_profile": "https://Stackoverflow.com/users/3807365",
"pm_score": 1,
"selected": false,
"text": "result, low, high, counter, i"
},
{
"answer_id": 74323582,
"author": "Mich",
"author_id": 2056201,
"author_profile": "https://Stackoverflow.com/users/2056201",
"pm_score": 0,
"selected": false,
"text": "function addTable(result, indices) {\n counter = 0;\n low = [];\n high = [];\n for (var i = 0; i < indices.length; i++) {\n let btn = document.createElement(\"button\");\n btn.innerHTML = result[counter][0];\n btn.className = \"button-28\";\n low[result[counter][0]] = counter;\n high[result[counter][0]] = indices[i] + counter;\n\n btn.onclick = function () {\n\n var v_popup = window.open(\"popup.html\", 'popUpWindow', 'height=300,width=700,left=50,top=50,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no, status=no')\n var indx = i;\n v_popup[\"dataarray\"] = result.slice(low[this.innerHTML], high[this.innerHTML]);\n\n }\n counter += indices[i];\n }\n}\n"
},
{
"answer_id": 74323674,
"author": "Staz",
"author_id": 16240376,
"author_profile": "https://Stackoverflow.com/users/16240376",
"pm_score": 0,
"selected": false,
"text": "function addTable(result, indices) {\ncounter = 0;\nlow = [];\nhigh = [];\nfor (var i = 0; i < indices.length; i++) {\n\n let btn = document.createElement(\"button\");\n btn.innerHTML = result[counter][0];\n btn.className = \"button-28\";\n var low = counter;\n var high = indices[i] + counter;\n var sub_array = result.slice(low, high);\n\n (function (sub_array) {\n btn.onclick = function () {\n\n var v_popup = window.open(\"popup.html\", 'popUpWindow', 'height=300,width=700,left=50,top=50,resizable=no,scrollbars=no,toolbar=no,menubar=no,location=no,directories=no, status=no')\n v_popup[\"dataarray\"] = sub_array;\n }\n })(sub_array);\n\n counter += indices[i];\n td.appendChild(btn);\n tr.appendChild(td);\n}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323366",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2056201/"
] |
74,323,387 | <p>I have a select dropdown menu containing a list of states. I have restricted the visible options after clicking the dropdown via <a href="https://stackoverflow.com/questions/8788245/how-can-i-limit-the-visible-options-in-an-html-select-dropdown">this</a> stackoverflow solution as can be seen in my code below:</p>
<pre><code> <div>
<label asp-for="Venture.Location" class="form-label">Venture Location</label>
<select asp-for="Venture.Location" class="form-input form-select" required onmousedown="this.size=9" onblur="this.size=0" onchange="this.size=0">
<option disabled selected value="">select an option</option>
@foreach(var location in Model.Locations)
{
<option value="location">@location</option>
}
</select>
</div>
</code></pre>
<p>However, clicking the dropdown, I will see a cuttoff option thus showing more than 9 options. How can I make sure to only show the correct amount of options via the size? How can I get rid of the cutoff option?
<a href="https://i.stack.imgur.com/nEZ2M.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nEZ2M.png" alt="enter image description here" /></a></p>
| [
{
"answer_id": 74323486,
"author": "str1ng",
"author_id": 12826055,
"author_profile": "https://Stackoverflow.com/users/12826055",
"pm_score": 1,
"selected": false,
"text": "size"
},
{
"answer_id": 74323521,
"author": "Alx1830",
"author_id": 20421505,
"author_profile": "https://Stackoverflow.com/users/20421505",
"pm_score": -1,
"selected": false,
"text": ".form-input {\nmargin: 10px 0px;\npadding: 15px;\noverflow: auto; /* This option can helpyou!*/\n}\n"
},
{
"answer_id": 74326547,
"author": "Duke3e33",
"author_id": 13783624,
"author_profile": "https://Stackoverflow.com/users/13783624",
"pm_score": 1,
"selected": true,
"text": "mousedown"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323387",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13783624/"
] |
74,323,404 | <p>For example, I have this dataFrame,</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>plates</th>
<th>food</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>eggs</td>
</tr>
<tr>
<td>1</td>
<td>bacon</td>
</tr>
<tr>
<td>2</td>
<td>waffles</td>
</tr>
<tr>
<td>2</td>
<td>toast</td>
</tr>
<tr>
<td>3</td>
<td></td>
</tr>
<tr>
<td>3</td>
<td></td>
</tr>
<tr>
<td>4</td>
<td>cereal</td>
</tr>
<tr>
<td>4</td>
<td>milk</td>
</tr>
</tbody>
</table>
</div>
<p>The result I want is...</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>food</th>
</tr>
</thead>
<tbody>
<tr>
<td>eggs bacon</td>
</tr>
<tr>
<td>waffles toast</td>
</tr>
<tr>
<td>None</td>
</tr>
<tr>
<td>cereal milk</td>
</tr>
</tbody>
</table>
</div>
<p>This is what I have</p>
<pre><code>result = df['food'].groupby(df['plates'].agg('sum')
</code></pre>
<p>but obviously the rows that aren't grouped are ignored. I want to find those values that do not have a group and fill those rows with Nan.</p>
| [
{
"answer_id": 74323439,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 1,
"selected": false,
"text": "food"
},
{
"answer_id": 74323492,
"author": "rhug123",
"author_id": 13802115,
"author_profile": "https://Stackoverflow.com/users/13802115",
"pm_score": 0,
"selected": false,
"text": ".agg(list)"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323404",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20421406/"
] |
74,323,408 | <p>I need a JavaScript regular expression for the following date/time format:</p>
<p>10 Jul 2010 15:00</p>
<p>(2 digits space 3 characters space 4 digits space 2 digits colon 2 digits)</p>
<p>Character case does not matter, and the only allowed input is a-z, 0-9, space, colon</p>
<p>Thanks in advance.</p>
<p>For now I don't really understand regular expression in JavaScript but I need this solution</p>
| [
{
"answer_id": 74323439,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 1,
"selected": false,
"text": "food"
},
{
"answer_id": 74323492,
"author": "rhug123",
"author_id": 13802115,
"author_profile": "https://Stackoverflow.com/users/13802115",
"pm_score": 0,
"selected": false,
"text": ".agg(list)"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323408",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20421498/"
] |
74,323,413 | <p>I'm trying to export all the 722 rules into an ndjson file, but the file is incomplete. There are two sets of rule: Elastic rules and Custom rules.</p>
<p>I go to Security > Overview > Rules > Select all 722 rules > Bulk Actions > Export selected.</p>
<p><a href="https://i.stack.imgur.com/jo6wC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/jo6wC.png" alt="enter image description here" /></a></p>
<p>However, the resulting output contains the following, which is NOT what I need.</p>
<p><a href="https://i.stack.imgur.com/L8yrV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/L8yrV.png" alt="enter image description here" /></a></p>
<p>Now, when I select the 20 Custom rules, I do get the expect output.
<a href="https://i.stack.imgur.com/pSMG2.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pSMG2.png" alt="enter image description here" /></a></p>
<p>Any idea on how to fix this? Or am I doing something wrong?</p>
<p>Thanks for your help!</p>
| [
{
"answer_id": 74377736,
"author": "PythonNoob",
"author_id": 17745322,
"author_profile": "https://Stackoverflow.com/users/17745322",
"pm_score": 3,
"selected": true,
"text": "https://<IP address\":<port>/api/detection_engine/rules/_find?page=1&per_page=<number of results to include>\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323413",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17745322/"
] |
74,323,423 | <p>I have a dataFrame and each column is a list with 3 elements. How I can compare the second element os each list based on each column and row based?</p>
<pre><code>Col1 col2 col3
['A',0.2,5] ['A',0.4,5] ['A',0,5]
['A',0.4,5] ['A',0.2,5] ['A',0.7,5]
['A',0.1,5] ['A',0.1,5] ['A',0.20,5]
['A',0.25,5] ['A',0.9,5] ['A',0.22,5]
</code></pre>
<p>max of the second element in column based:</p>
<pre><code>col1=0.4
col2=0.9
col3=0.22
</code></pre>
<p>max of the second element in row based:</p>
<pre><code> row1=0.2
row2=0.7
row3=0.20
row4=0.9
</code></pre>
| [
{
"answer_id": 74323507,
"author": "Nuri Taş",
"author_id": 19255749,
"author_profile": "https://Stackoverflow.com/users/19255749",
"pm_score": 2,
"selected": false,
"text": "applymap"
},
{
"answer_id": 74323547,
"author": "PaulS",
"author_id": 11564487,
"author_profile": "https://Stackoverflow.com/users/11564487",
"pm_score": 2,
"selected": true,
"text": "def mymax(x):\n return max([y[1] for y in x])\n\ndf.apply(mymax)\ndf.apply(mymax, axis=1)\n"
},
{
"answer_id": 74323660,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 1,
"selected": false,
"text": "stack"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323423",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16831723/"
] |
74,323,454 | <p>i created the following custom rule for PMD but when i run it, i get an error. if i replace the regex with a trivial regex like "a", it works. cannot understand what's wrong.</p>
<pre class="lang-xml prettyprint-override"><code><?xml version="1.0"?>
<ruleset name="Custom Rules"
xmlns="http://pmd.sourceforge.net/ruleset/2.0.0"
xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://pmd.sourceforge.net/ruleset/2.0.0 https://pmd.sourceforge.io/ruleset_2_0_0.xsd">
<rule name="LongMethodName"
language="java"
message="Method name too long"
class="net.sourceforge.pmd.lang.rule.XPathRule">
<description>
Method name should be composed by less that five words
</description>
<priority>4</priority>
<properties>
<property name="version" value="2.0" />
<property name="xpath">
<value>
<![CDATA[
//MethodDeclaration[count(tokenize(@Name, '(?<=[a-z])(?=[A-Z])')) + 1 > 5]
]]>
</value>
</property>
</properties>
</rule>
</ruleset>
</code></pre>
<p>the error i get is the following. get an error for each file in the project i'm analyzing</p>
<pre class="lang-bash prettyprint-override"><code>
Nov 04, 2022 10:45:42 PM net.sourceforge.pmd.RuleSet apply
WARNING: Exception applying rule LongMethodName on file /Users/francescobresciani/MSDE/1sem/software-design-modeling/sdem-ass2/fastjson-master/src/main/java/com/alibaba/fastjson/parser/SymbolTable.java, continuing with next rule
java.lang.RuntimeException: net.sf.saxon.trans.XPathException: Error at character 1 in regular expression "(?<=[a-z])(?=[A-Z])": expected ())
at net.sourceforge.pmd.lang.rule.xpath.SaxonXPathRuleQuery.initializeXPathExpression(SaxonXPathRuleQuery.java:272)
at net.sourceforge.pmd.lang.rule.xpath.SaxonXPathRuleQuery.evaluate(SaxonXPathRuleQuery.java:113)
at net.sourceforge.pmd.lang.rule.XPathRule.evaluate(XPathRule.java:176)
at net.sourceforge.pmd.lang.rule.XPathRule.apply(XPathRule.java:158)
at net.sourceforge.pmd.RuleSet.apply(RuleSet.java:670)
at net.sourceforge.pmd.RuleSets.apply(RuleSets.java:163)
at net.sourceforge.pmd.SourceCodeProcessor.processSource(SourceCodeProcessor.java:209)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCodeWithoutCache(SourceCodeProcessor.java:118)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:100)
at net.sourceforge.pmd.SourceCodeProcessor.processSourceCode(SourceCodeProcessor.java:62)
at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:89)
at net.sourceforge.pmd.processor.PmdRunnable.call(PmdRunnable.java:30)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.Executors$RunnableAdapter.call(Executors.java:539)
at java.base/java.util.concurrent.FutureTask.run(FutureTask.java:264)
at java.base/java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1136)
at java.base/java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:635)
at java.base/java.lang.Thread.run(Thread.java:833)
Caused by: net.sf.saxon.trans.XPathException: Error at character 1 in regular expression "(?<=[a-z])(?=[A-Z])": expected ())
at net.sf.saxon.java.JRegularExpression.<init>(JRegularExpression.java:70)
at net.sf.saxon.java.JavaPlatform.compileRegularExpression(JavaPlatform.java:198)
at net.sf.saxon.functions.Matches.tryToCompile(Matches.java:218)
at net.sf.saxon.functions.Tokenize.maybePrecompile(Tokenize.java:45)
at net.sf.saxon.functions.Tokenize.simplify(Tokenize.java:36)
at net.sf.saxon.expr.ExpressionVisitor.simplify(ExpressionVisitor.java:159)
at net.sf.saxon.expr.FunctionCall.simplifyArguments(FunctionCall.java:100)
at net.sf.saxon.expr.FunctionCall.simplify(FunctionCall.java:88)
at net.sf.saxon.expr.ExpressionVisitor.simplify(ExpressionVisitor.java:159)
at net.sf.saxon.expr.BinaryExpression.simplify(BinaryExpression.java:45)
at net.sf.saxon.expr.ArithmeticExpression.simplify(ArithmeticExpression.java:42)
at net.sf.saxon.expr.ExpressionVisitor.simplify(ExpressionVisitor.java:159)
at net.sf.saxon.expr.BinaryExpression.simplify(BinaryExpression.java:45)
at net.sf.saxon.expr.ExpressionVisitor.simplify(ExpressionVisitor.java:159)
at net.sf.saxon.expr.FilterExpression.simplify(FilterExpression.java:130)
at net.sf.saxon.expr.ExpressionVisitor.simplify(ExpressionVisitor.java:159)
at net.sf.saxon.expr.SlashExpression.simplify(SlashExpression.java:122)
at net.sf.saxon.expr.ExpressionVisitor.simplify(ExpressionVisitor.java:159)
at net.sf.saxon.expr.ExpressionTool.make(ExpressionTool.java:74)
at net.sf.saxon.sxpath.XPathEvaluator.createExpression(XPathEvaluator.java:167)
at net.sourceforge.pmd.lang.rule.xpath.SaxonXPathRuleQuery.initializeXPathExpression(SaxonXPathRuleQuery.java:269)
</code></pre>
<p>i tested the regex on <a href="https://regex101.com/" rel="nofollow noreferrer">regex101</a> and it works.
i tested the XPath expression on <a href="http://xpather.com/" rel="nofollow noreferrer">xpather</a> and it looks valid
i tested the XPath expression on <a href="https://www.freeformatter.com/xpath-tester.html" rel="nofollow noreferrer">freeformatter</a> and it looks <strong>NOT</strong> valid. it says: <code>Unable to perform XPath operation. Syntax error at char 1 in regular expression: No expression before quantifier </code></p>
<p>the following is the snippet i checked the XPath rule against</p>
<pre class="lang-xml prettyprint-override"><code><root>
<MethodDeclaration Name="shortName"/>
<MethodDeclaration Name="thisMethodNameIsVeryVeryLong"/>
</root>
</code></pre>
<p>the following is the exact string i input in xpather and freeformatter
<code>//MethodDeclaration[count(tokenize(@Name, '(?<=[a-z])(?=[A-Z])')) + 1 > 5]</code></p>
| [
{
"answer_id": 74323507,
"author": "Nuri Taş",
"author_id": 19255749,
"author_profile": "https://Stackoverflow.com/users/19255749",
"pm_score": 2,
"selected": false,
"text": "applymap"
},
{
"answer_id": 74323547,
"author": "PaulS",
"author_id": 11564487,
"author_profile": "https://Stackoverflow.com/users/11564487",
"pm_score": 2,
"selected": true,
"text": "def mymax(x):\n return max([y[1] for y in x])\n\ndf.apply(mymax)\ndf.apply(mymax, axis=1)\n"
},
{
"answer_id": 74323660,
"author": "mozway",
"author_id": 16343464,
"author_profile": "https://Stackoverflow.com/users/16343464",
"pm_score": 1,
"selected": false,
"text": "stack"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323454",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11324367/"
] |
74,323,465 | <p>I have text file that looks like this:</p>
<pre class="lang-none prettyprint-override"><code>[{"id":1,"title":"book1","author":"person1","pages":"10"}, {"id":2,"title":"book2","author":"person2","age":"20"},{"id":3,"title":"book3","author":"person3","age":"30"}, {"id":4,"title":"book4","author":"person4","age":"40"}]
</code></pre>
<p>I wish to parse this in Ruby to obtain an array of hashes <code>arr</code> from which I could obtain, for example, values of the author field:</p>
<pre><code>person1
person2
person3
person4
</code></pre>
<p>How can I do that?</p>
| [
{
"answer_id": 74323498,
"author": "Chris",
"author_id": 15261315,
"author_profile": "https://Stackoverflow.com/users/15261315",
"pm_score": 0,
"selected": false,
"text": "eval"
},
{
"answer_id": 74323793,
"author": "Cary Swoveland",
"author_id": 256970,
"author_profile": "https://Stackoverflow.com/users/256970",
"pm_score": 2,
"selected": false,
"text": "require 'json'\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323465",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20421491/"
] |
74,323,479 | <p>I stuck at this simple scenario & not able to find smart solution to <code>Reverse a string</code> that has negative number.</p>
<pre><code>Example 1: str = "stack-1flow" #Expected output- wolf-1kcats
</code></pre>
<p>#Note may input contain multiple negative like</p>
<pre><code>Example 2: str = "-1-2stack-1flow" #Expected output - wolf-1kcats-2-1
</code></pre>
<p>I want to reverse this such that i must preserve negative number format. In my case it is pretty sure that no Hyphen's will appear in input string except from <code>Negative numbers</code>.</p>
<p><strong>Expected output</strong></p>
<pre><code>wolf-1kcats
</code></pre>
<ol>
<li><p>I've tried normal sort it wont yeild required resulsts<code>(wolf1-kcats</code> -
wrong)</p>
<pre><code>'stack-1flow'[::-1] #outputs wolf1-kcats -wrong
</code></pre>
</li>
<li><p>Tried appending to list & then reversed the list yeild
same(<code>wolf1-kcats</code> - wrong)</p>
<pre><code>list('stack-1flow') # ['s', 't', 'a', 'c', 'k', '-', '1', 'f', 'l', 'o', 'w'] #Reversing fails as you can see `-1` not preserved
</code></pre>
</li>
<li><p>Tried <code>eval</code> same results.</p>
</li>
</ol>
<blockquote>
<p>Note: I prefer Regex will be my last option..Before that I want to
take help of 1.9M community people suggests me is there is any way to
solve without <code>Regex</code>.</p>
</blockquote>
| [
{
"answer_id": 74323528,
"author": "Rahul K P",
"author_id": 4407666,
"author_profile": "https://Stackoverflow.com/users/4407666",
"pm_score": 2,
"selected": false,
"text": "re"
},
{
"answer_id": 74323748,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 1,
"selected": false,
"text": "re"
},
{
"answer_id": 74323882,
"author": "Hai Vu",
"author_id": 459745,
"author_profile": "https://Stackoverflow.com/users/459745",
"pm_score": 1,
"selected": false,
"text": "re.sub"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323479",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15358800/"
] |
74,323,483 | <p>I'm trying to make a GUI for my final year project, so to make it more ergonomic I've suggested a simple design as shown in the picture, so as I'm still a beginner in HTML/CSS I tried multiple ways to find how to turn an image to a button, and that button will start another function which starts capturing video with a webcam, so for me, the most important is how to make the buttons as shown in the picture.
<a href="https://i.stack.imgur.com/V0bQl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/V0bQl.png" alt="" /></a></p>
<p>here is my HTML code:</p>
<pre><code>
<section class="lg">
<nav>
<a href="index.html"><img src="images/logo.png"></a>
</nav>
</section>
</code></pre>
<p>and here is the CSS linked with:</p>
<pre><code>*{
margin: 0;
padding: 0;
}
.lg{
min-height: 100vh;
width: 100%;
background-image: url(images/Background2.png);
background-position: center;
background-size: cover;
position:relative;
}
nav{
display: flex;
padding: 2% 6%;
justify-content: center;
}
</code></pre>
| [
{
"answer_id": 74323528,
"author": "Rahul K P",
"author_id": 4407666,
"author_profile": "https://Stackoverflow.com/users/4407666",
"pm_score": 2,
"selected": false,
"text": "re"
},
{
"answer_id": 74323748,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 1,
"selected": false,
"text": "re"
},
{
"answer_id": 74323882,
"author": "Hai Vu",
"author_id": 459745,
"author_profile": "https://Stackoverflow.com/users/459745",
"pm_score": 1,
"selected": false,
"text": "re.sub"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323483",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15137089/"
] |
74,323,496 | <p>I have tables like the one below.</p>
<pre><code>df <- data.frame(Metric = c("Stat1", "Stat1", "Stat1", "Stat1",
"Stat2", "Stat2", "Stat2",
"Stat3", "Stat3", "Stat3", "Stat3"),
Timestamp = c("0.000514", "0.060709", "0.091062", "0.134333",
"0.000382", "0.060018", "0.133970",
"0.007462", "0.078792", "0.115623", "0.148771"),
Value = c("10", "20", "25", "30",
"11", "21", "31",
"12", "22", "32", "37"))
</code></pre>
<p>There are multiple metrics and timestamps. Naturally for each timestamp there is a value for that metric. The problem is that between metrics the timestamps are completely different. It would be easier for me to work with the data if I have the same timestamps. I found that the average timestamp is 0.05533.</p>
<p>This is the result I'm trying to get.</p>
<pre><code>df_new <- data.frame(Metric = c("Stat1", "Stat1", "Stat1",
"Stat2", "Stat2", "Stat2",
"Stat3", "Stat3", "Stat3"),
Timestamp = c("0.00", "0.05", "0.10",
"0.00", "0.05", "0.10",
"0.00", "0.05", "0.10"),
Value = c("10", "22.5", "30",
"11", "21", "31",
"12", "22", "34.5"))
</code></pre>
<p>I want to have the same timestamps for every metric. Starting with time 0, I want to average all values of a metric that are in the [0s,0.5s] range (then [0.5, 1.0s] and so on).</p>
<p>One issue is that there might be only one value for a metric in that range or multiple. It's not set.</p>
<p>How can I create the second table from the first?</p>
| [
{
"answer_id": 74323687,
"author": "Ric Villalba",
"author_id": 6912817,
"author_profile": "https://Stackoverflow.com/users/6912817",
"pm_score": 1,
"selected": false,
"text": "aggregate"
},
{
"answer_id": 74323727,
"author": "onyambu",
"author_id": 8380272,
"author_profile": "https://Stackoverflow.com/users/8380272",
"pm_score": 3,
"selected": true,
"text": "library(tidyverse)\n\nv <- c(0,0.05, 0.1)\n\ndf %>%\n type_convert()%>%\n group_by(Metric, Timestamp = v[findInterval(Timestamp,v)])%>%\n summarise(Value = mean(Value))\n\n# A tibble: 9 × 3\n# Groups: Metric [3]\n Metric Timestamp Value\n <chr> <dbl> <dbl>\n1 Stat1 0 10 \n2 Stat1 0.05 22.5\n3 Stat1 0.1 30 \n4 Stat2 0 11 \n5 Stat2 0.05 21 \n6 Stat2 0.1 31 \n7 Stat3 0 12 \n8 Stat3 0.05 22 \n9 Stat3 0.1 34.5\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323496",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4714146/"
] |
74,323,504 | <p>I am trying to create a trigger on a table (TABLE_1) which detects if a column (ENTERED_DATE) has been changed then update another table (TABLE_2) to set the column (ENTRY_DATE) to the newly changed date on TABLE_1.</p>
<p>Here's what I have:</p>
<pre><code>create or replace trigger TRG_NAME
after insert or update or delete on TABLE_1
for each row
begin
if updating then
if nvl(:old.ENTERED_DATE, '*') != nvl(:new.ENTERED_DATE, '*') then
update TABLE_2 set ENTRY_DATE = :new.ENTERED_DATE where ID = :old.ID;
end if;
end if;
end TRG_NAME;
/
</code></pre>
<p>The trigger compiles successfully but when I update the column value which is of type date on both tables I get the following error:</p>
<p><code>ORA-01858: a non-numeric character was found where a numeric was expected</code></p>
<p>I am confused since both fields on both tables are a DATE datatype so why am I getting this error?</p>
| [
{
"answer_id": 74323553,
"author": "GMB",
"author_id": 10676716,
"author_profile": "https://Stackoverflow.com/users/10676716",
"pm_score": 3,
"selected": true,
"text": "nvl"
},
{
"answer_id": 74328012,
"author": "Wernfried Domscheit",
"author_id": 3027266,
"author_profile": "https://Stackoverflow.com/users/3027266",
"pm_score": 0,
"selected": false,
"text": "COALESCE"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323504",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10167746/"
] |
74,323,511 | <p>I wrote a function in JS towards the end that is suppose to give you a letter grade once you get the average of 5 subjects, but it's not showing me anything
I'm lost right now</p>
<p>The forth function I wrote doesn't seem to produce any letter grade. I believe everything else is right</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>function getHandleValue(idName) {
const value = parseInt(document.getElementById(idName).value);
console.log(value);
return value;
}
function getTotal() {
//console.log("app js starts loading")
let english = getHandleValue('english');
let math = getHandleValue('math');
let physics = getHandleValue('physics');
let computer = getHandleValue('computer');
let science = getHandleValue('science');
//console.log("app js ends loading")
let total = english + math + physics + computer + science;
document.getElementById('total').innerHTML = total;
return total;
}
function getAverage() {
// option 1
// const total = parseInt(document.getElementById('total').innerHTML);
// const average = total / 5;
// document.getElementById('average').innerHTML = average;
// option 2
const average = getTotal() / 5;
document.getElementById('average').innerHTML = average;
}
function letterGrade() {
letterGrade;
if (grade >= 90 && grade <= 100)
letterGrade = 'A';
else if (grade >= 80 && grade <= 89)
letterGrade = 'B';
else if (grade >= 70 && grade <= 79)
letterGrade = 'C';
else if (grade >= 60 && grade <= 69)
letterGrade = 'D';
else if (grade > 1 && grade <= 59)
letterGrade = 'F';
let average = letterGrade;
document.getElementById('Grade').innerHTML = Grade;
}</code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74323554,
"author": "Jordan Amberg",
"author_id": 17266561,
"author_profile": "https://Stackoverflow.com/users/17266561",
"pm_score": 0,
"selected": false,
"text": "letterGrade"
},
{
"answer_id": 74323651,
"author": "ethry",
"author_id": 16030830,
"author_profile": "https://Stackoverflow.com/users/16030830",
"pm_score": 0,
"selected": false,
"text": "lettergrade"
},
{
"answer_id": 74324070,
"author": "svarlitskiy",
"author_id": 1072378,
"author_profile": "https://Stackoverflow.com/users/1072378",
"pm_score": -1,
"selected": false,
"text": "<div>\n <section><label>Total:</label><span id=\"total\">0</span></section>\n <section><label>Average:</label><span id=\"average\">0</span></section>\n <section><label>Grade:</label><span id=\"grade\">-</span></section>\n</div>\n<br />\n<form onsubmit=\"return false;\">\n <label>English:</label><input type=\"number\" min=\"0\" max=\"100\" step=\"1\" name=\"english\" value=\"0\" /><br />\n <label>Math:</label><input type=\"number\" min=\"0\" max=\"100\" step=\"1\" name=\"math\" value=\"0\" /><br />\n <label>Physics:</label><input type=\"number\" min=\"0\" max=\"100\" step=\"1\" name=\"physics\" value=\"0\" /><br />\n <label>Computer:</label><input type=\"number\" min=\"0\" max=\"100\" step=\"1\" name=\"computer\" value=\"0\" /><br />\n <label>Science:</label><input type=\"number\" min=\"0\" max=\"100\" step=\"1\" name=\"science\" value=\"0\" /><br />\n\n <br />\n <button onclick=\"calculateGrades(this)\">Calculate Grade</button>\n</form>\n"
},
{
"answer_id": 74342131,
"author": "zer00ne",
"author_id": 2813224,
"author_profile": "https://Stackoverflow.com/users/2813224",
"pm_score": 0,
"selected": false,
"text": "letterGrade()"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323511",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20208389/"
] |
74,323,516 | <p>How do I read an input CSV two rows at a time, combine some values into a new single row, and then write that row to a new CSV?</p>
<p>In the input below I want to read two rows, take price1 from the second row and make it price2 in a new, combined, row, then repeat for the next two rows:</p>
<p><strong>input</strong></p>
<pre><code>date, name, qt, price1
9/12/22, AB, 2, 5.00
9/12/22, AB, 2, 5.08
9/12/22, BC, 1, 2.00
9/12/22, BC, 1, 2.03
</code></pre>
<p><strong>new csv</strong></p>
<pre><code>date, name, qt, price1, price2
9/12/22, AB, 2, 5.00, 5.08
9/12/22, BC, 1, 2.00, 2.03
</code></pre>
<pre class="lang-py prettyprint-override"><code>import csv
data = []
with open('test.csv', 'r') as f:
reader = csv.reader(f)
for row in reader:
data.append({'date': row[0], 'qt': row[3], 'name': row[5], 'price': row[10]})
#data.append(myClass(row[0], row[2], row[3], row[5], row[10]))
for x in data:
print(x)
</code></pre>
<p>Adrian's Answer is missing:</p>
<ul>
<li>import csv</li>
<li>#newline requires python 3</li>
<li>csv must be UTF-8 and headers must match</li>
</ul>
| [
{
"answer_id": 74323554,
"author": "Jordan Amberg",
"author_id": 17266561,
"author_profile": "https://Stackoverflow.com/users/17266561",
"pm_score": 0,
"selected": false,
"text": "letterGrade"
},
{
"answer_id": 74323651,
"author": "ethry",
"author_id": 16030830,
"author_profile": "https://Stackoverflow.com/users/16030830",
"pm_score": 0,
"selected": false,
"text": "lettergrade"
},
{
"answer_id": 74324070,
"author": "svarlitskiy",
"author_id": 1072378,
"author_profile": "https://Stackoverflow.com/users/1072378",
"pm_score": -1,
"selected": false,
"text": "<div>\n <section><label>Total:</label><span id=\"total\">0</span></section>\n <section><label>Average:</label><span id=\"average\">0</span></section>\n <section><label>Grade:</label><span id=\"grade\">-</span></section>\n</div>\n<br />\n<form onsubmit=\"return false;\">\n <label>English:</label><input type=\"number\" min=\"0\" max=\"100\" step=\"1\" name=\"english\" value=\"0\" /><br />\n <label>Math:</label><input type=\"number\" min=\"0\" max=\"100\" step=\"1\" name=\"math\" value=\"0\" /><br />\n <label>Physics:</label><input type=\"number\" min=\"0\" max=\"100\" step=\"1\" name=\"physics\" value=\"0\" /><br />\n <label>Computer:</label><input type=\"number\" min=\"0\" max=\"100\" step=\"1\" name=\"computer\" value=\"0\" /><br />\n <label>Science:</label><input type=\"number\" min=\"0\" max=\"100\" step=\"1\" name=\"science\" value=\"0\" /><br />\n\n <br />\n <button onclick=\"calculateGrades(this)\">Calculate Grade</button>\n</form>\n"
},
{
"answer_id": 74342131,
"author": "zer00ne",
"author_id": 2813224,
"author_profile": "https://Stackoverflow.com/users/2813224",
"pm_score": 0,
"selected": false,
"text": "letterGrade()"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323516",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/169366/"
] |
74,323,527 | <p>I have a problem with rerendering child component.</p>
<p>I have two components:</p>
<p><strong>Parent:</strong></p>
<pre><code>const Parent = () => {
const { checkAuth } = useActions();
const { isLoading } = useSelector(state => state.authReducer);
useEffect(() => {
checkAuth();
}, []);
if (isLoading) {
return <Loader />;
}
return (
<Child />
);
};
export default Parent;
</code></pre>
<p><strong>Child:</strong></p>
<pre><code>const Child = () => {
return (
<div>
Child Component
</div>
);
};
export default Child;
</code></pre>
<p>Action checkAuth() causes the isLoading change in authReducer. So, after isLoading changes, Child component re-renders.</p>
<p>How can I prevent re-render of Child component in this case?</p>
| [
{
"answer_id": 74323580,
"author": "kind user",
"author_id": 6695924,
"author_profile": "https://Stackoverflow.com/users/6695924",
"pm_score": 2,
"selected": false,
"text": "Child"
},
{
"answer_id": 74324454,
"author": "Facundo Gallardo",
"author_id": 20375146,
"author_profile": "https://Stackoverflow.com/users/20375146",
"pm_score": 0,
"selected": false,
"text": "const Parent = () => {\n const { checkAuth } = useActions();\n const { isLoading } = useSelector(state => state.authReducer);\n\n useEffect(() => {\n checkAuth();\n }, []);\n\n return (\n <div>\n {isLoading\n ? <Loader />\n : <Child />\n }\n </div>\n );\n};\n\nexport default Parent;\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323527",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20421175/"
] |
74,323,543 | <p>I am trying to remove some json object from a result of mongoose findone function</p>
<p>but is not working</p>
<p>My code</p>
<pre><code> export const transferGuest = async (req, res, next) => {
var guest = await Booking.findOne({"roomNumber": req.body.roomNumber, booked: true}).sort({createdAt: -1})
try{
const newBooking = new Booking(guest)
delete guest._id;
return res.status(200).json(guest)
}catch(error){
next(error)
}
}
</code></pre>
<p>but delete guest._id does not work.</p>
<p>How do I correct this?</p>
| [
{
"answer_id": 74323982,
"author": "jefmat95",
"author_id": 17471937,
"author_profile": "https://Stackoverflow.com/users/17471937",
"pm_score": 2,
"selected": true,
"text": "findOne()"
},
{
"answer_id": 74326650,
"author": "RK NANDA",
"author_id": 14544576,
"author_profile": "https://Stackoverflow.com/users/14544576",
"pm_score": 0,
"selected": false,
"text": "const guest = await Booking.findOne({roomNumber: req.body.roomNumber, booked: req.body.booked}).lean();\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323543",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16520980/"
] |
74,323,548 | <p>I have a script in google sheets that brings in data via API. Right now it is set to clear any old data in the sheet and then add the new data from the API, however in this instance I would like to be able to tell the script to look for the last row of data and the add the new API pull after the last row of data.</p>
<p>Below is the information that I believe needs to be changed. If anything other information is needed please let me know.</p>
<pre><code>function setDataInToSheet(sheet, data){
if(sheet.getLastRow() > 1)
sheet.getRange(2, 1, sheet.getLastRow()-1, sheet.getLastColumn()).clear()
var rows = []
data.forEach(function(item){
rows.push([item.name, item.fuelPercent.value, item.fuelPercent.time])
})
sheet.getRange(2, 1,rows.length,rows[0].length).setValues(rows);
}
</code></pre>
<p>I am really at a loss and am unsure how to complete this. Thank you in advance for any assistance that you can provide.</p>
| [
{
"answer_id": 74323982,
"author": "jefmat95",
"author_id": 17471937,
"author_profile": "https://Stackoverflow.com/users/17471937",
"pm_score": 2,
"selected": true,
"text": "findOne()"
},
{
"answer_id": 74326650,
"author": "RK NANDA",
"author_id": 14544576,
"author_profile": "https://Stackoverflow.com/users/14544576",
"pm_score": 0,
"selected": false,
"text": "const guest = await Booking.findOne({roomNumber: req.body.roomNumber, booked: req.body.booked}).lean();\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323548",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20421542/"
] |
74,323,561 | <p>I want to do something that seems simple - I have an app on the iPhone that allows you to change a date. On the watch, I have a complication that shows among other things the days until that date. So clearly, when you change the date on the iPhone app, I want the date on the watch to change and that state to be persisted until or if you change the date on the iPhone again.</p>
<p>What I've done is created a state object included in both the complication and the watch app, and in both I just do this to display the value</p>
<pre class="lang-swift prettyprint-override"><code> @ObservedObject state = OneDayState.shared
...
Text( state.daysUntilValue )
</code></pre>
<p><strong>what is happening</strong> when I change the date on the iphone:</p>
<ul>
<li>if the watch app is active and running
<ul>
<li>the date displayed on the app changes like it should</li>
<li>if I go back to the home screen, the complication has the old bad value</li>
<li>if I reset the watch - the complication now has the correct value</li>
</ul>
</li>
<li>if the watch app is not active and running
<ul>
<li>neither the complication nor the watch gets the new value</li>
</ul>
</li>
</ul>
<p><strong>What I <em>want</em> to happen</strong></p>
<ul>
<li>the app to get the new value even if it's not running when I change the value on the iphone</li>
<li>the complication to change instantly when I change the value on the iPhone</li>
</ul>
<p>Here is the code of my state object - what am I doing wrong?? (thx)</p>
<pre class="lang-swift prettyprint-override"><code>class OneDayState : NSObject, ObservableObject, WCSessionDelegate
{
static let shared = OneDayState()
//
// connection to the settings
//
let session = WCSession.default
//
// connection to the user defaults
//
let settings = UserDefaults(suiteName: "[removed]")!;
//
// what is watched by the UI
//
var daysUntilValue : String {
return String( Calendar.current.dateComponents( [.day], from: .now, to: theDate).day!)
}
//
// the target date
//
@Published var theDate : Date = Date.now
//
// setup this
//
override init()
{
super.init()
session.delegate = self
session.activate()
theDate = settings.object(forKey: "target" ) as? Date ?? Date.now;
}
//
// you seem to have to override this
//
func session(_ session: WCSession, activationDidCompleteWith activationState: WCSessionActivationState, error: Error?) {
print("sesison activated")
}
//
// when the application context changes, we just store the new date
//
func session(_ session: WCSession, didReceiveApplicationContext applicationContext: [String : Any])
{
let newDate = applicationContext["target"] as? Date ?? Date.now;
DispatchQueue.main.async
{
self.settings.set( newDate, forKey: "target")
self.theDate = newDate;
}
}
}
</code></pre>
| [
{
"answer_id": 74381613,
"author": "Reinhard Männer",
"author_id": 1987726,
"author_profile": "https://Stackoverflow.com/users/1987726",
"pm_score": 0,
"selected": false,
"text": "WatchSessionManager"
},
{
"answer_id": 74400847,
"author": "Owen Zhao",
"author_id": 1606231,
"author_profile": "https://Stackoverflow.com/users/1606231",
"pm_score": 2,
"selected": true,
"text": "WKWatchConnectivityRefreshBackgroundTask"
},
{
"answer_id": 74401370,
"author": "Cheezzhead",
"author_id": 2542661,
"author_profile": "https://Stackoverflow.com/users/2542661",
"pm_score": 0,
"selected": false,
"text": "OneDayState"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323561",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2446374/"
] |
74,323,563 | <p>I have a list, that can be of various lengths (less than 100 or more than 1.800.000) and I need to display all those values on a graph (a waveform) of 800 points on which I can draw.</p>
<p>I have tried taking a value for every step, where a step is the list length / 800. And it is the closest I can get to. I have tried taking the average value of the n surrounding of step with various n, but I can't get a waveform that satisfies me.</p>
<p>I know image compression work by taking an average of surrounding pixels, and I am trying to do the same with a list of values going from 0 to 200. I need to preserve the global aspect, but also the highest and lowest spikes.</p>
| [
{
"answer_id": 74381613,
"author": "Reinhard Männer",
"author_id": 1987726,
"author_profile": "https://Stackoverflow.com/users/1987726",
"pm_score": 0,
"selected": false,
"text": "WatchSessionManager"
},
{
"answer_id": 74400847,
"author": "Owen Zhao",
"author_id": 1606231,
"author_profile": "https://Stackoverflow.com/users/1606231",
"pm_score": 2,
"selected": true,
"text": "WKWatchConnectivityRefreshBackgroundTask"
},
{
"answer_id": 74401370,
"author": "Cheezzhead",
"author_id": 2542661,
"author_profile": "https://Stackoverflow.com/users/2542661",
"pm_score": 0,
"selected": false,
"text": "OneDayState"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323563",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19759196/"
] |
74,323,574 | <p>I have the following code however it does not work:</p>
<pre class="lang-js prettyprint-override"><code>let dummyDOM = document.createElement( 'html' );
dummyDOM.innerHTML = text;
const html = dummyDOM.getElementById("someID");
</code></pre>
<p>I receive: <code>Uncaught (in promise) TypeError: dummyDOM.getElementById is not a function</code></p>
<p>I know how to get elements by class name but I have not seen a way to get elements by ID. Is this possible with htmlcollection?</p>
| [
{
"answer_id": 74323792,
"author": "ethry",
"author_id": 16030830,
"author_profile": "https://Stackoverflow.com/users/16030830",
"pm_score": 0,
"selected": false,
"text": "getElementById()"
},
{
"answer_id": 74323858,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 3,
"selected": true,
"text": "querySelector"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323574",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4427375/"
] |
74,323,578 | <p>I have a BigQuery table that keeps track of user sign ins:</p>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>user_id</th>
<th>user_name</th>
<th>user_sign_in_date</th>
</tr>
</thead>
<tbody>
<tr>
<td>1</td>
<td>john doe</td>
<td>2019-04-05</td>
</tr>
<tr>
<td>1</td>
<td>john doe</td>
<td>2019-04-06</td>
</tr>
<tr>
<td>2</td>
<td>bob bobson</td>
<td>2019-04-05</td>
</tr>
<tr>
<td>2</td>
<td>bob bobson</td>
<td>2019-04-08</td>
</tr>
<tr>
<td>3</td>
<td>jane beer</td>
<td>2019-04-05</td>
</tr>
<tr>
<td>3</td>
<td>jane beer</td>
<td>2019-04-06</td>
</tr>
<tr>
<td>3</td>
<td>jane beer</td>
<td>2019-04-07</td>
</tr>
<tr>
<td>3</td>
<td>jane beer</td>
<td>2019-04-08</td>
</tr>
<tr>
<td>4</td>
<td>amy face</td>
<td>2019-04-09</td>
</tr>
</tbody>
</table>
</div>
<p>I want to be able to get users who have not signed in on certain dates and list the dates they have missed. For example, if I want to see users who have not signed in between 2019-04-05 and 2019-04-08, I would need a SQL query that could help me generate something like:</p>
<pre><code>[
{
'user_id': 1,
'user_name': 'john doe',
'dates_not_signed_in': ['2019-04-07', '2019-04-08']
},
{
'user_id': 2,
'user_name': 'bob bobson',
'dates_not_signed_in': ['2019-04-06', '2019-04-07']
},
{
'user_id': 4,
'user_name': 'amy face',
'dates_not_signed_in': ['2019-04-05', '2019-04-06', '2019-04-07', '2019-04-08']
}
]
</code></pre>
<p>I think I need to do something like</p>
<pre><code>SELECT user_id
FROM table
</code></pre>
<p>to get all the user IDs but then I'm not sure how to surround that query so that I only get back users who didn't sign in on certain dates <em>with</em> the dates they missed.</p>
| [
{
"answer_id": 74323792,
"author": "ethry",
"author_id": 16030830,
"author_profile": "https://Stackoverflow.com/users/16030830",
"pm_score": 0,
"selected": false,
"text": "getElementById()"
},
{
"answer_id": 74323858,
"author": "caTS",
"author_id": 18244921,
"author_profile": "https://Stackoverflow.com/users/18244921",
"pm_score": 3,
"selected": true,
"text": "querySelector"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323578",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10002483/"
] |
74,323,584 | <p>I want to map the object in the array and access it through the row and col fields</p>
<p>I have the following object array:</p>
<pre class="lang-js prettyprint-override"><code>const arrayList = [
{row: 0, col: 0, name:'Ankara'},
{row: 0, col: 1, name:'Tokyo'},
{row: 1, col: 0, name:'Munih'},
{row: 1, col: 1, name:'Basel'},
]
</code></pre>
<p>I want to be able to access those elements with a nested array.</p>
<p><em><strong>For example:</strong></em></p>
<p><code>arrayMapList[0][0] = {row:0,col:0, name:'Ankara'}</code></p>
<p><em><strong>Then I use:</strong></em></p>
<p><code>arrayMapList[0][0]</code></p>
<p><em><strong>The following should output:</strong></em></p>
<p><code>{row:0,col:0, name:'Ankara'}</code></p>
| [
{
"answer_id": 74323624,
"author": "Barmar",
"author_id": 1491895,
"author_profile": "https://Stackoverflow.com/users/1491895",
"pm_score": 2,
"selected": true,
"text": "const arrayList = [\n {row:0,col:0, name:'Ankara'},\n {row:0,col:1, name:'Tokyo'},\n {row:1,col:0, name:'Munih'},\n {row:1,col:1, name:'Basel'},\n];\n\nconst arrayMapList = [];\narrayList.forEach(el => {\n if (!arrayMapList[el.row]) {\n arrayMapList[el.row] = [];\n }\n arrayMapList[el.row][el.col] = el;\n});\n\nconsole.log(arrayMapList[0][1]);"
},
{
"answer_id": 74323652,
"author": "SparrowVic",
"author_id": 15564661,
"author_profile": "https://Stackoverflow.com/users/15564661",
"pm_score": -1,
"selected": false,
"text": "arrayList = [\n {row:0,col:0, name:'Ankara'},\n {row:0,col:1, name:'Tokyo'},\n {row:1,col:0, name:'Munih'},\n {row:1,col:1, name:'Basel'},\n];\n\nconst mappedArray = this.arrayList.map(x => ({row: x.row, col: x.col, x}));\n"
},
{
"answer_id": 74323666,
"author": "code",
"author_id": 15359157,
"author_profile": "https://Stackoverflow.com/users/15359157",
"pm_score": 0,
"selected": false,
"text": "Array#reduce"
},
{
"answer_id": 74323714,
"author": "Weeby_F33t",
"author_id": 19598380,
"author_profile": "https://Stackoverflow.com/users/19598380",
"pm_score": 1,
"selected": false,
"text": "const arrayMapList = [\n ['Ankara', 'Tokyo'],\n ['Munih', 'Basel']\n]\n\nlet row = 0;\nlet col = 0;\nconsole.log(\"Row:\" + row + \" Col:\" + col + \" Name: \");//Row:0 Col:0 Name: \nconsole.log(arrayMapList[row][col]);//Ankara\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323584",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19301566/"
] |
74,323,588 | <p>Using Entity Framework Core (5.0.17) code first I'm having trouble implementing a class that has two references to another class.</p>
<p>this is my structure:</p>
<pre><code>public class Beneficio
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
public int ComercioBeneficioId { get; set; }
public int ComercioOtorgadorId { get; set; }
[ForeignKey("ComercioBeneficioId")]
public Comercio ComercioBeneficio { get; set; }
[ForeignKey("ComercioOtorgadorId")]
public Comercio ComercioOtorgador { get; set; }
}
</code></pre>
<pre><code>public class Comercio
{
[Key]
[DatabaseGenerated(DatabaseGeneratedOption.Identity)]
public int Id { get; set; }
</code></pre>
<p>The Required attributes on the location references makes it impossible to update the table on the database . This is the error message I get:</p>
<blockquote>
<p>Introducing <code>FOREIGN KEY</code> constraint '<code>FK_Races_Locations_StartLocationId</code>' on table '<code>Races</code>' may cause cycles or multiple cascade paths.</p>
<p>Specify <code>ON DELETE NO ACTION</code> or <code>ON UPDATE NO ACTION</code>, or modify other <code>FOREIGN KEY</code> constraints.</p>
<p>Could not create constraint or index.</p>
</blockquote>
| [
{
"answer_id": 74323624,
"author": "Barmar",
"author_id": 1491895,
"author_profile": "https://Stackoverflow.com/users/1491895",
"pm_score": 2,
"selected": true,
"text": "const arrayList = [\n {row:0,col:0, name:'Ankara'},\n {row:0,col:1, name:'Tokyo'},\n {row:1,col:0, name:'Munih'},\n {row:1,col:1, name:'Basel'},\n];\n\nconst arrayMapList = [];\narrayList.forEach(el => {\n if (!arrayMapList[el.row]) {\n arrayMapList[el.row] = [];\n }\n arrayMapList[el.row][el.col] = el;\n});\n\nconsole.log(arrayMapList[0][1]);"
},
{
"answer_id": 74323652,
"author": "SparrowVic",
"author_id": 15564661,
"author_profile": "https://Stackoverflow.com/users/15564661",
"pm_score": -1,
"selected": false,
"text": "arrayList = [\n {row:0,col:0, name:'Ankara'},\n {row:0,col:1, name:'Tokyo'},\n {row:1,col:0, name:'Munih'},\n {row:1,col:1, name:'Basel'},\n];\n\nconst mappedArray = this.arrayList.map(x => ({row: x.row, col: x.col, x}));\n"
},
{
"answer_id": 74323666,
"author": "code",
"author_id": 15359157,
"author_profile": "https://Stackoverflow.com/users/15359157",
"pm_score": 0,
"selected": false,
"text": "Array#reduce"
},
{
"answer_id": 74323714,
"author": "Weeby_F33t",
"author_id": 19598380,
"author_profile": "https://Stackoverflow.com/users/19598380",
"pm_score": 1,
"selected": false,
"text": "const arrayMapList = [\n ['Ankara', 'Tokyo'],\n ['Munih', 'Basel']\n]\n\nlet row = 0;\nlet col = 0;\nconsole.log(\"Row:\" + row + \" Col:\" + col + \" Name: \");//Row:0 Col:0 Name: \nconsole.log(arrayMapList[row][col]);//Ankara\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323588",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/4024357/"
] |
74,323,594 | <p>How we make a C++ function that can assign different types to an auto variable?</p>
<p>The nlohmann json package does this, which is proof that it’s possible:</p>
<pre><code>#include <iostream>
#include "./x64/Debug/single_include/nlohmann/json.hpp"
using namespace std;
using json = nlohmann::json;
int main()
{
nlohmann::json obj = nlohmann::json::parse("{ \"one\": \"111\", \"two\": 222}");
string res1 = obj["one"]; // Types defined:
int res2 = obj["two"];
auto a1 = obj["one"]; // Auto variables:
auto a2 = obj["two"];
cout << "Types defined: " << res1 << ' ' << res2 << endl;
cout << "Auto variables: " << a1 << ' ' << a2 << endl;
}
</code></pre>
<p>Result:</p>
<pre><code>Types defined: 111 222
Auto variables: "111" 222
</code></pre>
<p>The auto variables correctly received types string and int.</p>
<p>I have a class that stores different types that I want to assign to auto variables like nlohmann json does.</p>
<p>I’ve tried using implicit conversion methods. The base class below defines int() and string() conversions, which are overridden in the derived classes for int and string. So PayloadParamBase is converted to int or string to match the derived class. The problem is that I can’t get conversion to the right type when PayloadParamBase is assigned to an auto variable. See the result below.</p>
<pre><code>#include <iostream>
#include <unordered_map>
using namespace std;
class PayloadParamBase;
unordered_map<string, PayloadParamBase*> map;
class PayloadParamBase // Base class.
{
public:
virtual void operator= (const int i) { };
virtual void operator= (const string s) { };
virtual operator int() const { return 0; }; // Implicit conversions:
virtual operator string() const { return ""; };
PayloadParamBase& operator[](const char* key) { string tmp(key); return operator[](tmp); } // Avoids implicit conversion error.
PayloadParamBase& operator[](const string& key);
};
PayloadParamBase& PayloadParamBase::operator[] (const string& key)
{
PayloadParamBase* ptr = map[key]; // Look up a derived class.
return *ptr;
}
class PayloadStringParam : public PayloadParamBase // String derived class.
{
public:
PayloadStringParam(string st) { mValue = st; }
virtual operator string() const override { return mValue; }
protected:
string mValue;
};
class PayloadIntParam : public PayloadParamBase // Int derived class.
{
public:
PayloadIntParam(int i) { mValue = i; }
virtual operator int() const override { return mValue; }
protected:
int mValue;
};
int main()
{
map["one"] = new PayloadStringParam("111");
map["two"] = new PayloadIntParam(222);
PayloadParamBase pl;
string strVal = pl["one"]; // Assignment to fixed type works:
int intVal = pl["two"];
cout << "Types defined: " << strVal << ' ' << intVal << endl;
auto res1 = pl["one"]; // Assignment to autos doesn't use type:
auto res2 = pl["two"];
cout << "Auto variables: " << res1 << ' ' << res2 << endl;
}
</code></pre>
<p>Result:</p>
<pre><code>Types defined: 111 222
Auto variables: 0 0
</code></pre>
<p>The auto variables are zeroes and the assignments failed. How can I get conversion to the right type when assigning to an auto variable? Thanks!</p>
| [
{
"answer_id": 74323706,
"author": "463035818_is_not_a_number",
"author_id": 4117728,
"author_profile": "https://Stackoverflow.com/users/4117728",
"pm_score": 0,
"selected": false,
"text": "auto"
},
{
"answer_id": 74323815,
"author": "Sam Varshavchik",
"author_id": 3943312,
"author_profile": "https://Stackoverflow.com/users/3943312",
"pm_score": 3,
"selected": false,
"text": "auto a1 = obj[\"one\"]; // Auto variables:\nauto a2 = obj[\"two\"];\n\nTypes defined: 111 222\nAuto variables: \"111\" 222\n"
},
{
"answer_id": 74324126,
"author": "Chris Dodd",
"author_id": 16406,
"author_profile": "https://Stackoverflow.com/users/16406",
"pm_score": 1,
"selected": false,
"text": "auto"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323594",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3845527/"
] |
74,323,601 | <p>How can I split each of the sentence in the arraylist? what i'm trying to make is, a different set of sentence to be splitted and shuffle, and student will arrange it in correct order</p>
<pre><code>public class QuestionActivity1 extends AppCompatActivity {
private int presCounter = 0;
private int maxpresCounter;
private List<QuestionModel1> list;
TextView textScreen, textQuestion, textTitle;
Button submitBtn;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_question1);
Toolbar toolbar=findViewById(R.id.toolbar);
setSupportActionBar(toolbar);
submitBtn=(Button) findViewById(R.id.submitBtn);
list=new ArrayList<>();
list.add(new QuestionModel1("The kids are playing"));
list.add(new QuestionModel1("The kids are sleeping"));
list.add(new QuestionModel1("The kids are dancing"));
keys=shuffleArray(keys);
for (String key : keys){
addView(((LinearLayout) findViewById(R.id.layoutParent)), key, ((EditText) findViewById(R.id.editText)));
}
maxpresCounter= keys.length;
}
</code></pre>
<p>I can only try one</p>
<pre><code>private String sentence="The kids are playing";
private String[] keys=sentence.split(" ");
</code></pre>
<p>QuestionModel Class</p>
<pre><code>public class QuestionModel1 {
private String sentence;
public QuestionModel1(String sentence) {
this.sentence = sentence;
}
public String getSentence() {
return sentence;
}
public void setSentence(String sentence) {
this.sentence = sentence;
}
}
</code></pre>
| [
{
"answer_id": 74323986,
"author": "jure",
"author_id": 10580773,
"author_profile": "https://Stackoverflow.com/users/10580773",
"pm_score": 1,
"selected": false,
"text": "List<QuestionModel1> list = new ArrayList();\nlist.add(new QuestionModel1(\"The kids are playing\"));\nlist.add(new QuestionModel1(\"The kids are sleeping\"));\nlist.add(new QuestionModel1(\"The kids are dancing\"));\n"
},
{
"answer_id": 74324166,
"author": "BigBeef",
"author_id": 20304512,
"author_profile": "https://Stackoverflow.com/users/20304512",
"pm_score": 3,
"selected": true,
"text": " for (QuestionModel1 questionModel1 : list) {\n String sentence = questionModel1.getSentence();\n String[] keys = sentence.split(\" \");\n // do what you need below for each key.\n // shuffleArray(keys); <--- A stab at what you need ??? \n }\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323601",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20274602/"
] |
74,323,622 | <p>I've created a .NET 6 Minimal Web API that needs to support a particularly formatted URL. The URL that needs to be accepted is similar to /sensor/sensor:123/measurement</p>
<p>The following is the relevant Program.cs.</p>
<pre class="lang-cs prettyprint-override"><code>var builder = WebApplication.CreateBuilder(args);
builder.Services.AddEndpointsApiExplorer();
builder.Services.AddSwaggerGen();
var app = builder.Build();
if (app.Environment.IsDevelopment())
{
app.UseSwagger();
app.UseSwaggerUI();
}
app.MapGet("/sensor/sensor:{sensorId}/measurement", (int sensorId) =>
{
return Results.Ok();
});
app.Run();
</code></pre>
<p>However, when I run this and check the generated Swagger UI I see the GET URL listed as <code>/sensor/sensor}/measurement</code>. Trying it out properly shows the sensorId as a path parameter, but actually entering data and executing via this interface results in a 404.</p>
<p>If I modify it to the following, I can get it to run, and it allows me to pass the colon in the request, but I would prefer if the colon was part of the route definition, since it a) should be and b) requires extra parsing logic.</p>
<pre class="lang-cs prettyprint-override"><code>app.MapGet("/sensor/sensor{sensorId}/measurement", (string sensorId) =>
{
return Results.Ok();
});
</code></pre>
<p>Is there a way to allow/escape colons in .NET 6 Minimal Web APIs so they can be part of the defined route?</p>
| [
{
"answer_id": 74323993,
"author": "Guru Stron",
"author_id": 2501279,
"author_profile": "https://Stackoverflow.com/users/2501279",
"pm_score": 0,
"selected": false,
"text": "GetIntProduct"
},
{
"answer_id": 74324087,
"author": "vernou",
"author_id": 2703673,
"author_profile": "https://Stackoverflow.com/users/2703673",
"pm_score": 2,
"selected": true,
"text": ":"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323622",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11912/"
] |
74,323,623 | <p>Firebase functions:</p>
<pre><code>const functions = require("firebase-functions");
const admin = require('firebase-admin');
admin.initializeApp();
exports.chatNotifications = functions.firestore.document("chat/{docId}").onCreate(
(snapshot, context) => {
admin.messaging().sendToTopic(
"chat",
{
notification: {title: "New message", body: "A new message has been sent"},
data: {click_action: "FLUTTER_NOTIFICATION_CLICK"},
}
);
}
);
</code></pre>
<p>Flutter:</p>
<pre><code>
Future<void> backgroundHandler(RemoteMessage message) async{
print(message.notification!.body.toString());
}
void main{
FirebaseMessaging.instance.subscribeToTopic("chat");
FirebaseMessaging.onBackgroundMessage(backgroundHandler);
}
</code></pre>
<p>pubspec.yaml:</p>
<pre><code>firebase_core: ^2.1.1
firebase_auth: ^4.1.0
cloud_firestore: ^4.0.3
firebase_messaging: ^14.0.4
flutter_local_notifications: ^12.0.3
</code></pre>
<p>It works when I send a notification from the firebase console.
I don't get anything from firebase functions.</p>
| [
{
"answer_id": 74323993,
"author": "Guru Stron",
"author_id": 2501279,
"author_profile": "https://Stackoverflow.com/users/2501279",
"pm_score": 0,
"selected": false,
"text": "GetIntProduct"
},
{
"answer_id": 74324087,
"author": "vernou",
"author_id": 2703673,
"author_profile": "https://Stackoverflow.com/users/2703673",
"pm_score": 2,
"selected": true,
"text": ":"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323623",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20421592/"
] |
74,323,625 | <p>I'm using Black to format python in VSCode, and it's making all my arrays super tall instead of wide. I've set max line length to 150 for pep8 and flake8 and black (but I'm new to Black, and not sure if it uses either of those settings):</p>
<p><code>"python.formatting.blackArgs": ["--line-length", "150"],</code></p>
<p>Here's how it looks:</p>
<pre><code>expected = make_dict_of_rows(
[
10,
11,
15,
24,
26,
30,
32,
35,
36,
37,
50,
53,
54,
74,
76,
81,
114,
115,
118,
119,
120,
123,
],
)
</code></pre>
<p>is what I get instead of the much more concise:</p>
<pre><code>expected = make_dict_of_rows(
[
10, 11, 15, 24, 26, 30, 32, 35, 36, 37, 50, 53, 54, 74, 76, 81, 114, 115, 118, 119, 120, 123,
],
)
</code></pre>
<p>(Or even preferable, this would have some collapsed brackets):</p>
<pre><code>expected = make_dict_of_rows([
10, 11, 15, 24, 26, 30, 32, 35, 36, 37, 50, 53, 54, 74, 76, 81, 114, 115, 118, 119, 120, 123
])
</code></pre>
| [
{
"answer_id": 74323661,
"author": "pigrammer",
"author_id": 19846219,
"author_profile": "https://Stackoverflow.com/users/19846219",
"pm_score": 3,
"selected": true,
"text": "--skip-magic-trailing-comma"
},
{
"answer_id": 74654234,
"author": "not_a_robot",
"author_id": 20204509,
"author_profile": "https://Stackoverflow.com/users/20204509",
"pm_score": 0,
"selected": false,
"text": "--skip-magic-trailing-comma"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323625",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1214800/"
] |
74,323,626 | <p>I'm making a sudoku solver, and I have the actual solver working. However, I want the sudoku solver to be sort of 'animated' and every time one of the tiles changes I want that change to be shown. With the way I have it written currently it will only re render once the whole sudoku is solved.</p>
<p>Here is my code:</p>
<pre><code>
import { useEffect, useState } from 'react'
import './SudokuSolver.css'
export default function SudokuSolver() {
//0 stands for empty
const sudoku = [8, 0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 3, 6, 0, 0, 0, 0, 0,
0, 7, 0, 0, 9, 0, 2, 0, 0,
0, 5, 0, 0, 0, 7, 0, 0, 0,
0, 0, 0, 0, 4, 5, 7, 0, 0,
0, 0, 0, 1, 0, 0, 0, 3, 0,
0, 0, 1, 0, 0, 0, 0, 6, 8,
0, 0, 8, 5, 0, 0, 0, 1, 0,
0, 9, 0, 0, 0, 0, 4, 0, 0]
const [sudokuObject, setSudokuObject] = useState(sudoku.map(tile => {
return {
value: tile,
predetermined: tile !== 0 ? true : false
}
}))
const sudokuSize = Math.sqrt(sudoku.length)
const tileSizeInPixels = 70;
const pixelsFromTop = (index) => {
const subsectionBuffer = Math.floor((index / sudokuSize) / Math.sqrt(sudokuSize)) * 20
return ((Math.floor(index / sudokuSize)) * tileSizeInPixels) + subsectionBuffer
}
const pixelsFromLeft = (index) => {
const subsectionBuffer = Math.floor((index % sudokuSize) / 3) * 20;
return ((index % sudokuSize) * tileSizeInPixels) + subsectionBuffer
}
const isLegalByRow = (testNum, index, sudokuObject) => {
//get the row number (possible values: 0 through sudokuSize)
const rowNum = Math.floor(index / sudokuSize)
for(let i = 0; i < sudokuSize; i++){
if(sudokuObject[i + (rowNum * sudokuSize)].value === testNum)
return false
}
return true
}
const isLegalByColumn = (testNum, index, sudokuObject) => {
//get the column number (possible values: 0 through sudokuSize)
const columnNum = (index) % (sudokuSize)
for(let i = 0; i < sudokuSize; i++){
if(sudokuObject[(i * sudokuSize) + columnNum].value === testNum)
return false;
}
return true;
}
const isLegalBySubsection = (testNum, index, sudokuObject) => {
const subsectionSize = Math.sqrt(sudokuSize)
const rowNum = Math.floor(index / sudokuSize)
const columnNum = index % sudokuSize
//gets 'subsection indexes', for instance in a 9x9 grid there's 9 subsections (3x3) boxes
//this determines which box to check
const subsectionRow = Math.floor(rowNum / Math.sqrt(sudokuSize))
const subsectionColumn = Math.floor(columnNum / Math.sqrt(sudokuSize))
//example: box [1, 1] should check indexes: 30, 31, 32, 39, 40, 41, 48, 49, 50
const subsectionRowSize = subsectionSize * sudokuSize
const startingIndex = subsectionRowSize * subsectionRow + (subsectionColumn * subsectionSize)
for(let i = 0; i < subsectionSize; i++){
for(let j = 0; j < subsectionSize; j++){
if(sudokuObject[(startingIndex + j) + i * sudokuSize].value === testNum)
return false
}
}
return true
}
const isLegal = (testNum, index, tempObject) => {
return(isLegalBySubsection(testNum, index, tempObject) &&
isLegalByRow(testNum, index, tempObject) && isLegalByColumn(testNum, index, tempObject))
}
const autoSolveSudoku = () => {
/* the algorithm:
iterate through each tile of the sudoku, for each tile:
starting at the number 1, try every possible number (up to 9 for a standard sudoku)
stop at a number when it's legal and go forward to the next tile
if(none of the possible numbers are legal):
go back to previous tiles(again skip if predetermined),
on previous tiles:
start at the number that was left there and go up to sudokuSize
once a legal number is found start going forward again
if no legal number is found keep going backward
*/
let goingForward = true;
let tempObject = [...sudokuObject];
for(let i = 0; i < tempObject.length; i++){
if(tempObject[i].predetermined){
if(goingForward)
continue;
i -=2;
continue;
}
for(let j = tempObject[i].value; j <= sudokuSize; j++){
if(j === 0){
continue;
}
if(!goingForward && tempObject[i].value === sudokuSize){
tempObject[i].value = 0;
break;
}
if(isLegal(j, i, tempObject)){
tempObject[i].value = j;
goingForward = true;
break;
}
if(j === sudokuSize){
tempObject[i].value = 0;
goingForward = false;
}
}
if(!goingForward)
i -= 2
setSudokuObject(tempObject)
}
}
return <div style={{top:'50px', left:'50px', position:'relative'}}>
{sudokuObject.map((tile, index) => {
return <div id="tile" style={{top: pixelsFromTop(index), left: pixelsFromLeft(index), color: tile.predetermined && 'blueviolet'}}>
{index - 1 % 9 === 0 && index !== 1 && index !== 0 && <br/>}
{tile.value !== 0 ? tile.value : " "}
</div>
})}
<button id='solvebutton' onClick={autoSolveSudoku}>Auto Solve</button>
</div>
}
</code></pre>
<p>I know setSudokuObject() would only be called once the autoSolveSudoku() function finishes, so is there a way to update it every time a value changes? Honestly I've never encountered this before so I'm not sure how to approach it.</p>
| [
{
"answer_id": 74323661,
"author": "pigrammer",
"author_id": 19846219,
"author_profile": "https://Stackoverflow.com/users/19846219",
"pm_score": 3,
"selected": true,
"text": "--skip-magic-trailing-comma"
},
{
"answer_id": 74654234,
"author": "not_a_robot",
"author_id": 20204509,
"author_profile": "https://Stackoverflow.com/users/20204509",
"pm_score": 0,
"selected": false,
"text": "--skip-magic-trailing-comma"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323626",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17266561/"
] |
74,323,677 | <p>I'm trying to replace a string with the character comma <code>,</code>, only if the string appears right <strong>after a digit</strong>.</p>
<p>Here is an example -</p>
<pre><code>text1 = "PaulWilliamsnéle110187auCaire"
text2 = "StaceyMauranéele190991auMaroc"
</code></pre>
<p>When I try using the <code>str_replace_all</code> function from <code>stringr</code>, it replaces all instances of 'au' from the texts.</p>
<pre><code>str_replace_all(text1,"au",",")
str_replace_all(text2,"au",",")
</code></pre>
<p>The above functions give the following outputs</p>
<blockquote>
<p>P,lWilliamsnéle110187,Caire</p>
</blockquote>
<blockquote>
<p>StaceyM,ranéele190991,Maroc</p>
</blockquote>
<p>However, I'd only like the <code>"au"</code> to be removed following the final digit in the texts, not before.</p>
<p>So ideally, the desired output would be -</p>
<blockquote>
<p>PaulWilliamsnéle110187,Caire</p>
</blockquote>
<blockquote>
<p>StaceyMauranéele190991,Maroc</p>
</blockquote>
<p>But I'm unable to figure out how to put this condition into the function, so it only removes the <code>"au"</code> following the final digits for both texts.</p>
<p>Any help would be appreciated</p>
| [
{
"answer_id": 74323661,
"author": "pigrammer",
"author_id": 19846219,
"author_profile": "https://Stackoverflow.com/users/19846219",
"pm_score": 3,
"selected": true,
"text": "--skip-magic-trailing-comma"
},
{
"answer_id": 74654234,
"author": "not_a_robot",
"author_id": 20204509,
"author_profile": "https://Stackoverflow.com/users/20204509",
"pm_score": 0,
"selected": false,
"text": "--skip-magic-trailing-comma"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323677",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/7819673/"
] |
74,323,678 | <p>I'm trying to create a graph for the function (1+1/x)^x.</p>
<p>I wrote it in python like this:</p>
<pre><code>def func(x):
return pow(1+(1/x),x)
</code></pre>
<p>I then plotted it like this:</p>
<pre><code>graph = axes.plot(lambda x: func(x), color=BLUE, stroke_width=2, x_range=[0,X_MAX])
</code></pre>
<p>(X_MAX is a variable that equals 1000)</p>
<p>but for some reason Manim is plotting something else.</p>
<p>When I plotted the function in Desmos I got this graph:
<a href="https://i.stack.imgur.com/C91qQ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C91qQ.png" alt="" /></a></p>
<p>And Manim gave me this one:
<a href="https://i.stack.imgur.com/5YSff.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5YSff.png" alt="" /></a></p>
<p>(I know the scales are different the main focus is the hump at the top)</p>
| [
{
"answer_id": 74323661,
"author": "pigrammer",
"author_id": 19846219,
"author_profile": "https://Stackoverflow.com/users/19846219",
"pm_score": 3,
"selected": true,
"text": "--skip-magic-trailing-comma"
},
{
"answer_id": 74654234,
"author": "not_a_robot",
"author_id": 20204509,
"author_profile": "https://Stackoverflow.com/users/20204509",
"pm_score": 0,
"selected": false,
"text": "--skip-magic-trailing-comma"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323678",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19278323/"
] |
74,323,693 | <p>I'm trying to click on a button using the selenium, but I'm getting an error.</p>
<p>This is the error:</p>
<p><a href="https://i.stack.imgur.com/NQjnh.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NQjnh.png" alt="enter image description here" /></a></p>
<p>this is the fragment of the accessed html page:</p>
<p><a href="https://i.stack.imgur.com/khL4T.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/khL4T.png" alt="enter image description here" /></a></p>
<p>This is my code:</p>
<pre><code>from selenium import webdriver
chrome_options = webdriver.ChromeOptions()
chrome_options.add_argument('--headless')
chrome_options.add_argument('--no-sandbox')
chrome_options.add_argument('--disable-dev-shm-usage')
wd = webdriver.Chrome('chromedriver',options=chrome_options)
wd.get("xxxxxx")
button = wd.find_element(By.CLASS_NAME,"VfPpkd-LgbsSe.VfPpkd-LgbsSe-OWXEXe-dgl2Hf.ksBjEc.lKxP2d.LQeN7.x0t5t")
button.click()
</code></pre>
<p>The objective is: When I click on the button using the selenium a popup appears on the screen</p>
| [
{
"answer_id": 74323661,
"author": "pigrammer",
"author_id": 19846219,
"author_profile": "https://Stackoverflow.com/users/19846219",
"pm_score": 3,
"selected": true,
"text": "--skip-magic-trailing-comma"
},
{
"answer_id": 74654234,
"author": "not_a_robot",
"author_id": 20204509,
"author_profile": "https://Stackoverflow.com/users/20204509",
"pm_score": 0,
"selected": false,
"text": "--skip-magic-trailing-comma"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323693",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12156494/"
] |
74,323,710 | <p>JSON file:</p>
<pre><code>{
"data": [
{
"id": "ec35139e-60b9-458e-95c6-0aa1db7d30d4",
"name": "Jeffrey",
"last_ping": "2022-11-02 17:42:00.765568",
"last_ping_timestamp": 1667407320,
"status": "ok",
"secret_key": "BigBook32"
},
{
"id": "4b9b05df-c9d7-4ed6-bde7-d4663414996b",
"name": "John",
"last_ping": "2022-11-02 17:42:00.772017",
"last_ping_timestamp": 1667407320,
"status": "ok",
"secret_key": "FastSnake40"
},
{
"id": "9ed15fce-2069-470a-8515-6723b28f257d",
"name": "Jack",
"last_ping": "2022-11-02 17:42:00.788384",
"last_ping_timestamp": 1667407320,
"status": "ok",
"secret_key": "GreenComputer33"
}
]
}
</code></pre>
<p>I have a JSON file with hundreds of objects, how can I update the "last_ping" value for one of them in python?</p>
| [
{
"answer_id": 74323661,
"author": "pigrammer",
"author_id": 19846219,
"author_profile": "https://Stackoverflow.com/users/19846219",
"pm_score": 3,
"selected": true,
"text": "--skip-magic-trailing-comma"
},
{
"answer_id": 74654234,
"author": "not_a_robot",
"author_id": 20204509,
"author_profile": "https://Stackoverflow.com/users/20204509",
"pm_score": 0,
"selected": false,
"text": "--skip-magic-trailing-comma"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323710",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14726294/"
] |
74,323,741 | <p>I need to insert links but check whether a file exists in this language. I want to adjust the link target dynamically during or after build.</p>
<p>Currently, due to the nested structure of the navigation file, a generator plugin creates an index of articles with their properties, e.g. title, path, etc. The information is accessible in includes in <code>site.docs_by_site</code>.</p>
<p>The idea is to correct any missing links to other articles in the page content by passing a partial link to an include file. The link will be passed into a parameter.</p>
<p>I would insert links like this:</p>
<p><code>{% include link.html path='getting-started/test.md' %} </code></p>
<p>I though using an include file could work out:</p>
<pre><code>{% if page.lang == 'en' %}
{% assign full_path = "_" | append: 'en' | append: "/" | append: include.path %}
{% assign post = site.docs_by_path[full_path] %}
{% endif %}
{% if page.lang != 'en' %}
{% assign full_path = "_" | append: page.lang | append: "/" | append: include.path %}
{% assign localized_file = site.docs_by_path[full_path] %}
{% if localized_file %}
{% assign post = localized_file %}
{% else %}
{% assign full_path = "_" | append: 'en' | append: "/" | append: include.path %}
{% assign post = site.docs_by_path[full_path] %}
{% endif %}
{% endif %}
<div>
{% if post[0] == nil %}
<a href="wrong-link-target">wrong-link-target {{ full_path }} in {{ page.url }}</a>
{% else %}
<a href="{{ post[0] }}">{{ post[1] }} <sup>in English</sup></a><!-- localize sup using i18n - it: in inglese, es: en inglés, nl: in Engels -->
{% endif %}
</div>
</code></pre>
<p>Is it smart and does it make sense at all or do you see any downsides, e.g. performance? I need to check and adjust several thousand links. Can it be implemented better, e.g. using another Jekyll plugin?</p>
<p>I have created a <a href="https://github.com/cadamini/jekyll-show-links-from-source-language" rel="nofollow noreferrer">sample repo</a> with code using conditionals, see <a href="https://github.com/cadamini/jekyll-show-links-from-source-language/blob/main/_includes/link.html" rel="nofollow noreferrer">include file</a> and a <a href="https://github.com/cadamini/jekyll-show-links-from-source-language/blob/main/_docs/_de/getting-started/system-requirements.md" rel="nofollow noreferrer">sample file</a>.</p>
<p>Bonus question: The include returns the element inside a p tag - any idea how to workaround this?</p>
| [
{
"answer_id": 74343569,
"author": "bryson",
"author_id": 20423423,
"author_profile": "https://Stackoverflow.com/users/20423423",
"pm_score": 3,
"selected": true,
"text": "{% if page.lang != 'en' %}\n {% assign path = '_' | append: page.lang | append: '/' | \nappend: include.path %}\n {% assign post = docs | where: 'path', path | first %}\n {% if post %}\n <a href=\"{{ post.url }}\">{{ post.title }}</a>\n {% else %}\n{% assign path = '_' | append: 'en' | append: '/' | append: \ninclude.path %}\n {% assign post = docs | where: 'path', path | first %}\n {% if post %}\n <a href=\"{{ post.url }}\">{{ post.title }}</a>\n {% endif %}\n {% endif %}\n{% endif %}\n"
},
{
"answer_id": 74634245,
"author": "Christian",
"author_id": 3842598,
"author_profile": "https://Stackoverflow.com/users/3842598",
"pm_score": 0,
"selected": false,
"text": "{% custom_link this is a link title | path/to/file.md %}\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323741",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3842598/"
] |
74,323,754 | <p>I am a newbie, please forgive my ignorance. I tried researching and reading other articles and questions, but nothing seems to give a proper answer.</p>
<p>If the answer is simply no, please just tell me.</p>
<p>Basically, I'm working on a project for school, and I want to be able to take someone's input (i.e. their name) and convert that to an integer. For example, If I input Rob, I want the output to show 18+15+2 (R=18, o=15, b=2), or 35. Something along those lines. Or, simply convert Rob to 35 and use that as a comparison in an if-else statement.</p>
<p>If there is more than one command, or set-up involved (such as converting the letters of the alphabet to integers before asking for input from the user) I would appreciate anyone just pointing me in the right direction for more information. I'm very excited to learn, and I understand this may be more complicated than I originally thought.</p>
<p>The only options I've found so far were the "hash" command, which did not give me the results I was looking for. From what I understand, that gives a random number to a word, but I could be misinterpreting the information.</p>
<p>The other thing I tried was the "ord()" command. However, that seems to only convert one letter at a time.</p>
<p>I apologize if this has been answered elsewhere, but I wasn't able to find anything that worked. I greatly appreciate anyone who takes time to try and help!</p>
<p>I am using Spyder (Python 3.9) if that matters.</p>
| [
{
"answer_id": 74323789,
"author": "Ged0jzn4",
"author_id": 17451659,
"author_profile": "https://Stackoverflow.com/users/17451659",
"pm_score": 2,
"selected": false,
"text": "name = input()\nnumber = 0\n\nfor letter in name:\n number += ord(letter) \n"
},
{
"answer_id": 74323802,
"author": "Flow",
"author_id": 14121161,
"author_profile": "https://Stackoverflow.com/users/14121161",
"pm_score": 2,
"selected": false,
"text": "string = \"Rob\"\nord_sum = sum(ord(c) for c in string)\nprint(ord_sum)\n"
},
{
"answer_id": 74324209,
"author": "TCK",
"author_id": 14525084,
"author_profile": "https://Stackoverflow.com/users/14525084",
"pm_score": 2,
"selected": true,
"text": "def Encode(input):\nchars = [\"A\", \"a\", \"B\", \"b\", \"C\", \"c\", \"D\", \"d\", \"E\", \"e\", \"F\", \"f\", \"G\", \"g\", \"H\", \"h\", \"I\", \"i\", \"J\", \"j\", \"K\", \"k\", \"L\", \"l\", \"M\", \"m\", \"N\", \"n\", \"O\", \"o\", \"P\", \"p\", \"Q\", \"q\", \"R\", \"r\", \"S\", \"s\", \"T\", \"t\", \"U\", \"u\", \"V\", \"v\", \"W\", \"w\", \"X\", \"x\", \"Y\", \"y\", \"Z\", \"z\", \" \"]\nIndex = 0\nResult = \"\"\nfor char in input:\n Index = chars.index(char) + 10\n Result = Result + str(Index)\nreturn Result\n\ndef Decode(input):\nchars = [\"A\", \"a\", \"B\", \"b\", \"C\", \"c\", \"D\", \"d\", \"E\", \"e\", \"F\", \"f\", \"G\", \"g\", \"H\", \"h\", \"I\", \"i\", \"J\", \"j\", \"K\", \"k\", \"L\", \"l\", \"M\", \"m\", \"N\", \"n\", \"O\", \"o\", \"P\", \"p\", \"Q\", \"q\", \"R\", \"r\", \"S\", \"s\", \"T\", \"t\", \"U\", \"u\", \"V\", \"v\", \"W\", \"w\", \"X\", \"x\", \"Y\", \"y\", \"Z\", \"z\", \" \"]\nIndex = 0\nIndex2 = \"0\"\nCheck1 = 0\nCheck2 = 1\nResult = \"\"\nfor char in input:\n try:\n Index2 = str(input[Check1]) + str(input[Check2])\n Index = int(Index2)\n Result = Result + chars[Index - 10]\n Check1 = Check1 + 2\n Check2 = Check2 + 2\n except:\n break\nreturn Result\n\nprint(Encode(\"test\"))\nprint(Decode(\"49194749\"))\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323754",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20361158/"
] |
74,323,757 | <p>I'm trying to loop over the lines in an output file I created that looks like this:</p>
<pre><code>2020-03-19, 22.0
2020-03-20, 6.0
2020-03-21, 5.0
</code></pre>
<p>And then create and print a list with the numbers in the 2nd column.</p>
<p>This is just my main and the function I'm having trouble with:</p>
<pre><code>def main():
for file in FILE_PATH_INPUT:
fWriteOutputFile(file)
print(fReadOutputFile(FILE_PATH_OUTPUT))
```
def fReadInputFile(pFile):
casesList = []
with open(pFile, 'r') as fi:
lines = fi.readlines()
for line in lines:
line = line.rstrip().split(',')
casesList.append(str(line[1]))
return casesList
```
**What I'm expecting:
[66, 6, 5]
what I'm getting:
casesList.append(str(line[1]))
IndexError: list index out of range**
</code></pre>
| [
{
"answer_id": 74323789,
"author": "Ged0jzn4",
"author_id": 17451659,
"author_profile": "https://Stackoverflow.com/users/17451659",
"pm_score": 2,
"selected": false,
"text": "name = input()\nnumber = 0\n\nfor letter in name:\n number += ord(letter) \n"
},
{
"answer_id": 74323802,
"author": "Flow",
"author_id": 14121161,
"author_profile": "https://Stackoverflow.com/users/14121161",
"pm_score": 2,
"selected": false,
"text": "string = \"Rob\"\nord_sum = sum(ord(c) for c in string)\nprint(ord_sum)\n"
},
{
"answer_id": 74324209,
"author": "TCK",
"author_id": 14525084,
"author_profile": "https://Stackoverflow.com/users/14525084",
"pm_score": 2,
"selected": true,
"text": "def Encode(input):\nchars = [\"A\", \"a\", \"B\", \"b\", \"C\", \"c\", \"D\", \"d\", \"E\", \"e\", \"F\", \"f\", \"G\", \"g\", \"H\", \"h\", \"I\", \"i\", \"J\", \"j\", \"K\", \"k\", \"L\", \"l\", \"M\", \"m\", \"N\", \"n\", \"O\", \"o\", \"P\", \"p\", \"Q\", \"q\", \"R\", \"r\", \"S\", \"s\", \"T\", \"t\", \"U\", \"u\", \"V\", \"v\", \"W\", \"w\", \"X\", \"x\", \"Y\", \"y\", \"Z\", \"z\", \" \"]\nIndex = 0\nResult = \"\"\nfor char in input:\n Index = chars.index(char) + 10\n Result = Result + str(Index)\nreturn Result\n\ndef Decode(input):\nchars = [\"A\", \"a\", \"B\", \"b\", \"C\", \"c\", \"D\", \"d\", \"E\", \"e\", \"F\", \"f\", \"G\", \"g\", \"H\", \"h\", \"I\", \"i\", \"J\", \"j\", \"K\", \"k\", \"L\", \"l\", \"M\", \"m\", \"N\", \"n\", \"O\", \"o\", \"P\", \"p\", \"Q\", \"q\", \"R\", \"r\", \"S\", \"s\", \"T\", \"t\", \"U\", \"u\", \"V\", \"v\", \"W\", \"w\", \"X\", \"x\", \"Y\", \"y\", \"Z\", \"z\", \" \"]\nIndex = 0\nIndex2 = \"0\"\nCheck1 = 0\nCheck2 = 1\nResult = \"\"\nfor char in input:\n try:\n Index2 = str(input[Check1]) + str(input[Check2])\n Index = int(Index2)\n Result = Result + chars[Index - 10]\n Check1 = Check1 + 2\n Check2 = Check2 + 2\n except:\n break\nreturn Result\n\nprint(Encode(\"test\"))\nprint(Decode(\"49194749\"))\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323757",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20413745/"
] |
74,323,763 | <p>I'm trying to make a simple few lines to print prime numbers between 1000 - 10,000</p>
<p>Shouldn't this code work? I'm taking i and dividing by 2 and saying if it does not equal remainder 0 then print the number as it would be prime.</p>
<pre><code>for i in range(1000, 10000):
if (i % 2) != 0:
print(i)
</code></pre>
| [
{
"answer_id": 74323770,
"author": "PCDSandwichMan",
"author_id": 12007307,
"author_profile": "https://Stackoverflow.com/users/12007307",
"pm_score": -1,
"selected": false,
"text": "for i in range(1000, 10000):\n for j in range(2, i):\n if i % j == 0:\n break\n else:\n print(i)\n"
},
{
"answer_id": 74323786,
"author": "Chris",
"author_id": 15261315,
"author_profile": "https://Stackoverflow.com/users/15261315",
"pm_score": 0,
"selected": false,
"text": "is_prime"
},
{
"answer_id": 74323834,
"author": "Mayo",
"author_id": 20311062,
"author_profile": "https://Stackoverflow.com/users/20311062",
"pm_score": 0,
"selected": false,
"text": "for i in range(1000, 10000):\n if pow(2, i - 1, i) == 1:\n print(i)\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323763",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18415626/"
] |
74,323,769 | <p>I am relatively new to typescript and trying to diagnose an error. I'm making sidebar navigation and trying to pull an icon from my navigation array.</p>
<p>Array:</p>
<pre><code> const menuItems = [
{ id: 1, label: "Dashboard", icon: <ComputerDesktopIcon />, link: "/" },
{ id: 2, label: "Page 2", icon: <AcademicCapIcon />, link: "" },
{ id: 3, label: "Settings", icon: <Cog6ToothIcon />, link: "/" },
];
</code></pre>
<p>In my code, the error is stemming from this section:</p>
<pre><code><div className="flex flex-col items-start mt-24">
{menuItems.map(({ icon: Icon, ...menu }) => {
const classes = getNavItemClasses(menu);
return <div className={classes}>
<Link href={menu.link}>
<div className="flex py-2 px-3 items-center w-full h-full">
<div>
<Icon />
</div>
{!toggleCollapse && (
<span className={classNames('text-md font-medium text-dark-gray')}>
{menu.label}
</span>
)}
</div>
</Link>
</div>
})}
</div>
</code></pre>
<p>Specifically the <code><Icon /></code> call is throwing the error: <code>JSX element type 'Icon' does not have any construct or call signatures</code>.</p>
<p>Worth noting everything works perfectly when that line is commented out.</p>
<p>I've worked through building <code>props</code> components and other Stack Overflow issues, but where I'm getting caught is in the <code>menuItems.map</code> section... most tutorials only define creating + implementing single <code>const</code> items.</p>
| [
{
"answer_id": 74323770,
"author": "PCDSandwichMan",
"author_id": 12007307,
"author_profile": "https://Stackoverflow.com/users/12007307",
"pm_score": -1,
"selected": false,
"text": "for i in range(1000, 10000):\n for j in range(2, i):\n if i % j == 0:\n break\n else:\n print(i)\n"
},
{
"answer_id": 74323786,
"author": "Chris",
"author_id": 15261315,
"author_profile": "https://Stackoverflow.com/users/15261315",
"pm_score": 0,
"selected": false,
"text": "is_prime"
},
{
"answer_id": 74323834,
"author": "Mayo",
"author_id": 20311062,
"author_profile": "https://Stackoverflow.com/users/20311062",
"pm_score": 0,
"selected": false,
"text": "for i in range(1000, 10000):\n if pow(2, i - 1, i) == 1:\n print(i)\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323769",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18377714/"
] |
74,323,772 | <p>I am trying to create a list of new objects in python (as in separate memory locations, not references)</p>
<pre><code>class example:
_name = ""
_words = []
def __init__(self,name):
_name = name
def add_words(self,new_words):
for i in new_words:
self._words.append(i)
examples = [example("example_1"),example("example_2"),example("example_3")]
examples[0].add_words(["test1","test2"])
print(examples[2]._words)
</code></pre>
<p><code>print(examples[2]._words)</code> outputs <code>["test1","test2"]</code>
I expected <code>[]</code> as I only added words to <code>examples[0]</code></p>
| [
{
"answer_id": 74323798,
"author": "Carcigenicate",
"author_id": 3000206,
"author_profile": "https://Stackoverflow.com/users/3000206",
"pm_score": 2,
"selected": true,
"text": "_words = []"
},
{
"answer_id": 74323803,
"author": "PCDSandwichMan",
"author_id": 12007307,
"author_profile": "https://Stackoverflow.com/users/12007307",
"pm_score": 0,
"selected": false,
"text": "class example:\n def __init__(self, name):\n self._words = []\n self._name = name\n\n def add_words(self, new_words):\n for i in new_words:\n self._words.append(i)\n\n\nexamples = [example(\"example_1\"), example(\"example_2\"), example(\"example_3\")]\nexamples[0].add_words([\"test1\", \"test2\"])\n\nprint(examples[2]._words)\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323772",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14469316/"
] |
74,323,773 | <p>I have a class Person that contains names and hobbies. Then there's a list that contains people.</p>
<ul>
<li>person1 = Person("MarySmith", ["dancing", "biking", "cooking"])</li>
<li>person2 = ...</li>
<li><strong>people = [person1, person2,..]</strong></li>
</ul>
<p>I need to return a list of people sorted alphabetically by their name, and also sort their list of hobbies alphabetically.</p>
<p>This is what I have so far:</p>
<pre><code>def sort_people_and_hobbies(people: list) -> list:
result = []
for p in people:
result.append(p)
return sorted(result, key=lambda x: x.names)
</code></pre>
<p>This is what I'm expecting to get:</p>
<pre><code>print(sort_people_and_hobbies(people)) # -> [KateBrown, MarySmith,..]
print(person1.hobbies) # -> ['biking', 'cooking', 'dancing']
</code></pre>
<p>I don't get how to implement sorting for hobbies into this. No matter what I do I get an unsorted list of hobbies.</p>
| [
{
"answer_id": 74323835,
"author": "Rahul K P",
"author_id": 4407666,
"author_profile": "https://Stackoverflow.com/users/4407666",
"pm_score": 1,
"selected": false,
"text": "class Person:\n def __init__(self, name, hobbies):\n self.name = name\n self.hobbies = sorted(hobbies)\n\ndef sort_people(people: list) -> list:\n name_list = [p.name for p in people]\n return sorted(name_list)\n\np1 = Person(\"MarySmith\", [\"dancing\", \"biking\", \"cooking\"])\np2 = Person(\"John\", [\"dancing\", \"reading\"])\np3 = Person(\"KateBrown\", [\"football\", \"cooking\"])\n"
},
{
"answer_id": 74323846,
"author": "davidlowryduda",
"author_id": 1141805,
"author_profile": "https://Stackoverflow.com/users/1141805",
"pm_score": 1,
"selected": true,
"text": "Person"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323773",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20421646/"
] |
74,323,826 | <p>After running 'npm update' on my app, I am suddenly getting the following error:</p>
<pre><code>Compiled with problems:
ERROR in ./node_modules/pako/lib/zlib/trees.js 257:106
Module parse failed: Unexpected token (257:106)
File was processed with these loaders:
* ./node_modules/babel-loader/lib/index.js
You may need an additional loader to handle the result of these loaders.
| * not null.
| */
> function gen_bitlen(s, desc) /* deflate_state *s;*/ /* tree_desc *desc; /* the tree descriptor */*/{
| var tree = desc.dyn_tree;
| var max_code = desc.max_code;
</code></pre>
<p>Strange. So I compared it to the same app running on a different workstation with the same code, but where I did <strong>not</strong> run 'npm update'. The app works, no surprise.</p>
<p>I've seen other posts with this error, but their solutions do not seem to apply to my environment.</p>
<p>I cannot figure out why it's not working on my main workstation. If I copy over node_modules from the working station, the app starts fine. But as soon as I remove node_modules and package-lock.json and reinstall, the app will not start. I've removed node_modules/package-lock.json/clear npm cache. Doesn't help.</p>
<p>I'm comparing the module versions via 'npm ls', and they are identical on both workstations.</p>
<p>Both are running NodeJS 8.12.0 and npm 8.19.2</p>
<p>I looked at the file that it's erroring out on (pako/lib/zlib/trees.js), and it's identical on both systems.</p>
<p>I have no idea what 'pako' is, but using 'npm explain pako' it appears to have something to do with pdf-lib, which was never updated.</p>
<p>My app was built with create-react-app.</p>
<p>I'm at a complete loss. Here is my <code>package.json</code>:</p>
<pre class="lang-json prettyprint-override"><code>{
"name": "foo",
"version": "0.1.0",
"description": "Foo",
"contributors": [],
"license": "UNLICENSED",
"private": true,
"dependencies": {
"@coreui/chartjs": "^2.0.0",
"@coreui/coreui-pro": "^3.4.2",
"@coreui/icons": "^2.1.0",
"@coreui/icons-pro": "^2.0.3",
"@coreui/icons-react": "^1.1.0",
"@coreui/react": "^3.4.6",
"@coreui/react-chartjs": "^1.1.0",
"@coreui/utils": "^1.3.1",
"@fortawesome/fontawesome-free-solid": "^5.0.13",
"@fortawesome/fontawesome-svg-core": "^6.1.1",
"@fortawesome/free-regular-svg-icons": "^6.1.1",
"@fortawesome/free-solid-svg-icons": "^6.1.1",
"@fortawesome/react-fontawesome": "^0.1.18",
"@nadavshaar/react-grid-table": "^1.0.0",
"@pdf-lib/fontkit": "^1.1.1",
"@react-firebase/auth": "^0.2.10",
"ag-grid-community": "^25.3.0",
"ag-grid-react": "^25.3.0",
"arithmetic": "^1.0.1",
"bootstrap": "^5.2.0",
"classnames": "^2.3.1",
"codemirror": "^5.63.3",
"core-js": "^3.19.1",
"downloadjs": "^1.4.7",
"firebase": "^9.12.1",
"firebase-admin": "^11.0.1",
"firebaseui": "^6.0.1",
"formik": "^2.2.9",
"mobx": "^6.3.3",
"mobx-react": "^7.1.0",
"pdf-lib": "^1.17.1",
"prop-types": "^15.7.2",
"random-id": "^1.0.4",
"react": "^17.0.2",
"react-app-polyfill": "^2.0.0",
"react-awesome-button": "^6.5.1",
"react-big-calendar": "^0.33.6",
"react-bootstrap": "^2.4.0",
"react-collapsible": "^2.10.0",
"react-cookie-consent": "^8.0.1",
"react-dom": "^17.0.2",
"react-firebase-hooks": "^5.0.3",
"react-firebaseui": "^6.0.0",
"react-grid-layout": "^1.3.0",
"react-range": "^1.8.12",
"react-redux": "7.2.4",
"react-router-dom": "^5.3.0",
"react-select": "^4.3.1",
"react-text-mask-hoc": "^0.11.0",
"react-toastify": "^9.0.8",
"reactstrap": "^8.10.0",
"redux": "4.1.0",
"rpg-dice-roller": "1.6.0",
"sass": "^1.55.0",
"sillyname": "^0.1.0",
"spinkit": "2.0.1",
"string-math": "^1.2.2",
"styled-components": "^5.3.3",
"yup": "^0.32.11"
},
"devDependencies": {
"mutationobserver-shim": "^0.3.7",
"react-scripts": "^5.0.0"
},
"scripts": {
"start": "react-scripts start",
"build": "react-scripts build",
"test": "react-scripts test",
"test:cov": "npm test -- --coverage --watchAll=false",
"test:debug": "react-scripts --inspect-brk test --runInBand",
"eject": "react-scripts eject",
"zip": "git archive -o coreui-pro-react-admin-template-v$npm_package_version.zip -9 HEAD"
},
"bugs": {
"url": "https://github.com/coreui/coreui-free-react-admin-template/issues"
},
"eslintConfig": {
"extends": "react-app"
},
"browserslist": [
">0.2%",
"not dead",
"not ie <= 10",
"not op_mini all"
],
"jest": {
"collectCoverageFrom": [
"src/**/*.{js,jsx}",
"!**/*index.js",
"!src/serviceWorker.js",
"!src/polyfill.js"
]
},
"engines": {
"node": ">=8.16",
"npm": ">=6"
}
}
</code></pre>
| [
{
"answer_id": 74327940,
"author": "Attila Szombathelyi",
"author_id": 20425666,
"author_profile": "https://Stackoverflow.com/users/20425666",
"pm_score": 5,
"selected": true,
"text": "package-lock.json"
},
{
"answer_id": 74341435,
"author": "Nick",
"author_id": 7755140,
"author_profile": "https://Stackoverflow.com/users/7755140",
"pm_score": 0,
"selected": false,
"text": "transpileDependecies"
},
{
"answer_id": 74346574,
"author": "Rejo Chandran",
"author_id": 2799454,
"author_profile": "https://Stackoverflow.com/users/2799454",
"pm_score": 2,
"selected": false,
"text": "package.json"
},
{
"answer_id": 74350261,
"author": "Sreenath MP",
"author_id": 10282706,
"author_profile": "https://Stackoverflow.com/users/10282706",
"pm_score": 0,
"selected": false,
"text": "\"overrides\": {\n \"@babel/core\": \"7.19.6\",\n \"@babel/generator\": \"7.19.6\",\n \"@babel/compat-data\": \"7.19.4\",\n \"@babel/helper-compilation-targets\": \"7.19.3\",\n \"@babel/helper-create-class-features-plugin\": \"7.19.0\",\n \"@babel/helper-module-transforms\": \"7.19.6\"\n }\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323826",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2487960/"
] |
74,323,850 | <p>So im making my first Dropdown but when i have a lot of Strings it expands upwards, is there a way to compact the list and make it scrollable or am i using the wrong Widget?</p>
<p><a href="https://i.stack.imgur.com/6Hi9J.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/6Hi9J.png" alt="Closed Dropdown" /></a><a href="https://i.stack.imgur.com/ap9n9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ap9n9.png" alt="Opened Dropdown" /></a></p>
<pre><code>class _DropdownBehaivorButton extends StatefulWidget {
const _DropdownBehaivorButton({super.key});
@override
State<_DropdownBehaivorButton> createState() => _DropdownBehaivorButtonState();
}
class _DropdownBehaivorButtonState extends State<_DropdownBehaivorButton> {
String dropdownvalue = 'Agresivo';
var tipos = [
'Agresivo',
'Tranquilo',
'Travieso',
'Docil',
'Travieso',
'Travieso',
'Travieso'
];
@override
Widget build(BuildContext context) {
return
DropdownButtonHideUnderline(
child: DropdownButton(
borderRadius: BorderRadius.circular(25),
isExpanded: true,
iconEnabledColor: Color(0xff525252),
dropdownColor: Colors.white,
style: _textStyle(),
value: dropdownvalue,
icon: const Icon(Icons.keyboard_arrow_down),
items: tipos.map((String items) {
return DropdownMenuItem(
value: items,
child: Center(child: Text(items)),
);
}).toList(),
onChanged: (String? newValue) {
setState(() {
dropdownvalue = newValue!;
});
},
),
);
}
TextStyle _textStyle() => TextStyle(
fontSize: 18,color: Color.fromARGB(123, 82, 82, 82),fontWeight: FontWeight.w400) ;}
</code></pre>
<p>I was expecting a compact dropdown list like this<a href="https://i.stack.imgur.com/9HRL9.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9HRL9.jpg" alt="Similar results" /></a></p>
| [
{
"answer_id": 74327940,
"author": "Attila Szombathelyi",
"author_id": 20425666,
"author_profile": "https://Stackoverflow.com/users/20425666",
"pm_score": 5,
"selected": true,
"text": "package-lock.json"
},
{
"answer_id": 74341435,
"author": "Nick",
"author_id": 7755140,
"author_profile": "https://Stackoverflow.com/users/7755140",
"pm_score": 0,
"selected": false,
"text": "transpileDependecies"
},
{
"answer_id": 74346574,
"author": "Rejo Chandran",
"author_id": 2799454,
"author_profile": "https://Stackoverflow.com/users/2799454",
"pm_score": 2,
"selected": false,
"text": "package.json"
},
{
"answer_id": 74350261,
"author": "Sreenath MP",
"author_id": 10282706,
"author_profile": "https://Stackoverflow.com/users/10282706",
"pm_score": 0,
"selected": false,
"text": "\"overrides\": {\n \"@babel/core\": \"7.19.6\",\n \"@babel/generator\": \"7.19.6\",\n \"@babel/compat-data\": \"7.19.4\",\n \"@babel/helper-compilation-targets\": \"7.19.3\",\n \"@babel/helper-create-class-features-plugin\": \"7.19.0\",\n \"@babel/helper-module-transforms\": \"7.19.6\"\n }\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323850",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19702304/"
] |
74,323,852 | <p>I was rewriting the code below using OpenMP task to parallilize the Pi program.</p>
<p>Original Code:</p>
<pre><code>#include <omp.h>
#include <stdio.h>
static long num_steps = 1024*1024*1024;
#define MIN_BLK 1024*1024*256
double pi_comp(int Nstart,int Nfinish,double step)
{ int i,iblk;
double x, sum = 0.0,sum1, sum2;
if (Nfinish-Nstart < MIN_BLK){
for (i=Nstart;i< Nfinish; i++){
x = (i+0.5)*step;
sum = sum + 4.0/(1.0+x*x);
}
}
else{
iblk = Nfinish-Nstart;
sum1 = pi_comp(Nstart, Nfinish-iblk/2,step);
sum2 = pi_comp(Nfinish-iblk/2, Nfinish, step);
sum = sum1 + sum2;
}return sum;
}
int main ()
{
int i;
double step, pi, sum;
double init_time, final_time;
step = 1.0/(double) num_steps;
init_time = omp_get_wtime();
sum = pi_comp(0,num_steps,step);
pi = step * sum;
final_time = omp_get_wtime() - init_time;
printf(" for %ld steps pi = %f in %f secs\n",num_steps,pi,final_time);
}
</code></pre>
<p>OpenMP Code:</p>
<pre><code>#include <omp.h>
#include <stdio.h>
static long num_steps = 1024*1024*1024;
#define MIN_BLK 1024*1024*256
double pi_comp(int Nstart,int Nfinish,double step)
{ int i,iblk;
double x, sum = 0.0,sum1, sum2;
if (Nfinish-Nstart < MIN_BLK){
for (i=Nstart;i< Nfinish; i++){
x = (i+0.5)*step;
sum = sum + 4.0/(1.0+x*x);
}
}
else{
iblk = Nfinish-Nstart;
#pragma omp task firstprivate(sum1)
sum1 = pi_comp(Nstart,Nfinish-iblk/2,step);
#pragma omp task firstprivate(sum2)
sum2 = pi_comp(Nfinish-iblk/2, Nfinish,step);
sum = sum1 + sum2;
}return sum;
}
int main ()
{
int i;
double step, pi, sum;
double init_time, final_time;
step = 1.0/(double) num_steps;
init_time = omp_get_wtime();
#pragma omp parallel
{
#pragma omp single
sum = pi_comp(0,num_steps,step);
}
pi = step * sum;
final_time = omp_get_wtime() - init_time;
printf(" for %ld steps pi = %f in %f secs\n",num_steps,pi,final_time);
}
</code></pre>
<p>I dont know why the output for the OpenMP program has pi = 0 instead of pi itself when testing the speed of a certain amount of thread. Is there something I did wrong in the OpenMP code that didn't give me pi?</p>
<p>Output:</p>
<pre><code>g++ -fopenmp -c pi_recur_omp.cpp
g++ -fopenmp -o pi_recur_omp pi_recur_omp.o -lm
./pi_recur
for 1073741824 steps pi = 3.141593 in 4.562793 secs
./pi_recur_omp
for 1073741824 steps pi = 0.000000 in 2.990318 secs
</code></pre>
| [
{
"answer_id": 74327940,
"author": "Attila Szombathelyi",
"author_id": 20425666,
"author_profile": "https://Stackoverflow.com/users/20425666",
"pm_score": 5,
"selected": true,
"text": "package-lock.json"
},
{
"answer_id": 74341435,
"author": "Nick",
"author_id": 7755140,
"author_profile": "https://Stackoverflow.com/users/7755140",
"pm_score": 0,
"selected": false,
"text": "transpileDependecies"
},
{
"answer_id": 74346574,
"author": "Rejo Chandran",
"author_id": 2799454,
"author_profile": "https://Stackoverflow.com/users/2799454",
"pm_score": 2,
"selected": false,
"text": "package.json"
},
{
"answer_id": 74350261,
"author": "Sreenath MP",
"author_id": 10282706,
"author_profile": "https://Stackoverflow.com/users/10282706",
"pm_score": 0,
"selected": false,
"text": "\"overrides\": {\n \"@babel/core\": \"7.19.6\",\n \"@babel/generator\": \"7.19.6\",\n \"@babel/compat-data\": \"7.19.4\",\n \"@babel/helper-compilation-targets\": \"7.19.3\",\n \"@babel/helper-create-class-features-plugin\": \"7.19.0\",\n \"@babel/helper-module-transforms\": \"7.19.6\"\n }\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323852",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20305654/"
] |
74,323,853 | <p>I am trying run the following two command in one command.</p>
<pre><code>eval "$(ssh-agent)"
ssh add ~/.ssh/id_rsa
</code></pre>
<p>I tried with many possible solutions:</p>
<pre><code>su username -c "{ eval $(ssh-agent -s) }; ssh-add ~/.ssh/id_rsa"
su username -c "eval $(ssh-agent -s)" ; ssh-add ~/.ssh/id_rsa
su username -c "eval $(ssh-agent -s)" && ssh-add ~/.ssh/id_rsa
su username -c "eval $(ssh-agent -s)" && "ssh-add ~/.ssh/id_rsa"
</code></pre>
<p>It seems like the first command run successfully but the second either response with Permission denied message (means it run with the current user) or cannot connect to the authentication agent (means it probably created a new session for the second command).</p>
<p>Error messages:</p>
<pre><code>Could not open a connection to your authentication agent.
</code></pre>
<pre><code>Error connecting to agent: Permission denied
</code></pre>
<p>If I run them separately in order, it works:///</p>
<p>The purpose is to create a bash script with these commands with variables, something like this:</p>
<pre><code>folder=/home/q12
username=q12
su $username -c "{ eval $(ssh-agent -s) }; ssh-add $folder/.ssh/id_rsa"
</code></pre>
<p>Because of the variables I can not quote the whole command because it will be sensitive to ";" and "&&".</p>
<p>Can anyone help me with this?
Thank you!</p>
| [
{
"answer_id": 74324137,
"author": "dan",
"author_id": 13919668,
"author_profile": "https://Stackoverflow.com/users/13919668",
"pm_score": 2,
"selected": true,
"text": "su username -c 'eval \"$(ssh-agent -s)\"; ssh-add ~/.ssh/id_rsa'\n"
},
{
"answer_id": 74324266,
"author": "Gordon Davisson",
"author_id": 89817,
"author_profile": "https://Stackoverflow.com/users/89817",
"pm_score": 0,
"selected": false,
"text": "$(ssh-agent -s)"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323853",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20421724/"
] |
74,323,856 | <pre class="lang-c prettyprint-override"><code>StackMeta_t *mystack_create(size_t objsize)
{
StackMeta_t *elem;
elem = (StackMeta_t*)malloc(sizeof(StackMeta_t));
if(elem == NULL)
{
return NULL;
}
else
{
elem->stack = NULL; // my actual stack basically the first elem(the top)
elem->objsize = objsize; // size of the datatype
elem->numelem = 0; // total count of elem inside the stack
}
return elem;
}
//PUSH
int mystack_push(StackMeta_t *data_stack, void* obj)
{
if(data_stack == NULL)
{
return -1;
}
StackObject_t *nodeObject = NULL;
nodeObject = (StackObject_t*)malloc(sizeof(StackObject_t));
if(nodeObject == NULL)
{
return -1;
}
nodeObject->obj = malloc(data_stack->objsize);
if(data_stack->stack == NULL)
{
nodeObject->next = NULL;
}
else
{
nodeObject->next = data_stack->stack;
}
memcpy(nodeObject->obj, obj, data_stack->objsize);
data_stack->stack = nodeObject;
data_stack->numelem++;
return 0;
}
</code></pre>
<p>So I am trying to translate my C code into C++ code. These are Linked List and Stacks data structure</p>
<p>I researched that the malloc() version of C++ is the <code>new</code> keyword. So creating memory for the
linked list <code>nodeObject</code>, I did <code>StackObject_t *nodeObject = new StackObject_t;</code>.</p>
<p>But the problem I encountered is creating memory for the <code>obj</code> of the Linked List. The data type for this variable is <code>void* obj;</code>. So that would be using a pointer to the <code>objsize</code> created with by the <code>mystack_create(size_t objsize)</code> function.</p>
<p>My question is, how do I convert <code>nodeObject->obj = malloc(data_stack->objsize);</code> to C++ while using the <code>new</code> keyword?</p>
<p>I tried doing <code>nodeObject->obj = new data_stack->objsize;</code> and the error gives me <code>expected a type specifier</code>. Do I need to cast <code>data_stack->objsize</code>? and what is the syntax for this for future reference? I have been coding with C for almost a year now and I know a few OOP from C#. Now I am just beginning to learn C++ and I couldn't find any answer for this type of situation.</p>
| [
{
"answer_id": 74324137,
"author": "dan",
"author_id": 13919668,
"author_profile": "https://Stackoverflow.com/users/13919668",
"pm_score": 2,
"selected": true,
"text": "su username -c 'eval \"$(ssh-agent -s)\"; ssh-add ~/.ssh/id_rsa'\n"
},
{
"answer_id": 74324266,
"author": "Gordon Davisson",
"author_id": 89817,
"author_profile": "https://Stackoverflow.com/users/89817",
"pm_score": 0,
"selected": false,
"text": "$(ssh-agent -s)"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323856",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19006940/"
] |
74,323,868 | <p><strong>routes.rb</strong></p>
<pre><code> namespace :scheduling do
resources :scheduling_details, only: [:create, :destroy, :update, :index]
do
</code></pre>
<p><strong>rake routes</strong></p>
<pre><code>scheduling_scheduling_detail
PATCH /scheduling/scheduling_details/:id(.:format)
scheduling/scheduling_details#update
PUT /scheduling/scheduling_details/:id(.:format)
scheduling/scheduling_details#update
</code></pre>
<p><strong>view</strong></p>
<pre><code><%= link_to "Yes", scheduling_scheduling_detail_path(@scheduling_detail) %>
</code></pre>
<p><strong>Error</strong>. No route matches [GET] "/scheduling/scheduling_details/6256"</p>
<p>Notice the plural there. I'm not sure why it's trying to access the plural url when I didn't use the plural path shortcut.</p>
<p>So I try to use the manual url instead of the path shortcut</p>
<pre><code><%= link_to "Yes", "/scheduling/scheduling_detail/#{@scheduling_detail}" %>
</code></pre>
<p><strong>Error:</strong> No route matches [GET] "/scheduling/scheduling_detail"</p>
<p>Maybe try with the id?</p>
<pre><code><%= link_to "Yes", "/scheduling/scheduling_detail/#{@scheduling_detail.id}" %>
</code></pre>
<p><strong>Error:</strong> No route matches [GET] "/scheduling/scheduling_detail/6256"</p>
| [
{
"answer_id": 74324137,
"author": "dan",
"author_id": 13919668,
"author_profile": "https://Stackoverflow.com/users/13919668",
"pm_score": 2,
"selected": true,
"text": "su username -c 'eval \"$(ssh-agent -s)\"; ssh-add ~/.ssh/id_rsa'\n"
},
{
"answer_id": 74324266,
"author": "Gordon Davisson",
"author_id": 89817,
"author_profile": "https://Stackoverflow.com/users/89817",
"pm_score": 0,
"selected": false,
"text": "$(ssh-agent -s)"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323868",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3842322/"
] |
74,323,872 | <pre><code>test = {"poop":{"okay":[10]}}
print(test)
</code></pre>
<p>For example, I want the 10 within["okay"], to now be 20.</p>
| [
{
"answer_id": 74323890,
"author": "PCDSandwichMan",
"author_id": 12007307,
"author_profile": "https://Stackoverflow.com/users/12007307",
"pm_score": 0,
"selected": false,
"text": "# To update the value in the list\ntest[\"poop\"][\"okay\"][0] = 20\n\n# Replaces the list altogether\ntest[\"poop\"][\"okay\"] = 20\n"
},
{
"answer_id": 74323893,
"author": "Cameron Riddell",
"author_id": 14278448,
"author_profile": "https://Stackoverflow.com/users/14278448",
"pm_score": 3,
"selected": true,
"text": "10"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323872",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/14833560/"
] |
74,323,874 | <p>relatively new to using Python and the dict structure.
I have imported a CSV file from online and turned it to a dictionary. I use the first row as the Key, and then any other subsequent rows are used as the value.</p>
<p>So for example
<a href="https://i.stack.imgur.com/1Sq9j.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/1Sq9j.png" alt="enter image description here" /></a></p>
<p>becomes</p>
<p>Date {0: '04-Nov-22', 1: '05-Nov-22'}</p>
<p>USD {0: 0.9872, 1: 2.9872}</p>
<p>JPY {0: 145.19, 1: 11115.19}</p>
<p>I am curious as to why when I do for example:
<code>print('0.9872' in df.values())</code> that returns me a false, since its clearly there. This is probably fairly trivial, but in the end what I want to do is:</p>
<p>The user inputs a date in the above format, and this date will determine which values will be used later on in my program. So if a user enters 04-Nov-22, I need to record the fact that this is the 0th value in the key:value pair, so from now on only use other 0th values, i.e 0.9872 and 145.19.
Anyway sorry for rambling, so all I want to get out of this is:
<code> data_input = input("Enter the data in DD-MM-YY format please: ")</code></p>
<p><code>print(data_input in df.values())</code> -< for this to not be False</p>
| [
{
"answer_id": 74324022,
"author": "TCK",
"author_id": 14525084,
"author_profile": "https://Stackoverflow.com/users/14525084",
"pm_score": 2,
"selected": false,
"text": "print(0.9872 in df.values())\n"
},
{
"answer_id": 74324057,
"author": "user19077881",
"author_id": 19077881,
"author_profile": "https://Stackoverflow.com/users/19077881",
"pm_score": 0,
"selected": false,
"text": "import pandas as pd\n\ndf = pd.DataFrame.from_dict({'Date': ['04-Nov-22', '05-Nov-22'], 'USD': [0.9872, 2.9872], 'JPY': [145.19, 11115.19]})\ndf = df.set_index('Date')\n"
},
{
"answer_id": 74324098,
"author": "user3435121",
"author_id": 3435121,
"author_profile": "https://Stackoverflow.com/users/3435121",
"pm_score": 0,
"selected": false,
"text": "df = {\"04-Nov-22\": (0.9872, 145.19),\n \"05-Nov-22\": (2.9872, 11115.19),\n }\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323874",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20208266/"
] |
74,323,883 | <p>I have a webapi where iam using repository pattern, in the service layer i have to acess the response.cookies and append few values to it and so far iam unable to figure out how to do it , it looks like the response is accessible only within the controller,can someone please teach me how to do it in service layer? i have attached the code i have so far below</p>
<pre><code> private Cart CreateCart()
{
string buyerId = Guid.NewGuid().ToString();
CookieOptions cookieOptions = new CookieOptions {
IsEssential = true,
Expires = DateTime.Now.AddDays(30)
};
//unable to do this in service layer
Response.Cookies.Append("buyerId",buyerId,cookieOptions);
//
Cart cart = new Cart { BuyerId = buyerId };
context.Add(cart);
return cart;
}
</code></pre>
| [
{
"answer_id": 74324022,
"author": "TCK",
"author_id": 14525084,
"author_profile": "https://Stackoverflow.com/users/14525084",
"pm_score": 2,
"selected": false,
"text": "print(0.9872 in df.values())\n"
},
{
"answer_id": 74324057,
"author": "user19077881",
"author_id": 19077881,
"author_profile": "https://Stackoverflow.com/users/19077881",
"pm_score": 0,
"selected": false,
"text": "import pandas as pd\n\ndf = pd.DataFrame.from_dict({'Date': ['04-Nov-22', '05-Nov-22'], 'USD': [0.9872, 2.9872], 'JPY': [145.19, 11115.19]})\ndf = df.set_index('Date')\n"
},
{
"answer_id": 74324098,
"author": "user3435121",
"author_id": 3435121,
"author_profile": "https://Stackoverflow.com/users/3435121",
"pm_score": 0,
"selected": false,
"text": "df = {\"04-Nov-22\": (0.9872, 145.19),\n \"05-Nov-22\": (2.9872, 11115.19),\n }\n"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323883",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/15556897/"
] |
74,323,902 | <p>I have this code and I want to count the days between 2 dates.</p>
<pre><code>from datetime import date, datetime
checkin= datetime(2022, 1, 30, 1, 15, 00)
checkout= datetime(2022, 1, 31, 0, 0, 00)
count_days= (checkout - checkin).days
</code></pre>
<p>In this case, the result of count_days result is 0, because in an operation with 2 datetimes, it takes into account hours, minutes and seconds.</p>
<p>I want the result to be 1 because is +1 day of difference. Type of variables <strong>must</strong> be datetimes. Thanks!</p>
| [
{
"answer_id": 74323920,
"author": "PCDSandwichMan",
"author_id": 12007307,
"author_profile": "https://Stackoverflow.com/users/12007307",
"pm_score": 0,
"selected": false,
"text": "from datetime import date, datetime\n\ncheck_in= datetime(2022, 1, 30, 1, 15, 00)\ncheck_out= datetime(2022, 1, 31, 0, 0, 00)\n\n# Number of days between two dates (min 1 day)\ndays = (check_out - check_in).days + 1\n\nprint(days)\n"
},
{
"answer_id": 74323929,
"author": "LeopardShark",
"author_id": 8425824,
"author_profile": "https://Stackoverflow.com/users/8425824",
"pm_score": 2,
"selected": true,
"text": "date"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323902",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19883757/"
] |
74,323,919 | <p>how can i redirect correctly to routes ?</p>
<p>My application has to have some route security and I try to do it with GoRouter
but it always executes one more redirection and always returns to home.</p>
<p>There are only 3 secure routes (profile, order, favorites) and if you are not logged in you must go back to login.</p>
<p>But when I put any of the 3 routes in the url, it redirects me to the login and immediately to the home (this is what should not happen)</p>
<p>Can somebody help me?
I changed the logic several times but I always come back to the same point.</p>
<pre><code>class AppRouter {
final SessionCubit sessionCubit;
GoRouter get router => _goRouter;
AppRouter(this.sessionCubit);
late final GoRouter _goRouter = GoRouter(
refreshListenable: GoRouterRefreshStream(sessionCubit.stream),
initialLocation: APP_PAGE.home.toPath,
routes: <GoRoute>[
GoRoute(
path: APP_PAGE.home.toPath,
name: APP_PAGE.home.toName,
builder: (context, state) => MyHomePage(),
),
GoRoute(
path: APP_PAGE.login.toPath,
name: APP_PAGE.login.toName,
builder: (context, state) => const LoginPage(),
),
GoRoute(
path: APP_PAGE.profile.toPath,
name: APP_PAGE.profile.toName,
builder: (context, state) => MyProfile(),
),
GoRoute(
path: APP_PAGE.page1.toPath,
name: APP_PAGE.page1.toName,
builder: (context, state) => const Page1(),
),
GoRoute(
path: APP_PAGE.error.toPath,
name: APP_PAGE.error.toName,
builder: (context, state) => ErrorPage(error: state.extra.toString()),
),
GoRoute(
path: APP_PAGE.page2.toPath,
name: APP_PAGE.page2.toName,
builder: (context, state) => const Page2(),
),
],
debugLogDiagnostics: true,
errorBuilder: (context, state) => ErrorPage(error: state.error.toString()),
redirect: (context, state) {
final userAutheticated = sessionCubit.state is Authenticated;
if (userAutheticated) {
if (state.subloc == '/login') return '/home';
if (state.subloc == '/profile') return '/profile';
if (state.subloc.contains('/page1')) return '/page1';
return '/home';
} else {
if (state.subloc == '/home') {
return '/home';
}
if (state.subloc == '/page2') {
return '/page2';
} else {
return '/login';
}
}
},
);
}
</code></pre>
<p><em><strong>UPDATE 05/11</strong></em>
I find the solution.</p>
<p><strong>First</strong> -> use the last version of go_router 5.1.5 (the redirect issue is on the older versions).</p>
<p><strong>Second</strong> -> I modify the redirect logic:</p>
<pre><code>if(!userAutheticated && !onloginPage && !onpublicPage1 && !onPublicPage2 && !onPublicPageN){
return '/login';
}
if (userAutheticated && onloginPage) {
return '/home';
}
//you must include this. so if condition not meet, there is no redirect
return null;
</code></pre>
<p>Note: I don't know why flutter web debug mode doesn't work properly. So I run the project on release mode and Voilá, it's works!.</p>
<p>Thanks So Much for the help!!!</p>
| [
{
"answer_id": 74323920,
"author": "PCDSandwichMan",
"author_id": 12007307,
"author_profile": "https://Stackoverflow.com/users/12007307",
"pm_score": 0,
"selected": false,
"text": "from datetime import date, datetime\n\ncheck_in= datetime(2022, 1, 30, 1, 15, 00)\ncheck_out= datetime(2022, 1, 31, 0, 0, 00)\n\n# Number of days between two dates (min 1 day)\ndays = (check_out - check_in).days + 1\n\nprint(days)\n"
},
{
"answer_id": 74323929,
"author": "LeopardShark",
"author_id": 8425824,
"author_profile": "https://Stackoverflow.com/users/8425824",
"pm_score": 2,
"selected": true,
"text": "date"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323919",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16797746/"
] |
74,323,925 | <p>Is there any less time consuming method of creating a program that can take all of my given parameters and regardless of what they are simply fill in for those values? For example given optional 4 parameters that I want to fill will I have to write a constructor for each possible combination?</p>
<p>I'm new to Java but I've already written one class where I did this, and it took me quite some time and was a somewhat monotonous, I was just wondering if there was a faster method of doing it.</p>
| [
{
"answer_id": 74324167,
"author": "hfontanez",
"author_id": 2851311,
"author_profile": "https://Stackoverflow.com/users/2851311",
"pm_score": 2,
"selected": false,
"text": "builder.setOptionalParm1(val1).setOptionalParm2(val2)..."
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323925",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20421822/"
] |
74,323,958 | <p>A customer added data into a text area and separated line items by pressing enter and put each item on a separate line. In the XML file, each item is on a separate line, but when I render the page, the text all comes together on one line. Is there a way to take each separate line and add it to a list, then make the following:</p>
<pre><code> Example
<description>
Panel Style: Full-View
R-Value: None
Sectional Material: Heavy Duty/Aluminum
Insulation Type: No Insulation
Color Options: Aluminum, White, Bronze, Black
</description>
Would become:
<description>
<ul>
<li>Panel Style: Full-View</li>
<li>R-Value: None</li>
<li>Sectional Material: Heavy Duty/Aluminum</li>
<li>Insulation Type: No Insulation</li>
<li>Color Options: Aluminum, White, Bronze, Black</li>
</ul>
</description>
</code></pre>
| [
{
"answer_id": 74324167,
"author": "hfontanez",
"author_id": 2851311,
"author_profile": "https://Stackoverflow.com/users/2851311",
"pm_score": 2,
"selected": false,
"text": "builder.setOptionalParm1(val1).setOptionalParm2(val2)..."
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323958",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/9115288/"
] |
74,323,971 | <p>I am trying to make a personal page with the name and other info and when you click EDIT PROFILE button it will take you to another page to edit the information.</p>
<p>On the EDIT Profile page I have the information on the input form that you can input new info. I want it to reflect the change only when I click the SAVE button. If I don't click the SAVE button and just click X button instead, it's not supposed to change when I go back the Profile page.</p>
<p>I am not sure what I did wrong but right now, it changes whether I clicked the SAVE button or not. Can someone please help me figure out what I did wrong? I've been at this for hours and I still can't figure out where I went wrong.</p>
<p>Below are my code:</p>
<p>profile-reducers.js</p>
<pre><code>const profileReducer = (state = profile, action) => {
switch (action.type) {
case 'edit-profile':
state[0].name = action.name;
return state;
default:
return state;
}
}
export default profileReducer;
</code></pre>
<p>edit-profile.js</p>
<pre><code>const EditProfileItem = () => {
let profile = useSelector(state => state.profile[0]);
const [name, setname] = useState(profile.name);
const dispatch = useDispatch();
const editProfileClickHandler = () => {
dispatch({
type: 'edit-profile',
name: name,
});
}
return (
<>
<div className = 'row p-2'>
<div className = 'float-start col-1'>
<Link to='/tuiter/profile'>
<i className = 'fas fa-times icon' style={{color:'black'}}/>
</Link>
</div>
<div className='col-5 text-black fw-bold'>
Edit Profile
</div>
<div className = 'col-6'>
<Link
className='btn rounded-pill bg-black float-end text-white fw-bold'
to='/tuiter/profile'
onClick={editProfileClickHandler()}
> Save
</Link>
</div>
</div>
<div className = 'pt-3'>
<ul className='list-group'>
<li className='list-group-item'>
<label className='text-secondary'>Name</label>
<input
className='form-control border-0 p-0'
defaultValue={profile.name}
onChange={(event) => setname(event.target.value)}/>
</li>
</ul>
</div>
</>
};
export default EditProfileItem;
</code></pre>
| [
{
"answer_id": 74324076,
"author": "Drew Reese",
"author_id": 8690857,
"author_profile": "https://Stackoverflow.com/users/8690857",
"pm_score": 2,
"selected": false,
"text": "EditProfileItem"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323971",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18198092/"
] |
74,323,985 | <p>I have the following code which, when given a number n, calculates the nth Fibonacci number.</p>
<pre><code>pub fn fibonacci(n: i64) -> i64 {
fib_iter(1, 0, 0, 1, n)
}
fn fib_iter(a: i64, b: i64, p: i64, q: i64, count: i64) -> i64 {
if count == 0 {
return b;
}
if is_even(count) {
return fib_iter(a, b, p*p + q*q, 2*p*q + q*q, count / 2);
}
fib_iter(b*q + a*q + a*p, b*p + a*q, p, q, count - 1)
}
</code></pre>
<p>The problem is it only works for i64 while I would like it to be generic, so it works for any integral type.</p>
<p>I tried using the Integer trait from the num crate to make it generic:</p>
<pre><code>pub fn fibonacci<T: Integer>(n: T) -> T {
fib_iter(1, 0, 0, 1, n)
}
fn fib_iter<T: Integer>(a: T, b: T, p: T, q: T, count: T) -> T {
if count.is_zero() {
return b;
}
if count.is_even() {
return fib_iter(a, b, p*p + q*q, 2*p*q + q*q, count / 2);
}
fib_iter(b*q + a*q + a*p, b*p + a*q, p, q, count - 1)
}
</code></pre>
<p>But it doesn't like the use of any integer literals, for example:</p>
<pre><code>
66 | return fib_iter(a, b, p*p + q*q, 2*p*q + q*q, count / 2);
| ^ no implementation for `{integer} * T`
...
69 | fib_iter(b*q + a*q + a*p, b*p + a*q, p, q, count - 1)
| ^ expected type parameter `T`, found integer
</code></pre>
<p>I also tried doing something like the following:</p>
<pre><code>let two: T = 2;
</code></pre>
<p>But same problem.
And same if I try using traits Mul, Div, Add, Sub etc.</p>
| [
{
"answer_id": 74325003,
"author": "Ahmed Masud",
"author_id": 894328,
"author_profile": "https://Stackoverflow.com/users/894328",
"pm_score": 0,
"selected": false,
"text": "num_traits"
},
{
"answer_id": 74326344,
"author": "Jmb",
"author_id": 5397009,
"author_profile": "https://Stackoverflow.com/users/5397009",
"pm_score": 1,
"selected": false,
"text": "T::one()"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74323985",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16498809/"
] |
74,324,023 | <p>I am having difficulty writing tests for this 3rd party library I am importing. I think this is because I want my <code>CustomClient</code> struct to have a <code>client</code> interface instead of the <code>*banker.Client</code>. This is making testing very difficult because it's hard to mock a <code>*banker.Client</code>. Any ideas how I can correctly turn this into an interface? So I can easily write mock tests against it and set up a fake client?</p>
<pre><code>type CustomClient struct {
client *banker.Client //I want to change this to an interface
name string
address string
}
func (c *CustomClient) SetHttpClient(httpClient *banker.Client) { //I want to accept an interface so I can easily mock this.
c.client = httpClient
}
</code></pre>
<p>The problem is that banker.Client is a third party client I am importing with many structs and other fields inside of it. It looks like this:</p>
<pre><code>type Client struct {
*restclient.Client
Monitor *Monitors
Pricing *Pricing
Verifications *Verifications
}
</code></pre>
<p>The end result is that my code looks like this:</p>
<pre><code>func (c *CustomClient) RequestMoney() {
_, err := v.client.Verifications.GetMoney("fakeIDhere")
}
</code></pre>
| [
{
"answer_id": 74324536,
"author": "nimdrak",
"author_id": 11758344,
"author_profile": "https://Stackoverflow.com/users/11758344",
"pm_score": 0,
"selected": false,
"text": "Client"
},
{
"answer_id": 74325802,
"author": "vague",
"author_id": 14837126,
"author_profile": "https://Stackoverflow.com/users/14837126",
"pm_score": 2,
"selected": true,
"text": "banker"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74324023",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/5117502/"
] |
74,324,034 | <p>I have made a map in the tiled editor and intend to use it in a game using pygame. I imported pytmx to help with this process but when I use load_pygame("directory of file") it give out this error</p>
<pre><code>
Traceback (most recent call last):
File "D:\Coder man\code\GUI\game map\showing map.py", line 7, in <module>
tmx_data = load_pygame("D:\Tile sheet\Dungeon Hub room.tmx")
File "C:\Users\Name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pytmx\util_pygame.py", line 183, in load_pygame
return pytmx.TiledMap(filename, *args, **kwargs)
File "C:\Users\Name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pytmx\pytmx.py", line 501, in __init__
self.parse_xml(ElementTree.parse(self.filename).getroot())
File "C:\Users\Name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pytmx\pytmx.py", line 550, in parse_xml
self.add_tileset(TiledTileset(self, subnode))
File "C:\Users\Name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pytmx\pytmx.py", line 1101, in __init__
self.parse_xml(node)
File "C:\Users\Name\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.7_qbz5n2kfra8p0\LocalCache\local-packages\Python37\site-packages\pytmx\pytmx.py", line 1129, in parse_xml
source, self.parent.filename, path
Exception: Cannot find tileset file :/automap-tiles.tsx from D:\Tile sheet\Dungeon Hub room.tmx, should be at D:\Tile sheet\:\automap-tiles.tsx
</code></pre>
<p>the code I have so far is this:</p>
<pre><code>import pygame, sys
from pytmx.util_pygame import load_pygame
pygame.init()
screen = pygame.display.set_mode((1280, 720))
tmx_data = load_pygame("D:\Tile sheet\Dungeon Hub room.tmx")
print(tmx_data)
# game loop
while True:
for event in pygame.event.get():
if event.type == pygame.QUIT:
pygame.quit()
sys.exit()
screen.fill("black")
pygame.display.update()
</code></pre>
<p>i was expecting the pygame to come up with no errors and an output of:</p>
<p><Tiledmap: "Tile sheet\Dungeon Hub room.tmx"></p>
<p>and a pygame window</p>
<p>I have tried double checking the directory of the file and using <code>pytmx.load_pygame </code></p>
| [
{
"answer_id": 74324536,
"author": "nimdrak",
"author_id": 11758344,
"author_profile": "https://Stackoverflow.com/users/11758344",
"pm_score": 0,
"selected": false,
"text": "Client"
},
{
"answer_id": 74325802,
"author": "vague",
"author_id": 14837126,
"author_profile": "https://Stackoverflow.com/users/14837126",
"pm_score": 2,
"selected": true,
"text": "banker"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74324034",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18739114/"
] |
74,324,049 | <p>I have a dataset with measures for individuals, where each measure represents a specific type of measure (say '1' or '2') and each individual belongs to specific group (say 'A' or 'B'). For a subset of individuals, I have observed both measures '1' and '2'. In this data, the different measures have different variances, and there is a subject-level random effect that has very different variances in the two groups. How would I go about fitting this model in the right way?</p>
<p>Here is an example:</p>
<pre><code>dat <- structure(list(subject = c(1, 2, 3, 4, 5, 6, 7, 8, 9, 10, 11,
12, 13, 14, 15, 16, 17, 18, 19, 20, 21, 22, 23, 24, 25, 26, 27,
28, 29, 30, 31, 32, 33, 34, 35, 36, 37, 38, 39, 40, 41, 42, 43,
44, 45, 46, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59,
60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75,
76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91,
92, 93, 94, 95, 96, 97, 98, 99, 100, 101, 101, 102, 102, 103,
103, 104, 104, 105, 105, 106, 106, 107, 107, 108, 108, 109, 109,
110, 110, 111, 111, 112, 112, 113, 113, 114, 114, 115, 115, 116,
116, 117, 117, 118, 118, 119, 119, 120, 120, 121, 121, 122, 122,
123, 123, 124, 124, 125, 125, 126, 126, 127, 127, 128, 128, 129,
129, 130, 130),
group = structure(c(1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 1L, 2L,
2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L,
2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L,
2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L,
2L, 1L, 1L, 2L, 2L, 1L, 1L, 2L, 2L), .Label = c("A", "B"), class = "factor"),
measure = structure(c(1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L,
1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 1L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L, 2L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L,
1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L, 2L, 1L,
2L), .Label = c("1", "2"), class = "factor"),
y = c(-1.71,
121.74, -1.57, 109.96, -0.64, 101.67, -0.13, 120.64, 1.47,
101.99, -4.51, 133.18, -2.9, 117.95, -0.97, 126.94, -1.44,
105.1, -1.52, 122.2, -2.29, 130.17, -0.35, 133.14, -0.94,
112.68, -0.89, 105.37, -2.49, 126.75, -2.61, 139.25, -2.13,
113.43, 0.61, 140.76, -0.75, 129.17, 1.94, 139.4, -0.49,
119.03, -2.09, 89.97, -2.76, 107.85, 1.61, 136.31, -0.55,
128.6, 0.41, 86.66, 0.54, 100.03, 2.46, 115.37, 6.94, 109.34,
3.78, 102.34, -4.46, 104.06, 1.48, 105.06, 3.98, 85.21, 1.31,
103.17, -3.35, 110.83, 2.75, 98.38, -2.43, 101.57, 2.2, 120.45,
-4.06, 101.25, 3.85, 99.38, 2.17, 108, 9.27, 100.76, 3.27,
110.3, 1.22, 98.91, 1.62, 105.65, 4.64, 113.07, 8.14, 108.75,
6.84, 73.08, 1.42, 99.41, -0.5, 95.25, 1.42, 3.76, 102.95,
85.45, -2.71, -0.48, 137.34, 114.61, -0.42, 1.71, 98.82,
83.06, -3.51, -0.32, 109.66, 91.99, -0.46, -1.35, 113.88,
97.32, -0.93, 1.17, 111.26, 103.9, -4.11, 6.78, 106.36, 88.22,
-0.85, -6.56, 137.39, 112.19, -0.91, 3.26, 122.53, 105.18,
-0.61, 4.25, 111.01, 95.85, -2.68, 3.1, 142.26, 114.44, -0.31,
3.76, 127.61, 102.26, -1.82, 4.01, 116.61, 97.1, -3.61, 0.9,
107.73, 90.6, -0.13, 3.78, 108.73, 95.12)),
row.names = c(NA, -160L), class = "data.frame")
</code></pre>
<p><a href="https://i.stack.imgur.com/S3kEV.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/S3kEV.png" alt="Plot of values for the two measures across groups" /></a></p>
<p>I can fit a mixed-effects model with nlme:</p>
<pre><code>init <- c(-1.2, 120, 2, 100)
model1 <- nlme(y ~ a,
data = dat,
fixed = list(a ~ group : measure + 0),
random = a ~ 1,
groups = ~ subject,
start = init,
weights = varIdent(form = ~ 1 | measure))
</code></pre>
<p>Is there a way to fit the model such that the random effect has different variances across groups? I have a feeling that this should be achievable by using a correlation structure, but so far I have been unsuccessful.</p>
<p>In reality, my model is nonlinear and more complex than the above, so the problem can unfortunately not be solved by crossed random effects with <code>lmer</code> (but maybe a crossed random effects hack for nlme?)</p>
| [
{
"answer_id": 74324268,
"author": "Ben Bolker",
"author_id": 190277,
"author_profile": "https://Stackoverflow.com/users/190277",
"pm_score": 2,
"selected": false,
"text": "lme"
},
{
"answer_id": 74332670,
"author": "Lars Lau Raket",
"author_id": 1637957,
"author_profile": "https://Stackoverflow.com/users/1637957",
"pm_score": 0,
"selected": false,
"text": "mixed.cpp"
}
] | 2022/11/04 | [
"https://Stackoverflow.com/questions/74324049",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/1637957/"
] |
74,324,086 | <p>I'm working with some developers to create a website, and I want to know if React will work if I hire someone to create the html and css first, and then have another person integrate react with those templates</p>
<p>Is react integratable in this situation, or does react have to be used from the get go? I am a python programmer, so I have no clue how react works lol</p>
| [
{
"answer_id": 74324268,
"author": "Ben Bolker",
"author_id": 190277,
"author_profile": "https://Stackoverflow.com/users/190277",
"pm_score": 2,
"selected": false,
"text": "lme"
},
{
"answer_id": 74332670,
"author": "Lars Lau Raket",
"author_id": 1637957,
"author_profile": "https://Stackoverflow.com/users/1637957",
"pm_score": 0,
"selected": false,
"text": "mixed.cpp"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324086",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/11280068/"
] |
74,324,124 | <p>I am building a shop project for school, and as I decided that instead copying and pasting a function which toasts that there's no internet connection in each activity, I should instead add it to my project manager class, which is not an activity, ShopManager. The problem is, in order to toast, one of the parameters is the activity in which the toast should occur and I have not found a way to do it. I decided for now I should just try to toast before adding any internet checking, and this is what I created thus far:</p>
<p>This is in my Home Page activity:</p>
<pre><code>public class Home extends AppCompatActivity implements View.OnClickListener {
ShopManager shopMng;
...
...
...
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_home);
shopMng = new ShopManager();
shopMng.toast(Home.this);
}
}
</code></pre>
<p>In my ShopManager class:</p>
<pre><code>public class ShopManager {
public void toast(Class cls) {
Toast.makeText(cls.this, "Test", Toast.LENGTH_SHORT).show();
}
}
</code></pre>
<p>The error message I am getting is " 'toast(java.lang.Class)' in 'com.example.birthdayshop.ShopManager' cannot be applied to '(com.example.birthdayshop.Shop)' ", which I deducted basically means that the type of the cls parameter is not correct. What type of variable should it be in order to work in ALL activities? Thank you so much in advance.</p>
| [
{
"answer_id": 74324258,
"author": "BigBeef",
"author_id": 20304512,
"author_profile": "https://Stackoverflow.com/users/20304512",
"pm_score": 0,
"selected": false,
"text": "Intent intent = new Intent(getApplicationContext(), Home.class);\nshopMng.someMethod(intent);\n"
},
{
"answer_id": 74326232,
"author": "Pouria Rezaie",
"author_id": 17754056,
"author_profile": "https://Stackoverflow.com/users/17754056",
"pm_score": 2,
"selected": true,
"text": "public class ShopManager {\n static void toastMessage(Context context){\n Toast.makeText(context, \"Test\", Toast.LENGTH_SHORT).show();\n }\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324124",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/13901310/"
] |
74,324,143 | <p>This was originally working, until I removed some JS files and unused CSS. Now, I can no longer get the accordion buttons to expand. I believe my implementation doesn't require JS. However, to the best of my knowledge I reimplemented all JS that was present when it was working.</p>
<p>I believe my issue is that I'm missing the neccessary data-toggle within CSS. However, the original CSS file doesn't have any collapse toggles related to button or accordion classes. Only <code>.nav</code>.</p>
<p><strong>HTML:</strong></p>
<pre><code><div class="card">
<div class="card-header py-4" id="heading-1-1" data-toggle="collapse" role="button" data-target="#collapse-1-1" aria-expanded="false" aria-controls="collapse-1-1">
<h6 class="mb-0"><i data-feather="file" class="mr-3"></i>Title</h6>
</div>
<div id="collapse-1-1" class="collapse" aria-labelledby="heading-1-1" data-parent="#accordion-1">
<div class="card-body">
<p>Text</p>
</div>
</div>
</div>
</code></pre>
<p><strong>CSS:</strong></p>
<pre><code>.collapse:not(.show) {
display: none; }
.collapsing {
position: relative;
height: 0;
overflow: hidden;
transition: height 0.2s ease; }
@media (prefers-reduced-motion: reduce) {
.collapsing {
transition: none; } }
</code></pre>
| [
{
"answer_id": 74324191,
"author": "Oscar ",
"author_id": 15619870,
"author_profile": "https://Stackoverflow.com/users/15619870",
"pm_score": 0,
"selected": false,
"text": "<script src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.min.js\" integrity=\"sha384-IDwe1+LCz02ROU9k972gdyvl+AESN10+x7tBKgc9I5HFtuNz0wWnPclzo6p9vxnk\" crossorigin=\"anonymous\"></script>\n"
},
{
"answer_id": 74324301,
"author": "Sigurd Mazanti",
"author_id": 14776809,
"author_profile": "https://Stackoverflow.com/users/14776809",
"pm_score": 2,
"selected": true,
"text": "bootstrap-4"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324143",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3605767/"
] |
74,324,193 | <p>I'm trying to put my append list into a table. I only can print one line of the list but not the others since the amount of numbers and words can varie from 1 to infinity</p>
<pre><code>everthing = []
option = 0
while option < 5:
Mainmenue = ["Main menue", "1. ADD AN ITEM", "4. GENERATE A REPORT"]
for i in (Mainmenue):
print(i)
option = int(input("Option you want:"))
if option == 1:
item = (input("add an item:"))
itemquantity = (input("Item quantity:"))
everthing.append(item)
everthing.append(itemquantity)
print(everthing)
elif option == 4:
#Here is the question
for thing in everthing:
print(thing, sep='\t')
#Here is the question end
Mainmenue = ["Main menue", "1. ADD AN ITEM","4. GENERATE A REPORT"]
for i in (Mainmenue):
print(i)
option = float(input("Option you want:"))
</code></pre>
<p>When I run this code to give me a list it gives the table like this</p>
<pre><code>Jam
40
Sprite
30
</code></pre>
<p>But I want it to be like this</p>
<pre><code>Jam 40
Sprite 30
</code></pre>
<p>Thanks in advance :)</p>
| [
{
"answer_id": 74324191,
"author": "Oscar ",
"author_id": 15619870,
"author_profile": "https://Stackoverflow.com/users/15619870",
"pm_score": 0,
"selected": false,
"text": "<script src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.min.js\" integrity=\"sha384-IDwe1+LCz02ROU9k972gdyvl+AESN10+x7tBKgc9I5HFtuNz0wWnPclzo6p9vxnk\" crossorigin=\"anonymous\"></script>\n"
},
{
"answer_id": 74324301,
"author": "Sigurd Mazanti",
"author_id": 14776809,
"author_profile": "https://Stackoverflow.com/users/14776809",
"pm_score": 2,
"selected": true,
"text": "bootstrap-4"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324193",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20421976/"
] |
74,324,213 | <p>I am working on a library project but my function called <code>changeColor</code> inside the <code>readStatus</code> function does not appear to be working.</p>
<p>I've tried separating it but having two event listeners on the same button does not appear to work. My goal is for <code>readStatus</code> function to allow a user to update the status of a book from no to yes when finished with the book.</p>
<p>Likewise, I want to change the background color of the div (class: card) when yes to be green and no to be red.</p>
<p>Can anyone tell me what I'm doing wrong?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let myLibrary = [];
function Book(title, author, pages, read) {
this.title = title;
this.author = author;
this.pages = pages;
this.read = read;
}
function addBookToLibrary(title, author, pages, read) {
let book = new Book(title, author, pages, read);
myLibrary.push(book);
displayOnPage();
}
function displayOnPage() {
const books = document.querySelector(".books");
const removeDivs = document.querySelectorAll(".card");
for (let i = 0; i < removeDivs.length; i++) {
removeDivs[i].remove();
}
let index = 0;
myLibrary.forEach((myLibrarys) => {
let card = document.createElement("div");
card.classList.add("card");
books.appendChild(card);
for (let key in myLibrarys) {
let para = document.createElement("p");
para.textContent = `${key}: ${myLibrarys[key]}`;
card.appendChild(para);
}
let read_button = document.createElement("button");
read_button.classList.add("read_button");
read_button.textContent = "Read ";
read_button.dataset.linkedArray = index;
card.appendChild(read_button);
read_button.addEventListener("click", readStatus);
let delete_button = document.createElement("button");
delete_button.classList.add("delete_button");
delete_button.textContent = "Remove";
delete_button.dataset.linkedArray = index;
card.appendChild(delete_button);
delete_button.addEventListener("click", removeFromLibrary);
function removeFromLibrary() {
let retrieveBookToRemove = delete_button.dataset.linkedArray;
myLibrary.splice(parseInt(retrieveBookToRemove), 1);
card.remove();
displayOnPage();
}
function readStatus() {
let retrieveBookToToggle = read_button.dataset.linkedArray;
Book.prototype = Object.create(Book.prototype);
const toggleBook = new Book();
if (myLibrary[parseInt(retrieveBookToToggle)].read == "yes") {
toggleBook.read = "no";
myLibrary[parseInt(retrieveBookToToggle)].read = toggleBook.read;
} else if (myLibrary[parseInt(retrieveBookToToggle)].read == "no") {
toggleBook.read = "yes";
myLibrary[parseInt(retrieveBookToToggle)].read = toggleBook.read;
}
let colorDiv = document.querySelector(".card");
function changeColor() {
for (let i = 0; i < length.myLibrary; i++) {
if (myLibrary[i].read == "yes") {
colorDiv.style.backgroundColor = "green";
} else if (myLibrary[i].read == "no") {
colorDiv.style.backgroundColor = "red";
}
}
}
displayOnPage();
}
index++;
});
}
let add_book = document.querySelector(".add-book");
add_book.addEventListener("click", popUpForm);
function popUpForm() {
document.getElementById("data-form").style.display = "block";
}
function closeForm() {
document.getElementById("data-form").style.display = "none";
}
let close_form_button = document.querySelector("#close-form");
close_form_button.addEventListener("click", closeForm);
function intakeFormData() {
let title = document.getElementById("title").value;
let author = document.getElementById("author").value;
let pages = document.getElementById("pages").value;
let read = document.getElementById("read").value;
if (title == "" || author == "" || pages == "" || read == "") {
return;
}
addBookToLibrary(title, author, pages, read);
document.getElementById("data-form").reset();
}
let submit_form = document.querySelector("#submit-form");
submit_form.addEventListener("click", function (event) {
event.preventDefault();
intakeFormData();
});</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>* {
margin: 0;
padding: 0;
background-color: rgb(245, 227, 205);
}
.books {
display: grid;
grid-template-columns: 1fr 1fr 1fr 1fr;
text-align: center;
margin: 20px;
gap: 10px;
}
.card {
border: 1px solid black;
border-radius: 15px;
padding: 10px;
}
.forms {
display: flex;
flex-direction: column;
align-items: center;
}
form {
margin-top: 20px;
}
select,
input[type="text"],
input[type="number"] {
width: 100%;
box-sizing: border-box;
}
.buttons-container {
display: flex;
margin-top: 10px;
}
.buttons-container button {
width: 100%;
margin: 2px;
}
.add-book {
margin-top: 20px;
}
#data-form {
display: none;
}
.read_button {
margin-right: 10px;
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8" />
<meta http-equiv="X-UA-Compatible" content="IE=edge" />
<meta name="viewport" content="width=device-width, initial-scale=1.0" />
<link rel="stylesheet" href="style.css" />
<title>Document</title>
</head>
<body>
<div class="container">
<div class="forms">
<button class="add-book">Add Book To Library</button>
<div class="pop-up">
<form id="data-form">
<div class="form-container">
<label for="title">Title</label>
<input type="text" name="title" id="title" />
</div>
<div class="form-container">
<label for="author">Author</label>
<input type="text" name="author" id="author" />
</div>
<div class="form-container">
<label for="pages">Pages</label>
<input type="number" name="pages" id="pages" />
</div>
<div class="form-container">
<label for="read">Read</label>
<select name="read" id="read">
<option value="yes">Yes</option>
<option value="no">No</option>
</select>
</div>
<div class="buttons-container">
<button type="submit" id="submit-form">Submit Form</button>
<button type="button" id="close-form">Close Form</button>
</div>
</form>
</div>
</div>
<div class="books"></div>
</div>
<script src="script.js"></script>
</body>
</html></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74324191,
"author": "Oscar ",
"author_id": 15619870,
"author_profile": "https://Stackoverflow.com/users/15619870",
"pm_score": 0,
"selected": false,
"text": "<script src=\"https://cdn.jsdelivr.net/npm/bootstrap@5.2.2/dist/js/bootstrap.min.js\" integrity=\"sha384-IDwe1+LCz02ROU9k972gdyvl+AESN10+x7tBKgc9I5HFtuNz0wWnPclzo6p9vxnk\" crossorigin=\"anonymous\"></script>\n"
},
{
"answer_id": 74324301,
"author": "Sigurd Mazanti",
"author_id": 14776809,
"author_profile": "https://Stackoverflow.com/users/14776809",
"pm_score": 2,
"selected": true,
"text": "bootstrap-4"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324213",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19530516/"
] |
74,324,219 | <p>I have an application that I wrote in <strong>kivy</strong>. I want to convert this application to <strong>exe</strong>. Although I follow the steps in the documentation, I get an <strong>error</strong> when I run the <strong>exe</strong> file.</p>
<p>It didn't work even though I looked at all the examples. The .spec file may also be faulty</p>
<pre class="lang-py prettyprint-override"><code># -*- mode: python ; coding: utf-8 -*-
from kivy_deps import sdl2, glew
block_cipher = None
a = Analysis(
['..\\tübitak\\main.py'],
pathex=[],
binaries=[],
datas=[],
hiddenimports=[],
hookspath=[],
hooksconfig={},
runtime_hooks=[],
excludes=[],
win_no_prefer_redirects=False,
win_private_assemblies=False,
cipher=block_cipher,
noarchive=False,
)
pyz = PYZ(a.pure, a.zipped_data, cipher=block_cipher)
exe = EXE(
pyz,
a.scripts,
[],
exclude_binaries=True,
name='touchtracer',
debug=False,
bootloader_ignore_signals=False,
strip=False,
upx=True,
console=True,
disable_windowed_traceback=False,
argv_emulation=False,
target_arch=None,
codesign_identity=None,
entitlements_file=None,
)
coll = COLLECT(
exe,
a.binaries,
a.zipfiles,
a.datas,
*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],
strip=False,
upx=True,
upx_exclude=[],
name='touchtracer',
)
</code></pre>
<p>This is how I created my .spec file</p>
<pre><code>[INFO ] [Logger ] Record log in C:\Users\koray\.kivy\logs\kivy_22-11-05_2.txt
[INFO ] [Kivy ] v2.1.0
[INFO ] [Kivy ] Installed at "C:\Users\koray\AppData\Local\Temp\_MEI104402\kivy\__init__.pyc"
[INFO ] [Python ] v3.9.5 (tags/v3.9.5:0a7dcbd, May 3 2021, 17:27:52) [MSC v.1928 64 bit (AMD64)]
[INFO ] [Python ] Interpreter at "C:\Users\koray\Desktop\tübitak\build\main.exe"
[INFO ] [Logger ] Purge log fired. Processing...
[INFO ] [Logger ] Purge finished!
[INFO ] [Factory ] 189 symbols loaded
[INFO ] [Image ] Providers: img_tex, img_dds, img_sdl2, img_pil (img_ffpyplayer ignored)
[INFO ] [Window ] Provider: sdl2
[INFO ] [GL ] Using the "OpenGL" graphics system
[INFO ] [GL ] GLEW initialization succeeded
[INFO ] [GL ] Backend used <glew>
[INFO ] [GL ] OpenGL version <b'4.6.0 NVIDIA 526.47'>
[INFO ] [GL ] OpenGL vendor <b'NVIDIA Corporation'>
[INFO ] [GL ] OpenGL renderer <b'NVIDIA GeForce GTX 1050/PCIe/SSE2'>
[INFO ] [GL ] OpenGL parsed version: 4, 6
[INFO ] [GL ] Shading version <b'4.60 NVIDIA'>
[INFO ] [GL ] Texture max size <32768>
[INFO ] [GL ] Texture max units <32>
[WARNING] [Image ] Unable to load image <C:\Users\koray\AppData\Local\Temp\_MEI104402\kivy_install\data\glsl\default.png>
[CRITICAL] [Window ] Unable to find any valuable Window provider. Please enable debug logging (e.g. add -d if running from the command line, or change the log level in the config) and re-run your app to identify potential causes
</code></pre>
<pre><code>sdl2 - Exception: SDL2: Unable to load image
File "kivy\core\__init__.py", line 71, in core_select_lib
File "kivy\core\window\window_sdl2.py", line 165, in __init__
File "kivy\core\window\__init__.py", line 1071, in __init__
File "kivy\core\window\window_sdl2.py", line 362, in create_window
File "kivy\core\window\__init__.py", line 1450, in create_window
File "kivy\graphics\instructions.pyx", line 797, in kivy.graphics.instructions.RenderContext.__init__
File "kivy\core\image\__init__.py", line 561, in __init__
File "kivy\core\image\__init__.py", line 754, in _set_filename
File "kivy\core\image\__init__.py", line 460, in load
File "kivy\core\image\__init__.py", line 223, in __init__
File "kivy\core\image\img_sdl2.py", line 47, in load
Traceback (most recent call last):
File "main.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "python\newpageTwo.py", line 22, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "dtale\__init__.py", line 22, in <module>
* :class:`~kivy.modules.showborder`: Show widget's border.
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "dtale\app.py", line 50, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "dtale\views.py", line 38, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "dtale\charts\utils.py", line 7, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "dtale\column_analysis.py", line 12, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "dtale\column_builders.py", line 23, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
File "dtale\translations\__init__.py", line 9, in <module>
* :class:`~kivy.modules.monitor`: Add a red topbar that indicates the FPS
FileNotFoundError: [WinError 3] Sistem belirtilen yolu bulamıyor: 'C:\\Users\\koray\\AppData\\Local\\Temp\\_MEI104402\\dtale\\translations'
[18296] Failed to execute script 'main' due to unhandled exception!
</code></pre>
<p>When i run my exe file i get an error like this</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-html lang-html prettyprint-override"><code>Traceback (most recent call last):
File "main.py", line 3, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
exec(bytecode, module.__dict__)
File "python\newpageTwo.py", line 4, in <module>
File "<frozen importlib._bootstrap>", line 1007, in _find_and_load
File "<frozen importlib._bootstrap>", line 986, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 680, in _load_unlocked
File "PyInstaller\loader\pyimod02_importers.py", line 499, in exec_module
exec(bytecode, module.__dict__)
File "kivy\__init__.py", line 317, in <module>
mod = importer.find_module(modname).load_module(modname)
File "C:\Users\koray\Desktop\tübitak\dist\main\kivy_deps\angle\__init__.py", line 23, in <module>
p = join(d, 'share', 'angle', 'bin')
File "ntpath.py", line 78, in join
TypeError: expected str, bytes or os.PathLike object, not NoneType</code></pre>
</div>
</div>
</p>
<p>I started getting this error after my recent fixes</p>
| [
{
"answer_id": 74365492,
"author": "MST",
"author_id": 7351626,
"author_profile": "https://Stackoverflow.com/users/7351626",
"pm_score": 0,
"selected": false,
"text": "*[Tree(p) for p in (sdl2.dep_bins + glew.dep_bins)],\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324219",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16230831/"
] |
74,324,234 | <p>How do I merge every single batch of consecutive lines in a .txt file?</p>
<p><strong>Example:</strong></p>
<p>Turn this:</p>
<pre><code>User#0001
Hello
Whats Up
User#0002
Hi
...
</code></pre>
<p>into this:</p>
<pre><code>User#0001 Hello Whats Up
User#0002 Hi
...
</code></pre>
<p>I want to merge all of the lines because when I've tried doing this:</p>
<pre class="lang-py prettyprint-override"><code>pattern = r'([a-zA-Z]+#[0-9]+.)(.+?(?:^$|\Z))'
</code></pre>
<pre class="lang-py prettyprint-override"><code>data = {
'name': [],
'message': []
}
</code></pre>
<pre class="lang-py prettyprint-override"><code>with open('chat.txt', 'rt') as file:
for message in file.readlines():
match = re.findall(pattern, message, flags=re.M|re.S)
print(match)
if match:
name, message = match[0]
data['name'].append(name)
data['message'].append(message)
</code></pre>
<p>I got this when printing 'match':</p>
<pre><code>[('User#0001', '\n')]
[]
[]
[]
[('User#0002', '\n')
...
</code></pre>
<p>And when manually editing some of the lines to be <code>User#0001 message</code> then it does return the correct output.</p>
| [
{
"answer_id": 74324278,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 3,
"selected": true,
"text": "re.sub"
},
{
"answer_id": 74324300,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 1,
"selected": false,
"text": "import re\n\ns = \"\"\"\\\nUser#0001\nHello\nWhats Up\n\n\nUser#0002\nHi\"\"\"\n\npat = re.compile(r\"^(\\S+#\\d+)\\s*(.*?)\\s*(?=^\\S+#\\d+|\\Z)\", flags=re.M | re.S)\nout = [(user, messages.splitlines()) for user, messages in pat.findall(s)]\nprint(out)\n"
},
{
"answer_id": 74325056,
"author": "user3435121",
"author_id": 3435121,
"author_profile": "https://Stackoverflow.com/users/3435121",
"pm_score": 0,
"selected": false,
"text": "t= [\n\"User#0001\\n\",\n\"Hello\\n\",\n\"Whats Up\\n\",\n\"\\n\",\n\"\\n\",\n\"User#0002\\n\",\n\"Hi\\n\",\n\"...\\n\",\n]\n\ndata=[]\n\nfor line in t:\n line = line.strip() # remove spaces and \\n\n if line.strip().startswith( \"User#\"):\n data.append( [line,\"\"])\n else:\n data[-1][1] += ' ' + line\nfor msg in data:\n print( msg[0], msg[1] if len(msg)>1 else \"\")\n"
},
{
"answer_id": 74326134,
"author": "The fourth bird",
"author_id": 5424988,
"author_profile": "https://Stackoverflow.com/users/5424988",
"pm_score": 0,
"selected": false,
"text": "^([a-zA-Z]+#[0-9]+)((?:\\n(?![a-zA-Z]+#[0-9]).+)*)\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324234",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12704826/"
] |
74,324,263 | <p>I'm trying to create a program that takes user input and passes it to three methods.</p>
<ul>
<li>one method calculates total pay</li>
<li>one method determines shift selected</li>
<li>I want the last method to be the display method, but I've used a method that receives parameters to pass the information, a <code>void</code> method, and <code>static</code> which caused more problems than it helped.</li>
</ul>
<p>Why is the method not getting the information?</p>
<p>This class has its own code file called Employee.</p>
<p>Class method to display results:</p>
<pre class="lang-cs prettyprint-override"><code>//Method to display results
public void Display(double total)
{
//main form instance to access controls
MainForm mainForm = new MainForm();
mainForm.nameSumBox .Text = Name;
mainForm.empNumSumBox.Text = EmployeeNumber.ToString();
mainForm.paySumBox .Text = total.ToString();
mainForm.shiftSumBox .Text = SelectedShift;
}
</code></pre>
<p>Call-site:</p>
<pre><code>try
{
//variables
double totalPay;
//get user entry
employee.Name = nameBox.Text;
employee.EmployeeNumber = int.Parse(empNumBox.Text);
employee.HRPay = double.Parse(hrPayBox.Text);
employee.SelectedShift = employee.ShiftChoice(); // method to determine shift selection
//calculate pay total
totalPay = employee.CalcPay();
//display
employee.Display(totalPay);
</code></pre>
| [
{
"answer_id": 74324278,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 3,
"selected": true,
"text": "re.sub"
},
{
"answer_id": 74324300,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 1,
"selected": false,
"text": "import re\n\ns = \"\"\"\\\nUser#0001\nHello\nWhats Up\n\n\nUser#0002\nHi\"\"\"\n\npat = re.compile(r\"^(\\S+#\\d+)\\s*(.*?)\\s*(?=^\\S+#\\d+|\\Z)\", flags=re.M | re.S)\nout = [(user, messages.splitlines()) for user, messages in pat.findall(s)]\nprint(out)\n"
},
{
"answer_id": 74325056,
"author": "user3435121",
"author_id": 3435121,
"author_profile": "https://Stackoverflow.com/users/3435121",
"pm_score": 0,
"selected": false,
"text": "t= [\n\"User#0001\\n\",\n\"Hello\\n\",\n\"Whats Up\\n\",\n\"\\n\",\n\"\\n\",\n\"User#0002\\n\",\n\"Hi\\n\",\n\"...\\n\",\n]\n\ndata=[]\n\nfor line in t:\n line = line.strip() # remove spaces and \\n\n if line.strip().startswith( \"User#\"):\n data.append( [line,\"\"])\n else:\n data[-1][1] += ' ' + line\nfor msg in data:\n print( msg[0], msg[1] if len(msg)>1 else \"\")\n"
},
{
"answer_id": 74326134,
"author": "The fourth bird",
"author_id": 5424988,
"author_profile": "https://Stackoverflow.com/users/5424988",
"pm_score": 0,
"selected": false,
"text": "^([a-zA-Z]+#[0-9]+)((?:\\n(?![a-zA-Z]+#[0-9]).+)*)\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324263",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20245024/"
] |
74,324,269 | <p>I have a row in my csv file here:</p>
<pre><code> 0 1 2 3 4 5
0 I 55 A 2018-03-10 00:00:00.000 username_in_current_row 2012-01-24 00:00:00.000
</code></pre>
<p>I want to write something in python where it only selects rows that have "I" at the index of 0, so do a row count of how many records have "I" there. And I want to print ("X number of records were inserted successfully where an "I" exists.)</p>
<p>So in this case I would do something like:</p>
<pre><code>df = pd.read_csv('file.csv', header=None')
print(df)
</code></pre>
<p>This would print the dataframe.</p>
<pre><code>df_row_count = df.shape[0]
</code></pre>
<p>Here I want a row count of how many records have "I" in it at the index of 0???</p>
<pre><code>print("X amount of records inserted successfully.")
</code></pre>
<p>I think I need an f-string here in place of X that would just count the total number of rows in the table with "I"?</p>
| [
{
"answer_id": 74324278,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 3,
"selected": true,
"text": "re.sub"
},
{
"answer_id": 74324300,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 1,
"selected": false,
"text": "import re\n\ns = \"\"\"\\\nUser#0001\nHello\nWhats Up\n\n\nUser#0002\nHi\"\"\"\n\npat = re.compile(r\"^(\\S+#\\d+)\\s*(.*?)\\s*(?=^\\S+#\\d+|\\Z)\", flags=re.M | re.S)\nout = [(user, messages.splitlines()) for user, messages in pat.findall(s)]\nprint(out)\n"
},
{
"answer_id": 74325056,
"author": "user3435121",
"author_id": 3435121,
"author_profile": "https://Stackoverflow.com/users/3435121",
"pm_score": 0,
"selected": false,
"text": "t= [\n\"User#0001\\n\",\n\"Hello\\n\",\n\"Whats Up\\n\",\n\"\\n\",\n\"\\n\",\n\"User#0002\\n\",\n\"Hi\\n\",\n\"...\\n\",\n]\n\ndata=[]\n\nfor line in t:\n line = line.strip() # remove spaces and \\n\n if line.strip().startswith( \"User#\"):\n data.append( [line,\"\"])\n else:\n data[-1][1] += ' ' + line\nfor msg in data:\n print( msg[0], msg[1] if len(msg)>1 else \"\")\n"
},
{
"answer_id": 74326134,
"author": "The fourth bird",
"author_id": 5424988,
"author_profile": "https://Stackoverflow.com/users/5424988",
"pm_score": 0,
"selected": false,
"text": "^([a-zA-Z]+#[0-9]+)((?:\\n(?![a-zA-Z]+#[0-9]).+)*)\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324269",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20412585/"
] |
74,324,271 | <p>I have a gallery of 20 images and each image corresponds to a div with text in it.
When i click on an image, the text should appear. When i click on the next image, that images text should appear WHILE closing the previous text div from the 1st image i clicked on.</p>
<p>So only one text box should be visible at one time.</p>
<p>so far i have this:</p>
<pre><code>attachToggleListener("leifr","rosenvold");
attachToggleListener("damians","smith");
attachToggleListener("megan","adam");
function attachToggleListener (buttonID, divID) {
var myTrigger = document.getElementById(buttonID);
if (myTrigger != null) {
myTrigger.addEventListener("click", toggleDiv);
myTrigger.targetDiv = divID;
}
}
function toggleDiv(evt) {
var target = document.getElementById(evt.currentTarget.targetDiv);
if (target.style.display === "block")
{ target.style.display = "none"; }
else
{ target.style.display = "block"; }
}
</code></pre>
<p>the text appears when i click on the image, but it does not close when i click on the next image.
as it sits now, I can click on 4 images and 4 text divs will appear and only be removed when i click the image that made it appear.</p>
<p>Again what i was expecting was to click on an image "leifr" > the text box appears "rosenvold" >click on a second image "damians" > the second text box appears "smith" while the 1st text box "rosenvold" disappears</p>
| [
{
"answer_id": 74324278,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 3,
"selected": true,
"text": "re.sub"
},
{
"answer_id": 74324300,
"author": "Andrej Kesely",
"author_id": 10035985,
"author_profile": "https://Stackoverflow.com/users/10035985",
"pm_score": 1,
"selected": false,
"text": "import re\n\ns = \"\"\"\\\nUser#0001\nHello\nWhats Up\n\n\nUser#0002\nHi\"\"\"\n\npat = re.compile(r\"^(\\S+#\\d+)\\s*(.*?)\\s*(?=^\\S+#\\d+|\\Z)\", flags=re.M | re.S)\nout = [(user, messages.splitlines()) for user, messages in pat.findall(s)]\nprint(out)\n"
},
{
"answer_id": 74325056,
"author": "user3435121",
"author_id": 3435121,
"author_profile": "https://Stackoverflow.com/users/3435121",
"pm_score": 0,
"selected": false,
"text": "t= [\n\"User#0001\\n\",\n\"Hello\\n\",\n\"Whats Up\\n\",\n\"\\n\",\n\"\\n\",\n\"User#0002\\n\",\n\"Hi\\n\",\n\"...\\n\",\n]\n\ndata=[]\n\nfor line in t:\n line = line.strip() # remove spaces and \\n\n if line.strip().startswith( \"User#\"):\n data.append( [line,\"\"])\n else:\n data[-1][1] += ' ' + line\nfor msg in data:\n print( msg[0], msg[1] if len(msg)>1 else \"\")\n"
},
{
"answer_id": 74326134,
"author": "The fourth bird",
"author_id": 5424988,
"author_profile": "https://Stackoverflow.com/users/5424988",
"pm_score": 0,
"selected": false,
"text": "^([a-zA-Z]+#[0-9]+)((?:\\n(?![a-zA-Z]+#[0-9]).+)*)\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324271",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/18581100/"
] |
74,324,312 | <p>Currently, when you click 'more info' and the popup opens. You are able to scroll and you'll see that the background moves. I want to prevent the ability for scrolling while the popup is opening, what would I do to take care of this issue? I tried playing with overflow:hidden; in CSS but it didn't work for this. I will add a link to my fiddle. <a href="http://jsfiddle.net/ctose0Lq/11/" rel="nofollow noreferrer">http://jsfiddle.net/ctose0Lq/11/</a></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>/*=============== SERVICES MODAL ===============*/
const modalViews = document.querySelectorAll('.services__modal'),
modalBtns = document.querySelectorAll('.services__button'),
modalClose = document.querySelectorAll('.services__modal-close')
let modal = function(modalClick) {
modalViews[modalClick].classList.add('active-modal')
}
modalBtns.forEach((mb, i) => {
mb.addEventListener('click', () => {
modal(i)
})
})
modalClose.forEach((mc) => {
mc.addEventListener('click', () => {
modalViews.forEach((mv) => {
mv.classList.remove('active-modal')
})
})
})
/*=============== Products MODAL ===============*/
const modalViews2 = document.querySelectorAll('.services__modal'),
modalBtns2 = document.querySelectorAll('.products__button'),
modalClose2 = document.querySelectorAll('.services__modal-close')
let modal2 = function(modalClick) {
modalViews[modalClick].classList.add('active-modal')
}
modalBtns2.forEach((mb, i) => {
mb.addEventListener('click', () => {
modal2(i)
})
})
modalClose2.forEach((mc) => {
mc.addEventListener('click', () => {
modalViews2.forEach((mv) => {
mv.classList.remove('active-modal')
})
})
})</code></pre>
<pre class="snippet-code-css lang-css prettyprint-override"><code>/*=============== SERVICES ===============*/
.section__services {
padding: 4.5rem 0 1rem;
}
.section__title,
.section__subtitle {
text-align: center;
}
.section__title {
font-size: 1.55rem;
color: var(--first-color);
margin-bottom: 2rem;
}
.section__subtitle {
display: block;
font-size: .813rem;
color: black;
}
.container__services {
max-width: 968px;
margin-left: 1rem;
margin-right: 1rem;
}
.grid__services {
display: grid;
gap: 1.25rem;
}
.services__container {
grid-template-columns: repeat(2, 1fr);
gap: 1.5rem;
padding-top: 1rem;
}
.services__card {
padding: 5rem 1.5rem 1.5rem;
border-radius: 1rem;
background: linear-gradient(to top, #bdbcbfba, #4769b878), url(../img/blueflower-removebg-preview.webp) no-repeat top center;
}
.services__card2 {
padding: 5rem 1.5rem 1.5rem;
border-radius: 1rem;
background: linear-gradient(to top, #bdbcbfba, #c4bc4893), url(../img/yellowflower-removebg-preview.webp) no-repeat top center;
}
.services__card3 {
padding: 5rem 1.5rem 1.5rem;
border-radius: 1rem;
background: linear-gradient(to top, #bdbcbfba, #b38dd194), url(../img/pinkflower-removebg-preview.webp) no-repeat top center;
}
.services__card4 {
padding: 5rem 1.5rem 1.5rem;
border-radius: 1rem;
background: linear-gradient(to top, #bdbcbfba, #de6d3498), url(../img/salmonflower-removebg-preview.webp) no-repeat top center;
}
.section__services .services__container .services__card,
.section__services .services__container .services__card2,
.section__services .services__container .services__card3,
.section__services .services__container .services__card4 {
z-index: 1;
box-shadow: 0px 4px 16px rgba(43, 31, 31, 0.228);
border: .5px solid #9cd1f5;
}
.services__title {
font-size: 1.35rem;
margin-bottom: 2.5rem;
color: var(--text-color);
text-align: center;
}
.services__button {
color: var(--text-color);
font-size: .9rem;
display: flex;
align-items: center;
column-gap: .25rem;
cursor: pointer;
margin-left: 55%;
}
.services__button:hover .services__icon {
transform: translateX(.25rem);
}
.services__icon {
font-size: 1rem;
transition: .4s;
}
.services__modal {
position: fixed;
inset: 0;
background-color: hsla(219, 28%, 16%, 0.7);
padding: 2rem 1rem;
display: grid;
place-items: center;
visibility: hidden;
opacity: 0;
transition: .4s;
z-index: 15;
}
.services__modal-content {
position: relative;
background-color: #daeef6;
padding: 4.5rem 1.5rem 2.5rem;
border-radius: 1.5rem;
z-index: 15;
}
.services__modal-title,
.services__modal-description {
text-align: center;
}
.services__modal-title {
font-size: 1rem;
color: var(--first-color);
margin-bottom: 1rem;
}
.services__modal-description {
font-size: .813rem;
margin-bottom: 2rem;
}
.services__modal-list {
display: grid;
row-gap: .75rem;
}
.services__modal-item {
display: flex;
align-items: flex-start;
column-gap: .5rem;
}
.services__modal-icon {
font-size: 1.5rem;
color: var(--first-color);
cursor: default;
}
.services__modal-icon-x {
font-size: 1.5rem;
color: red;
cursor: default;
}
.services__modal-info {
font-size: .913rem;
}
.services__modal-close {
position: absolute;
top: 1.5rem;
right: 1.5rem;
font-size: 1.5rem;
color: var(--title-color);
cursor: pointer;
}
.modal__Z-index {
z-index: 1000 !important;
}
/*Active modal*/
.active-modal {
opacity: 1;
visibility: visible;
}
@media screen and (max-width: 991px) {
.services__button {
color: var(--text-color);
font-size: .9rem;
display: flex;
align-items: center;
column-gap: .25rem;
cursor: pointer;
margin-left: 35%;
}
}
/* For small devices */
@media screen and (max-width: 375px) {
.services__container {
grid-template-columns: repeat(1, 250px);
justify-content: center;
text-align: center;
}
}
@media screen and (max-width: 445px) {
.section__title {
font-size: 1.35rem;
}
.services__modal-info {
font-size: .7rem;
}
.services__container {
grid-template-columns: repeat(1, 250px);
justify-content: center;
text-align: center;
}
.section__services {
padding: 6.5rem 0 1rem;
margin-top: 25px;
}
.services__button {
color: var(--text-color);
font-size: .9rem;
display: flex;
align-items: center;
column-gap: .25rem;
cursor: pointer;
margin-left: 55%;
}
}
@media screen and (max-width: 575px) {
.specialty_button_center {
text-align: center;
}
.container__partners {
padding-top: 150px;
}
}
@media screen and (min-width: 576px) {
.services__container {
grid-template-columns: repeat(2, 200px);
justify-content: center;
}
.container__partners {
padding-top: 80px;
}
.services__modal-content {
width: 500px;
padding: 4.5rem 2.5rem 2.5rem;
z-index: 15;
}
.services__modal-description {
padding: 0 3.5rem;
}
.specialty__category {
grid-template-columns: repeat(2, 200px);
column-gap: 3rem;
}
.blog__content {
grid-template-columns: 450px;
justify-content: center;
}
.machine__content {
grid-template-columns: 450px;
justify-content: center;
}
.contact__container {
grid-template-columns: repeat(2, 1fr);
justify-items: center;
}
.contact__form {
width: 380px;
}
}
@media screen and (min-width: 576px) {
.services__container {
grid-template-columns: repeat(2, 200px);
justify-content: center;
}
.services__modal-content {
width: 500px;
padding: 4.5rem 2.5rem 2.5rem;
z-index: 15;
}
.services__modal-description {
padding: 0 3.5rem;
}
}
@media screen and (min-width: 992px) {
.section__services {
padding: 6.5rem 0 1rem;
margin-top: -100px;
}
.services__container {
grid-template-columns: repeat(3, 272px);
column-gap: 3rem;
}
.container__services {
margin-left: auto;
margin-right: auto;
}
.services__card {
padding: 5rem 2rem 1.5rem;
text-align: center;
}
.services__car2 {
padding: 5rem 2rem 1.5rem;
text-align: center;
}
.services__card3 {
padding: 5rem 2rem 1.5rem;
text-align: center;
}
.services__card4 {
padding: 5rem 2rem 1.5rem;
text-align: center;
}
}</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="viewport" content="width=device-width, initial-scale=1.0">
<!--=============== REMIXICONS ===============-->
<link href="https://cdn.jsdelivr.net/npm/remixicon@2.5.0/fonts/remixicon.css" rel="stylesheet">
<!--=============== BOXICONS ===============-->
<link href='https://unpkg.com/boxicons@2.1.1/css/boxicons.min.css' rel='stylesheet'>
<!--=============== CSS ===============-->
<link rel="stylesheet" href="assets/css/styles.css">
</head>
<body>
<!--=============== SERVICES ===============-->
<section id="whatweprovide" class="services section__services">
<span class="section__subtitle">Our Info Cards</span>
<h2 class="section__title">What We Provide</h2>
<div class="services__container container__services grid__services">
<div class="services__card">
<h3 class="services__title">Test 4</h3>
<span class="services__button">
More Info <i class='bx bx-right-arrow-alt services__icon'></i>
</span>
</div>
<div class="services__card2">
<h3 class="services__title">Test 3</h3>
<span class="services__button">
More Info <i class='bx bx-right-arrow-alt services__icon'></i>
</span>
</div>
<div class="services__card3">
<h3 class="services__title">Test 2</h3>
<span class="services__button">
More Info <i class='bx bx-right-arrow-alt services__icon'></i>
</span>
</div>
<div class="services__card4">
<h3 class="services__title">Test 1</h3>
<span class="services__button">
More Info <i class='bx bx-right-arrow-alt services__icon'></i>
</span>
</div>
</div>
</section>
<!--=============== Service Cards ===============-->
<div class="services__modal modal__Z-index">
<div class="services__modal-content">
<i class='bx bx-x services__modal-close'></i>
<h3 class="services__modal-title">Coming Soon </h3>
<p class="services__modal-description">
Test Textr skjhte e
</p>
<ul class="services__modal-list">
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e
</p>
</li>
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e
</p>
</li>
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e
</p>
</li>
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e
</p>
</li>
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e
</p>
</li>
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e
</p>
</li>
</ul>
</div>
</div>
<div class="services__modal .modal__Z-index">
<div class="services__modal-content">
<i class='bx bx-x services__modal-close'></i>
<h3 class="services__modal-title">Coming Soon </h3>
<p class="services__modal-description">
Test Textr skjhte e
</p>
<ul class="services__modal-list">
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e
</p>
</li>
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e
</p>
</li>
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e
</p>
</li>
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e
</p>
</li>
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e
</p>
</li>
</ul>
</div>
</div>
<div class="services__modal modal__Z-index">
<div class="services__modal-content">
<i class='bx bx-x services__modal-close'></i>
<h3 class="services__modal-title">Coming Soon</h3>
<p class="services__modal-description">
Test Textr skjhte e
</p>
<ul class="services__modal-list">
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e
</p>
</li>
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e
</p>
</li>
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e
</p>
</li>
</ul>
</div>
</div>
<div class="services__modal modal__Z-index">
<div class="services__modal-content">
<i class='bx bx-x services__modal-close'></i>
<h3 class="services__modal-title">Coming Soon...</h3>
<p class="services__modal-description">
Test Textr skjhte e
</p>
<ul class="services__modal-list">
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e
</p>
</li>
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e Test Textr skjhte e
</p>
</li>
<li class="services__modal-item">
<i class='bx bx-check services__modal-icon'></i>
<p class="services__modal-info">
Test Textr skjhte e
</p>
</li>
</ul>
</div>
</div>
<!--=============== Service Cards End ===============-->
<!--=============== End of SERVICES ===============-->
<br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/><br/>
</main>
<!--=============== GSAP ===============-->
<script src="https://cdnjs.cloudflare.com/ajax/libs/gsap/3.10.4/gsap.min.js"></script>
<!--=============== MAIN JS ===============-->
<script src="assets/js/main.js"></script>
</body>
</html></code></pre>
</div>
</div>
</p>
| [
{
"answer_id": 74324340,
"author": "Sigurd Mazanti",
"author_id": 14776809,
"author_profile": "https://Stackoverflow.com/users/14776809",
"pm_score": 2,
"selected": false,
"text": "onclick"
},
{
"answer_id": 74324855,
"author": "Abhay Bisht",
"author_id": 14343411,
"author_profile": "https://Stackoverflow.com/users/14343411",
"pm_score": 0,
"selected": false,
"text": ".scroll-fix {\nposition:fixed;\noverflow-y: hidden;\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324312",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/12683667/"
] |
74,324,317 | <p>I have a dataset of customer profiles where I am trying to capture how much revenue they generated until they cancelled their subscription. The issue I am having is that after the customer cancels their subscription, the customer profile still exists in the database and registers as being charged 0. I am trying to create a visualization that shows each customers lifespan in a table up until the month that they cancel.</p>
<h2>Here is the data I have:</h2>
<div class="s-table-container">
<table class="s-table">
<thead>
<tr>
<th>customer name</th>
<th>customer id</th>
<th>cancelled</th>
<th>charge date</th>
<th>charged amount</th>
</tr>
</thead>
<tbody>
<tr>
<td>gary</td>
<td>012</td>
<td>no</td>
<td>1/1/2022</td>
<td>199</td>
</tr>
<tr>
<td>gary</td>
<td>012</td>
<td>no</td>
<td>2/1/2022</td>
<td>199</td>
</tr>
<tr>
<td>gary</td>
<td>012</td>
<td>no</td>
<td>3/1/2022</td>
<td>199</td>
</tr>
<tr>
<td>gary</td>
<td>012</td>
<td>yes</td>
<td>4/1/2022</td>
<td>199</td>
</tr>
<tr>
<td>gary</td>
<td>012</td>
<td>no</td>
<td>5/1/2022</td>
<td>199</td>
</tr>
<tr>
<td>gary</td>
<td>012</td>
<td>no</td>
<td>6/1/2022</td>
<td>199</td>
</tr>
</tbody>
</table>
</div>
<p>I my desired output would select the first 4 lines above, and get rid of the last two.</p>
<p>I can pull up the data, but not sure where to go from there. So far I have:</p>
<pre><code>select
t.customer_name,
t.customer_id,
t.cancel_flag,
t.revenue_date,
a.revenue,
a.customer_id
from metrics t
inner join drp.mrr a
on t.customer_id= a.customer_id
</code></pre>
<p>Any ideas are much appreciated!!</p>
| [
{
"answer_id": 74324430,
"author": "The Impaler",
"author_id": 6436191,
"author_profile": "https://Stackoverflow.com/users/6436191",
"pm_score": 1,
"selected": false,
"text": "select *\nfrom (\n select\n t.customer_name,\n t.customer_id,\n t.cancel_flag,\n t.revenue_date,\n a.revenue,\n a.customer_id,\n max(t.cancel_flag) over(\n partition by t.customer_id \n order by t.revenue_date\n rows between unbounded preceding and 1 preceding\n ) as mc\n from metrics t\n inner join drp.daasity_mrr a on t.customer_id= a.customer_id\n) x\nwhere mc = 'no' or mc is null\n"
},
{
"answer_id": 74324491,
"author": "DannySlor",
"author_id": 19174570,
"author_profile": "https://Stackoverflow.com/users/19174570",
"pm_score": 0,
"selected": false,
"text": "select *\n ,sum(charged_amount) over(partition by customer_id order by charge_date) as running_total\nfrom\n(\nselect customer_name \n ,customer_id \n ,cancelled \n ,charge_date\n ,case when count(case when cancelled = 'yes' then 1 end) over(partition by customer_id order by charge_date) = 0 then charged_amount end as charged_amount\nfrom t\n) t\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324317",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20235204/"
] |
74,324,330 | <p>I tried to compose patten with regex, and tried to validate multiple strings. However, seems my patterns fine according to regex documentation, but some reason, some invalid string is not validated correctly. Can anyone point me out what is my mistakes here?</p>
<p><strong>test use case</strong></p>
<p>this is test use case for one input string:</p>
<pre><code>import re
usr_pat = r"^\$\w+_src_username_\w+$"
u_name='$ini_src_username_cdc_char4ec_pits'
m = re.match(usr_pat, u_name, re.M)
if m:
print("Valid username:", m.group())
else:
print("ERROR: Invalid user_name:\n", u_name)
</code></pre>
<p>I am expecting this return error because I am expecting input string must start with <code>$</code> sign, then one string <code>_\w+</code>, then <code>_</code>, then <code>src</code>, then <code>_</code>, then <code>user_name</code>, then <code>_</code>, then end with only one string <code>\w+</code>. this is how I composed my pattern and tried to validate the different input strings, but some reason, it is not parsed correctly. Did I miss something here? can anyone point me out here?</p>
<p><strong>desired output</strong></p>
<p>this is valid and invalid input:</p>
<p>valid:</p>
<pre><code>$ini_src_usrname_ajkc2e
$ini_src_password_ajkc2e
$ini_src_conn_url_ajkc2e
</code></pre>
<p>invalid:</p>
<pre><code>$ini_src_usrname_ajkc2e_chan4
$ini_src_password_ajkc2e_tst1
$ini_smi_src_conn_url_ajkc2e_tst2
ini_smi_src_conn_url_ajkc2e_tst2
$ini_src_usrname_ajkc2e_chan4_jpn3
</code></pre>
<p>according to regex documentation, <code>r"^\$\w+_src_username_\w+$"</code> this should capture the logic that I want to parse, but it is not working all my test case. what did I miss here? thanks</p>
| [
{
"answer_id": 74324379,
"author": "Micah Smith",
"author_id": 2514228,
"author_profile": "https://Stackoverflow.com/users/2514228",
"pm_score": 2,
"selected": true,
"text": "\\w"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324330",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/10708392/"
] |
74,324,372 | <p>How to get coefficients for ALL combinations of the variables of a multivariable polynomial using sympy.jl or another Julia package for symbolic computation?</p>
<p>Here is an example from MATLAB,</p>
<pre><code> syms a b y
[cxy, txy] = coeffs(ax^2 + by, [y x], ‘All’)
cxy =
[ 0, 0, b]
[ a, 0, 0]
txy =
[ x^2y, xy, y]
[ x^2, x, 1]
</code></pre>
<p>My goal is to get</p>
<pre><code>[ x^2y, xy, y]
[ x^2, x, 1]
</code></pre>
<p>instead of [x^2, y]</p>
<p>I asked the same question at
<a href="https://github.com/JuliaPy/SymPy.jl/issues/482" rel="nofollow noreferrer">https://github.com/JuliaPy/SymPy.jl/issues/482</a>
and
<a href="https://discourse.julialang.org/t/symply-jl-for-getting-coefficients-for-all-combination-of-the-variables-of-a-multivariable-polynomial/89091" rel="nofollow noreferrer">https://discourse.julialang.org/t/symply-jl-for-getting-coefficients-for-all-combination-of-the-variables-of-a-multivariable-polynomial/89091</a>
but I think I should ask if this can be done using Sympy.py.</p>
<p>Using Julia, I tried the following,</p>
<pre><code> julia> @syms x, y, a, b
julia> ff = sympy.Poly(ax^2 + by, (x,y))
Poly(ax**2 + by, x, y, domain='ZZ[a,b]')
julia> [prod(ff.gens.^i) for i in ff.monoms()]
2-element Vector{Sym}:
x^2
y
</code></pre>
| [
{
"answer_id": 74324501,
"author": "smichr",
"author_id": 1089161,
"author_profile": "https://Stackoverflow.com/users/1089161",
"pm_score": -1,
"selected": false,
"text": "a*x**2 + b*y + c"
},
{
"answer_id": 74331592,
"author": "Dan Getz",
"author_id": 3580870,
"author_profile": "https://Stackoverflow.com/users/3580870",
"pm_score": 2,
"selected": false,
"text": "Pipe.jl"
},
{
"answer_id": 74334330,
"author": "xyli",
"author_id": 20422196,
"author_profile": "https://Stackoverflow.com/users/20422196",
"pm_score": 0,
"selected": false,
"text": "using SymPy\n@syms x, y, z, a, b\n\nff = sympy.Poly(a*x^2 + b*y + z^2 + x*y + y*z, (x, y, z))\n\n[prod(ff.gens.^Tuple(I)) for I in CartesianIndices(tuple(UnitRange.(0,vec(reduce(max, hcat(collect.(ff.monoms())...), dims=1)))...))]\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324372",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20422196/"
] |
74,324,373 | <p>I am trying to make a Computer PIN cracking game in roblox.
But I don't know how to check how many digits the number value has, so I come here to ask.</p>
<p>If you guys want to play my game, <a href="https://web.roblox.com/games/11455612774/Computer-PIN-Cracking-Simulator" rel="nofollow noreferrer">Click Here</a></p>
<p>I just did this because I expect that nil can do the job, but no, they can't</p>
<pre><code>if game.ReplicatedStorage.Password.Value == {nil, nil, nil, nil} then
script.Parent.PlaceholderText = "Four Digits PIN"
elseif game.ReplicatedStorage.Password.Value == {nil, nil, nil, nil, nil, nil} then
script.Parent.PlaceholderText = "Six Digits PIN"
end
</code></pre>
| [
{
"answer_id": 74338136,
"author": "trico",
"author_id": 11760895,
"author_profile": "https://Stackoverflow.com/users/11760895",
"pm_score": 1,
"selected": true,
"text": "math.ceil(math.log(game.ReplicatedStorage.Password.Value))"
},
{
"answer_id": 74375177,
"author": "Kylaaa",
"author_id": 2860267,
"author_profile": "https://Stackoverflow.com/users/2860267",
"pm_score": 1,
"selected": false,
"text": "local password = game.ReplicatedStorage.Password.Value\n\nlocal passwordLength = #password\nassert(passwordLength > 0, \"The password cannot be empty\")\nlocal numberWords = {\n \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\"\n}\nlocal message = string.format(\"%s Digit PIN\", numberWords[passwordLength] or tostring(passwordLength))\n\nlocal Placeholder = script.Parent.Placeholder\nPlaceholder.Text = message\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324373",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20422121/"
] |
74,324,386 | <p>I am using the <a href="https://pub.dev/packages/flutter_riverpod" rel="nofollow noreferrer"><code>flutter_riverpod</code></a> package. I'm using it for a search field and it's showing an error when searching for something. I asked <a href="https://stackoverflow.com/q/74316651/16124033">a question</a> about the error but couldn't fix it. Is there any other way to create a search field in Flutter using the <a href="https://pub.dev/packages/flutter_riverpod" rel="nofollow noreferrer"><code>flutter_riverpod</code></a> package?</p>
<p>Here is some code:</p>
<p>User interface code:</p>
<pre><code>TextFormField(
…
onChanged: (search) => controller.updateSearch(search),
onSaved: (search) {
search == null ? null : controller.updateSearch(search);
},
),
</code></pre>
<hr />
<pre><code>itemBuilder: (context, index) {
if (mounted) {
return name.contains(state.search) ? ListTile(title: Text(name)) : Container();
}
return Container();
},
</code></pre>
<p>Controller code:</p>
<pre><code>class Controller extends StateNotifier<State> {
Controller() : super(State());
void updateSearch(String search) => state = state.copyWith(search: search);
}
final controllerProvider = StateNotifierProvider.autoDispose< Controller, State>((ref) {
return Controller();
});
</code></pre>
<p>State code:</p>
<pre><code>class State {
State({this.search = "", this.value = const AsyncValue.data(null)});
final String search;
final AsyncValue<void> value;
bool get isLoading => value.isLoading;
State copyWith({String? search, AsyncValue<void>? value}) {
return State(search: search ?? this.search, value: value ?? this.value);
}
}
</code></pre>
<p>Is there something wrong with the code above? If yes, what is the way to create the seach field using the <a href="https://pub.dev/packages/flutter_riverpod" rel="nofollow noreferrer"><code>flutter_riverpod</code></a> package? If not, why am I getting the error message (go to <a href="https://stackoverflow.com/q/74316651/16124033">this question</a> to see the error message)?</p>
<p>If I can't create a search field using the <a href="https://pub.dev/packages/flutter_riverpod" rel="nofollow noreferrer"><code>flutter_riverpod</code></a> package in Flutter, how can I create a search field (I hope maybe without using any package and without using <code>setState</code> function)?</p>
<p>Feel free to comment if you need more information!</p>
<p>How to fix this error? I would appreciate any help. Thank you in advance!</p>
<p>Update:</p>
<p>We can discuss in <a href="https://chat.stackoverflow.com/rooms/249359/create-a-search-field-in-flutter">this room</a>.</p>
| [
{
"answer_id": 74338136,
"author": "trico",
"author_id": 11760895,
"author_profile": "https://Stackoverflow.com/users/11760895",
"pm_score": 1,
"selected": true,
"text": "math.ceil(math.log(game.ReplicatedStorage.Password.Value))"
},
{
"answer_id": 74375177,
"author": "Kylaaa",
"author_id": 2860267,
"author_profile": "https://Stackoverflow.com/users/2860267",
"pm_score": 1,
"selected": false,
"text": "local password = game.ReplicatedStorage.Password.Value\n\nlocal passwordLength = #password\nassert(passwordLength > 0, \"The password cannot be empty\")\nlocal numberWords = {\n \"One\", \"Two\", \"Three\", \"Four\", \"Five\", \"Six\"\n}\nlocal message = string.format(\"%s Digit PIN\", numberWords[passwordLength] or tostring(passwordLength))\n\nlocal Placeholder = script.Parent.Placeholder\nPlaceholder.Text = message\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324386",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16124033/"
] |
74,324,402 | <p>I have two tables Transactions_Products(tref,prod_id) and Products(prod_id,prod_name,price).
How to find product_id of Products which is not in any of Transactions_Products.</p>
<p>I have tried using NOT IN but it didn't work as expected</p>
| [
{
"answer_id": 74324418,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 1,
"selected": false,
"text": "SELECT p.*\nFROM Products p\nWHERE NOT EXISTS (\n SELECT 1\n FROM Transactions_Products tp\n WHERE tp.prod_id = p.prod_id\n);\n"
},
{
"answer_id": 74326059,
"author": "Jonas Metzler",
"author_id": 18794826,
"author_profile": "https://Stackoverflow.com/users/18794826",
"pm_score": 0,
"selected": false,
"text": "NOT EXISTS"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324402",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/-1/"
] |
74,324,458 | <p>Flutter ,My Launcher is not working With Link Widget of Url Launcher.</p>
<pre class="lang-dart prettyprint-override"><code>final websiteUri = Uri.parse('https://flutter.dev');
Link(
uri: websiteUri,
target: LinkTarget.blank,
builder: (context, openLink) => TextButton(
onPressed: openLink,
child: Text(websiteUri.toString()),
),
)
</code></pre>
| [
{
"answer_id": 74324418,
"author": "Tim Biegeleisen",
"author_id": 1863229,
"author_profile": "https://Stackoverflow.com/users/1863229",
"pm_score": 1,
"selected": false,
"text": "SELECT p.*\nFROM Products p\nWHERE NOT EXISTS (\n SELECT 1\n FROM Transactions_Products tp\n WHERE tp.prod_id = p.prod_id\n);\n"
},
{
"answer_id": 74326059,
"author": "Jonas Metzler",
"author_id": 18794826,
"author_profile": "https://Stackoverflow.com/users/18794826",
"pm_score": 0,
"selected": false,
"text": "NOT EXISTS"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324458",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/2831255/"
] |
74,324,476 | <p>While running react native app I am getting following error:</p>
<p>`</p>
<blockquote>
<p>Task :app:mergeDebugNativeLibs FAILED</p>
</blockquote>
<p>Deprecated Gradle features were used in this build, making it incompatible with Gradle 7.0.
Use '--warning-mode all' to show the individual deprecation warnings.
See <a href="https://docs.gradle.org/6.9.2/userguide/command_line_interface.html#sec:command_line_warnings" rel="nofollow noreferrer">https://docs.gradle.org/6.9.2/userguide/command_line_interface.html#sec:command_line_warnings</a>
574 actionable tasks: 2 executed, 572 up-to-date</p>
<p>FAILURE: Build failed with an exception.</p>
<ul>
<li>What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.</li>
</ul>
<blockquote>
<p>A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
2 files found with path 'lib/armeabi-v7a/libfbjni.so' from inputs:
- C:\Users\nouman.gradle\caches\transforms-3\6ef14503de3c85fa1ab2aba364d580cc\transformed\jetified-react-native-0.71.0-rc.0-debug\jni
- C:\Users\nouman.gradle\caches\transforms-3\64faf76bb2f0142d731347d7bfff47d4\transformed\jetified-fbjni-0.3.0\jni
If you are using jniLibs and CMake IMPORTED targets, see
<a href="https://developer.android.com/r/tools/jniLibs-vs-imported-targets" rel="nofollow noreferrer">https://developer.android.com/r/tools/jniLibs-vs-imported-targets</a></p>
</blockquote>
<ul>
<li><p>Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.</p>
</li>
<li><p>Get more help at <a href="https://help.gradle.org" rel="nofollow noreferrer">https://help.gradle.org</a></p>
</li>
</ul>
<p>BUILD FAILED in 32s</p>
<p>error Failed to install the app. Make sure you have the Android development environment set up: <a href="https://reactnative.dev/docs/environment-setup" rel="nofollow noreferrer">https://reactnative.dev/docs/environment-setup</a>.
Error: Command failed: gradlew.bat app:installDebug -PreactNativeDevServerPort=8081</p>
<p>FAILURE: Build failed with an exception.</p>
<ul>
<li>What went wrong:
Execution failed for task ':app:mergeDebugNativeLibs'.</li>
</ul>
<blockquote>
<p>A failure occurred while executing com.android.build.gradle.internal.tasks.MergeJavaResWorkAction
2 files found with path 'lib/armeabi-v7a/libfbjni.so' from inputs:
- C:\Users\nouman.gradle\caches\transforms-3\6ef14503de3c85fa1ab2aba364d580cc\transformed\jetified-react-native-0.71.0-rc.0-debug\jni
- C:\Users\nouman.gradle\caches\transforms-3\64faf76bb2f0142d731347d7bfff47d4\transformed\jetified-fbjni-0.3.0\jni
If you are using jniLibs and CMake IMPORTED targets, see
<a href="https://developer.android.com/r/tools/jniLibs-vs-imported-targets" rel="nofollow noreferrer">https://developer.android.com/r/tools/jniLibs-vs-imported-targets</a></p>
</blockquote>
<ul>
<li><p>Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.</p>
</li>
<li><p>Get more help at <a href="https://help.gradle.org" rel="nofollow noreferrer">https://help.gradle.org</a></p>
</li>
</ul>
<p>BUILD FAILED in 32s</p>
<pre><code>at makeError (D:\BayQi-Customer-Mobile-App\node_modules\execa\index.js:174:9)
at D:\BayQi-Customer-Mobile-App\node_modules\execa\index.js:278:16
at processTicksAndRejections (node:internal/process/task_queues:96:5)
at async runOnAllDevices (D:\BayQi-Customer-Mobile-App\node_modules\react-native\node_modules\@react-native-community\cli-platform-android\build\commands\runAndroid\runOnAllDevices.js:94:5)
at async Command.handleAction (D:\BayQi-Customer-Mobile-App\node_modules\@react-native-community\cli\build\index.js:192:9)
</code></pre>
<p>info Run CLI with --verbose flag for more details.
`</p>
<p>I am trying to run my react native app in physical device but getting this error.
It was running okay but suddenly has stopped working</p>
| [
{
"answer_id": 74326754,
"author": "Kishan Vaghela",
"author_id": 3758898,
"author_profile": "https://Stackoverflow.com/users/3758898",
"pm_score": 3,
"selected": false,
"text": "android/build.gradle"
},
{
"answer_id": 74330992,
"author": "Sameed Sharif",
"author_id": 19221726,
"author_profile": "https://Stackoverflow.com/users/19221726",
"pm_score": 2,
"selected": false,
"text": "// Top-level build file where you can add configuration options common to all sub-projects/modules.\n\nbuildscript {\n // ...\n}\n\n\nallprojects {\n repositories {\n+ exclusiveContent {\n+ // We get React Native's Android binaries exclusively through npm,\n+ // from a local Maven repo inside node_modules/react-native/.\n+ // (The use of exclusiveContent prevents looking elsewhere like Maven Central\n+ // and potentially getting a wrong version.)\n+ filter {\n+ includeGroup \"com.facebook.react\"\n+ }\n+ forRepository {\n+ maven {\n+ url \"$rootDir/../node_modules/react-native/android\"\n+ }\n+ }\n+ }\n // ...\n }\n}"
},
{
"answer_id": 74331845,
"author": "Gopy Sankar",
"author_id": 5737776,
"author_profile": "https://Stackoverflow.com/users/5737776",
"pm_score": 1,
"selected": false,
"text": "com.facebook.react:react-native:+"
},
{
"answer_id": 74342654,
"author": "Ali Hasan",
"author_id": 10638877,
"author_profile": "https://Stackoverflow.com/users/10638877",
"pm_score": 0,
"selected": false,
"text": "allprojects {\nrepositories {\n ...\n exclusiveContent {\n // We get React Native's Android binaries exclusively through npm,\n // from a local Maven repo inside node_modules/react-native/.\n // (The use of exclusiveContent prevents looking elsewhere like Maven Central\n // and potentially getting a wrong version.)\n filter {\n includeGroup \"com.facebook.react\"\n }\n forRepository {\n maven {\n url \"$rootDir/../node_modules/react-native/android\"\n }\n }\n }\n}\n"
},
{
"answer_id": 74343440,
"author": "Ankit Agnihotri",
"author_id": 10849030,
"author_profile": "https://Stackoverflow.com/users/10849030",
"pm_score": 0,
"selected": false,
"text": "distributionUrl=https\\://services.gradle.org/distributions/gradle-6.9-all.zip\n\n"
},
{
"answer_id": 74390974,
"author": "Deni Al Farizi",
"author_id": 7789242,
"author_profile": "https://Stackoverflow.com/users/7789242",
"pm_score": 1,
"selected": false,
"text": "android {\n // yout existing code\n packagingOptions {\n pickFirst '**/libc++_shared.so'\n pickFirst '**/libfbjni.so'\n }\n}\n"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324476",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/16869852/"
] |
74,324,480 | <p>Say there's an existing function definition <code>.my.func:{[tbl;data] ...}</code> and I want to set the <code>upd</code> function to this lambda.</p>
<h3>Are the two lines below equivalent?</h3>
<pre><code>@[`.;`upd;:;.my.func]; / #1
`upd set .my.func; / #2
</code></pre>
<p>Asking because I see a lot of #1 in the codebase I work with, but #2 seems more succinct, so was wondering if they're somehow different.</p>
<hr />
<p>I checked <a href="https://code.kx.com/q/ref/amend/" rel="nofollow noreferrer">https://code.kx.com/q/ref/amend/</a>
"Amend at" <code>@[d; i; v; vy]</code></p>
<p>This seems to simply define the function <code>upd</code> in the global namespace.</p>
<ul>
<li>d = <code>`.</code></li>
<li>i = <code>`upd</code></li>
<li>v = <code>:</code></li>
<li>vy = <code>.my.func</code></li>
</ul>
<p>After running #1/#2 myself, <code>get`.</code> also seems to suggest #1/2 are equivalent.</p>
| [
{
"answer_id": 74325997,
"author": "Thomas Smyth - Treliant",
"author_id": 5620913,
"author_profile": "https://Stackoverflow.com/users/5620913",
"pm_score": 4,
"selected": true,
"text": "\\d"
},
{
"answer_id": 74355577,
"author": "cillianreilly",
"author_id": 12838568,
"author_profile": "https://Stackoverflow.com/users/12838568",
"pm_score": 2,
"selected": false,
"text": "@"
},
{
"answer_id": 74367938,
"author": "Igor Korkhov",
"author_id": 93462,
"author_profile": "https://Stackoverflow.com/users/93462",
"pm_score": 2,
"selected": false,
"text": "set"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324480",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/3927314/"
] |
74,324,525 | <h1>Question:</h1>
<p>A common year in the modern Gregorian Calendar consists of 365 days. In reality, Earth takes longer to rotate around the sun. To account for the difference in time, every 4 years, a leap year takes place. A leap year is when a year has 366 days: An extra day, February 29th. The requirements for a given year to be a leap year are:</p>
<ol>
<li><p>The year must be divisible by 4</p>
</li>
<li><p>If the year is a century year (1700, 1800, etc.), the year must be evenly divisible by 400; therefore, both 1700 and 1800 are not leap years</p>
</li>
</ol>
<p>Some example leap years are 1600, 1712, and 2016.</p>
<p>Write a program that takes in a year and determines the number of days in February for that year.</p>
<p>Ex: If the input is:</p>
<p>1712
the output is:</p>
<p>1712 has 29 days in February.
Ex: If the input is:</p>
<p>1913
the output is:</p>
<p>1913 has 28 days in February.
Your program must define and call the following function. The function should return the number of days in February for the input year.
def days_in_feb(user_year)</p>
<h1>Here is my code:</h1>
<pre><code>def days_in_feb(user_year):
user_year = int(input())
return user_year
if __name__ == '__main__':
user_year = int(input())
if (user_year % 4 == 0) or (user_year % 100 != 0):
print(f'{user_year} has 29 days in February.')
else:
print(f'{user_year} has 28 days in February.')
</code></pre>
<p>When I run it, I keep getting this error:</p>
<p><code>EOFError: EOF when reading a line</code></p>
<p>Please help.</p>
| [
{
"answer_id": 74325997,
"author": "Thomas Smyth - Treliant",
"author_id": 5620913,
"author_profile": "https://Stackoverflow.com/users/5620913",
"pm_score": 4,
"selected": true,
"text": "\\d"
},
{
"answer_id": 74355577,
"author": "cillianreilly",
"author_id": 12838568,
"author_profile": "https://Stackoverflow.com/users/12838568",
"pm_score": 2,
"selected": false,
"text": "@"
},
{
"answer_id": 74367938,
"author": "Igor Korkhov",
"author_id": 93462,
"author_profile": "https://Stackoverflow.com/users/93462",
"pm_score": 2,
"selected": false,
"text": "set"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324525",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/19999887/"
] |
74,324,558 | <p>How to determine if a column has two equal vowels in SQL Server?</p>
<p>For example <code>'maria'</code> has two <code>'a'</code> characters.</p>
<pre class="lang-sql prettyprint-override"><code>select
*
from
hr.locations
where
state_province is null
and
city like '...' <-- ?
</code></pre>
| [
{
"answer_id": 74325298,
"author": "Jonas Metzler",
"author_id": 18794826,
"author_profile": "https://Stackoverflow.com/users/18794826",
"pm_score": 2,
"selected": false,
"text": "SELECT yourcolumn\nFROM yourtable\nWHERE\nLEN (yourcolumn) - LEN(REPLACE(yourcolumn,'a','')) = 2\nOR LEN (yourcolumn) - LEN(REPLACE(yourcolumn,'e','')) = 2\nOR LEN (yourcolumn) - LEN(REPLACE(yourcolumn,'i','')) = 2\nOR LEN (yourcolumn) - LEN(REPLACE(yourcolumn,'o','')) = 2\nOR LEN (yourcolumn) - LEN(REPLACE(yourcolumn,'u','')) = 2;\n"
},
{
"answer_id": 74326354,
"author": "Thorsten Kettner",
"author_id": 2270762,
"author_profile": "https://Stackoverflow.com/users/2270762",
"pm_score": 3,
"selected": true,
"text": "city like '...'"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324558",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17474181/"
] |
74,324,565 | <p>I am trying to assign my APP with a static IP. I think I have assigned the IP, but I cannot reach the IP from outside either curl or the browser.</p>
<p>docker-compose.yaml</p>
<pre class="lang-yaml prettyprint-override"><code>version: '3.8'
services:
client:
container_name: client
build: ./frontend
ports:
- 3000:3000
working_dir: /app
volumes:
- ./frontend:/app/
- /app/node_modules
networks:
app_net:
ipv4_address: 172.16.238.10
hostname: client
command: npm run dev
networks:
app_net:
driver: bridge
ipam:
driver: default
config:
- subnet: "172.16.238.0/24"
</code></pre>
<p>Terminal message when I run it:</p>
<pre><code>client | > frontend@0.0.0 dev
client | > vite
client |
client |
client | VITE v3.2.2 ready in 710 ms
client |
client | ➜ Local: http://localhost:3000/
client | ➜ Network: http://172.16.238.10:3000/
</code></pre>
<p>I can reach <code>http://localhost:3000/</code> on the browser just fine. But whenever I try to reach <code>http://172.16.238.10:3000/</code>, I get a timeout. Something this on the browser:</p>
<pre><code>This site can’t be reached
172.16.238.10 took too long to respond.
ERR_CONNECTION_TIMED_OUT
</code></pre>
<p>I can curl to the IP I assigned inside the docker container, but I cannot do it from outside. Is it possible to expose the IP to the outside?</p>
| [
{
"answer_id": 74325298,
"author": "Jonas Metzler",
"author_id": 18794826,
"author_profile": "https://Stackoverflow.com/users/18794826",
"pm_score": 2,
"selected": false,
"text": "SELECT yourcolumn\nFROM yourtable\nWHERE\nLEN (yourcolumn) - LEN(REPLACE(yourcolumn,'a','')) = 2\nOR LEN (yourcolumn) - LEN(REPLACE(yourcolumn,'e','')) = 2\nOR LEN (yourcolumn) - LEN(REPLACE(yourcolumn,'i','')) = 2\nOR LEN (yourcolumn) - LEN(REPLACE(yourcolumn,'o','')) = 2\nOR LEN (yourcolumn) - LEN(REPLACE(yourcolumn,'u','')) = 2;\n"
},
{
"answer_id": 74326354,
"author": "Thorsten Kettner",
"author_id": 2270762,
"author_profile": "https://Stackoverflow.com/users/2270762",
"pm_score": 3,
"selected": true,
"text": "city like '...'"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324565",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/17312196/"
] |
74,324,585 | <pre><code>condition = True
classes = []
print("Welcome to class registration!")
def printClasses():
print("You are currently taking these courses: ")
for item in range(0, len(classes)):
print(item+1, ".", classes[item])
while condition:
if(len(classes) < 5):
course = str(input("What course(s) would you like to take?: \n"))
course = course.title()
course = str(course)
print(course)
print(len(classes))
classes = course.split(",")
for i in range(len(classes)):
classes[i] = classes[i].strip()
print(len(classes))
print(classes)
printClasses()
elif (len(classes) > 5):
removeClass = input("Please select a class to remove: \n")
removeClass = removeClass.title()
removeClass = str(removeClass)
removeClass = removeClass.strip()
classGone = []
classGone = removeClass.split(",")
for i in range(len(classGone)):
classGone[i] = classGone[i].strip()
for item in classGone:
removeClass = []
inputCheck = classGone.count(removeClass)
if inputCheck > 0:
classes.remove(item)
else:
print("Please select a class that exists...")
printClasses()
else:
print("Done!")
break
</code></pre>
<p>Im having trouble with my inputCheck statement. I need to be able to remove things from the list but they have to be on there.
Thank you!</p>
<p>I tried to make a iputCheck variable that checks the list for the input to make sure it matches something in the list, but it all went downhill.</p>
| [
{
"answer_id": 74325298,
"author": "Jonas Metzler",
"author_id": 18794826,
"author_profile": "https://Stackoverflow.com/users/18794826",
"pm_score": 2,
"selected": false,
"text": "SELECT yourcolumn\nFROM yourtable\nWHERE\nLEN (yourcolumn) - LEN(REPLACE(yourcolumn,'a','')) = 2\nOR LEN (yourcolumn) - LEN(REPLACE(yourcolumn,'e','')) = 2\nOR LEN (yourcolumn) - LEN(REPLACE(yourcolumn,'i','')) = 2\nOR LEN (yourcolumn) - LEN(REPLACE(yourcolumn,'o','')) = 2\nOR LEN (yourcolumn) - LEN(REPLACE(yourcolumn,'u','')) = 2;\n"
},
{
"answer_id": 74326354,
"author": "Thorsten Kettner",
"author_id": 2270762,
"author_profile": "https://Stackoverflow.com/users/2270762",
"pm_score": 3,
"selected": true,
"text": "city like '...'"
}
] | 2022/11/05 | [
"https://Stackoverflow.com/questions/74324585",
"https://Stackoverflow.com",
"https://Stackoverflow.com/users/20422434/"
] |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.