qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,169,130
<p>This is either a dumb question or one without an answer</p> <p>I want to call a function by using an element in an array as a way to match the function name. The elements of the array are, and may need to remain string.</p> <p>i.e</p> <pre><code> $(document).on('click', 'a', function() { var classes = $(this).attr('class'); var classesArr = classes.split(' '); arr[1](); }); function two() { console.log('hello'); } </code></pre> <pre><code> &lt;a href=&quot;foo&quot; class=&quot;one two three&quot;&gt;&lt;/a&gt; </code></pre> <p>obviously this doesn't work, and I get &quot;arr[1] is not a function&quot;. But is there a trick?</p>
[ { "answer_id": 74169139, "author": "flyingfox", "author_id": 3176419, "author_profile": "https://Stackoverflow.com/users/3176419", "pm_score": 3, "selected": true, "text": "var arr = ['one', 'two', 'three'];\neval(arr[1]+'()');\n\nfunction two() { console.log('hello'); }" }, { "a...
2022/10/23
[ "https://Stackoverflow.com/questions/74169130", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18305379/" ]
74,169,132
<p>I have a List that look like this:</p> <pre><code>&quot;workinghours&quot;: [ { &quot;shop&quot;: 31, &quot;weekday&quot;: &quot;monday&quot;, &quot;start_time&quot;: &quot;05:25 AM&quot;, &quot;end_time&quot;: &quot;11:00 AM&quot;, &quot;is_closed&quot;: false }, { &quot;shop&quot;: 31, &quot;weekday&quot;: &quot;monday&quot;, &quot;start_time&quot;: &quot;01:10 PM&quot;, &quot;end_time&quot;: &quot;05:00 PM&quot;, &quot;is_closed&quot;: false }, { &quot;shop&quot;: 31, &quot;weekday&quot;: &quot;tuesday&quot;, &quot;start_time&quot;: &quot;12:00 PM&quot;, &quot;end_time&quot;: &quot;05:00 PM&quot;, &quot;is_closed&quot;: false }, { &quot;shop&quot;: 31, &quot;weekday&quot;: &quot;tuesday&quot;, &quot;start_time&quot;: &quot;05:00 PM&quot;, &quot;end_time&quot;: &quot;10:00 PM&quot;, &quot;is_closed&quot;: false }, { &quot;shop&quot;: 31, &quot;weekday&quot;: &quot;tuesday&quot;, &quot;start_time&quot;: &quot;04:00 AM&quot;, &quot;end_time&quot;: &quot;05:00 PM&quot;, &quot;is_closed&quot;: false }, { &quot;shop&quot;: 31, &quot;weekday&quot;: &quot;wednesday&quot;, &quot;start_time&quot;: &quot;03:00 AM&quot;, &quot;end_time&quot;: &quot;11:00 AM&quot;, &quot;is_closed&quot;: false }, { &quot;shop&quot;: 31, &quot;weekday&quot;: &quot;wednesday&quot;, &quot;start_time&quot;: &quot;01:00 PM&quot;, &quot;end_time&quot;: &quot;11:00 AM&quot;, &quot;is_closed&quot;: false }, { &quot;shop&quot;: 31, &quot;weekday&quot;: &quot;wednesday&quot;, &quot;start_time&quot;: &quot;07:00 PM&quot;, &quot;end_time&quot;: &quot;11:00 PM&quot;, &quot;is_closed&quot;: false }, { &quot;shop&quot;: 31, &quot;weekday&quot;: &quot;thursday&quot;, &quot;start_time&quot;: &quot;06:00 AM&quot;, &quot;end_time&quot;: &quot;11:00 AM&quot;, &quot;is_closed&quot;: false }, { &quot;shop&quot;: 31, &quot;weekday&quot;: &quot;thursday&quot;, &quot;start_time&quot;: &quot;01:00 PM&quot;, &quot;end_time&quot;: &quot;05:00 PM&quot;, &quot;is_closed&quot;: false }, { &quot;shop&quot;: 31, &quot;weekday&quot;: &quot;thursday&quot;, &quot;start_time&quot;: &quot;07:00 PM&quot;, &quot;end_time&quot;: &quot;11:00 PM&quot;, &quot;is_closed&quot;: false }, { &quot;shop&quot;: 31, &quot;weekday&quot;: &quot;saturday&quot;, &quot;start_time&quot;: &quot;05:00 AM&quot;, &quot;end_time&quot;: &quot;12:00 PM&quot;, &quot;is_closed&quot;: false }, { &quot;shop&quot;: 31, &quot;weekday&quot;: &quot;saturday&quot;, &quot;start_time&quot;: &quot;01:00 PM&quot;, &quot;end_time&quot;: &quot;11:00 PM&quot;, &quot;is_closed&quot;: false }, { &quot;shop&quot;: 31, &quot;weekday&quot;: &quot;sunday&quot;, &quot;start_time&quot;: &quot;05:00 AM&quot;, &quot;end_time&quot;: &quot;11:00 PM&quot;, &quot;is_closed&quot;: false }, { &quot;shop&quot;: 31, &quot;weekday&quot;: &quot;sunday&quot;, &quot;start_time&quot;: &quot;02:10 PM&quot;, &quot;end_time&quot;: &quot;10:00 PM&quot;, &quot;is_closed&quot;: false } ], </code></pre> <p>Its basically a list of weekdays and the time which the shop open and closes. I need to convert this list to the below json model:</p> <pre><code>{ &quot;work_time&quot;: [ { &quot;shop_id&quot;: 11, &quot;week_day&quot;: &quot;monday&quot;, &quot;work_time&quot;: [ { &quot;id&quot;: 11, &quot;startTime&quot;: &quot;&quot;, &quot;endTime&quot;: &quot;&quot;, &quot;isClosed&quot;: true } ] }, { &quot;shop_id&quot;: 12, &quot;week_day&quot;: &quot;tuesday&quot;, &quot;work_time&quot;: [ { &quot;id&quot;: 12, &quot;startTime&quot;: &quot;&quot;, &quot;endTime&quot;: &quot;&quot;, &quot;isClosed&quot;: true }, { &quot;id&quot;: 12, &quot;startTime&quot;: &quot;&quot;, &quot;endTime&quot;: &quot;&quot;, &quot;isClosed&quot;: true } ] } ] } </code></pre> <p>And the model class is</p> <pre><code>ShopWorkTimeModel shopWorkTimeModelFromJson(String str) =&gt; ShopWorkTimeModel.fromJson(json.decode(str)); String shopWorkTimeModelToJson(ShopWorkTimeModel data) =&gt; json.encode(data.toJson()); class ShopWorkTimeModel { ShopWorkTimeModel({ this.workTime, }); List&lt;ShopWorkTimeModelWorkTime&gt; workTime; factory ShopWorkTimeModel.fromJson(Map&lt;String, dynamic&gt; json) =&gt; ShopWorkTimeModel( workTime: List&lt;ShopWorkTimeModelWorkTime&gt;.from(json[&quot;work_time&quot;].map((x) =&gt; ShopWorkTimeModelWorkTime.fromJson(x))), ); Map&lt;String, dynamic&gt; toJson() =&gt; { &quot;work_time&quot;: List&lt;dynamic&gt;.from(workTime.map((x) =&gt; x.toJson())), }; } class ShopWorkTimeModelWorkTime { ShopWorkTimeModelWorkTime({ this.workingHourId, this.weekDay, this.workTime, }); int workingHourId; String weekDay; List&lt;WorkTimeWorkTime&gt; workTime; factory ShopWorkTimeModelWorkTime.fromJson(Map&lt;String, dynamic&gt; json) =&gt; ShopWorkTimeModelWorkTime( workingHourId: json[&quot;working_hour_id&quot;], weekDay: json[&quot;week_day&quot;], workTime: List&lt;WorkTimeWorkTime&gt;.from(json[&quot;work_time&quot;].map((x) =&gt; WorkTimeWorkTime.fromJson(x))), ); Map&lt;String, dynamic&gt; toJson() =&gt; { &quot;working_hour_id&quot;: workingHourId, &quot;week_day&quot;: weekDay, &quot;work_time&quot;: List&lt;dynamic&gt;.from(workTime.map((x) =&gt; x.toJson())), }; } class WorkTimeWorkTime { WorkTimeWorkTime({ this.id, this.startTime, this.endTime, this.isClosed, }); int id; String startTime; String endTime; bool isClosed; factory WorkTimeWorkTime.fromJson(Map&lt;String, dynamic&gt; json) =&gt; WorkTimeWorkTime( id: json[&quot;id&quot;], startTime: json[&quot;startTime&quot;], endTime: json[&quot;endTime&quot;], isClosed: json[&quot;isClosed&quot;], ); Map&lt;String, dynamic&gt; toJson() =&gt; { &quot;id&quot;: id, &quot;startTime&quot;: startTime, &quot;endTime&quot;: endTime, &quot;isClosed&quot;: isClosed, }; } </code></pre> <p>How to parse the above json to this model class in dart. In the above json file the list contains weekdays more than one times, so i need to convert that by having one weekday and list all the working hours in a list below that weekdays as i mentioned in the above model class.</p>
[ { "answer_id": 74169185, "author": "Tanvir Ahmed", "author_id": 13256526, "author_profile": "https://Stackoverflow.com/users/13256526", "pm_score": 1, "selected": false, "text": "class dummy {\n List<WorkTime>? workTime;\n\n dummy({this.workTime});\n\n dummy.fromJson(Map<String, dynam...
2022/10/23
[ "https://Stackoverflow.com/questions/74169132", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17424991/" ]
74,169,146
<p><strong>I am trying to make my whole website fit into any display resolution. So for example when I load this website onto my phone it displays it accordingly. How do I fit all of this website content to any screen size? I tried using</strong></p> <pre><code>&lt;div style=&quot;background-color: white; width:105%; max-width:1920px; height:200px; margin-left:-8px; overflow: hidden;&quot; &gt; &lt;/div&gt; </code></pre> <p><strong>But I get an error, The bottom half of the content just disappears. How do I solve it?</strong></p> <hr /> <pre><code>&lt;!DOCTYPE html&gt; &lt;html&gt; &lt;title&gt; Hello &lt;/title&gt; &lt;head&gt; &lt;/head&gt; &lt;meta name='viewport' content=&quot;width=device-width, initial-scale=1&quot;&gt; &lt;style&gt; body { font-family: &quot;Arial&quot;; font-size: 30px; } .name{ overflow: hidden; border-right: .01em solid black; white-space: nowrap; animation: typing 2s forwards; font-size: 1.6rem; width: 0; } @keyframes typing { from { width: 0 } to { width: 100% } } .name { color: #04143A; text-align: center; font-size: 70px; font-weight: 600; margin: 0 } .info h3 { color: #4A90E2; text-align: center; font-weight: 100; font-size: 40px; margin: 0 } .skills_1 h3 { margin-left: 50px; color: #04143A; font-size: 30px; font-weight: 100 } .list-card { font-size: 20px; margin-left: 100px; } .list { color: #4A90E2; } .list-card p { color: #091F4E font-size: 20px; margin-left: 100px; display: inline-block; } br{ display: block; content: &quot;&quot;; margin-top: 0; } .job-title { font-size: 18px; vertical-align: top; background-color: #D9E7F8; color: #4A90E2; font-weight: 300; margin-top: 0px; margin-left: 10px; border-radius: 5px; display: inline-block; padding: 15px 25px; } &lt;/style&gt; &lt;body&gt; &lt;div class='intro'&gt; &lt;div class=&quot;first_last&quot;&gt; &lt;h1 class=&quot;name&quot;&gt; Prajwal Sharma &lt;/h1&gt; &lt;/div&gt; &lt;div class=&quot;info&quot;&gt; &lt;h3 class=&quot;email&quot;&gt;Welcome! &lt;span class=&quot;job-title&quot;&gt;Testing site&lt;/span&gt; &lt;/h3&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class='skills_1' &gt; &lt;h3&gt; Technical Skills &lt;/h3&gt; &lt;div&gt; &lt;div class=&quot;list-card&quot;&gt; &lt;div&gt; &lt;span class=&quot;list&quot;&gt;+ Hello&lt;/span&gt; &lt;p&gt;Programming Languages: HTML, Python, C++, JavaScript&lt;/p&gt; &lt;br&gt;&lt;/br&gt; &lt;span class=&quot;list&quot;&gt;+ Hello&lt;/span&gt; &lt;p&gt;Software Skills: Unity, Photoshop, PyCharm, VisualStudio&lt;/p&gt; &lt;br&gt;&lt;/br&gt; &lt;span class=&quot;list&quot;&gt;+ Hello&lt;/span&gt; &lt;p&gt;Programming Languages: HTML, Python, C++, JavaScript&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 74169185, "author": "Tanvir Ahmed", "author_id": 13256526, "author_profile": "https://Stackoverflow.com/users/13256526", "pm_score": 1, "selected": false, "text": "class dummy {\n List<WorkTime>? workTime;\n\n dummy({this.workTime});\n\n dummy.fromJson(Map<String, dynam...
2022/10/23
[ "https://Stackoverflow.com/questions/74169146", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20128133/" ]
74,169,235
<p>I have a sealed class like below,</p> <pre><code>sealed class ApiResult&lt;T&gt;( val data: T? = null, val errors: List&lt;Error&gt;? = null ) { class Success&lt;T&gt;(data: T?) : ApiResult&lt;T&gt;(data) class Failure&lt;T&gt;( errors: List&lt;Error&gt;, data: T? = null ) : ApiResult&lt;T&gt;(data, errors) } </code></pre> <p>And this is my Retrofit API interface,</p> <pre><code>interface Api { @POST(&quot;login&quot;) suspend fun login(@Body loginRequestDto: LoginRequestDto): ApiResult&lt;LoginResponseDto&gt; } </code></pre> <p>What I want to achieve is, internally wrap the LoginResponseDto in BaseResponseDto which has the success, error, and data fields. Then put them in the ApiResult class.</p> <pre><code>data class BaseResponseDto&lt;T&gt;( val success: Boolean, val errors: List&lt;Int&gt;, val data: T? ) </code></pre> <p>In this case, LoginResponseDto is my data class. So, Retrofit should internally wrap the LoginResponseDto in BaseResponseDto then I will create the ApiResult response in my custom call adapter. How can I tell Retrofit to internally wrap this? I don't want to include the BaseResponseDto in the API interface every time.</p>
[ { "answer_id": 74171785, "author": "Farhan Farooqui", "author_id": 4961874, "author_profile": "https://Stackoverflow.com/users/4961874", "pm_score": 2, "selected": true, "text": "class ApiConverter private constructor(\n private val gson: Gson\n) : Converter.Factory() {\n override ...
2022/10/23
[ "https://Stackoverflow.com/questions/74169235", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4961874/" ]
74,169,277
<p>I am trying to code a program which generates random passwords and saves it to a text file. I want program to keep running until it saves 100 random passwords to text file.</p> <p>I have created the password generator But whenever i try to save password its saves same password again and again.</p> <p>Can anyone help me to make a loop for saving 100 random passwords to text file ?</p>
[ { "answer_id": 74171785, "author": "Farhan Farooqui", "author_id": 4961874, "author_profile": "https://Stackoverflow.com/users/4961874", "pm_score": 2, "selected": true, "text": "class ApiConverter private constructor(\n private val gson: Gson\n) : Converter.Factory() {\n override ...
2022/10/23
[ "https://Stackoverflow.com/questions/74169277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18872346/" ]
74,169,290
<p>I'm trying to get the url of the minecraft skin through the api using python programming but I can't get the url, let's see if someone could</p> <p>This is the code I'm currently using...</p> <pre><code> import json import requests import base64 response = requests.get(f&quot;https://sessionserver.mojang.com/session/minecraft/profile/11f1cc006cc84499a174bc9b7fa1982a&quot;) id = response.json()[&quot;properties&quot;][0][&quot;value&quot;] #### msg = f&quot;{id}&quot; msg_bytes = msg.encode('ascii') base64_bytes = base64.b64decode(msg_bytes) base64_msg = base64_bytes.decode('ascii') print(base64_msg) </code></pre> <p>Thank you very much in advance!</p>
[ { "answer_id": 74171785, "author": "Farhan Farooqui", "author_id": 4961874, "author_profile": "https://Stackoverflow.com/users/4961874", "pm_score": 2, "selected": true, "text": "class ApiConverter private constructor(\n private val gson: Gson\n) : Converter.Factory() {\n override ...
2022/10/23
[ "https://Stackoverflow.com/questions/74169290", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20312881/" ]
74,169,300
<p>So I have this 3d array</p> <pre><code>x = np.zeros((9, 9)) </code></pre> <p>Output:</p> <pre><code>[[0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0] [0 0 0 0 0 0 0 0 0]] </code></pre> <p>and I want to change all of row <em>x</em> and column <em>y</em> into 1</p> <p>Desired output:</p> <pre><code>[[0 0 0 0 0 1 0 0 0] [0 0 0 0 0 1 0 0 0] [0 0 0 0 0 1 0 0 0] [1 1 1 1 1 1 1 1 1] [0 0 0 0 0 1 0 0 0] [0 0 0 0 0 1 0 0 0] [0 0 0 0 0 1 0 0 0] [0 0 0 0 0 1 0 0 0] [0 0 0 0 0 1 0 0 0]] </code></pre> <p>I am doing this on a 3d array with Booleans instead of 0s and 1s but I assume that the answers would be the same.</p>
[ { "answer_id": 74171785, "author": "Farhan Farooqui", "author_id": 4961874, "author_profile": "https://Stackoverflow.com/users/4961874", "pm_score": 2, "selected": true, "text": "class ApiConverter private constructor(\n private val gson: Gson\n) : Converter.Factory() {\n override ...
2022/10/23
[ "https://Stackoverflow.com/questions/74169300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19918389/" ]
74,169,313
<p>Since <code>std::format</code> isn't supported everywhere, and I didn't want another large dependency like <code>fmt</code>, I wanted to quickly roll my own <code>to_string</code> solution for a number of types. The following is the code.</p> <pre><code>#include &lt;ranges&gt; #include &lt;string&gt; #include &lt;concepts&gt; template&lt;typename Type&gt; constexpr std::string stringify(const Type &amp;data) noexcept; template&lt;typename Type&gt; requires std::integral&lt;Type&gt; constexpr std::string stringify(const Type &amp;data) noexcept { return std::to_string(data); } template&lt;typename Type&gt; constexpr std::string stringify_inner(const Type &amp;data) noexcept { return stringify(data); } template&lt;typename Type&gt; requires std::ranges::range&lt;Type&gt; constexpr std::string stringify_inner(const Type &amp;data) noexcept { return &quot;[&quot; + stringify(data) + &quot;]&quot;; } template&lt;typename Type&gt; requires std::ranges::range&lt;Type&gt; constexpr std::string stringify(const Type &amp;data) noexcept { std::string string; for (auto &amp;i : data) { string += stringify_inner(i); string += &quot;, &quot;; } string.pop_back(); string.pop_back(); return string; } </code></pre> <p>Now, if I write the following code, I get some nice output.</p> <pre><code>int main() { std::vector&lt;int&gt; a = { 1, 2, 3, 4 }; std::vector&lt;std::vector&lt;int&gt;&gt; b = {{ 1, 2 }, { 3, 4 }}; std::cout &lt;&lt; stringify(a) &lt;&lt; std::endl; std::cout &lt;&lt; stringify(b) &lt;&lt; std::endl; } // &gt;&gt;&gt; 1, 2, 3, 4 // &gt;&gt;&gt; [1, 2], [3, 4] </code></pre> <p>Now, for some reason, if I remove the <code>stringify&lt;std::vector&lt;int&gt;&gt;</code> call, the compiler fails to deduce the correct function.</p> <pre><code>int main() { // std::vector&lt;int&gt; a = { 1, 2, 3, 4 }; std::vector&lt;std::vector&lt;int&gt;&gt; b = {{ 1, 2 }, { 3, 4 }}; // std::cout &lt;&lt; stringify(a) &lt;&lt; std::endl; std::cout &lt;&lt; stringify(b) &lt;&lt; std::endl; } // &gt;&gt;&gt; undefined reference to `std::__cxx11::basic_string&lt;char, std::char_traits&lt;char&gt;, // &gt;&gt;&gt; std::allocator&lt;char&gt; &gt; stringify&lt;std::vector&lt;int, std::allocator&lt;int&gt; &gt; &gt;(std::vector&lt;int, // &gt;&gt;&gt; std::allocator&lt;int&gt; &gt; const&amp;)' </code></pre> <p>I think I understand what is happening here, but I don't know why exactly or how to fix it. It seems like the compiler needs the manual instantiation of <code>stringify&lt;std::vector&lt;int&gt;&gt;</code>, so that it can resolve <code>stringify&lt;std::vector&lt;std::vector&lt;int&gt;&gt;&gt;</code>.</p> <p>I've never encountered this behavior before and have no idea how to continue. I'm compiling with C++20, using GCC on Windows. Thanks.</p>
[ { "answer_id": 74169372, "author": "Enlico", "author_id": 5825294, "author_profile": "https://Stackoverflow.com/users/5825294", "pm_score": 1, "selected": false, "text": "stringify" }, { "answer_id": 74169421, "author": "fabian", "author_id": 2991525, "author_profile"...
2022/10/23
[ "https://Stackoverflow.com/questions/74169313", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16940505/" ]
74,169,353
<p>Here is a literal class that allows one to get a value of a specified type:</p> <pre><code>public class Literal { private final String value; public Literal(String value) { this.value = value; } public &lt;T&gt; T getValue(Class&lt;T&gt; type) { if (type == Boolean.class || type == Boolean.TYPE) { return type.cast(&quot;true&quot;.equalsIgnoreCase(value)); } throw new UnsupportedOperationException(); } } </code></pre> <p>It works fine for object types:</p> <pre><code>new Literal(&quot;true&quot;).getValue(Boolean.class); </code></pre> <p>But it throws the error for primitive types:</p> <pre><code>new Literal(&quot;true&quot;).getValue(Boolean.TYPE); </code></pre> <pre><code>java.lang.ClassCastException: Cannot cast java.lang.Boolean to boolean </code></pre> <p>Is it possible to return a boolean value without the exception?</p> <p>Or maybe I can transform a primitive type to a corresponding object type before calling the method? Is there a method to transform boolean type to java.lang.Boolean.class, int type to java.lang.Integer.class, ...? Something like this:</p> <pre><code>new Literal(&quot;true&quot;).getValue(toObjectType(Boolean.TYPE)); </code></pre>
[ { "answer_id": 74169448, "author": "rzwitserloot", "author_id": 768644, "author_profile": "https://Stackoverflow.com/users/768644", "pm_score": 2, "selected": false, "text": "Object o = 5;" }, { "answer_id": 74169653, "author": "F. Müller", "author_id": 1294283, "auth...
2022/10/23
[ "https://Stackoverflow.com/questions/74169353", "https://Stackoverflow.com", "https://Stackoverflow.com/users/632199/" ]
74,169,357
<p>I have got an error every time, this is because the mappingId is wrong, where I need to create/get mappingId? any solution.</p> <pre><code>{&quot;type&quot;:&quot;error.SuiteScriptError&quot;,&quot;name&quot;:&quot;CANT_FIND_SAVED_IMPORT&quot;,&quot;message&quot;:&quot;No saved import with internalId 123&quot;,&quot;stack&quot;:[&quot;createError(N/error.js)&quot;,&quot;&lt;anonymous&gt;(adhoc$-1$debugger.user:13)&quot;,&quot;&lt;anonymous&gt;(adhoc$-1$debugger.user:1)&quot;],&quot;cause&quot;:{&quot;type&quot;:&quot;internal error&quot;,&quot;code&quot;:&quot;CANT_FIND_SAVED_IMPORT&quot;,&quot;details&quot;:&quot;No saved import with internalId 123&quot;,&quot;userEvent&quot;:null,&quot;stackTrace&quot;:[&quot;createError(N/error.js)&quot;,&quot;&lt;anonymous&gt;(adhoc$-1$debugger.user:13)&quot;,&quot;&lt;anonymous&gt;(adhoc$-1$debugger.user:1)&quot;],&quot;notifyOff&quot;:false},&quot;id&quot;:&quot;&quot;,&quot;notifyOff&quot;:false,&quot;userFacing&quot;:false} </code></pre> <pre><code>require([&quot;N/task&quot;,&quot;N/file&quot;],function(task,file){ var fileObj = file.create({ name:&quot;temporary.csv&quot;, fileType:file.Type.CSV, contents: &quot;1,1&quot; }); var obj = task.create({taskType: task.TaskType.CSV_IMPORT}); obj.mappingId = 123; obj.importFile = fileObj; obj.name = &quot;TestingCSV&quot;; var objId = obj.submit(); log.debug(objId); }); </code></pre>
[ { "answer_id": 74208199, "author": "Mike Robbins", "author_id": 675137, "author_profile": "https://Stackoverflow.com/users/675137", "pm_score": 2, "selected": false, "text": "Setup > Import/Export > Import CSV Records" }, { "answer_id": 74214270, "author": "wozzarvl", "au...
2022/10/23
[ "https://Stackoverflow.com/questions/74169357", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12132850/" ]
74,169,361
<p>I'm using the featherlight lightbox to open iframes with different widths, please see the 1st 2 links on the fiddle below:</p> <p><a href="http://jsfiddle.net/sm123456/d5Lvw1rs/" rel="noreferrer">http://jsfiddle.net/sm123456/d5Lvw1rs/</a></p> <p>The issue is that I seem I cant seem to be able to make the iframe responsive ie. when the browser window goes below the iframe width, the iframe should switch to 100%.</p> <p>I've tried the code below which should work great, but doesn't, even when removing <code>data-featherlight-iframe-height=&quot;575&quot; data-featherlight-iframe-width=&quot;800&quot;.</code></p> <pre><code>data-featherlight-iframe-style=&quot;width: 100% !important; max-width: 800px !important;&quot; </code></pre> <p>Any assistance would be very much appreciated!</p>
[ { "answer_id": 74232514, "author": "DSDmark", "author_id": 16517581, "author_profile": "https://Stackoverflow.com/users/16517581", "pm_score": 0, "selected": false, "text": ".featherlight-iframe .featherlight-content{\n /* dimensions: 1140px prevents iframe from spanning the full ...
2022/10/23
[ "https://Stackoverflow.com/questions/74169361", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10782385/" ]
74,169,374
<pre><code> enum class Admin(myName:String, val id:Int, val age:Int){ ROOT_ADMIN (&quot;Pete&quot;, 1, 55), ACADEMIC_ADMIN(&quot;Jacob&quot;,11,56), DEPARTMENT_ADMIN(&quot;Robin&quot;,111,50), CLASS_ADMIN(&quot;Chris&quot;,1111,22) </code></pre> <p>To access the properties of objects of enum class <strong>Admin</strong>, when I type</p> <pre><code>Admin.CLASS_ADMIN.____ </code></pre> <p>Naturally, <code>myName</code> to come out in the IDE auto-complete is expected. But its not happening. But <code>id</code> and <code>age</code> does come as they have <code>val</code> keyword associated with them.</p> <p>But when I add <code>var</code> in front of myName, like:</p> <pre><code>enum class Admin(var myName:String, val id:Int, val age:Int) </code></pre> <p>I am now getting myName in auto-complete.</p> <p>What is the importance of <code>var</code> keyword here?</p> <p>Note: I am aware of the fact that when we declare variables with var or val keywords in constructor, it declares a property inside that class. But how this logic relates to this situation?</p>
[ { "answer_id": 74170145, "author": "Pemassi", "author_id": 8139410, "author_profile": "https://Stackoverflow.com/users/8139410", "pm_score": 0, "selected": false, "text": "enum class" }, { "answer_id": 74171077, "author": "Todd", "author_id": 49746, "author_profile": ...
2022/10/23
[ "https://Stackoverflow.com/questions/74169374", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17472695/" ]
74,169,390
<p>the log file is</p> <pre><code>Oct 01 [time] a Oct 02 [time] b Oct 03 [time] c . . . Oct 04 [time] d Oct 05 [time] e Oct 06 [time] f . . . Oct 28 [time] g Oct 29 [time] h Oct 30 [time] i </code></pre> <p>and it is really <strong>big</strong> ( millions of lines )</p> <p>I wanna to get logs between <code>Oct 01</code> and <code>Oct 30</code></p> <p>I can do it with gawk</p> <pre><code>gawk 'some conditions' filter.log </code></pre> <p>and it works correctly.</p> <p>and it return millions of log lines that is not good</p> <p>because I wanna to get it <strong>part by part</strong></p> <p>some thing like this</p> <pre><code>gawk 'some conditions' -limit 100 -offset 200 filter.log </code></pre> <p>and every time when I change <code>limit</code> and <code>offset</code></p> <p>I can get another part of that.</p> <p>How can I do that ?</p>
[ { "answer_id": 74170145, "author": "Pemassi", "author_id": 8139410, "author_profile": "https://Stackoverflow.com/users/8139410", "pm_score": 0, "selected": false, "text": "enum class" }, { "answer_id": 74171077, "author": "Todd", "author_id": 49746, "author_profile": ...
2022/10/23
[ "https://Stackoverflow.com/questions/74169390", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14952975/" ]
74,169,393
<p>I have a record with 2 params in it, its a compiler error while trying to pass the record as a <code>TestCase()</code>.</p> <pre><code> [Test] [TestCase( myRecord)] // here it complains public void StartGame_SingleValidGame( MyRecord myRecord) { var result = myObject.Foo(myRecord); Assert.IsTrue(result); } [SetUp] public void Setup() { var a = new Rec1(&quot;Abce&quot;, 0); var b = new Rec2(&quot;Xyz&quot;, 0); myRecord = new MyRecord(a, b); } </code></pre> <p>Does NUnit support <code>Records</code> ? or there were some issue while I fill the records in <code>[SetUp]</code> function ?</p>
[ { "answer_id": 74170145, "author": "Pemassi", "author_id": 8139410, "author_profile": "https://Stackoverflow.com/users/8139410", "pm_score": 0, "selected": false, "text": "enum class" }, { "answer_id": 74171077, "author": "Todd", "author_id": 49746, "author_profile": ...
2022/10/23
[ "https://Stackoverflow.com/questions/74169393", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2702996/" ]
74,169,396
<pre><code>class add: def add_me(self, *args): res = 0 for x in args: res += x return res print(add().add_me(1, 2, 3, 4, 5)) # 15 print(add.add_me(add(), 1, 2, 3, 4, 5)) # 15 print(add.add_me(1, 2, 3, 4, 5)) # 14 </code></pre> <p>calling add.add_me still allows me to call the method, even when add() is not properly instantiated, how come? Is add.add_me in this case a Static method without needing to instantiated add class?</p>
[ { "answer_id": 74170145, "author": "Pemassi", "author_id": 8139410, "author_profile": "https://Stackoverflow.com/users/8139410", "pm_score": 0, "selected": false, "text": "enum class" }, { "answer_id": 74171077, "author": "Todd", "author_id": 49746, "author_profile": ...
2022/10/23
[ "https://Stackoverflow.com/questions/74169396", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19756041/" ]
74,169,430
<p>I opened multiple netcdfs (each one corresponds to an hour 0-30hr) with xr.open_mfdataset('*.nc'). Now I have an extra dimension (time). I am considering one of my variables(u,v,w). I want to average u (time: 30 z: 200 y: 100 x: 100) over 24 hours instead of the whole time period I have. How can I do that?</p>
[ { "answer_id": 74174004, "author": "msi_gerva", "author_id": 1913367, "author_profile": "https://Stackoverflow.com/users/1913367", "pm_score": 0, "selected": false, "text": "#!/usr/bin/env ipython\n# ---------------------\nimport numpy as np\nimport xarray as xr\nimport datetime\n# -----...
2022/10/23
[ "https://Stackoverflow.com/questions/74169430", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20185959/" ]
74,169,457
<p><a href="https://i.stack.imgur.com/ry38F.png" rel="nofollow noreferrer">Loop</a></p> <p>how to loop this without using array? I'm clearly confuse in this in java module I don't know the solution ;-; I'm new to java pls helppp mee</p>
[ { "answer_id": 74169633, "author": "PentaMine", "author_id": 15674760, "author_profile": "https://Stackoverflow.com/users/15674760", "pm_score": 0, "selected": false, "text": "public class Main {\n public static void main(String[] args) {\n int outputNum = 0;\n for(int i...
2022/10/23
[ "https://Stackoverflow.com/questions/74169457", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19126644/" ]
74,169,479
<h2>I have long been declaring a lot more space for arrays during competitive programming.</h2> <pre class="lang-cpp prettyprint-override"><code>int pr[100010]; //for example </code></pre> <p>However, when I was trying to declare an array for a smaller space this morning, things went wrong.</p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt; using namespace std; int main() { int n; cin &gt;&gt; n; int pr[100]; //seems enough for(int i = 1; i &lt;= n; i++) { int x; cin &gt;&gt; x; pr[i] = pr[i-1] + x; } for(int i = 1; i &lt;= n; i++) cout &lt;&lt; pr[i] &lt;&lt; endl; return 0; } </code></pre> <p>You see, this program was for calculating the prefix sum of an array. The value for this array comes from input. <strong>The space for this array seems enough.</strong> But when I input these to my program and found that it occurs to a wrong output:</p> <pre><code>//the input: 5 1 2 3 4 5 //the output: 1875947561 1875947563 1875947566 1875947570 1875947575 </code></pre> <p>The array might just out of bounds. I thought. However, when I modified the space <code>100</code> to <code>10</code>, the answer was correct this time!</p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt; using namespace std; int main() { int n; cin &gt;&gt; n; int pr[10]; //smaller, but correct! for(int i = 1; i &lt;= n; i++) { int x; cin &gt;&gt; x; pr[i] = pr[i-1] + x; cout &lt;&lt; &quot;*&quot; &lt;&lt; pr[i] &lt;&lt; endl; } for(int i = 1; i &lt;= n; i++) cout &lt;&lt; pr[i] &lt;&lt; endl; return 0; } </code></pre> <pre><code>5 1 2 3 4 5 1 3 6 10 15 </code></pre> <p>It seems that the problem happend at here:</p> <pre class="lang-cpp prettyprint-override"><code>pr[i] = pr[i-1] + x; </code></pre> <p><strong>I know that the initial value of the array was 0, but why a smaller space works well and the higher space didn't ?</strong> The most interesting thing is that when I declare the array as a global variable, though small, the answer was correct?</p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt; using namespace std; int pr[1]; //such a tiny space but correct! int main() { int n; cin &gt;&gt; n; for(int i = 1; i &lt;= n; i++) { int x; cin &gt;&gt; x; pr[i] = pr[i-1] + x; } for(int i = 1; i &lt;= n; i++) cout &lt;&lt; pr[i] &lt;&lt; endl; return 0; } </code></pre> <p>The results:</p> <pre><code>//the input 5 1 2 3 4 5 //the output 1 3 6 10 15 </code></pre> <p>This problem confuses me a whole day, can someone help me? I can't fell asleep as the problem was still there :(</p>
[ { "answer_id": 74169496, "author": "John Zwinck", "author_id": 4323, "author_profile": "https://Stackoverflow.com/users/4323", "pm_score": 3, "selected": true, "text": "int pr[100]; //seems enough\nfor(int i = 1; i <= n; i++) {\n int x; cin >> x;\n\n pr[i] = pr[i-1] + x; // uniniti...
2022/10/23
[ "https://Stackoverflow.com/questions/74169479", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13257979/" ]
74,169,481
<p>I have the following scenario:</p> <pre><code>@Entity @Table(name = &quot;groups_supervisors&quot;) public class SupervisorEntity extends AbstractEntity { @ManyToOne @EqualsAndHashCode.Exclude @JoinColumn(name = &quot;group_id&quot;) KibanaAdGroupEntity kibanaAdGroup; //Another fields @Override public boolean equals(Object o) { if (this == o) return true; if (o == null || getClass() != o.getClass()) return false; SupervisorEntity that = (SupervisorEntity) o; if (!Objects.equals(id, that.id)) return false; if (kibanaAdGroup!=null &amp;&amp; !kibanaAdGroup.getId().equals(that.kibanaAdGroup.getId())) return false; if (!Objects.equals(name, that.name)) return false; if (!Objects.equals(updateDate, that.updateDate)) return false; return Objects.equals(dateAdd, that.dateAdd); } @Override public int hashCode() { int result = id.hashCode(); result = 31 * result + (kibanaAdGroup != null ? kibanaAdGroup.getId().hashCode() : 0); result = 31 * result + name.hashCode(); result = 31 * result + updateDate.hashCode(); result = 31 * result + dateAdd.hashCode(); return result; } } </code></pre> <pre><code>@Entity @Data @Table(name = &quot;ad_groups&quot;) public class KibanaAdGroupEntity extends AbstractEntity { @NotNull @Size(min = 2) @BatchSize(size = 10) @ToString.Exclude @OneToMany(mappedBy = &quot;kibanaAdGroup&quot;, cascade = {CascadeType.ALL}, orphanRemoval =true) Set&lt;SupervisorEntity&gt; supervisors; //Some other fields //Destroy releation public Set&lt;SupervisorEntity&gt; removeSupervisor(SupervisorEntity supervisor) { supervisors.remove(supervisor); supervisor.setKibanaAdGroup(null); return supervisors; } } </code></pre> <p>When I'm trying to perform following</p> <pre><code> @Transactional public void test() { var adGroup = adGroupRepository.findAll().stream().limit(1000).filter(adGr -&gt; adGr.getId() == 142) .findFirst().get(); var supervisor = adGroup.getSupervisors().iterator().next(); adGroup.removeSupervisor(supervisor); adGroupRepository.save(adGroup); } </code></pre> <p>expected that <code>adGroupRepository.save(adGroup)</code> will perform update cascade on <code>adGroup</code> and constraint <code>@Size(min = 2)</code> on <code>Set&lt;SupervisorEntity&gt; supervisors</code> will trigger an exception. I tried to debug <code>DefaultFlushEntityEventListener::dirtyCheck</code> , but I see that an old entity and new one one contain identical size of <code>supervisors</code> Please can any one clarify to me where I've mistaken and how to trigger update/checking of this constraint?</p> <p>UPD In logs and DB I see that supervisor was successfully deleted</p> <pre><code>2022-10-23 10:37:07.022 DEBUG [4b5430e5fcb074b6,4b5430e5fcb074b6] 93041 - [8080-exec-1] org.hibernate.SQL : \n delete \n from\n public.groups_supervisors \n where\n id=? Hibernate: delete from public.groups_supervisors where id=? </code></pre>
[ { "answer_id": 74169496, "author": "John Zwinck", "author_id": 4323, "author_profile": "https://Stackoverflow.com/users/4323", "pm_score": 3, "selected": true, "text": "int pr[100]; //seems enough\nfor(int i = 1; i <= n; i++) {\n int x; cin >> x;\n\n pr[i] = pr[i-1] + x; // uniniti...
2022/10/23
[ "https://Stackoverflow.com/questions/74169481", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11968705/" ]
74,169,483
<p>I am trying to use data science tool <code>kedro</code> according to <a href="https://kedro.readthedocs.io/en/stable/tutorial/visualise_pipeline.html" rel="nofollow noreferrer">this tutorial</a>.<br /> I followed the instruction(write config.yaml, node.py and pipeline.py etc) and do exactly the same as the documentation) and could run <code>kedro run</code> successfully.<br /> And next step, I tried <code>kedro viz</code> and could show the pipelines but I cannot see plotly chart.<br /> Here is the result of the visualization. Please see the left pane. I can see <code>Shuttle Passenger Capacity Plot</code> but it is not activated and plots does not show up.<br /> <a href="https://i.stack.imgur.com/rTeKe.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rTeKe.png" alt="enter image description here" /></a></p> <p>Also, I set <code>conf/base/catalog.yaml</code> to output json file to load for plotly but I cannot see any in <code>08_reporting</code> directory. This could be the cause of the issue?</p> <p><a href="https://i.stack.imgur.com/CAIhu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/CAIhu.png" alt="enter image description here" /></a></p> <h2>Update</h2> <p><code>nodes.py</code> and <code>pipeline.py</code> is located here. <a href="https://i.stack.imgur.com/dDzcK.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dDzcK.png" alt="enter image description here" /></a></p> <p><strong>nodes.py</strong></p> <pre><code>import pandas as pd def _is_true(x: pd.Series) -&gt; pd.Series: return x == &quot;t&quot; def _parse_percentage(x: pd.Series) -&gt; pd.Series: x = x.str.replace(&quot;%&quot;, &quot;&quot;) x = x.astype(float) / 100 return x def _parse_money(x: pd.Series) -&gt; pd.Series: x = x.str.replace(&quot;$&quot;, &quot;&quot;).str.replace(&quot;,&quot;, &quot;&quot;) x = x.astype(float) return x def preprocess_companies(companies: pd.DataFrame) -&gt; pd.DataFrame: &quot;&quot;&quot;Preprocesses the data for companies. Args: companies: Raw data. Returns: Preprocessed data, with `company_rating` converted to a float and `iata_approved` converted to boolean. &quot;&quot;&quot; companies[&quot;iata_approved&quot;] = _is_true(companies[&quot;iata_approved&quot;]) companies[&quot;company_rating&quot;] = _parse_percentage(companies[&quot;company_rating&quot;]) return companies def preprocess_shuttles(shuttles: pd.DataFrame) -&gt; pd.DataFrame: &quot;&quot;&quot;Preprocesses the data for shuttles. Args: shuttles: Raw data. Returns: Preprocessed data, with `price` converted to a float and `d_check_complete`, `moon_clearance_complete` converted to boolean. &quot;&quot;&quot; shuttles[&quot;d_check_complete&quot;] = _is_true(shuttles[&quot;d_check_complete&quot;]) shuttles[&quot;moon_clearance_complete&quot;] = _is_true(shuttles[&quot;moon_clearance_complete&quot;]) shuttles[&quot;price&quot;] = _parse_money(shuttles[&quot;price&quot;]) return shuttles def create_model_input_table( shuttles: pd.DataFrame, companies: pd.DataFrame, reviews: pd.DataFrame ) -&gt; pd.DataFrame: &quot;&quot;&quot;Combines all data to create a model input table. Args: shuttles: Preprocessed data for shuttles. companies: Preprocessed data for companies. reviews: Raw data for reviews. Returns: Model input table. &quot;&quot;&quot; rated_shuttles = shuttles.merge(reviews, left_on=&quot;id&quot;, right_on=&quot;shuttle_id&quot;) model_input_table = rated_shuttles.merge( companies, left_on=&quot;company_id&quot;, right_on=&quot;id&quot; ) model_input_table = model_input_table.dropna() return model_input_table import plotly.express as px import pandas as pd import plotly.graph_objects as go # the below function uses plotly.express def compare_passenger_capacity(preprocessed_shuttles: pd.DataFrame): fig = px.bar(data_frame=preprocessed_shuttles.groupby([&quot;shuttle_type&quot;]).mean().reset_index(), x=&quot;shuttle_type&quot;, y=&quot;passenger_capacity&quot;, ) return fig </code></pre> <p><strong>pipeline.py</strong></p> <pre><code>from kedro.pipeline import Pipeline, node from kedro.pipeline.modular_pipeline import pipeline from .nodes import create_model_input_table, preprocess_companies, preprocess_shuttles, compare_passenger_capacity def create_pipeline(**kwargs) -&gt; Pipeline: return pipeline( [ node( func=preprocess_companies, inputs=&quot;companies&quot;, outputs=&quot;preprocessed_companies&quot;, name=&quot;preprocess_companies_node&quot;, ), node( func=preprocess_shuttles, inputs=&quot;shuttles&quot;, outputs=&quot;preprocessed_shuttles&quot;, name=&quot;preprocess_shuttles_node&quot;, ), node( func=create_model_input_table, inputs=[&quot;preprocessed_shuttles&quot;, &quot;preprocessed_companies&quot;, &quot;reviews&quot;], outputs=&quot;model_input_table&quot;, name=&quot;create_model_input_table_node&quot;, ), node( func=compare_passenger_capacity, inputs=&quot;preprocessed_shuttles&quot;, outputs=&quot;shuttle_passenger_capacity_plot&quot;, ), ], namespace=&quot;data_processing&quot;, inputs=[&quot;companies&quot;, &quot;shuttles&quot;, &quot;reviews&quot;], outputs=&quot;model_input_table&quot;, ) </code></pre> <p>Reference: <a href="https://kedro.readthedocs.io/en/stable/tutorial/visualise_pipeline.html" rel="nofollow noreferrer">https://kedro.readthedocs.io/en/stable/tutorial/visualise_pipeline.html</a></p>
[ { "answer_id": 74206209, "author": "Ryo Matsuzaka", "author_id": 14855070, "author_profile": "https://Stackoverflow.com/users/14855070", "pm_score": 1, "selected": true, "text": "namespace=\"data_processing\",\ninputs=[\"companies\", \"shuttles\", \"reviews\"],\noutputs=\"model_input_tab...
2022/10/23
[ "https://Stackoverflow.com/questions/74169483", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14855070/" ]
74,169,495
<p>What i want to be able to do is to add items to an array if the Bool attached to them is true.</p> <p>For example : Here is my data model</p> <pre><code>struct ListModel: Identifiable, Hashable { var id = UUID() var name:String var amount:Int var code:String var users:[User] var items:[Item] } struct User: Identifiable, Hashable{ var id = UUID() var foreName:String var surName:String var username:String var pfp:String } struct Item:Identifiable, Hashable{ var id = UUID() var name:String var image:String? var showItem:Bool var amount:String } </code></pre> <p>and when an the property <code>showItem</code> is true i want to add it to a new array</p> <p>I have tried an approach like this</p> <pre><code>import SwiftUI struct ListTest: View { var list:ListModel @State var nonHiddenItems:[Item] = [] var body: some View { VStack{ ForEach(0..&lt;list.items.count){item in ItemView(item: list.items[item]) } } .onAppear(){ ForEach(0..&lt;list.items.count){item in if list.items[item].showItem == true{ nonHiddenItems.append(list.items[item]) } } } } } struct ListTest_Previews: PreviewProvider { static var previews: some View { ListTest(list: ListModel(name: &quot;Family Shopping&quot;, amount: 0, code: &quot;1001&quot;, users: [User(foreName: &quot;Elon&quot;, surName: &quot;Musk&quot;, username: &quot;Elon123&quot;, pfp: &quot;Musk&quot;), User(foreName: &quot;Jeff&quot;, surName: &quot;Bezos&quot;, username: &quot;Jefferey&quot;, pfp: &quot;Bezos&quot;)], items: [Item(name: &quot;Cheese&quot;, image: &quot;Pizza&quot;, showItem: true, amount: &quot;5g&quot;), Item(name: &quot;Ham&quot;, showItem: false, amount: &quot;5g&quot;)])) } } </code></pre> <p>But i get errors such as <code> Type '()' cannot conform to 'View'</code> on my <code>ForEach loop</code></p> <p>How can i fix m errors? Many Thanks Sean</p>
[ { "answer_id": 74169599, "author": "vadian", "author_id": 5044042, "author_profile": "https://Stackoverflow.com/users/5044042", "pm_score": 2, "selected": false, "text": "ForEach" }, { "answer_id": 74169625, "author": "workingdog support Ukraine", "author_id": 11969817, ...
2022/10/23
[ "https://Stackoverflow.com/questions/74169495", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17142046/" ]
74,169,504
<p>If I have this data frame:</p> <pre><code>df = pd.DataFrame( {&quot;A&quot;:[45,67,12,78,92,65,89,12,34,78], &quot;B&quot;:[&quot;h&quot;,&quot;b&quot;,&quot;f&quot;,&quot;d&quot;,&quot;e&quot;,&quot;t&quot;,&quot;y&quot;,&quot;p&quot;,&quot;w&quot;,&quot;q&quot;], &quot;C&quot;:[True,False,False,True,False,True,True,True,True,True]}) </code></pre> <p>How can I select 50% of the rows, so that column &quot;C&quot; is True in 90% of the selected rows and False in 10% of them?</p>
[ { "answer_id": 74169599, "author": "vadian", "author_id": 5044042, "author_profile": "https://Stackoverflow.com/users/5044042", "pm_score": 2, "selected": false, "text": "ForEach" }, { "answer_id": 74169625, "author": "workingdog support Ukraine", "author_id": 11969817, ...
2022/10/23
[ "https://Stackoverflow.com/questions/74169504", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13356545/" ]
74,169,525
<p>I have two compare to chars: '2' &lt; 'a'. I typed this into my console and it returned true. Why is that?</p>
[ { "answer_id": 74169567, "author": "Enlico", "author_id": 5825294, "author_profile": "https://Stackoverflow.com/users/5825294", "pm_score": 3, "selected": false, "text": "2" }, { "answer_id": 74170058, "author": "Francis King", "author_id": 9841104, "author_profile": ...
2022/10/23
[ "https://Stackoverflow.com/questions/74169525", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17917454/" ]
74,169,591
<p>I have a column <code>A,B,C,D</code>.<br /> A column has value <code>x1,x2,x3,x4,x5</code>.<br /> Create a column <code>x1,x2,x3,x4,x5</code> and print <code>1</code> if <code>B,C,D</code> has a duplication.</p> <p>Please provide an answer using pyspark or python pandas.</p> <p>Input</p> <pre><code>A B C D status_color X1 a b c red X2 a a b green X3 a a b red X4 a b c green </code></pre> <p>Output</p> <pre><code>B C D X1 X2 X3 X4 a b c red 0 0 green a a b 0 green red 0 </code></pre> <p>I tried to find duplicate of column and then create a column duplicate flag which prints status_color if other column are duplicated.</p> <pre><code>df['duplicate_flag']=df.duplicated(subset['B','C','D']) </code></pre> <p>My problem here I don't know to compare it with column <code>A</code> and print it in <code>X1,X2,X3,X4</code></p> <p>With the help of <code>get_dummies</code> it printed a duplicate value column as 1,0 but I need a status color column value to be printed instead of 1 and 0. Can anyone help me with this using python?</p>
[ { "answer_id": 74169753, "author": "Rabinzel", "author_id": 15521392, "author_profile": "https://Stackoverflow.com/users/15521392", "pm_score": 1, "selected": false, "text": "out = (\n df\n .join(\n pd.get_dummies(df.pop('A'))\n .mul(df.pop('status_color'),axis=0)\n ...
2022/10/23
[ "https://Stackoverflow.com/questions/74169591", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19606332/" ]
74,169,608
<p>I am have an idea on how I could get the time but its always in 24 hour format, how can I get it into being in a 12 hour format??</p> <p>any suggestions??</p>
[ { "answer_id": 74169685, "author": "Kirill Novikov", "author_id": 2791142, "author_profile": "https://Stackoverflow.com/users/2791142", "pm_score": 1, "selected": false, "text": "import DeviceInfo from 'react-native-device-info';\n\nDeviceInfo.getTimezone();\n" }, { "answer_id": ...
2022/10/23
[ "https://Stackoverflow.com/questions/74169608", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20254832/" ]
74,169,610
<p>I am having an Access Violation when my project tries to open up a separate form using the <code>.Show</code> command.</p> <p>The code is supposed to open the <code>login</code> form. But just outputs an Access Violation error.</p> <p>This is the code from the main form, and is run on its activation:</p> <pre><code>procedure TForm4.FormActivate(Sender: TObject); begin label1.BringToFront; DBMatch.Enabled := false; DBContestants.Enabled := false; btncreate.Enabled := false; DbNav.Enabled := false; login.Show; end; </code></pre> <p>The below code is the start of the <code>login</code> form:</p> <pre><code>unit login_form; interface uses Windows, Messages, SysUtils, Variants, Classes, Graphics, Controls, Forms, Dialogs ,StdCtrls, ExtCtrls, unit4,pngimage; type Tlogin = class(TForm) edit_username: TEdit; edit_password: TEdit; btnlogin: TButton; btnForgotten: TButton; lUsername: TLabel; LPassword: TLabel; Imageside: TImage; procedure btnloginClick(Sender: TObject); procedure FormActivate(Sender: TObject); private { Private declarations } public end; var login: Tlogin; password,result:string; implementation {$R *.dfm} uses dmChess_u; </code></pre> <p>This is one of the errors on the main form</p> <p><a href="https://i.stack.imgur.com/HqkU8.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/HqkU8.png" alt="Images of the main file for the program" /></a></p>
[ { "answer_id": 74173233, "author": "Remy Lebeau", "author_id": 65863, "author_profile": "https://Stackoverflow.com/users/65863", "pm_score": 4, "selected": true, "text": "Form4" }, { "answer_id": 74174846, "author": "Ineffable21", "author_id": 19733965, "author_profil...
2022/10/23
[ "https://Stackoverflow.com/questions/74169610", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20313080/" ]
74,169,623
<p>How do I add a symbol (e.g. &gt;) to the end of a component from Material UI? i.e. It looks like this:</p> <p><a href="https://i.stack.imgur.com/iEF6B.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/iEF6B.png" alt="enter image description here" /></a></p> <p>Currently, my code looks something like this:</p> <pre><code>&lt;Link&gt; Learn more &amp;gt; &lt;/Link&gt; </code></pre> <p>But I want it to end up looking like this without adding &quot;&gt;&quot; into the HTML:</p> <pre><code>&lt;Link xxx&gt; Learn more &lt;/Link&gt; </code></pre>
[ { "answer_id": 74169673, "author": "Braxton Goss", "author_id": 11777708, "author_profile": "https://Stackoverflow.com/users/11777708", "pm_score": 0, "selected": false, "text": "const linkSymbol = \">\";\n\nreturn ( \n <Link props> \n Learn More {linkSymbol}\n </Link>\n)\n" }, ...
2022/10/23
[ "https://Stackoverflow.com/questions/74169623", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11784307/" ]
74,169,638
<p>I saw the following question on here regarding repeating values: <a href="https://stackoverflow.com/q/74167929/12634230">List number of lessons including half lessons based on Number of lessons and lesson name</a></p> <p>This question needed an older Excel version, I liked the problem statement and liked searching for a solution including new Excel formulas.</p> <p>We have the following data:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th></th> <th>A</th> <th>B</th> </tr> </thead> <tbody> <tr> <td><em>1</em></td> <td>1</td> <td>w</td> </tr> <tr> <td><em>2</em></td> <td>5</td> <td>e</td> </tr> <tr> <td><em>3</em></td> <td>4.5</td> <td>o</td> </tr> <tr> <td><em>4</em></td> <td>2.5</td> <td>Win</td> </tr> <tr> <td><em>5</em></td> <td>1.5</td> <td>pp</td> </tr> </tbody> </table> </div> <p>The idea is to repeat the value of column B the number of times mentioned in column A. The challenge is that column A could also contain non-integers (<code>0.5</code>-values only). If a <code>0.5</code>-value is used it should repeat the value in column B the number of integers in A and show <code>0.5 </code> and the text value stacked with <code>0.5 </code> and the next text value.</p> <p>In this case the expected result would be:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>expected</th> </tr> </thead> <tbody> <tr> <td>w</td> </tr> <tr> <td>e</td> </tr> <tr> <td>e</td> </tr> <tr> <td>e</td> </tr> <tr> <td>e</td> </tr> <tr> <td>e</td> </tr> <tr> <td>o</td> </tr> <tr> <td>o</td> </tr> <tr> <td>o</td> </tr> <tr> <td>o</td> </tr> <tr> <td>0.5 o, 0.5 Win</td> </tr> <tr> <td>Win</td> </tr> <tr> <td>Win</td> </tr> <tr> <td>pp</td> </tr> <tr> <td>0.5 pp</td> </tr> </tbody> </table> </div> <p>I managed to get a working solution in Office 365:</p> <pre><code>=LET( data,A1:B5, A,INDEX(data,,1), B,INDEX(data,,2), s,SCAN(0,A,LAMBDA(a,b,a+b)), si,INT(s), sr,ROUNDUP(s,0), sm,SEQUENCE(MAX(sr)), mr,XMATCH(sm,sr,1), mi,XMATCH(sm,si,1), IFERROR( IF(mr=mi, INDEX(B,mr,), &quot;0.5 &quot;&amp;INDEX(B,mr,)&amp;&quot;, 0.5 &quot;&amp;INDEX(B,mi)), &quot;0.5 &quot;&amp;INDEX(B,mr,))) </code></pre> <p>and Tony got an answer using FILTERXML coming real close in the original question: <code>=FILTERXML(REPLACE(CONCAT(REPT(&quot;&lt;/c&gt;&lt;c&gt;&quot; &amp; B2:B6,FLOOR(A2:A6,1)) &amp; IF(A2:A6-INT(A2:A6)&gt;0,&quot;&lt;/c&gt;&lt;c&gt;&quot; &amp; A2:A6-INT(A2:A6) &amp; B2:B6,&quot;&quot;)),2,2,&quot;p&quot;)&amp;&quot;&lt;/c&gt;&lt;/p&gt;&quot;,&quot;//c&quot;)</code></p> <p>Would this be realisable in Excel 2013?</p>
[ { "answer_id": 74170011, "author": "JvdV", "author_id": 9758194, "author_profile": "https://Stackoverflow.com/users/9758194", "pm_score": 2, "selected": false, "text": "CONCAT()" }, { "answer_id": 74173591, "author": "P.b", "author_id": 12634230, "author_profile": "ht...
2022/10/23
[ "https://Stackoverflow.com/questions/74169638", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12634230/" ]
74,169,647
<p><strong>Routes.php</strong></p> <p>while routing to other routes this error showed up</p> <blockquote> <p>The requested URL was not found on this server</p> </blockquote> <p>why do I get this error?</p> <p>In routes.php setAutoRoute is set to &quot;true&quot; but the routes did not connect to the controllers. Main root D:/xampp/htdocs/cresentLake/</p> <pre><code>&lt;?php namespace Config; // Create a new instance of our RouteCollection class. $routes = Services::routes(); // Load the system's routing file first, so that the app and ENVIRONMENT // can override as needed. if (file_exists(SYSTEMPATH . 'Config/Routes.php')) { require SYSTEMPATH . 'Config/Routes.php'; } /** * -------------------------------------------------------------------- * Router Setup * -------------------------------------------------------------------- */ $routes-&gt;setDefaultNamespace('App\Controllers'); $routes-&gt;setDefaultController('Home'); $routes-&gt;setDefaultMethod('index'); $routes-&gt;setTranslateURIDashes(false); $routes-&gt;set404Override(); $routes-&gt;setAutoRoute(true); /* * -------------------------------------------------------------------- * Route Definitions * -------------------------------------------------------------------- */ // We get a performance increase by specifying the default // route since we don't have to scan directories. $routes-&gt;get('/', 'Home::index'); $routes-&gt;add('login', 'Home::login'); $routes-&gt;add('change-password/(.*)', 'Home::change_password'); $routes-&gt;add('logout', 'Home::logout'); $routes-&gt;add('available_inventory', 'Inventory::available_inventory'); $routes-&gt;add('sold_inventory', 'Inventory::sold_inventory'); $routes-&gt;add('reserved_inventory', 'Inventory::reserved_inventory'); $routes-&gt;add('agent_deal', 'Inventory::agent_deal'); $routes-&gt;add('employee_deal', 'Inventory::employee_deal'); /* * -------------------------------------------------------------------- * Additional Routing * -------------------------------------------------------------------- * * There will often be times that you need additional routing and you * need it to be able to override any defaults in this file. Environment * based routes is one such time. require() additional route files here * to make that happen. * * You will have access to the $routes object within that file without * needing to reload it. */ if (file_exists(APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php')) { require APPPATH . 'Config/' . ENVIRONMENT . '/Routes.php'; } </code></pre>
[ { "answer_id": 74170011, "author": "JvdV", "author_id": 9758194, "author_profile": "https://Stackoverflow.com/users/9758194", "pm_score": 2, "selected": false, "text": "CONCAT()" }, { "answer_id": 74173591, "author": "P.b", "author_id": 12634230, "author_profile": "ht...
2022/10/23
[ "https://Stackoverflow.com/questions/74169647", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19735012/" ]
74,169,663
<p>I am trying to make a function call from a choice of two functions based on the variable 't' value. But &quot;float() argument must be a string or a number, not 'function'&quot; comes up. Please help.</p> <pre><code>import numpy as np import sympy as sym import matplotlib.pyplot as plt n = 9 t = np.linspace(0,10,n) u = np.linspace(0.0,n) v = np.linspace(0.0,n) a = np.linspace(0.0,n) def T_td(t,utd,vtd): t = sym.symbols('t') y = utd*sym.sin(5*t) + vtd*sym.cos(5*t) yp = y.diff(t) ypp = yp.diff(t) j = sym.lambdify(t,y) k = sym.lambdify(t,yp) l = sym.lambdify(t,ypp) return j,k,l def td_T(t): t = sym.symbols('t') y = sym.sin(5*t) + sym.cos(5*t) yp = y.diff(t) ypp = yp.diff(t) j = sym.lambdify(t,y) k = sym.lambdify(t,yp) l = sym.lambdify(t,ypp) return j,k,l def func(t,utd,vtd): if t &lt; 5: u,v,a = td_T(t) utd = 0 vtd = 0 elif t == 5: u,v,a = td_T(t) utd = u vtd = v else: u,v,a = T_td(t,utd,vtd) return u,v,a,utd,vtd #print(t) for i in range(0,n,1): u[i],v[i],a[i],u_td,v_td = func(t[i],0,0) </code></pre>
[ { "answer_id": 74170011, "author": "JvdV", "author_id": 9758194, "author_profile": "https://Stackoverflow.com/users/9758194", "pm_score": 2, "selected": false, "text": "CONCAT()" }, { "answer_id": 74173591, "author": "P.b", "author_id": 12634230, "author_profile": "ht...
2022/10/23
[ "https://Stackoverflow.com/questions/74169663", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20313199/" ]
74,169,668
<p>What would be the type which I have defined as any? I have tried TQueryFnData as per the RQ docs. but get <code>Cannot find name 'TQueryFnData'</code></p> <pre><code>export const useFetchUser = (userID: string | undefined) =&gt; { return useQuery&lt;any, Error&gt;([users.fetchUser, userID], () =&gt; axios.get(`https://jsonplaceholder.typicode.com/users/${userID}`) .then(response =&gt; response.data)) } </code></pre> <p>An example of the data returned is: <code>https://jsonplaceholder.typicode.com/users/1</code></p> <pre><code>export interface Users { id: number, name: string, username: string, email: string, address: Address, phone: string, website: string, company: Company } export interface Address { ... } export interface Geo { ... } export interface Company { ... } </code></pre>
[ { "answer_id": 74169787, "author": "Besnik Korça", "author_id": 13305073, "author_profile": "https://Stackoverflow.com/users/13305073", "pm_score": 1, "selected": false, "text": "export interface Users\n// to\nexport interface User\n" }, { "answer_id": 74247096, "author": "Tk...
2022/10/23
[ "https://Stackoverflow.com/questions/74169668", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19932692/" ]
74,169,675
<p>I load this json to Spark dataframe without specifying schema:</p> <pre><code>{ &quot;titles&quot;: { &quot;L&quot;: [ { &quot;S&quot;: &quot;ABC&quot; } ] } } </code></pre> <p>The result of df.printSchema() is</p> <pre><code>root |-- titles: struct (nullable = true) | |-- L: array (nullable = true) | | |-- element: struct (containsNull = true) | | | |-- S: string (nullable = true) </code></pre> <p>I tried and failed to translate this json schema to the code as below:</p> <pre><code>AS = StructType([StructField (&quot;L&quot;, ArrayType(StructField(&quot;S&quot;, StringType(), True)) ) ]) my_schema = StructType([ StructField(&quot;titles&quot;, AS ,True) ]) </code></pre> <p>I tried to use my_schema to read the same json and got the error:</p> <p>&quot;Failed to convert the JSON string '{&quot;metadata&quot;:{},&quot;name&quot;:&quot;S&quot;,&quot;nullable&quot;:true,&quot;type&quot;:&quot;string&quot;}' to a data type&quot;.</p> <p>How to fix it?</p>
[ { "answer_id": 74169787, "author": "Besnik Korça", "author_id": 13305073, "author_profile": "https://Stackoverflow.com/users/13305073", "pm_score": 1, "selected": false, "text": "export interface Users\n// to\nexport interface User\n" }, { "answer_id": 74247096, "author": "Tk...
2022/10/23
[ "https://Stackoverflow.com/questions/74169675", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3440012/" ]
74,169,682
<p>This is my code I've been working on for a couple of hours, I can't get it to compare the two passwords, it will submit the form even if the passwords don't match. It does not return any alert message either way. I've tried doing (pass1.value == pass2.value) too, it didn't work.</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>strong text alert ("Welcome"); function enableButton(){ if (document.getElementById("checkb").checked) { document.getElementById("btn").disabled = false; } else { document.getElementById("btn").disabled = true; } } function checkPassword() { var pass1= document.getElementById("pw").value ; var pass2= document.getElementById("pw2").value ; if ( pass1 == pass2 ) { alert ("Passwords match") ; return true; } else { alert ("Passwords do not match"); return false; } }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;title&gt; Sign up &lt;/title&gt; &lt;link rel = "stylesheet" href = "registration.css"&gt; &lt;script src = "registration.js"&gt;&lt;/script&gt; &lt;noscript&gt; Sorry, your browser does not support Javascript! &lt;/noscript&gt; &lt;/head&gt; &lt;body&gt; &lt;header style = " background-color : #f0e68c" &gt; &lt;div class = "logo"&gt; &lt;a href = "#"&gt;&lt;img src = "logo.png" style = "width : 130px ; height : 130px"&gt; &lt;/a&gt; &lt;/div&gt; &lt;ul class = "menu"&gt; &lt;a href="#" &gt;&lt;li class = "menu1"&gt; Home &lt;/li&gt; &lt;/a&gt; &lt;a href="#"&gt;&lt;li class = "menu1"&gt; About us &lt;/li&gt; &lt;/a&gt; &lt;a href="#"&gt;&lt;li class = "menu1"&gt; Blog &lt;/li&gt; &lt;/a&gt; &lt;a href="#"&gt;&lt;li class = "menu1"&gt; Book an Appointment &lt;/li&gt; &lt;/a&gt; &lt;a href="#"&gt;&lt;li class = "menu1"&gt; Contact us &lt;/li&gt;&lt;/a&gt; &lt;/ul&gt; &lt;br&gt; &lt;/header&gt; &lt;div class = "heading"&gt; &lt;h1&gt; Sign Up &lt;/h1&gt; &lt;div&gt; &lt;div class = "form" align = "center"&gt; &lt;form&gt; &lt;fieldset&gt; &lt;div class = "left"&gt; &lt;label for = "fname"&gt; First Name &lt;/label&gt;&lt;br&gt; &lt;input type = "text" id = "fname" name = "fname" required&gt; &lt;/div&gt; &lt;div class = "left"&gt; &lt;label for = "lname"&gt; Last Name &lt;/label&gt;&lt;br&gt; &lt;input type = "text" id = "lname" name = "lname" required&gt; &lt;/div&gt; &lt;div class = "clear"&gt; &amp;nbsp; &lt;/div&gt; &lt;div class = "left"&gt; &lt;label for = "email"&gt; E-mail &lt;/label&gt;&lt;br&gt; &lt;input type = "email" id = "email" name = "email" required&gt; &lt;/div&gt; &lt;div class = "clear"&gt; &amp;nbsp; &lt;/div&gt; &lt;div class = "left"&gt; &lt;label for = "pw"&gt; Password &lt;/label&gt;&lt;br&gt; &lt;input type = "password" id = "pw" min = "6" max = "25" pattern = "(?=.*\d)(?=.*[a-z])(?=.*[A-Z]).{6,25}" title="Password should contain Uppercase letters, lowercase letters, numbers, minimum 6 and maximum 25 characters " required&gt; &lt;/div&gt; &lt;div class = "left"&gt; &lt;label for = "confpw"&gt; Confirm password &lt;/label&gt;&lt;br&gt; &lt;input type = "password" id = "pw2" required&gt; &lt;/div&gt; &lt;div class = "clear"&gt; &amp;nbsp; &lt;/div&gt; &lt;input type = "checkbox" id = "checkb" name = "checkb" onclick = "enableButton()" required&gt; I agree to the rules and privacy policy&lt;br&gt;&lt;br&gt; &lt;input type = "checkbox"&gt; I want to recieve updates by mail &lt;br&gt; &lt;input type = "checkbox"&gt; Subscribe for monthly newsletter &lt;br&gt;&lt;br&gt; &lt;div class = "clear"&gt; &amp;nbsp; &lt;/div&gt; &lt;a href = "#"&gt;&lt;input type = "submit" id = "btn" value = "sign up"&gt;&lt;/a&gt; &lt;/fieldset&gt; &lt;/form&gt; &lt;/div&gt; &lt;/html&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74169787, "author": "Besnik Korça", "author_id": 13305073, "author_profile": "https://Stackoverflow.com/users/13305073", "pm_score": 1, "selected": false, "text": "export interface Users\n// to\nexport interface User\n" }, { "answer_id": 74247096, "author": "Tk...
2022/10/23
[ "https://Stackoverflow.com/questions/74169682", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20313183/" ]
74,169,691
<p>I want to ask, how to create new column based on the occurence of a certain value in a certain column</p> <p>This is the example :</p> <p>I have this DF:</p> <pre><code>example_twins #&gt; # A tibble: 4 × 2 #&gt; family name #&gt; &lt;chr&gt; &lt;chr&gt; #&gt; 1 Kelly Mark #&gt; 2 Kelly Scott #&gt; 3 Quin Tegan #&gt; 4 Quin Sara </code></pre> <p>I wanted to count family name into new Order in new Column (n)</p> <pre><code> example_twins #&gt; # A tibble: 4 × 3 #&gt; family name n #&gt; &lt;chr&gt; &lt;chr&gt; &lt;dbl&gt; #&gt; 1 Kelly Mark 1 #&gt; 2 Kelly Scott 2 #&gt; 3 Quin Tegan 1 #&gt; 4 Quin Sara 2 </code></pre> <p>Thank You!</p>
[ { "answer_id": 74169787, "author": "Besnik Korça", "author_id": 13305073, "author_profile": "https://Stackoverflow.com/users/13305073", "pm_score": 1, "selected": false, "text": "export interface Users\n// to\nexport interface User\n" }, { "answer_id": 74247096, "author": "Tk...
2022/10/23
[ "https://Stackoverflow.com/questions/74169691", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17076133/" ]
74,169,709
<p>I have a dataframe <code>df</code> like below :</p> <pre><code> import pandas as pd data = {'A': ['ABCD_1', 'ABCD_1', 'ABCD_1', 'ABCD_1', 'PQRS_2', 'PQRS_2', 'PQRS_2', 'PQRS_2', 'PQRS_2', 'PQRS_3', 'PQRS_4'], 'B':[2, 3, 5, 6, 7, 8, 9, 11, 13, 15, 17]} df = pd.DataFrame(data) df | A | B | +------------+----------+ | ABCD_1 | 2 | | ABCD_1 | 3 | | ABCD_1 | 5 | | ABCD_1 | 6 | | PQRS_2 | 7 | | PQRS_2 | 8 | | PQRS_2 | 9 | | PQRS_2 | 11 | | PQRS_2 | 13 | | PQRS_3 | 15 | | PQRS_4 | 17 | +------------+----------+ </code></pre> <p>What I want to achieve is that I need to assign 1 to first value of every group of column <code>A</code> and 0 to the rest of other values. Incase, there is a single group present in Column <code>A</code> I just assign 1 to that group. So, my expected result should look like below.</p> <pre><code>Expected Output : | A | B | P | +------------+----------+----------+ | ABCD_1 | 2 | 1 | | ABCD_1 | 3 | 0 | | ABCD_1 | 5 | 0 | | ABCD_1 | 6 | 0 | | PQRS_2 | 7 | 1 | | PQRS_2 | 8 | 0 | | PQRS_2 | 9 | 0 | | PQRS_2 | 11 | 0 | | PQRS_2 | 13 | 0 | | PQRS_3 | 15 | 1 | | PQRS_4 | 17 | 1 | +------------+----------+----------+ </code></pre> <p>I tried to group them using the below code, however, I wasn't able to get expected results.</p> <pre><code>Actual Output df['P'] = pd.factorize(df['A']) + 1 | A | B | P | +------------+----------+----------+ | ABCD_1 | 2 | 1 | | ABCD_1 | 3 | 1 | | ABCD_1 | 5 | 1 | | ABCD_1 | 6 | 1 | | PQRS_2 | 7 | 1 | | PQRS_2 | 8 | 2 | | PQRS_2 | 9 | 2 | | PQRS_2 | 11 | 2 | | PQRS_2 | 13 | 2 | | PQRS_3 | 15 | 3 | | PQRS_4 | 17 | 4 | +------------+----------+----------+ </code></pre> <p>How can I assign 1 and 0 to each of the groups using Pandas ?</p>
[ { "answer_id": 74169809, "author": "ouroboros1", "author_id": 18470692, "author_profile": "https://Stackoverflow.com/users/18470692", "pm_score": 3, "selected": true, "text": "df.duplicated" } ]
2022/10/23
[ "https://Stackoverflow.com/questions/74169709", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3046211/" ]
74,169,732
<p>On <a href="https://en.cppreference.com/w/cpp/string/basic_string/to_string" rel="nofollow noreferrer">cppreference.com</a>, it says that the <code>to_string</code> function could work in the following ways. Why isn't there <code>char</code> and <code>unsigned char</code> type?</p> <pre><code>to_string(int value); to_string(long value); to_string(long long value); to_string(unsigned value); to_string(unsigned long value); to_string(unsigned long long value); to_string(float value); to_string(double value); to_string(long double value); </code></pre>
[ { "answer_id": 74169784, "author": "Jason Liam", "author_id": 12002570, "author_profile": "https://Stackoverflow.com/users/12002570", "pm_score": 3, "selected": false, "text": "std::string" }, { "answer_id": 74169832, "author": "user17732522", "author_id": 17732522, "...
2022/10/23
[ "https://Stackoverflow.com/questions/74169732", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19059088/" ]
74,169,765
<p>I'm trying to use modelsummary for the following process:</p> <ol> <li>Estimate a multivariate regression ( j explanatory variables) per group (k groups) so that you have k estimates per each one of j variables.</li> <li>Average those k coefficients per each variable and calculate the corresponding t stat.</li> <li>Display those averages and t stats in one column as if they were estimates in a normal regression.</li> </ol> <p>Statistically it is not the best approach but that's necessary in this case. It's basically averaged coefficients of k regressions. So my question is for the steps 2 and 3. Here is a reprex using mtcars just to calc averages and tstats:</p> <pre><code>fit&lt;-mtcars %&gt;% feols(c(mpg,hp )~1) modelsummary(fit, estimate=&quot;{estimate}{stars}&quot;, stars = c('*' = .1, '**' = .05, '***'=0.01), output=&quot;flextable&quot;) </code></pre> <p>So this is the original ouptut</p> <p><a href="https://i.stack.imgur.com/5IUWT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5IUWT.png" alt="Original output" /></a></p> <p>And I would like to stack those averages and tstats in one column like in the screenshot below.</p> <p><a href="https://i.stack.imgur.com/NRvGz.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/NRvGz.png" alt="Desired column structure" /></a></p> <p>There are several ways to do this but the best in this case imho would be to say within fixest+modelsummary+flextable workflow and I haven't been able to find the best approach for this. Would really appreciate any insight!</p>
[ { "answer_id": 74169784, "author": "Jason Liam", "author_id": 12002570, "author_profile": "https://Stackoverflow.com/users/12002570", "pm_score": 3, "selected": false, "text": "std::string" }, { "answer_id": 74169832, "author": "user17732522", "author_id": 17732522, "...
2022/10/23
[ "https://Stackoverflow.com/questions/74169765", "https://Stackoverflow.com", "https://Stackoverflow.com/users/851353/" ]
74,169,796
<p>I am trying to get DividendYield from a company for the last 20 years using ChartJs in laravel project. The arrays came from HTTP client API. The formula is like that :$dividendPayed / $dailyPrice * 100. The problem i am facing is that the $dividendPayed is once in three months so it makes that array shorter that the one which contains daily prices.</p> <pre><code>private function getDividend() { $dividend = []; $response = Http::get('https://some-endpoint-for-once-in-3-months-dividend'); $response-&gt;throw(); foreach($response-&gt;json('historical') as $stock){ $dividend [] = $stock['dividend']; } return $dividend; //THIS ARRAY RETURNS LET'S SAY FOR EXAMPLE 50 RESULTS // $dividend = [ 0 =&gt; 0.23 1 =&gt; 0.23 2 =&gt; 0.22 3 =&gt; 0.22 .......... 50 =&gt; .43 ] } private function getPrice() { $price = []; $response = Http::get('https://some-endpoint-for-daily-prices'); $response-&gt;throw(); foreach($response-&gt;json('historical') as $stockPrice){ $price [] = $stockPrice['close']; } return $price; } //THIS ARRAY RETURNS LET'S SAY FOR EXAMPLE 240 RESULTS // $price = [ 0 =&gt; 147.27 1 =&gt; 143.39 2 =&gt; 143.86 3 =&gt; 143.75 4 =&gt; 142.41 5 =&gt; 138.38 .......... 240 =&gt; 300.43 ] </code></pre> <p>I also have to mention that the 'date' in the chart for labels (day by day for the last 20 years) is taken from the same endpoint as $dailyPrice.</p>
[ { "answer_id": 74169784, "author": "Jason Liam", "author_id": 12002570, "author_profile": "https://Stackoverflow.com/users/12002570", "pm_score": 3, "selected": false, "text": "std::string" }, { "answer_id": 74169832, "author": "user17732522", "author_id": 17732522, "...
2022/10/23
[ "https://Stackoverflow.com/questions/74169796", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16107233/" ]
74,169,800
<p>In my sidebar, when I hover over a submenu (portfolio or contact)</p> <p><a href="https://i.stack.imgur.com/8mmC5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8mmC5.png" alt="enter image description here" /></a></p> <p>I would like the red background to take up the entire background of the cell.</p> <p><a href="https://i.stack.imgur.com/AxghD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/AxghD.png" alt="enter image description here" /></a></p> <p>Do you know how I could create this?</p> <p>I think the problem is here? But I don't see what priority I should add?</p> <pre><code>.sidebar .nav-links li:hover { background: red; } </code></pre> <p>Thanks a lot</p> <p>Here is a demonstration via <a href="https://stackblitz.com/github/kora1348/exemple1?file=src/styles.css" rel="nofollow noreferrer">Stackblitz</a></p> <p><em><strong>HTML</strong></em></p> <pre><code>&lt;ul class=&quot;nav-links&quot; id=&quot;nav-links&quot; &gt; &lt;li *ngFor=&quot;let item of menuSidebar&quot; #itemEl &gt; &lt;div *ngIf=&quot;item.sub_menu.length &gt; 0&quot; class=&quot;dropdown-title&quot; (click)=&quot;showSubmenu(itemEl)&quot;&gt; &lt;a&gt; &lt;i [class]=&quot;item.icon&quot;&gt;&lt;/i&gt; &lt;span class=&quot;link_name&quot;&gt;{{item.link_name}}&lt;/span&gt; &lt;/a&gt; &lt;i class='bx bxs-chevron-down arrow'&gt;&lt;/i&gt; &lt;/div&gt; &lt;ul class=&quot;sub-menu&quot; [class.blank]=&quot;item.sub_menu.length == 0&quot;&gt; &lt;li&gt;&lt;a class=&quot;link_name&quot;&gt;{{item.link_name}}&lt;/a&gt;&lt;/li&gt; &lt;li *ngFor=&quot;let item_sub of item.sub_menu&quot; routerLinkActive=&quot;active&quot;&gt; &lt;a [routerLink]=&quot;[item_sub.link]&quot;&gt;{{item_sub.link_name}}&lt;/a&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/li&gt; &lt;/ul&gt; </code></pre> <p><em><strong>CSS</strong></em></p> <pre><code>/* Sidebar */ .sidebar { position: fixed; top: 0; left: 0; height: 100%; width: 260px; background: white; z-index: 100; transition: all 0.5s ease; } .sidebar.sidebar-close { width: 60px; } .sidebar .logo-details{ width: 100%; padding: 10px 10px 10px 10px; } .sidebar .logo-details img{ height: 50px; width: 80%; display: block; margin: 0 auto; } .sidebar.sidebar-close .logo-details img { width: 37px; height: 50px; transform: scale(1.2) translateX(-3px); } .sidebar .nav-links { height: 100%; width: 260px; padding-bottom: 150px; overflow: auto; } .sidebar .nav-links::-webkit-scrollbar { display: none; } .sidebar .nav-links li { list-style: none; } .sidebar .nav-links &gt; li { position: relative; width: fit-content; } .sidebar .nav-links li:hover { background: red; } /* Dropdown Title */ .sidebar .nav-links .dropdown-title { width: 260px; overflow: hidden; transition: all 0.52s ease; display: flex; align-items: center; justify-content: space-between; position: relative; } .sidebar.sidebar-close .nav-links .dropdown-title { width: 60px; } .sidebar .nav-links li i { height: 50px; min-width: 60px; text-align: center; line-height: 50px; color: #ffa726; font-size: 20px; cursor: pointer; transition: all 0.3s ease; } .sidebar .nav-links li:hover i, .sidebar .nav-links li.active i { color: white; } .sidebar .nav-links li.showMenu i.arrow { transform: rotate(-180deg); } /* a Tag */ .sidebar .nav-links li a { display: flex; align-items: center; text-decoration: none; width: 100%; } /* Link Name */ .sidebar .nav-links li a .link_name { font-size: 16px; font-weight: 600; color: #ffa726; transition: all 0.4s ease; } .sidebar .nav-links li:hover a .link_name, .sidebar .nav-links li.active a .link_name { color: white; } .sidebar.sidebar-close .nav-links li a .link_name { pointer-events: none; } /* Sub Menu */ .sidebar .nav-links li .sub-menu { padding: 6px 6px 14px 50px; background: #239CD3; display: none; transition: all 0.4s ease; } .sidebar .nav-links li.showMenu .sub-menu { display: block; } .sidebar .nav-links li .sub-menu a { color: #ffa726; font-size: 15px; padding: 7px 0; white-space: nowrap; transition: all 0.3s ease; } .sidebar .nav-links li .sub-menu li { padding-left: 10px; } .sidebar .nav-links li .sub-menu li:hover a, .sidebar .nav-links li .sub-menu li.active a { color: black; } .sidebar.sidebar-close .nav-links li .sub-menu { position: absolute; left: 100%; top: -10px; margin-top: 0; padding: 0; border-radius: 0 6px 6px 0; opacity: 0; display: block; pointer-events: none; transition: 0s; overflow: hidden; } .sidebar.sidebar-close .nav-links li .sub-menu li { padding: 6px 15px; width: 200px; } .sidebar.sidebar-close .nav-links li:hover .sub-menu { top: 0; opacity: 1; pointer-events: auto; transition: all 0.4s ease; } .sidebar .nav-links li .sub-menu .link_name { display: none; } .sidebar.sidebar-close .nav-links li .sub-menu .link_name { font-size: 16px; font-weight: 600; display: block; } .sidebar.sidebar-close .nav-links li .sub-menu li:first-child { background: white; pointer-events: none; } .sidebar .nav-links li .sub-menu.blank { pointer-events: auto; opacity: 0; pointer-events: none; } .sidebar .nav-links li:hover .sub-menu.blank, .sidebar .nav-links li.active .sub-menu.blank { top: 50%; transform: translateY(-50%); } .sidebar.sidebar-close ~ .home-section { left: 60px; width: calc(100% - 60px); } </code></pre>
[ { "answer_id": 74169784, "author": "Jason Liam", "author_id": 12002570, "author_profile": "https://Stackoverflow.com/users/12002570", "pm_score": 3, "selected": false, "text": "std::string" }, { "answer_id": 74169832, "author": "user17732522", "author_id": 17732522, "...
2022/10/23
[ "https://Stackoverflow.com/questions/74169800", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18216840/" ]
74,169,819
<p>I am working on a small project in which data after filling the form will be posted on the notion.</p> <p>Error while submitting button from form:contact.jsx?287f:14 POST http://localhost:3000/contact 405 (Method Not Allowed)<a href="https://imgur.com/a/iOzYFCC" rel="nofollow noreferrer">enter link description here</a></p> <p>source:- <a href="https://imgur.com/a/xqUsEkE" rel="nofollow noreferrer">notion db</a></p> <p>here were ui renders contact.jsx::- '''</p> <pre><code>import { useState } from 'react'; import ContactCode from '../components/ContactCode'; import styles from '../styles/ContactPage.module.css'; const ContactPage = () =&gt; { const [name, setName] = useState(''); const [email, setEmail] = useState(''); const [subject, setSubject] = useState(''); const [message, setMessage] = useState(''); const submitForm = async (e) =&gt; { e.preventDefault(); console.log(process.env.NEXT_PUBLIC_API_URL); const res = await fetch(`http://localhost:3000/contact`, { method: 'post', body: JSON.stringify({ name: name, email: email, subject:subject, message: message }), }); if (res.ok) { alert('Your response has been received!'); setName(''); setEmail(''); setSubject(''); setMessage(''); } else { alert('There was an error. Please try again in a while.'); } }; return ( &lt;div className={styles.container}&gt; &lt;div&gt; &lt;h3 className={styles.heading}&gt;Reach Out Via Socials&lt;/h3&gt; &lt;ContactCode /&gt; &lt;/div&gt; &lt;div&gt; &lt;h3 className={styles.heading}&gt;Or Fill Out This Form&lt;/h3&gt; &lt;form className={styles.form} onSubmit={submitForm}&gt; &lt;div className={styles.flex}&gt; &lt;div&gt; &lt;label htmlFor=&quot;name&quot;&gt;Name&lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;name&quot; id=&quot;name&quot; value={name} onChange={(e) =&gt; setName(e.target.value)} required /&gt; &lt;/div&gt; &lt;div&gt; &lt;label htmlFor=&quot;email&quot;&gt;Email&lt;/label&gt; &lt;input type=&quot;email&quot; name=&quot;email&quot; id=&quot;email&quot; value={email} onChange={(e) =&gt; setEmail(e.target.value)} required /&gt; &lt;/div&gt; &lt;/div&gt; &lt;div&gt; &lt;label htmlFor=&quot;name&quot;&gt;Subject&lt;/label&gt; &lt;input type=&quot;text&quot; name=&quot;subject&quot; id=&quot;subject&quot; value={subject} onChange={(e) =&gt; setSubject(e.target.value)} required /&gt; &lt;/div&gt; &lt;div&gt; &lt;label htmlFor=&quot;message&quot;&gt;Message&lt;/label&gt; &lt;textarea name=&quot;message&quot; id=&quot;message&quot; rows=&quot;5&quot; value={message} onChange={(e) =&gt; setMessage(e.target.value)} required &gt;&lt;/textarea&gt; &lt;/div&gt; &lt;button type=&quot;submit&quot;&gt;Submit&lt;/button&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; ); }; export async function getStaticProps() { return { props: { title: 'Contact' }, }; } export default ContactPage; </code></pre> <p>'''</p> <p>api/contact.js :-</p> <pre><code>const { Client } = require('@notionhq/client'); const notion = new Client({ auth: 'secret_xxxxxxxxxxxxxxxxxxxxx', }); export default async (req, res) =&gt; { if (req.method !== 'POST') { return res.status(405).json({ msg: 'Only POST requests are allowed' }); } try { const { name, email, subject, message } = JSON.parse(req.body); await notion.pages.create({ parent: { database_id: 'https://www.notion.so/62xxxxx713xx`, }, properties: { Name: { title: [ { text: { content: name, }, }, ], }, Email: { email, }, Subject: { rich_text: [ { text: { content: subject, }, }, ], }, Message: { rich_text: [ { text: { content: message, }, }, ], }, }, }); res.status(201).json({ msg: 'Success' }); } catch (error) { console.log(error); res.status(500).json({ msg: 'Failed' }); } }; </code></pre>
[ { "answer_id": 74169784, "author": "Jason Liam", "author_id": 12002570, "author_profile": "https://Stackoverflow.com/users/12002570", "pm_score": 3, "selected": false, "text": "std::string" }, { "answer_id": 74169832, "author": "user17732522", "author_id": 17732522, "...
2022/10/23
[ "https://Stackoverflow.com/questions/74169819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19756756/" ]
74,169,820
<p>A webpage created to fetch data from an api with a simple search bar and search button.</p> <p>This is the HTML file:</p> <pre><code>&lt;!DOCTYPE html&gt; &lt;html lang=&quot;en&quot;&gt; &lt;head&gt; &lt;meta charset=&quot;UTF-8&quot;&gt; &lt;meta http-equiv=&quot;X-UA-Compatible&quot; content=&quot;IE=edge&quot;&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width&gt;, initial-scale=1.0&quot;&gt; &lt;title&gt;Search Games&lt;/title&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;pbl.css&quot;&gt; &lt;/head&gt; &lt;body&gt; &lt;br&gt;&lt;h1 class=&quot;heading1&quot;&gt;Gamer's DataBase&lt;/h1&gt; &lt;br&gt; &lt;br&gt; &lt;br&gt; &lt;div&gt; &lt;input class=&quot;search&quot; type=&quot;search&quot; placeholder=&quot;Search Game(s) by name...&quot; id = &quot;game_name&quot;&gt; &lt;button class=&quot;searchbtn&quot; onclick = &quot;movie_search();event.preventDefault()&quot;&gt;&lt;svg width=&quot;30&quot; height=&quot;30&quot; viewBox=&quot;0 0 24 24&quot;&gt;&lt;path fill=&quot;currentColor&quot; d=&quot;m18.9 20.3l-5.6-5.6q-.75.6-1.725.95Q10.6 16 9.5 16q-2.725 0-4.612-1.887Q3 12.225 3 9.5q0-2.725 1.888-4.613Q6.775 3 9.5 3t4.613 1.887Q16 6.775 16 9.5q0 1.1-.35 2.075q-.35.975-.95 1.725l5.625 5.625q.275.275.275.675t-.3.7q-.275.275-.7.275q-.425 0-.7-.275ZM9.5 14q1.875 0 3.188-1.312Q14 11.375 14 9.5q0-1.875-1.312-3.188Q11.375 5 9.5 5Q7.625 5 6.312 6.312Q5 7.625 5 9.5q0 1.875 1.312 3.188Q7.625 14 9.5 14Z&quot;/&gt;&lt;/svg&gt;&lt;/button&gt; &lt;/div&gt; &lt;div class = &quot;games&quot;&gt;&lt;/div&gt; &lt;script src = &quot;game(with css).js&quot;&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>This is the JavaScript:</p> <pre><code>function movie_search() { var game_name = document.getElementById('game_name').value; var raw = &quot;search \&quot;&quot;+game_name+&quot;\&quot;\;\r\nfields cover.url, name, url, screenshots.*; \r\n&quot;; var requestOptions = { method: 'POST', headers: myHeaders, body: raw, redirect: 'follow' }; fetch(&quot;https://cors-anywhere.herokuapp.com/https://api.igdb.com/v4/games&quot;, requestOptions) .then(response =&gt; response.json()) .then(data =&gt; { data.forEach(gayme =&gt; { html += &quot;&lt;div class = 'gayme'&gt;&quot; let keys = Object.keys(gayme); keys.forEach((key) =&gt; { html += gayme[key] }) html += &quot;&lt;/div&gt;&quot; const game = `&lt;ul&gt;&lt;li&gt;&lt;img src = &quot;https:${gayme.cover.url}&quot;&gt;&lt;br&gt;&lt;h4&gt;Name:&lt;/h4&gt;&lt;h3&gt;${gayme.name}&lt;/h3&gt;&lt;br&gt;&lt;a href = &quot;${gayme.url}&quot;&gt;Click for Game Info&lt;/a&gt;&lt;br&gt;&lt;br&gt;&lt;/li&gt;&lt;/ul&gt;`; document.querySelector('.games').innerHTML += game; }) }) .catch(error =&gt; console.log('error', error)); } document.querySelector(&quot;.search&quot;).addEventListener(&quot;keyup&quot;,function(event){ if(event.key == &quot;Enter&quot;) { movie_search (); } }) </code></pre> <p>When I search something for the second time, the new resutls list below the previous results. I want to add something to the code which will remove the previous results when the button is clicked and will display the new results only. Please help.</p>
[ { "answer_id": 74169784, "author": "Jason Liam", "author_id": 12002570, "author_profile": "https://Stackoverflow.com/users/12002570", "pm_score": 3, "selected": false, "text": "std::string" }, { "answer_id": 74169832, "author": "user17732522", "author_id": 17732522, "...
2022/10/23
[ "https://Stackoverflow.com/questions/74169820", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20313316/" ]
74,169,831
<p>I'm trying to remove white space on a page but I don't understand where it coming from. The website Is built on the WordPress platform I've attached a screenshot of the whitespace. basically, I want to remove the whitespace so the text will align with the image on the same line. <a href="https://i.stack.imgur.com/2b7ft.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/2b7ft.png" alt="image" /></a></p> <p>Here is a URL of the product page: <a href="https://medton-hedim.co.il/product/clean-aid-%D7%A1%D7%A4%D7%A8%D7%99%D7%99-%D7%9C%D7%A0%D7%99%D7%A7%D7%95%D7%99-%D7%9E%D7%99%D7%A0%D7%99/" rel="nofollow noreferrer">https://medton-hedim.co.il/product/clean-aid-%d7%a1%d7%a4%d7%a8%d7%99%d7%99-%d7%9c%d7%a0%d7%99%d7%a7%d7%95%d7%99-%d7%9e%d7%99%d7%a0%d7%99/</a></p>
[ { "answer_id": 74169876, "author": "orghu", "author_id": 2817442, "author_profile": "https://Stackoverflow.com/users/2817442", "pm_score": 2, "selected": true, "text": ".summary.entry-summary {\n display: flex;\n}\n" }, { "answer_id": 74169897, "author": "Rakesh", "aut...
2022/10/23
[ "https://Stackoverflow.com/questions/74169831", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19323865/" ]
74,169,862
<p>I'm having an entry:</p> <pre><code>auto myEntry = elm_entry_add(..); </code></pre> <p>Its <em>focused</em> event works great for detecting when it's getting <em>actually</em> edited:</p> <pre><code>evas_object_smart_callback_add(myEntry, &quot;focused&quot;, onOpen, NULL); </code></pre> <p>This calls my <code>onOpen</code> function when the entry is focused, thus when it's getting edited:</p> <p><a href="https://i.stack.imgur.com/pAb7w.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pAb7w.png" alt="enter image description here" /></a></p> <p>When I edit the text, I can use another event: <em>changed</em>, to detect when user finishes (or more appropriate: <em>changed,user</em>).</p> <p>However, when user just dismiss it without changing (by pressing the back key), I don't get any events:</p> <ul> <li>aborted: not called</li> <li>changed: not called, as text has not been changed</li> <li>unfocused: not called, as the entry hasn't lost its focus, just it's editor has been closed.</li> </ul> <p>Other events are mainly for selection and cursor.</p> <p><strong>How can I detect when editor has been closed?</strong></p>
[ { "answer_id": 74177187, "author": "Daniel", "author_id": 1446710, "author_profile": "https://Stackoverflow.com/users/1446710", "pm_score": 0, "selected": false, "text": "elm_entry" }, { "answer_id": 74177499, "author": "wonrst", "author_id": 16163137, "author_profile...
2022/10/23
[ "https://Stackoverflow.com/questions/74169862", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1446710/" ]
74,169,864
<ol> <li><p>Create a drop-down component from Breeds that allows you to select a breed.</p> <ul> <li>The component name is BreedsSelect component (BreedsSelect.js)</li> <li>Use select and option tags.</li> <li>The BreedsSelect component should be passed the breeds (an array of the list of breeds) as props. The variable name to be assigned should also be &quot;breeds&quot;. Example: <code>&lt;BreedsSelect breeds={breeds} /&gt;</code></li> </ul> </li> <li><p>Load the BreedsSelect component from the DogListContainer component.</p> </li> <li><p>Define selectedBreed and setSelectedBreed in useState to hold the selected breed. (Define them in the DogListContainer component.</p> </li> <li><p>Reflect the selected breed information in selectedBreed on drop-down selection.</p> <ul> <li>Update state on dropdown selection (add props to BreedsSelect that you may need).</li> <li>Use the data in selectedBreed for the value of the select tag. (Let's add the props we might need to BreedsSelect)</li> </ul> </li> </ol> <p>How would I change these two codes to accomplish these four things?</p> <hr /> <p>BreedsSelect.js:</p> <pre><code>import { useState } from 'react' export const BreedsSelect = props =&gt; { const [selectedBreed, setSelectedBreed] = useState(null) return ( &lt;div&gt; &lt;select value={selectedBreed}&gt; &lt;option&gt;&lt;/option&gt; &lt;option&gt;&lt;/option&gt; &lt;opition&gt;&lt;/opition&gt; &lt;/select&gt; &lt;/div&gt; ) } </code></pre> <p>DogListContainer.js:</p> <pre><code>import { useEffect, useState } from 'react' // DO NOT DELETE import { BreedsSelect } from './BreedsSelect' export const DogListContainer = () =&gt; { const [breeds, setBreeds] = useState(null) useEffect(() =&gt; { fetch('https://dog.ceo/api/breeds/list/all') .then(res =&gt; res.json()) .then(data =&gt; { console.log(data.message) setBreeds(data.message) }) }, []) return &lt;BreedsSelect breeds={breeds} /&gt; } </code></pre>
[ { "answer_id": 74177187, "author": "Daniel", "author_id": 1446710, "author_profile": "https://Stackoverflow.com/users/1446710", "pm_score": 0, "selected": false, "text": "elm_entry" }, { "answer_id": 74177499, "author": "wonrst", "author_id": 16163137, "author_profile...
2022/10/23
[ "https://Stackoverflow.com/questions/74169864", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,169,872
<p>I'm new to C# and .Net platforms. I have a problem.</p> <p>I want to create a custom class. This class has <code>Dispose</code> method and implements the <code>IDisposable</code> interface. And I want to force everyone who wants to use my class and create an instance to use <code>using</code> syntax.</p> <p>Because I want to it</p> <pre><code>using (Person person = new Person()) { // Some code example } </code></pre> <p>I don't want to allow creation of an instance without <code>using</code> declarations</p> <pre><code>Person person = new Person () // I don't want it this method </code></pre> <p>Is it possible or not? (maybe a custom attribute, maybe .net attributes, maybe another method)</p> <p>What do you? What advice would you give me about this job?</p>
[ { "answer_id": 74170051, "author": "Neil", "author_id": 759558, "author_profile": "https://Stackoverflow.com/users/759558", "pm_score": 0, "selected": false, "text": "Dispose" }, { "answer_id": 74170354, "author": "György Kőszeg", "author_id": 5114784, "author_profile...
2022/10/23
[ "https://Stackoverflow.com/questions/74169872", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15196212/" ]
74,169,917
<p>i'm tring to make something looks good</p> <p>i was tring to use css but i got a problem</p> <p>only a inline style is working...</p> <pre><code>reply new { display: inline-block; height: 5vh; } reply new writer { width: 20px; } reply new content { width: 20px; } </code></pre> <ul> <li></li> </ul> <pre><code>&lt;input type=&quot;text&quot; class=&quot;reply new writer form-control input-sm&quot; style=&quot;width: 20px&quot;&gt; &lt;input type=&quot;text&quot; class=&quot;reply new content form-control input-sm&quot;&gt; </code></pre> <p>it doesn't work.</p> <p>but</p> <pre><code>&lt;input type=&quot;text&quot; class=&quot;reply new writer form-control input-sm&quot; style=&quot;width: 20px&quot;&gt; &lt;input type=&quot;text&quot; class=&quot;reply new content form-control input-sm&quot;&gt; </code></pre> <p>it works.</p> <p>what should i do</p>
[ { "answer_id": 74169952, "author": "Quentin", "author_id": 19068, "author_profile": "https://Stackoverflow.com/users/19068", "pm_score": 2, "selected": false, "text": "reply new\n" }, { "answer_id": 74169954, "author": "Harrison", "author_id": 15291770, "author_profil...
2022/10/23
[ "https://Stackoverflow.com/questions/74169917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16349822/" ]
74,169,968
<p>Say we have two types of objects, patients and hospitals:</p> <pre><code>import random class Patient: def __init__(self): x = random.randint(0,100) y = random.randint(0,100) class Hospital: def __init__(self): x = random.randint(0,100) y = random.randint(0,100) </code></pre> <p>Say we had lists of 25 patients and 5 hospitals.</p> <pre><code>PatientList = [] for p in range(25): PatientList.append(Patient()) HospitalList = [] for p in range(5): HospitalList.append(Hospital()) </code></pre> <p>The goal is to use the XY coordinates belonging to each object to find the closest hospital to the individual patient. Ideally, we would also be able to rank the hospitals in order of distance, or at least be able to find the second closest, third closest, etc. after the closest hospital is found.</p>
[ { "answer_id": 74169952, "author": "Quentin", "author_id": 19068, "author_profile": "https://Stackoverflow.com/users/19068", "pm_score": 2, "selected": false, "text": "reply new\n" }, { "answer_id": 74169954, "author": "Harrison", "author_id": 15291770, "author_profil...
2022/10/23
[ "https://Stackoverflow.com/questions/74169968", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19678327/" ]
74,169,989
<p>Im working on a program that changes a specified character, if its uppercase, it will change it to lowercase and vice versa.</p> <p>I have written a piece of code that in theory should work. I have also written it with a foreach(char c in x) method but that wont work wither. Any tips?</p> <p>Expected output <strong>teSTSTring</strong> Given output <strong>TEststRING</strong></p> <pre><code> string x = &quot;TEststRING&quot;; for (int i = 0; i &lt; x.Length; i++) { if (char.IsUpper(x[i])) { char.ToLower(x[i]); } if (char.IsLower(x[i])) { char.ToUpper(x[i]); } } Console.WriteLine(x); </code></pre>
[ { "answer_id": 74169952, "author": "Quentin", "author_id": 19068, "author_profile": "https://Stackoverflow.com/users/19068", "pm_score": 2, "selected": false, "text": "reply new\n" }, { "answer_id": 74169954, "author": "Harrison", "author_id": 15291770, "author_profil...
2022/10/23
[ "https://Stackoverflow.com/questions/74169989", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20125200/" ]
74,169,994
<p>I am grateful to everyone who participates and will help a newbie.</p> <p>Task: Access div = client-state, then div = Here-Goes-Some-Div-ID and return json from data-state.</p> <pre><code>&lt;div class=&quot;client-state&quot;&gt; &lt;div id=&quot;Here-Goes-Some-Div-ID&quot; data-state='{&quot;items&quot;:[{&quot;action&quot;:&quot;LAYOUT&quot;}]'&gt; &lt;/div&gt; </code></pre> <p>I managed to refer to div = client state like this -</p> <pre><code>import cheerio from 'cheerio'; const id = [&quot;98772&quot;] async function GetDataFunction () { try { for (let i = 0; i &lt; id.length; i++) { let HTMLresponse = await ProductSearchFunction(id[i]); const $ = cheerio.load(HTMLresponse); $('.client-state').each(function() { const ClientState = $(this).html() console.log(ClientState) }) }} catch (err) { throw err } };GetDataFunction() </code></pre> <p>Unfortunately, I did not find information on how to further access the &quot;Here-Goes-Some-Div-ID&quot; div and get data-state= I would be grateful for the hint, thank you in advance!</p>
[ { "answer_id": 74174831, "author": "theDavidBarton", "author_id": 12412595, "author_profile": "https://Stackoverflow.com/users/12412595", "pm_score": 2, "selected": true, "text": "await page.$eval('.client-state #Here-Goes-Some-Div-ID', el => el.getAttribute('data-state'))\n" }, { ...
2022/10/23
[ "https://Stackoverflow.com/questions/74169994", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20299768/" ]
74,170,024
<p>My output</p> <p><a href="https://i.stack.imgur.com/8WiE5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8WiE5.png" alt="enter image description here" /></a></p> <p>How to align horizontally this Icon , Text and radio button.Radio button and text display nicely but Icon and text are not align horizontally. How make this?</p> <p>my code</p> <pre><code>ListTile( leading: Icon( Icons.brightness_1, color: Colors.black, size: 13, ), minLeadingWidth: 2, title: Text(&quot;Can you understand?&quot;), trailing: Radio( value: &quot;talk&quot;, groupValue: level, onChanged: (value) { setState(() { level = value.toString(); }); }, ), ), </code></pre>
[ { "answer_id": 74174831, "author": "theDavidBarton", "author_id": 12412595, "author_profile": "https://Stackoverflow.com/users/12412595", "pm_score": 2, "selected": true, "text": "await page.$eval('.client-state #Here-Goes-Some-Div-ID', el => el.getAttribute('data-state'))\n" }, { ...
2022/10/23
[ "https://Stackoverflow.com/questions/74170024", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20000775/" ]
74,170,025
<p>I wonder if this is all a PATH issue. I have MacBook Pro 12.6, with homebrew. No pyenv or virtualenv. (perhaps I should..) I am using nvim. When I start iterm it launches python to the python command prompt rather than my zsh prompt. When I <code>ctrl D</code> it goes straight to the zshell prompt with no complaints.</p> <pre><code>Last login: Sun Oct 23 10:07:06 on ttys001 /etc/zshrc:7: command not found: locale Python 3.9.6 (default, Sep 19 2022, 18:46:30) [Clang 14.0.0 (clang-1400.0.29.201)] on darwin Type &quot;help&quot;, &quot;copyright&quot;, &quot;credits&quot; or &quot;license&quot; for more information. &gt;&gt;&gt; </code></pre> <p>My /etc/paths is</p> <pre><code>/usr/local/bin /usr/bin /bin /usr/sbin /sbin </code></pre> <p>My .zshenv is</p> <pre><code>export PATH=/Users/np/.local/bin:$PATH </code></pre> <p>My .zsh_profile is</p> <pre><code>export PATH=&quot;$PATH:/usr/bin&quot; export PATH=&quot;$PATH:/usr/sbin&quot; export PATH=/usr/local/bin:/usr/local/sbin:$PATH export PATH=/opt/homebrew/bin:$PATH PATH=/.local/bin:$PATH PATH=/bin:/usr/bin:/usr/local/bin:${PATH} #clipboard set clipboard=unnamed #oh-my-zsh export ZSH=&quot;$HOME/.oh-my-zsh&quot; source $ZSH/oh-my-zsh.sh #Theme ZSH_THEME=&quot;powerlevel10k/powerlevel10k&quot; #Plugins plugins=(git zsh-autosuggestions z ) source $ZSH/oh-my-zsh.sh #/opt/homebrew/etc/profile.d/z.sh #aliases source ~/.zsh_aliases #P10k # To customize prompt, run `p10k configure` or edit ~/.p10k.zsh. [[ ! -f ~/.p10k.zsh ]] || source ~/.p10k.zsh source /Users/np/zsh-syntax-highlighting/zsh-syntax-highlighting.zsh export PATH=&quot;/opt/homebrew/bin:$PATH&quot; export PATH=&quot;/opt/homebrew/sbin:$PATH&quot;``` </code></pre> <p>I know the PATH entries are a mess.</p> <p>I don't know how to fix the PATHS and dont have a clear idea of the priorities and orders for PATHS if indeed that is the issue. I know that my path to homebrew should be loaded first so that the system uses homebrew links before system links.</p> <p>I think this is something to do with my multiple pythons and I need advice on wihich to delete, - presumably all except the homebrew and native mac ones as I mainly use homebrew.</p> <p>Here is</p> <pre><code>Which -a python </code></pre> <pre><code>/opt/homebrew/bin/python3 /usr/bin/python3 /usr/local/bin/python3 /opt/homebrew/bin/python3 /usr/local/bin/python3 /opt/homebrew/bin/python3 /Library/Frameworks/Python.framework/Versions/3.9/bin/python3 /usr/bin/python3 </code></pre>
[ { "answer_id": 74255746, "author": "flakes", "author_id": 3280538, "author_profile": "https://Stackoverflow.com/users/3280538", "pm_score": 1, "selected": false, "text": "~/.zshrc" }, { "answer_id": 74321328, "author": "Pierre Baudin", "author_id": 19753631, "author_p...
2022/10/23
[ "https://Stackoverflow.com/questions/74170025", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11795964/" ]
74,170,032
<p>I have Installed the flutter SDK. But Android studio says flutter SDK is not configured</p>
[ { "answer_id": 74255746, "author": "flakes", "author_id": 3280538, "author_profile": "https://Stackoverflow.com/users/3280538", "pm_score": 1, "selected": false, "text": "~/.zshrc" }, { "answer_id": 74321328, "author": "Pierre Baudin", "author_id": 19753631, "author_p...
2022/10/23
[ "https://Stackoverflow.com/questions/74170032", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10618543/" ]
74,170,070
<p><a href="https://i.stack.imgur.com/pCvKD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pCvKD.png" alt="I am trying to scrape on content from the article but its div includes many other things" /></a></p> <p>I am getting this whole run the code <code>Article_content = ''</code> can anyone fix this code to get only the article's content?</p> <p>Here is the URL<br /> <a href="https://www.fodors.com/world/asia/india/experiences/news/things-you-need-to-know-before-you-visit-india" rel="nofollow noreferrer">https://www.fodors.com/world/asia/india/experiences/news/things-you-need-to-know-before-you-visit-india</a></p> <p>This is my Code</p> <pre><code> # Content = {} # header,paragraphs = &quot;&quot;,[] # for element in response.xpath('//*[@class=&quot;entry-content content-single container &quot;]/*'): # tag = element.re(r&quot;&lt;(\w+)\s&quot;) # get the tag name # # if its a paragraph add it to the paragraph list # if tag[0] == &quot;p&quot;: # paragraphs += element.xpath(&quot;.//text()&quot;).getall() # # if it's a heading place the heading and paragraphs in the # # dictionary and start a new heading with the current text. # elif tag[0] == &quot;h3&quot;: # Content[header] = ''.join(paragraphs).strip() # header = ' '.join(element.xpath(&quot;.//text()&quot;).getall()).strip() # paragraphs = [] Article_Content = response.xpath('//*[@class=&quot;entry-content content-single container &quot;]/text()') Content = '\n'.join(Article_Content.getall()).strip() yield{ 'Category':Category, 'Headlines':Headlines, 'Author': Author, 'Source': Source, 'Publication Date': Published_Date, 'Feature_Image': Feature_Image, 'Article Content': Content } </code></pre>
[ { "answer_id": 74170149, "author": "Prophet", "author_id": 3485434, "author_profile": "https://Stackoverflow.com/users/3485434", "pm_score": 3, "selected": true, "text": "'//*[@class=\"entry-content content-single container \"]//p | //*[@class=\"entry-content content-single container \"]...
2022/10/23
[ "https://Stackoverflow.com/questions/74170070", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20147022/" ]
74,170,081
<p>Sorry if this is a repeat question or for the poor heading, I haven't been able to properly articulate in one line what I'm trying to find in a generic sense, so using the example below for what I'm trying to do.</p> <p>I want to attain certain rows from a dataframe based on a min and max value from another dataframe. The min and max values are conditional on the group assigned:</p> <pre><code>data = { 'Name': ['John', 'John', 'Sam', 'Sam', 'Tim', 'Tim'], 'Salary': [18000, 20000, 15000, 35000, 12000, 30000] } boundary = { 'Name': ['John', 'Sam', 'Tim'], 'Min': [19000, 18000, 10000], 'Max': [21000, 30000, 32000] } data = pd.DataFrame(data, columns = ['Name', 'Salary']) boundary = pd.DataFrame(boundary, columns = ['Name', 'Min', 'Max']) </code></pre> <p>I want the result to be the below dataframe, where only the rows from the data df above the max and below the min from the boundary df are kept.</p> <pre><code> Name Salary 0 John 18000 2 Sam 15000 3 Sam 35000 </code></pre> <p>I've been able to do this with a single min/max, but can't quite figure it out with the groups involved, thanks in advance.</p>
[ { "answer_id": 74170157, "author": "ouroboros1", "author_id": 18470692, "author_profile": "https://Stackoverflow.com/users/18470692", "pm_score": 1, "selected": false, "text": "df.merge" }, { "answer_id": 74170178, "author": "Community", "author_id": -1, "author_profi...
2022/10/23
[ "https://Stackoverflow.com/questions/74170081", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14173510/" ]
74,170,089
<p>In this figure, the axes are not displayed on the plot. How to fix it? Can anybody help me, thank you!</p> <pre><code>plot(swedishpines, axes=TRUE) &gt; dput(swedishpines) structure(list(window = structure(list(type = &quot;rectangle&quot;, xrange = c(0, 96), yrange = c(0, 100), units = structure(list(singular = &quot;metre&quot;, plural = &quot;metres&quot;, multiplier = 0.1), class = &quot;unitname&quot;)), class = &quot;owin&quot;), n = 71L, x = c(1L, 1L, 2L, 2L, 7L, 9L, 11L, 13L, 14L, 16L, 17L, 17L, 20L, 21L, 23L, 24L, 25L, 26L, 27L, 28L, 28L, 33L, 33L, 36L, 37L, 39L, 39L, 39L, 41L, 45L, 48L, 49L, 52L, 52L, 53L, 53L, 56L, 58L, 59L, 60L, 61L, 61L, 61L, 63L, 65L, 66L, 66L, 69L, 72L, 72L, 73L, 74L, 74L, 75L, 76L, 79L, 81L, 82L, 83L, 84L, 85L, 86L, 87L, 92L, 92L, 93L, 94L, 94L, 95L, 95L, 95L), y = c(99L, 72L, 62L, 84L, 45L, 75L, 85L, 63L, 16L, 54L, 26L, 41L, 2L, 80L, 87L, 11L, 70L, 57L, 54L, 42L, 26L, 52L, 63L, 59L, 80L, 34L, 47L, 91L, 17L, 23L, 53L, 63L, 43L, 75L, 98L, 13L, 78L, 18L, 68L, 55L, 43L, 32L, 25L, 41L, 81L, 89L, 16L, 4L, 52L, 60L, 42L, 36L, 54L, 93L, 17L, 85L, 45L, 67L, 10L, 32L, 20L, 9L, 87L, 60L, 81L, 8L, 10L, 26L, 23L, 46L, 62L), markformat = &quot;none&quot;), class = &quot;ppp&quot;) </code></pre> <p>What if in case of marked point pattern like 'longleaf'? <img src="https://i.stack.imgur.com/KlbJq.png" alt="" /></p>
[ { "answer_id": 74170229, "author": "Peter", "author_id": 6936545, "author_profile": "https://Stackoverflow.com/users/6936545", "pm_score": 0, "selected": false, "text": "library(spatstat)\n\nplot(swedishpines$x, swedishpines$y, axes=TRUE)\n" }, { "answer_id": 74177001, "autho...
2022/10/23
[ "https://Stackoverflow.com/questions/74170089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18720921/" ]
74,170,094
<p>I'm looking for solution how to modify property in css of element with <code>container-type: inline-size;</code> (not in children) by <code>@container</code> query.</p> <p>Consider HTML</p> <pre><code>&lt;div class=&quot;card card--1&quot;&gt; &lt;h2 class=&quot;card__title&quot;&gt; card 1 title &lt;/h2&gt; &lt;p class=&quot;card__body&quot;&gt; lorem ipsum &lt;/p&gt; &lt;/div&gt; &lt;div class=&quot;card card--2&quot;&gt; &lt;h2 class=&quot;card__title&quot;&gt; card 2 title &lt;/h2&gt; &lt;p class=&quot;card__body&quot;&gt; lorem ipsum &lt;/p&gt; &lt;/div&gt; </code></pre> <p>and CSS</p> <pre><code>.card { container-type: inline-size; background-color: antiquewhite; } .card--1 { width: 200px; } .card--2 { width: 300px; } @container (min-width: 250px) { .card { /* do not work */ background-color: aqua; } .card__title { /* works fine */ color: red; } } </code></pre> <p>How to modify above example to change <code>background-color</code> in <code>.card</code> without changing HTML markup? Working example in <a href="https://codesandbox.io/s/peaceful-jones-g9u2r8" rel="nofollow noreferrer">codesandbox</a>.</p>
[ { "answer_id": 74170350, "author": "Temani Afif", "author_id": 8620333, "author_profile": "https://Stackoverflow.com/users/8620333", "pm_score": 0, "selected": false, "text": ".card {\n container-type: inline-size;\n background-color: antiquewhite;\n z-index: 0;\n position: relative;...
2022/10/23
[ "https://Stackoverflow.com/questions/74170094", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3708596/" ]
74,170,095
<p>I'm new to rust and I'm trying to return a <code>Window</code> struct:</p> <pre class="lang-rust prettyprint-override"><code>pub struct Window&lt;'a&gt; { ev_loop: EventLoop&lt;()&gt;, window_builder: WindowBuilder, context_builder: ContextBuilder&lt;'a, NotCurrent&gt;, display: Display } </code></pre> <p>from this function:</p> <pre class="lang-rust prettyprint-override"><code>pub fn init_lib () -&gt; Window&lt;'static&gt; { let event_loop = glutin::event_loop::EventLoop::new(); let wb = glutin::window::WindowBuilder::new(); let cb = glutin::ContextBuilder::new(); let display = glium::Display::new(wb, cb, &amp;event_loop).unwrap(); return Window { ev_loop: event_loop, window_builder: wb, context_builder: cb, display: display } } </code></pre> <p>however whilst returning <code>wb</code> as <code>window_builder</code> and <code>cb</code> as <code>context_builder</code> I get the following error:</p> <pre><code>use of moved value: `cb` value used here after moverustcE0382 lib.rs(32, 43): value moved here lib.rs(31, 9): move occurs because `cb` has type `ContextBuilder&lt;'_, NotCurrent&gt;`, which does not implement the `Copy` trait </code></pre> <p>I'm using <code>glium</code> which is a library, so I can't just modify the library code. How can I fix this?</p>
[ { "answer_id": 74170383, "author": "alexzander", "author_id": 12172291, "author_profile": "https://Stackoverflow.com/users/12172291", "pm_score": 3, "selected": true, "text": "&" }, { "answer_id": 74170913, "author": "Miiao", "author_id": 20028181, "author_profile": "...
2022/10/23
[ "https://Stackoverflow.com/questions/74170095", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18801588/" ]
74,170,116
<p>I am trying to scrape tweets with a hashtag and I want tweets only in the Arabic Language. But I still get tweets in all languages. Can anyone help please</p> <pre><code>import snscrape.modules.twitter as sntwitter query = [&quot;#Covid19&quot;, 'lang: ar'] tweets = [] limit = 5000 for tweet in sntwitter.TwitterSearchScraper(query).get_items(): if len(tweets) == limit: break else: tweets.append([tweet.date, tweet.username, tweet.content]) </code></pre>
[ { "answer_id": 74170383, "author": "alexzander", "author_id": 12172291, "author_profile": "https://Stackoverflow.com/users/12172291", "pm_score": 3, "selected": true, "text": "&" }, { "answer_id": 74170913, "author": "Miiao", "author_id": 20028181, "author_profile": "...
2022/10/23
[ "https://Stackoverflow.com/questions/74170116", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20009487/" ]
74,170,120
<p>I have a problem. I want to investigate whether my assumption is correct that it can be said that <code>receiver X</code> frequently receives a delivery from <code>consignor Y</code>. I have grouped <code>receiver </code> and <code>consignor </code> for this purpose.</p> <p>However, what I would like to do now, I would like to output to myself all <code>receivers </code> where the most frequent <code>consignor</code> contains more than 80% of all <code>consignors</code> in <code>receiver </code>.</p> <p>For example we have <code>receiver c</code> this has received from <code>consignor 2, 3</code> what. From <code>consignor 2</code> only 1 packet and from <code>consignor 3</code> 4 packets. Thus he has received a total of 5 packets. Thus <code>consignor 3</code> accepts 80% of all <code>consignor</code> within <code>receiver c</code>. Thus <code>receiver c</code> should be represented in a table. This should be done below for all others.</p> <p>In simple terms, I want all <code>receivers</code> that have more than 80% of a given <code>consignor</code>.</p> <p>How can I do this?</p> <p>What I want</p> <pre class="lang-py prettyprint-override"><code>receiver consignor count_with_most_consignor count_all c 3 4 5 d 2 4 5 </code></pre> <p>Dataframe</p> <pre class="lang-py prettyprint-override"><code> consignor receiver 0 1 a 1 2 a 2 1 a 3 2 c 4 3 c 5 1 b 6 3 c 7 3 c 8 3 c 9 2 d 10 2 d 11 2 d 12 1 d 13 2 d </code></pre> <p>Code</p> <pre class="lang-py prettyprint-override"><code>import pandas as pd d = {'consignor': [1, 2, 1, 2, 3, 1, 3, 3, 3, 2, 2, 2, 1, 2], 'receiver': ['a', 'a', 'a', 'c', 'c', 'b', 'c', 'c', 'c', 'd', 'd', 'd', 'd', 'd']} df = pd.DataFrame(data=d) print(df) df_ = df.groupby(['receiver','consignor']).size().reset_index(name='counts').sort_values(by=['counts'], ascending=False) print(df_) X = 'c' print(df_[df_['receiver'] == X].shape[1]) print(df_[df_['receiver'] == X]) </code></pre> <p>Out</p> <pre class="lang-py prettyprint-override"><code>[OUT] 3 receiver consignor counts 4 c 3 4 3 c 2 1 </code></pre>
[ { "answer_id": 74170541, "author": "maow", "author_id": 6564620, "author_profile": "https://Stackoverflow.com/users/6564620", "pm_score": 2, "selected": false, "text": "value_counts(normalize=True)" }, { "answer_id": 74170577, "author": "Raibek", "author_id": 11040577, ...
2022/10/23
[ "https://Stackoverflow.com/questions/74170120", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17136258/" ]
74,170,147
<p>I have an app with about 20 Fragments in Android and each of them can write Data into the Firebase Realtime Database. For not implementing the write operation in each of those 20 Fragments, I have created a <code>HelpFunctions</code>class that has the method <code>writeDataIntoFirebaseDB </code></p> <pre><code>public class HelpFunctions { static boolean dataCouldBeWrittenIntoFirebaseDB; public static boolean writeDataIntoFirebaseDB (Object dataBaseEntry, String dbTable, String entryIdPrefix) { dataCouldBeWrittenIntoFirebaseDB = false; long currentTimeMillis = System.currentTimeMillis(); SimpleDateFormat sdf1 = new SimpleDateFormat(&quot;dd-MM-yy&quot;); sdf1.setTimeZone(TimeZone.getTimeZone(&quot;Europe/Berlin&quot;)); SimpleDateFormat sdf2 = new SimpleDateFormat(&quot;HH-mm-ss&quot;); sdf2.setTimeZone(TimeZone.getTimeZone(&quot;Europe/Berlin&quot;)); DatabaseReference rootRef = FirebaseDatabase.getInstance(&quot;https://...&quot;).getReference(); DatabaseReference ordersRef = rootRef.child(dbTable); String entryIdComplete =entryIdPrefix + &quot;_date_&quot; + sdf1.format(new Date()) + &quot;_time_&quot; + sdf2.format(new Date()); ordersRef.child(entryIdComplete).setValue(dataBaseEntry).addOnCompleteListener(new OnCompleteListener&lt;Void&gt;() { @Override public void onComplete(@NonNull Task&lt;Void&gt; task) { if (task.isSuccessful()) { Log.e(&quot;HelpFuncTag&quot;, &quot;Data successfully written.&quot;); dataCouldBeWrittenIntoFirebaseDB = true; } else { Log.e(&quot;HelpFuncTag&quot;, task.getException().getMessage()); dataCouldBeWrittenIntoFirebaseDB = false; } } }); return dataCouldBeWrittenIntoFirebaseDB ; } } </code></pre> <p>The method is called from the 20 Fragments and it should return <code>true</code> or <code>false</code> to the fragments if the writing operation was successfull to Firebase, such that the Fragments can show a message (Snackbar) to the user. When using this approach, the method always returns <code>false</code>, even though the data could be written into Firebase because of the asynchronous operation of Firebase.</p> <p>This is why I tried to implement a callback similarly as explained in this video: <a href="https://www.youtube.com/watch?v=OvDZVV5CbQg&amp;ab_channel=AlexMamo" rel="nofollow noreferrer">https://www.youtube.com/watch?v=OvDZVV5CbQg&amp;ab_channel=AlexMamo</a></p> <p>So I have the following code:</p> <pre><code>public class HelpFunctions { public static boolean writeDataIntoFirebaseDB (Object dataBaseEntry, String dbTable, String entryIdPrefix) { final boolean[] dataCouldBeWrittenIntoFirebaseDB = {false}; long currentTimeMillis = System.currentTimeMillis(); SimpleDateFormat sdf1 = new SimpleDateFormat(&quot;dd-MM-yy&quot;); sdf1.setTimeZone(TimeZone.getTimeZone(&quot;Europe/Berlin&quot;)); SimpleDateFormat sdf2 = new SimpleDateFormat(&quot;HH-mm-ss&quot;); sdf2.setTimeZone(TimeZone.getTimeZone(&quot;Europe/Berlin&quot;)); DatabaseReference rootRef = FirebaseDatabase.getInstance(&quot;https://...&quot;).getReference(); DatabaseReference ordersRef = rootRef.child(dbTable); String entryIdComplete =entryIdPrefix + &quot;_date_&quot; + sdf1.format(new Date()) + &quot;_time_&quot; + sdf2.format(new Date()); HelpFunctions.writeIntoFirebase(new HelpFunctions.FirebaseCallback() { @Override public void onCallBack(boolean writingSuccesfull) { if (writingSuccesfull==true) { dataCouldBeWrittenIntoFirebaseDB[0] = true; } if (writingSuccesfull==false) { dataCouldBeWrittenIntoFirebaseDB[0] = false; } } }, entryIdComplete, dataBaseEntry, ordersRef); return dataCouldBeWrittenIntoFirebaseDB[0]; } private static void writeIntoFirebase (HelpFunctions.FirebaseCallback firebaseCallback, String entryIdComplete, Object dataBaseEntry, DatabaseReference ordersRef ) { boolean dataCouldBeWrittenIntoFirebaseDB = false; ordersRef.child(entryIdComplete).setValue(dataBaseEntry).addOnCompleteListener(new OnCompleteListener&lt;Void&gt;() { @Override public void onComplete(@NonNull Task&lt;Void&gt; task) { if (task.isSuccessful()) { Log.e(&quot;HelpFuncTag&quot;, &quot;Data successfully written.&quot;); firebaseCallback.onCallBack (true); } else { Log.e(&quot;HelpFuncTag&quot;, task.getException().getMessage()); firebaseCallback.onCallBack (false); } } }); }//End write data method private interface FirebaseCallback { void onCallBack(boolean dataCouldBeWrittenIntoFirebase); } } </code></pre> <p>Unfortunately, also the Callback solution always returns false to the Fragments altough the data could be written into the Firebase database. Do you know another approach how to get feedback from Firebase Realtime Database about writing operation in Android?</p>
[ { "answer_id": 74170541, "author": "maow", "author_id": 6564620, "author_profile": "https://Stackoverflow.com/users/6564620", "pm_score": 2, "selected": false, "text": "value_counts(normalize=True)" }, { "answer_id": 74170577, "author": "Raibek", "author_id": 11040577, ...
2022/10/23
[ "https://Stackoverflow.com/questions/74170147", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9437740/" ]
74,170,152
<p>currently I'm able to remove a single character from a string but I can't figure out how I can setup &quot;symbol&quot; so that it can remove multiple characters... any suggestions ?</p> <pre><code>#include &lt;string.h&gt; void remove_character(char *string, char *remove); int main(void){ char s[] = &quot;Thi!s is s!ome tex!t that we'!ll check for plagiarism&quot;; char symbol[] = &quot;!&quot;; printf(&quot;%s\n&quot;, s); remove_character(s, symbol); printf(&quot;%s\n&quot;, s); return(0); } void remove_character(char *string, char *remove){ int position = 0; while (string[position] != '\0') { if (string[position] == *remove){ int newposition = position; while (string[newposition] != '\0') { string[newposition] = string[newposition+1]; newposition++; } } else position++; } } </code></pre>
[ { "answer_id": 74170237, "author": "Filipe", "author_id": 20309644, "author_profile": "https://Stackoverflow.com/users/20309644", "pm_score": 0, "selected": false, "text": "void remove_character(char *string, char remove){\n int position = 0;\n\n while (string[position] != '\\0')\n...
2022/10/23
[ "https://Stackoverflow.com/questions/74170152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20294591/" ]
74,170,172
<p>I know this may sound like another join relational question, but I think the major problem I have is a spaghetti code.</p> <p>Following is the code that I worked with:</p> <pre><code>select fruit, COUNT(fruit) as Total FROM transaction where fruit = 'Apple' GROUP BY fruit; </code></pre> <p>which will give me the value as</p> <pre><code>fruit Total Apple 10 </code></pre> <p>and another query is</p> <pre><code>select customerPhone, count(customerPhone) as Total from CustomerDBTrans where FruitID in (select FruitID from Storage where fruit = 'Apple') Group BY customerPhone; </code></pre> <p>which gives me the value as</p> <pre><code>CustomerPhone Total 111111 10 222222 5 333333 7 444444 10 </code></pre> <p>I need to select from here CustomerPhone 111111 and 444444 as I want to know a customer that bought 'Apple' every single time there was a transaction, and use that PhoneNumber to derive customer name from another table named CustomerDB.</p> <p>I was thinking of using Outer Join, but then realized that ain't gonna work, and tried to look through over my textbook for last 4 hours.</p> <p>What could be the right function to use in this kind of case?</p> <p>Kinda stucked cause most of the tutorial material that I have access to only shows the case where both table has a same number of rows.</p>
[ { "answer_id": 74170257, "author": "MT0", "author_id": 1509264, "author_profile": "https://Stackoverflow.com/users/1509264", "pm_score": 0, "selected": false, "text": "HAVING" }, { "answer_id": 74170535, "author": "d r", "author_id": 19023353, "author_profile": "https...
2022/10/23
[ "https://Stackoverflow.com/questions/74170172", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8898659/" ]
74,170,173
<p>I understand the difference between them.</p> <p>OnInitializedAsync fires once when the component is Initialized where as OnParametersSetAsync fires each time the components parameter is set/changed.</p> <p>does it mean that in the .razor page we can omit OnInitializedAsync function and do all the coding in this OnParametersSetAsync() function?</p> <p>does it mean OnInitializedAsync() is redundant?</p>
[ { "answer_id": 74170389, "author": "Dimitris Maragkos", "author_id": 10839134, "author_profile": "https://Stackoverflow.com/users/10839134", "pm_score": 3, "selected": true, "text": "SortDirection" }, { "answer_id": 74177568, "author": "MrC aka Shaun Curtis", "author_id":...
2022/10/23
[ "https://Stackoverflow.com/questions/74170173", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4679505/" ]
74,170,184
<p>I'm trying to upload image to website, It was successful but app shows FETAL error.</p> <p>issue seems like in AsyncTask as it might get executed to early.</p> <p>I also upgraded SDK version 30 to 32 &amp; ucrop:2.2.5</p> <pre><code>package com.myappname.dating.ui.home.profileImageUploading import android.app.Activity import android.content.Intent import android.graphics.Color import android.net.Uri import android.os.AsyncTask import android.os.Bundle import android.view.View import android.widget.Toast import androidx.appcompat.app.AppCompatActivity import com.myappname.dating.R import com.myappname.dating.data.db.CrushDataBase import com.myappname.dating.data.network.ApiHelper import com.myappname.dating.data.network.model.profileRespo.ProfileStatus import com.myappname.dating.data.network.model.user.Mediafile import com.myappname.dating.data.network.model.user.UserResponse import com.myappname.dating.data.pref.AppPreferencesHelper import com.myappname.dating.ui.login.LoginActivity import com.myappname.dating.ui.utils.AppConstants import com.myappname.dating.ui.utils.CommonUtil import com.yalantis.ucrop.UCrop import kotlinx.android.synthetic.main.activity_user_image_crop.* import kotlinx.android.synthetic.main.activity_user_image_crop.pb_load import okhttp3.MediaType.Companion.toMediaTypeOrNull import okhttp3.MultipartBody import okhttp3.RequestBody import okhttp3.RequestBody.Companion.asRequestBody import okhttp3.RequestBody.Companion.toRequestBody import retrofit2.Call import retrofit2.Callback import retrofit2.Response import java.io.File @Suppress(&quot;NULLABILITY_MISMATCH_BASED_ON_JAVA_ANNOTATIONS&quot;) class UserImageCropActivity : AppCompatActivity(), View.OnClickListener, CropImageView { internal val IMAGE_REQUEST_CODE = 123 internal val CROP_IMAGE_NAME = &quot;cropImage&quot; private lateinit var mImageCropPresenter : ImageCropPresenter lateinit var from : String var imageUriResultCrop: Uri? = null var uriString: String? = null lateinit var mPref: AppPreferencesHelper var mCrushDataBase: CrushDataBase? = null lateinit var userResponse: UserResponse; override fun onCreate(savedInstanceState : Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_user_image_crop) mPref = AppPreferencesHelper(applicationContext, AppConstants.PREF_NAME) val view: View = findViewById(R.id.imageCropActivity) mCrushDataBase = CrushDataBase.getDatabase(this) mImageCropPresenter = ImageCropPresenterImpl(this, this, view) if(intent != null){ from = intent.getStringExtra(&quot;From&quot;).toString() } if(from.equals(&quot;Signup&quot;)){ //Toast.makeText(applicationContext, &quot;Uploaded&quot;, Toast.LENGTH_SHORT).show() } else { userResponse = getDataTask(this).execute().get() } val galleryIntent = Intent(Intent.ACTION_PICK) galleryIntent.type = &quot;image/*&quot; if(galleryIntent.resolveActivity(packageManager) != null) { startActivityForResult( Intent.createChooser(galleryIntent, &quot;Select Picture&quot;), IMAGE_REQUEST_CODE ) } uploadBtn.setOnClickListener(this) } override fun onActivityResult(requestCode: Int, resultCode: Int, data: Intent?) { super.onActivityResult(requestCode, resultCode, data) if (requestCode == IMAGE_REQUEST_CODE &amp;&amp; resultCode == Activity.RESULT_OK) { val imageUri = data?.data if (imageUri != null) { startCrop(imageUri) } else { uploadBtn.visibility = View.GONE finish() // if (from == &quot;&quot;) { // // } // else if(from == &quot;&quot;) // { // // } } } else { imageUriResultCrop = data?.let { UCrop.getOutput(it) } uriString = imageUriResultCrop?.path if (imageUriResultCrop != null) { result_image.setImageURI(imageUriResultCrop) uploadBtn.visibility = View.VISIBLE } else { uploadBtn.visibility = View.GONE finish() } } } private fun startCrop(uri: Uri) { var destinationFileName = CROP_IMAGE_NAME destinationFileName += &quot;.jpg&quot; val uCrop = UCrop.of(uri, Uri.fromFile(File(cacheDir, destinationFileName))) uCrop.withAspectRatio(1F, 1F) uCrop.withMaxResultSize(800, 800) uCrop.withOptions(getCropOptions()) uCrop.start(this) } private fun getCropOptions() : UCrop.Options { val options = UCrop.Options() options.setHideBottomControls(false) options.setFreeStyleCropEnabled(true) options.setStatusBarColor(resources.getColor(R.color.colorPrimaryDark)) options.setToolbarColor(resources.getColor(R.color.colorPrimary)) return options } override fun onClick(v: View?) { when (v?.id) { R.id.uploadBtn -&gt; { if (uriString == null || uriString == &quot;&quot;) { Toast.makeText(applicationContext, &quot;please select an image &quot;, Toast.LENGTH_LONG) .show() return } else { val file = File(imageUriResultCrop?.path) val requestFile = file.asRequestBody(&quot;multipart/form-data&quot;.toMediaTypeOrNull()) val body = MultipartBody.Part.createFormData(&quot;avater&quot;, file.name, requestFile) val accessToken: String? = mPref.getAccessToken() val requestBody = accessToken?.toRequestBody(MultipartBody.FORM) if (from.equals(&quot;Signup&quot;)){ updateAvater(requestBody,body) }else if(from.equals(&quot;ProfileAct&quot;)){ updateAvaterp(requestBody,body) }else if(from.equals(&quot;userImage&quot;)){ updateAvaterG(requestBody,body) }else if(from.equals(&quot;userImageD&quot;)){ updateAvaterGal(requestBody,body) } else{ mImageCropPresenter.imageCropUploadPresenter(requestBody, body) } } uploadBtn.isClickable = false uploadBtn.setBackgroundColor(Color.parseColor(&quot;#e4e6e8&quot;)) } } } fun updateAvaterp( access_token: RequestBody?, avater: MultipartBody.Part ) { ApiHelper().updateAvaterImage(access_token, avater) .enqueue(object : Callback&lt;ProfileStatus&gt; { override fun onFailure(call: Call&lt;ProfileStatus&gt;, t: Throwable) { Toast.makeText(applicationContext, &quot;Failed to upload please select another image or check internet&quot;, Toast.LENGTH_SHORT) .show() uploadBtn.isClickable = true uploadBtn.setBackgroundColor(Color.parseColor(&quot;#2196f3&quot;)) } override fun onResponse( call: Call&lt;ProfileStatus&gt;, response: Response&lt;ProfileStatus&gt; ) { if (response.isSuccessful) { val updateCheck = UpdateTaskA( this@UserImageCropActivity, response.body()!!.picurl, userResponse.id ).execute().get() Toast.makeText(applicationContext, &quot;Profile Upload Successfully&quot;, Toast.LENGTH_SHORT).show() finish() } } }) } fun updateAvaterG( access_token: RequestBody?, avater: MultipartBody.Part ) { ApiHelper().updateAvaterImage(access_token, avater) .enqueue(object : Callback&lt;ProfileStatus&gt; { override fun onFailure(call: Call&lt;ProfileStatus&gt;, t: Throwable) { Toast.makeText(applicationContext, &quot;Failed to upload please select another image or check internet&quot;, Toast.LENGTH_SHORT) .show() } override fun onResponse( call: Call&lt;ProfileStatus&gt;, response: Response&lt;ProfileStatus&gt; ) { if (response.isSuccessful) { val updateCheck = UpdateTaskG(this@UserImageCropActivity, response.body()!!.picurl, userResponse!!.id ).execute().get() Toast.makeText(applicationContext, &quot;Profile Upload Successfully&quot;, Toast.LENGTH_SHORT).show() finish() } } }) } fun updateAvaterGal( access_token: RequestBody?, avater: MultipartBody.Part ) { ApiHelper().uploadImage(access_token, avater) .enqueue(object : Callback&lt;ProfileStatus&gt; { override fun onFailure(call: Call&lt;ProfileStatus&gt;, t: Throwable) { Toast.makeText(applicationContext, &quot;Failed to upload please select another image or check internet&quot;, Toast.LENGTH_SHORT) .show() } override fun onResponse( call: Call&lt;ProfileStatus&gt;, response: Response&lt;ProfileStatus&gt; ) {if (response.isSuccessful) { // val updateCheck = UpdateTaskG(this@UserImageCropActivity, response.body()!!.picurl, userResponse!!.id ).execute().get() Toast.makeText(applicationContext, &quot;Image Upload Successfully&quot;, Toast.LENGTH_SHORT).show() // finish() // var lnk = response.body()!!.file_url // response.body().picurl val intent = Intent(applicationContext, UserImageGalleryActivity::class.java) // intent.putExtra(&quot;fileurl&quot;, lnk) // intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_CLEAR_TASK startActivity(intent) //startActivity(Intent(this, UserImageGalleryActivity::class.java)) } } }) } fun updateAvater( access_token: RequestBody?, avater: MultipartBody.Part ) { ApiHelper().updateAvaterImage(access_token, avater) .enqueue(object : Callback&lt;ProfileStatus&gt; { override fun onFailure(call: Call&lt;ProfileStatus&gt;, t: Throwable) { Toast.makeText(applicationContext, &quot;Failed to upload please select another image or check internet&quot;, Toast.LENGTH_SHORT) .show() } override fun onResponse( call: Call&lt;ProfileStatus&gt;, response: Response&lt;ProfileStatus&gt; ) { if (response.isSuccessful) { val intent = Intent(applicationContext, LoginActivity::class.java) intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_CLEAR_TASK startActivity(intent) finish() } } }) } override fun showProgressBar() { pb_load.visibility = View.VISIBLE } override fun hideProgressBar() { pb_load.visibility = View.GONE } override fun onSuccess(id: String) { var value: List&lt;Mediafile&gt; // val updateCheck = UpdateTask(this,map).execute().get() Toast.makeText(applicationContext, &quot;Image Upload Successfully$id&quot;, Toast.LENGTH_LONG).show() finish() } override fun onFailure(message: String) { Toast.makeText( applicationContext, &quot;Image not upload Something went wrong&quot;+message, Toast.LENGTH_LONG ).show() finish() } override fun backToActivity() { val intent = Intent(applicationContext, UserImageGalleryActivity::class.java) intent.flags = Intent.FLAG_ACTIVITY_CLEAR_TOP or Intent.FLAG_ACTIVITY_NEW_TASK startActivity(intent) finish() } override fun onDestroy() { super.onDestroy() mImageCropPresenter.onDestroy() } private class UpdateTask(var context: UserImageCropActivity, var value: List&lt;Mediafile&gt;?) : AsyncTask&lt;Void, Void, Boolean&gt;() { override fun doInBackground(vararg params: Void?): Boolean { context.mCrushDataBase!!.crushDao().updateMediaFile(value, 1) return true } override fun onPostExecute(bool: Boolean?) { if (bool!!) { } } } class UpdateTaskA(var context: UserImageCropActivity, var avatar: String,var id : Int) : AsyncTask&lt;Void, Void, Boolean&gt;() { override fun doInBackground(vararg params: Void?): Boolean { val imageAvatar = CommonUtil.convertToString64(avatar) context.mCrushDataBase!!.crushDao().updateAvatar(imageAvatar!!, id) return true } override fun onPostExecute(bool: Boolean?) { if (bool!!) { } } } class UpdateTaskG(var context: UserImageCropActivity, var avatar: String, var user: Int) : AsyncTask&lt;Void, Void, Boolean&gt;() { override fun doInBackground(vararg params: Void?): Boolean { val imageAvatar = CommonUtil.convertToString64(avatar) context.mCrushDataBase!!.crushDao().updateAvatar(imageAvatar!!, user) return true } override fun onPostExecute(bool: Boolean?) { if (bool!!) { } } } class getDataTask(var context: UserImageCropActivity) : AsyncTask&lt;Void, Void, UserResponse&gt;() { override fun doInBackground(vararg params: Void?): UserResponse { var listOfdata = context.mCrushDataBase!!.crushDao().getData() val data = listOfdata[0] return data } override fun onPostExecute(userResponse: UserResponse?) { } } } </code></pre> <p>Error was displayed in line</p> <pre><code> FATAL EXCEPTION: main Process: com.myappname.dating, PID: 17170 java.lang.NullPointerException: Parameter specified as non-null is null: method kotlin.jvm.internal.Intrinsics.checkNotNullParameter, parameter avatar at com.myappname.dating.ui.home.profileImageUploading.UserImageCropActivity$UpdateTaskA.&lt;init&gt;(Unknown Source:7) at com.myappname.dating.ui.home.profileImageUploading.UserImageCropActivity$updateAvaterp$1.onResponse(UserImageCropActivity.kt:190) </code></pre>
[ { "answer_id": 74170892, "author": "Sergio", "author_id": 1731626, "author_profile": "https://Stackoverflow.com/users/1731626", "pm_score": 0, "selected": false, "text": "!!" }, { "answer_id": 74173594, "author": "cactustictacs", "author_id": 13598222, "author_profile...
2022/10/23
[ "https://Stackoverflow.com/questions/74170184", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14100027/" ]
74,170,198
<p>Anybody know, How to directing user to <strong>Device Admin App</strong> page programtically in react native ?</p> <p>so, all into application without user have to go to manual menu in Settings &gt; Privacy &gt; Manage &gt; Special app access &gt; Device Admin Apps..</p> <p>Thanks in advance</p> <p><a href="https://i.stack.imgur.com/0ZRET.png" rel="nofollow noreferrer">Device admin apps Image</a> <a href="https://i.stack.imgur.com/EY21L.jpg" rel="nofollow noreferrer">Checklist for permission apps Image</a></p>
[ { "answer_id": 74170892, "author": "Sergio", "author_id": 1731626, "author_profile": "https://Stackoverflow.com/users/1731626", "pm_score": 0, "selected": false, "text": "!!" }, { "answer_id": 74173594, "author": "cactustictacs", "author_id": 13598222, "author_profile...
2022/10/23
[ "https://Stackoverflow.com/questions/74170198", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20278389/" ]
74,170,204
<p><a href="https://i.stack.imgur.com/Z7Sy5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Z7Sy5.png" alt="enter image description here" /></a></p> <p>I want to import only the agent name and its &quot;Twitter user&quot; but if &quot;F&quot; is empty then ignore it. How? I have tried &quot;Query&quot; but its not working. I want to import it to another sheet in the same general sheet. Thank you</p>
[ { "answer_id": 74173681, "author": "player0", "author_id": 5632629, "author_profile": "https://Stackoverflow.com/users/5632629", "pm_score": 3, "selected": true, "text": "=QUERY(Sheet1!A:F; \"select A,F where F is not null\"; )\n" } ]
2022/10/23
[ "https://Stackoverflow.com/questions/74170204", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20042190/" ]
74,170,218
<p>I have the two lists below:</p> <pre><code>list1 = [(1, 'A'), (2, 'B'), (3, '?'), (4, 'T'), (5, 'A'), (6, 'B'), (7, '?'), (8, 'T')] list2 = [(2, 'D'), (6, 'E'), (7, '!'), (10, 'T')] </code></pre> <p>I need to remove from <code>list1</code> the elements in common with <code>list2</code> that are in first position. So, I've used the for loop below:</p> <pre><code>for x in list1: id_list1 = x[0] for y in list2: id_list2 = y[0] if id_list1 == id_list2: list1.remove(x) </code></pre> <p>The output is: <code>[(1, 'A'), (3, '?'), (4, 'T'), (5, 'A'), (7, '?'), (8, 'T')]</code></p> <p>The result is strange because I see <code>(7, '?')</code> in <code>list1</code> but not <code>(2, 'B')</code> and <code>(6, 'B')</code>. The last two tuples are correctly removed, but why not <code>(7, '?')</code>?</p> <p>The expected output is: <code>[(1, 'A'), (3, '?'), (4, 'T'), (5, 'A'), (8, 'T')]</code></p>
[ { "answer_id": 74170244, "author": "S.B", "author_id": 13944524, "author_profile": "https://Stackoverflow.com/users/13944524", "pm_score": 2, "selected": true, "text": "list1 = [(1, \"A\"), (2, \"B\"), (3, \"?\"), (4, \"T\"), (5, \"A\"), (6, \"B\"), (7, \"?\"), (8, \"T\")]\nlist2 = [(2, ...
2022/10/23
[ "https://Stackoverflow.com/questions/74170218", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10012856/" ]
74,170,224
<p>I have a Next JS frontend and Laravel 9 as backend. Created APIs and tested them on the postman. All of the API's working fine without any issues.</p> <p><strong>The Problem</strong></p> <p>So I have created a Nextjs file with a form and posted data using Axios. I am getting <code>Error: Request failed with status code 419</code>.</p> <p><strong>Tried</strong></p> <p>There are multiple answers available on StackOverflow for similar questions. I followed the answers but nothing worked for the problem.</p> <ol> <li><p>Changed VerifyCsrfToken.php code to disable the csrf protection. (i want to keep the csrf)</p> </li> <li><p>Tried adding the csrf cookie using the headers option in Axios. (<a href="https://stackoverflow.com/q/70830662/17486591">Axios POST to Laravel API results in 419 error</a>)</p> </li> <li><p>Generated key using (PHP artisan key: generate)</p> </li> <li><p>Added Session domain</p> </li> <li><p>added route in the web middleware</p> </li> </ol> <pre><code>Route::group(['middleware' =&gt; ['api']], function () { // our routes }); </code></pre> <p><strong>What's working ?</strong></p> <ol> <li>Allowing all domains in VerifyCsrfToken.php is working.</li> </ol> <p><strong>I want to get csrf token</strong></p> <p>`const csrf = () =&gt; axios.get('/sanctum/csrf-cookie')'</p> <p>i am getting empty value for csrf token / csrf cookie. and found no accepted answer to the request failed with status code 419.</p> <p>Does anyone know what I am doing wrong?</p>
[ { "answer_id": 74170391, "author": "Jeybin George", "author_id": 10433322, "author_profile": "https://Stackoverflow.com/users/10433322", "pm_score": 1, "selected": false, "text": "web" }, { "answer_id": 74170506, "author": "didene tahi", "author_id": 7263394, "author_...
2022/10/23
[ "https://Stackoverflow.com/questions/74170224", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17486591/" ]
74,170,239
<p>I am only interested in the occurrence of one certain character, for example, 'stateA' so I do not want to use table() as suggested in most answers I can find. And I wish to store the count as a new DF or in the last row. What is the tidiest way to do this? Thank you very much.</p> <p>The data looks like</p> <pre><code>df &lt;- data.frame( var1 = c(paste0('state', sample(LETTERS[1:20], 1000, replace = T))), var2 = c(paste0('state', sample(LETTERS[1:20], 1000, replace = T))), var3 = c(paste0('state', sample(LETTERS[1:20], 1000, replace = T))), var4 = c(paste0('state', sample(LETTERS[1:20], 1000, replace = T))), var5 = c(paste0('state', sample(LETTERS[1:20], 1000, replace = T))) ) </code></pre>
[ { "answer_id": 74170391, "author": "Jeybin George", "author_id": 10433322, "author_profile": "https://Stackoverflow.com/users/10433322", "pm_score": 1, "selected": false, "text": "web" }, { "answer_id": 74170506, "author": "didene tahi", "author_id": 7263394, "author_...
2022/10/23
[ "https://Stackoverflow.com/questions/74170239", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13599401/" ]
74,170,247
<p>I tried below code to private route the admin dash board i am using react-router-dom:6.2.2. I need help to figure out private route which could be accessed only by the admin. I tried all the existing solution in the stackoverflow .</p> <p>app.js</p> <pre><code> &lt;BrowserRouter&gt; &lt;Routes&gt; &lt;Route path=&quot;/admin/dashboard&quot; element={&lt;PrivateRouter&gt;&lt;Dashboard /&gt; &lt;/PrivateRouter&gt;} /&gt; &lt;/Routes&gt; &lt;/BrowserRouter&gt; </code></pre> <p>Private Router.js</p> <pre><code> &lt;Route {...rest} component={(props) =&gt; { const token = window.localStorage.getItem(&quot;userInfo&quot;); console.log(token) if (token) { return &lt;Component {...props} /&gt;; } else { return &lt;Navigate to={&quot;/login&quot;} /&gt;; } }} /&gt; ); } </code></pre> <p>And its throwing error on console</p> <pre><code>index.tsx:24 Uncaught Error: A &lt;Route&gt; is only ever to be used as the child of &lt;Routes&gt; element, never rendered directly. Please wrap your &lt;Route&gt; in a &lt;Routes&gt;. at invariant (index.tsx:24:1) at Route (index.tsx:235:1) at renderWithHooks (react-dom.development) </code></pre>
[ { "answer_id": 74267699, "author": "Elbashir Saror", "author_id": 20033482, "author_profile": "https://Stackoverflow.com/users/20033482", "pm_score": 0, "selected": false, "text": "<Route path=\"/admin/dashboard\" element={<Dashboard />} />\n" }, { "answer_id": 74268045, "aut...
2022/10/23
[ "https://Stackoverflow.com/questions/74170247", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16487951/" ]
74,170,271
<p>I've been struggling with something for quite a long time so I thought I would ask my question here. I have a list of lists that looks like this : list = [[2,3,4,5,2,3],[3,4,1,6,9,9]] Inside, there is, as you can see, two lists that have the same number of elements. I also have what i call an &quot;index list&quot; that looks like this : index = [0,2,4] What I've been trying to do is essentially to put a specific number inside each list of my list of lists at each given index of my index list.</p> <p>For example, in my case, my goal is to put insert a 1 in my list in each of my 2 lists at the index 0, 2 and 4 (because my index list = [0,2,4]).</p> <p>To be more clear, the ouput I would like to get is this : [[<strong>1</strong>,2,3,<strong>1</strong>,4,5,<strong>1</strong>,2,3],[<strong>1</strong>,3,4,<strong>1</strong>,1,6,<strong>1</strong>,9,9]] Each 1 is inserted in each list of my list of lists at the index 0,2,4 of each lists.</p> <p>But I've been really struggling to achieve that : I found an answer that works for a simple list but I can't make it work for a list of multiple lists.</p> <p>I would appreciate it a lot if someone could help me ! Thanks a lot !</p>
[ { "answer_id": 74267699, "author": "Elbashir Saror", "author_id": 20033482, "author_profile": "https://Stackoverflow.com/users/20033482", "pm_score": 0, "selected": false, "text": "<Route path=\"/admin/dashboard\" element={<Dashboard />} />\n" }, { "answer_id": 74268045, "aut...
2022/10/23
[ "https://Stackoverflow.com/questions/74170271", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20313724/" ]
74,170,278
<p>I want to get my custom error from <code>validate_image</code> this is my models.py</p> <pre><code>def validate_image(image): valid_image_extensions = ['jpg', 'png', 'jpeg'] input_extension = str(image).split('.')[1] if input_extension not in valid_image_extensions: raise ValidationError( f&quot;We aren't accepted your extension - {input_extension} only accepted {','.join(valid_image_extensions)}&quot; ) class Image(models.Model): description = models.CharField(null=True, default='Image', blank=True, max_length=120) image = models.ImageField(upload_to='images', validators=[validate_image]) </code></pre> <p>When i try upload image with <code>.raw</code> extension i expected my custom validation but i have error from django.</p> <pre><code>{ &quot;image&quot;: [ &quot;File extension “raw” is not allowed. Allowed extensions are: bmp, dib, gif, tif, tiff, jfif, jpe, jpg, jpeg, pbm, pgm, ppm, pnm, png, apng, blp, bufr, cur, pcx, dcx, dds, ps, eps, fit, fits, fli, flc, ftc, ftu, gbr, grib, h5, hdf, jp2, j2k, jpc, jpf, jpx, j2c, icns, ico, im, iim, mpg, mpeg, mpo, msp, palm, pcd, pdf, pxr, psd, bw, rgb, rgba, sgi, ras, tga, icb, vda, vst, webp, wmf, emf, xbm, xpm.&quot; ] } </code></pre> <p>How i can run custom validation before django validation ?</p>
[ { "answer_id": 74267699, "author": "Elbashir Saror", "author_id": 20033482, "author_profile": "https://Stackoverflow.com/users/20033482", "pm_score": 0, "selected": false, "text": "<Route path=\"/admin/dashboard\" element={<Dashboard />} />\n" }, { "answer_id": 74268045, "aut...
2022/10/23
[ "https://Stackoverflow.com/questions/74170278", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17821661/" ]
74,170,281
<p><strong># This is my purchase dataframe</strong></p> <pre><code>data = { 'order_date': ['2022-01-02' , '2022-05-03' , '2022-02-01' , '2022-09-30'], 'order_id' : ['001' , '002' , '003' , '004'], 'item_code': ['12-05', '13-05', '13-05' , '12-05' ], 'price': [20, 21, 19,17], } df_purchase = pd.DataFrame (data) df_purchase order_date order_id item_code price 2022-01-02 001 12-05 20 2022-05-03 002 13-05 21 2022-02-01 003 13-05 19 2022-09-30 004 12-05 17 </code></pre> <p><strong>I have wanted to get the last purchase price of the item according the order_date like below</strong></p> <pre><code> order_date order_id item_code price 2022-05-03 002 13-05 21 2022-09-30 004 12-05 17 </code></pre> <p>I have tried in many ways but couldn't achieve the result.</p>
[ { "answer_id": 74170342, "author": "Rabinzel", "author_id": 15521392, "author_profile": "https://Stackoverflow.com/users/15521392", "pm_score": 2, "selected": true, "text": "(\n df_purchase\n .sort_values(['item_code', 'order_date'])\n .groupby('item_code', as_index=False)\n ...
2022/10/23
[ "https://Stackoverflow.com/questions/74170281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11778948/" ]
74,170,340
<p>Currently, a part of my r assignment is to take a set of time zones and then adding a new column that shows its location. For example, if <code>Timezone = &quot;GMT+1:00 Europe/Andorra&quot;</code>, then <code>Timezone_Continent = &quot;Europe&quot;</code>. <a href="https://i.stack.imgur.com/TKg6V.png" rel="nofollow noreferrer">Picture of the dataframe</a>. How can I select specific columns with keywords like &quot;Europe&quot; or &quot;America&quot; in a way that I can use them with gsub?</p> <pre><code>df[&quot;Timezone_Continent&quot;] &lt;- df$Timezone ame &lt;- df$Timezone[grep(&quot;America&quot;, df$Timezone)] df[&quot;Timezone_Continent&quot;] &lt;- gsub(ame, &quot;America&quot;, df[&quot;Timezone_Continent&quot;]) </code></pre> <p>This is what I currently have, and I know that the second line wouldnt work for gsub. I was sort of just experimenting.</p>
[ { "answer_id": 74170458, "author": "Allan Cameron", "author_id": 12500315, "author_profile": "https://Stackoverflow.com/users/12500315", "pm_score": 0, "selected": false, "text": "lookup <- c(\"America\", \"Europe\")\n" }, { "answer_id": 74170689, "author": "utubun", "aut...
2022/10/23
[ "https://Stackoverflow.com/questions/74170340", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18184655/" ]
74,170,346
<p>I'm trying to write a program, that will sum numbers of a string value(ex. &quot;1+2+3&quot; = 1+2+3). When i'm tried to get first element of string value(&quot;3&quot;), convert and add it to Result, IDE straightaway gave him - 51. Can anyone explain me, why does it happen so?</p> <pre><code>static void SumString(string num, ref int index, ref int result) { if(index &gt;= num.Length - 1) { Console.WriteLine(result); return; } result += Convert.ToInt32(num[index]); index++; SumString(num, ref index, ref result); } </code></pre>
[ { "answer_id": 74170458, "author": "Allan Cameron", "author_id": 12500315, "author_profile": "https://Stackoverflow.com/users/12500315", "pm_score": 0, "selected": false, "text": "lookup <- c(\"America\", \"Europe\")\n" }, { "answer_id": 74170689, "author": "utubun", "aut...
2022/10/23
[ "https://Stackoverflow.com/questions/74170346", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18006503/" ]
74,170,368
<p>I have two tables calendar and team, to simplify : in <code>calendar</code> table i have <code>Id</code>, <code>team_id1</code>, <code>team_id2</code> and <code>date</code>, and in <code>team</code> table i have <code>Id</code>, <code>name</code> and <code>image</code>. I have to select all columns of calendars and also team names and images associated, i used this query, it works but i think i execute more than 3 queries in one. Can you suggest me more effective please :</p> <pre><code>SELECT *, calendar.team_id1,calendar.team_id2, (select team.Name from team where team.Id = calendar.team_id1 ) AS 'TeamName1', (select team.Name from team where team.Id = calendar.team_id2 ) AS 'TeamName2', (select team.Image from team where team.Id = calendar.team_id1 ) AS 'TeamImage1', (select team.Image from team where team.Id = calendar.team_id2 ) AS 'TeamImage2' FROM calendrier ORDER BY calendar.Date DESC </code></pre> <p>Thank you.</p>
[ { "answer_id": 74170458, "author": "Allan Cameron", "author_id": 12500315, "author_profile": "https://Stackoverflow.com/users/12500315", "pm_score": 0, "selected": false, "text": "lookup <- c(\"America\", \"Europe\")\n" }, { "answer_id": 74170689, "author": "utubun", "aut...
2022/10/23
[ "https://Stackoverflow.com/questions/74170368", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15862710/" ]
74,170,387
<p>I am fetching my backend using axios. The data is fetched correctly. I am using MongoDb. I can see that the state has changed to an array of objects correctly in the react dev tools. However, it is not being displayed in my webpage.</p> <p>This is a simple code, i am testing the api, I could not figure out what is wrong because it is pretty much straightforward and i have no clue why it is not working.</p> <p>this is my code</p> <pre><code>import axios from &quot;axios&quot;; import React, { useEffect, useState } from &quot;react&quot;; function ApiTest() { const [users, setUsers] = useState([]); const fetchUsers = () =&gt; { axios .get(&quot;/api/users&quot;) .then((response) =&gt; { setUsers(response.data); console.log(response.data); }) .catch((err) =&gt; { console.log(err); }); }; return ( &lt;div&gt; &lt;button onClick={fetchUsers}&gt;Fetch Users&lt;/button&gt; &lt;ul&gt; {users.map((user) =&gt; { &lt;li key={user._id}&gt;{user.emai}&lt;/li&gt;; })} &lt;/ul&gt; &lt;/div&gt; ); } export default ApiTest; </code></pre>
[ { "answer_id": 74170406, "author": "Ozan Mudul", "author_id": 12260088, "author_profile": "https://Stackoverflow.com/users/12260088", "pm_score": 3, "selected": true, "text": "{users.map((user) => {\n return <li key={user._id}>{user.emai}</li>;\n})}\n" }, { "answer_id": 74170471...
2022/10/23
[ "https://Stackoverflow.com/questions/74170387", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18396390/" ]
74,170,429
<p>I can't figure out how to make this in regular css or tailwind, any help appreciated, tried using a grid but couldn't make it compact enough, example below. Example of what it should look like.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;script src="https://cdn.tailwindcss.com"&gt;&lt;/script&gt; &lt;div class="w-2/3 grid grid-rows-2 grid-flow-col justify-center gap-y-0 self-center"&gt; &lt;h1 class="text-[256px] font-bold font-mono flex md:text-light-blue row-span-2"&gt;PR&lt;/h1&gt; &lt;h1 class="text-[90px] font-bold font-mono flex md:text-light-blue items-end p-0"&gt;ESIDENT&lt;/h1&gt; &lt;h1 class="text-[90px] font-bold font-mono flex md:text-light-blue items-start p-0"&gt;IZE&lt;/h1&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p><a href="https://i.stack.imgur.com/48JKv.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/48JKv.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/vE55t.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vE55t.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74170598, "author": "ChenBr", "author_id": 17718587, "author_profile": "https://Stackoverflow.com/users/17718587", "pm_score": 1, "selected": false, "text": "grid" }, { "answer_id": 74170620, "author": "Rizeen", "author_id": 8782141, "author_profile": "...
2022/10/23
[ "https://Stackoverflow.com/questions/74170429", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19476059/" ]
74,170,438
<p>I have the following Django models:</p> <pre class="lang-py prettyprint-override"><code>class Owner(models.Model): name = models.CharField(max_length=30) class Dog(models.Model): name = models.CharField(max_length=30) owner = models.ForeignKey(Owner) class GoForAWalk(models.Model): date = models.DateTimeField() location = models.CharField() owner = models.ForeignKey(Owner) dog = models.ForeignKey(Dog) </code></pre> <p>I want that a <code>Owner</code> can only <code>GoForAWalk</code> with one of his own <code>Dog</code>.</p> <p>Currently any owner can go for a walk with any dog.</p> <p>Would you restrict this via model validators or via some logic during the creation of a new <code>GoForAWalk</code> object?</p> <p>Can anyone provide an example? I'm quite stuck.</p> <p>Thanks a lot!</p> <p>Cheers, Philipp</p>
[ { "answer_id": 74170501, "author": "Yevhen Kuzmovych", "author_id": 4727702, "author_profile": "https://Stackoverflow.com/users/4727702", "pm_score": 3, "selected": true, "text": "GoForAWalk" }, { "answer_id": 74170518, "author": "Lucas Grugru", "author_id": 16984466, ...
2022/10/23
[ "https://Stackoverflow.com/questions/74170438", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11751491/" ]
74,170,494
<p>When you first run the component, it should display &quot;1&quot;, and on button click, append it by 3, which it does. Value inside localstorage also changes, but when i reload the page, localstorage changes again to 1... what am i missing?</p> <pre><code>import { useState, useEffect } from 'react' function Test() { const [testNum, setTestNum] = useState(1); useEffect(() =&gt; { const data = window.localStorage.getItem(&quot;MY_TEST_ITEM&quot;); setTestNum(JSON.parse(data)); }, []); useEffect(() =&gt; { window.localStorage.setItem(&quot;MY_TEST_ITEM&quot;, JSON.stringify(testNum)) }, [testNum]); return ( &lt;div&gt; &lt;h1&gt;{testNum}&lt;/h1&gt; &lt;button onClick={() =&gt; { setTestNum(testNum + 3) }}&gt;Add&lt;/button&gt; &lt;/div&gt; ) } export default Test </code></pre>
[ { "answer_id": 74170536, "author": "mohammad mohammadi nodhe", "author_id": 14099191, "author_profile": "https://Stackoverflow.com/users/14099191", "pm_score": 1, "selected": false, "text": "const [testNum, setTestNum] = useState(window.localStorage.getItem(\"MY_TEST_ITEM\") === null ? 1...
2022/10/23
[ "https://Stackoverflow.com/questions/74170494", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20137771/" ]
74,170,496
<p>What am I doing wrong? At Start() the GameObject gets instantiated and saved in <code>_blockedMatter</code>. After clicking on a specific field the objects should get destroyed but I get an error</p> <blockquote> <p>Error CS0103: The name '_blockedMatter' does not exist in the current context</p> </blockquote> <p>So it does not get saved there?</p> <pre><code>void Start() { ... GameObject _blockedMatter = (GameObject)Instantiate(buildmanager.blockedMatter, GetBuildPosition(), Quaternion.identity); ... } ... public void unlock() { ... Destroy(_blockedMatter); ... } </code></pre> <p>But why does this work then?</p> <pre><code>... GameObject _cleaningEffect = (GameObject)Instantiate(buildmanager.cleaningEffect, GetBuildPosition(), Quaternion.identity); Destroy(_cleaningEffect, 5f); ... </code></pre>
[ { "answer_id": 74170527, "author": "vivek nuna", "author_id": 6527049, "author_profile": "https://Stackoverflow.com/users/6527049", "pm_score": 1, "selected": false, "text": "_blockedMatter" }, { "answer_id": 74170537, "author": "Geeky Quentin", "author_id": 17235431, ...
2022/10/23
[ "https://Stackoverflow.com/questions/74170496", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20307382/" ]
74,170,557
<p>I am trying to create a python file and then convert it into an EXE. This is my current code:</p> <pre><code>from cx_Freeze import setup, Executable spyerFile = open(&quot;myFile.py&quot;, &quot;w+&quot;) spyerFile.write(&quot;print(\&quot;Hello, world!\&quot;)&quot;) # creating the python file spyerFile.close() executables = [Executable(&quot;myFile.py&quot;, base=None)] packages = [&quot;idna&quot;, &quot;os&quot;, &quot;sys&quot;] options = { &quot;build_exe&quot;: { &quot;packages&quot;:packages, }, } setup( # converting the python file to an exe file name = &quot;myFile&quot;, options = options, version = &quot;10.0&quot;, description = &quot;&quot;, executables = executables ) </code></pre> <p>But I am getting this error:</p> <pre><code>usage: myFile.py [global_opts] cmd1 [cmd1_opts] [cmd2 [cmd2_opts] ...] or: myFile.py --help [cmd1 cmd2 ...] or: myFile.py --help-commands or: myFile.py cmd --help error: no commands supplied </code></pre> <p>Can someone please tell me what am I doing wrong?</p>
[ { "answer_id": 74170527, "author": "vivek nuna", "author_id": 6527049, "author_profile": "https://Stackoverflow.com/users/6527049", "pm_score": 1, "selected": false, "text": "_blockedMatter" }, { "answer_id": 74170537, "author": "Geeky Quentin", "author_id": 17235431, ...
2022/10/23
[ "https://Stackoverflow.com/questions/74170557", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19414671/" ]
74,170,568
<p>In my App I have a dashboard page with 2 Charts. Each chart uses a different configuration but the same API end-point. I would like to check if the payload for each end point is correct:</p> <pre class="lang-js prettyprint-override"><code>cy.intercept({ method: 'POST', url: `${Cypress.env('API_URL')}/api/v1/company/*/statistics/charts/data?cache_buster=*`, }).as('chartData'); </code></pre> <p>I have this route intercept which is matched twice.</p> <p>I can do this:</p> <pre class="lang-js prettyprint-override"><code>cy.wait('@chartData').then((data: any) =&gt; { expect(data.response.statusCode).to.eq(200); expect(data.request.body.document_types[0]).to.eq('receipt'); expect(data.request.body.document_types[1]).to.eq('invoice'); expect(data.request.body.filters[0].comparison_operator).to.eq('=='); expect(data.request.body.filters[0].field).to.eq('purchase_date'); expect(data.request.body.filters[0].type).to.eq('field_value'); expect(data.request.body.filters[0].value).to.eq('this_year'); }); </code></pre> <p>Which works but I cannot check the values of the second match.</p> <p>Any suggestions?</p>
[ { "answer_id": 74172565, "author": "jjhelguero", "author_id": 17917809, "author_profile": "https://Stackoverflow.com/users/17917809", "pm_score": 0, "selected": false, "text": "cy.get('@chartData.all')" }, { "answer_id": 74174725, "author": "Roberta D", "author_id": 20008...
2022/10/23
[ "https://Stackoverflow.com/questions/74170568", "https://Stackoverflow.com", "https://Stackoverflow.com/users/848706/" ]
74,170,580
<p>I have a data frame and I am trying to map one of column values to values present in a set.</p> <p>Data frame is</p> <pre><code>Name CallType Location ABC IN SFO DEF OUT LHR PQR INCOMING AMS XYZ OUTGOING BOM TYR A_IN DEL OMN A_OUT DXB </code></pre> <p>I have a Constant list where Call Type will be replaced by that in the list</p> <pre><code>call_type = set(&quot;IN&quot;,&quot;OUT&quot;) </code></pre> <p>Desired data frame</p> <pre><code>Name CallType Location ABC IN SFO DEF OUT LHR PQR IN AMS XYZ OUT BOM TYR IN DEL OMN OUT DXB </code></pre> <p>I wrote the code to check the response but the process.extractOne gives IN for OUTGOING sometimes (Which is wrong) and sometimes it gives OUT for OUTGOING (Which is right)</p> <p>Here's is my code</p> <pre><code>data=[('ABC','IN','SFO), ('DEF','OUT','LHR), ('PQR','INCOMING','AMS), ('XYZ','OUTGOING','BOM), ('TYR','A_IN','DEL), ('OMN','A_OUT','DXB)] df = pd.DataFrame(data, columns =['Name', 'CallType', 'Location']) call_types=set(['IN','OUT']) df['Call Type'] = df['Call Type'].apply(lambda x: process.extractOne(x, list(call_types))[0]) total_rows=len(df) for row_no in range(total_rows): row=df.iloc[row_no] print(row) // Here Sometimes OUTGOING sets as OUT and Sometimes IN . Shouldn't the result be consistent ? </code></pre> <p>I am not sure if there is a better way. Can someone please suggest if I am missing something.</p>
[ { "answer_id": 74172565, "author": "jjhelguero", "author_id": 17917809, "author_profile": "https://Stackoverflow.com/users/17917809", "pm_score": 0, "selected": false, "text": "cy.get('@chartData.all')" }, { "answer_id": 74174725, "author": "Roberta D", "author_id": 20008...
2022/10/23
[ "https://Stackoverflow.com/questions/74170580", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5029589/" ]
74,170,594
<p>I have some files in my components folder. Two of them are <code>CardItem-component/CardItemComponent.js</code> and <code>list-component/list-components.js</code>. When I'm trying to import the first component into the latter using</p> <pre><code>import CardItemComponent from &quot;./CardItem-component/CardItemComponent&quot;; </code></pre> <p>it gives the following mistake:</p> <pre><code>Module not found: Error: Can't resolve './CardItem-component/CardItemComponent' in 'D:\project\src\components\list-component' </code></pre>
[ { "answer_id": 74170642, "author": "Md Meheady hasan", "author_id": 16724652, "author_profile": "https://Stackoverflow.com/users/16724652", "pm_score": 2, "selected": true, "text": "import CardItemComponent from \"./CardItem-component/CardItemComponent\";\n" }, { "answer_id": 741...
2022/10/23
[ "https://Stackoverflow.com/questions/74170594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17695439/" ]
74,170,629
<p>Why my row getting second line, while shrinkering the width.</p> <p>Here is the screen shot.</p> <p>I am using bootstrap 5 for this, and dont know how to fix it, here is my code.</p> <p><a href="https://i.stack.imgur.com/RWLfz.png" rel="nofollow noreferrer">How it is right now ScreenShot</a></p> <p>Here is the screenshot how I want this to look like on mobiles.</p> <p><a href="https://i.stack.imgur.com/xsMyD.png" rel="nofollow noreferrer">How this has to look like Screenshot</a></p> <pre><code>&lt;div class=&quot;container-fluid fixed-bottom &quot; style=&quot;margin-bottom: 16px;&quot;&gt; &lt;div class=&quot;row align-items-center&quot;&gt; &lt;div class=&quot;col&quot; &gt; &lt;div class=&quot;text-center bottomElement&quot;&gt; &lt;img class=&quot;img-fluid bottomIcon&quot; src=&quot;/assets/business.png&quot; style=&quot;max-width:56px;&quot; /&gt; &lt;p class=&quot;bottomText&quot; style=&quot;color: white;&quot;&gt;Business&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;col&quot;&gt; &lt;div class=&quot;text-center bottomElement&quot;&gt; &lt;img class=&quot;img-fluid bottomIcon&quot; src=&quot;/assets/calculator.png&quot; style=&quot;max-width:56px;&quot; /&gt; &lt;p class=&quot;bottomText&quot; style=&quot;color: white;&quot;&gt;Calculator&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;col&quot;&gt; &lt;div class=&quot;text-center bottomElement&quot;&gt; &lt;img class=&quot;img-fluid bottomIcon&quot; src=&quot;/assets/oogPermits.png&quot; style=&quot;max-width:56px;&quot; /&gt; &lt;p class=&quot;bottomText&quot; style=&quot;color: white;&quot;&gt;OOG Permits&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;col&quot;&gt; &lt;div class=&quot;text-center bottomElement&quot;&gt; &lt;img class=&quot;img-fluid bottomIcon&quot; src=&quot;/assets/services.png&quot; style=&quot;max-width:56px;&quot; /&gt; &lt;p class=&quot;bottomText&quot; style=&quot;color: white;&quot;&gt;Services&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;col&quot;&gt; &lt;div class=&quot;text-center bottomElement&quot;&gt; &lt;img class=&quot;img-fluid bottomIcon&quot; src=&quot;/assets/career.png&quot; style=&quot;max-width:56px;&quot; /&gt; &lt;p class=&quot;bottomText&quot; style=&quot;color: white;&quot;&gt;Career&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre>
[ { "answer_id": 74170642, "author": "Md Meheady hasan", "author_id": 16724652, "author_profile": "https://Stackoverflow.com/users/16724652", "pm_score": 2, "selected": true, "text": "import CardItemComponent from \"./CardItem-component/CardItemComponent\";\n" }, { "answer_id": 741...
2022/10/23
[ "https://Stackoverflow.com/questions/74170629", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10706270/" ]
74,170,635
<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>&lt;div class="card" style="width: 150%;" style="display:table;"&gt; &lt;div class="card-header" style="display:table;"&gt; &lt;p class="display-4 bold" style="font-size: 30px;"&gt;Voici la transcription et traduction :&lt;/p&gt; &lt;/div&gt; &lt;ul class="list-group list-group-flush"&gt; &lt;li class="list-group-item" style="display: inline-block;"&gt; ADN &lt;div class="input-group-prepend"&gt; &lt;span class="input-group-text" id="basic-addon1" style="font-size: 15px;display: inline-block;"&gt;{{ generationdata[0] }}&lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;li class="list-group-item" style="display: inline-block;"&gt; ARN &lt;div class="input-group-prepend"&gt; &lt;span class="input-group-text" id="basic-addon1" style="font-size: 15px;display: inline-block;"&gt;{{ generationdata[1] }}&lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;li class="list-group-item" style="display: table;width: fit-content; "&gt; Protéine &lt;div class="input-group-prepend"&gt; &lt;span class="input-group-text" id="basic-addon1" style="font-size: 15px;display: inline-block;width: fit-content; "&gt;{{ generationdata[2] }}&lt;/span&gt; &lt;/div&gt; &lt;/li&gt; &lt;/ul&gt; &lt;/div&gt;</code></pre> </div> </div> </p> <p>This is what I get but I would want the content to be displayed on another line if too long for the div width:<br /> <a href="https://i.stack.imgur.com/lZuHX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lZuHX.png" alt="This is what I get but I would want the content to be displayed on another line if too long for the div width" /></a></p>
[ { "answer_id": 74170642, "author": "Md Meheady hasan", "author_id": 16724652, "author_profile": "https://Stackoverflow.com/users/16724652", "pm_score": 2, "selected": true, "text": "import CardItemComponent from \"./CardItem-component/CardItemComponent\";\n" }, { "answer_id": 741...
2022/10/23
[ "https://Stackoverflow.com/questions/74170635", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15344929/" ]
74,170,676
<pre><code>class Human { public: Human(string name); string getName() { return Human::name; } void setName(string name) { Human::name = name ; } private: string name; }; </code></pre> <p>Human::name in getName and setName funcs. work perfectly although name is not a static variable.</p> <p>Why is this happening ?</p> <p>As far as I know &quot;::&quot; is used to acces functions or static members of a class.</p> <p>I thought correct usage in getName would be return this -&gt; name or return name.</p> <p>And even, when generated auto setter function in Clion, setter function uses Human::name not this -&gt; name</p> <p>I'm coming from java background and in java classname.X (which resembles classname::X in c++) was only used for static members or functions of a class. That is why I am confused</p>
[ { "answer_id": 74170642, "author": "Md Meheady hasan", "author_id": 16724652, "author_profile": "https://Stackoverflow.com/users/16724652", "pm_score": 2, "selected": true, "text": "import CardItemComponent from \"./CardItem-component/CardItemComponent\";\n" }, { "answer_id": 741...
2022/10/23
[ "https://Stackoverflow.com/questions/74170676", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17680835/" ]
74,170,680
<p>I am have a pandas data frame that has about 2000 rows and 8000 columns. I am trying to check if there are any rows with all values are NaN and if that is the case then replace NaN with 0. I am aware that we can use the below code to check but I am not sure on how to further build it to replace the NaN (s).</p> <p>Note - I do not want to replace NaN on a column level.</p> <p>Could someone please help?</p> <pre><code>df_june.isna().all(axis=1) # to check if all values of a row are NaN. </code></pre>
[ { "answer_id": 74170642, "author": "Md Meheady hasan", "author_id": 16724652, "author_profile": "https://Stackoverflow.com/users/16724652", "pm_score": 2, "selected": true, "text": "import CardItemComponent from \"./CardItem-component/CardItemComponent\";\n" }, { "answer_id": 741...
2022/10/23
[ "https://Stackoverflow.com/questions/74170680", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20059373/" ]
74,170,687
<p>I started an online training for Python. The assignment wants to me calculate 45 hours work for 10.50 hourly payment. But, 5 hours in this is overwork. So, the payment goes to 10.50 X 5 So, the payment should be 498.75.</p> <p>But, my program finds different sum. What is wrong with this code? (Note that I am novice)</p> <pre><code>hours = float(input(&quot;Enter hours: &quot;)) rate = float(input(&quot;Enter rate: &quot;)) extraPay = float((hours-40) * (rate*1.5)) def computepay(a, b, c): paymentCalc= a * b + c return paymentCalc x = computepay(hours, rate, extraPay) print(x) </code></pre>
[ { "answer_id": 74170744, "author": "Muhammad Akhlaq Mahar", "author_id": 17416783, "author_profile": "https://Stackoverflow.com/users/17416783", "pm_score": 1, "selected": false, "text": "hours = float(45)\nrate = float(10.5)\nextra_hours = float(hours - 40)\nextraPay = float(extra_hours...
2022/10/23
[ "https://Stackoverflow.com/questions/74170687", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16559849/" ]
74,170,748
<p>In list whitch I'am downloading there is a parameter:</p> <p><code>taf[index]['change']['indicator']['text'] </code></p> <p>in:</p> <pre><code>ListView.builder( itemCount: taf.length, itemBuilder: (context, index) { return Card( child: Column( children: [ Text('Indicator: ' + taf[index]['change']['indicator']['text']), // !!This element sometimes is present sometimes not!! Text('Valid from: ' + taf[index]['timestamp']['from']), Text('Valid to: ' + taf[index]['timestamp']['to']) ], ), ); }, ), </code></pre> <p>whitch sometimes in present in downloaded data sometimes no. My question is how to handle this to do not crash the app diring the ListView.builder function when varaying paramater is not present?</p> <p><strong>EDIT: If you know alternative for building a list view but with irregular elements let me know :)</strong></p> <p><a href="https://i.stack.imgur.com/G7gw0.png" rel="nofollow noreferrer">Error screen</a></p> <p><a href="https://i.stack.imgur.com/1MZIW.png" rel="nofollow noreferrer">ListView.builder with problematic parameter</a></p>
[ { "answer_id": 74170866, "author": "Shimaa Yasser", "author_id": 10868923, "author_profile": "https://Stackoverflow.com/users/10868923", "pm_score": 2, "selected": true, "text": " ListView.builder(\n itemCount: taf.length,\n itemBuilder: (context, index) {\n\n\n ...
2022/10/23
[ "https://Stackoverflow.com/questions/74170748", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20314032/" ]
74,170,758
<p>I am new to the azure maps and try to generate a weighted heat map to show population in particular areas. I am using the following code, if I use my GeoJSON as data source, no heat map layer is rendered. If I use the earthquake URL, I can see the heat map layer.</p> <pre><code> map.events.add('ready', function () { map.events.add('load', function (e) { datasource = new atlas.source.DataSource(); map.sources.add(datasource); //datasource.importDataFromUrl('https://earthquake.usgs.gov/earthquakes/feed/v1.0/summary/all_week.geojson'); alert(geoJson); datasource.add(geoJson); map.layers.add(new atlas.layer.HeatMapLayer(datasource, null, { radius: 50, color: [ 'interpolate', ['linear'], ['heatmap-density'], 0, 'rgba(33,102,172,0)', 0.2, 'rgb(103,169,207)', 0.4, 'rgb(209,229,240)', 0.6, 'rgb(253,219,199)', 0.8, 'rgb(239,138,98)', 1, 'rgb(178,24,43)' ] }), 'labels'); }); }); </code></pre> <p>My GeoJSON is as below:</p> <pre><code>{ &quot;type&quot;:&quot;FeatureCollection&quot;, &quot;features&quot;:[ { &quot;type&quot;:&quot;Feature&quot;, &quot;properties&quot;:{ &quot;density&quot;:&quot;50&quot; }, &quot;geometry&quot;:{ &quot;type&quot;:&quot;Point&quot;, &quot;coordinates&quot;:[ 51.5570726284386, 25.3115021617515 ] } }, { &quot;type&quot;:&quot;Feature&quot;, &quot;properties&quot;:{ &quot;density&quot;:&quot;50&quot; }, &quot;geometry&quot;:{ &quot;type&quot;:&quot;Point&quot;, &quot;coordinates&quot;:[ 51.5570726284386, 25.3115021617515 ] } }, { &quot;type&quot;:&quot;Feature&quot;, &quot;properties&quot;:{ &quot;density&quot;:&quot;10&quot; }, &quot;geometry&quot;:{ &quot;type&quot;:&quot;Point&quot;, &quot;coordinates&quot;:[ 51.5570726284386, 25.391562807081 ] } }, { &quot;type&quot;:&quot;Feature&quot;, &quot;properties&quot;:{ &quot;density&quot;:&quot;10&quot; }, &quot;geometry&quot;:{ &quot;type&quot;:&quot;Point&quot;, &quot;coordinates&quot;:[ 51.5570726284386, 25.391562807081 ] } }, { &quot;type&quot;:&quot;Feature&quot;, &quot;properties&quot;:{ &quot;density&quot;:&quot;10&quot; }, &quot;geometry&quot;:{ &quot;type&quot;:&quot;Point&quot;, &quot;coordinates&quot;:[ 35.4343604091702, 33.9136459680463 ] } }, { &quot;type&quot;:&quot;Feature&quot;, &quot;properties&quot;:{ &quot;density&quot;:&quot;10&quot; }, &quot;geometry&quot;:{ &quot;type&quot;:&quot;Point&quot;, &quot;coordinates&quot;:[ 35.5220012295491, 33.8847298539905 ] } }, { &quot;type&quot;:&quot;Feature&quot;, &quot;properties&quot;:{ &quot;density&quot;:&quot;40&quot; }, &quot;geometry&quot;:{ &quot;type&quot;:&quot;Point&quot;, &quot;coordinates&quot;:[ 51.4729695383047, 25.2856697056661 ] } }, { &quot;type&quot;:&quot;Feature&quot;, &quot;properties&quot;:{ &quot;density&quot;:&quot;20&quot; }, &quot;geometry&quot;:{ &quot;type&quot;:&quot;Point&quot;, &quot;coordinates&quot;:[ 35.4343604091702, 33.7574366679259 ] } }, { &quot;type&quot;:&quot;Feature&quot;, &quot;properties&quot;:{ &quot;density&quot;:&quot;50&quot; }, &quot;geometry&quot;:{ &quot;type&quot;:&quot;Point&quot;, &quot;coordinates&quot;:[ 35.4343604091702, 33.7574366679259 ] } }, { &quot;type&quot;:&quot;Feature&quot;, &quot;properties&quot;:{ &quot;density&quot;:&quot;10&quot; }, &quot;geometry&quot;:{ &quot;type&quot;:&quot;Point&quot;, &quot;coordinates&quot;:[ 51.4729695383047, 25.2856697056661 ] } }, { &quot;type&quot;:&quot;Feature&quot;, &quot;properties&quot;:{ &quot;density&quot;:&quot;10&quot; }, &quot;geometry&quot;:{ &quot;type&quot;:&quot;Point&quot;, &quot;coordinates&quot;:[ 35.5220012295491, 33.8847298539905 ] } } ] } </code></pre> <p>Can anyone please check and advise if there's anything wrong in the code or the geoJson?</p> <p>Thanks.</p>
[ { "answer_id": 74170866, "author": "Shimaa Yasser", "author_id": 10868923, "author_profile": "https://Stackoverflow.com/users/10868923", "pm_score": 2, "selected": true, "text": " ListView.builder(\n itemCount: taf.length,\n itemBuilder: (context, index) {\n\n\n ...
2022/10/23
[ "https://Stackoverflow.com/questions/74170758", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13586481/" ]
74,170,769
<p>I am trying to disable a button that requires both an input of text being typed and one of three checkboxes being checked. The text is a user name and the checkbox is a difficulty of either easy, medium, or hard. Currently, my function only works if one of the requirements is met. So if the text has been inputted the button is enabled and the same with the checkboxes.</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>startButton.addEventListener('click', startQuiz); function disableButton() { if (document.getElementById("username").value === "") { document.getElementById("start-btn").disabled = true; } if (document.getElementsByName("difficulty").checked) { document.getElementById("start-btn").disabled = true; } else { document.getElementById("start-btn").disabled = false; } }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code> &lt;div&gt; &lt;label for="username"&gt;Enter your Username&lt;/label&gt; &lt;input type="text" name="username" id="username" onkeyup="disableButton()" placeholder="Enter Username"&gt; &lt;/div&gt; &lt;div id="difficulty" class="center"&gt; &lt;div&gt; &lt;input type="radio" name="difficulty" id="easy-diff" onclick="disableButton()"&gt; &lt;label for="easy-diff"&gt;Easy&lt;/label&gt; &lt;/div&gt; &lt;div&gt; &lt;input type="radio" name="difficulty" id="medium-diff" onclick="disableButton()"&gt; &lt;label for="medium-diff"&gt;Medium&lt;/label&gt; &lt;/div&gt; &lt;div&gt; &lt;input type="radio" name="difficulty" id="hard-diff" onclick="disableButton()"&gt; &lt;label for="hard-diff"&gt;Hard&lt;/label&gt; &lt;/div&gt; &lt;/div&gt; &lt;button id="start-btn" type="submit" class="btn" disabled&gt;Start&lt;/button&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74170866, "author": "Shimaa Yasser", "author_id": 10868923, "author_profile": "https://Stackoverflow.com/users/10868923", "pm_score": 2, "selected": true, "text": " ListView.builder(\n itemCount: taf.length,\n itemBuilder: (context, index) {\n\n\n ...
2022/10/23
[ "https://Stackoverflow.com/questions/74170769", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20248446/" ]
74,170,810
<p>My Pandas data frame contains the following data reading from a csv file:</p> <pre><code>id,values 1001-MAC, 10 1034-WIN, 20 2001-WIN, 15 3001-MAC, 45 4001-LINUX, 12 4001-MAC, 67 df = pd.read_csv('example.csv') df.set_index('id', inplace=True) </code></pre> <p>I have to sort this data frame based on the id column order by given suffix list = [&quot;WIN&quot;, &quot;MAC&quot;, &quot;LINUX&quot;]. Thus, I would like to get the following output:</p> <pre><code> id,values 1034-WIN, 20 2001-WIN, 15 1001-MAC, 10 3001-MAC, 45 4001-MAC, 67 4001-LINUX, 12 </code></pre> <p>How can I do that?</p>
[ { "answer_id": 74170843, "author": "Lowin Li", "author_id": 19560513, "author_profile": "https://Stackoverflow.com/users/19560513", "pm_score": 1, "selected": false, "text": "import pandas as pd\ndf = pd.DataFrame({\n \"id\":[\"1001-MAC\", \"1034-WIN\", \"2001-WIN\", \"3001-MAC\", \"4...
2022/10/23
[ "https://Stackoverflow.com/questions/74170810", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6815682/" ]
74,170,825
<p>I'm trying to change the color of some buttons onClick and getting this error, what can I do?</p> <p><a href="https://i.stack.imgur.com/MUTIL.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/MUTIL.jpg" alt="enter image description here" /></a></p> <p>after adding const I now get then error TypeError: undefined is not an object (evaluating 'e.target.name') <a href="https://i.stack.imgur.com/oIJjb.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/oIJjb.jpg" alt="enter image description here" /></a></p>
[ { "answer_id": 74170874, "author": "Ryan", "author_id": 3722302, "author_profile": "https://Stackoverflow.com/users/3722302", "pm_score": 0, "selected": false, "text": "const" }, { "answer_id": 74175884, "author": "Peter Tam", "author_id": 20002061, "author_profile": ...
2022/10/23
[ "https://Stackoverflow.com/questions/74170825", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16373524/" ]
74,170,834
<p>TL;DR - Microsoft Store Apps are broken (0 bytes), hence the Python interpreter is unable to create process and run &quot;Python&quot; inside virtualenv, I failed to follow numerous explanations of how to change virtualenv path for Python.</p> <p>Recently, without any changes to my computer/environment, an issue started occurring when executing (also tried python3, which brings the same):</p> <pre><code>python manage.py runserver </code></pre> <p>This brought back the following issue:</p> <blockquote> <p>Unable to create process using '&quot;C:\Users\MyUser\AppData\Local\Microsoft\WindowsApps\PythonSoftwareFoundation.Python.3.10_qbz5n2kfra8p0\python.exe&quot;'</p> </blockquote> <p>As I dug deeper, I realized that all of the apps installed under this folder are 0 bytes, hence they are completed broken, all of a sudden. Therefore I figured it's not an issue with Django, rather the python itself.</p> <p>I tried changing the virtualenv path for Python.exe, instead of using WindowsApps version, I installed the original Python from the original website.</p> <p>I failed to do so, multiple times.</p> <p>I tried: &quot;https://stackoverflow.com/questions/4757178/how-do-you-set-your-pythonpath-in-an-already-created-virtualenv/47184788#47184788&quot; - Adding the path inside &quot;activate&quot; and &quot;activate.bat&quot;, as</p> <pre><code>set PYTHONPATH=&quot;C:\Users\MyUser\AppData\Local\Programs\Python\Python310\python.exe&quot; </code></pre> <p>And the issue persists.</p> <p>I tried every solution/article I found in regards to the issue I have. Many of them claim a simple result, whereas the rest claim a complete refactor is required. Even downloading from Microsoft store is broken, it always fails.</p> <p>Since I'm unable to remove the broken apps, and I wasn't able to find a way to change the virtualenv Python interpreter, I am here, asking for your assistance.</p> <p>Thanks in advance,</p>
[ { "answer_id": 74170874, "author": "Ryan", "author_id": 3722302, "author_profile": "https://Stackoverflow.com/users/3722302", "pm_score": 0, "selected": false, "text": "const" }, { "answer_id": 74175884, "author": "Peter Tam", "author_id": 20002061, "author_profile": ...
2022/10/23
[ "https://Stackoverflow.com/questions/74170834", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12738225/" ]
74,170,850
<p>First I define a relu function and vectorize it.</p> <p>Then I feed an arbitrary list into this relu function, but it returns the wrong result, because the value of relu(1.5) should be 1.5.</p> <p>The code is as follows:</p> <pre><code>import numpy as np def relu(x): return x if x &gt; 0 else 0 relu = np.vectorize(relu) print(relu([-3,-1.5,0,1.5,3])) # result: array([0, 0, 0, 1, 3]) </code></pre> <p>Could you please explain to me why this happens?</p>
[ { "answer_id": 74170912, "author": "user19077881", "author_id": 19077881, "author_profile": "https://Stackoverflow.com/users/19077881", "pm_score": 3, "selected": true, "text": "relu = np.vectorize(relu,otypes=[float])\n" }, { "answer_id": 74170994, "author": "Tom McLean", ...
2022/10/23
[ "https://Stackoverflow.com/questions/74170850", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20314102/" ]
74,170,861
<p><a href="https://pastebin.com/19WXRrDR" rel="nofollow noreferrer">Pastebin | Full xml file</a></p> <p><a href="https://i.stack.imgur.com/8fIm4.png" rel="nofollow noreferrer">xml element</a></p> <pre><code> &lt;EditText android:id=&quot;@+id/etBaseAmount&quot; android:layout_width=&quot;wrap_content&quot; android:layout_height=&quot;wrap_content&quot; android:layout_marginStart=&quot;32dp&quot; android:ems=&quot;8&quot; android:hint=&quot;Bill amount&quot; android:inputType=&quot;numberDecimal&quot; android:textSize=&quot;24sp&quot; app:layout_constraintBottom_toBottomOf=&quot;@+id/tvBaseLabel&quot; app:layout_constraintStart_toEndOf=&quot;@+id/tvBaseLabel&quot; app:layout_constraintTop_toTopOf=&quot;@+id/tvBaseLabel&quot; /&gt; </code></pre> <p><a href="https://i.stack.imgur.com/6aQfN.png" rel="nofollow noreferrer">Log</a></p> <p>Can someone say me what I did wrong?</p> <p>I work with Android 11</p>
[ { "answer_id": 74171049, "author": "abhishekrajak", "author_id": 8879652, "author_profile": "https://Stackoverflow.com/users/8879652", "pm_score": 1, "selected": false, "text": "(android:id=\"@+id/etBaseAmount\")" } ]
2022/10/23
[ "https://Stackoverflow.com/questions/74170861", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15905312/" ]
74,170,876
<pre><code>&lt;div class=&quot;logodiv&quot;&gt; &lt;a href=&quot;/&quot;&gt;&lt;img src=&quot;images/logoweb.png&quot; alt=&quot;&quot;&gt;&lt;/a&gt; &lt;/div&gt; </code></pre> <p>Hello, I need to change the image source from images/logoweb.png into a different files like logowebnew.gif. I have no access to HTMl for an edit or make an id for the img, how do I change the source using javascript?</p>
[ { "answer_id": 74171049, "author": "abhishekrajak", "author_id": 8879652, "author_profile": "https://Stackoverflow.com/users/8879652", "pm_score": 1, "selected": false, "text": "(android:id=\"@+id/etBaseAmount\")" } ]
2022/10/23
[ "https://Stackoverflow.com/questions/74170876", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20314181/" ]
74,170,883
<p>The problem is simple. I copied an example from a Python book about output redirection and firstly <code>sys.stdout</code> is changed to a file object and then is restored to <code>sys.__stdout__</code>. However the restoration part doesn't seem to work because the output later in the code doesn't get displayed at all anywhere.</p> <p>I found out the issue which I'll explain with this shell code sample:</p> <pre><code>&gt;&gt;&gt; import sys &gt;&gt;&gt; sys.stdout &lt;idlelib.run.StdOutputFile object at 0x00000191D0BCFB50&gt; &gt;&gt;&gt; sys.__stdout__ &gt;&gt;&gt; print(sys.__stdout__) None &gt;&gt;&gt; </code></pre> <p>So: why is <code>sys.__stdout__</code> equal to <code>None</code> by default?</p> <p>EDIT: I know about the context manager in contextlib explained in <a href="https://stackoverflow.com/questions/51340347/python-revert-sys-stdout-to-default">this</a> issue but I still would like to know why this happens.</p>
[ { "answer_id": 74172091, "author": "sj95126", "author_id": 13843268, "author_profile": "https://Stackoverflow.com/users/13843268", "pm_score": 2, "selected": false, "text": "sys.stdout" }, { "answer_id": 74172192, "author": "Bharel", "author_id": 1658617, "author_prof...
2022/10/23
[ "https://Stackoverflow.com/questions/74170883", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19429842/" ]