qid
int64
4
22.2M
question
stringlengths
18
48.3k
answers
list
date
stringlengths
10
10
metadata
list
74,455,642
<p>I am trying to pass a parameter through Ajax using GET method in Laravel. For testing purpose, I am trying to get the same parameter value in the response. But the response I am getting is <code>{code}</code>.</p> <pre><code>$.ajax({ type: &quot;GET&quot;, url: &quot;{{ url('helpers/get-item-details/{code}') }}&quot;, data: { code: 100390, }, success:function(response) { console.log(response); $('input[name=&quot;hs_code&quot;]').val(response.hs_code); }, error: function(jqXHR, textStatus, errorThrown) { console.log(&quot;Invalid response&quot;); console.log(jqXHR.responseText); alert(jqXHR.responseText); } }); </code></pre> <p><strong>Controller:</strong></p> <pre><code>class Helper { public static function getItemDetails($itemId){ return $itemId; } } </code></pre> <p>Not sure where it is going wrong. I tried to call the URL on the browser like following which returns the parameter value as expected. <pre>helpers/get-item-details/100390</pre></p> <p>Thanks in advance for any help.</p> <p><strong>Route:</strong></p> <pre><code>Route::get('/helpers/get-item-details/{id}', 'App\Helpers\Helper@getItemDetails'); </code></pre>
[ { "answer_id": 74474924, "author": "stefan", "author_id": 3925235, "author_profile": "https://Stackoverflow.com/users/3925235", "pm_score": 3, "selected": false, "text": "heuristics/nlpdiving/freq = 0\nheuristics/nlpdiving/freqofs = 0\nheuristics/nlpdiving/maxnlpiterabs = 10000\nheuristics/nlpdiving/nlpfastfail = FALSE\nheuristics/nlpdiving/varselrule = f\n" }, { "answer_id": 74492097, "author": "Erwin Kalvelagen", "author_id": 5625534, "author_profile": "https://Stackoverflow.com/users/5625534", "pm_score": 0, "selected": false, "text": "Classifier predicts products in MIQP should be linearized.\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455642", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2444568/" ]
74,455,652
<p>I wanna convert CSV to JSON correct data type</p> <p>csv file 2nd row is data type. data has over 300 properties example data:</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Name</th> <th>DMG</th> <th>HP</th> <th>Human</th> </tr> </thead> <tbody> <tr> <td>string</td> <td>number</td> <td>number</td> <td>boolean</td> </tr> <tr> <td>knight</td> <td>100</td> <td>500</td> <td>true</td> </tr> <tr> <td>archer</td> <td>50</td> <td>200</td> <td>true</td> </tr> <tr> <td>dog</td> <td>-</td> <td>-</td> <td>-</td> </tr> </tbody> </table> </div> <p>if string empty return null</p> <p>if number empty return 0</p> <p>if boolean empty return false</p> <p>my node.js code:</p> <pre><code>const fs = require('fs') const papa = require(&quot;papaparse&quot;) const results = []; const options = { header: true, dynamicTyping: true }; fs.createReadStream(&quot;characters.csv&quot;) .pipe(papa.parse(papa.NODE_STREAM_INPUT, options)) .on(&quot;data&quot;, (data) =&gt; { results.push(data); }).on(&quot;end&quot;, () =&gt; { console.log(results) }) </code></pre> <p>output I expecting:</p> <pre><code>[ { &quot;Name&quot;: &quot;knight&quot;, &quot;DMG&quot;: 100, &quot;HP&quot;: 500, &quot;Human&quot;: true, }, { &quot;Name&quot;: &quot;archer&quot;, &quot;DMG&quot;: 50, &quot;HP&quot;: 200, &quot;Human&quot;: true, }, { &quot;Name&quot;: &quot;dog&quot;, &quot;DMG&quot;: 0, &quot;HP&quot;: 0, &quot;Human&quot;: false, }, ] </code></pre>
[ { "answer_id": 74455815, "author": "JoeCrash", "author_id": 4539309, "author_profile": "https://Stackoverflow.com/users/4539309", "pm_score": 0, "selected": false, "text": "let i = 0; //define this outside, its only to skip that first row with headers.\nif(i > 0){ //skipping first row\n data.DMG = parseInt(data.DMG) || 0; //an int or 0\n data.HP = parseInt(data.HP) || 0; //an int or 0\n data.Human = data.Human === !0; //!0 = not false, will match true string or bool\n results.push(data);\n}\ni++;//iterate\n" }, { "answer_id": 74456055, "author": "JoeCrash", "author_id": 4539309, "author_profile": "https://Stackoverflow.com/users/4539309", "pm_score": 2, "selected": true, "text": "let i = 0, headerTypes = {};" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455652", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18403575/" ]
74,455,690
<p>so im taking number input and the im trying to add each digit to an array of int without using any loop</p> <p>here i got an answer</p> <pre><code>int[] fNum = Array.ConvertAll(num.ToString().ToArray(),x=&gt;(int)x - 48); </code></pre> <p>I understand until .toarray(), but I do not understand why it takes a new variable x and the =&gt; (int)x - 48.</p> <p>Could anyone explain this to me?</p>
[ { "answer_id": 74455726, "author": "Natrium", "author_id": 59119, "author_profile": "https://Stackoverflow.com/users/59119", "pm_score": 1, "selected": false, "text": "ConvertAll" }, { "answer_id": 74455894, "author": "eloiz", "author_id": 16756296, "author_profile": "https://Stackoverflow.com/users/16756296", "pm_score": 0, "selected": false, "text": "num.ToString().ToArray(),x=>(int)x - 48\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455690", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12438238/" ]
74,455,707
<p>I'm learning ASP.NET CORE 6 with MS official website below: <a href="https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/search?view=aspnetcore-6.0" rel="nofollow noreferrer">https://learn.microsoft.com/en-us/aspnet/core/tutorials/first-mvc-app/search?view=aspnetcore-6.0</a></p> <p>Then I found a instruction said &quot;There's no [HttpPost] overload of the Index method as you might expect. You don't need it, because the method isn't changing the state of the app, just filtering data.&quot; and I'm confused with it.</p> <p>the following code is the sample from teaching page, a form tag without method atrribute, so I think it should be &quot;post&quot; as the default.</p> <pre><code>&lt;form asp-action=&quot;index&quot;&gt; Search: &lt;input type=&quot;text&quot; name=&quot;searchText&quot; /&gt; &lt;input type=&quot;submit&quot; value=&quot;GO&quot; class=&quot;btn btn-secondary&quot; /&gt; &lt;/form&gt; </code></pre> <p>And the following action method without [HTTPXXX] attribute should be [HTTPGET] as the default, right?</p> <pre><code>// GET: Movies public async Task&lt;IActionResult&gt; Index(string searchText) { if (!string.IsNullOrEmpty(searchText)) { var result = _context.Movie.Where(m=&gt;m.Title!.Contains(searchText)); return View(await result.ToListAsync()); } return View(await _context.Movie.ToListAsync()); } </code></pre> <p>So the question is why I ask a request with POST method, but it still can lead to a GET action method?</p>
[ { "answer_id": 74455726, "author": "Natrium", "author_id": 59119, "author_profile": "https://Stackoverflow.com/users/59119", "pm_score": 1, "selected": false, "text": "ConvertAll" }, { "answer_id": 74455894, "author": "eloiz", "author_id": 16756296, "author_profile": "https://Stackoverflow.com/users/16756296", "pm_score": 0, "selected": false, "text": "num.ToString().ToArray(),x=>(int)x - 48\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455707", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16726142/" ]
74,455,757
<p>I have a database that is coded with numbers instead of names. for example Less than high school = 0 High school/GED = 1 Some college/trade school = 2 Bachelor'sdegree = 3 Graduate school/advanced degree = 4</p> <p>I'm using the ifelse function its working but im looking for faster way because its a big data and its time consuming</p> <pre><code>Mass_Shooter_fullDatabase$Education &lt;- ifelse(Mass_Shooter_fullDatabase$Education==0,&quot;Less than high school&quot;, ifelse(Mass_Shooter_fullDatabase$Education==1,&quot;High school/GED&quot;, ifelse(Mass_Shooter_fullDatabase$Education==2,&quot;Some college/trade school&quot;, ifelse(Mass_Shooter_fullDatabase$Education==3,&quot;Bachelor's degree&quot;, ifelse(Mass_Shooter_fullDatabase$Education==4,&quot;Graduate school/advanced degree&quot;,NA))))) </code></pre>
[ { "answer_id": 74456988, "author": "Luiy_coder", "author_id": 9596339, "author_profile": "https://Stackoverflow.com/users/9596339", "pm_score": 2, "selected": false, "text": "library(dplyr)\nEducation = c(1, 1, 0, 2, 3, 4, 5)\nMass_Shooter_fullDatabase = data.frame(Education, stringsAsFactors = FALSE)\n\nMass_Shooter_fullDatabase %>% \n mutate(\n Educations = case_when(\n Mass_Shooter_fullDatabase$Education == 0 ~ \"Less than high school\",\n Mass_Shooter_fullDatabase$Education == 1 ~ \"High school/GED\",\n Mass_Shooter_fullDatabase$Education == 2 ~\"Some college/trade school\",\n Mass_Shooter_fullDatabase$Education == 3 ~\"Bachelor's degree\",\n Mass_Shooter_fullDatabase$Education == 4 ~\"Graduate school/advanced degree\"))\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455757", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19713955/" ]
74,455,762
<p>I want to find all elements before first <code>&lt;p&gt;&lt;strong&gt;</code> encountered and exit the loop once it found.</p> <pre><code>example = &quot;&quot;&quot;This should be in before section&lt;p&gt;Content before&lt;/p&gt;&lt;p&gt;&lt;strong&gt;First Title&lt;/strong&gt;&lt;/p&gt;Content of first title1&lt;p&gt;Content of first title2&lt;/p&gt;&lt;p&gt;&lt;strong&gt;Second title&lt;/strong&gt;&lt;/p&gt;&lt;p&gt;Content of second title&lt;/p&gt;&lt;/strong&gt;&quot;&quot;&quot; soup = BeautifulSoup(example, 'html.parser') for data in soup: print(data.previous_sibling) print(data.nextSibling.name) if nextSibling.name == '&lt;p&gt;&lt;strong&gt;': print('found and add before content in variable') </code></pre> <p>Output variable should have:</p> <pre><code>This should be in before section&lt;p&gt;Content before&lt;/p&gt; </code></pre> <p><strong>Edit: Tried below code as well</strong></p> <pre><code>res = [] for sibling in soup.find('p').previous_siblings: res.append(sibling.text) res.reverse() res = ' '.join(res) print(res) </code></pre> <p>It should check <code>&lt;p&gt;&lt;strong&gt;</code> not only <code>&lt;p&gt;</code> and I am not sure how can I do that.</p>
[ { "answer_id": 74456225, "author": "HedgeHog", "author_id": 14460824, "author_profile": "https://Stackoverflow.com/users/14460824", "pm_score": 0, "selected": false, "text": "find_previous" }, { "answer_id": 74456440, "author": "Rakesh Shetty", "author_id": 1455354, "author_profile": "https://Stackoverflow.com/users/1455354", "pm_score": 1, "selected": false, "text": "example = \"\"\"<span>output1</span>This should be in overview section<span>output1</span><p>output 2</p><p><strong>First Title</strong></p>Content of first title1<p>Content of first title2</p><p><strong>Second title</strong></p><p>Content of second title</p></strong>\"\"\"\nsoup = BeautifulSoup(example, 'html.parser')\n\nres = []\nfor sibling in soup.select_one('p:has(strong)').previous_siblings:\n res.append(sibling.text)\n \nres.reverse()\nres = ' '.join(res)\n\nprint(res)\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455762", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1455354/" ]
74,455,767
<p>I keep getting this error when I'm trying to read in a file and add the data to my objects. Can someone please help me? Here is the error:</p> <pre><code>Exception in thread &quot;main&quot; java.lang.NumberFormatException: For input string: &quot;N64&quot; at java.base/java.lang.NumberFormatException.forInputString(NumberFormatException.java:67) at java.base/java.lang.Integer.parseInt(Integer.java:668) at java.base/java.lang.Integer.parseInt(Integer.java:786) at FinalProjectTests.main(FinalProjectTests.java:34) </code></pre> <p>Here are my objects. Also at the bottom I have setters and getters below the code as well as a <code>toString()</code> method generated by Eclipse:</p> <p><a href="https://i.stack.imgur.com/BNNRp.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/BNNRp.jpg" alt="enter image description here" /></a></p> <p>Here is my code that is trying to read in a file and add the data to my objects:</p> <pre class="lang-java prettyprint-override"><code>public class FinalProjectTests { //create an arraylist so the objects can be used through them public static ArrayList&lt;FinalProjectRecord&gt; record = new ArrayList&lt;FinalProjectRecord&gt;(); public static void main(String[] args) { Scanner input = null; try { input = new Scanner(new File(&quot;Video Games Sales.csv&quot;)); } catch (FileNotFoundException e) { System.out.println(&quot;file not found&quot;); e.printStackTrace(); }//end try //skips the title columns in our data file input.nextLine(); while(input.hasNext()) { String [] columns = input.nextLine().split(&quot;,&quot;); record.add(new FinalProjectRecord(Integer.parseInt(columns[0]), columns[1], columns[2], Integer.parseInt(columns[3]), columns[4], columns[5], Double.parseDouble(columns[6]), Double.parseDouble(columns[7]), Double.parseDouble(columns[8]), Double.parseDouble(columns[9]), Double.parseDouble(columns[10]), Double.parseDouble(columns[11]))); }//end while for(FinalProjectRecord r: record) System.out.println(r); }//end main }//end class </code></pre> <p>Here is a snippet of the data I am trying to read in:</p> <p><a href="https://i.stack.imgur.com/Bgyag.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/Bgyag.png" alt="enter image description here" /></a></p> <p>Edit: I got the data from <em>data.world</em>.</p>
[ { "answer_id": 74456225, "author": "HedgeHog", "author_id": 14460824, "author_profile": "https://Stackoverflow.com/users/14460824", "pm_score": 0, "selected": false, "text": "find_previous" }, { "answer_id": 74456440, "author": "Rakesh Shetty", "author_id": 1455354, "author_profile": "https://Stackoverflow.com/users/1455354", "pm_score": 1, "selected": false, "text": "example = \"\"\"<span>output1</span>This should be in overview section<span>output1</span><p>output 2</p><p><strong>First Title</strong></p>Content of first title1<p>Content of first title2</p><p><strong>Second title</strong></p><p>Content of second title</p></strong>\"\"\"\nsoup = BeautifulSoup(example, 'html.parser')\n\nres = []\nfor sibling in soup.select_one('p:has(strong)').previous_siblings:\n res.append(sibling.text)\n \nres.reverse()\nres = ' '.join(res)\n\nprint(res)\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455767", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20516551/" ]
74,455,777
<p>I am getting <code>This loop will have at most one iteration</code> for following chunk of code. But when I Add else condition, I get an error.</p> <pre><code>def self.list_all_rentals_person_id(people, rentals) list_all_people(people) print 'ID of person: ' person_id = gets.chomp rentals.each do |rental| return puts &quot;Rentals:\nDate: #{rental.date} Book: #{rental.book.title}&quot; if rental.person.id == person_id else return puts 'No Rental Records Found' end end </code></pre> <p>But When I only use if and return, the if condition return. I won't get any error</p> <pre class="lang-rb prettyprint-override"><code> def self.list_all_rentals_person_id(people, rentals) list_all_people(people) print 'ID of person: ' person_id = gets.chomp rentals.each do |rental| return puts &quot;Rentals:\nDate: #{rental.date} Book: #{rental.book.title}&quot; if rental.person.id == person_id end end </code></pre>
[ { "answer_id": 74455996, "author": "Dennis van de Hoef - Xiotin", "author_id": 5600652, "author_profile": "https://Stackoverflow.com/users/5600652", "pm_score": 2, "selected": true, "text": "def self.list_all_rentals_person_id(people, rentals)\n list_all_people(people)\n print 'ID of person: '\n person_id = gets.chomp\n\n rentals.each do |rental|\n return puts \"Rentals:\\nDate: #{rental.date} Book: #{rental.book.title}\" if rental.person.id == person_id\n end\n\n puts 'No Rental Records Found'\nend\n" }, { "answer_id": 74456252, "author": "Chris", "author_id": 15261315, "author_profile": "https://Stackoverflow.com/users/15261315", "pm_score": 2, "selected": false, "text": "Enumerable#find" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455777", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12959923/" ]
74,455,794
<p>I'm always getting indexValue -1 of <code>ProductType[]</code> Array, when I select array of product value.</p> <p>Is there something wrong with my code?</p> <p>Any help is appreciated. Thanks!</p> <p>ViewModel:</p> <pre><code>public ProductType[] ProductTypesSel { get; set; } private int _ProductTypeIndex = -1; public int ProductTypeIndex { get { return _ProductTypeIndex; } set { _ProductTypeIndex = value; if (value &gt;= 0) { Item.ProductType = ProductTypesSel[value].Code; } OnPropertyChanged(nameof(ProductTypeDisp)); Console.WriteLine(ProductTypeDisp); } } public string ProductTypeDisp =&gt; Config != null &amp;&amp; ProductTypeIndex &gt;= 0 &amp;&amp; ProductTypeIndex &lt; ProductTypesSel.Length ? ProductTypesSel[ProductTypeIndex].Name : null; </code></pre> <p>Codebehind:</p> <pre><code>int indexValue = Array.IndexOf(_Model.ProductTypesSel, productValue); _Model.ProductTypeIndex = indexValue; </code></pre>
[ { "answer_id": 74455806, "author": "vivek nuna", "author_id": 6527049, "author_profile": "https://Stackoverflow.com/users/6527049", "pm_score": 2, "selected": false, "text": "value3" }, { "answer_id": 74456737, "author": "Liyun Zhang - MSFT", "author_id": 17455524, "author_profile": "https://Stackoverflow.com/users/17455524", "pm_score": 2, "selected": true, "text": "Name" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455794", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12399310/" ]
74,455,821
<p>I'm using an <code>AUTOLOAD</code> example from <a href="https://stackoverflow.com/a/74229589/14055985">@ikegami's post here</a>. A recent <a href="http://www.cpantesters.org/cpan/report/5bde02fe-652a-11ed-abf4-11073d6a6173" rel="nofollow noreferrer">CPAN testers report</a> for my <a href="https://metacpan.org/pod/RF::Component::Multi" rel="nofollow noreferrer">RF::Component::Multi</a> module says:</p> <pre><code>Bareword found where operator expected at .../RF/Component/Multi.pm line 102, near &quot;s/^.*:://sr&quot; syntax error at .../RF/Component/Multi.pm line 102, near &quot;s/^.*:://sr&quot; </code></pre> <p>The code is below and <a href="https://github.com/KJ7LNW/perl-RF-Component/blob/master/lib/RF/Component/Multi.pm#L98" rel="nofollow noreferrer">here</a> on GitHub.</p> <ul> <li>What is it that Perl 5.10 doesn't like?</li> <li>Is there a Perl feature requiring &gt;5.10 hidden in here that I'm missing? (My Perl 5.26.3 is working) <ul> <li>If so can it be made more backwards compatible? How?</li> <li>If not, where do I find the version so I can do the right <code>use 5.xx</code>?</li> </ul> </li> <li>Do I need <code>use vars '$AUTOLOAD'</code>?</li> </ul> <pre class="lang-perl prettyprint-override"><code># Thanks @ikegami: # https://stackoverflow.com/a/74229589/14055985 sub AUTOLOAD { my $method_name = our $AUTOLOAD =~ s/^.*:://sr; my $method = sub { my $self = shift; return [ map { $_-&gt;$method_name(@_) } @$self ]; }; { no strict 'refs'; *$method_name = $method; } goto &amp;$method; } </code></pre>
[ { "answer_id": 74455982, "author": "ikegami", "author_id": 589924, "author_profile": "https://Stackoverflow.com/users/589924", "pm_score": 4, "selected": true, "text": "s///r" }, { "answer_id": 74458707, "author": "Dave Cross", "author_id": 7231, "author_profile": "https://Stackoverflow.com/users/7231", "pm_score": 3, "selected": false, "text": "$ perlver your-code.pl\n\n\n --------------------------------------\n | file | explicit | syntax | external |\n | -------------------------------------- |\n | minver | ~ | v5.13.2 | n/a |\n | -------------------------------------- |\n | Minimum explicit version : ~ |\n | Minimum syntax version : v5.13.2 |\n | Minimum version of perl : v5.13.2 |\n --------------------------------------\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455821", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14055985/" ]
74,455,855
<p>It is possible to identify the datatype at runtime using RTTI, but <strong>how do we do it at compile time</strong>, is it even possible ?</p>
[ { "answer_id": 74455856, "author": "Rajesh", "author_id": 956608, "author_profile": "https://Stackoverflow.com/users/956608", "pm_score": 0, "selected": false, "text": "\ntemplate<class T>\nstruct isPointer{\nstatic bool value = false;\n}\n\ntemplate<class T> // Template specialization \nstruct isPointer<T*>{\nstatic bool value = true;\n}\n" }, { "answer_id": 74456062, "author": "Stack Danny", "author_id": 6039995, "author_profile": "https://Stackoverflow.com/users/6039995", "pm_score": 3, "selected": false, "text": "decltype" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455855", "https://Stackoverflow.com", "https://Stackoverflow.com/users/956608/" ]
74,455,909
<p>I have a requirement where I need to select rows from a dataframe where one column-value is <em><strong>like</strong></em> values in a list. The requirement is for a large dataframe with millions of rows and need to search for rows where column-value is like values of a list of thousands of values.</p> <p>Below is a sample data.</p> <pre><code>NAME,AGE Amar,80 Rameshwar,60 Farzand,90 Naren,60 Sheikh,45 Ramesh,55 Narendra,85 Rakesh,86 Ram,85 Kajol,80 Naresh,86 Badri,85 Ramendra,80 </code></pre> <p>My code is like below. But problem is that I'm using a for loop, hence with increased number of values in the list-of-values (variable names_like in my code) I need to search, the number of loop and concat operation increases and it makes the code runs very slow. I can't use the isin() option as isin is for exact match and for me it is not an exact match, it a like condition for me. <strong>Looking for a better more performance efficient way of getting the required result.</strong></p> <p>My Code:-</p> <pre><code>import pandas as pd infile = &quot;input.csv&quot; df = pd.read_csv(infile) print(f&quot;df=\n{df}&quot;) names_like = ['Ram', 'Nar'] df_res = pd.DataFrame(columns=df.columns) for name in names_like: df1 = df[df['NAME'].str.contains(name, na=False)] df_res = pd.concat([df_res,df1], axis=0) print(f&quot;df_res=\n{df_res}&quot;) </code></pre> <p>My Output:-</p> <pre><code>df_res= NAME AGE 1 Rameshwar 60 5 Ramesh 55 8 Ram 85 12 Ramendra 80 3 Naren 60 6 Narendra 85 10 Naresh 86 </code></pre> <p>Looking for a better more performance efficient way of getting the required result.</p>
[ { "answer_id": 74455923, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 2, "selected": true, "text": "|" }, { "answer_id": 74455939, "author": "Shubham Kamble", "author_id": 20516976, "author_profile": "https://Stackoverflow.com/users/20516976", "pm_score": 0, "selected": false, "text": "df_res = df[df['NAME'].str.contains('|'.join(names_like), na=False)]" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455909", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2577122/" ]
74,455,917
<p>I am making a chrome extension (mv3). Based on user activity, the content.js passes a message to the background.js which then calls an async function to add data in Google Docs using Docs API.</p> <p>I want each request to execute only after the previous one has finished running. I am using <code>chrome.runtime.sendMessage</code> to send a message from content.js and don't see a way of calling background.js serially from there. So I need a way of executing them one by one in background.js only. The order of these requests is also important (but if the order of the requests gets changed by one/two places, I think that would still be okay from a user perspective).</p> <p>I tried something and it is working but I am not sure if I am missing some edge cases, because I was unable to find the approach in any other answers -</p> <ul> <li><a href="https://stackoverflow.com/q/17528749/10217754">Semaphore-like queue in javascript?</a></li> <li><a href="https://stackoverflow.com/questions/42751197/run-n-number-of-async-function-before-calling-another-method-in-nodejs">Run n number of async function before calling another method in nodejs</a></li> <li><a href="https://stackoverflow.com/questions/13583280/javascript-execute-async-function-one-by-one">JavaScript: execute async function one by one</a></li> </ul> <p>The approach I used is: I use a stack like structure to store requests, use setInterval to check for any pending requests and execute them serially.</p> <p>content.js:</p> <pre><code>chrome.runtime.sendMessage({message}); </code></pre> <p>background.js:</p> <pre><code>let addToDocInterval = &quot;&quot;; let addToDocCalls = []; async function addToDoc(msg) { // Await calls to doc API } async function addToDocHelper() { if(addToDocCalls.length === 0) return; clearInterval(addToDocInterval) while(addToDocCalls.length &gt; 0) { let msg = addToDocCalls.shift(); await addToDoc(msg); } addToDocInterval = setInterval(addToDocHelper, 1000); } chrome.runtime.onMessage.addListener((msg) =&gt; { // Some other logic addToDocCalls.push(msg); }) addToDocInterval = setInterval(addToDocHelper, 1000); </code></pre> <p>Is this approach correct? Or is there any better way to do this?</p>
[ { "answer_id": 74456307, "author": "jfriend00", "author_id": 816620, "author_profile": "https://Stackoverflow.com/users/816620", "pm_score": 2, "selected": true, "text": "addToDocCalls" }, { "answer_id": 74456346, "author": "Molda", "author_id": 3284355, "author_profile": "https://Stackoverflow.com/users/3284355", "pm_score": 1, "selected": false, "text": "let addToDocInterval = \"\";\nlet addToDocCalls = [];\nlet running = false;\n\nasync function addToDoc(msg) {\n // Await calls to doc API\n}\n\nasync function addToDocHelper() {\n if(running || addToDocCalls.length === 0)\n return;\n\n running = true;\n\n let msg = addToDocCalls.shift();\n await addToDoc(msg);\n\n running = false;\n\n addToDocHelper();\n}\n\nchrome.runtime.onMessage.addListener((msg) => {\n // Some other logic\n addToDocCalls.push(msg);\n addToDocHelper();\n});\n" }, { "answer_id": 74456540, "author": "Rocky Sims", "author_id": 4123400, "author_profile": "https://Stackoverflow.com/users/4123400", "pm_score": 0, "selected": false, "text": "const tasks = [];\nlet taskInProgress = false;\nasync function qTask(newTask) {\n if (newTask) tasks.push(newTask);\n if (tasks.length === 0) return;\n if (taskInProgress) return;\n\n const nextTask = tasks.shift();\n taskInProgress = true;\n try {\n await nextTask();\n } finally {\n taskInProgress = false;\n \n //use setTimeout so call stack can't overflow\n setTimeout(qTask, 0);\n }\n}\n\n\n\n//the code below is just used to demonstrate the code above works\n\nasync function test() {\n console.log(`queuing first task`);\n qTask(async () => {\n await delay(500); //pretend this task takes 0.5 seconds\n console.log('first task started');\n throw 'demonstrate error does not ruin task queue';\n console.log('first task finished');\n });\n\n for (let i = 0; i < 5; i++) {\n console.log(`queuing task ${i}`)\n qTask(async () => {\n await delay(200); //pretend this task takes 0.2 seconds\n console.log(`task ${i} ran`);\n }); \n }\n\n await delay(1000); //wait 1 second\n\n console.log(`queuing extra task`);\n qTask(async () => {\n console.log('extra task ran');\n }); \n\n await delay(3000); //wait 3 seconds\n\n console.log(`queuing last task`);\n qTask(async () => {\n console.log('last task ran');\n }); \n}\ntest();\n\nfunction delay(ms) {\n return new Promise(resolve => {\n setTimeout(resolve, ms);\n });\n}" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455917", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10217754/" ]
74,455,925
<p>So i have an API, which gives me date format like this <code>11/21/2022 19:00:00</code> what i need to do is i have to schedule notification for this datetime, but the problem is i am using <code>react-native/expo</code> which accepts the scheduling time in seconds.</p> <p>How do i convert this datetime to seconds, i mean if today's date is <code>11/15/2022 12:00:00</code> and the date on which the notification should be scheduled is <code>11/16/2022 12:00:00</code> which means the future date in 1 day ahead of todays date, and 1 day is equal to <code>86400</code> seconds, which means i have to trigger notification after <code>86400</code> seconds. So how do i get the remaining seconds of the upcoming date?</p>
[ { "answer_id": 74456218, "author": "pope_maverick", "author_id": 3065781, "author_profile": "https://Stackoverflow.com/users/3065781", "pm_score": 1, "selected": false, "text": "+ new Date\n" }, { "answer_id": 74456301, "author": "Nasyx Nadeem", "author_id": 9663776, "author_profile": "https://Stackoverflow.com/users/9663776", "pm_score": 0, "selected": false, "text": "const dayjs = require(\"dayjs\")\n\nconst d1 = dayjs(\"2022-11-15 13:00\")\nconst d2 = dayjs(\"2022-11-16 12:00\")\n\nconst res = d1.diff(d2) / 1000 // ÷ by 1000 to get output in seconds\n\nconsole.log(res)\n\n" }, { "answer_id": 74456314, "author": "Michal Miky Jankovský", "author_id": 1474751, "author_profile": "https://Stackoverflow.com/users/1474751", "pm_score": 2, "selected": false, "text": "new Date(\"2022-11-16T12:00:00Z\")" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455925", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9663776/" ]
74,455,933
<p>im confuse with redis instalation. I've already tried uninstall redis with any tutorials, also trying uninstall manually. But, redis still used 6379 port.</p> <pre class="lang-bash prettyprint-override"><code>dna@dna:~$ sudo netstat -tulnp | grep 6379 [sudo] password for dna: tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 22141/redis-server tcp6 0 0 :::6379 :::* LISTEN 22141/redis-server dna@dna:~$ apt-get autopurge redis-server E: Could not open lock file /var/lib/dpkg/lock-frontend - open (13: Permission denied) E: Unable to acquire the dpkg frontend lock (/var/lib/dpkg/lock-frontend), are you root? dna@dna:~$ sudo apt-get autopurge redis-server Reading package lists... Done Building dependency tree... Done Reading state information... Done Package 'redis-server' is not installed, so not removed 0 upgraded, 0 newly installed, 0 to remove and 45 not upgraded. dna@dna:~$ sudo apt-get autopurge redis* Reading package lists... Done Building dependency tree... Done Reading state information... Done E: Unable to locate package redis-stable E: Unable to locate package redis-stable.tar.gz E: Couldn't find any package by glob 'redis-stable.tar.gz' E: Couldn't find any package by regex 'redis-stable.tar.gz' dna@dna:~$ redis-cli </code></pre> <p>my docker apps used redis already stopped, also the redis image already removed too.<br /> Here's my os:</p> <pre class="lang-bash prettyprint-override"><code>dna@dna:~$ hostnamectl Static hostname: dna Icon name: computer-laptop Chassis: laptop Machine ID: ------- Boot ID: ------- Operating System: Linux Mint 21 Kernel: Linux 5.15.0-41-generic Architecture: x86-64 Hardware Vendor: Lenovo Hardware Model: ------- </code></pre> <p><strong>[UPDATED1]</strong><br /> thank you for answer me. Currently the problem still exist. By this update, here i give you my cmd input and output.</p> <pre class="lang-bash prettyprint-override"><code>dna@dna:~$ docker ps Cannot connect to the Docker daemon at unix:///var/run/docker.sock. Is the docker daemon running? dna@dna:~$ sudo apt-get autopurge redis* [sudo] password for dna: Reading package lists... Done Building dependency tree... Done Reading state information... Done E: Unable to locate package redis-stable E: Unable to locate package redis-stable.tar.gz E: Couldn't find any package by glob 'redis-stable.tar.gz' E: Couldn't find any package by regex 'redis-stable.tar.gz' dna@dna:~$ redis-cli Command 'redis-cli' not found, but can be installed with: sudo apt install redis-tools dna@dna:~$ redis-cli ping Command 'redis-cli' not found, but can be installed with: sudo apt install redis-tools dna@dna:~$ sudo netstat -tulnp | grep 6379 tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 961/redis-server *: tcp6 0 0 :::6379 :::* LISTEN 961/redis-server *: dna@dna:~$ fuser -n tcp 6379 dna@dna:~$ sudo netstat -tulnp | grep 6379 tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 961/redis-server *: tcp6 0 0 :::6379 :::* LISTEN 961/redis-server *: dna@dna:~$ kill -9 961 bash: kill: (961) - Operation not permitted dna@dna:~$ sudo kill -9 961 dna@dna:~$ sudo netstat -tulnp | grep 6379 tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 36248/redis-server tcp6 0 0 :::6379 :::* LISTEN 36248/redis-server dna@dna:~$ ps -auxf | grep -i redis dna 36284 0.0 0.0 9080 2396 pts/0 S+ 13:02 0:00 \_ grep --color=auto -i redis root 36248 0.2 0.1 53760 8212 ? Ssl 13:01 0:00 /snap/redis/525/usr/bin/redis-server *:6379 dna@dna:~$ apt list installed | grep -i redis WARNING: apt does not have a stable CLI interface. Use with caution in scripts. dna@dna:~$ systemctl | grep -i redis run-snapd-ns-redis.mnt.mount loaded active mounted /run/snapd/ns/redis.mnt snap-redis-525.mount loaded active mounted Mount unit for redis, revision 525 snap.redis.server.service loaded active running Service for snap application redis.server dna@dna:~$ </code></pre> <p><strong>[UPDATED2]</strong><br /> trying to uninstall redis with snap</p> <pre class="lang-bash prettyprint-override"><code>dna@dna:~$ sudo snap remove redis.server [sudo] password for dna: snap &quot;redis.server&quot; is not installed dna@dna:~$ sudo snap remove redis-525 snap &quot;redis-525&quot; is not installed dna@dna:~$ sudo netstat -tulnp | grep 6379 tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 36248/redis-server tcp6 0 0 :::6379 :::* LISTEN 36248/redis-server dna@dna:~$ sudo snap remove redis.server ; sudo snap remove redis-525 snap &quot;redis.server&quot; is not installed snap &quot;redis-525&quot; is not installed dna@dna:~$ systemctl | grep -i redis run-snapd-ns-redis.mnt.mount loaded active mounted /run/snapd/ns/redis.mnt snap-redis-525.mount loaded active mounted Mount unit for redis, revision 525 snap.redis.server.service loaded active running Service for snap application redis.server dna@dna:~$ pkill -9 36248 dna@dna:~$ systemctl | grep -i redis run-snapd-ns-redis.mnt.mount loaded active mounted /run/snapd/ns/redis.mnt snap-redis-525.mount loaded active mounted Mount unit for redis, revision 525 snap.redis.server.service loaded active running Service for snap application redis.server dna@dna:~$ sudo netstat -tulnp | grep 6379 tcp 0 0 0.0.0.0:6379 0.0.0.0:* LISTEN 36248/redis-server tcp6 0 0 :::6379 :::* LISTEN 36248/redis-server dna@dna:~$ </code></pre>
[ { "answer_id": 74456182, "author": "Kevin C", "author_id": 4834431, "author_profile": "https://Stackoverflow.com/users/4834431", "pm_score": 1, "selected": true, "text": "snap" }, { "answer_id": 74457336, "author": "C-nan", "author_id": 13524500, "author_profile": "https://Stackoverflow.com/users/13524500", "pm_score": 0, "selected": false, "text": "fuser -n tcp 6379" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455933", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2978502/" ]
74,455,947
<p>I save the current record using</p> <pre><code>$(&quot;.o_form_button_save&quot;).click(); </code></pre> <p>Now I want to get the record id of this record. While printing &quot;this&quot;, I am not able to find the id.</p>
[ { "answer_id": 74456182, "author": "Kevin C", "author_id": 4834431, "author_profile": "https://Stackoverflow.com/users/4834431", "pm_score": 1, "selected": true, "text": "snap" }, { "answer_id": 74457336, "author": "C-nan", "author_id": 13524500, "author_profile": "https://Stackoverflow.com/users/13524500", "pm_score": 0, "selected": false, "text": "fuser -n tcp 6379" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455947", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19986231/" ]
74,455,953
<pre><code>INSERT INTO `iot_athlete_ind_cont_non_cur_chlng_consp` (`aicicc_id`, `aicid_id`, `aicidl_id`, `aica_id`, `at_id`, `aicicc_type`, `aicicc_tp`, `aicicc_attempt`, `aicicc_lastposition`, `aicicc_status`, `pan_percentile`, `age_percentile`, `created_at`, `updated_at`) VALUES (270, 3, 14, 17, 7, 'Time', 50, 1, 5, 'Active', NULL, NULL, '2022-11-15 08:34:40', '2022-11-15 08:34:40'), (271, 3, 14, 20, 7, 'Time', 60, 1, 231, 'Active', NULL, NULL, '2022-11-15 08:34:45', '2022-11-15 08:35:21'), (272, 3, 14, 21, 7, 'Time', 70, 1, 20, 'Active', NULL, NULL, '2022-11-15 08:34:45', '2022-11-15 08:35:21'), (273, 3, 14, 17, 7, 'Time', 90, 2, 5, 'Active', NULL, NULL, '2022-11-15 08:34:45', '2022-11-15 12:13:42'), (274, 3, 14, 20, 7, 'Time', 40, 2, 231, 'Active', NULL, NULL, '2022-11-15 08:34:45', '2022-11-15 08:35:21'), (275, 3, 14, 21, 7, 'Time', 70, 2, 20, 'Active', NULL, NULL, '2022-11-15 08:34:45', '2022-11-15 08:35:21'), (276, 3, 10, 17, 3, 'Time', 80, 1, 5, 'Active', NULL, NULL, '2022-11-15 08:34:45', '2022-11-15 12:10:25'), (277, 3, 10, 20, 3, 'Time', 60, 1, 231, 'Active', NULL, NULL, '2022-11-15 08:34:45', '2022-11-15 12:10:43'), (278, 3, 10, 21, 3, 'Time', 60, 1, 20, 'Active', NULL, NULL, '2022-11-15 08:34:45', '2022-11-15 12:11:03'); </code></pre> <p>I need 3 rows form this table with average like this</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>at_id</th> <th>aicicc_attempt</th> <th>average</th> </tr> </thead> <tbody> <tr> <td>7</td> <td>1</td> <td>60</td> </tr> <tr> <td>7</td> <td>2</td> <td>66.66</td> </tr> <tr> <td>3</td> <td>1</td> <td>66.66</td> </tr> </tbody> </table> </div> <p>my query is</p> <pre><code>SELECT DISTINCT at_id, AVG(aicicc_tp) OVER (PARTITION BY aicicc_attempt) as average FROM iot_athlete_ind_cont_non_cur_chlng_consp WHERE aicid_id = '3'; </code></pre> <p>but its not working properly average calculation is wrong here in my query.</p>
[ { "answer_id": 74456565, "author": "Jonas Metzler", "author_id": 18794826, "author_profile": "https://Stackoverflow.com/users/18794826", "pm_score": 1, "selected": true, "text": "GROUP BY" }, { "answer_id": 74456573, "author": "learning", "author_id": 12458846, "author_profile": "https://Stackoverflow.com/users/12458846", "pm_score": -1, "selected": false, "text": "SELECT at_id, aicicc_attempt, AVG(aicicc_tp) FROM iot_athlete_ind_cont_non_cur_chlng_consp\nGROUP BY at_id, aicicc_attempt\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455953", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17176306/" ]
74,455,987
<p>I have a project named <code>cheshire-cat</code> in which I am trying to run Rhino-based ClojureScript REPL with the command <code>lein trampoline cljsbuild repl-rhino</code>. It gives an exception in thread &quot;main&quot; and terminates.<br /> What is the problem? Following is the terminal output:</p> <pre><code>$lein trampoline cljsbuild repl-rhino Running Rhino-based ClojureScript REPL. Exception in thread &quot;main&quot; Syntax error compiling at (cljs/repl.clj:1:1). at clojure.lang.Compiler.load(Compiler.java:7647) at clojure.lang.RT.loadResourceScript(RT.java:381) at clojure.lang.RT.loadResourceScript(RT.java:372) at clojure.lang.RT.load(RT.java:463) at clojure.lang.RT.load(RT.java:428) at clojure.core$load$fn__6824.invoke(core.clj:6126) at clojure.core$load.invokeStatic(core.clj:6125) at clojure.core$load.doInvoke(core.clj:6109) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5908) at clojure.core$load_one.invoke(core.clj:5903) at clojure.core$load_lib$fn__6765.invoke(core.clj:5948) at clojure.core$load_lib.invokeStatic(core.clj:5947) at clojure.core$load_lib.doInvoke(core.clj:5928) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$load_libs.invokeStatic(core.clj:5985) at clojure.core$load_libs.doInvoke(core.clj:5969) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$require.invokeStatic(core.clj:6007) at clojure.core$require.doInvoke(core.clj:6007) at clojure.lang.RestFn.invoke(RestFn.java:421) at cljsbuild.repl.rhino$eval144$loading__6706__auto____145.invoke(rhino.clj:1) at cljsbuild.repl.rhino$eval144.invokeStatic(rhino.clj:1) at cljsbuild.repl.rhino$eval144.invoke(rhino.clj:1) at clojure.lang.Compiler.eval(Compiler.java:7176) at clojure.lang.Compiler.eval(Compiler.java:7165) at clojure.lang.Compiler.load(Compiler.java:7635) at clojure.lang.RT.loadResourceScript(RT.java:381) at clojure.lang.RT.loadResourceScript(RT.java:372) at clojure.lang.RT.load(RT.java:463) at clojure.lang.RT.load(RT.java:428) at clojure.core$load$fn__6824.invoke(core.clj:6126) at clojure.core$load.invokeStatic(core.clj:6125) at clojure.core$load.doInvoke(core.clj:6109) at clojure.lang.RestFn.invoke(RestFn.java:408) at clojure.core$load_one.invokeStatic(core.clj:5908) at clojure.core$load_one.invoke(core.clj:5903) at clojure.core$load_lib$fn__6765.invoke(core.clj:5948) at clojure.core$load_lib.invokeStatic(core.clj:5947) at clojure.core$load_lib.doInvoke(core.clj:5928) at clojure.lang.RestFn.applyTo(RestFn.java:142) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$load_libs.invokeStatic(core.clj:5985) at clojure.core$load_libs.doInvoke(core.clj:5969) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.core$apply.invokeStatic(core.clj:667) at clojure.core$require.invokeStatic(core.clj:6007) at clojure.core$require.doInvoke(core.clj:6007) at clojure.lang.RestFn.invoke(RestFn.java:408) at user$eval5.invokeStatic(form-init5565266544074168037.clj:1) at user$eval5.invoke(form-init5565266544074168037.clj:1) at clojure.lang.Compiler.eval(Compiler.java:7176) at clojure.lang.Compiler.eval(Compiler.java:7165) at clojure.lang.Compiler.load(Compiler.java:7635) at clojure.lang.Compiler.loadFile(Compiler.java:7573) at clojure.main$load_script.invokeStatic(main.clj:452) at clojure.main$init_opt.invokeStatic(main.clj:454) at clojure.main$init_opt.invoke(main.clj:454) at clojure.main$initialize.invokeStatic(main.clj:485) at clojure.main$null_opt.invokeStatic(main.clj:519) at clojure.main$null_opt.invoke(main.clj:516) at clojure.main$main.invokeStatic(main.clj:598) at clojure.main$main.doInvoke(main.clj:561) at clojure.lang.RestFn.applyTo(RestFn.java:137) at clojure.lang.Var.applyTo(Var.java:705) at clojure.main.main(main.java:37) Caused by: java.lang.ClassNotFoundException: javax.xml.bind.DatatypeConverter at java.base/java.net.URLClassLoader.findClass(URLClassLoader.java:445) at clojure.lang.DynamicClassLoader.findClass(DynamicClassLoader.java:69) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:588) at clojure.lang.DynamicClassLoader.loadClass(DynamicClassLoader.java:77) at java.base/java.lang.ClassLoader.loadClass(ClassLoader.java:521) at java.base/java.lang.Class.forName0(Native Method) at java.base/java.lang.Class.forName(Class.java:495) at java.base/java.lang.Class.forName(Class.java:474) at clojure.lang.RT.classForName(RT.java:2207) at clojure.lang.RT.classForNameNonLoading(RT.java:2220) at cljs.repl$eval150$loading__6706__auto____151.invoke(repl.clj:9) at cljs.repl$eval150.invokeStatic(repl.clj:9) at cljs.repl$eval150.invoke(repl.clj:9) at clojure.lang.Compiler.eval(Compiler.java:7176) at clojure.lang.Compiler.eval(Compiler.java:7165) at clojure.lang.Compiler.load(Compiler.java:7635) ... 67 more </code></pre> <p>This is my <code>project.clj</code> file:</p> <pre><code>(defproject cheshire-cat &quot;0.1.0-SNAPSHOT&quot; :description &quot;FIXME: write description&quot; :url &quot;http://example.com/FIXME&quot; :min-lein-version &quot;2.0.0&quot; :dependencies [[org.clojure/clojure &quot;1.10.0&quot;] [compojure &quot;1.6.1&quot;] [ring/ring-defaults &quot;0.3.2&quot;] [ring/ring-json &quot;0.5.1&quot;] [org.clojure/clojurescript &quot;0.0-2371&quot;]] :plugins [[lein-ring &quot;0.12.6&quot;] [lein-cljsbuild &quot;1.1.8&quot;]] :ring {:handler cheshire-cat.handler/app} :profiles {:dev {:dependencies [[javax.servlet/servlet-api &quot;2.5&quot;] [ring/ring-mock &quot;0.3.2&quot;]]}} :cljsbuild { :builds [{ :source-paths [&quot;src-cljs&quot;] :compiler { :output-to &quot;resources/public/main.js&quot; :optimizations :whitespace :pretty-print true}}]}) </code></pre> <p>I tried to change the dependencies version to make it work but it didn't. How to remove this error and make the command run the REPL without any error. Thanks.</p>
[ { "answer_id": 74456685, "author": "Thomas Heller", "author_id": 8009006, "author_profile": "https://Stackoverflow.com/users/8009006", "pm_score": 2, "selected": true, "text": "[javax.xml.bind/jaxb-api \"2.3.1\"]\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455987", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20499245/" ]
74,455,999
<p>I have a multiple Pressable component. How can I make it that when I clicked on the Motorcycle pressable, the check icon would be shown beside it and if on the Tricycle Pressable, the check icon would be shown beside it and the one on the Motorcycle icon will be gone.</p> <p><a href="https://i.stack.imgur.com/GXIN9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/GXIN9.png" alt="enter image description here" /></a></p> <p>I have tried creating a state but it simultaneously set all icons in place. Here is the code:</p> <pre><code> const [checkIcon, setCheckIcon] = useState(false) &lt;Pressable style={({ pressed }) =&gt; [{ opacity: pressed ? 0.4 : 1 }, styles.modalField]} onPress={() =&gt; setCheckIcon(true)} &gt; &lt;Image source={require(&quot;../assets/motorcycle.png&quot;)} style={styles.modalFieldImage} /&gt; &lt;View style={styles.modalFieldVehicleNameContainer}&gt; &lt;Text style={styles.modalFieldText}&gt;Motorcycle&lt;/Text&gt; &lt;Text style={styles.modalFieldTextDescription}&gt;Cheapest option perfect for small-sized items&lt;/Text&gt; &lt;Text style={styles.modalFieldTextDescription}&gt;Up to 20 kg&lt;/Text&gt; &lt;/View&gt; { checkIcon === true ? &lt;Icon name=&quot;check&quot; type=&quot;font-awesome-5&quot; size={hp(&quot;3%&quot;)} color=&quot;#322C6A&quot; style={styles.modalFieldIcon} /&gt; : null } &lt;/Pressable&gt; &lt;Pressable style={({ pressed }) =&gt; [{ opacity: pressed ? 0.4 : 1 }, styles.modalField]} onPress={() =&gt; setCheckIcon(true)} &gt; &lt;Image source={require(&quot;../assets/tricycle.png&quot;)} style={styles.modalFieldImage} /&gt; &lt;View style={styles.modalFieldVehicleNameContainer}&gt; &lt;Text style={styles.modalFieldText}&gt;Tricycle&lt;/Text&gt; &lt;Text style={styles.modalFieldTextDescription}&gt;Perfect for multiple medium-sized items&lt;/Text&gt; &lt;Text style={styles.modalFieldTextDescription}&gt;Up to 70 kg&lt;/Text&gt; &lt;/View&gt; { checkIcon === true ? &lt;Icon name=&quot;check&quot; type=&quot;font-awesome-5&quot; size={hp(&quot;3%&quot;)} color=&quot;#322C6A&quot; style={styles.modalFieldIcon} /&gt; : null } &lt;/Pressable&gt; &lt;Pressable style={({ pressed }) =&gt; [{ opacity: pressed ? 0.4 : 1 }, styles.modalField]} onPress={() =&gt; setCheckIcon(true)} &gt; &lt;Image source={require(&quot;../assets/sedan.png&quot;)} style={styles.modalFieldImage} /&gt; &lt;View style={styles.modalFieldVehicleNameContainer}&gt; &lt;Text style={styles.modalFieldText}&gt;Sedan Car&lt;/Text&gt; &lt;Text style={styles.modalFieldTextDescription}&gt;Good for cakes and multiple small to medium-sized items&lt;/Text&gt; &lt;Text style={styles.modalFieldTextDescription}&gt;Up to 200 kg&lt;/Text&gt; &lt;/View&gt; { checkIcon === true ? &lt;Icon name=&quot;check&quot; type=&quot;font-awesome-5&quot; size={hp(&quot;3%&quot;)} color=&quot;#322C6A&quot; style={styles.modalFieldIcon} /&gt; : null } &lt;/Pressable&gt; </code></pre>
[ { "answer_id": 74456115, "author": "Hardik prajapati", "author_id": 18241250, "author_profile": "https://Stackoverflow.com/users/18241250", "pm_score": 2, "selected": false, "text": "vehicle:[ image:'put your imageUrl', name:'', description:'', clickStatus:true ]" }, { "answer_id": 74456286, "author": "Peter Tam", "author_id": 20002061, "author_profile": "https://Stackoverflow.com/users/20002061", "pm_score": 3, "selected": true, "text": "map()" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74455999", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20307955/" ]
74,456,010
<p>I would like to check if the user in the database exists. with this line of codes, it says that it exists and also that it does not exist. I want to make the code read-only if the name exists in one of the registers</p> <p><a href="https://i.stack.imgur.com/oY8HV.png" rel="nofollow noreferrer">enter image description here</a></p> <p>Firebase database</p> <pre><code>private void Criar_Conta() { databaseReference_users.addValueEventListener(new ValueEventListener() { @Override public void onDataChange(@NonNull DataSnapshot dataSnapshot) { if (dataSnapshot.exists()) { for (DataSnapshot snapshot : dataSnapshot.getChildren()) { if (snapshot.child(&quot;usuario&quot;).getValue().equals(Usuario.getText().toString()) &amp;&amp; snapshot.getKey().equals(Usuario.getText().toString()) &amp;&amp; snapshot.getKey().equals(snapshot.child(&quot;usuario&quot;).getValue())) { Toast.makeText(Sign_Up.this, &quot;Usuário Existente&quot;, Toast.LENGTH_SHORT).show(); } else { Toast.makeText(Sign_Up.this, &quot;Gravar ...&quot;, Toast.LENGTH_SHORT).show(); //Gravar_Dados(); } } } else { Gravar_Dados(); } } @Override public void onCancelled(@NonNull DatabaseError databaseError) { Toast.makeText(Sign_Up.this, databaseError.getMessage(), Toast.LENGTH_LONG).show(); Swipe.setRefreshing(true); } }); </code></pre>
[ { "answer_id": 74456115, "author": "Hardik prajapati", "author_id": 18241250, "author_profile": "https://Stackoverflow.com/users/18241250", "pm_score": 2, "selected": false, "text": "vehicle:[ image:'put your imageUrl', name:'', description:'', clickStatus:true ]" }, { "answer_id": 74456286, "author": "Peter Tam", "author_id": 20002061, "author_profile": "https://Stackoverflow.com/users/20002061", "pm_score": 3, "selected": true, "text": "map()" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456010", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17752957/" ]
74,456,013
<p>so basically i want to use the python input() function to get a velocity input from the user. After the user types the number i want to display a nit like m/s behind the user input. I thought i can do something like this:</p> <pre><code>velocity = input(&quot;Please enter a velocity: &quot;, end='') print(&quot;m/s&quot;) </code></pre> <p>but end='' only works with print() and not with input(). Do you have any other ideas? Thank you in advance.</p>
[ { "answer_id": 74456084, "author": "Jay", "author_id": 8677071, "author_profile": "https://Stackoverflow.com/users/8677071", "pm_score": 2, "selected": true, "text": "velocity" }, { "answer_id": 74456387, "author": "Himanshu Joshi", "author_id": 10337294, "author_profile": "https://Stackoverflow.com/users/10337294", "pm_score": -1, "selected": false, "text": "print(input(\"Please enter a velocity: \"), \"m/s\")\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456013", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11432227/" ]
74,456,021
<p>I have a pySpark dataframe, where I have null values that I want to replace - however the value to replace with is different for different groups.</p> <p>My data looks like this (appologies, I dont have a way to past it as text):</p> <p><a href="https://i.stack.imgur.com/d3rDU.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d3rDU.png" alt="enter image description here" /></a></p> <p>For group A I want to replace the null values with -999; while for group B, I want to replace the null value with 0.</p> <p>Currently, I split the data into sections, then do a <code>df = df.fillna(-999)</code> .</p> <p>Is there a more efficient way of doing it? in psudo-code I was thinking something along the line of <code>df = df.where(col('group') == A).fillna(lit(-999)).where(col('group') == B).fillna(lit(0))</code> but ofcourse, this doesn't work.</p>
[ { "answer_id": 74456543, "author": "PieCot", "author_id": 5359797, "author_profile": "https://Stackoverflow.com/users/5359797", "pm_score": 1, "selected": false, "text": "when" }, { "answer_id": 74463632, "author": "Ric S", "author_id": 7465462, "author_profile": "https://Stackoverflow.com/users/7465462", "pm_score": 0, "selected": false, "text": "coalesce" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456021", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11187883/" ]
74,456,060
<p>I'm using a container in Docker to host my Laravel app and this container is connected to another container using Nginx to host it. I'm trying to import a SQL file into my Laravel app with a seeder that's like this</p> <pre><code>$path = public_path('sql/2022_11_16_import_table.sql'); $sql = file_get_contents($path); DB::unprepared($sql); </code></pre> <p>However, it displayed the error</p> <blockquote> <p>Symfony\Component\Debug\Exception\FatalErrorException : Allowed memory size of 134217728 bytes exhausted (tried to allocate 186885432 bytes) at /var/www/database/seeds/SqlFileSeeder.php:16</p> </blockquote> <p>I have figured this is due to my memory_limit in php.ini is being 128M so I went ahead and changed it by changing the php.ini-development and php.ini-production file inside the PHP container and then restart the whole container and the Nginx container. However, when I tried</p> <pre><code>php -ini </code></pre> <p>again the memory_limit is still 128M=&gt;128M despite both the php.ini file has been changed. I have also tried ini_set('memory_limit','200M'); but it still seems to have no effect.</p>
[ { "answer_id": 74456161, "author": "Dream Bold", "author_id": 12743692, "author_profile": "https://Stackoverflow.com/users/12743692", "pm_score": 1, "selected": false, "text": "php.ini-production" }, { "answer_id": 74457051, "author": "Tural Rzaxanov", "author_id": 9922647, "author_profile": "https://Stackoverflow.com/users/9922647", "pm_score": 1, "selected": true, "text": "php.ini" }, { "answer_id": 74487939, "author": "Tran Minh Quan", "author_id": 16174416, "author_profile": "https://Stackoverflow.com/users/16174416", "pm_score": 0, "selected": false, "text": "ini_set" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456060", "https://Stackoverflow.com", "https://Stackoverflow.com/users/16174416/" ]
74,456,077
<p>I am writing code in C# to consume POST API that accepts form-body with the following parameters.</p> <p>Files[Array] (User can send multiple files in request)</p> <p>TemplateId[Int]</p> <p>Also, I need to pass the bearer AuthToken as a header in the HTTP client Post Request.</p> <p>I need some help writing the HTTP request with the above form data.</p> <pre><code>using (var client = new HttpClient()) { HttpRequestMessage requestMessage = new HttpRequestMessage(HttpMethod.Post, $&quot; {_apiBaseUri}/{route}&quot;); requestMessage.Headers.Authorization = new AuthenticationHeaderValue($&quot;Bearer {authToken}&quot;); var pdfFiles = Directory.GetFiles($&quot;C:\\files&quot;, &quot;*.pdf&quot;); foreach (var filename in pdfFiles) { // create array[] of each File and add them to the form data request } // Add TemplateId in the form data request } </code></pre> <p>postman request <a href="https://i.stack.imgur.com/vZBc7.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/vZBc7.png" alt="enter image description here" /></a></p> <p>swagger request <a href="https://i.stack.imgur.com/IKUyZ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/IKUyZ.png" alt="enter image description here" /></a></p>
[ { "answer_id": 74457023, "author": "Hamidreza Aliyari", "author_id": 12697989, "author_profile": "https://Stackoverflow.com/users/12697989", "pm_score": 2, "selected": true, "text": "private static async Task UploadSampleFile()\n{\n var client = new HttpClient\n {\n BaseAddress = new(\"https://localhost:5001\")\n };\n\n await using var stream = System.IO.File.OpenRead(\"./Test.txt\");\n using var request = new HttpRequestMessage(HttpMethod.Post, \"file\");\n using var content = new MultipartFormDataContent\n {\n { new StreamContent(stream), \"file\", \"Test.txt\" }\n };\n\n request.Content = content;\n\n await client.SendAsync(request);\n}\n" }, { "answer_id": 74464360, "author": "Saurabh Soni", "author_id": 3207067, "author_profile": "https://Stackoverflow.com/users/3207067", "pm_score": 0, "selected": false, "text": "using (var httpClient = new HttpClient())\n{\n using (var request = new HttpRequestMessage(new HttpMethod(\"POST\"), _apiBaseUri))\n {\n request.Headers.TryAddWithoutValidation(\"Authorization\", $\"Bearer {authToken}\");\n\n var pdfFiles = Directory.GetFiles($\"C:\\\\test\", \"*.pdf\");\n var multipartContent = new MultipartFormDataContent();\n multipartContent.Add(new StringContent(\"100\"), \"templateId\");\n foreach (var filename in pdfFiles)\n {\n multipartContent.Add(new ByteArrayContent(File.ReadAllBytes(filename)), \"files\", Path.GetFileName(filename));\n }\n request.Content = multipartContent;\n\n var response = await httpClient.SendAsync(request);\n }\n}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456077", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3207067/" ]
74,456,099
<p>I've added FontAwesome 6 to my app and want to use an icon. I have the OTF file in my assets folder here:</p> <p><a href="https://i.stack.imgur.com/C6OkL.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/C6OkL.png" alt="Assets/Fonts" /></a></p> <p>I want to change the default symbols (icons) for NavigationViewItems. I added the <code>FontIcon</code> however instead of the icon, I'm seeing just empty box:</p> <p><a href="https://i.stack.imgur.com/nWWzO.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nWWzO.png" alt="empty box" /></a></p> <p>The icon I'm adding is this: <a href="https://fontawesome.com/icons/tower-control?s=solid&amp;f=classic" rel="nofollow noreferrer">https://fontawesome.com/icons/tower-control?s=solid&amp;f=classic</a></p> <p>and my code is</p> <pre class="lang-xml prettyprint-override"><code>&lt;NavigationViewItem Content=&quot;Home&quot; Tag=&quot;homePageView&quot; x:Name=&quot;homeViewItem&quot;&gt; &lt;NavigationViewItem.Icon&gt; &lt;FontIcon FontFamily=&quot;Assets/Fonts/Font Awesome 6 Pro-Solid-900.otf#Font Awesome 6 Pro Solid&quot; Glyph=&quot;&amp;#xe2a1;&quot; /&gt; &lt;/NavigationViewItem.Icon&gt; &lt;/NavigationViewItem&gt; </code></pre> <p>Why is the icon not showing up?</p>
[ { "answer_id": 74457510, "author": "Andrew KeepCoding", "author_id": 2411960, "author_profile": "https://Stackoverflow.com/users/2411960", "pm_score": 1, "selected": false, "text": "<FontIcon FontFamily=\"Assets/Fonts/Font Awesome 6 Pro-Solid-900.otf#Font Awesome 6 Pro Solid\" Glyph=\"&#xe2a1;\" />\n" }, { "answer_id": 74484759, "author": "cptalpdeniz", "author_id": 5984665, "author_profile": "https://Stackoverflow.com/users/5984665", "pm_score": 1, "selected": true, "text": "ImageIcon" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456099", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5984665/" ]
74,456,102
<p>I am trying to understand the syntax of R and having difficulty when we nest formulas.</p> <p>In this case, I am trying to:</p> <ol> <li>select everything in column &quot;Y&quot; that is equal to one</li> <li>then give me unique values in column &quot;X&quot; when #1 is true.</li> </ol> <p>I know how to do this in two steps but not in a nested format.</p> <p>Thank you</p> <blockquote> <p>subset(data, Y == &quot;1&quot;) %&gt;%<br /> unique(&quot;X&quot;)</p> </blockquote>
[ { "answer_id": 74457510, "author": "Andrew KeepCoding", "author_id": 2411960, "author_profile": "https://Stackoverflow.com/users/2411960", "pm_score": 1, "selected": false, "text": "<FontIcon FontFamily=\"Assets/Fonts/Font Awesome 6 Pro-Solid-900.otf#Font Awesome 6 Pro Solid\" Glyph=\"&#xe2a1;\" />\n" }, { "answer_id": 74484759, "author": "cptalpdeniz", "author_id": 5984665, "author_profile": "https://Stackoverflow.com/users/5984665", "pm_score": 1, "selected": true, "text": "ImageIcon" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456102", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19740382/" ]
74,456,108
<p>I haven't changed anything recently in my project, but when I tried to deploy it last, I received this error in the logs: <code>ERROR: Could not build wheels for pyarrow, which is required to install pyproject.toml-based projects</code></p> <p>See the full log here: <a href="https://github.com/GoogleCloudPlatform/buildpacks/files/10018377/log-d20114fe-3eeb-4a8d-8926-3a971882894c.txt" rel="nofollow noreferrer">log-d20114fe-3eeb-4a8d-8926-3a971882894c.txt</a></p> <p>This is my <code>requirements.txt</code>: <a href="https://github.com/GoogleCloudPlatform/buildpacks/files/10018383/requirements.txt" rel="nofollow noreferrer">requirements.txt</a></p> <p>It seems like it is an issue with the dependencies for the snowflake-connector-python package, but I am not really sure what would have caused this. I see in the logs:</p> <pre><code>-- Running cmake for pyarrow Step #0 - &quot;Buildpack&quot;: cmake -DPYTHON_EXECUTABLE=/layers/google.python.runtime/python/bin/python3 -DPython3_EXECUTABLE=/layers/google.python.runtime/python/bin/python3 &quot;&quot; -DPYARROW_BUILD_CUDA=off -DPYARROW_BUILD_FLIGHT=off -DPYARROW_BUILD_GANDIVA=off -DPYARROW_BUILD_DATASET=off -DPYARROW_BUILD_ORC=off -DPYARROW_BUILD_PARQUET=off -DPYARROW_BUILD_PARQUET_ENCRYPTION=off -DPYARROW_BUILD_PLASMA=off -DPYARROW_BUILD_S3=off -DPYARROW_BUILD_HDFS=off -DPYARROW_USE_TENSORFLOW=off -DPYARROW_BUNDLE_ARROW_CPP=off -DPYARROW_BUNDLE_BOOST=off -DPYARROW_GENERATE_COVERAGE=off -DPYARROW_BOOST_USE_SHARED=on -DPYARROW_PARQUET_USE_SHARED=on -DCMAKE_BUILD_TYPE=release /tmp/pip-install-w1g_50oc/pyarrow_4a54282bee5f4c3c8399d3428e4134e6 Step #0 - &quot;Buildpack&quot;: error: command 'cmake' failed: No such file or directory </code></pre> <p>This makes me think CMake is the problem, but I tried explicitly adding CMake to my requirements file and had the same result.</p> <p>I also looked at the last successful build, and it looks like I was running python version 3.10.8, and the one that failed first was running 3.11. How can I change what python version cloud build uses? I am using the cloudbuild.yaml file instead of docker.</p>
[ { "answer_id": 74464812, "author": "Jasper Madrone", "author_id": 19808508, "author_profile": "https://Stackoverflow.com/users/19808508", "pm_score": 1, "selected": false, "text": "steps:\n - name: gcr.io/k8s-skaffold/pack\n env:\n - GOOGLE_ENTRYPOINT=$_ENTRYPOINT\n - GOOGLE_RUNTIME_VERSION=$_RUNTIME_VERSION\n args:\n - build\n - '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'\n - '--builder=gcr.io/buildpacks/builder:v1'\n - '--network=cloudbuild'\n - '--path=.'\n - '--env=GOOGLE_ENTRYPOINT'\n - '--env=GOOGLE_RUNTIME_VERSION'\n" }, { "answer_id": 74503830, "author": "Josh Kruse", "author_id": 2744073, "author_profile": "https://Stackoverflow.com/users/2744073", "pm_score": 0, "selected": false, "text": "Procfile" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456108", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19808508/" ]
74,456,127
<pre><code>test_ds.save(path) </code></pre> <p>I want to save the tf.data.Dataset,but get the message &quot;AttributeError: type object 'DatasetV2' has no attribute 'save'&quot;</p>
[ { "answer_id": 74464812, "author": "Jasper Madrone", "author_id": 19808508, "author_profile": "https://Stackoverflow.com/users/19808508", "pm_score": 1, "selected": false, "text": "steps:\n - name: gcr.io/k8s-skaffold/pack\n env:\n - GOOGLE_ENTRYPOINT=$_ENTRYPOINT\n - GOOGLE_RUNTIME_VERSION=$_RUNTIME_VERSION\n args:\n - build\n - '$_GCR_HOSTNAME/$PROJECT_ID/$REPO_NAME/$_SERVICE_NAME:$COMMIT_SHA'\n - '--builder=gcr.io/buildpacks/builder:v1'\n - '--network=cloudbuild'\n - '--path=.'\n - '--env=GOOGLE_ENTRYPOINT'\n - '--env=GOOGLE_RUNTIME_VERSION'\n" }, { "answer_id": 74503830, "author": "Josh Kruse", "author_id": 2744073, "author_profile": "https://Stackoverflow.com/users/2744073", "pm_score": 0, "selected": false, "text": "Procfile" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456127", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20517027/" ]
74,456,135
<p>I am new to programming. Just started a few months ago and I hope I can get some help.</p> <p>I have a flight delays dataset with columns 'Year', 'Month', 'DayOfMonth', 'DayOfWeek' and 'CRSDepTime' with int64 Dtype.</p> <p><a href="https://i.stack.imgur.com/MqL1N.png" rel="nofollow noreferrer">Screenshot of df</a></p> <p>I need to perform analysis and visualistions to identify the month, day and time with the lowest delays.</p> <p>Would you advise to convert all dtypes to datetime? Can I use pandas' to_datetime() function? If yes, what should the format be?</p> <p>Thanks in advance! :)</p> <p>I tried:</p> <pre><code>df['CRSDepTime'] = pd.to_datetime(df['CRSDepTime'], format='HHMM') </code></pre> <p>But I am not too sure of the format and it always gives: ValueError: time data '1605' does not match format 'HHMM' (match)</p>
[ { "answer_id": 74456149, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 1, "selected": false, "text": "to_datetime" }, { "answer_id": 74456217, "author": "Tim Roberts", "author_id": 1883316, "author_profile": "https://Stackoverflow.com/users/1883316", "pm_score": 0, "selected": false, "text": "import pandas as pd\nimport datetime\n\ndata = [\n [2005,1,28,5,1605],\n [2005,1,29,6,1605],\n [2005,1,30,7,1610],\n [2005,1,31,1,1605],\n [2005,1,2,7,1900],\n [2005,1,3,1,1900],\n]\n\ndef translate(row):\n return datetime.datetime( row['Year'],row['Month'],row['DayOfMonth'],row['CRSDepTime']//100, row['CRSDepTime']%100)\n\ndf = pd.DataFrame(data, columns=['Year','Month','DayOfMonth','DayOfWeek','CRSDepTime'])\n\ndf['timestamp'] = df.apply(translate,axis=1)\nprint(df)\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456135", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20517034/" ]
74,456,152
<p>I need to center a div vertically in a page</p> <pre><code>&lt;div class=&quot;d-flex align-items-center justify-content-center&quot;&gt; &lt;div class=&quot;w-100&quot;&gt; &lt;p&gt;My Content Here&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Where my code was</p> <pre><code>&lt;div&gt; &lt;h2&gt;My Content&lt;/h2&gt; &lt;/div&gt; &lt;div class=&quot;d-flex align-items-center justify-content-center&quot;&gt; &lt;div class=&quot;w-100&quot;&gt; &lt;p&gt;My Content Here&lt;/p&gt; &lt;/div&gt; &lt;/div&gt; &lt;div&gt; &lt;P&gt;My Content&lt;/P&gt; &lt;/div&gt; </code></pre> <p>My Html looks like this</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;title&gt;Title&lt;/title&gt; &lt;base href=&quot;/cfm&quot;&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1&quot;&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, user-scalable=no&quot;&gt; &lt;link rel=&quot;icon&quot; type=&quot;image/x-icon&quot; href=&quot;assets/images/favicon.png&quot;&gt; &lt;link rel=&quot;preconnect&quot; href=&quot;https://fonts.gstatic.com&quot;&gt; &lt;link href=&quot;https://fonts.googleapis.com/css2?family=Roboto:wght@300;400;500&amp;display=swap&quot; rel=&quot;stylesheet&quot;&gt; &lt;link href=&quot;https://fonts.googleapis.com/icon?family=Material+Icons&quot; rel=&quot;stylesheet&quot;&gt; &lt;/head&gt; &lt;body&gt; &lt;app-root&gt;&lt;/app-root&gt; &lt;script defer src=&quot;https://use.fontawesome.com/releases/v6.1.2/js/all.js&quot; integrity=&quot;sha384-11X1bEJVFeFtn94r1jlvSC7tlJkV2VJctorjswdLzqOJ6ZvYBSZQkaQVXG0R4Flt&quot; crossorigin=&quot;anonymous&quot;&gt;&lt;/script&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
[ { "answer_id": 74456191, "author": "Tushar Kumawat", "author_id": 3176303, "author_profile": "https://Stackoverflow.com/users/3176303", "pm_score": 1, "selected": false, "text": "position: absolute;\ntop: 50%;\nleft: 50%;\ntransform: translate(-50%, -50%);\n" }, { "answer_id": 74456205, "author": "Dennis Quan", "author_id": 12226091, "author_profile": "https://Stackoverflow.com/users/12226091", "pm_score": 0, "selected": false, "text": "div" }, { "answer_id": 74456238, "author": "Microtribute", "author_id": 3858559, "author_profile": "https://Stackoverflow.com/users/3858559", "pm_score": 0, "selected": false, "text": "h-100" }, { "answer_id": 74456273, "author": "Momin", "author_id": 4672474, "author_profile": "https://Stackoverflow.com/users/4672474", "pm_score": 0, "selected": false, "text": ".center {\n display: grid;\n place-items: center;\n min-height: 400px;\n}" }, { "answer_id": 74457728, "author": "Veljko03", "author_id": 20046454, "author_profile": "https://Stackoverflow.com/users/20046454", "pm_score": -1, "selected": false, "text": " width: 100px;\n height: 100px;\n\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n\n margin: auto;\n" }, { "answer_id": 74458248, "author": "Praveen Impaxive", "author_id": 19282758, "author_profile": "https://Stackoverflow.com/users/19282758", "pm_score": -1, "selected": false, "text": "<div class=\"d-flex flex-column\" style=\"min-height: 100vh\">\n <div>Head</div>\n <div class=\"d-flex align-items-center justify-content-center\" style=\"flex: 100%\">\n <p>Content Here</p>\n </div>\n <div class=\"mt-auto\">Footer</div>\n</div>\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19282758/" ]
74,456,174
<p>I've been working on this all day and can't get it done. Any help will be much appreciated! In Python, I want to loop through 3 times asking the user to enter 1 or more days of the week (e.g., Please enter the day(s) of the week:) with the input ending up in a list. The resulting data could look like this:</p> <pre><code>List1 = ['Monday','Wednesday','Friday'] List2 = ['Tuesday','Friday'] List3 = ['Wednesday'] </code></pre> <p>In addition, I want to validate the input so that I know that each entered day is spelled correctly with appropriate capitalization. The only valid entries are Monday, Tuesday, Wednesday, Thursday, Friday, Saturday, Sunday.</p> <p>Suggestions??? Thanks!!!</p>
[ { "answer_id": 74456191, "author": "Tushar Kumawat", "author_id": 3176303, "author_profile": "https://Stackoverflow.com/users/3176303", "pm_score": 1, "selected": false, "text": "position: absolute;\ntop: 50%;\nleft: 50%;\ntransform: translate(-50%, -50%);\n" }, { "answer_id": 74456205, "author": "Dennis Quan", "author_id": 12226091, "author_profile": "https://Stackoverflow.com/users/12226091", "pm_score": 0, "selected": false, "text": "div" }, { "answer_id": 74456238, "author": "Microtribute", "author_id": 3858559, "author_profile": "https://Stackoverflow.com/users/3858559", "pm_score": 0, "selected": false, "text": "h-100" }, { "answer_id": 74456273, "author": "Momin", "author_id": 4672474, "author_profile": "https://Stackoverflow.com/users/4672474", "pm_score": 0, "selected": false, "text": ".center {\n display: grid;\n place-items: center;\n min-height: 400px;\n}" }, { "answer_id": 74457728, "author": "Veljko03", "author_id": 20046454, "author_profile": "https://Stackoverflow.com/users/20046454", "pm_score": -1, "selected": false, "text": " width: 100px;\n height: 100px;\n\n position: absolute;\n top: 0;\n bottom: 0;\n left: 0;\n right: 0;\n\n margin: auto;\n" }, { "answer_id": 74458248, "author": "Praveen Impaxive", "author_id": 19282758, "author_profile": "https://Stackoverflow.com/users/19282758", "pm_score": -1, "selected": false, "text": "<div class=\"d-flex flex-column\" style=\"min-height: 100vh\">\n <div>Head</div>\n <div class=\"d-flex align-items-center justify-content-center\" style=\"flex: 100%\">\n <p>Content Here</p>\n </div>\n <div class=\"mt-auto\">Footer</div>\n</div>\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456174", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9008892/" ]
74,456,195
<p>We have an observable collection <code>SelectedPartys</code> if user interacts with the listview we add/remove in code behind.</p> <pre class="lang-xml prettyprint-override"><code>&lt;ListView x:Name=&quot;LV_Partys&quot; IsMultiSelectCheckBoxEnabled=&quot;True&quot; ItemsSource=&quot;{x:Bind ViewModel.PartysOC, UpdateSourceTrigger=PropertyChanged, Mode=TwoWay}&quot; SelectionChanged=&quot;LV_Partys_SelectionChanged&quot; SelectionMode=&quot;Extended&quot;&gt; &lt;ListView.ItemTemplate&gt; &lt;DataTemplate&gt; &lt;Grid Margin=&quot;0&quot;&gt; &lt;Grid.RowDefinitions&gt; &lt;RowDefinition Height=&quot;Auto&quot; /&gt; &lt;RowDefinition Height=&quot;Auto&quot; /&gt; &lt;/Grid.RowDefinitions&gt; &lt;StackPanel Grid.Row=&quot;0&quot; Orientation=&quot;Horizontal&quot;&gt; &lt;TextBlock Text=&quot;{Binding Name, UpdateSourceTrigger=PropertyChanged}&quot; TextWrapping=&quot;NoWrap&quot; /&gt; &lt;/StackPanel&gt; &lt;/Grid&gt; &lt;/DataTemplate&gt; &lt;/ListView.ItemTemplate&gt; &lt;/ListView&gt; </code></pre> <pre class="lang-cs prettyprint-override"><code>private ObservableCollection&lt;Party&gt; partysOC; public ObservableCollection&lt;Party&gt; PartysOC { get =&gt; partysOC; set =&gt; Set(ref partysOC, value); } private void LV_Partys_SelectionChanged(object sender, SelectionChangedEventArgs e) { var added_items = e.AddedItems.Cast&lt;Party&gt;().ToList(); foreach (var item in added_items) { ViewModel.SelectedPartys.Add(item); } var removed_items = e.RemovedItems.Cast&lt;Party&gt;().ToList(); foreach (var item in removed_items) { ViewModel.SelectedPartys.Remove(item); } ViewModel.SelectedPartyChanged(); } </code></pre> <p>We need to save the ListViews selected items in Db and then restore them <em><strong>pre-selected</strong></em> in the ListView, to do this I believe we need to select an item programatically, how can we do this?</p>
[ { "answer_id": 74457817, "author": "Andrew KeepCoding", "author_id": 2411960, "author_profile": "https://Stackoverflow.com/users/2411960", "pm_score": 2, "selected": true, "text": "SelectedItems" }, { "answer_id": 74460052, "author": "tinmac", "author_id": 425357, "author_profile": "https://Stackoverflow.com/users/425357", "pm_score": 0, "selected": false, "text": "YourListView.SelectRange()" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456195", "https://Stackoverflow.com", "https://Stackoverflow.com/users/425357/" ]
74,456,214
<p>I am using .NET MAUI app for migrating my xamarin.forms into .NET MAUI. I have problem which i have to view pdf file in .NET MAUI app or in .NET MAUI Page as i previously did in Xamarin.Forms. I was using SfPdfViewer in Xamarin.Forms and it was working fine. Kindly Help or guide please.</p> <p>I want to View Pdf file in .Net Maui page in mobile app.</p>
[ { "answer_id": 74457817, "author": "Andrew KeepCoding", "author_id": 2411960, "author_profile": "https://Stackoverflow.com/users/2411960", "pm_score": 2, "selected": true, "text": "SelectedItems" }, { "answer_id": 74460052, "author": "tinmac", "author_id": 425357, "author_profile": "https://Stackoverflow.com/users/425357", "pm_score": 0, "selected": false, "text": "YourListView.SelectRange()" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456214", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20517062/" ]
74,456,219
<p>I'm using Django as a framework, and I want to hide a column on mobile view with CSS.</p> <p>I use three different settings files: base, dev, and prod. All the main settings are in the base file and the only difference between the dev and prod settings - in what database I'm using (local Postgres and remote Postgres on Railway).</p> <p>I have my base.html file, where I load static files:</p> <pre><code>&lt;head&gt; &lt;meta charset=&quot;UTF-8&quot;&gt; &lt;title&gt;{{ title }}&lt;/title&gt; &lt;!-- Required meta tags --&gt; &lt;meta charset=&quot;utf-8&quot;&gt; &lt;meta name=&quot;viewport&quot; content=&quot;width=device-width, initial-scale=1, shrink-to-fit=no&quot;&gt; &lt;!-- Bootstrap CSS --&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;https://cdn.jsdelivr.net/npm/bootstrap@4.5.3/dist/css/bootstrap.min.css&quot; integrity=&quot;sha384-TX8t27EcRE3e/ihU7zmQxVncDAy5uIKz4rEkgIXeMed4M0jlfIDPvg6uqKI2xXr2&quot; crossorigin=&quot;anonymous&quot;&gt; &lt;link rel=&quot;stylesheet&quot; href=&quot;{% static 'main/css/base.css' %}&quot;&gt; &lt;link rel=&quot;shortcut icon&quot; type=&quot;image/png&quot; href=&quot;{% static 'main/img/favicon.ico' %}&quot;/&gt; </code></pre> <p>That's my project structure:</p> <p><a href="https://i.stack.imgur.com/9ZJLb.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9ZJLb.png" alt="enter image description here" /></a></p> <p>I want to hide a column on mobile view, so that's what I have in my base.css:</p> <pre><code>@media only screen and (max-width: 800px) { td:nth-child(1) { display:none; } th:nth-child(1) { display:none; } } </code></pre> <p>However, when I run the app using dev settings - everything works fine. When I run using prod - changes are not displayed. It seems that CSS file is not being read, but I'm wondering why if the code is the same - the difference is only in using different databases on different settings. I already did <code>collectstatic</code> with changes in CSS and pushed it to the server. But even when I run the app with prod settings locally - still the CSS is not taking into consideration.</p> <p>This is how I manage static files in my base settings:</p> <pre><code>STATIC_URL = '/static/' STATIC_ROOT = os.path.join(BASE_DIR, 'staticfiles') STATICFILES_DIRS = [ os.path.join(BASE_DIR), 'static' ] </code></pre>
[ { "answer_id": 74457817, "author": "Andrew KeepCoding", "author_id": 2411960, "author_profile": "https://Stackoverflow.com/users/2411960", "pm_score": 2, "selected": true, "text": "SelectedItems" }, { "answer_id": 74460052, "author": "tinmac", "author_id": 425357, "author_profile": "https://Stackoverflow.com/users/425357", "pm_score": 0, "selected": false, "text": "YourListView.SelectRange()" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456219", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1512250/" ]
74,456,221
<p>Edit : the solution given by simone works, but it is in javascript, and as I already coded everything else in jquery, I 'd love a jquery solution..</p> <p>I have a series of divs widht content to copy. Looking at different examples, I decide to put a div with the content to copy, and just after that a hidden copy button. I wrap everything in a div in relative position, so that I can put the button in absolute position in the top right corner, exactly like <a href="https://developer.mozilla.org/fr/docs/Web/CSS/cursor" rel="nofollow noreferrer">this example</a>.</p> <p>Here is an example of my code:</p> <pre><code>&lt;div class=&quot;token-block&quot;&gt; &lt;div class=&quot;token&quot; id=&quot;copy-1&quot;&gt;{{customText[&lt;span id=&quot;custom_wrapper&quot;&gt; &lt;span class=&quot;output&quot;&gt;&lt;/span&gt;&lt;span class=&quot;output&quot;&gt;&lt;/span&gt;&lt;/span&gt;]}}&lt;/div&gt; &lt;button type=&quot;button&quot; class=&quot;copy&quot; onclick=&quot;copy('#copy-1')&quot; aria-hidden=&quot;false&quot; aria-label=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Copy to Clipboard&lt;/span&gt;&lt;/button&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>The copy function works perfectly with this :</p> <pre><code>function copy(element) { var $temp = $(&quot;&lt;input&gt;&quot;); $(&quot;body&quot;).append($temp); $temp.val($(element).text()).select(); document.execCommand(&quot;copy&quot;); $temp.remove(); } </code></pre> <p>But I'd prefer to have a dynamic solution. So I add the wrapping div, the id and copy button dynamically.</p> <pre><code>$(function() { .... $('.token').wrap('&lt;div class=&quot;token-block&quot;&gt;&lt;/div&gt;'); $('.token').each(function(){ i=0; $(this).attr('id', 'token-'+i+''); $(this).append('&lt;button type=&quot;button&quot; class=&quot;copy&quot; onclick=&quot;copy(#copy-'+i+'&quot;)&quot; aria-hidden=&quot;false&quot; aria-label=&quot;Copy to clipboard&quot;&gt;&lt;span class=&quot;visually-hidden&quot;&gt;Copy to Clipboard&lt;/span&gt;&lt;/button&gt;'); i++; }); }); function copy(element) { var $temp = $(&quot;&lt;input&gt;&quot;); $(&quot;body&quot;).append($temp); $temp.val($(element).text()).select(); document.execCommand(&quot;copy&quot;); $temp.remove(); } </code></pre> <p>It doen't work..So What is wrong here ? the code when I inspect the element is exactly the same in the html, but if I do it dynamicaly, it doesn't work anymore..</p> <p>can someone help please ??</p>
[ { "answer_id": 74456608, "author": "Simone Rossaini", "author_id": 12402732, "author_profile": "https://Stackoverflow.com/users/12402732", "pm_score": -1, "selected": false, "text": "function copy(div) {\n navigator.clipboard.writeText(div.innerText).then(\n function() {\n //if function work done work\n alert('copy done by clipboard');\n },\n function() {\n //if fail cliboard use execCommand\n const inputTemp = document.createElement(\"input\");\n inputTemp.setAttribute(\"value\", div.innerText);\n document.body.appendChild(inputTemp);\n inputTemp.select();\n document.execCommand(\"copy\");\n document.body.removeChild(inputTemp);\n alert('copy done by execCommand');\n }\n )\n}" }, { "answer_id": 74527646, "author": "blogob", "author_id": 4455763, "author_profile": "https://Stackoverflow.com/users/4455763", "pm_score": 1, "selected": true, "text": "$('.token').wrap('<div class=\"token-block\"></div>');\n \n $('.token-block').each(function(){\n \n $(this).append('<button type=\"button\" class=\"copy\" onclick=\"copy(this)\" aria-hidden=\"false\" aria-label=\"Copy to clipboard\"><span class=\"visually-hidden\">Copy to Clipboard</span></button>');\n \n }); \n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456221", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4455763/" ]
74,456,223
<p>i am working with a piece of code that have a StringBuilder where i will do an append of some data and then send an email with all the data. Here is the code:</p> <pre><code>StringBuilder stringBuild= new StringBuilder(); for (int i = 0; i &lt; variable.size(); i++) { //Unknown size, could be quite big stringBuild.append(thingsToDO((Map&lt;String, Object&gt;) variable.get(i))); } sendEmail(stringBuild); /** * @param stringBuild */ private void enviarEmail(StringBuilder stringBuild) { if(StringUtils.isNotBlank(stringBuild)) { //Email OK } else { //Email with all errors } } </code></pre> <p>Is okay to use the StringUtils library for StringBuilders or there are better methods to work with StringBuilders?</p> <p>I don´t have that much experience with StringBuilders so maybe i am missing something, any help is appreciated</p>
[ { "answer_id": 74456608, "author": "Simone Rossaini", "author_id": 12402732, "author_profile": "https://Stackoverflow.com/users/12402732", "pm_score": -1, "selected": false, "text": "function copy(div) {\n navigator.clipboard.writeText(div.innerText).then(\n function() {\n //if function work done work\n alert('copy done by clipboard');\n },\n function() {\n //if fail cliboard use execCommand\n const inputTemp = document.createElement(\"input\");\n inputTemp.setAttribute(\"value\", div.innerText);\n document.body.appendChild(inputTemp);\n inputTemp.select();\n document.execCommand(\"copy\");\n document.body.removeChild(inputTemp);\n alert('copy done by execCommand');\n }\n )\n}" }, { "answer_id": 74527646, "author": "blogob", "author_id": 4455763, "author_profile": "https://Stackoverflow.com/users/4455763", "pm_score": 1, "selected": true, "text": "$('.token').wrap('<div class=\"token-block\"></div>');\n \n $('.token-block').each(function(){\n \n $(this).append('<button type=\"button\" class=\"copy\" onclick=\"copy(this)\" aria-hidden=\"false\" aria-label=\"Copy to clipboard\"><span class=\"visually-hidden\">Copy to Clipboard</span></button>');\n \n }); \n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456223", "https://Stackoverflow.com", "https://Stackoverflow.com/users/12631570/" ]
74,456,249
<p>So I have two divs inside a parent div. Something like</p> <pre><code> &lt;div className='parent'&gt; &lt;div className='child1'&gt; &lt;div className='child2'&gt; &lt;/div&gt; </code></pre> <p>I want to achieve something like this <a href="https://i.stack.imgur.com/sQTlr.png" rel="nofollow noreferrer">Sample</a>. How can I add padding only for child2 and not child1. Or is there any other way to do it.</p>
[ { "answer_id": 74456406, "author": "ray", "author_id": 636077, "author_profile": "https://Stackoverflow.com/users/636077", "pm_score": 1, "selected": false, "text": ".child2" }, { "answer_id": 74457329, "author": "Mahdi", "author_id": 15182863, "author_profile": "https://Stackoverflow.com/users/15182863", "pm_score": 0, "selected": false, "text": "<div>1</div>\n<div>2</div>\n<div id=\"div3\">3</div>\n<div>4</div>\n" }, { "answer_id": 74457766, "author": "Niroj Luitel", "author_id": 7239971, "author_profile": "https://Stackoverflow.com/users/7239971", "pm_score": 1, "selected": false, "text": ".parent .child:nth-child(2){padding: 10px;}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456249", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19501310/" ]
74,456,260
<p>I'm trying to update state inside a nested array with a map function and spread operator, but i don't understand how to get the key in the key/value pair to select a nested object .</p> <p>In below code, when i try to implement multiple selection but i acheive only single selection in innerarray1 and how to update innerarray1 with original data using state, i try .. but not work can any one pls help how to multiselection data ?</p> <p>I want multiple time circle selected when i click see below image it might have an idea i try to implement see below code , but i am stuck at a point , please help?</p> <p><a href="https://i.stack.imgur.com/i0aNt.jpg" rel="nofollow noreferrer">enter image description here</a></p> <pre><code>const [Data, setData] = useState([ { id: 0, title: ' Cycling', Days: '3 Days completed', innerArray: [ { id: 1, name: 'MON', image: require('../../../../assets/Images/rightWhite.png'), isselected: false, }, { id: 2, name: 'TUE', image: require('../../../../assets/Images/rightWhite.png'), isselected: false, }, { id: 3, name: 'WED', image: require('../../../../assets/Images/rightWhite.png'), isselected: false, }, { id: 4, name: 'THU', image: require('../../../../assets/Images/rightWhite.png'), isselected: false, }, { id: 5, name: 'FRI', image: require('../../../../assets/Images/rightWhite.png'), isselected: false, }, { id: 6, name: 'SAT', image: require('../../../../assets/Images/rightWhite.png'), isselected: false, }, { id: 7, name: 'SUN', image: require('../../../../assets/Images/rightWhite.png'), isselected: false, }, ], }, { id: 1, title: ' Bath', Days: '4 days compelted', innerArray: [], }, ]); const onClick = (innerData, item) =&gt; { //i am stuck in this section let data1 = Data.map((val) =&gt; { if (val.id == item.id) { let innerarray1 = val.innerArray.map((value) =&gt; { // console.log(&quot;innervalue is====&gt;&quot;,value) if (value.id == innerData.id) { return { ...value, isselected: !value.isselected }; } else { return { ...value }; } }); // console.log(&quot;inner arrayData is====&quot;, innerarray1); } else { return { val }; } }); }; &lt;View&gt; &lt;FlatList data={Data} style={{ marginBottom: 200 }} renderItem={({ item }) =&gt; ( &lt;View&gt; &lt;View style={{ height: hp('2%') }}&gt;&lt;/View&gt; &lt;View style={{ height: hp('17%'), width: wp('80%'), }} &gt; &lt;View style={{ height: hp('5%'), width: wp('70%'), flexDirection: 'row', alignSelf: 'center', }} &gt; &lt;View style={{ height: hp('5%'), width: wp('30%'), justifyContent: 'center', }} &gt; &lt;Text&gt;{item.title}&lt;/Text&gt; &lt;/View&gt; &lt;View style={{ height: hp('5%'), width: wp('40%'), justifyContent: 'center', }} &gt; &lt;Text&gt;{item.Days}&lt;/Text&gt; &lt;/View&gt; &lt;/View&gt; &lt;FlatList data={item.innerArray} horizontal={true} showsHorizontalScrollIndicator={false} showsVerticalScrollIndicator={false} style={{ marginTop: 10, marginLeft: wp('2%') }} renderItem={({ item: innerData, index }) =&gt; ( // {selectedData(innerData)} &lt;View style={{ height: hp('10%'), justifyContent: 'space-between', width: wp('12%'), }} &gt; &lt;View style={{ height: hp('4%') }}&gt; &lt;Text&gt;{innerData.name}&lt;/Text&gt; &lt;/View&gt; &lt;TouchableOpacity style={styles.circleView1} onPress={() =&gt; { // onSelect(innerData , item) onClick(innerData, item); }} &gt; &lt;Text&gt;&lt;/Text&gt; &lt;/TouchableOpacity&gt; &lt;/View&gt; )} /&gt; &lt;/View&gt; &lt;/View&gt; )} /&gt; &lt;/View&gt;; </code></pre> <p>I'm trying to update state inside a nested array with a map function and spread operator, but i don't understand how to get the key in the key/value pair to select a nested object .</p>
[ { "answer_id": 74456406, "author": "ray", "author_id": 636077, "author_profile": "https://Stackoverflow.com/users/636077", "pm_score": 1, "selected": false, "text": ".child2" }, { "answer_id": 74457329, "author": "Mahdi", "author_id": 15182863, "author_profile": "https://Stackoverflow.com/users/15182863", "pm_score": 0, "selected": false, "text": "<div>1</div>\n<div>2</div>\n<div id=\"div3\">3</div>\n<div>4</div>\n" }, { "answer_id": 74457766, "author": "Niroj Luitel", "author_id": 7239971, "author_profile": "https://Stackoverflow.com/users/7239971", "pm_score": 1, "selected": false, "text": ".parent .child:nth-child(2){padding: 10px;}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456260", "https://Stackoverflow.com", "https://Stackoverflow.com/users/-1/" ]
74,456,277
<p>I trying to drop two rows from a CSV file and after exploring other similar questions I have not been able to figure it out still. I have tried using pandas and it does not seem to be working and I tried a few functions that people on here said worked for them but I could not get to work.</p> <p>Here is my code I've ben trying. My output is unchanged with and without trying to drop the two rows. <img src="https://i.stack.imgur.com/zH6DX.png"> The rows I'm trying to drop are the United States and Iowa State rows.</p> <pre class="lang-py prettyprint-override"><code>import csv import pandas as pd iowa_csv = r'C:\Users\Downloads\Iowa 2010 Census Data Population Income.csv' with open(iowa_csv, encoding='utf-8-sig') as csvfile: reader = csv.DictReader(csvfile) county_col = {'County': []} for record in reader: county_col['County'].append(record['County']) print(county_col) df = pd.read_csv(r'C:\Users\Downloads\Iowa 2010 Census Data Population Income.csv') df.drop([9, 20]) print(df) </code></pre>
[ { "answer_id": 74456406, "author": "ray", "author_id": 636077, "author_profile": "https://Stackoverflow.com/users/636077", "pm_score": 1, "selected": false, "text": ".child2" }, { "answer_id": 74457329, "author": "Mahdi", "author_id": 15182863, "author_profile": "https://Stackoverflow.com/users/15182863", "pm_score": 0, "selected": false, "text": "<div>1</div>\n<div>2</div>\n<div id=\"div3\">3</div>\n<div>4</div>\n" }, { "answer_id": 74457766, "author": "Niroj Luitel", "author_id": 7239971, "author_profile": "https://Stackoverflow.com/users/7239971", "pm_score": 1, "selected": false, "text": ".parent .child:nth-child(2){padding: 10px;}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456277", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20352112/" ]
74,456,293
<p>i have implement a List from api and it gives me actual response which is working fine. but when i implemented a list search on it. Then the list doesn't show up when i open that screen. but when i start searching it gives me the correct search results.</p> <p>here is my code:</p> <pre><code> import 'dart:convert'; import 'package:fb_installer_phase1/api/controller/user_auth_controller.dart'; import 'package:fb_installer_phase1/api/model/technician.dart'; import 'package:fb_installer_phase1/views/user_management/add_user_screen.dart'; import 'package:flutter/material.dart'; import 'package:flutter/services.dart'; import 'package:flutter_screenutil/flutter_screenutil.dart'; import 'package:get/get.dart'; import 'package:http/http.dart' as http; import 'package:shared_preferences/shared_preferences.dart'; import '../../api/network_calls/api_configration.dart'; import '../../utils/app_constants.dart'; import '../../utils/color_resourse.dart'; class UserListScreen extends StatefulWidget { const UserListScreen({Key? key}) : super(key: key); @override State&lt;UserListScreen&gt; createState() =&gt; _UserListScreenState(); } class _UserListScreenState extends State&lt;UserListScreen&gt; { final TextEditingController searchController = TextEditingController(); String keyword = ''; bool isDataLoading = false; List&lt;TechData&gt; _technicians = &lt;TechData&gt;[]; List&lt;TechData&gt; _techniciansList = &lt;TechData&gt;[]; Future getData() async { SharedPreferences preferences = await SharedPreferences.getInstance(); bearerToken = preferences.getString(AppConstants.appToken)!; String url = AppConstants.baseUrl + AppConstants.allTechnicianListApi; try { final response = await http.get(Uri.parse(url), headers: { 'Content-Type': 'application/json', 'Accept': 'application/json', 'Authorization': 'Bearer $bearerToken', }); debugPrint(&quot;Token: $bearerToken&quot;); debugPrint(&quot;Response::: ${response.body}&quot;); TechnicianModel model = TechnicianModel.fromJson( jsonDecode(response.body)); _technicians = model.data!; setState(() { isDataLoading = false; isDataLoading = !isDataLoading; }); print(&quot;hello...: ${_technicians.length}&quot;); } catch (exception) { print(exception); } } @override void initState() { getAllTechniciansData(); getData(); super.initState(); } @override Widget build(BuildContext context) { return Scaffold( floatingActionButton: FloatingActionButton( backgroundColor: ColorResources.primaryColor, child: Center( child: Icon( Icons.add, size: 25.h, ), ), onPressed: () { Get.to(() =&gt; const AddUserScreen()); }, ), appBar: AppBar( flexibleSpace: Container( decoration: const BoxDecoration( gradient: LinearGradient( begin: Alignment.centerLeft, end: Alignment.centerRight, stops: [ 0.2, 0.7, 1, ], colors: [ Color(0XFF3DDA76), Color(0XFF6DD2D1), Color(0XFF41B1A1), ], )), ), centerTitle: true, backgroundColor: ColorResources.primaryColor, title: const Text(&quot;User List&quot;), systemOverlayStyle: SystemUiOverlayStyle.light, ), body: Column( children: [ SizedBox( height: 20.h, ), _createSearchbar(), SizedBox( height: 15.h, ), Container( width: double.infinity, margin: EdgeInsets.symmetric(horizontal: 15.w), height: 35.h, color: const Color(0xffF2F2F2), child: Row( children: [ Container( width: 80.w, height: double.infinity, color: Colors.transparent, alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: 10.w), child: Text( &quot;Name&quot;, style: TextStyle( color: Colors.black, fontWeight: FontWeight.w600, fontSize: 12.sp), ), ), Container( width: 170.w, height: double.infinity, color: Colors.transparent, alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: 10.w), child: Text( &quot;Email&quot;, style: TextStyle( color: Colors.black, fontWeight: FontWeight.w600, fontSize: 12.sp), ), ), Container( height: double.infinity, color: Colors.transparent, alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: 10.w), child: Text( &quot;App Status&quot;, style: TextStyle( color: Colors.black, fontWeight: FontWeight.w600, fontSize: 12.sp), ), ) ], ), ), _userListView(), ], ), ); } @override void dispose() { super.dispose(); FocusScope.of(context).unfocus(); } Container _createSearchbar() { return Container( height: 50.h, margin: EdgeInsets.symmetric(horizontal: 15.w), decoration: BoxDecoration( borderRadius: BorderRadius.circular(10), color: Colors.white, border: Border.all(color: ColorResources.grey300)), child: Row( children: [ SizedBox( height: 50.h, width: 40.h, child: const Center( child: Icon( Icons.search, color: ColorResources.primaryColor, ), ), ), Expanded( child: TextField( decoration: InputDecoration( border: InputBorder.none, focusedBorder: InputBorder.none, enabledBorder: InputBorder.none, errorBorder: InputBorder.none, disabledBorder: InputBorder.none, contentPadding: EdgeInsets.only(left: 15.w, bottom: 11.h, top: 11, right: 15), hintText: &quot;Search here&quot;, ), onChanged: searchTechnicians, )), ], ), ); } TextEditingController controller = TextEditingController(); Widget _userListView() { return isDataLoading || _techniciansList.isNotEmpty || controller.text.isNotEmpty ? Expanded(child: ListView.builder( itemCount: _techniciansList.length , itemBuilder: (context, index) { if (_techniciansList.isNotEmpty) { return Container( margin: EdgeInsets.symmetric(horizontal: 15.w), height: 32.h, //color: const Color(0xffF2F2F2), child: Row( children: [ Container( width: 80.w, height: double.infinity, color: Colors.transparent, alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: 10.w), child: Text( _techniciansList[index].name!, style: TextStyle( color: Colors.black, fontWeight: FontWeight.w400, overflow: TextOverflow.ellipsis, fontSize: 11.sp), ), ), Container( width: 170.w, height: double.infinity, color: Colors.transparent, alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: 10.w), child: Text( _techniciansList[index].email!, overflow: TextOverflow.ellipsis, maxLines: 2, style: TextStyle( color: Colors.black, fontWeight: FontWeight.w400, fontSize: 11.sp), ), ), Expanded( child: Container( height: double.infinity, color: Colors.transparent, alignment: Alignment.centerLeft, padding: EdgeInsets.only(left: 5.w), child: Text( _techniciansList[index].phone! ?? '', style: TextStyle( color: Colors.black, overflow: TextOverflow.ellipsis, fontWeight: FontWeight.w400, fontSize: 11.sp), ), ), ) ], ), ); } else { return const SizedBox(); } } )) : const Expanded( child: Center(child: CircularProgressIndicator( color: ColorResources.primaryColor,)), ); } searchTechnicians(String text) { _techniciansList.clear(); if (text.isEmpty) { setState(() { }); return; } _technicians.forEach((element) { if (element.name!.contains(text) || element.email!.contains(text) || element.phone!.contains(text)) { _techniciansList.add(element); } }); print(&quot;searchresults: ${_techniciansList.length}&quot;); setState(() { }); } } </code></pre>
[ { "answer_id": 74456406, "author": "ray", "author_id": 636077, "author_profile": "https://Stackoverflow.com/users/636077", "pm_score": 1, "selected": false, "text": ".child2" }, { "answer_id": 74457329, "author": "Mahdi", "author_id": 15182863, "author_profile": "https://Stackoverflow.com/users/15182863", "pm_score": 0, "selected": false, "text": "<div>1</div>\n<div>2</div>\n<div id=\"div3\">3</div>\n<div>4</div>\n" }, { "answer_id": 74457766, "author": "Niroj Luitel", "author_id": 7239971, "author_profile": "https://Stackoverflow.com/users/7239971", "pm_score": 1, "selected": false, "text": ".parent .child:nth-child(2){padding: 10px;}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456293", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13628530/" ]
74,456,300
<p>I am taking timestamp from the user like this</p> <pre><code>2015-05-28T17:00:00 </code></pre> <p>And a timezone <code>&quot;America/Los_Angeles&quot;</code> Now I want convert the date into something like</p> <pre><code>2015-05-28T17:00:00-07:00 </code></pre> <p>Is that possible in go ,Please help me out in this ,if you have any links which you can share</p>
[ { "answer_id": 74456406, "author": "ray", "author_id": 636077, "author_profile": "https://Stackoverflow.com/users/636077", "pm_score": 1, "selected": false, "text": ".child2" }, { "answer_id": 74457329, "author": "Mahdi", "author_id": 15182863, "author_profile": "https://Stackoverflow.com/users/15182863", "pm_score": 0, "selected": false, "text": "<div>1</div>\n<div>2</div>\n<div id=\"div3\">3</div>\n<div>4</div>\n" }, { "answer_id": 74457766, "author": "Niroj Luitel", "author_id": 7239971, "author_profile": "https://Stackoverflow.com/users/7239971", "pm_score": 1, "selected": false, "text": ".parent .child:nth-child(2){padding: 10px;}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456300", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10254670/" ]
74,456,363
<p>I am trying to fix the corner icons to the bottom of the screen regardless the expansion of the text area. I tried with <code>position=absolute and bottom = 0</code> but it got hidden behind my <code>textArea</code>.</p> <p>Here is what it looks like right now:</p> <p><a href="https://i.stack.imgur.com/uWB0F.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/uWB0F.png" alt="enter image description here" /></a></p> <p><strong>This is what I want.</strong></p> <p><a href="https://i.stack.imgur.com/RI7em.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/RI7em.png" alt="enter image description here" /></a></p> <p>I just need to fix send and add image icon to the bottom corners of the screen. Please guide me how i can achieve that.</p> <p><strong>Here my styleSheet</strong> :</p> <pre><code>StyleSheet.create({ containerStyle: { ...shadowStyle, minHeight: 72, width: &quot;100%&quot;, paddingHorizontal: Spacing.m, alignItems: &quot;flex-end&quot;, flexDirection: &quot;row&quot;, padding: 10, borderTopLeftRadius: Spacing.s, borderTopRightRadius: Spacing.s, backgroundColor: colors.gray10, }, textImageWrapper: { width: &quot;79%&quot;, borderRadius: Radius.s, backgroundColor: colors.white, }, inputStyleShort: { ...Typography.callout, flexWrap: &quot;wrap&quot;, minHeight: 40, paddingLeft: Spacing.m, borderRadius: Radius.s, backgroundColor: colors.white, }, inputStyle: { ...Typography.callout, flexWrap: &quot;wrap&quot;, height: 40, borderRadius: Radius.s, paddingLeft: Spacing.m, paddingTop: 11, }, submitButton: { backgroundColor: colors.green25, flexDirection: &quot;row&quot;, justifyContent: &quot;center&quot;, alignItems: &quot;center&quot;, marginLeft: Spacing.s, width: 40, height: 40, borderRadius: Radius.s, }, addImageButton: { width: &quot;8%&quot;, height: Spacing.l, flexDirection: &quot;row&quot;, alignItems: &quot;center&quot;, }, </code></pre> <p><strong>Here is my design code</strong> :</p> <pre><code> const calculateImageContainer = selectedImage.length ? { height: 280 } : { alignItems: &quot;center&quot; }; return ( &lt;View style={[getStyle.containerStyle, calculateImageContainer]}&gt; &lt;TouchableOpacity style={getStyle.addImageButton} onPress={() =&gt; setImageSelectionVisible(true)} &gt; {renderSvgIcon(&quot;addPicture&quot;, colors.gray90, null, null)} &lt;/TouchableOpacity&gt; &lt;View style={getStyle.textImageWrapper}&gt; &lt;TextInput ref={inputRef} value={inputValue} style={inputValue.length ? getStyle.inputStyleShort : getStyle.inputStyle} placeholder={placeholder || i18n.t(&quot;community.writeComment&quot;)} placeholderTextColor=&quot;gray&quot; multiline textAlignVertical=&quot;top&quot; onChangeText={onChange} maxLength={maxLength || 500} /&gt; {selectedImage?.length ? ( &lt;ImagesLayout path=&quot;AvyCommentLinearInput&quot; images={selectedImage} handleRemoveImagePress={removeImage} /&gt; ) : null} &lt;/View&gt; &lt;TouchableOpacity onPress={onPressSubmit} style={getStyle.submitButton}&gt; {renderSvgIcon(&quot;message_send_icon&quot;, colors.white, IconSize.m, IconSize.m)} &lt;/TouchableOpacity&gt; &lt;ImageSelectionMethod isVisible={isImageSelectionVisible} onClose={() =&gt; setImageSelectionVisible(false)} onCameraPicker={showCamera} onImagePicker={showPhotoGalleryPicker} /&gt; &lt;/View&gt; </code></pre>
[ { "answer_id": 74456406, "author": "ray", "author_id": 636077, "author_profile": "https://Stackoverflow.com/users/636077", "pm_score": 1, "selected": false, "text": ".child2" }, { "answer_id": 74457329, "author": "Mahdi", "author_id": 15182863, "author_profile": "https://Stackoverflow.com/users/15182863", "pm_score": 0, "selected": false, "text": "<div>1</div>\n<div>2</div>\n<div id=\"div3\">3</div>\n<div>4</div>\n" }, { "answer_id": 74457766, "author": "Niroj Luitel", "author_id": 7239971, "author_profile": "https://Stackoverflow.com/users/7239971", "pm_score": 1, "selected": false, "text": ".parent .child:nth-child(2){padding: 10px;}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456363", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4758413/" ]
74,456,378
<p>I'm trying to create and visualize graph using cytoscape js</p> <p>I have two files:</p> <p>index.html input.html</p> <p>index.html includes the following</p> <pre><code>&lt;head&gt; &lt;title&gt;Tutorial 1: Getting Started&lt;/title&gt; &lt;script src=&quot;https://cdnjs.cloudflare.com/ajax/libs/cytoscape/2.7.10/cytoscape.js&quot;&gt;&lt;/script&gt; &lt;/head&gt; &lt;style&gt; #cy { width: 100%; height: 100%; position: absolute; top: 0px; left: 0px; } &lt;/style&gt; &lt;body&gt; &lt;div id=&quot;cy&quot;&gt;&lt;/div&gt; &lt;script&gt; $.getJSON(&quot;input.js&quot;, function (data) { var cy = cytoscape({ elements: data, container: document.getElementById('cy'), style: [ { selector: 'node', style: { shape: 'hexagon', 'background-color': 'red', label: 'data(id)' } }], layout: { name: 'grid' }, }); }); &lt;/script&gt; &lt;/body&gt; </code></pre> <p>input.js includes the following</p> <pre><code> [ // nodes { data: { id: 'a' } }, { data: { id: 'b' } }, { data: { id: 'c' } }, { data: { id: 'd' } }, { data: { id: 'e' } }, { data: { id: 'f' } }, // edges { data: { id: 'ab', source: 'a', target: 'b' } }, { data: { id: 'cd', source: 'c', target: 'd' } }, { data: { id: 'ef', source: 'e', target: 'f' } }, { data: { id: 'ac', source: 'a', target: 'd' } }, { data: { id: 'be', source: 'b', target: 'e' } } ] </code></pre> <p>But I see only an empty file when I open index.html in a browser.</p> <p>Could someone please help me with this?</p> <p>EDIT: I have worked on the changes mentioned in the answer below <a href="https://github.com/DeepaMahm/misc/blob/master/index.html" rel="nofollow noreferrer">https://github.com/DeepaMahm/misc/blob/master/index.html</a> <a href="https://github.com/DeepaMahm/misc/blob/master/input.js" rel="nofollow noreferrer">https://github.com/DeepaMahm/misc/blob/master/input.js</a></p> <p>but I am still not able to view the graph by opening the index.html.</p>
[ { "answer_id": 74456406, "author": "ray", "author_id": 636077, "author_profile": "https://Stackoverflow.com/users/636077", "pm_score": 1, "selected": false, "text": ".child2" }, { "answer_id": 74457329, "author": "Mahdi", "author_id": 15182863, "author_profile": "https://Stackoverflow.com/users/15182863", "pm_score": 0, "selected": false, "text": "<div>1</div>\n<div>2</div>\n<div id=\"div3\">3</div>\n<div>4</div>\n" }, { "answer_id": 74457766, "author": "Niroj Luitel", "author_id": 7239971, "author_profile": "https://Stackoverflow.com/users/7239971", "pm_score": 1, "selected": false, "text": ".parent .child:nth-child(2){padding: 10px;}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456378", "https://Stackoverflow.com", "https://Stackoverflow.com/users/8281509/" ]
74,456,398
<p>I want to create a box for pros and cons just like Life Hacker which looks like this:</p> <p><a href="https://i.stack.imgur.com/8jVl9.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/8jVl9.png" alt="enter image description here" /></a></p> <p>As a beginner in HTML CSS, I started and so far, I have this:</p> <p><a href="https://i.stack.imgur.com/d9lQS.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/d9lQS.png" alt="enter image description here" /></a></p> <p>As can see there is too much overlapping. How do I fix this? Also, I would like to align the text with the list.</p> <p>HTML:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>.indent-1 { float: left; border: 2px solid orange; border-radius: 5px; padding-right: 10px; padding-left: 10px; } .indent-1 section { float: left; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;section class="indent-1"&gt; &lt;section&gt; &lt;h3&gt;What we like:&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;Pro 1&lt;/li&gt; &lt;li&gt;Pro 2&lt;/li&gt; &lt;li&gt;Pro 3&lt;/li&gt; &lt;/ul&gt; &lt;/section&gt; &lt;section&gt; &lt;h3&gt;What we don't like:&lt;/h3&gt; &lt;ul&gt; &lt;li&gt;Con 1&lt;/li&gt; &lt;li&gt;Con 2&lt;/li&gt; &lt;li&gt;Con 3&lt;/li&gt; &lt;/ul&gt; &lt;/section&gt; &lt;/section&gt;</code></pre> </div> </div> </p> <p>Any more suggestions to make it look pretty will be welcomed.</p> <p>Thanks</p>
[ { "answer_id": 74457258, "author": "Adam", "author_id": 12571484, "author_profile": "https://Stackoverflow.com/users/12571484", "pm_score": 3, "selected": true, "text": ".indent-1 {\n display: inline-grid;\n grid-template-columns: 1fr 1fr;\n border: 2px solid orange;\n border-radius: 5px;\n padding-right: 10px;\n padding-left: 10px;\n}" }, { "answer_id": 74457575, "author": "Salwa A. Soliman", "author_id": 18270700, "author_profile": "https://Stackoverflow.com/users/18270700", "pm_score": 1, "selected": false, "text": ".indent-1 {\n display: flex;\n justify-content: space-between;\n border: 2px solid orangered;\n border-radius: 5px;\n padding: 10px 20px;\n}" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456398", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6304394/" ]
74,456,437
<p>I have a list format as shown below.</p> <pre><code>stripped_list=['WLH1', 'GWJ1', 'AV11', 'UBN1'] </code></pre> <p>I want to remove trailing 1's at the end but if i am using below code</p> <pre><code>stripped_list2 = [[item.replace('1', '') for item in z] for z in stripped_list] </code></pre> <p>it is stripping AV11 to AV only but i need AV1.</p> <p>How to solve this?</p> <p>I have a list format as shown below.</p> <pre><code>stripped_list=['WLH1', 'GWJ1', 'AV11', 'UBN1'] </code></pre> <p>I want to remove trailing 1's at the end but if i am using below code</p> <pre><code>stripped_list2 = [[item.replace('1', '') for item in z] for z in stripped_list] </code></pre> <p>it is stripping AV11 to AV only but i need AV1.</p> <p>How to solve this?</p>
[ { "answer_id": 74456466, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 1, "selected": false, "text": "re.sub" }, { "answer_id": 74456470, "author": "Wanderer", "author_id": 7631183, "author_profile": "https://Stackoverflow.com/users/7631183", "pm_score": 0, "selected": false, "text": "#assuming 1 is always at the end:" }, { "answer_id": 74456485, "author": "uozcan12", "author_id": 5226470, "author_profile": "https://Stackoverflow.com/users/5226470", "pm_score": 0, "selected": false, "text": "s = [i[:len(stripped_list)-1] for i in stripped_list]\n" }, { "answer_id": 74456489, "author": "Jay", "author_id": 8677071, "author_profile": "https://Stackoverflow.com/users/8677071", "pm_score": 1, "selected": false, "text": "1" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456437", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10945224/" ]
74,456,447
<p>My flutter app was working fine for android and for iOS the build was failing.</p> <p>My pod file code was</p> <pre><code>post_install do |installer| installer.pods_project.targets.each do |target| target.build_configurations.each do |config| config.build_settings['IPHONEOS_DEPLOYMENT_TARGET'] = '14.0' end end end </code></pre> <p><a href="https://i.stack.imgur.com/fPQNY.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fPQNY.jpg" alt="enter image description here" /></a></p>
[ { "answer_id": 74456466, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 1, "selected": false, "text": "re.sub" }, { "answer_id": 74456470, "author": "Wanderer", "author_id": 7631183, "author_profile": "https://Stackoverflow.com/users/7631183", "pm_score": 0, "selected": false, "text": "#assuming 1 is always at the end:" }, { "answer_id": 74456485, "author": "uozcan12", "author_id": 5226470, "author_profile": "https://Stackoverflow.com/users/5226470", "pm_score": 0, "selected": false, "text": "s = [i[:len(stripped_list)-1] for i in stripped_list]\n" }, { "answer_id": 74456489, "author": "Jay", "author_id": 8677071, "author_profile": "https://Stackoverflow.com/users/8677071", "pm_score": 1, "selected": false, "text": "1" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456447", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11925795/" ]
74,456,461
<p>for large data selection (1000 + cells) below query is not working but for small it's working. Excel stopped working unless i press escape.</p> <pre><code>Sub TrimReplaceAndUppercase() For Each cell In Selection If Not cell.HasFormula Then cell.Value = UCase(cell.Value) cell = Trim(cell) Selection.Replace What:=&quot;-&quot;, Replacement:=&quot;&quot;, LookAt:=xlPart, _ SearchOrder:=xlByRows, MatchCase:=False, SearchFormat:=False, _ ReplaceFormat:=False End If Next cell End Sub </code></pre>
[ { "answer_id": 74456567, "author": "Pᴇʜ", "author_id": 3219613, "author_profile": "https://Stackoverflow.com/users/3219613", "pm_score": 4, "selected": true, "text": "replace()" }, { "answer_id": 74456975, "author": "Siddharth Rout", "author_id": 1140579, "author_profile": "https://Stackoverflow.com/users/1140579", "pm_score": 2, "selected": false, "text": "Selection" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456461", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9395425/" ]
74,456,465
<pre><code>this.form = this.formBuilder.group({ kWhControl: [false, []], kWhValue: [0, []], identified: this.formBuilder.group({ kWhControl: [false, []], kWhValue: [0, []], }), )}; </code></pre> <p>Tried multiple ways but coudn't get what exatly is the right way to do this.</p>
[ { "answer_id": 74456567, "author": "Pᴇʜ", "author_id": 3219613, "author_profile": "https://Stackoverflow.com/users/3219613", "pm_score": 4, "selected": true, "text": "replace()" }, { "answer_id": 74456975, "author": "Siddharth Rout", "author_id": 1140579, "author_profile": "https://Stackoverflow.com/users/1140579", "pm_score": 2, "selected": false, "text": "Selection" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456465", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20517289/" ]
74,456,469
<p>I have a list of string that I need to pass to an sql query.</p> <pre><code> listofinput = [] for i in input: listofinput.append(i) if(len(listofinput)&gt;1): listofinput = format(tuple(listofinput)) </code></pre> <pre><code>sql_query = f&quot;&quot;&quot;SELECT * FROM countries where name in {listofinput}; &quot;&quot;&quot; </code></pre> <p>This works when I have a list, but in case of just one value it fails.</p> <pre><code>as listofinput = ['USA'] for one value but listofinput ('USA', 'Germany') for multiple </code></pre> <p>also I need to do this for thousands of input, what is the best optimized way to achieve the same. name in my table countries is an indexed column</p>
[ { "answer_id": 74456567, "author": "Pᴇʜ", "author_id": 3219613, "author_profile": "https://Stackoverflow.com/users/3219613", "pm_score": 4, "selected": true, "text": "replace()" }, { "answer_id": 74456975, "author": "Siddharth Rout", "author_id": 1140579, "author_profile": "https://Stackoverflow.com/users/1140579", "pm_score": 2, "selected": false, "text": "Selection" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456469", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11402025/" ]
74,456,518
<p>I have this <strong>DropdownMenu</strong> component that works just fine. Basically, if you click on <strong>&quot;Click me&quot;</strong> button you'll see a DropdownMenu then if you either click <strong>outside</strong> the DropdownMenu or <strong>select an option</strong> by clicking on it the Dropdown disappears and this is expected.</p> <p>My issue is that I want to be able to toggle the Dropdown Menu <strong>when clicking on &quot;Click me&quot;</strong> button, as of right now if I click on &quot;Click me&quot; button the menu shows up, then if I click again on &quot;Click me&quot; button the DropdownMenu won't go away (I want to toggle it). Can anyone point me in the right direction and tell me what I'm missing or need to do please? Thanks a lot in advance!</p> <p>Here's a <a href="https://codesandbox.io/s/dreamy-flower-qon9ou?file=/DropdownMenu.tsx" rel="nofollow noreferrer"><strong>LIVE DEMO</strong></a> of my code, and here are the 2 functions that handle the <strong>toggle</strong> for my DropdownMenu and handle the <strong>ClickOutside</strong>.</p> <pre><code>const handleToggle = () =&gt; setOpen((isOpen) =&gt; !isOpen); const handleClickOutside = (evt: MouseEvent) =&gt; !menuListRef?.current?.contains(evt.target as HTMLElement) &amp;&amp; setOpen(false); </code></pre>
[ { "answer_id": 74456665, "author": "lpizzinidev", "author_id": 13211263, "author_profile": "https://Stackoverflow.com/users/13211263", "pm_score": 2, "selected": true, "text": "ref" }, { "answer_id": 74456763, "author": "Sandsten", "author_id": 5903504, "author_profile": "https://Stackoverflow.com/users/5903504", "pm_score": 0, "selected": false, "text": "const buttonRef = useRef<HTMLDivElement | null>() as React.MutableRefObject<HTMLInputElement>;\n.\n.\n.\nconst handleClickOutside = (evt: MouseEvent) => {\n const dropdownClicked = menuListRef?.current?.contains(\n evt.target as HTMLElement\n );\n const buttonToOpenClicked = buttonRef?.current?.contains(\n evt.target as HTMLElement\n );\n // If nether the button or dropdown menu has been clicked\n // You haven't clicked \"outside\"\n if (!dropdownClicked && !buttonToOpenClicked) {\n console.log(\"Clicked outside\");\n setOpen(false);\n }\n};\n.\n.\n.\n<StyledMenuButton onClick={handleToggle} ref={buttonRef}>\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456518", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5245070/" ]
74,456,583
<p>Existing Dataframe :</p> <pre><code>Id Month Year processed success A Jan 2021 0 0 A Feb 2021 0 1 A Mar 2021 1 0 B Jan 2021 0 1 B Feb 2021 0 0 B Mar 2021 0 0 B Apr 2021 0 0 C Dec 2021 0 0 C Jan 2022 0 0 C Feb 2022 1 0 </code></pre> <p>Expected Dataframe :</p> <pre><code> Id final_status A Paid B UnPaid C Paid </code></pre> <p>I am trying to create a Tag as Paid and UnPaid for the Id. Condition for <strong>UnPaid</strong> is to check for the last three consecutive month if either success or Processed doen't have any count it is to be flagged as &quot;Unpaid&quot; else &quot;Paid&quot;</p> <p>stuck with applying conditions.</p>
[ { "answer_id": 74456604, "author": "mozway", "author_id": 16343464, "author_profile": "https://Stackoverflow.com/users/16343464", "pm_score": 0, "selected": false, "text": "groupby.apply" }, { "answer_id": 74456623, "author": "jezrael", "author_id": 2901002, "author_profile": "https://Stackoverflow.com/users/2901002", "pm_score": 1, "selected": false, "text": "Series" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456583", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19303365/" ]
74,456,617
<p>I have the following python code snippet involving dictionary,</p> <pre class="lang-py prettyprint-override"><code> sample_dict = { &quot;name&quot;: &quot;Kelly&quot;, &quot;age&quot;: 25, &quot;salary&quot;: 8000, &quot;city&quot;: &quot;New york&quot; } keys = [&quot;name&quot;, &quot;salary&quot;] sample_dict = {k: sample_dict[k] for k in sample_dict.keys() - keys} print(sample_dict) </code></pre> <p>Why the output is <code>{'city': 'New york', 'age': 25}</code> and not <code>{'age': 25, 'city': 'New york'}</code>?</p> <p>What causes the reverse ordering of dictionary keys? Any help will be highly appreciated. I executed the code on Spyder and Python 3.8.5 version.</p>
[ { "answer_id": 74456735, "author": "Tranbi", "author_id": 13525512, "author_profile": "https://Stackoverflow.com/users/13525512", "pm_score": 2, "selected": false, "text": "-" }, { "answer_id": 74456807, "author": "ILS", "author_id": 10017662, "author_profile": "https://Stackoverflow.com/users/10017662", "pm_score": 1, "selected": false, "text": "dict" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456617", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10607333/" ]
74,456,669
<p>I am iterating over an object from firestore subcollection and I can only console log the result, but I am not able to add the result in a state to use it in a flat list. I tried many ways to get the result in an array but no success.</p> <pre><code> const [order, setOrder] = useState() useEffect(()=&gt;{ const fetchOrder = async()=&gt;{ const orderRef = doc(db, &quot;Order&quot;, route.params.orderId) const orderCollectionRef = collection(orderRef, &quot;products&quot;) const q = await query(orderCollectionRef) const getOrder =await getDocs(q) getOrder.forEach(doc=&gt;{ console.log(doc.data()) //i can console log the result but i want to get it in a state to use it in flatlist }) } fetchOrder() },[]) </code></pre> <p>this is the console log of getOrder <a href="https://i.stack.imgur.com/DMqgI.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/DMqgI.jpg" alt="enter image description here" /></a></p> <p>and this is the console log of doc.data() <a href="https://i.stack.imgur.com/nTgmu.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nTgmu.jpg" alt="enter image description here" /></a></p>
[ { "answer_id": 74456845, "author": "Ka Hung Au Yeung", "author_id": 8090506, "author_profile": "https://Stackoverflow.com/users/8090506", "pm_score": 0, "selected": false, "text": "const getOrder =await getDocs(q)\nconst temp = []\ngetOrder.forEach(doc=>{\n temp.push(doc.data()))\nsetOrder(temp)\n" }, { "answer_id": 74500552, "author": "mohammed refat", "author_id": 9275381, "author_profile": "https://Stackoverflow.com/users/9275381", "pm_score": 2, "selected": true, "text": " const fetchOrder = async()=>{\n const orderRef = doc(db, \"Order\", route.params.orderId)\n const orderCollectionRef = collection(orderRef, \"products\")\n const q = await query(orderCollectionRef)\n const getOrder =await getDocs(q)\n let orders = []\n getOrder.forEach(doc=>{\n //this is the right way to push the orders to an array\n orders.push({\n ...doc.data(),\n id: doc.id\n })\n })\n setOrder(orders)\n }\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456669", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9275381/" ]
74,456,677
<p>I'm trying to setup and explore this firebase extension Trigger Email, as per other tutorial, you can use your personal gmail account (this might be where my problem starts) rather than using mail providers such as SendGrid / Postmark.</p> <p>When I tried using it, I get the following logs on my document</p> <p><a href="https://i.stack.imgur.com/EFnkF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/EFnkF.png" alt="enter image description here" /></a></p> <p>I've followed workarounds here and in other sites however the problem persist. Despite applying the following solutions I got from <a href="https://stackoverflow.com/questions/57196305/invalid-login-535-5-7-8-username-and-password-not-accepted">here</a>, <a href="https://stackoverflow.com/questions/45953488/535-5-7-8-username-and-password-not-accepted-when-sending-mail">here as well</a> and also <a href="https://www.folkstalk.com/2022/09/535-5-7-8-username-and-password-not-accepted-learn-more-atn5-7-8-https-support-google-com-mail-pbadcredentials-q17-20020a17090676d100b006fea59ef3a5sm9650868ejn-32-gsmtp-with-code-examples.html" rel="nofollow noreferrer">here</a> <a href="https://i.stack.imgur.com/J6U13.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/J6U13.png" alt="enter image description here" /></a></p> <p><a href="https://i.stack.imgur.com/pSMgD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pSMgD.png" alt="enter image description here" /></a></p> <p>Does anyone have like another workaround or documentation to follow on setting up? Thanks</p>
[ { "answer_id": 74456845, "author": "Ka Hung Au Yeung", "author_id": 8090506, "author_profile": "https://Stackoverflow.com/users/8090506", "pm_score": 0, "selected": false, "text": "const getOrder =await getDocs(q)\nconst temp = []\ngetOrder.forEach(doc=>{\n temp.push(doc.data()))\nsetOrder(temp)\n" }, { "answer_id": 74500552, "author": "mohammed refat", "author_id": 9275381, "author_profile": "https://Stackoverflow.com/users/9275381", "pm_score": 2, "selected": true, "text": " const fetchOrder = async()=>{\n const orderRef = doc(db, \"Order\", route.params.orderId)\n const orderCollectionRef = collection(orderRef, \"products\")\n const q = await query(orderCollectionRef)\n const getOrder =await getDocs(q)\n let orders = []\n getOrder.forEach(doc=>{\n //this is the right way to push the orders to an array\n orders.push({\n ...doc.data(),\n id: doc.id\n })\n })\n setOrder(orders)\n }\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456677", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11955613/" ]
74,456,693
<p>Tried to build an electron based app by running <code>npm run make</code> in terminal, everything went fine except when it had to go thru <code>Making distributables</code>. Out folder has been created but app is not bundled in one exe. <br> <br> dependencies in Package.json</p> <pre><code> &quot;devDependencies&quot;: { &quot;@electron-forge/cli&quot;: &quot;^6.0.3&quot;, &quot;@electron-forge/maker-deb&quot;: &quot;^6.0.3&quot;, &quot;@electron-forge/maker-rpm&quot;: &quot;^6.0.3&quot;, &quot;@electron-forge/maker-squirrel&quot;: &quot;^6.0.3&quot;, &quot;@electron-forge/maker-zip&quot;: &quot;^6.0.3&quot;, &quot;electron&quot;: &quot;^6.1.12&quot; }, </code></pre> <br> config in forge.config.js: <br> <pre><code>module.exports = { packagerConfig: {}, rebuildConfig: {}, makers: [ { name: '@electron-forge/maker-squirrel', config: {}, }, { name: '@electron-forge/maker-zip', platforms: ['darwin'], }, { name: '@electron-forge/maker-deb', config: {}, }, { name: '@electron-forge/maker-rpm', config: {}, }, ], }; </code></pre> <br> <p><a href="https://i.stack.imgur.com/2g9bR.png" rel="nofollow noreferrer">Full error I'm getting</a> <br> any solutions?</p>
[ { "answer_id": 74468680, "author": "AlexPavlov", "author_id": 3242691, "author_profile": "https://Stackoverflow.com/users/3242691", "pm_score": 2, "selected": false, "text": "{\n \"name\": \"test\",\n \"version\": \"1.0.0\",\n \"description\": \"test\",\n \"main\": \"index.js\",\n \"scripts\": {\n \"start\": \"electron-forge start\",\n \"package\": \"electron-forge package\",\n \"make\": \"electron-forge make\"\n },\n \"author\": \"John\",\n \"license\": \"ISC\",\n \"devDependencies\": {\n \"@electron-forge/cli\": \"^6.0.3\",\n \"@electron-forge/maker-deb\": \"^6.0.3\",\n \"@electron-forge/maker-rpm\": \"^6.0.3\",\n \"@electron-forge/maker-squirrel\": \"^6.0.3\",\n \"@electron-forge/maker-zip\": \"^6.0.3\",\n \"electron\": \"^21.2.3\"\n },\n \"dependencies\": {\n \"electron-squirrel-startup\": \"^1.0.0\"\n }\n}\n" }, { "answer_id": 74494964, "author": "CP Lepage", "author_id": 9777391, "author_profile": "https://Stackoverflow.com/users/9777391", "pm_score": 1, "selected": false, "text": "{\n ...\n description: \"an electron test app\",\n ...\n}\n" }, { "answer_id": 74500854, "author": "Akshay", "author_id": 1453841, "author_profile": "https://Stackoverflow.com/users/1453841", "pm_score": 1, "selected": false, "text": "An unhandled rejection has occurred inside Forge:\n[object Object]\n" }, { "answer_id": 74615501, "author": "Franklin'j Gil'z", "author_id": 6569071, "author_profile": "https://Stackoverflow.com/users/6569071", "pm_score": 0, "selected": false, "text": "forge.config.js" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456693", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18241634/" ]
74,456,713
<h3><strong>Description:</strong></h3> <p>We have two tables as below:</p> <ol> <li>table_1 (&quot;question&quot; main table)</li> <li>table_2 (&quot;question_attempted&quot; joining table)</li> </ol> <h3>Cases:</h3> <ol> <li>In &quot;table_2&quot; we have a column that has a column &quot;is_correct&quot; (holds 1,0) for right or wrong answers.</li> <li>In &quot;table_1&quot; we have 1 m records and in &quot;table_2&quot; we have 10m records</li> </ol> <p>We want to sort our listing data by below columns/values:</p> <ol> <li>Total number of times questions were attempted</li> <li>Total number of times questions were answered correctly</li> <li>The percentages questions were answered correctly (based on above two values)</li> </ol> <h3>Issue:</h3> <p>As soon as we join the table_1 and table_2 to get the count of total_questions_attempted, total_questiones_give_correct_answer, perntage_corrected_given_answers. The query starts taking around 8-10 minutes to run. Table structures are given below. Thanks in advance.</p> <h3>Table structures:</h3> <pre><code>CREATE TABLE IF NOT EXISTS `question` ( `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, `category` bigint(20) NOT NULL DEFAULT 0, `parent` bigint(20) UNSIGNED NOT NULL DEFAULT 0, `name` text COLLATE utf8mb4_unicode_ci NOT NULL, `questiontext` text COLLATE utf8mb4_unicode_ci NOT NULL, `questiontextformat` tinyint(4) NOT NULL DEFAULT 0, `generalfeedback` text COLLATE utf8mb4_unicode_ci NOT NULL, `generalfeedbackformat` tinyint(4) NOT NULL DEFAULT 0, `defaultmark` decimal(12,7) NOT NULL DEFAULT 1.0000000, `penalty` decimal(12,7) NOT NULL DEFAULT 0.3333333, `qtype` varchar(20) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '' COMMENT '''1''', `length` bigint(20) UNSIGNED NOT NULL DEFAULT 1, `stamp` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `version` varchar(255) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `hidden` tinyint(3) UNSIGNED NOT NULL DEFAULT 0, `timecreated` bigint(20) UNSIGNED NOT NULL DEFAULT 0, `timemodified` bigint(20) UNSIGNED NOT NULL DEFAULT 0, `createdby` bigint(20) UNSIGNED DEFAULT NULL, `modifiedby` bigint(20) UNSIGNED DEFAULT NULL, `type_data_id` bigint(20) NOT NULL, `img_id` bigint(20) DEFAULT NULL, `qimg_gallary_text` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, `qrimg_gallary_text` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, `qimg_gallary_ids` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, `qrimg_gallary_ids` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, `case_id` bigint(20) NOT NULL DEFAULT 0, `ques_type_id` bigint(20) DEFAULT NULL, `year` bigint(20) DEFAULT NULL, `spec` bigint(20) DEFAULT NULL, `sub_speciality_id` int(11) DEFAULT NULL, `sub_sub_speciality_id` int(11) DEFAULT NULL, `spec_level` bigint(20) DEFAULT 1, `is_deleted` int(11) NOT NULL DEFAULT 0, `sequence` int(11) NOT NULL DEFAULT 0, `sort_order` bigint(20) NOT NULL DEFAULT 0 COMMENT 'Question order in list', `idnumber` varchar(100) COLLATE utf8mb4_unicode_ci DEFAULT NULL, `addendum` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, `text_for_search` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL COMMENT 'this is for the text based searching, this will store the text of the question without html tags', `text_for_search_ans` longtext COLLATE utf8mb4_unicode_ci DEFAULT NULL, PRIMARY KEY (`id`), UNIQUE KEY `type_data_id` (`type_data_id`), UNIQUE KEY `mdl_ques_catidn_uix` (`category`,`idnumber`), KEY `mdl_ques_cat_ix` (`category`), KEY `mdl_ques_par_ix` (`parent`), KEY `mdl_ques_cre_ix` (`createdby`), KEY `mdl_ques_mod_ix` (`modifiedby`), KEY `id` (`id`), KEY `mq_spec_ix` (`spec`), KEY `sort_order` (`sort_order`) ) ENGINE=InnoDB DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='The questions themselves'; </code></pre> <pre><code>CREATE TABLE IF NOT EXISTS `question_attempted` ( `id` bigint(20) UNSIGNED NOT NULL AUTO_INCREMENT, `questionusageid` bigint(20) UNSIGNED NOT NULL, `slot` bigint(20) UNSIGNED NOT NULL, `behaviour` varchar(32) COLLATE utf8mb4_unicode_ci NOT NULL DEFAULT '', `questionid` bigint(20) UNSIGNED NOT NULL, `variant` bigint(20) UNSIGNED NOT NULL DEFAULT 1, `maxmark` decimal(12,7) NOT NULL, `minfraction` decimal(12,7) NOT NULL, `flagged` tinyint(3) UNSIGNED NOT NULL DEFAULT 2, `questionsummary` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, `rightanswer` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, `responsesummary` text COLLATE utf8mb4_unicode_ci DEFAULT NULL, `timemodified` bigint(20) UNSIGNED NOT NULL, `maxfraction` decimal(12,7) DEFAULT 1.0000000, `in_remind_state` int(11) NOT NULL DEFAULT 0, `is_correct` tinyint(1) DEFAULT 1, PRIMARY KEY (`id`), UNIQUE KEY `mdl_quesatte_queslo_uix` (`questionusageid`,`slot`), KEY `mdl_quesatte_que_ix` (`questionid`), KEY `mdl_quesatte_que2_ix` (`questionusageid`), KEY `mdl_quesatte_beh_ix` (`behaviour`), KEY `questionid` (`questionid`), KEY `is_correct` (`is_correct`) ) ENGINE=InnoDB AUTO_INCREMENT=151176 DEFAULT CHARSET=utf8mb4 COLLATE=utf8mb4_unicode_ci COMMENT='Each row here corresponds to an attempt at one question, as '; </code></pre> <p>I tried with the below query:</p> <pre><code>SELECT mq.id, mq.name, COUNT(is_correct) FROM mdl_question_attempts as mqa LEFT JOIN mdl_question mq on mq.id = mqa.questionid where mq.id IS NOT NULL and mq.is_deleted = '0' GROUP by mqa.questionid ORDER by mq.sort_order desc, mq.id DESC LIMIT 50 https://i.stack.imgur.com/mHK6W.png </code></pre>
[ { "answer_id": 74472592, "author": "Thorsten Kettner", "author_id": 2270762, "author_profile": "https://Stackoverflow.com/users/2270762", "pm_score": 1, "selected": true, "text": "SELECT mq.id, mq.name, COUNT(mqa.questionid)\nFROM mdl_question mq\nLEFT JOIN mdl_question_attempts mqa ON mq.id = mqa.questionid AND mqa.is_correct\nWHERE NOT mq.is_deleted\nGROUP by mq.id\nORDER by mq.sort_order DESC, mq.id DESC \nLIMIT 50;\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456713", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5891402/" ]
74,456,724
<p>Hello I a beginner in python. I am building a small program that can find any duplicate characters in a string. However there's something i don't understand.</p> <p>Code:</p> <pre><code>def is_isogram(string): dict = {} for letter in string: dict[letter] = 1 if letter in dict: dict[letter] += 1 return dict print(is_isogram(&quot;Dermatoglyphics&quot;)) </code></pre> <p>OUTPUT {'D': 1, 'e': 1, 'r': 1, 'm': 1, 'a': 1, 't': 1, 'o': 1, 'g': 1, 'l': 1, 'y': 1, 'p': 1, 'h': 1, 'i': 1, 'c': 1, <strong>'s': 2</strong>}</p> <p>I set an empty dictionary. I then used a for loop to iterate over the string, and then in each iteration it should assign 1 to a dictionary key, &quot;letter&quot;</p> <p>Then used &quot;if...in&quot; to check if letter has already appeared, and if it has then the the &quot;letter&quot; key should be incremented by 1.</p> <p>I tried it on a word, Dermatoglyphics, but each time the last key value pair is always 2, even though this word only contains 1 of each letter. Does anyone know why?</p>
[ { "answer_id": 74456778, "author": "Zohaib Hamdule", "author_id": 11941095, "author_profile": "https://Stackoverflow.com/users/11941095", "pm_score": -1, "selected": false, "text": "def is_isogram(string):\n dict = {}\n for letter in string:\n dict[letter] = 0\n for letter in string:\n dict[letter] += 1\n return dict\n\n\nprint(is_isogram(\"telegram\"))\n" }, { "answer_id": 74456792, "author": "Minot", "author_id": 16298771, "author_profile": "https://Stackoverflow.com/users/16298771", "pm_score": 2, "selected": false, "text": "if" }, { "answer_id": 74456804, "author": "Robin", "author_id": 7387089, "author_profile": "https://Stackoverflow.com/users/7387089", "pm_score": 2, "selected": false, "text": "if" }, { "answer_id": 74457026, "author": "0x0fba", "author_id": 20339407, "author_profile": "https://Stackoverflow.com/users/20339407", "pm_score": 1, "selected": false, "text": "is_isogram()" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456724", "https://Stackoverflow.com", "https://Stackoverflow.com/users/18303009/" ]
74,456,725
<p>I have run <code>squashmigrations</code> in Django and after a while I needed to delete the database and start from scratch (the problem also applies when downloading the repository from GitHub and trying to recreate the project). I get following error when running <code>python manage.py makemigrations</code> or <code>python manage.py migrate</code>:</p> <pre><code>(venv) meal_plan   main  python manage.py makemigrations Traceback (most recent call last): File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/db/backends/utils.py&quot;, line 89, in _execute return self.cursor.execute(sql, params) File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/db/backends/sqlite3/base.py&quot;, line 357, in execute return Database.Cursor.execute(self, query, params) sqlite3.OperationalError: no such table: meal_plan_recipe The above exception was the direct cause of the following exception: Traceback (most recent call last): File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/manage.py&quot;, line 22, in &lt;module&gt; main() File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/manage.py&quot;, line 18, in main execute_from_command_line(sys.argv) File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/core/management/__init__.py&quot;, line 446, in execute_from_command_line utility.execute() File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/core/management/__init__.py&quot;, line 440, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/core/management/base.py&quot;, line 402, in run_from_argv self.execute(*args, **cmd_options) File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/core/management/base.py&quot;, line 443, in execute self.check() File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/core/management/base.py&quot;, line 475, in check all_issues = checks.run_checks( File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/core/checks/registry.py&quot;, line 88, in run_checks new_errors = check(app_configs=app_configs, databases=databases) File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/core/checks/urls.py&quot;, line 42, in check_url_namespaces_unique all_namespaces = _load_all_namespaces(resolver) File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/core/checks/urls.py&quot;, line 61, in _load_all_namespaces url_patterns = getattr(resolver, &quot;url_patterns&quot;, []) File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/utils/functional.py&quot;, line 57, in __get__ res = instance.__dict__[self.name] = self.func(instance) File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/urls/resolvers.py&quot;, line 715, in url_patterns patterns = getattr(self.urlconf_module, &quot;urlpatterns&quot;, self.urlconf_module) File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/utils/functional.py&quot;, line 57, in __get__ res = instance.__dict__[self.name] = self.func(instance) File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/urls/resolvers.py&quot;, line 708, in urlconf_module return import_module(self.urlconf_name) File &quot;/Users/enricobonardi/.pyenv/versions/3.10.7/lib/python3.10/importlib/__init__.py&quot;, line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1050, in _gcd_import File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1027, in _find_and_load File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1006, in _find_and_load_unlocked File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 688, in _load_unlocked File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 883, in exec_module File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 241, in _call_with_frames_removed File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/config/urls.py&quot;, line 9, in &lt;module&gt; path(&quot;&quot;, include(&quot;meal_plan.urls&quot;, namespace=&quot;mealplan&quot;)), File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/urls/conf.py&quot;, line 38, in include urlconf_module = import_module(urlconf_module) File &quot;/Users/enricobonardi/.pyenv/versions/3.10.7/lib/python3.10/importlib/__init__.py&quot;, line 126, in import_module return _bootstrap._gcd_import(name[level:], package, level) File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1050, in _gcd_import File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1027, in _find_and_load File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 1006, in _find_and_load_unlocked File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 688, in _load_unlocked File &quot;&lt;frozen importlib._bootstrap_external&gt;&quot;, line 883, in exec_module File &quot;&lt;frozen importlib._bootstrap&gt;&quot;, line 241, in _call_with_frames_removed File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/meal_plan/urls.py&quot;, line 5, in &lt;module&gt; from . import views File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/meal_plan/views.py&quot;, line 11, in &lt;module&gt; from .forms import MealPlanForm, RecipeSimpleForm File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/meal_plan/forms.py&quot;, line 26, in &lt;module&gt; class RecipeSimpleForm(forms.ModelForm): File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/meal_plan/forms.py&quot;, line 38, in RecipeSimpleForm RECIPES = [(x.id, x.title) for x in Recipe.objects.all()] File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/db/models/query.py&quot;, line 394, in __iter__ self._fetch_all() File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/db/models/query.py&quot;, line 1866, in _fetch_all self._result_cache = list(self._iterable_class(self)) File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/db/models/query.py&quot;, line 87, in __iter__ results = compiler.execute_sql( File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/db/models/sql/compiler.py&quot;, line 1398, in execute_sql cursor.execute(sql, params) File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/db/backends/utils.py&quot;, line 103, in execute return super().execute(sql, params) File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/db/backends/utils.py&quot;, line 67, in execute return self._execute_with_wrappers( File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/db/backends/utils.py&quot;, line 80, in _execute_with_wrappers return executor(sql, params, many, context) File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/db/backends/utils.py&quot;, line 84, in _execute with self.db.wrap_database_errors: File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/db/utils.py&quot;, line 91, in __exit__ raise dj_exc_value.with_traceback(traceback) from exc_value File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/db/backends/utils.py&quot;, line 89, in _execute return self.cursor.execute(sql, params) File &quot;/Users/enricobonardi/CODING/TESTING/meal_plan/venv/lib/python3.10/site-packages/django/db/backends/sqlite3/base.py&quot;, line 357, in execute return Database.Cursor.execute(self, query, params) django.db.utils.OperationalError: no such table: meal_plan_recipe (venv) ✘  meal_plan   main  </code></pre> <p>meal_plan/models.py:</p> <pre><code>from django.conf import settings from django.db import models from django.db.models.signals import post_save from django.dispatch import receiver from django.urls import reverse User = settings.AUTH_USER_MODEL # ---------Stagionality----------# class Month(models.Model): name = models.CharField(max_length=25) class Meta: ordering = (&quot;id&quot;,) verbose_name = &quot;mese&quot; verbose_name_plural = &quot;mesi&quot; def __str__(self): return self.name class VegetableItem(models.Model): class Types(models.IntegerChoices): VERDURA = 1 FRUTTA = 2 name = models.CharField(max_length=100) type = models.SmallIntegerField(choices=Types.choices, default=Types.VERDURA) description = models.TextField(blank=True) seasonality = models.ManyToManyField(Month, verbose_name=&quot;stagionalità&quot;) image = models.ImageField(upload_to=&quot;vegetableitems&quot;, default=&quot;vegetableitems/default.png&quot;) class Meta: verbose_name = &quot;alimento stagionale&quot; verbose_name_plural = &quot;alimenti stagionali&quot; def __str__(self): return self.name # ---------END of Stagionality----------# # ---------MealPlan----------# class Day(models.TextChoices): LUNEDI = &quot;LUN&quot;, &quot;Lunedì&quot; MARTEDI = &quot;MAR&quot;, &quot;Martedì&quot; MERCOLEDI = &quot;MER&quot;, &quot;Mercoledì&quot; GIOVEDI = &quot;GIO&quot;, &quot;Giovedì&quot; VENERDI = &quot;VEN&quot;, &quot;Venerdì&quot; SABATO = &quot;SAB&quot;, &quot;Sabato&quot; DOMENICA = &quot;DOM&quot;, &quot;Domenica&quot; class Type(models.IntegerChoices): COLAZIONE = 1 SPUNTINO = 2 PRANZO = 3 MERENDA = 4 CENA = 5 class MealPlan(models.Model): title = models.CharField(max_length=100) user = models.ForeignKey(User, on_delete=models.CASCADE) created_at = models.DateTimeField(auto_now_add=True) updated_at = models.DateTimeField(auto_now=True) def __str__(self) -&gt; str: return self.title class Meta: verbose_name_plural = &quot;mealplan&quot; def get_absolute_url(self): return reverse(&quot;mealplan:mealplan_detail&quot;, kwargs={&quot;pk&quot;: self.pk}) class Meal(models.Model): day = models.CharField(max_length=3, choices=Day.choices, default=Day.LUNEDI, verbose_name=&quot;giorno&quot;) type = models.IntegerField(choices=Type.choices) mealplan = models.ForeignKey(MealPlan, on_delete=models.CASCADE) class Meta: verbose_name = &quot;pasto&quot; verbose_name_plural = &quot;pasti&quot; def __str__(self) -&gt; str: return f&quot;{self.mealplan} ({self.get_day_display()} - {self.get_type_display()})&quot; class Measure(models.IntegerChoices): ML = 1 G = 2 UNIT = 3 class Recipe(models.Model): title = models.CharField(max_length=100) method = models.TextField(blank=True) meals = models.ManyToManyField(Meal) class Meta: verbose_name = &quot;ricetta&quot; verbose_name_plural = &quot;ricette&quot; def __str__(self) -&gt; str: return self.title class Ingredient(models.Model): name = models.CharField(max_length=100) quantity = models.SmallIntegerField(blank=True) measure = models.IntegerField(choices=Measure.choices, default=Measure.G) recipe = models.ForeignKey(Recipe, on_delete=models.CASCADE, null=True) @receiver(post_save, sender=MealPlan) def mealplan_post_save_receiver(sender, instance, created, *args, **kwargs): if created: mealplan = instance days_of_the_week = Meal._meta.get_field(&quot;day&quot;).choices days = [label for label, day in days_of_the_week] for day in days: for type in range(1, 6): meal = Meal.objects.create(mealplan=mealplan, day=day, type=type) meal.save() # ---------END of MealPlan----------# </code></pre> <p>I tried to reset migrations on original repository using <a href="https://simpleisbetterthancomplex.com/tutorial/2016/07/26/how-to-reset-migrations.html" rel="nofollow noreferrer">these instructions</a> with no luck.</p>
[ { "answer_id": 74456853, "author": "Manoj Tolagekar", "author_id": 17808039, "author_profile": "https://Stackoverflow.com/users/17808039", "pm_score": 0, "selected": false, "text": "python manage.py makemigrations appname\n\npython manage.py sqlmigrate appname 0001\n\npython manage.py migrate\n" }, { "answer_id": 74464696, "author": "WEBBOgrafico", "author_id": 20517540, "author_profile": "https://Stackoverflow.com/users/20517540", "pm_score": 1, "selected": false, "text": "class RecipeSimpleForm(forms.ModelForm):\n\n...\n\nRECIPES = [(x.id, x.title) for x in Recipe.objects.all()]\n\ntitle = forms.ChoiceField(widget=forms.Select, choices=RECIPES)\n\nclass Meta:\n model = Recipe\n fields = [\"title\"]\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456725", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20517540/" ]
74,456,742
<p>How to fix this problem <code>this string cannot be provided in the text widget.</code> How can I solve this? My code: <a href="https://i.stack.imgur.com/Rf5EF.jpg" rel="nofollow noreferrer">code</a></p>
[ { "answer_id": 74456853, "author": "Manoj Tolagekar", "author_id": 17808039, "author_profile": "https://Stackoverflow.com/users/17808039", "pm_score": 0, "selected": false, "text": "python manage.py makemigrations appname\n\npython manage.py sqlmigrate appname 0001\n\npython manage.py migrate\n" }, { "answer_id": 74464696, "author": "WEBBOgrafico", "author_id": 20517540, "author_profile": "https://Stackoverflow.com/users/20517540", "pm_score": 1, "selected": false, "text": "class RecipeSimpleForm(forms.ModelForm):\n\n...\n\nRECIPES = [(x.id, x.title) for x in Recipe.objects.all()]\n\ntitle = forms.ChoiceField(widget=forms.Select, choices=RECIPES)\n\nclass Meta:\n model = Recipe\n fields = [\"title\"]\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456742", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20517506/" ]
74,456,806
<p>When I run it on my local computer I don't get any problem, I encounter this error when I deploy it to Heroku. I don't fully understand the reason.</p> <pre><code>MongoParseError URI malformed, cannot be parsed </code></pre> <p>I just get this on Heroku. Also, my file on the server.js side is as follows.</p> <pre><code>const dotenv = require(&quot;dotenv&quot;); dotenv.config({ path: &quot;./.env&quot; }); const app = require(&quot;./app&quot;); const DB = process.env.DATABASE.replace( &quot;&lt;PASSWORD&gt;&quot;, process.env.DATABASE_PASSWORD ); console.log(DB); mongoose .connect(DB, { auth: { user: process.env.MONGO_DB_USER, password: process.env.MONGO_DB_PASSWORD, }, useNewUrlParser: true, useCreateIndex: true, useFindAndModify: false, }) .then(() =&gt; console.log(&quot;DB connection successful!&quot;)); </code></pre> <blockquote> <p>&quot;mongoose&quot;: &quot;^5.13.14&quot;, &quot;mongoose-intl&quot;: &quot;^3.3.0&quot;, &quot;dotenv&quot;: &quot;^16.0.3&quot;,</p> </blockquote> <p>My .env file has MongoDB URLs and passwords. That's why I don't share. Works great locally too. but there are problems in deployment.</p>
[ { "answer_id": 74460249, "author": "Ali Iqbal", "author_id": 20321054, "author_profile": "https://Stackoverflow.com/users/20321054", "pm_score": 0, "selected": false, "text": "require('dotenv').config();\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456806", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17321009/" ]
74,456,811
<p>All the true values are exchanged with false and vice versa. The undefined and other array elements are to be ignored but I am encountering an error in my code. The error seems to be caused by an undefined element in the array. The code after removing the undefined element runs properly.</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>function flipGrid(grid) { for (let i = 0; i &lt; grid.length; i++) { for (let k = 0; k &lt; grid[i].length &amp;&amp; grid[i] !== undefined; k++) { if (grid[i][k] === undefined) { grid[i][k] = undefined; continue; } if (grid[i][k] === true) { grid[i][k] = false; } else if (grid[i][k] === false) { grid[i][k] = true; } } } return grid; } let grid = [ [true, false, undefined, true], [undefined, false, true, true], undefined, [undefined, undefined, false, false] ]; console.log(JSON.stringify(flipGrid(grid)));</code></pre> </div> </div> </p> <p>I am expecting this outcome.</p> <pre><code>should print [[false,true,undefined,false], [undefined,true,false,false], undefined, [undefined,undefined,true,true]]); </code></pre>
[ { "answer_id": 74456876, "author": "subodhkalika", "author_id": 6682406, "author_profile": "https://Stackoverflow.com/users/6682406", "pm_score": 2, "selected": false, "text": "function flipgrid(grid) {\n return grid.map(gridValue => {\n if (Array.isArray(gridValue)) {\n return flipgrid(gridValue)\n } else {\n return (gridValue === undefined) ? gridValue : !gridValue;\n }\n })\n}\n\n\nlet grid = [[true, false, undefined, true],\n[undefined, false, true, true],\n undefined,\n[undefined, undefined, false, false]];\n\nconsole.log(flipgrid(grid))" }, { "answer_id": 74457160, "author": "Rohìt Jíndal", "author_id": 4116300, "author_profile": "https://Stackoverflow.com/users/4116300", "pm_score": 0, "selected": false, "text": "@subodhkalia's" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456811", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20517436/" ]
74,456,819
<p>I want to find an integer value from a sigma contained equation with two variables like <a href="https://stackoverflow.com/q/61362303/13394817">this post</a></p> <p><a href="https://i.stack.imgur.com/nm6hX.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/nm6hX.png" alt="enter image description here" /></a></p> <p>where <code>x</code> (a real decimal value) range is between two limits e.g. <code>known_xmin_value &lt;= x &lt; known_xmax_value</code>. <code>1</code> is the lower limit of <code>k</code> (which is the integer) but don't know the upper limit (which is the goal to be derived from the solution); Perhaps just could be guess that it will be lower than 2000000. Is it possible to find the integer for <code>k</code>? How?</p> <pre><code>from sympy import Sum, solve from sympy.abc import k, x known_value = 742.231 # just for example known_xmin_value = 3.652 # just for example solve(-known_value + Sum((x + (k - 1) * (x - known_xmin_value)) ** 3, (k, 1, integer_unknown_limit)), x) </code></pre>
[ { "answer_id": 74456876, "author": "subodhkalika", "author_id": 6682406, "author_profile": "https://Stackoverflow.com/users/6682406", "pm_score": 2, "selected": false, "text": "function flipgrid(grid) {\n return grid.map(gridValue => {\n if (Array.isArray(gridValue)) {\n return flipgrid(gridValue)\n } else {\n return (gridValue === undefined) ? gridValue : !gridValue;\n }\n })\n}\n\n\nlet grid = [[true, false, undefined, true],\n[undefined, false, true, true],\n undefined,\n[undefined, undefined, false, false]];\n\nconsole.log(flipgrid(grid))" }, { "answer_id": 74457160, "author": "Rohìt Jíndal", "author_id": 4116300, "author_profile": "https://Stackoverflow.com/users/4116300", "pm_score": 0, "selected": false, "text": "@subodhkalia's" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456819", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13394817/" ]
74,456,884
<p>My component with Home is not accessible in my App.js component. Home.jsx</p> <pre><code>import React from 'react' import &quot;./Home.scss const Home = () =&gt; { return ( &lt;div&gt; &lt;div className=&quot;home&quot;&gt;Home&lt;/div&gt; &lt;/div&gt; ) } export default Home </code></pre> <p>This is my App.js Code</p> <pre><code>import &quot;./pages/home/Home&quot; function App() { return ( &lt;div className=&quot;App&quot;&gt; &lt;Home/&gt; &lt;/div&gt; ); } export default App; </code></pre> <p>I am facing the error:</p> <pre><code> [eslint] src/App.js Line 8:6: 'Home' is not defined react/jsx-no-undef Search for the keywords to learn more about each error. ERROR in [eslint] src/App.js Line 8:6: 'Home' is not defined react/jsx-no-undef Search for the keywords to learn more about each error. webpack compiled with 1 error </code></pre> <p>I am expecting to access Home component in App.js file</p>
[ { "answer_id": 74456909, "author": "PCPbiscuit", "author_id": 14260530, "author_profile": "https://Stackoverflow.com/users/14260530", "pm_score": 0, "selected": false, "text": "import Home from \"./pages/home/Home\"\n" }, { "answer_id": 74456930, "author": "Saqib Ali", "author_id": 20508261, "author_profile": "https://Stackoverflow.com/users/20508261", "pm_score": 2, "selected": false, "text": "import Home from \"./pages/home/Home\";\n" }, { "answer_id": 74456934, "author": "Ka Hung Au Yeung", "author_id": 8090506, "author_profile": "https://Stackoverflow.com/users/8090506", "pm_score": 0, "selected": false, "text": "import Home from \"./pages/home/Home\"\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456884", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20517610/" ]
74,456,900
<p>I want to write a macro to copy rows from one worksheet to another below cell that is colored black (manually) - if it is detected, otherwise just copy rows from first sheet to Sheet1 at the top. After many trials and errors I came up with that code:</p> <pre><code>Sub copytherows(clf As Long, lastcell As Long) 'clf - cell that marks the start, lastcell - ending cell Dim st As Long, cnext As Range Dim wshet As Worksheet Dim wshetend As Worksheet 'st - start of looking up, cnext - range of lines, wshet - worksheet Dim coprange As String Dim cnextcoprow, cnextrow As Long 'variables for copying macro part Dim rangehelper As Range Dim TargetColor As Long Dim cell As Range Dim sht As Worksheet Dim x As Long Dim Aend As Long Set wshet = Worksheets(1) Set wshetend = Sheets(&quot;Sheet1&quot;) wshetend.Cells.Delete For st = 1 To wshet.Cells(Rows.Count, &quot;B&quot;).End(xlUp).Row If wshet.Cells(st, &quot;B&quot;).Interior.Color = clf Then 'has the color of interest cnextcoprow = st Set cnext = wshet.Cells(st, &quot;B&quot;).Offset(1, 0) 'next cell down Do While cnext.Interior.Color &lt;&gt; lastcell Set cnext = cnext.Offset(1, 0) 'next row Loop st = st + 1 End If Next st cnextrow = cnext.Row - 1 coprange = cnextcoprow &amp; &quot;:&quot; &amp; cnextrow Aend = Cells(Rows.Count, &quot;A&quot;).End(xlUp).Row 'set color is black TargetColor = RGB(255, 255, 255) wshetend.Activate For x = 1 To Rows.Count If wshetend.Cells(x, &quot;A&quot;).Interior.Color = TargetColor Then x = x + 1 Set rangehelper = wshetend.Rows(x) wshet.Range(coprange).Copy wshetend.Range(rangehelper).Offset(1) Else wshet.Range(coprange).Copy wshetend.Range(&quot;A&quot; &amp; Rows.Count).End(xlUp).Offset(1) End If Next x End Sub </code></pre> <p>When Macro is ran it displays an error(Run-time error '1004' Method 'Range' of object '_Worksheet' failed on line :</p> <pre><code>wshet.Range(coprange).Copy wshetend.Range(rangehelper).Offset(1) </code></pre> <p>Sheet1 is for sure present in Workbook. Edit as suggested by @FaneDuru: <a href="https://i.stack.imgur.com/IWkp8.png" rel="nofollow noreferrer">1</a> - in this image is my curret state of worksheet that is <code>wshet</code> in my macro and for example if I select (by checkboxes) section1 and section3, section3 should be in the place of black cell in section1 (the order of sections doesn't really matter to me) inside destination sheet ( I know I'm not good in explaining things like that).<br /> <a href="https://i.stack.imgur.com/7kJpC.png" rel="nofollow noreferrer">2</a> - this should be end result of this macro</p>
[ { "answer_id": 74458392, "author": "Notus_Panda", "author_id": 19353309, "author_profile": "https://Stackoverflow.com/users/19353309", "pm_score": 1, "selected": false, "text": " ElseIf wshet.Cells(st, \"B\").Interior.Color = lastcell Then\n cnextrow = st\n Exit For\n End If\n" }, { "answer_id": 74460851, "author": "FaneDuru", "author_id": 2233308, "author_profile": "https://Stackoverflow.com/users/2233308", "pm_score": 0, "selected": false, "text": "Sub CopyRowsCheckBox_Black_limited()\n Dim wshet As Worksheet, wshetend As Worksheet, blackCell As Range, redCell As Range, rngCopy As Range\n Dim sh As Shape, chkB As MSForms.CheckBox, cellPaste As Range, pasteRow As Long\n \n Set wshet = ActiveSheet 'use here the sheet where from you need copying\n Set wshetend = wshet.Next 'use here the sheet where to copy\n \n 'settings to make Find function searching for Interior color:\n With Application.FindFormat\n .Clear: .Interior.Color = vbBlack\n .Locked = True\n End With\n \n 'find the black cell in the second sheet:\n Set cellPaste = wshetend.cells.Find(What:=vbNullString, After:=wshetend.Range(\"A1\"), SearchFormat:=True)\n If Not cellPaste Is Nothing Then 'set the row where to copy first\n pasteRow = cellPaste.Offset(1).row\n Else\n pasteRow = 1\n End If\n \n 'iterate between all shapes, found the ones being checkBoxes and being on column G:G, set the rows range and copy it:\n For Each sh In wshet.Shapes\n If TypeName(sh.OLEFormat.Object.Object) = \"CheckBox\" And sh.TopLeftCell.Column = 7 Then\n Set chkB = sh.OLEFormat.Object.Object 'set the checkBox ActiveX object\n If chkB.Value = True Then 'if it is checked\n Set blackCell = wshet.Range(\"B:B\").Find(What:=vbNullString, After:=wshet.Range(\"B\" & _\n sh.TopLeftCell.row), SearchFormat:=True) 'find first black cell\n Set rngCopy = wshet.Range(wshet.Range(\"B\" & sh.TopLeftCell.row), blackCell).EntireRow 'set the rows to be copied\n rngCopy.Copy wshetend.Range(\"A\" & pasteRow): pasteRow = pasteRow + rngCopy.rows.count 'copy and update pasting row\n End If\n End If\n Next sh\n \n MsgBox \"Ready...\"\nEnd Sub\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456900", "https://Stackoverflow.com", "https://Stackoverflow.com/users/13401873/" ]
74,456,908
<p>I'm a beginner in Python with no prior programming experience, so bear with me here.</p> <p>I installed Python, started playing with it (typing variables, playing with math operations) in the Shell window and everything is fine. I open a New Window and started writing a simple script. Something like this:</p> <p>print (1+1)</p> <p>I press Run Module, and I am asked to name and save the script first. I do so by calling it firstscript.py, and save it to my desktop.</p> <p>Now I press Run Module, and in the shell window 2 is printed on the screen. Everything is fine. I close Python, and open it up again. Now in the shell window, I type firstscript.py and I get the red message NameError: name 'firstscript' is not defined.</p> <p>I can run my program only if I open the script file on my desktop and press Run Module from there, but if I try to start it up directly in IDLE Shell by typing its name, I get the error message.</p> <p>What did I do wrong? Thank you.</p>
[ { "answer_id": 74457009, "author": "Mirza Younus", "author_id": 8683891, "author_profile": "https://Stackoverflow.com/users/8683891", "pm_score": 1, "selected": false, "text": "python [locationOfFile\\]firstscript.py\n" }, { "answer_id": 74457029, "author": "LiiVion", "author_id": 19328707, "author_profile": "https://Stackoverflow.com/users/19328707", "pm_score": 0, "selected": false, "text": "firstscript.py" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456908", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20516856/" ]
74,456,949
<p>When pressing the delete button it successfully delete the record from database. But not delete from the frontend it gives result after reloading or refreshing the page.</p> <p>My view:</p> <pre><code>@foreach (var item in Model) { &lt;a href=&quot;#&quot; class=&quot;phone_number&quot; onclick=&quot;del(this)&quot; data-id=&quot;@item.id&quot;&gt; &lt;i class=&quot;fas fa-trash-alt&quot;&gt;&lt;/i&gt; &lt;/a&gt; } &lt;script&gt; function del(x) { var url = '@Url.Action(&quot;deleteRent&quot;, &quot;Home&quot;)'; var rd = x.dataset.id debugger $.ajax({ url: url, type: 'POST', data: { id: rd }, success: function (data) { if (data.length == 0) // No errors alert(&quot;Delete success!&quot;); }, error: function (jqXHR) { // Http Status is not 200 }, complete: function (jqXHR, status) { // Whether success or error it enters here } }); }; &lt;/script&gt; </code></pre>
[ { "answer_id": 74457230, "author": "Dipendrasinh Vaghela", "author_id": 20127612, "author_profile": "https://Stackoverflow.com/users/20127612", "pm_score": 0, "selected": false, "text": "success: function (data) {\n if (data.length == 0) // No errors\n alert(\"Delete success!\");\n **window.location.reload();**\n },\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456949", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20467305/" ]
74,456,951
<p>In our Jenkins pipeline, I'm using a bash script to call the <code>helm install</code> command. We have a <code>values.yaml</code> containing most of the values to be passed to helm. However, few values are based upon <code>environment variables</code> and have to be passed using the <code>--set</code> argument. Here is the snippet:</p> <pre class="lang-bash prettyprint-override"><code>helm install $RELEASE_NAME shared/phoenixmsp-app -f value.yaml \ --set global.env.production=$production \ --set global.cluster.hosts=${CONFIG[${CLUSTER_NAME}]} \ --set nameOverride=$RELEASE_NAME \ --set fullnameOverride=$RELEASE_NAME \ --set image.repository=myhelm.hub.mycloud.io/myrepo/mainservice \ --set-string image.tag=$DOCKER_TAG \ --wait --timeout 180s --namespace $APP_NAMESPACE&quot; </code></pre> <p>We want to move these <code>--set</code> parameters to <code>values.yaml</code>. The goal is to get rid of <code>--set</code> and simply pass the <code>values.yaml</code>.</p> <h3>Question: Is it possible to expand Environment Variables in <code>values.yaml</code> while calling with <code>helm install</code> or <code>helm upgrade</code>?</h3>
[ { "answer_id": 74457316, "author": "Blender Fox", "author_id": 2017590, "author_profile": "https://Stackoverflow.com/users/2017590", "pm_score": 3, "selected": true, "text": "values.yaml" }, { "answer_id": 74464219, "author": "Paul Hodges", "author_id": 8656552, "author_profile": "https://Stackoverflow.com/users/8656552", "pm_score": 0, "selected": false, "text": "--set" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456951", "https://Stackoverflow.com", "https://Stackoverflow.com/users/395069/" ]
74,456,955
<p>I have a User model that inherits from AbstractUser which has an email field. And a profile model that has an OneToOne relation with the User model</p> <pre><code>class User(AbstractUser): email = models.EmailField(unique=True) class Profile(models.Model): user = models.OneToOneField(settings.AUTH_USER_MODEL, on_delete=models.CASCADE) phone = models.CharField(max_length=13, validators=[phone_regex], unique=True, null=True, blank=True) birth_date = models.DateField(blank=True, null=True) about = models.TextField(max_length=2000, blank=True) def __str__(self): return f&quot;{self.user.first_name} {self.user.last_name}&quot; </code></pre> <p>view.py</p> <pre><code>class ProfileViewSet(ModelViewSet): .... @action(detail=False, methods=[&quot;GET&quot;, &quot;PUT&quot;], permission_classes=[IsAuthenticated]) def me(self, request, *args, **kwargs): profile = Profile.objects.get(user_id=request.user.id) if request.method == &quot;GET&quot;: serializer = ProfileSerializer(profile) return Response(serializer.data) elif request.method == &quot;PUT&quot;: serializer = ProfileSerializer(profile, request.data) serializer.is_valid(raise_exception=True) serializer.save() return Response(serializer.data) </code></pre> <p>serializers.py</p> <pre><code>class ProfileSerializer(serializers.ModelSerializer): user = CurrentUserSerializer() def update(self, instance, validated_data): user_data = validated_data.pop('user') user_ser = CurrentUserSerializer(instance=instance.user, data=user_data) if user_ser.is_valid(): user_ser.save() instance.phone = validated_data.get('phone', instance.phone) instance.birth_date = validated_data.get('birth_date', instance.birth_date) instance.about = validated_data.get('about', instance.about) instance.save() return instance class Meta: model = Profile fields = [ 'id', 'user', 'phone', 'birth_date', 'about', ] </code></pre> <p>Now when I try to update a user profile I get status: 400 Bad Request error</p> <pre><code>{ &quot;user&quot;: { &quot;email&quot;: [ &quot;user with this email already exists.&quot; ] } } </code></pre> <p>using patch instead of put or partial=True doesn't change anything I still get this error. What can I do here?</p>
[ { "answer_id": 74457745, "author": "lord stock", "author_id": 14689289, "author_profile": "https://Stackoverflow.com/users/14689289", "pm_score": 1, "selected": false, "text": "class ProfileSerializer(serializers.ModelSerializer):\n user = CurrentUserSerializer()\n\n def update(self, instance, validated_data):\n user_data = validated_data.pop('user')\n try:\n user=User.objects.get(pk=instance.user.id)\n except User.DoesNotExist:\n raise ValidationError(\"User already exist\")\n #now with user instance you can save the email or do whatever \n you want\n user.email = \"xyaz@gmail.com\")\n user.save()\n\n \n \n \n \n instance.phone = validated_data.get('phone', instance.phone)\n instance.birth_date = validated_data.get('birth_date', instance.birth_date)\n instance.about = validated_data.get('about', instance.about)\n instance.save()\n return instance\n\n class Meta:\n model = Profile\n fields = [\n 'id',\n 'user',\n 'phone',\n 'birth_date',\n 'about',\n\n ]\n" }, { "answer_id": 74479559, "author": "Ryan", "author_id": 10468368, "author_profile": "https://Stackoverflow.com/users/10468368", "pm_score": 1, "selected": true, "text": "class ProfileSerializer(serializers.ModelSerializer):\n email = serializers.EmailField(source='user.email')\n first_name = serializers.CharField(source='user.first_name')\n last_name = serializers.CharField(source='user.last_name')\n\n def update(self, instance, validated_data):\n user_data = validated_data.pop('user')\n user = instance.user\n\n user_ser = CurrentUserSerializer(instance=user, data=user_data)\n if user_ser.is_valid():\n user_ser.save()\n\n instance.phone = validated_data.get('phone', instance.phone)\n instance.birth_date = validated_data.get('birth_date', instance.birth_date)\n instance.about = validated_data.get('about', instance.about)\n instance.save()\n \n\n class Meta:\n model = Profile\n fields = [\n 'id',\n 'email',\n 'first_name',\n 'last_name',\n 'phone',\n 'birth_date',\n 'about',\n\n ]\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456955", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10468368/" ]
74,456,959
<p>As an R-beginner, there's one hurdle that I just can't find the answer to. I have a table where I can see the amount of responses to a question according to gender.</p> <div class="s-table-container"> <table class="s-table"> <thead> <tr> <th>Response</th> <th>Gender</th> <th>n</th> </tr> </thead> <tbody> <tr> <td>1</td> <td>1</td> <td>84</td> </tr> <tr> <td>1</td> <td>2</td> <td>79</td> </tr> <tr> <td>2</td> <td>1</td> <td>42</td> </tr> <tr> <td>2</td> <td>2</td> <td>74</td> </tr> <tr> <td>3</td> <td>1</td> <td>84</td> </tr> <tr> <td>3</td> <td>2</td> <td>79</td> </tr> </tbody> </table> </div> <p>etc.</p> <p>I want to plot these in a column chart: on the y I want the n (or its proportions), and on the x I want to have two seperate bars: one for gender 1, and one for gender 2. It should look like the following example that I was given:</p> <p><a href="https://i.stack.imgur.com/1VHaH.png" rel="nofollow noreferrer">The example that I want to emulate</a></p> <p>However, when I try to filter the columns according to gender inside aes(), it returns an error! Could anyone tell me why my approach is not working? And is there another practical way to filter the columns of the table that I have?</p> <pre><code>ggplot(table) + geom_col(aes(x = select(filter(table, gender == 1), Q), y = select(filter(table, gender == 1), n), fill = select(filter(table, gender == 2), n), position = &quot;dodge&quot;) </code></pre>
[ { "answer_id": 74457745, "author": "lord stock", "author_id": 14689289, "author_profile": "https://Stackoverflow.com/users/14689289", "pm_score": 1, "selected": false, "text": "class ProfileSerializer(serializers.ModelSerializer):\n user = CurrentUserSerializer()\n\n def update(self, instance, validated_data):\n user_data = validated_data.pop('user')\n try:\n user=User.objects.get(pk=instance.user.id)\n except User.DoesNotExist:\n raise ValidationError(\"User already exist\")\n #now with user instance you can save the email or do whatever \n you want\n user.email = \"xyaz@gmail.com\")\n user.save()\n\n \n \n \n \n instance.phone = validated_data.get('phone', instance.phone)\n instance.birth_date = validated_data.get('birth_date', instance.birth_date)\n instance.about = validated_data.get('about', instance.about)\n instance.save()\n return instance\n\n class Meta:\n model = Profile\n fields = [\n 'id',\n 'user',\n 'phone',\n 'birth_date',\n 'about',\n\n ]\n" }, { "answer_id": 74479559, "author": "Ryan", "author_id": 10468368, "author_profile": "https://Stackoverflow.com/users/10468368", "pm_score": 1, "selected": true, "text": "class ProfileSerializer(serializers.ModelSerializer):\n email = serializers.EmailField(source='user.email')\n first_name = serializers.CharField(source='user.first_name')\n last_name = serializers.CharField(source='user.last_name')\n\n def update(self, instance, validated_data):\n user_data = validated_data.pop('user')\n user = instance.user\n\n user_ser = CurrentUserSerializer(instance=user, data=user_data)\n if user_ser.is_valid():\n user_ser.save()\n\n instance.phone = validated_data.get('phone', instance.phone)\n instance.birth_date = validated_data.get('birth_date', instance.birth_date)\n instance.about = validated_data.get('about', instance.about)\n instance.save()\n \n\n class Meta:\n model = Profile\n fields = [\n 'id',\n 'email',\n 'first_name',\n 'last_name',\n 'phone',\n 'birth_date',\n 'about',\n\n ]\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74456959", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20517558/" ]
74,457,003
<p>I need to generate a yaml file and want to use python to do that. This (<a href="https://stackoverflow.com/questions/12470665/how-can-i-write-data-in-yaml-format-in-a-file">How can I write data in YAML format in a file?</a>) helped me a lot but I am missing a few more steps.</p> <p>I want to have something like this in the end:</p> <pre><code>- A: a B: C: c D: d E: e </code></pre> <p>This:</p> <pre><code>d = {'- A':'a', 'B':{'C':'c', 'D':'d', 'E':'e'}} with open('result.yml', 'w') as yaml_file: yaml.dump(d, yaml_file, default_flow_style=False) </code></pre> <p>gives me this:</p> <pre><code>'- A': a B: C: 'c' D: 'd' E: 'e' </code></pre> <p>I have a couple problems here.</p> <ol> <li>I need the dash before A, but in this way - A is in '' , next rows are not</li> <li>Indention is wrong. B, C, D and E need to go one indent to the right (if the ' in front of A goes away...) B needs to start right under A</li> </ol> <p>For another step I would need some more, finally I want do have:</p> <pre><code>steps - A: a B: C: c D: d E: e - A: a1 B: C: c1 D: d1 E: e1 - A: a2 B: C: c2 D: d2 E: e2 .... </code></pre> <p>Can someone help?</p>
[ { "answer_id": 74457074, "author": "bereal", "author_id": 770830, "author_profile": "https://Stackoverflow.com/users/770830", "pm_score": 3, "selected": true, "text": "- A:" }, { "answer_id": 74457084, "author": "timgeb", "author_id": 3620003, "author_profile": "https://Stackoverflow.com/users/3620003", "pm_score": 1, "selected": false, "text": ">>> import yaml\n>>> l = [{'A':'a', 'B':{'C':'c', 'D':'d', 'E':'e'}}]\n>>> print(yaml.dump(l))\n- A: a\n B:\n C: c\n D: d\n E: e\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457003", "https://Stackoverflow.com", "https://Stackoverflow.com/users/14800042/" ]
74,457,015
<p>I try to put a &quot;processing...&quot; text before the a calculation start, but Kotlin code finishing before the layout text change.</p> <pre><code>var watcher: TextWatcher = object : TextWatcher { override fun beforeTextChanged( s: CharSequence?, start: Int, count: Int, after: Int ) { } override fun onTextChanged(s: CharSequence?, start: Int, before: Int, count: Int) { } override fun afterTextChanged(s: Editable?) { val text = binding.textInput.text.toString() if (text != &quot;0&quot;) binding.prime.text =&quot;processing...&quot; binding.prime.text = foundNPrime(text) } } binding.textInput.addTextChangedListener(watcher) </code></pre> <p>How can I change first the layout text?</p>
[ { "answer_id": 74457074, "author": "bereal", "author_id": 770830, "author_profile": "https://Stackoverflow.com/users/770830", "pm_score": 3, "selected": true, "text": "- A:" }, { "answer_id": 74457084, "author": "timgeb", "author_id": 3620003, "author_profile": "https://Stackoverflow.com/users/3620003", "pm_score": 1, "selected": false, "text": ">>> import yaml\n>>> l = [{'A':'a', 'B':{'C':'c', 'D':'d', 'E':'e'}}]\n>>> print(yaml.dump(l))\n- A: a\n B:\n C: c\n D: d\n E: e\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457015", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20517694/" ]
74,457,020
<p>I've got a ScrollView nested in an absolute positioned View that is bigger then it's parent. The scrolling works fine if I press inside that parent, but when I go outside it, it's not handling the touches. How can I get around this?</p> <p><a href="https://i.stack.imgur.com/zVSQx.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/zVSQx.png" alt="enter image description here" /></a><br /> I can't scroll if I touch the screen below the green line.</p> <p>Code to reproduce:</p> <pre><code>&lt;View style={{flex: 1, justifyContent: &quot;center&quot;, alignItems: &quot;center&quot;}}&gt; &lt;View style={{width: &quot;80%&quot;, height: 150, borderWidth: 1}}&gt; &lt;View style={{position: 'absolute', height: 400, width: &quot;80%&quot;, backgroundColor: &quot;green&quot;, alignSelf: &quot;center&quot;}}&gt; &lt;ScrollView&gt; &lt;View style={{height: 200, backgroundColor: &quot;red&quot;}} /&gt; &lt;View style={{height: 200, backgroundColor: &quot;blue&quot;}} /&gt; &lt;View style={{height: 200, backgroundColor: &quot;yellow&quot;}} /&gt; &lt;/ScrollView&gt; &lt;/View&gt; &lt;/View&gt; &lt;/View&gt; </code></pre> <p>Expo Snack: <a href="https://snack.expo.dev/uV88qpP7f" rel="nofollow noreferrer">https://snack.expo.dev/uV88qpP7f</a> (Happens on android)</p>
[ { "answer_id": 74487368, "author": "Farbod Shabani", "author_id": 14712252, "author_profile": "https://Stackoverflow.com/users/14712252", "pm_score": -1, "selected": false, "text": "import * as React from 'react';\nimport { Text, View, StyleSheet, ScrollView } from 'react-native';\nimport Constants from 'expo-constants';\n\n// You can import from local files\nimport AssetExample from './components/AssetExample';\n\n// or any pure javascript modules available in npm\nimport { Card } from 'react-native-paper';\n\nexport default function App() {\nconst customHeight = 400; //change this based on your needs\n\n\nreturn (\n<View style={{flex: 1, justifyContent: \"center\", alignItems: \"center\"}}>\n <View style={{width: \"80%\", height: 150, borderWidth: 1}}>\n <View style={{position: 'absolute', height: customHeight, width: \"80%\", backgroundColor: \"green\", alignSelf: \"center\"}}>\n <ScrollView style={{backgroundColor: \"grey\", height: 600}}>\n <View style={{height: 200, backgroundColor: \"red\"}} />\n <View style={{height: 200, backgroundColor: \"blue\"}} />\n <View style={{height: 200, backgroundColor: \"yellow\"}} />\n </ScrollView>\n </View>\n </View>\n</View>\n);\n}\n" }, { "answer_id": 74494081, "author": "Cory Cunningham", "author_id": 10236353, "author_profile": "https://Stackoverflow.com/users/10236353", "pm_score": 0, "selected": false, "text": "import { useState } from 'react';\nimport {\n View,\n StyleSheet,\n Pressable,\n Text,\n ScrollView,\n FlatList,\n} from 'react-native';\nimport Constants from 'expo-constants';\nimport { Feather } from '@expo/vector-icons';\n\nconst data = [\n {\n color: 'red',\n },\n {\n color: 'blue',\n },\n {\n color: 'orange',\n },\n {\n color: 'green',\n },\n {\n color: 'pink',\n },\n];\n\nexport default function App() {\n const [value, setValue] = useState('Press me!');\n const [heightOfButton, setHeightOfButton] = useState(0);\n const [heightOfContainer, setHeightOfContainer] = useState(0);\n const [shouldShow, setShouldShow] = useState(true);\n // android handles the padding a bit strange but I feel like this is close to what you're looking for.\n const scrollPosition = heightOfContainer + 12 + heightOfButton\n\n return (\n <View style={styles.container}>\n <View\n onLayout={(e) =>\n setHeightOfContainer(e.nativeEvent.layout.y)\n }\n style={styles.card}>\n <Pressable\n onLayout={(e) =>\n setHeightOfButton(e.nativeEvent.layout.height)\n }\n onPress={() => setShouldShow(true)}\n style={styles.button}>\n <Text>{value}</Text>\n <Feather name=\"chevron-down\" size={24} />\n </Pressable>\n </View>\n {shouldShow ? (\n <FlatList\n style={{\n position: 'absolute',\n top: scrollPosition,\n height: 400,\n width: '80%',\n backgroundColor: 'green',\n alignSelf: 'center',\n }}\n data={data}\n renderItem={({ item }) => (\n <Pressable\n onPress={() => {\n setValue(item.color);\n setShouldShow(false);\n }}\n style={{ height: 200, backgroundColor: item.color }}\n />\n )}\n />\n ) : null}\n {/*<ScrollView \n style={{ \n position: 'absolute',\n bottom: height,\n height: 400, \n width: \"80%\", \n backgroundColor: \"green\", \n alignSelf: \"center\"\n }}>\n <View style={{height: 200, backgroundColor: \"red\"}} />\n <View style={{height: 200, backgroundColor: \"blue\"}} />\n <View style={{height: 200, backgroundColor: \"yellow\"}} />\n </ScrollView> */}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'center',\n paddingTop: Constants.statusBarHeight,\n backgroundColor: 'lightblue',\n padding: 8,\n },\n card: {\n backgroundColor: 'white',\n height: '30%',\n borderRadius: 8,\n padding: 12,\n },\n button: {\n width: '100%',\n borderColor: 'black',\n borderRadius: 8,\n borderWidth: 1,\n padding: 12,\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n },\n});\n" }, { "answer_id": 74530534, "author": "Xhirazi", "author_id": 6890414, "author_profile": "https://Stackoverflow.com/users/6890414", "pm_score": 1, "selected": false, "text": "<View style={{flex: 1, justifyContent: \"center\", alignItems: \"center\"}}>\n <View style={{width: \"80%\"}}>\n <View style={{ height: 150, borderWidth: 1}}/>\n <View style={{position: 'absolute', height: 400, width: \"80%\", backgroundColor: \"green\", alignSelf: \"center\"}}>\n <ScrollView>\n <View style={{height: 200, backgroundColor: \"red\"}} />\n <View style={{height: 200, backgroundColor: \"blue\"}} />\n <View style={{height: 200, backgroundColor: \"yellow\"}} />\n </ScrollView>\n </View>\n </View>\n</View>\n" }, { "answer_id": 74532209, "author": "Muhammad Numan", "author_id": 8079868, "author_profile": "https://Stackoverflow.com/users/8079868", "pm_score": 2, "selected": true, "text": "Box" }, { "answer_id": 74532970, "author": "Furkan KARABABA", "author_id": 20459130, "author_profile": "https://Stackoverflow.com/users/20459130", "pm_score": -1, "selected": false, "text": "export default function App() {\n return (\n <View style={{flex: 1, justifyContent: \"center\", alignItems: \"center\"}}>\n <View style={{width: \"80%\", height: 150, borderWidth: 1, backgroundColor: \"green\"}}>\n <ScrollView>\n <View style={{height: 70, backgroundColor: \"red\"}} />\n <View style={{height: 70, backgroundColor: \"blue\"}} />\n <View style={{height: 70, backgroundColor: \"yellow\"}} />\n </ScrollView>\n </View>\n </View>\n );\n}" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457020", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17873944/" ]
74,457,039
<p>I need to delete a parent div on click child icon. For achieving this I'm using for loop for select all parent element and inside it I'm using function for deleting but I unable to understand where am making mistake. Right now I'm only able to delete one card but not every card.</p> <p>css</p> <pre><code>.box { background:red; padding:10px; width:200px; display:none; } .selection-row { background:yellow; margin-bottom:10px; } .delete-selection-btn { background:red; width:150px; padding:20px; } </code></pre> <p>HTML</p> <pre><code>&lt;div class=&quot;mycards delete-row-btn&quot;&gt; &lt;div class=&quot;selection-row selectionRow&quot; &gt; Hell Shubham This is the data &lt;div class=&quot;accordion accordion-btn active&quot; &gt; &lt;div class=&quot;my-details&quot; &gt; &lt;div class=&quot;delete-selection-btn&quot; onclick=&quot;deleteRow()&quot; id=&quot;Div4&quot;&gt; X1 &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;mycards delete-row-btn&quot;&gt; &lt;div class=&quot;selection-row selectionRow&quot; &gt; Hell Shubham This is the data &lt;div class=&quot;accordion accordion-btn active&quot; &gt; &lt;div class=&quot;my-details&quot; &gt; &lt;div class=&quot;delete-selection-btn&quot; onclick=&quot;deleteRow()&quot; id=&quot;Div1&quot;&gt; X2 &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;div class=&quot;mycards delete-row-btn&quot;&gt; &lt;div class=&quot;selection-row selectionRow&quot; &gt; Hell Shubham This is the data &lt;div class=&quot;accordion accordion-btn active&quot; &gt; &lt;div class=&quot;my-details&quot; &gt; &lt;div class=&quot;delete-selection-btn&quot; onclick=&quot;deleteRow()&quot; id=&quot;Div2&quot;&gt; X3 &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>JS</p> <pre><code>&lt;script&gt; var selectionRow = document.getElementsByClassName('selectionRow'); //var child = document.getElementById('selectionRow'); for (i = 0; i &lt; selectionRow.length; i++) { var x = selectionRow[i]; function deleteRow() { x.parentElement.remove(); } } &lt;/script&gt; </code></pre>
[ { "answer_id": 74487368, "author": "Farbod Shabani", "author_id": 14712252, "author_profile": "https://Stackoverflow.com/users/14712252", "pm_score": -1, "selected": false, "text": "import * as React from 'react';\nimport { Text, View, StyleSheet, ScrollView } from 'react-native';\nimport Constants from 'expo-constants';\n\n// You can import from local files\nimport AssetExample from './components/AssetExample';\n\n// or any pure javascript modules available in npm\nimport { Card } from 'react-native-paper';\n\nexport default function App() {\nconst customHeight = 400; //change this based on your needs\n\n\nreturn (\n<View style={{flex: 1, justifyContent: \"center\", alignItems: \"center\"}}>\n <View style={{width: \"80%\", height: 150, borderWidth: 1}}>\n <View style={{position: 'absolute', height: customHeight, width: \"80%\", backgroundColor: \"green\", alignSelf: \"center\"}}>\n <ScrollView style={{backgroundColor: \"grey\", height: 600}}>\n <View style={{height: 200, backgroundColor: \"red\"}} />\n <View style={{height: 200, backgroundColor: \"blue\"}} />\n <View style={{height: 200, backgroundColor: \"yellow\"}} />\n </ScrollView>\n </View>\n </View>\n</View>\n);\n}\n" }, { "answer_id": 74494081, "author": "Cory Cunningham", "author_id": 10236353, "author_profile": "https://Stackoverflow.com/users/10236353", "pm_score": 0, "selected": false, "text": "import { useState } from 'react';\nimport {\n View,\n StyleSheet,\n Pressable,\n Text,\n ScrollView,\n FlatList,\n} from 'react-native';\nimport Constants from 'expo-constants';\nimport { Feather } from '@expo/vector-icons';\n\nconst data = [\n {\n color: 'red',\n },\n {\n color: 'blue',\n },\n {\n color: 'orange',\n },\n {\n color: 'green',\n },\n {\n color: 'pink',\n },\n];\n\nexport default function App() {\n const [value, setValue] = useState('Press me!');\n const [heightOfButton, setHeightOfButton] = useState(0);\n const [heightOfContainer, setHeightOfContainer] = useState(0);\n const [shouldShow, setShouldShow] = useState(true);\n // android handles the padding a bit strange but I feel like this is close to what you're looking for.\n const scrollPosition = heightOfContainer + 12 + heightOfButton\n\n return (\n <View style={styles.container}>\n <View\n onLayout={(e) =>\n setHeightOfContainer(e.nativeEvent.layout.y)\n }\n style={styles.card}>\n <Pressable\n onLayout={(e) =>\n setHeightOfButton(e.nativeEvent.layout.height)\n }\n onPress={() => setShouldShow(true)}\n style={styles.button}>\n <Text>{value}</Text>\n <Feather name=\"chevron-down\" size={24} />\n </Pressable>\n </View>\n {shouldShow ? (\n <FlatList\n style={{\n position: 'absolute',\n top: scrollPosition,\n height: 400,\n width: '80%',\n backgroundColor: 'green',\n alignSelf: 'center',\n }}\n data={data}\n renderItem={({ item }) => (\n <Pressable\n onPress={() => {\n setValue(item.color);\n setShouldShow(false);\n }}\n style={{ height: 200, backgroundColor: item.color }}\n />\n )}\n />\n ) : null}\n {/*<ScrollView \n style={{ \n position: 'absolute',\n bottom: height,\n height: 400, \n width: \"80%\", \n backgroundColor: \"green\", \n alignSelf: \"center\"\n }}>\n <View style={{height: 200, backgroundColor: \"red\"}} />\n <View style={{height: 200, backgroundColor: \"blue\"}} />\n <View style={{height: 200, backgroundColor: \"yellow\"}} />\n </ScrollView> */}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'center',\n paddingTop: Constants.statusBarHeight,\n backgroundColor: 'lightblue',\n padding: 8,\n },\n card: {\n backgroundColor: 'white',\n height: '30%',\n borderRadius: 8,\n padding: 12,\n },\n button: {\n width: '100%',\n borderColor: 'black',\n borderRadius: 8,\n borderWidth: 1,\n padding: 12,\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n },\n});\n" }, { "answer_id": 74530534, "author": "Xhirazi", "author_id": 6890414, "author_profile": "https://Stackoverflow.com/users/6890414", "pm_score": 1, "selected": false, "text": "<View style={{flex: 1, justifyContent: \"center\", alignItems: \"center\"}}>\n <View style={{width: \"80%\"}}>\n <View style={{ height: 150, borderWidth: 1}}/>\n <View style={{position: 'absolute', height: 400, width: \"80%\", backgroundColor: \"green\", alignSelf: \"center\"}}>\n <ScrollView>\n <View style={{height: 200, backgroundColor: \"red\"}} />\n <View style={{height: 200, backgroundColor: \"blue\"}} />\n <View style={{height: 200, backgroundColor: \"yellow\"}} />\n </ScrollView>\n </View>\n </View>\n</View>\n" }, { "answer_id": 74532209, "author": "Muhammad Numan", "author_id": 8079868, "author_profile": "https://Stackoverflow.com/users/8079868", "pm_score": 2, "selected": true, "text": "Box" }, { "answer_id": 74532970, "author": "Furkan KARABABA", "author_id": 20459130, "author_profile": "https://Stackoverflow.com/users/20459130", "pm_score": -1, "selected": false, "text": "export default function App() {\n return (\n <View style={{flex: 1, justifyContent: \"center\", alignItems: \"center\"}}>\n <View style={{width: \"80%\", height: 150, borderWidth: 1, backgroundColor: \"green\"}}>\n <ScrollView>\n <View style={{height: 70, backgroundColor: \"red\"}} />\n <View style={{height: 70, backgroundColor: \"blue\"}} />\n <View style={{height: 70, backgroundColor: \"yellow\"}} />\n </ScrollView>\n </View>\n </View>\n );\n}" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457039", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15232179/" ]
74,457,079
<p>I would like to know what is the best way to use SVG on an HTML document.</p> <p>I've read an article that states, <em><strong>it's better to use SVG icons than icon fonts</strong></em> (i.e fontawesome etc) for better performance &amp; to reduce HTTP (network) calls. And to boost SEO also.</p> <hr /> <p>I know how to used/include SVG, but I have a few concerns, especially on performance and reduce network requests.</p> <p>The most common one to use <code>&lt;img src=&quot;facebook.svg&quot;&gt;</code> tag. Which I usually see from dev tools on some websites.</p> <p>The other one is, by using <code>&lt;svg xmlns=&quot;&quot;&gt;&lt;path&gt;&lt;/svg&gt;</code> tag and,</p> <p>The last one is, I put all the SVG on one single .SVG file (Sprite) and import them</p> <pre><code>&lt;svg class=&quot;svg__icon&quot;&gt; &lt;use href=&quot;sprite.svg#facebook-icon&quot;&gt; &lt;/svg&gt; </code></pre> <p><code>sprite.svg</code></p> <pre><code>&lt;svg xmlns=&quot;http://www.w3.org/2000/svg&quot;&gt; &lt;defs&gt; &lt;symbol id=&quot;user&quot; viewBox=&quot;0 0 24 24&quot;&gt; &lt;title&gt;User&lt;/title&gt; &lt;path fill=&quot;none&quot; d=&quot;M0 0h24v24H0z&quot;/&gt; &lt;path d=&quot;M4 22a8 8 0 1 1 16 0h-2a6 6 0 1 0-12 0H4zm8-9c-3.315 0-6-2.685-6-6s2.685-6 6-6 6 2.685 6 6-2.685 6-6 6zm0-2c2.21 0 4-1.79 4-4s-1.79-4-4-4-4 1.79-4 4 1.79 4 4 4z&quot;/&gt; &lt;/symbol&gt; &lt;symbol id=&quot;facebook-icon&quot; viewBox=&quot;0 0 24 24&quot;&gt; &lt;title&gt;Facebook&lt;/title&gt; &lt;path fill=&quot;none&quot; d=&quot;M0 0h24v24H0z&quot;/&gt; &lt;path d=&quot;M14 13.5h2.5l1-4H14v-2c0-1.03 0-2 2-2h1.5V2.14c-.326-.043-1.557-.14-2.857-.14C11.928 2 10 3.657 10 6.7v2.8H7v4h3V22h4v-8.5z&quot;/&gt; &lt;/symbol&gt; &lt;symbol id=&quot;instagram-icon&quot; viewBox=&quot;0 0 24 24&quot;&gt; &lt;title&gt;Instagram&lt;/title&gt; &lt;path fill=&quot;none&quot; d=&quot;M0 0h24v24H0z&quot;/&gt; &lt;path d=&quot;M12 2c2.717 0 3.056.01 4.122.06 1.065.05 1.79.217 2.428.465.66.254 1.216.598 1.772 1.153a4.908 4.908 0 0 1 1.153 1.772c.247.637.415 1.363.465 2.428.047 1.066.06 1.405.06 4.122 0 2.717-.01 3.056-.06 4.122-.05 1.065-.218 1.79-.465 2.428a4.883 4.883 0 0 1-1.153 1.772 4.915 4.915 0 0 1-1.772 1.153c-.637.247-1.363.415-2.428.465-1.066.047-1.405.06-4.122.06-2.717 0-3.056-.01-4.122-.06-1.065-.05-1.79-.218-2.428-.465a4.89 4.89 0 0 1-1.772-1.153 4.904 4.904 0 0 1-1.153-1.772c-.248-.637-.415-1.363-.465-2.428C2.013 15.056 2 14.717 2 12c0-2.717.01-3.056.06-4.122.05-1.066.217-1.79.465-2.428a4.88 4.88 0 0 1 1.153-1.772A4.897 4.897 0 0 1 5.45 2.525c.638-.248 1.362-.415 2.428-.465C8.944 2.013 9.283 2 12 2zm0 5a5 5 0 1 0 0 10 5 5 0 0 0 0-10zm6.5-.25a1.25 1.25 0 0 0-2.5 0 1.25 1.25 0 0 0 2.5 0zM12 9a3 3 0 1 1 0 6 3 3 0 0 1 0-6z&quot;/&gt; &lt;/symbol&gt; &lt;symbol id=&quot;twitter-icon&quot; viewBox=&quot;0 0 24 24&quot;&gt; &lt;title&gt;Twitter&lt;/title&gt; &lt;path fill=&quot;none&quot; d=&quot;M0 0h24v24H0z&quot;/&gt; &lt;path d=&quot;M22.162 5.656a8.384 8.384 0 0 1-2.402.658A4.196 4.196 0 0 0 21.6 4c-.82.488-1.719.83-2.656 1.015a4.182 4.182 0 0 0-7.126 3.814 11.874 11.874 0 0 1-8.62-4.37 4.168 4.168 0 0 0-.566 2.103c0 1.45.738 2.731 1.86 3.481a4.168 4.168 0 0 1-1.894-.523v.052a4.185 4.185 0 0 0 3.355 4.101 4.21 4.21 0 0 1-1.89.072A4.185 4.185 0 0 0 7.97 16.65a8.394 8.394 0 0 1-6.191 1.732 11.83 11.83 0 0 0 6.41 1.88c7.693 0 11.9-6.373 11.9-11.9 0-.18-.005-.362-.013-.54a8.496 8.496 0 0 0 2.087-2.165z&quot;/&gt; &lt;/symbol&gt; &lt;symbol id=&quot;youtube-icon&quot; viewBox=&quot;0 0 24 24&quot;&gt; &lt;title&gt;YouTube&lt;/title&gt; &lt;path fill=&quot;none&quot; d=&quot;M0 0h24v24H0z&quot;/&gt; &lt;path d=&quot;M21.543 6.498C22 8.28 22 12 22 12s0 3.72-.457 5.502c-.254.985-.997 1.76-1.938 2.022C17.896 20 12 20 12 20s-5.893 0-7.605-.476c-.945-.266-1.687-1.04-1.938-2.022C2 15.72 2 12 2 12s0-3.72.457-5.502c.254-.985.997-1.76 1.938-2.022C6.107 4 12 4 12 4s5.896 0 7.605.476c.945.266 1.687 1.04 1.938 2.022zM10 15.5l6-3.5-6-3.5v7z&quot;/&gt; &lt;/symbol&gt; &lt;symbol id=&quot;pinterest-icon&quot; viewBox=&quot;0 0 24 24&quot;&gt; &lt;title&gt;Pinterest&lt;/title&gt; &lt;path fill=&quot;none&quot; d=&quot;M0 0h24v24H0z&quot;/&gt; &lt;path d=&quot;M13.37 2.094A10.003 10.003 0 0 0 8.002 21.17a7.757 7.757 0 0 1 .163-2.293c.185-.839 1.296-5.463 1.296-5.463a3.739 3.739 0 0 1-.324-1.577c0-1.485.857-2.593 1.923-2.593a1.334 1.334 0 0 1 1.342 1.508c0 .9-.578 2.262-.88 3.54a1.544 1.544 0 0 0 1.575 1.923c1.898 0 3.17-2.431 3.17-5.301 0-2.2-1.457-3.848-4.143-3.848a4.746 4.746 0 0 0-4.93 4.794 2.96 2.96 0 0 0 .648 1.97.48.48 0 0 1 .162.554c-.046.184-.162.623-.208.784a.354.354 0 0 1-.51.254c-1.384-.554-2.036-2.077-2.036-3.816 0-2.847 2.384-6.255 7.154-6.255 3.796 0 6.32 2.777 6.32 5.747 0 3.909-2.177 6.848-5.394 6.848a2.861 2.861 0 0 1-2.454-1.246s-.578 2.316-.692 2.754a8.026 8.026 0 0 1-1.019 2.131c.923.28 1.882.42 2.846.416a9.988 9.988 0 0 0 9.996-10.003 10.002 10.002 0 0 0-8.635-9.903z&quot;/&gt; &lt;/symbol&gt; &lt;/defs&gt; &lt;/svg&gt; </code></pre> <p>Why would I like to put them on a single sprite? I would you to <strong><code>preload</code></strong> it. If this method/technique is possible.</p> <pre><code>&lt;link rel=&quot;preload&quot; as=&quot;image&quot; href=&quot;sprite.svg&quot;&gt; </code></pre> <hr /> <p>Any suggestions/corrections (upside &amp; downside) are appreciated, just a concerned about the SEO task I was assigned to.</p>
[ { "answer_id": 74487368, "author": "Farbod Shabani", "author_id": 14712252, "author_profile": "https://Stackoverflow.com/users/14712252", "pm_score": -1, "selected": false, "text": "import * as React from 'react';\nimport { Text, View, StyleSheet, ScrollView } from 'react-native';\nimport Constants from 'expo-constants';\n\n// You can import from local files\nimport AssetExample from './components/AssetExample';\n\n// or any pure javascript modules available in npm\nimport { Card } from 'react-native-paper';\n\nexport default function App() {\nconst customHeight = 400; //change this based on your needs\n\n\nreturn (\n<View style={{flex: 1, justifyContent: \"center\", alignItems: \"center\"}}>\n <View style={{width: \"80%\", height: 150, borderWidth: 1}}>\n <View style={{position: 'absolute', height: customHeight, width: \"80%\", backgroundColor: \"green\", alignSelf: \"center\"}}>\n <ScrollView style={{backgroundColor: \"grey\", height: 600}}>\n <View style={{height: 200, backgroundColor: \"red\"}} />\n <View style={{height: 200, backgroundColor: \"blue\"}} />\n <View style={{height: 200, backgroundColor: \"yellow\"}} />\n </ScrollView>\n </View>\n </View>\n</View>\n);\n}\n" }, { "answer_id": 74494081, "author": "Cory Cunningham", "author_id": 10236353, "author_profile": "https://Stackoverflow.com/users/10236353", "pm_score": 0, "selected": false, "text": "import { useState } from 'react';\nimport {\n View,\n StyleSheet,\n Pressable,\n Text,\n ScrollView,\n FlatList,\n} from 'react-native';\nimport Constants from 'expo-constants';\nimport { Feather } from '@expo/vector-icons';\n\nconst data = [\n {\n color: 'red',\n },\n {\n color: 'blue',\n },\n {\n color: 'orange',\n },\n {\n color: 'green',\n },\n {\n color: 'pink',\n },\n];\n\nexport default function App() {\n const [value, setValue] = useState('Press me!');\n const [heightOfButton, setHeightOfButton] = useState(0);\n const [heightOfContainer, setHeightOfContainer] = useState(0);\n const [shouldShow, setShouldShow] = useState(true);\n // android handles the padding a bit strange but I feel like this is close to what you're looking for.\n const scrollPosition = heightOfContainer + 12 + heightOfButton\n\n return (\n <View style={styles.container}>\n <View\n onLayout={(e) =>\n setHeightOfContainer(e.nativeEvent.layout.y)\n }\n style={styles.card}>\n <Pressable\n onLayout={(e) =>\n setHeightOfButton(e.nativeEvent.layout.height)\n }\n onPress={() => setShouldShow(true)}\n style={styles.button}>\n <Text>{value}</Text>\n <Feather name=\"chevron-down\" size={24} />\n </Pressable>\n </View>\n {shouldShow ? (\n <FlatList\n style={{\n position: 'absolute',\n top: scrollPosition,\n height: 400,\n width: '80%',\n backgroundColor: 'green',\n alignSelf: 'center',\n }}\n data={data}\n renderItem={({ item }) => (\n <Pressable\n onPress={() => {\n setValue(item.color);\n setShouldShow(false);\n }}\n style={{ height: 200, backgroundColor: item.color }}\n />\n )}\n />\n ) : null}\n {/*<ScrollView \n style={{ \n position: 'absolute',\n bottom: height,\n height: 400, \n width: \"80%\", \n backgroundColor: \"green\", \n alignSelf: \"center\"\n }}>\n <View style={{height: 200, backgroundColor: \"red\"}} />\n <View style={{height: 200, backgroundColor: \"blue\"}} />\n <View style={{height: 200, backgroundColor: \"yellow\"}} />\n </ScrollView> */}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'center',\n paddingTop: Constants.statusBarHeight,\n backgroundColor: 'lightblue',\n padding: 8,\n },\n card: {\n backgroundColor: 'white',\n height: '30%',\n borderRadius: 8,\n padding: 12,\n },\n button: {\n width: '100%',\n borderColor: 'black',\n borderRadius: 8,\n borderWidth: 1,\n padding: 12,\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n },\n});\n" }, { "answer_id": 74530534, "author": "Xhirazi", "author_id": 6890414, "author_profile": "https://Stackoverflow.com/users/6890414", "pm_score": 1, "selected": false, "text": "<View style={{flex: 1, justifyContent: \"center\", alignItems: \"center\"}}>\n <View style={{width: \"80%\"}}>\n <View style={{ height: 150, borderWidth: 1}}/>\n <View style={{position: 'absolute', height: 400, width: \"80%\", backgroundColor: \"green\", alignSelf: \"center\"}}>\n <ScrollView>\n <View style={{height: 200, backgroundColor: \"red\"}} />\n <View style={{height: 200, backgroundColor: \"blue\"}} />\n <View style={{height: 200, backgroundColor: \"yellow\"}} />\n </ScrollView>\n </View>\n </View>\n</View>\n" }, { "answer_id": 74532209, "author": "Muhammad Numan", "author_id": 8079868, "author_profile": "https://Stackoverflow.com/users/8079868", "pm_score": 2, "selected": true, "text": "Box" }, { "answer_id": 74532970, "author": "Furkan KARABABA", "author_id": 20459130, "author_profile": "https://Stackoverflow.com/users/20459130", "pm_score": -1, "selected": false, "text": "export default function App() {\n return (\n <View style={{flex: 1, justifyContent: \"center\", alignItems: \"center\"}}>\n <View style={{width: \"80%\", height: 150, borderWidth: 1, backgroundColor: \"green\"}}>\n <ScrollView>\n <View style={{height: 70, backgroundColor: \"red\"}} />\n <View style={{height: 70, backgroundColor: \"blue\"}} />\n <View style={{height: 70, backgroundColor: \"yellow\"}} />\n </ScrollView>\n </View>\n </View>\n );\n}" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457079", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5634470/" ]
74,457,086
<p>Need to remove extra space , number, characters from start and end of the string</p> <pre><code>Column 1 11 2013US83838 2019IN353535 2 Output 2013US83838 2019IN353535 </code></pre>
[ { "answer_id": 74487368, "author": "Farbod Shabani", "author_id": 14712252, "author_profile": "https://Stackoverflow.com/users/14712252", "pm_score": -1, "selected": false, "text": "import * as React from 'react';\nimport { Text, View, StyleSheet, ScrollView } from 'react-native';\nimport Constants from 'expo-constants';\n\n// You can import from local files\nimport AssetExample from './components/AssetExample';\n\n// or any pure javascript modules available in npm\nimport { Card } from 'react-native-paper';\n\nexport default function App() {\nconst customHeight = 400; //change this based on your needs\n\n\nreturn (\n<View style={{flex: 1, justifyContent: \"center\", alignItems: \"center\"}}>\n <View style={{width: \"80%\", height: 150, borderWidth: 1}}>\n <View style={{position: 'absolute', height: customHeight, width: \"80%\", backgroundColor: \"green\", alignSelf: \"center\"}}>\n <ScrollView style={{backgroundColor: \"grey\", height: 600}}>\n <View style={{height: 200, backgroundColor: \"red\"}} />\n <View style={{height: 200, backgroundColor: \"blue\"}} />\n <View style={{height: 200, backgroundColor: \"yellow\"}} />\n </ScrollView>\n </View>\n </View>\n</View>\n);\n}\n" }, { "answer_id": 74494081, "author": "Cory Cunningham", "author_id": 10236353, "author_profile": "https://Stackoverflow.com/users/10236353", "pm_score": 0, "selected": false, "text": "import { useState } from 'react';\nimport {\n View,\n StyleSheet,\n Pressable,\n Text,\n ScrollView,\n FlatList,\n} from 'react-native';\nimport Constants from 'expo-constants';\nimport { Feather } from '@expo/vector-icons';\n\nconst data = [\n {\n color: 'red',\n },\n {\n color: 'blue',\n },\n {\n color: 'orange',\n },\n {\n color: 'green',\n },\n {\n color: 'pink',\n },\n];\n\nexport default function App() {\n const [value, setValue] = useState('Press me!');\n const [heightOfButton, setHeightOfButton] = useState(0);\n const [heightOfContainer, setHeightOfContainer] = useState(0);\n const [shouldShow, setShouldShow] = useState(true);\n // android handles the padding a bit strange but I feel like this is close to what you're looking for.\n const scrollPosition = heightOfContainer + 12 + heightOfButton\n\n return (\n <View style={styles.container}>\n <View\n onLayout={(e) =>\n setHeightOfContainer(e.nativeEvent.layout.y)\n }\n style={styles.card}>\n <Pressable\n onLayout={(e) =>\n setHeightOfButton(e.nativeEvent.layout.height)\n }\n onPress={() => setShouldShow(true)}\n style={styles.button}>\n <Text>{value}</Text>\n <Feather name=\"chevron-down\" size={24} />\n </Pressable>\n </View>\n {shouldShow ? (\n <FlatList\n style={{\n position: 'absolute',\n top: scrollPosition,\n height: 400,\n width: '80%',\n backgroundColor: 'green',\n alignSelf: 'center',\n }}\n data={data}\n renderItem={({ item }) => (\n <Pressable\n onPress={() => {\n setValue(item.color);\n setShouldShow(false);\n }}\n style={{ height: 200, backgroundColor: item.color }}\n />\n )}\n />\n ) : null}\n {/*<ScrollView \n style={{ \n position: 'absolute',\n bottom: height,\n height: 400, \n width: \"80%\", \n backgroundColor: \"green\", \n alignSelf: \"center\"\n }}>\n <View style={{height: 200, backgroundColor: \"red\"}} />\n <View style={{height: 200, backgroundColor: \"blue\"}} />\n <View style={{height: 200, backgroundColor: \"yellow\"}} />\n </ScrollView> */}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'center',\n paddingTop: Constants.statusBarHeight,\n backgroundColor: 'lightblue',\n padding: 8,\n },\n card: {\n backgroundColor: 'white',\n height: '30%',\n borderRadius: 8,\n padding: 12,\n },\n button: {\n width: '100%',\n borderColor: 'black',\n borderRadius: 8,\n borderWidth: 1,\n padding: 12,\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n },\n});\n" }, { "answer_id": 74530534, "author": "Xhirazi", "author_id": 6890414, "author_profile": "https://Stackoverflow.com/users/6890414", "pm_score": 1, "selected": false, "text": "<View style={{flex: 1, justifyContent: \"center\", alignItems: \"center\"}}>\n <View style={{width: \"80%\"}}>\n <View style={{ height: 150, borderWidth: 1}}/>\n <View style={{position: 'absolute', height: 400, width: \"80%\", backgroundColor: \"green\", alignSelf: \"center\"}}>\n <ScrollView>\n <View style={{height: 200, backgroundColor: \"red\"}} />\n <View style={{height: 200, backgroundColor: \"blue\"}} />\n <View style={{height: 200, backgroundColor: \"yellow\"}} />\n </ScrollView>\n </View>\n </View>\n</View>\n" }, { "answer_id": 74532209, "author": "Muhammad Numan", "author_id": 8079868, "author_profile": "https://Stackoverflow.com/users/8079868", "pm_score": 2, "selected": true, "text": "Box" }, { "answer_id": 74532970, "author": "Furkan KARABABA", "author_id": 20459130, "author_profile": "https://Stackoverflow.com/users/20459130", "pm_score": -1, "selected": false, "text": "export default function App() {\n return (\n <View style={{flex: 1, justifyContent: \"center\", alignItems: \"center\"}}>\n <View style={{width: \"80%\", height: 150, borderWidth: 1, backgroundColor: \"green\"}}>\n <ScrollView>\n <View style={{height: 70, backgroundColor: \"red\"}} />\n <View style={{height: 70, backgroundColor: \"blue\"}} />\n <View style={{height: 70, backgroundColor: \"yellow\"}} />\n </ScrollView>\n </View>\n </View>\n );\n}" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457086", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20437932/" ]
74,457,089
<p>I am trying to calculate the predicted r2 (using <a href="https://gist.github.com/benjaminmgross/d71f161d48378d34b6970fa6d7378837" rel="nofollow noreferrer">https://gist.github.com/benjaminmgross/d71f161d48378d34b6970fa6d7378837</a>), but the values are completely off. Even the standard r2 is not correct.</p> <p>Using the metric r2, I get 0.8191</p> <p>Using the benjamin gross method I get: r2 = -19322.08 and pred_r2 = -35204.34</p> <p>Here is scripts and dataset:</p> <pre><code>y_true = np.array(y_test) xs = X_test def press_statistic(y_true, y_pred, xs): res = y_pred - y_true hat = xs.dot(np.linalg.pinv(xs)) den = (1 - np.diagonal(hat)) sqr = np.square(res/den) return sqr.sum() def predicted_r2(y_true, y_pred, xs): press = press_statistic(y_true=y_true, y_pred=y_pred, xs=xs ) sst = np.square( y_true - y_true.mean() ).sum() return 1 - press / sst def r2(y_true, y_pred): sse = np.square( y_pred - y_true ).sum() sst = np.square( y_true - y_true.mean() ).sum() return 1 - sse/sst print(r2(y_true, y_pred)) print(predicted_r2(y_true, y_pred, xs)) </code></pre> <p>y_test</p> <pre><code>16698 -7.758248 16699 -8.007173 16700 -8.226193 16701 -8.459754 16702 -8.348888 27754 -55.125691 27755 -55.217113 27756 -55.295972 27757 -55.303383 27758 -55.442200 Name: logger, Length: 11061, dtype: float64 </code></pre> <p>y_pred</p> <pre><code>array([[ -7.21622871], [ -7.43596746], [ -7.58752355], ..., [-42.42983352], [-42.38907826], [-42.31012853]]) </code></pre> <p>X_test</p> <pre><code> DayCos YearCos ... lagged_logger106 lagged_logger107 16698 -0.279829 0.836961 ... 2.294633 2.272826 16699 -0.021815 0.837353 ... 2.158491 2.294633 16700 0.237686 0.837744 ... 2.027501 2.158491 16701 0.480989 0.838135 ... 1.745879 2.027501 16702 0.691513 0.838526 ... 1.501611 1.745879 ... ... ... ... ... 27754 -0.692563 0.486713 ... -44.717439 -44.702282 27755 -0.855665 0.486086 ... -44.918132 -44.717439 27756 -0.960456 0.485460 ... -45.132487 -44.918132 27757 -0.999793 0.484833 ... -45.458775 -45.132487 27758 -0.970995 0.484206 ... -45.672997 -45.458775 [11061 rows x 227 columns] </code></pre> <p>Can you see, what I am doing wrong? Thx! As I added the y_pred, I realised the arrays are different.. maybe that is why?</p> <pre><code></code></pre>
[ { "answer_id": 74487368, "author": "Farbod Shabani", "author_id": 14712252, "author_profile": "https://Stackoverflow.com/users/14712252", "pm_score": -1, "selected": false, "text": "import * as React from 'react';\nimport { Text, View, StyleSheet, ScrollView } from 'react-native';\nimport Constants from 'expo-constants';\n\n// You can import from local files\nimport AssetExample from './components/AssetExample';\n\n// or any pure javascript modules available in npm\nimport { Card } from 'react-native-paper';\n\nexport default function App() {\nconst customHeight = 400; //change this based on your needs\n\n\nreturn (\n<View style={{flex: 1, justifyContent: \"center\", alignItems: \"center\"}}>\n <View style={{width: \"80%\", height: 150, borderWidth: 1}}>\n <View style={{position: 'absolute', height: customHeight, width: \"80%\", backgroundColor: \"green\", alignSelf: \"center\"}}>\n <ScrollView style={{backgroundColor: \"grey\", height: 600}}>\n <View style={{height: 200, backgroundColor: \"red\"}} />\n <View style={{height: 200, backgroundColor: \"blue\"}} />\n <View style={{height: 200, backgroundColor: \"yellow\"}} />\n </ScrollView>\n </View>\n </View>\n</View>\n);\n}\n" }, { "answer_id": 74494081, "author": "Cory Cunningham", "author_id": 10236353, "author_profile": "https://Stackoverflow.com/users/10236353", "pm_score": 0, "selected": false, "text": "import { useState } from 'react';\nimport {\n View,\n StyleSheet,\n Pressable,\n Text,\n ScrollView,\n FlatList,\n} from 'react-native';\nimport Constants from 'expo-constants';\nimport { Feather } from '@expo/vector-icons';\n\nconst data = [\n {\n color: 'red',\n },\n {\n color: 'blue',\n },\n {\n color: 'orange',\n },\n {\n color: 'green',\n },\n {\n color: 'pink',\n },\n];\n\nexport default function App() {\n const [value, setValue] = useState('Press me!');\n const [heightOfButton, setHeightOfButton] = useState(0);\n const [heightOfContainer, setHeightOfContainer] = useState(0);\n const [shouldShow, setShouldShow] = useState(true);\n // android handles the padding a bit strange but I feel like this is close to what you're looking for.\n const scrollPosition = heightOfContainer + 12 + heightOfButton\n\n return (\n <View style={styles.container}>\n <View\n onLayout={(e) =>\n setHeightOfContainer(e.nativeEvent.layout.y)\n }\n style={styles.card}>\n <Pressable\n onLayout={(e) =>\n setHeightOfButton(e.nativeEvent.layout.height)\n }\n onPress={() => setShouldShow(true)}\n style={styles.button}>\n <Text>{value}</Text>\n <Feather name=\"chevron-down\" size={24} />\n </Pressable>\n </View>\n {shouldShow ? (\n <FlatList\n style={{\n position: 'absolute',\n top: scrollPosition,\n height: 400,\n width: '80%',\n backgroundColor: 'green',\n alignSelf: 'center',\n }}\n data={data}\n renderItem={({ item }) => (\n <Pressable\n onPress={() => {\n setValue(item.color);\n setShouldShow(false);\n }}\n style={{ height: 200, backgroundColor: item.color }}\n />\n )}\n />\n ) : null}\n {/*<ScrollView \n style={{ \n position: 'absolute',\n bottom: height,\n height: 400, \n width: \"80%\", \n backgroundColor: \"green\", \n alignSelf: \"center\"\n }}>\n <View style={{height: 200, backgroundColor: \"red\"}} />\n <View style={{height: 200, backgroundColor: \"blue\"}} />\n <View style={{height: 200, backgroundColor: \"yellow\"}} />\n </ScrollView> */}\n </View>\n );\n}\n\nconst styles = StyleSheet.create({\n container: {\n flex: 1,\n justifyContent: 'center',\n paddingTop: Constants.statusBarHeight,\n backgroundColor: 'lightblue',\n padding: 8,\n },\n card: {\n backgroundColor: 'white',\n height: '30%',\n borderRadius: 8,\n padding: 12,\n },\n button: {\n width: '100%',\n borderColor: 'black',\n borderRadius: 8,\n borderWidth: 1,\n padding: 12,\n flexDirection: 'row',\n alignItems: 'center',\n justifyContent: 'space-between',\n },\n});\n" }, { "answer_id": 74530534, "author": "Xhirazi", "author_id": 6890414, "author_profile": "https://Stackoverflow.com/users/6890414", "pm_score": 1, "selected": false, "text": "<View style={{flex: 1, justifyContent: \"center\", alignItems: \"center\"}}>\n <View style={{width: \"80%\"}}>\n <View style={{ height: 150, borderWidth: 1}}/>\n <View style={{position: 'absolute', height: 400, width: \"80%\", backgroundColor: \"green\", alignSelf: \"center\"}}>\n <ScrollView>\n <View style={{height: 200, backgroundColor: \"red\"}} />\n <View style={{height: 200, backgroundColor: \"blue\"}} />\n <View style={{height: 200, backgroundColor: \"yellow\"}} />\n </ScrollView>\n </View>\n </View>\n</View>\n" }, { "answer_id": 74532209, "author": "Muhammad Numan", "author_id": 8079868, "author_profile": "https://Stackoverflow.com/users/8079868", "pm_score": 2, "selected": true, "text": "Box" }, { "answer_id": 74532970, "author": "Furkan KARABABA", "author_id": 20459130, "author_profile": "https://Stackoverflow.com/users/20459130", "pm_score": -1, "selected": false, "text": "export default function App() {\n return (\n <View style={{flex: 1, justifyContent: \"center\", alignItems: \"center\"}}>\n <View style={{width: \"80%\", height: 150, borderWidth: 1, backgroundColor: \"green\"}}>\n <ScrollView>\n <View style={{height: 70, backgroundColor: \"red\"}} />\n <View style={{height: 70, backgroundColor: \"blue\"}} />\n <View style={{height: 70, backgroundColor: \"yellow\"}} />\n </ScrollView>\n </View>\n </View>\n );\n}" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457089", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20164809/" ]
74,457,092
<p>How to call models from other multi application site in single installation codeigniter 4 ?</p> <p>The folder structure look like this :</p> <pre><code>- WebsiteFolder -- Site1 --- app --- public --- tests --- writeable (.env, spark and other file) -- Site2 --- app --- public --- tests --- writeable (.env, spark and other file) -- system </code></pre> <p>This is my example code :</p> <p><strong>In Site1</strong></p> <hr /> <p><strong>Constants.php</strong> I have define a root directory to targeted the site2.</p> <pre><code>define('ROOTSOURCE', dirname(__DIR__,3) . '\site2'); </code></pre> <p>This return :</p> <p><em>E:\Project\website\site2</em></p> <p><strong>Autoload.php</strong></p> <p>I have setup PSR4.</p> <pre><code> public $psr4 = [ APP_NAMESPACE =&gt; APPPATH, // For custom app namespace 'Config' =&gt; APPPATH . 'Config', 'Source\Models' =&gt; ROOTSOURCE . '/app/Models/' ]; </code></pre> <p>Then I Run SPARK COMMAND :</p> <pre><code>php spark namespaces </code></pre> <p>And return</p> <pre><code>+---------------+-----------------------------------------------------------------------------------------+--------+ | Namespace | Path | Found? | +---------------+-----------------------------------------------------------------------------------------+--------+ | CodeIgniter | E:\Project\DennisLiu\website\system | Yes | | App | E:\Project\DennisLiu\website\site1\app | Yes | | Config | E:\Project\DennisLiu\website\site1\app\Config | Yes | | Source\Models | E:\Project\DennisLiu\website\site2\app\Models | Yes | +---------------+-----------------------------------------------------------------------------------------+--------+ </code></pre> <p>Then NameSpace <strong>Source\Models</strong> is Found. So far everything is okay.</p> <p>Controller =&gt; <strong>Home.php</strong></p> <pre><code>namespace App\Controllers; use Source\Models; class Home extends BaseController { public function index() { $setting = new \Source\Models\Setting(); return view('welcome_message'); } </code></pre> <p>When I run the controller I got :</p> <blockquote> <p><strong>Class &quot;Source\Models\Setting&quot; not found</strong></p> </blockquote> <p>Next,</p> <p><strong>In Site2</strong></p> <p>I have model <strong>&quot;Setting&quot;</strong> in Site2 Model Folder.</p> <p><strong>For Note :</strong></p> <p>Everything In Site 2 Is running properly.</p> <p>My question is for the error I got &quot;Class <strong>&quot;Source\Models\Setting&quot; not found&quot;</strong> What is the proper setting to call the site 2 model in single application installation codeigniter 4 ?.</p> <p><strong>For Note :</strong> This is single installation codeigniter 4 for two website. And I shared the system folder.</p>
[ { "answer_id": 74457171, "author": "Saqib Ali", "author_id": 20508261, "author_profile": "https://Stackoverflow.com/users/20508261", "pm_score": 0, "selected": false, "text": "// Create a new class manually\n$userModel = new \\App\\Models\\UserModel();\n\n// Create a new class with the model function\n$userModel = model('App\\Models\\UserModel', false);\n\n// Create a shared instance of the model\n$userModel = model('App\\Models\\UserModel');\n" }, { "answer_id": 74459775, "author": "marcogmonteiro", "author_id": 2055393, "author_profile": "https://Stackoverflow.com/users/2055393", "pm_score": 0, "selected": false, "text": "namespace App\\Controllers;\nrequire_once ROOTSOURCE . '/app/Models/UserModel.php';\n\nclass Home extends BaseController\n{\n public function index()\n { \n //Access the model like so:\n $setting = new UserModel(); \n\n return view('welcome_message');\n \n }\n}\n" }, { "answer_id": 74470353, "author": "Dennis Liu", "author_id": 6786634, "author_profile": "https://Stackoverflow.com/users/6786634", "pm_score": 2, "selected": true, "text": "- WebsiteFolder\n -- Site1\n --- app\n --- public\n --- tests\n --- writeable\n (.env, spark and other file)\n -- Site2\n --- app\n --- public\n --- tests\n --- writeable\n (.env, spark and other file)\n -- shared/Models\n (DBSetting.php)\n -- system\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457092", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6786634/" ]
74,457,152
<p>Given the function</p> <pre><code>function invert(arr: string[]) { let result = {}; arr.forEach((x, i) =&gt; { result[x] = i; }) return result; // insert type cast here } </code></pre> <p>What I'm basically looking for, is a way for intellisense in VSCode to tell me exactly what props are available in the resulting object, so given <code>const example = invert(['foo', 'bar', 'baz'])</code></p> <p>The auto-completion should show me this: <a href="https://i.stack.imgur.com/JzNs5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JzNs5.png" alt="Intellisense output" /></a></p> <p>My current approach involves casting the <code>result as {[K in T[number]]: K}</code> where <code>T</code> is an alias for <code>typeof arr</code>, but this approach doesn't give me any auto-completion.</p> <p>What do I write to get TypeScript to do show me this stuff?</p> <p>The interface <code>{[name]: number}</code> is merely a simplified example (for NDA reasons), the main question of how to map an array to property names is still the core of it all.</p>
[ { "answer_id": 74457548, "author": "Tobias S.", "author_id": 8613630, "author_profile": "https://Stackoverflow.com/users/8613630", "pm_score": 2, "selected": true, "text": "invert" }, { "answer_id": 74457582, "author": "nate-kumar", "author_id": 9987590, "author_profile": "https://Stackoverflow.com/users/9987590", "pm_score": 2, "selected": false, "text": "as const" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457152", "https://Stackoverflow.com", "https://Stackoverflow.com/users/1351298/" ]
74,457,158
<p>When a configured quota is exceeded, the API Gateway responds with a detailed http 429 message to the client. This message contains information about the Google Cloud project such as the project name used, the project number, or the API Gateway URL. If you use a Load Balancer in front of the API Gateway, the API Gateway URL is usually hidden.</p> <p>Here is an example:</p> <pre class="lang-json prettyprint-override"><code>{ &quot;message&quot;: &quot;RESOURCE_EXHAUSTED:Quota exceeded for quota metric 'Read requests' and limit 'Read requests per minute' of service 'api-gw-xyz.apigateway.abc.cloud.goog' for consumer 'project_number:123456'.&quot;, &quot;code&quot;: 429 } </code></pre> <p>Can I omit this information and just return an http 429 code? Or am I too paranoid?</p>
[ { "answer_id": 74457548, "author": "Tobias S.", "author_id": 8613630, "author_profile": "https://Stackoverflow.com/users/8613630", "pm_score": 2, "selected": true, "text": "invert" }, { "answer_id": 74457582, "author": "nate-kumar", "author_id": 9987590, "author_profile": "https://Stackoverflow.com/users/9987590", "pm_score": 2, "selected": false, "text": "as const" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457158", "https://Stackoverflow.com", "https://Stackoverflow.com/users/2851799/" ]
74,457,176
<p>I have this code:</p> <pre class="lang-rust prettyprint-override"><code>let mut is_ok_test = false; let handle = thread::spawn(move || { is_ok_test = true; }); handle.join().unwrap(); if is_ok_test == true { println!(&quot;Success&quot;); } else { println!(&quot;Test Failed&quot;) } </code></pre> <p>The <code>is_ok_test</code> variable always remains false. I don't understand why.</p> <p>When modifying the variable inside I get a warning like this:</p> <pre class="lang-none prettyprint-override"><code>value assigned to `is_ok_test` is never read maybe it is overwritten before being read? unused variable: `is_ok_test` did you mean to capture by reference instead? </code></pre> <p>I tried to add <code>&amp;</code> but it doesn't work.</p>
[ { "answer_id": 74457529, "author": "cafce25", "author_id": 442760, "author_profile": "https://Stackoverflow.com/users/442760", "pm_score": 3, "selected": true, "text": "move || {..." }, { "answer_id": 74457901, "author": "Chayim Friedman", "author_id": 7884305, "author_profile": "https://Stackoverflow.com/users/7884305", "pm_score": 3, "selected": false, "text": "is_ok_test" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457176", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20221116/" ]
74,457,197
<p>I have a python CLI interface tool which is used by more than 80 people in my team. Every time we make changes to our code and release it, users also have to download the latest code on their <strong>Windows Machine</strong> and then run it.</p> <p>Like this we have other tools as well like GCC, Company's internal software to be installed on every users PC.</p> <p>Users sometimes face issues in installing the software and upgrading to newer version of Python CLI tool.</p> <p>I want these tools and softwares to be managed at a single place and then user can access them from there.</p> <p>How to resolve this problem on Windows Platform?</p>
[ { "answer_id": 74457529, "author": "cafce25", "author_id": 442760, "author_profile": "https://Stackoverflow.com/users/442760", "pm_score": 3, "selected": true, "text": "move || {..." }, { "answer_id": 74457901, "author": "Chayim Friedman", "author_id": 7884305, "author_profile": "https://Stackoverflow.com/users/7884305", "pm_score": 3, "selected": false, "text": "is_ok_test" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457197", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20517531/" ]
74,457,200
<p>The state variables are -</p> <pre><code>const [details, setDetails] = useState({ Name: &quot;&quot;, Number: null, subject= [{ subject1 : &quot;&quot;, subject2 : &quot;&quot; }] }) &lt;input type=&quot;text&quot; placeholder=&quot;Enter name&quot; value={details.Name} onChange={(e) =&gt; setDetails({ ...details, Name: e.target.value })} /&gt; &lt;input type=&quot;text&quot; placeholder=&quot;Enter number&quot; value={details.Number} onChange={(e) =&gt; setDetails({ ...details, Number: e.target.value })} /&gt; </code></pre> <p>I dont know how to write access the subjects respectively</p>
[ { "answer_id": 74457255, "author": "sm3sher", "author_id": 8845480, "author_profile": "https://Stackoverflow.com/users/8845480", "pm_score": -1, "selected": true, "text": "<input\n type=\"text\"\n placeholder=\"Enter subject1\"\n value={details.subject[0].subject1}\n onChange={(e) =>\n setDetails((curr) => ({\n ...curr,\n subject: [\n { ...curr.subject[0], subject1: e.target.value },\n ...curr.subject,\n ],\n }))\n }\n/>\n<input\n type=\"text\"\n placeholder=\"Enter subject2\"\n value={details.subject[0].subject2}\n onChange={(e) =>\n setDetails((curr) => ({\n ...curr,\n subject: [\n { ...curr.subject[0], subject2: e.target.value },\n ...curr.subject,\n ],\n }))\n }\n/>\n" }, { "answer_id": 74457324, "author": "Saqib Ali", "author_id": 20508261, "author_profile": "https://Stackoverflow.com/users/20508261", "pm_score": 0, "selected": false, "text": "const [count, setCount] = useState(0);\n const [details, setDetails] = useState({\n Name: \"saqib\",\n Number: null,\n subject: [\n {\n subject1: \"1\",\n subject2: \"2\",\n },\n ],\n });\n" }, { "answer_id": 74457427, "author": "Apostolos", "author_id": 1121008, "author_profile": "https://Stackoverflow.com/users/1121008", "pm_score": 0, "selected": false, "text": " {\n details.subject.map((obj,index) => {\n return Object.entries(obj).map(k => {\n return <input type=\"text\" value={k[1]} onChange={(e) => setDetails({ ...details, subject: Object.assign([ ...details.subject], { [index]: {...details.subject[index], [k[0]]: e.target.value }}) })} />\n })\n })\n }\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457200", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20517847/" ]
74,457,231
<p>I am using Spyder IDE with code style warnings enabled. Selecting a subset from a Pandas dataframe via <code>df[df['Col1'].isna() == False]</code> triggers the following code style warning.</p> <p><a href="https://i.stack.imgur.com/PFa3v.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/PFa3v.png" alt="enter image description here" /></a></p> <p>The code analysis suggests using <code>if</code>. However, <code>if</code> does not work in this context. How do I select a subset from a Pandas dataframe without triggering a code style warning?</p>
[ { "answer_id": 74457255, "author": "sm3sher", "author_id": 8845480, "author_profile": "https://Stackoverflow.com/users/8845480", "pm_score": -1, "selected": true, "text": "<input\n type=\"text\"\n placeholder=\"Enter subject1\"\n value={details.subject[0].subject1}\n onChange={(e) =>\n setDetails((curr) => ({\n ...curr,\n subject: [\n { ...curr.subject[0], subject1: e.target.value },\n ...curr.subject,\n ],\n }))\n }\n/>\n<input\n type=\"text\"\n placeholder=\"Enter subject2\"\n value={details.subject[0].subject2}\n onChange={(e) =>\n setDetails((curr) => ({\n ...curr,\n subject: [\n { ...curr.subject[0], subject2: e.target.value },\n ...curr.subject,\n ],\n }))\n }\n/>\n" }, { "answer_id": 74457324, "author": "Saqib Ali", "author_id": 20508261, "author_profile": "https://Stackoverflow.com/users/20508261", "pm_score": 0, "selected": false, "text": "const [count, setCount] = useState(0);\n const [details, setDetails] = useState({\n Name: \"saqib\",\n Number: null,\n subject: [\n {\n subject1: \"1\",\n subject2: \"2\",\n },\n ],\n });\n" }, { "answer_id": 74457427, "author": "Apostolos", "author_id": 1121008, "author_profile": "https://Stackoverflow.com/users/1121008", "pm_score": 0, "selected": false, "text": " {\n details.subject.map((obj,index) => {\n return Object.entries(obj).map(k => {\n return <input type=\"text\" value={k[1]} onChange={(e) => setDetails({ ...details, subject: Object.assign([ ...details.subject], { [index]: {...details.subject[index], [k[0]]: e.target.value }}) })} />\n })\n })\n }\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457231", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5696601/" ]
74,457,244
<p>Attempt to read property &quot;headers&quot; on null Laravel Middleware</p> <pre><code>public function handle(Request $request, Closure $next) { $seller = DB::table('seller_accounts')-&gt;where('user_id',auth()-&gt;id())-&gt;first(); if ($seller-&gt;is_active !== 0) { return $next($request); } else{ $seller_order = DB::table('seller_orders')-&gt;where('user_id',auth()-&gt;id())-&gt;first(); if(!empty($seller_order)) { if($seller_order-&gt;is_paid == 0 &amp;&amp; $seller_order-&gt;is_cancelled == 0) { $payu = app(PayUController::class); $payu-&gt;changeSellerOrderStatus(); return redirect()-&gt;route('seller.after-pay'); }elseif ($seller_order-&gt;is_paid == 1) { DB::table('seller_accounts')-&gt;where('user_id', auth()-&gt;id())-&gt;update(['is_active' =&gt; 1]); }elseif ($seller_order-&gt;is_cancelled == 1) { return response()-&gt;view(&quot;multivendor::dashboard.cancelled&quot;); } }else{ return response()-&gt;view(&quot;multivendor::dashboard.buy&quot;); } } } </code></pre> <p>I get this error when seller is active I think broblem is on next request but I don't know how to solve this.</p>
[ { "answer_id": 74457547, "author": "Semih SAHIN", "author_id": 10542740, "author_profile": "https://Stackoverflow.com/users/10542740", "pm_score": 0, "selected": false, "text": "return new response(view('multivendor::dashboard.cancelled'));\n" }, { "answer_id": 74459103, "author": "Fanmade", "author_id": 3652125, "author_profile": "https://Stackoverflow.com/users/3652125", "pm_score": 1, "selected": false, "text": "else" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457244", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20467991/" ]
74,457,251
<p>I have 3 columns and the data types of all 3 columns are object. First column is Date column and 3rd column is values</p> <p>Something like this-</p> <pre><code>Date Values Country 01/01/21 12:00 2. India 01/01/21 12:15 4. India 01/01/21 12:30 6. India 01/01/21 12:45 8. India 01/01/21 1:00. 10. India 01/01/21 1:15. 20. India 01/01/21 1:30. 30. India 01/01/21 1:45. 40. India </code></pre> <p>Date is from past 1 year and there are 20000 records</p> <p>I want to change the time from 15 minutes bucket to hourly bucket So that the output becomes something like this</p> <pre><code>Date. Values. 01/01/21 12:00. 5. India 01/01/21 1:00. 25. India </code></pre> <p>Values is the avg</p> <p>Tried to resample this data but getting error Only valid with datetimeindex,TimedeltaIndex or PeriodIndex but got an instance of RangeIndex</p>
[ { "answer_id": 74457547, "author": "Semih SAHIN", "author_id": 10542740, "author_profile": "https://Stackoverflow.com/users/10542740", "pm_score": 0, "selected": false, "text": "return new response(view('multivendor::dashboard.cancelled'));\n" }, { "answer_id": 74459103, "author": "Fanmade", "author_id": 3652125, "author_profile": "https://Stackoverflow.com/users/3652125", "pm_score": 1, "selected": false, "text": "else" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457251", "https://Stackoverflow.com", "https://Stackoverflow.com/users/10976458/" ]
74,457,264
<p>I am trying to figure out a loop logic to get all possible permutations where I add a set value to each item in a set array iLoop number of times. I'm gonna try my best to explain what I am looking for.</p> <p>I have a set value &quot;StrokeValue&quot; and a set array &quot;DistanceMatesArray&quot;</p> <pre><code>Dim StrokeValue as single Dim DistanceMatesArray as variant StrokeValue = 300 DistanceMatesArray = Array(300, 300, 300, 300) </code></pre> <p>Now I need to loop through each possible result where I add StrokeValue to each Item which in the first loop would result in possible DistanceMatesArrays:</p> <p><a href="https://i.stack.imgur.com/dSZtn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dSZtn.png" alt="enter image description here" /></a></p> <p>The tricky part is when I want to add StrokeValue more than once and get every outcome where I added StrokeValue iLoop number of time &quot;AllowedActions&quot; resulting in a list such as:</p> <p><a href="https://i.stack.imgur.com/kcVLs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/kcVLs.png" alt="enter image description here" /></a></p> <p>I kind of suspect that I need a 2D array to store all the results from previous loop., that's why in the example the rows are coloured to indicate which one row was taken as a starting point to add the StrokeValue once</p> <p>What I got so far looks like this:</p> <pre><code>Public StrokeValue As Single Public DistanceMatesArray As Variant Public iError As Long Public NumberOfCombinations As Long Public x As Long Public y As Long Public i As Long Option Explicit Sub Test() 'Declare variables Dim PreviousLoopResultsArray As Variant Dim NextLoopResultsArray As Variant Dim iresults As Long Dim iLoop As Long Dim iPreviousResult As Long 'Set variables StrokeValue = 300 'Array DistanceMatesArray = Array(300, 300, 300, 300) ReDim NextLoopResultsArray(0, UBound(DistanceMatesArray)) For i = LBound(DistanceMatesArray) To UBound(DistanceMatesArray) NextLoopResultsArray(0, i) = DistanceMatesArray(i) Next i '------------------------------------------------------ 'Loop Do While iError = NumberOfCombinations 'Try DistanceMatesArray For i = 0 To iresults For x = 0 To UBound(DistanceMatesArray) 'Loop horizontally DistanceMatesArray(x) = NextLoopResultsArray(i, x) Next x Debug.Print Join(DistanceMatesArray) 'TRY HERE Next i 'Array PreviousLoopResultsArray = NextLoopResultsArray 'Array If iLoop &lt;&gt; 0 Then For x = 0 To UBound(DistanceMatesArray) 'Loop horizontally DistanceMatesArray(x) = PreviousLoopResultsArray(iPreviousResult, x) Next x End If 'Set variables iLoop = iLoop + 1 iPreviousResult = 1 iresults = ((UBound(DistanceMatesArray) + 1) ^ iLoop) - 1 ReDim NextLoopResultsArray(iresults, UBound(DistanceMatesArray)) 'Populate NextLoopResultsArray For y = 0 To iresults 'Loop vertically If y Mod (UBound(DistanceMatesArray) + 1) = 0 And y &lt;&gt; iresults And y &lt;&gt; 0 Then For x = 0 To UBound(DistanceMatesArray) 'Loop horizontally DistanceMatesArray(x) = PreviousLoopResultsArray(iPreviousResult, x) Next x iPreviousResult = iPreviousResult + 1 End If For x = 0 To UBound(DistanceMatesArray) 'Loop horizontally NextLoopResultsArray(y, x) = DistanceMatesArray(x) With ThisWorkbook.Worksheets(1).Cells(y + 1, x + 1) .Value = NextLoopResultsArray(y, x) End With Next x Next y 'Modify NextLoopResultsArray x = 0 For y = 0 To iresults 'Loop vertically NextLoopResultsArray(y, x) = NextLoopResultsArray(y, x) + StrokeValue With ThisWorkbook.Worksheets(1).Cells(y + 1, x + 1) .Value = NextLoopResultsArray(y, x) .Interior.Color = vbYellow End With If x + 1 &gt; UBound(DistanceMatesArray) Then x = 0 Else x = x + 1 End If Next y 'Set variables iPreviousResult = 0 'Excel reset For i = 1 To (UBound(DistanceMatesArray) + 1) Columns(i).Clear Next i Loop End Sub </code></pre> <p>At the end of the loop I am expecting to have each one row as DistanceMatesArray i.e. one of them would now be</p> <pre><code>DistanceMatesArray = array(300,600,600,300) </code></pre> <p>Where it added StrokeValue twice.</p> <p>Would someone, please, help me figure out a shorter and simpler logic behind this?</p> <p>EDIT:</p> <p>Results expected after running it up to 3 loops looks like this: <a href="https://i.stack.imgur.com/OJQsg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/OJQsg.png" alt="enter image description here" /></a></p> <p>And without duplicate outcomes</p> <p><a href="https://i.stack.imgur.com/5PaYn.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/5PaYn.png" alt="enter image description here" /></a></p> <p>Continuing to try and figure out the logic of it, maybe now someone get's a betetr idea for what I am lookign for and can help</p> <p>No need to mention that it's an infinite loop - I know that and That's the point, it needs to go on untill I validate the right array in which case iError &lt;&gt; NumberOfCombinations.</p>
[ { "answer_id": 74457547, "author": "Semih SAHIN", "author_id": 10542740, "author_profile": "https://Stackoverflow.com/users/10542740", "pm_score": 0, "selected": false, "text": "return new response(view('multivendor::dashboard.cancelled'));\n" }, { "answer_id": 74459103, "author": "Fanmade", "author_id": 3652125, "author_profile": "https://Stackoverflow.com/users/3652125", "pm_score": 1, "selected": false, "text": "else" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457264", "https://Stackoverflow.com", "https://Stackoverflow.com/users/15265213/" ]
74,457,274
<p>This is my file structure</p> <pre class="lang-php prettyprint-override"><code>\+-- config | +-- config1.php | +-- config2.php \+-- test | +-- test1 | +-- innerRunner.php \+-- outerRunner.php </code></pre> <p>this is <code>config1.php</code></p> <pre class="lang-php prettyprint-override"><code>&lt;?php require_once 'config/config2.php'; </code></pre> <p>this is <code>config2.php</code></p> <pre class="lang-php prettyprint-override"><code>&lt;?php function runConfig2(){ echo &quot;control in config2&quot;; } runConfig2(); </code></pre> <p>this is <code>innerRunner.php</code></p> <pre class="lang-php prettyprint-override"><code>&lt;?php require_once(&quot;../../config/config1.php&quot;); </code></pre> <p>this is <code>outerRunner.php</code></p> <pre class="lang-php prettyprint-override"><code>&lt;?php require_once(&quot;config/config1.php&quot;); </code></pre> <p>When i exceute outerRunner.php then everything works fine but when i run innerRunner.php it shows error</p> <pre><code>Warning: require_once(config/config2.php): Failed to open stream: No such file or directory in /var/www/config/config1.php on line 2 Fatal error: Uncaught Error: Failed opening required 'config/config2.php' (include_path='.:/usr/local/lib/php') in /var/www/config/config1.php:2 Stack trace: #0 /var/www/test/test1/innerRunner.php(2): require_once() #1 {main} thrown in /var/www/config/config1.php on line 2 </code></pre> <p>Can anyone help me with this? <br> Here is the link of sandbox for the same: <a href="https://phpsandbox.io/n/crimson-scene-r00k-qtosz?files=%2Fconfig%2Fconfig2.php" rel="nofollow noreferrer">Link</a></p> <p>PS : I can't make any changes in config1 or config2, i need to do something with innerRunner.php only.</p>
[ { "answer_id": 74457547, "author": "Semih SAHIN", "author_id": 10542740, "author_profile": "https://Stackoverflow.com/users/10542740", "pm_score": 0, "selected": false, "text": "return new response(view('multivendor::dashboard.cancelled'));\n" }, { "answer_id": 74459103, "author": "Fanmade", "author_id": 3652125, "author_profile": "https://Stackoverflow.com/users/3652125", "pm_score": 1, "selected": false, "text": "else" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457274", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20517772/" ]
74,457,279
<p>I am creating a website, i am beginner in web design i want to create a design of category to be showed 4 cards in desktop and 2 card in mobile view.</p> <p>My code below</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;link rel="stylesheet" href="https://cdn.jsdelivr.net/npm/bootstrap@4.6.2/dist/css/bootstrap.min.css" integrity="sha384-xOolHFLEh07PJGoPkLv1IbcEPTNtaed2xpHsD9ESMhqIYd0nLMwNLD69Npy4HI+N" crossorigin="anonymous"&gt; &lt;div class="categories-main"&gt; &lt;div class="container bg-light rounded"&gt; &lt;br&gt; &lt;div class="h4 font-weight-bold text-center py-2"&gt;Categories&lt;/div&gt; &lt;br&gt; &lt;div class="row"&gt; &lt;div class="col-lg-3 col-md-6 my-lg-2 my-2"&gt; &lt;div class="box bg-white"&gt; &lt;div class="d-flex align-items-center"&gt; &lt;div class="rounded-circle mx-3 text-center d-flex align-items-center justify-content-center blue"&gt; &lt;img src="#" alt=""&gt; &lt;/div&gt; &lt;div class="d-flex flex-column"&gt; &lt;b&gt;Public Speech&lt;/b&gt; &lt;a href="#"&gt; &lt;/a&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;br&gt; Categories &lt;br&gt;</code></pre> </div> </div> </p> <p>I tried a lot of changes but didn't get what i want. I expect from developers to help in this.</p>
[ { "answer_id": 74457547, "author": "Semih SAHIN", "author_id": 10542740, "author_profile": "https://Stackoverflow.com/users/10542740", "pm_score": 0, "selected": false, "text": "return new response(view('multivendor::dashboard.cancelled'));\n" }, { "answer_id": 74459103, "author": "Fanmade", "author_id": 3652125, "author_profile": "https://Stackoverflow.com/users/3652125", "pm_score": 1, "selected": false, "text": "else" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457279", "https://Stackoverflow.com", "https://Stackoverflow.com/users/11153227/" ]
74,457,281
<p>This is the error showing in browser when I hit the url of container:</p> <p>This XML file does not appear to have any style information associated with it. The document tree is shown below.</p> <blockquote> <p>ResourceNotFound</p> <p>The specified resource does not exist. RequestId:3fc3c275-301e-000f-3193-f99692000000 Time:2022-11-16T08:13:12.8837824Z</p> </blockquote> <p>But I am able to access the blob when I hit the URL of blob.</p>
[ { "answer_id": 74458756, "author": "Imran", "author_id": 18229970, "author_profile": "https://Stackoverflow.com/users/18229970", "pm_score": 2, "selected": true, "text": "https://<storage-account-name>.blob.core.windows.net/<containername>?restype=container&comp=list&<sas-token>\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457281", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20248160/" ]
74,457,296
<p>I have two loops in my <code>archive-inzerat.php</code>, first is custom loop, second is default loop:</p> <pre><code>&lt;div class=&quot;container&quot;&gt; &lt;div class=&quot;row&quot;&gt; &lt;?php $paged = ( get_query_var( 'paged' ) ) ? get_query_var( 'paged' ) : 1; $featured_args = array( 'post_type' =&gt; 'inzerat', 'post_status' =&gt; 'publish', 'posts_per_page' =&gt; 10, 'paged' =&gt; $paged, 'orderby' =&gt; 'publish_date', 'order' =&gt; 'DESC', 'meta_query' =&gt; array( array( 'key' =&gt; 'is_featured', 'value' =&gt; '1', ) ) ); $featured_query = new WP_Query( $featured_args ); if ( $featured_query-&gt;have_posts() ) : ?&gt; &lt;div class=&quot;col-md-12&quot;&gt; &lt;div class=&quot;row&quot;&gt; &lt;?php while ( $featured_query-&gt;have_posts() ) : $featured_query-&gt;the_post(); echo '&lt;div class=&quot;col-md-3&quot;&gt;'; get_template_part( 'content', 'inzerat' ); echo '&lt;/div&gt;'; endwhile; wp_reset_postdata(); ?&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php endif; ?&gt; &lt;?php if ( have_posts() ) : ?&gt; &lt;div class=&quot;col-md-12&quot;&gt; &lt;div class=&quot;row&quot;&gt; &lt;?php while ( have_posts() ) : the_post(); echo '&lt;div class=&quot;col-md-3&quot;&gt;'; get_template_part( 'content', 'inzerat' ); echo '&lt;/div&gt;'; endwhile; ?&gt; &lt;/div&gt; &lt;div class=&quot;clearfix&quot;&gt;&lt;/div&gt; &lt;div class=&quot;utf-pagination-container margin-top-20&quot;&gt; &lt;nav class=&quot;pagination&quot;&gt; &lt;?php global $wp_query; $total_pages = $wp_query-&gt;max_num_pages; if ( $total_pages &gt; 1 ) { $current_page = max( 1, get_query_var( 'paged' ) ); echo paginate_links( array( 'base' =&gt; get_pagenum_link( 1 ) . '%_%', 'format' =&gt; '/page/%#%', 'current' =&gt; $current_page, 'total' =&gt; $total_pages, 'prev_text' =&gt; '&lt;i class=&quot;fa fa-angle-left&quot;&gt;&lt;/i&gt;', 'next_text' =&gt; '&lt;i class=&quot;fa fa-angle-right&quot;&gt;&lt;/i&gt;', 'type' =&gt; 'list', 'end_size' =&gt; 3, 'mid_size' =&gt; 3, ) ); } wp_reset_postdata(); ?&gt; &lt;script&gt; jQuery('ul.page-numbers').addClass('pagination-custom'); //jQuery('ul.page-numbers li').addClass('page-item'); //jQuery('ul.page-numbers li a, ul.page-numbers li span').addClass('page-link'); jQuery('ul.page-numbers li span.current').parent().addClass('active'); &lt;/script&gt; &lt;/nav&gt; &lt;/div&gt; &lt;/div&gt; &lt;?php endif; ?&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>In first loop I want to display only custom posts by custom field <code>is_featured</code> which is type boolean. In second loop I want to exclude these posts and display others to prevent duplications. Unfortunately, this code I use removes everything from the main loop:</p> <pre><code>function my_posts_filter( $query ) { if ( ! is_admin() &amp;&amp; $query-&gt;is_main_query() &amp;&amp; is_post_type_archive( 'inzerat' ) ) { $query-&gt;set( 'meta_query', array( array( 'key' =&gt; 'is_featured', 'value' =&gt; '1', 'compare' =&gt; 'NOT IN' ) )); } } add_action( 'pre_get_posts', 'my_posts_filter' ); </code></pre> <p>What's wrong here?</p> <p>I want also ask, will my pagination work and not break when adding custom loop? Thanks for helping.</p>
[ { "answer_id": 74457490, "author": "Nilesh", "author_id": 11514647, "author_profile": "https://Stackoverflow.com/users/11514647", "pm_score": 0, "selected": false, "text": "post__not_in" }, { "answer_id": 74458180, "author": "Mark Tendly", "author_id": 20500301, "author_profile": "https://Stackoverflow.com/users/20500301", "pm_score": 1, "selected": false, "text": "$firstloop_ids = array();\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457296", "https://Stackoverflow.com", "https://Stackoverflow.com/users/9598872/" ]
74,457,375
<p>To load csv data from a file, we have:</p> <pre><code>file = open(path) reader = csv.reader(file) </code></pre> <p>Similarly to load json data, we have:</p> <pre><code>file = open(path) data = json.load(file) </code></pre> <p>In both the cases, we are using <code>file</code> object as the base abstraction to build upon. Thinking this in OOPs and modular terms also makes sense since csv and json files are basically string files with additional properties. So, it appears bad to have something like <code>read = csv.reader(path)</code> or <code>data = json.load(path)</code> as an alternative implementation choice just to reduce 1 line of fileIO code, while losing the functionality &amp; flexibility of the &quot;file objects.&quot;</p> <p>But when I see binary files IO with this perspective, it doesn't appear that packages handling them are always following the same logic.</p> <p>As an instance to load an image in opencv we do <code>image = cv2.imread(path)</code> instead of</p> <pre><code>file = open(path, 'b') image = cv2.imread(file) </code></pre> <p>Same is the case in PIL module.</p> <p>Aren't images binary files which can utilize implementation benefits of bytes IO provided by the standard library?</p>
[ { "answer_id": 74457567, "author": "Eugene Yalansky", "author_id": 6808501, "author_profile": "https://Stackoverflow.com/users/6808501", "pm_score": 0, "selected": false, "text": "StingIO" }, { "answer_id": 74457666, "author": "dzang", "author_id": 7812912, "author_profile": "https://Stackoverflow.com/users/7812912", "pm_score": 1, "selected": false, "text": "json" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457375", "https://Stackoverflow.com", "https://Stackoverflow.com/users/6919391/" ]
74,457,376
<p>Hello I am trying to use <a href="https://pub.dev/packages/shared_preferences" rel="nofollow noreferrer">SharedPreferences</a> in flutter but this error appears:</p> <pre><code>NoSuchMethodError: Class 'Future&lt;dynamic&gt;' has no instance method 'setString'. I/flutter ( 5764): Receiver: Instance of 'Future&lt;dynamic&gt;' </code></pre> <p>Here is my code:</p> <pre><code>late SharedPreferences pref; getPref() async { if (pref == null) { pref = await SharedPreferences.getInstance(); } else { return pref; } } getPref.setString(&quot;&quot;); </code></pre>
[ { "answer_id": 74457417, "author": "VincentDR", "author_id": 19540575, "author_profile": "https://Stackoverflow.com/users/19540575", "pm_score": 2, "selected": false, "text": "late SharedPreferences pref;\n getPref() async {\n pref = await SharedPreferences.getInstance();\n }\n\n await getPref();\n pref.setString(\"MY_KEY\", \"MY_VALUE\");\n" }, { "answer_id": 74458302, "author": "Ivo", "author_id": 1514861, "author_profile": "https://Stackoverflow.com/users/1514861", "pm_score": 0, "selected": false, "text": "SharedPreferences? pref;\n\nFuture<bool> setString(String key, String value) async {\n final p = pref ??= await SharedPreferences.getInstance();\n return await p.setString(key, value);\n}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457376", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20059879/" ]
74,457,431
<p>Write a program that prints a sentence the required number of times (each sentence must start on a new line)</p> <p>Solved the problem with a (for) loop and tried with a while loop How to solve it with while?</p> <pre><code>text = input('data input:') amount = int(input()) for _ in range(amount): print(text) </code></pre> <pre><code>text = input('data input:') amount = int(input()) while True: print(text * amount) break </code></pre>
[ { "answer_id": 74457417, "author": "VincentDR", "author_id": 19540575, "author_profile": "https://Stackoverflow.com/users/19540575", "pm_score": 2, "selected": false, "text": "late SharedPreferences pref;\n getPref() async {\n pref = await SharedPreferences.getInstance();\n }\n\n await getPref();\n pref.setString(\"MY_KEY\", \"MY_VALUE\");\n" }, { "answer_id": 74458302, "author": "Ivo", "author_id": 1514861, "author_profile": "https://Stackoverflow.com/users/1514861", "pm_score": 0, "selected": false, "text": "SharedPreferences? pref;\n\nFuture<bool> setString(String key, String value) async {\n final p = pref ??= await SharedPreferences.getInstance();\n return await p.setString(key, value);\n}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457431", "https://Stackoverflow.com", "https://Stackoverflow.com/users/20388001/" ]
74,457,446
<pre><code> final FaIcon? icon; const ButtonWidget({ super.key, this.icon, }); Widget build(BuildContext context) { return Row( children: [ FaIcon(icon) // &quot;The argument type 'FaIcon?' can't be assigned to the parameter type 'IconData?',), ), ], ); } </code></pre> <p>I defined the value named icon as FaIcon. But to me; The argument type 'FaIcon?' can't be assigned to the parameter type 'IconData? Gives a fault.</p>
[ { "answer_id": 74457417, "author": "VincentDR", "author_id": 19540575, "author_profile": "https://Stackoverflow.com/users/19540575", "pm_score": 2, "selected": false, "text": "late SharedPreferences pref;\n getPref() async {\n pref = await SharedPreferences.getInstance();\n }\n\n await getPref();\n pref.setString(\"MY_KEY\", \"MY_VALUE\");\n" }, { "answer_id": 74458302, "author": "Ivo", "author_id": 1514861, "author_profile": "https://Stackoverflow.com/users/1514861", "pm_score": 0, "selected": false, "text": "SharedPreferences? pref;\n\nFuture<bool> setString(String key, String value) async {\n final p = pref ??= await SharedPreferences.getInstance();\n return await p.setString(key, value);\n}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457446", "https://Stackoverflow.com", "https://Stackoverflow.com/users/17906689/" ]
74,457,492
<p>I am using a text view. I want remove if a url is typed inside the text view.I am not able to do that after finding the url present</p>
[ { "answer_id": 74457417, "author": "VincentDR", "author_id": 19540575, "author_profile": "https://Stackoverflow.com/users/19540575", "pm_score": 2, "selected": false, "text": "late SharedPreferences pref;\n getPref() async {\n pref = await SharedPreferences.getInstance();\n }\n\n await getPref();\n pref.setString(\"MY_KEY\", \"MY_VALUE\");\n" }, { "answer_id": 74458302, "author": "Ivo", "author_id": 1514861, "author_profile": "https://Stackoverflow.com/users/1514861", "pm_score": 0, "selected": false, "text": "SharedPreferences? pref;\n\nFuture<bool> setString(String key, String value) async {\n final p = pref ??= await SharedPreferences.getInstance();\n return await p.setString(key, value);\n}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457492", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19542744/" ]
74,457,523
<p>I have three icons in a row, each icon has a title and a subtitle under it. What I try to do is align the title on the same line no matter how much subtitle is big. I need it working on mobile and desktop. <a href="https://i.stack.imgur.com/fBZRB.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/fBZRB.png" alt="enter image description here" /></a></p> <p>This is the code I do so far, but don't success to align them. If you can help me solve this using flex that would be great</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-css lang-css prettyprint-override"><code>#join3icons { display: flex; flex-direction: row; justify-content: center; gap: var(--size-125); padding: 0 var(--size-125); } .icon-box { display: flex; flex-direction: column; justify-content: center; align-items: center; gap: 4px; }</code></pre> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;div id="join3icons"&gt; &lt;div class="icon-box"&gt; &lt;a href="."&gt;&lt;img src="Easier.svg"&gt;&lt;/a&gt; &lt;span class="headline3"&gt;Einfacher&lt;/span&gt; &lt;span class="sub3iconsText"&gt;Auftragsverfolgung&lt;/span&gt; &lt;/div&gt; &lt;div class="icon-box"&gt; &lt;a href="."&gt;&lt;img src="Faster.svg"&gt;&lt;/a&gt; &lt;span class="headline3"&gt;Schneller&lt;/span&gt; &lt;span class="sub3iconsText "&gt;Checkout-Vorgang&lt;/span&gt; &lt;/div&gt; &lt;div class="icon-box"&gt; &lt;a href="."&gt;&lt;img src="Earn.svg"&gt;&lt;/a&gt; &lt;span class="headline3"&gt;Besser&lt;/span&gt; &lt;span class="sub3iconsText "&gt;Lorem Ipsum is simply dummy text&lt;/span&gt; &lt;/div&gt; &lt;/div&gt;</code></pre> </div> </div> </p>
[ { "answer_id": 74457619, "author": "Ali_Sdg90", "author_id": 19556273, "author_profile": "https://Stackoverflow.com/users/19556273", "pm_score": 0, "selected": false, "text": "img{\n height: 100px;\n}\n" }, { "answer_id": 74457796, "author": "Seryn", "author_id": 20117729, "author_profile": "https://Stackoverflow.com/users/20117729", "pm_score": 2, "selected": true, "text": "#join3icons {\n display: grid;\n grid-auto-flow: column;\n grid-template-columns: repeat(3, 1fr);\n grid-template-rows: repeat(3, 1fr);\n justify-items: center;\n align-items: center;\n}\n" }, { "answer_id": 74457833, "author": "Ali_Sdg90", "author_id": 19556273, "author_profile": "https://Stackoverflow.com/users/19556273", "pm_score": -1, "selected": false, "text": ".sub3iconsText {\n height: 40px;\n}\n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457523", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19533023/" ]
74,457,532
<p>I am working with Python 3.10.5 64bit and a strange behavior regarding the listboy widget of the tkinter modul.</p> <p>Look at the following code:</p> <pre><code>import tkinter as tk root = tk.Tk() cities = ['New York', 'Beijing', 'Cairo', 'Mumbai', 'Mexico'] list_source = tk.StringVar(value=cities) lst_cities = tk.Listbox( master=root, listvariable=list_source, height=6, selectmode=tk.SINGLE, exportselection=False) # enables that the selected item will be highlighted lst_cities.grid(row=0, column=0, sticky=tk.EW) lst_cities.select_set(0) lst_cities.select_set(1) lst_cities.select_set(2) root.mainloop() </code></pre> <p>As you can see I have created a simple listbox and finally used the 'select_set' method several times with different indexes. I would assume as I have set selectmode to SINGLE that a new 'select_set' call would remove the previous selection, but this isn't the case so I ended with 3 selected entries. Is this a desired behavior? If so it looks like an inconsistent behavior.</p> <p>I tried to clear the selection with: ` lst_cities.selection_clear(tk.END) lst_cities.select_clear(tk.END)</p> <p>but this doesn't seem to have any effect. So I am also looking for way to clear the selection, so I can select a new entry. Seems I am missing something.</p>
[ { "answer_id": 74457755, "author": "acw1668", "author_id": 5317403, "author_profile": "https://Stackoverflow.com/users/5317403", "pm_score": 1, "selected": false, "text": "selection_set()" }, { "answer_id": 74461005, "author": "toyota Supra", "author_id": 4136999, "author_profile": "https://Stackoverflow.com/users/4136999", "pm_score": 0, "selected": false, "text": "tk.MULTIPLE" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457532", "https://Stackoverflow.com", "https://Stackoverflow.com/users/19774188/" ]
74,457,574
<p>We have a springboot application (File Reading/Writing) which is deployed on <code>Pivotal Cloud Foundry</code>. Currently, only one instance is running, but now we are forced to increase the instance count to 2(Due to company policy/standard etc). If we scale up to 2, our application won't work 100% as expected, it may process same file separately , and this can cause issues.</p> <p>So, my question is ,</p> <ol> <li>is there any way, we can set the <code>cron</code> scheduler separately for each instance ? or</li> <li>inside the spring boot application, is there any way to pass the instance number or id or any identification, saying this is instance 1 or 2 ?, so that i can restrict the execution for a certain instance.</li> </ol>
[ { "answer_id": 74461423, "author": "Daniel Mikusa", "author_id": 1585136, "author_profile": "https://Stackoverflow.com/users/1585136", "pm_score": 2, "selected": true, "text": "CF_INSTANCE_INDEX" }, { "answer_id": 74514585, "author": "user_che_ban", "author_id": 3211648, "author_profile": "https://Stackoverflow.com/users/3211648", "pm_score": 0, "selected": false, "text": " @Value(\"${CF_INSTANCE_INDEX}\") \n private int intanceIndex; \n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457574", "https://Stackoverflow.com", "https://Stackoverflow.com/users/3211648/" ]
74,457,594
<p>I have written a simple playwright test to open a url, do some action and then click on the &quot;next&quot; button and do the same processing again on the page which comes out.</p> <p>This is to test if the navigation is working properly.</p> <p>The script seems to be working file except that when I try to click on the element, I get an <code>locator.click: Target closed</code>.</p> <p>I have verified that the element is there and is available for action.</p> <p>The code is as follows:</p> <pre><code>await page.goto(url, { waitUntil: &quot;networkidle&quot; }); let totalPages = 2; for (let p = 1; p &lt;= totalPages; p++) { let all = await page.$$(&quot;div.course-card--container--1QM2W&quot;); for (let i = 0; i &lt; all.length; i++) { let element = await all[i].asElement().innerHTML(); let $ = await cheerio.load(element); let texts = $(&quot; div .course-card--instructor-list--nH1OC&quot;).text(); } page.locator(&quot;a.pagination--next--BrXhF&quot;).click(); await page.waitForNavigation(); } </code></pre> <p>Please suggest if I am doing something wrong.</p>
[ { "answer_id": 74461423, "author": "Daniel Mikusa", "author_id": 1585136, "author_profile": "https://Stackoverflow.com/users/1585136", "pm_score": 2, "selected": true, "text": "CF_INSTANCE_INDEX" }, { "answer_id": 74514585, "author": "user_che_ban", "author_id": 3211648, "author_profile": "https://Stackoverflow.com/users/3211648", "pm_score": 0, "selected": false, "text": " @Value(\"${CF_INSTANCE_INDEX}\") \n private int intanceIndex; \n" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457594", "https://Stackoverflow.com", "https://Stackoverflow.com/users/4124068/" ]
74,457,631
<p>I am trying to understand why I cannot get a component on a gameobject that derives from a base class that has a generic tied to an interface.</p> <p>I have the following setup for my class:</p> <pre><code>MyClass : Node&lt;IMyInterface&gt; </code></pre> <p>with</p> <pre><code>abstract Node&lt;T&gt; : Monobehaviour where T : IMyInterface </code></pre> <p>Then in a separate component on the same gameobject as <code>MyClass</code> i have:</p> <pre><code>GetComponent&lt;Node&lt;IMyInterface&gt;&gt;() </code></pre> <p>This always returns null when i have <code>MyClass</code> attached to the same GameObject. I also cannot drag the component to a public field of type <code>Node&lt;IMyInterface&gt;</code> either even though it seems to suggest I can because when I drag it over the field it highlights it as if I am able to set it there.</p> <p>Why does it not allow this ? I don't see anything wrong here as the types match perfectly fine...</p>
[ { "answer_id": 74457801, "author": "TimChang", "author_id": 4139780, "author_profile": "https://Stackoverflow.com/users/4139780", "pm_score": 0, "selected": false, "text": "MyClass : Node<IMyInterface>\nabstract Node<T> : Monobehaviour where T : IMyInterface\nPreciseClass : Monobehaviour , IMyInterface\n\nGetComponent<MyClass >()//work\nGetComponent<Node<PreciseClass>()//not work\nGetComponent<PreciseClass>()//work\n" }, { "answer_id": 74458678, "author": "shingo", "author_id": 6196568, "author_profile": "https://Stackoverflow.com/users/6196568", "pm_score": 2, "selected": true, "text": "MyClass" } ]
2022/11/16
[ "https://Stackoverflow.com/questions/74457631", "https://Stackoverflow.com", "https://Stackoverflow.com/users/5736835/" ]