Id
int64
34.6M
60.5M
Title
stringlengths
15
150
Body
stringlengths
33
36.7k
Tags
stringlengths
3
112
CreationDate
stringdate
2016-01-01 00:21:59
2020-02-29 17:55:56
Y
stringclasses
3 values
58,494,428
Create better URL - .htaccess
<p>My URL is looking now like this:</p> <blockquote> <p>localhost/en/products/bear-toys/bear.php?id=26123</p> </blockquote> <p>And i need to looks like this:</p> <blockquote> <p>localhost/en/products/bear-toys/bear/26123</p> </blockquote> <p>or if i can get title of that product and store into URL:</p> <blockquote> <p>localhost/en/products/bear-toys/bear/blue-bear.php</p> </blockquote> <p>I know there is solution with <code>.htaccess</code> but im not good one in <code>.htaccess</code>. So any kind of help will be good. Thanks all</p>
<php><.htaccess>
2019-10-21 21:34:34
LQ_CLOSE
58,495,068
How to display background image using PHP/CSS
<p>I'm looking for the clean simple solution for linking background images using PHP and CSS Any help is much appreciated! </p> <p>I've read around for over an hour and can't seem to find the answer. <a href="https://i.stack.imgur.com/Ia0qv.png" rel="nofollow noreferrer">Here is what I have</a></p> <p>I'm expecting the image to be displayed but it is not.</p>
<php><wordpress><image><background><add>
2019-10-21 22:49:59
LQ_CLOSE
58,495,151
Why does the methods doesn't compile
<p>I have a multi catch exception block with a methods that doesn't compile , there's no inhertance relation between the two classes I still not able to define the rule behind this error ,this my code :</p> <pre><code>class MyException extends RuntimeException { public void log() { System.out.println("Logging MyException"); } } class MyException2 extends RuntimeException { public void log() { System.out.println("Logging MyException2"); } } public class Test { public static void main(String[] args) { try { throw new MyException(); } catch(MyException | MyException2 ex){ ex.log(); // this doesn't compile ! } } } </code></pre>
<java><java-8>
2019-10-21 23:00:02
LQ_CLOSE
58,495,238
Getting error after i put Async function in useEffect
<p>In the useEffect function, If i just mention the getResults function variable, the app doesn't crash, but when i call it as i'm doing in code below, i get these errors : </p> <blockquote> <p>react-dom.development.js:21857 Uncaught TypeError: destroy is not a function</p> </blockquote> <p>and</p> <blockquote> <p>Consider adding an error boundary to your tree to customize error handling behavior.</p> </blockquote> <pre><code> function App() { const [foods, setFoods] = useState([]); const [isLoaded, setIsLoaded] = useState(false); useEffect(() =&gt; getResponse()); const getResponse = async () =&gt; { const response = await fetch(sampleRequest); const data = await response.json(); setFoods(data.hits); }; let query = "Tomato"; let sampleRequest = `https://api.edamam.com/search?q=${query}&amp;app_id=${"1811484f"}&amp;app_key=${"9cac93361efc99e2ebfbb8a453882af8"}`; return ( &lt;div className="App"&gt; &lt;div className="main"&gt; &lt;div className="navbars"&gt; {" "} &lt;Navbars&gt;&lt;/Navbars&gt; &lt;/div&gt; &lt;div className="listings"&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;Listing&gt;&lt;/Listing&gt; &lt;/div&gt; &lt;div className="footer"&gt; &lt;h5&gt;Made By YoYo Strangler in 2019&lt;/h5&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; ); } export default App; </code></pre>
<reactjs><fetch><use-effect>
2019-10-21 23:12:18
HQ
58,496,642
How do you load a separate .html page with Javascript
<p>I am trying to figure out how to send a user to another page I design after they have input the correct password. I don't know how to load the page with a JavaScript Command. How could i use the code below to open a new page titled insideVault.html? </p> <p>I have tried many google searches, but cant find any resources to help me out with this.</p> <pre><code>// login code // &lt;div class = "container"&gt; &lt;div class = "passwordEnter"&gt; &lt;div class = "text-center"&gt; &lt;form id="login" onsubmit="return passCheck()" method="get"&gt; &lt;p&gt; Enter Password &lt;/p&gt; &lt;input type="password" name="password" id = "password"&gt; &lt;input type="submit"&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; &lt;script src="script.js"&gt;&lt;/script&gt; &lt;/div&gt; &lt;script&gt; function passCheck(){ var input = document.getElementById("password").value == 'test'; console.log(input); if(!input){ alert('Password incorrect, please try again.'); return false; } return true; } </code></pre> <p>I want the code to load a new page, but so far I have not been able to find any code that would allow me to do this.</p>
<javascript><html>
2019-10-22 03:19:31
LQ_CLOSE
58,497,874
I am trying to write a haskell function that takes a list of dates and a month and returns how many dates in the list match the given month
this is what I have so far and it doesn't seem to be working numInMonth :: [(Int,Int,Int)] -> Int -> Int numInMonth x [] = x numInMonth x (y:ys) minList1 (x:xs) = currentMin x xs currentMax :: Int -> [Int] -> Int currentMax x [] = x currentMax x (y:ys) | x >= y = currentMax x ys | otherwise = currentMax y ys maxList1 :: [Int] -> Int maxList1 (x:xs) = currentMax x xs
<haskell>
2019-10-22 05:58:05
LQ_EDIT
58,499,136
Is there any way of executing a Python script from a web browser?
<p>I have a python script which I want to execute when someone clicks on a button in an HTML/PHP web page in the browser. How can this be achieved and what is the best way of doing it?</p>
<php><python><html><browser><execution>
2019-10-22 07:30:00
LQ_CLOSE
58,499,153
How to understand the &-sign in Less/SCSS?
<p>I'm trying to understand the &amp; sign in Less. According to lesscss.org, the &amp; represents the current selector parent. So what does it mean in the instance below? The css for the container class is obvious. But what does the &amp;-footer, .CancelButton and &amp;-thresholds apply to?</p> <pre><code>.container { display: flex; margin: 8px 0 8px 0; line-height: 32px; &amp;-footer { display: flex; margin: 24px 0 8px 8px; height: 32px; justify-content: flex-end; .CancelButton { margin: 0; } } &amp;-thresholds { margin: 24px 0; } } </code></pre>
<css><less><scss-mixins>
2019-10-22 07:31:28
LQ_CLOSE
58,499,260
How to Insert and sort the data at the same time using java
This is the sample code which I have written ``` String sql =" INSERT INTO "+tablename+" (id,timestamp,type,current_num_workers,target_num_workers) VALUES (?,?,?,?,?)"; PreparedStatement pstmt=con.prepareStatement(sql); System.out.println("Fetching records in ascending order..."); String se="SELECT * FROM " + tablename + " ORDER BY type ASC"; PreparedStatement pstmt=con.prepareStatement(sql); pstmt.setString(1, id); pstmt.setString(2, timestamp); pstmt.setString(3, type); pstmt.setString(4, current_num_workers); pstmt.setString(5, target_num_workers); pstmt.executeUpdate(); pstmt.executeUpdate(); ``` This is the exception which I am facing ``` Exception in thread "main" com.microsoft.sqlserver.jdbc.SQLServerException: A result set was generated for update. at com.microsoft.sqlserver.jdbc.SQLServerException.makeFromDriverError(SQLServerException.java:226) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.doExecutePreparedStatement (SQLServerPreparedStatement.java:592) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement$PrepStmtExecCmd.doExecute (SQLServerPreparedStatement.java:508) at com.microsoft.sqlserver.jdbc.TDSCommand.execute(IOBuffer.java:7240) at com.microsoft.sqlserver.jdbc.SQLServerConnection.executeCommand(SQLServerConnection.java:2869) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeCommand(SQLServerStatement.java:243) at com.microsoft.sqlserver.jdbc.SQLServerStatement.executeStatement(SQLServerStatement.java:218) at com.microsoft.sqlserver.jdbc.SQLServerPreparedStatement.executeUpdate (SQLServerPreparedStatement.java:461) ``` Help me to resolve this and where I should sort and insert the details at the same time.
<java><sql><sql-server><jdbc>
2019-10-22 07:38:30
LQ_EDIT
58,499,610
How to fix 'Incorrect syntax near the keyword 'WHEN'' error in SQL server?
I'm trying to implement this two when condition in the Case statement but it is just not happening. Please help me fix this ? ``` SELECT BR, CID, TRNDATE, CASE WHEN TRNTYPE = '108' THEN -1 else 1 * TrnAmt/100 WHEN TRNTYPE = '114' THEN (TrnIntAmt - TrnTaxAmt)/100 END as TransactionAmount FROM T_TRNHIST
<sql-server>
2019-10-22 08:01:30
LQ_EDIT
58,500,706
Can someone help me to understand in Python print(4 & 3)-->0 and print(5 & 4)--> 4?
<p>Can someone help me to understand in Python print(4 &amp; 3)-->0 and print(5 &amp; 4)--> 4?</p>
<python><python-3.x>
2019-10-22 09:04:57
LQ_CLOSE
58,502,922
I want to store an array of objects
I want to store an array of objects items=[ {"122":{ name:"abc", "price":"12" }, {"1225656":{ name:"bc", "price":"35" } } ]
<javascript><node.js><express><redis><node-redis>
2019-10-22 11:09:28
LQ_EDIT
58,504,575
View is not rerendered in Nested ForEach loop
<p>I have the following component that renders a grid of semi transparent characters:</p> <pre class="lang-swift prettyprint-override"><code> var body: some View { VStack{ Text("\(self.settings.numRows) x \(self.settings.numColumns)") ForEach(0..&lt;self.settings.numRows){ i in Spacer() HStack{ ForEach(0..&lt;self.settings.numColumns){ j in Spacer() // why do I get an error when I try to multiply i * j self.getSymbol(index:j) Spacer() } } Spacer() } } } </code></pre> <p><code>settings</code> is an EnvironmentObject</p> <p>Whenever <code>settings</code> is updated the Text in the outermost <code>VStack</code> is correctly updated. However, the rest of the view is not updated (Grid has same dimenstions as before). Why is this?</p> <p>Second question: Why is it not possible to access the <code>i</code> in the inner <code>ForEach</code>-loop and pass it as a argument to the function?</p> <p>I get an error at the outer <code>ForEach</code>-loop:</p> <blockquote> <p>Generic parameter 'Data' could not be inferred</p> </blockquote>
<swiftui>
2019-10-22 12:41:54
HQ
58,504,665
jQuery erroring when using .split
I am trying to split this string down into sections: 2 h 3 12 s From this I am trying to create a longer string such as: 00020312 DDHHMMSS I am getting an error on line 3: Cannot read property split of undefined ``` if(hasHours[1] === undefined){ var downTimeH = downTime.split(" h")[0]; downTime = downTime.split(" h ")[1]; if(downTimeH <=9){ downTimeH = downTimeH.toString(downTimeD); downTimeH = '0' + downTimeH; }; } ```
<javascript>
2019-10-22 12:45:52
LQ_EDIT
58,505,463
How Can I Place A MYSQL Database Record In A Variable With PHP?
<p>I need some assistance with my code here. I'm using a mail() function to send a welcome email to a registrant.</p> <p>My mailer script looks like this:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php $to = print require("includes/email.php"); $subject = "This is where I have my subject"; $txt = "Greetings "."\n"." Thank you for registering. "."\n"." This is some of my text "."\n"." Best Regards Admin"; $headers = "From: email@domain.com"; mail($to,$subject,$txt,$headers); header("Location: pay.php"); ?&gt;</code></pre> </div> </div> </p> <p>and my includes/email.php code looks like this:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-html lang-html prettyprint-override"><code>&lt;?php $conn = mysqli_connect('localhost', 'username', 'password', 'database'); // Check connection if ($conn-&gt;connect_error) { die('Connection failed: ' . $conn-&gt;connect_error); } $sql = 'SELECT email_address FROM table WHERE id=(SELECT MAX(id) FROM `table`)'; $result = $conn-&gt;query($sql); if ($result-&gt;num_rows &gt; 0) { // output data of each row while($row = $result-&gt;fetch_assoc()) { echo $row['email_address']; }} $conn-&gt;close(); ?&gt;</code></pre> </div> </div> </p> <p>Now I want my $to variable to have the email_address record from my database and for the mail() function to send an email to that email when the mailer script is run. When I run the script, an email is displayed on the screen and no email is sent but everything works when I manually put an email address on the $to variable. How can I successfully get the script to send the email to the requested email on the database?</p>
<php><mysql>
2019-10-22 13:30:35
LQ_CLOSE
58,506,054
Should I learn Unity C# for PC before learning Unity for Android?
<p>I want to start learning Unity, I'm a web developer and I have a decent level in C# but I've never touched Unity before.</p> <p>I mainly want to create games for Android (maybe iOS in the future), there are many courses on the internet but I'm wodering if I need to have a good understanding of Unity PC/Mac.. before trying to learn Unity for Android.</p> <p>I found this course : <a href="https://www.udemy.com/course/unitycourse/" rel="nofollow noreferrer">https://www.udemy.com/course/unitycourse/</a>, It seems like a it's a complete and detailed one, but it has nothing to do with Android. Should I learn something like this first?</p> <p>I'll appreciate any advices, thank you.</p>
<android><unity3d>
2019-10-22 14:01:44
LQ_CLOSE
58,506,337
Java byte array of 1 MB or more takes up twice the RAM
<p>Running the code below on Windows 10 / OpenJDK 11.0.4_x64 produces as output <code>used: 197</code> and <code>expected usage: 200</code>. This means that 200 byte arrays of one million elements take up approx. 200MB RAM. Everything fine.</p> <p>When I change the byte array allocation in the code from <code>new byte[1000000]</code> to <code>new byte[1048576]</code> (that is, to 1024*1024 elements), it produces as output <code>used: 417</code> and <code>expected usage: 200</code>. What the heck?</p> <pre><code>import java.io.IOException; import java.util.ArrayList; public class Mem { private static Runtime rt = Runtime.getRuntime(); private static long free() { return rt.maxMemory() - rt.totalMemory() + rt.freeMemory(); } public static void main(String[] args) throws InterruptedException, IOException { int blocks = 200; long initiallyFree = free(); System.out.println("initially free: " + initiallyFree / 1000000); ArrayList&lt;byte[]&gt; data = new ArrayList&lt;&gt;(); for (int n = 0; n &lt; blocks; n++) { data.add(new byte[1000000]); } System.gc(); Thread.sleep(2000); long remainingFree = free(); System.out.println("remaining free: " + remainingFree / 1000000); System.out.println("used: " + (initiallyFree - remainingFree) / 1000000); System.out.println("expected usage: " + blocks); System.in.read(); } } </code></pre> <p>Looking a bit deeper with visualvm, I see in the first case everything as expected:</p> <p><a href="https://i.stack.imgur.com/Z7lPo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/Z7lPo.png" alt="byte arrays take up 200mb"></a></p> <p>In the second case, in addition to the byte arrays, I see the same number of int arrays taking up the same amount of RAM as the byte arrays:</p> <p><a href="https://i.stack.imgur.com/W0TnR.png" rel="noreferrer"><img src="https://i.stack.imgur.com/W0TnR.png" alt="int arrays take up additional 200mb"></a></p> <p>These int arrays, by the way, do not show that they are referenced, but I can't garbage collect them... (The byte arrays show just fine where they are referenced.)</p> <p>Any ideas what is happening here?</p>
<java><arrays><memory><memory-leaks>
2019-10-22 14:18:32
HQ
58,506,970
What are some good learning resources?
<p>I was wondering if there where any good resources like books or programs for learning how to code. I've been trying to learn by watching tutorials but I end up just fallowing the instructions without really knowing how and why things go together the way they do. So I get lost when trying to make my own projects. </p> <p>I was wondering what are the recommended resources? preferably with plenty of exercises so I could get a lot of practice.</p> <p>Thank you!</p>
<resources>
2019-10-22 14:51:52
LQ_CLOSE
58,507,663
removing number from notification icon
<p>I have a notification icon that has the number of notifications as below. I'm trying to remove the number upon clicking on the icon. </p> <pre><code>&lt;li class="dropdown"&gt; &lt;a href="#" class="dropdown-toggle" data-toggle="dropdown" role="button" aria-haspopup="true" aria-expanded="false"&gt; &lt;span class="glyphicon glyphicon-globe"&gt;&lt;/span&gt;Notifications &lt;span class="badge"&gt;{{count(auth()-&gt;user()-&gt;notifics)}}&lt;/span&gt;&lt;/a&gt; &lt;ul class="dropdown-menu"&gt; &lt;li&gt; </code></pre> <p>Which is the easiest way to do it, Jquery, or there is an easier way in HTML ?</p>
<javascript><jquery><html>
2019-10-22 15:29:16
LQ_CLOSE
58,509,249
how to remove backslash from Json tag name
I need to remove "/" from Json tag name. Anyone have common solution for this. "langServices": {"en/ENGLISH_ONLY": "English"} This is the sample currently I have. var finalData = jsonstr.replace("en/", "en-");
<javascript><json>
2019-10-22 17:10:00
LQ_EDIT
58,511,476
Vanilla Javascript - Passing values from one input field to another
I'm trying to pass a value from one input field, to another input field, with vanilla javascript. This is the HTML I use: <input type="text" id="input1"> <input type="text" id="input2"> When I try to pass it to a paragraph it works, but passing it to a new input field it won't. Hope you can help me! Thanks!
<javascript><html>
2019-10-22 19:58:49
LQ_EDIT
58,513,022
Should Program class be static?
<p>I am getting the following Warning in Visual Studio 2019, after creating a new ASP.NET Core 3 project:</p> <p>Warning CA1052 Type 'Program' is a static holder type but is neither static nor NotInheritable</p> <pre class="lang-cs prettyprint-override"><code>public class Program { public static void Main(string[] args) { // ... } public static IHostBuilder CreateHostBuilder(string[] args) =&gt; // ... } </code></pre> <p>vs</p> <pre class="lang-cs prettyprint-override"><code>public static class Program { public static void Main(string[] args) { // ... } public static IHostBuilder CreateHostBuilder(string[] args) =&gt; // ... } </code></pre> <p>Should I add the static modifier? Why / Why not? Pro's and Cons'?</p> <p>Edit: This is a ASP.NET Core 3 <strong>API</strong></p>
<c#><asp.net><asp.net-core>
2019-10-22 22:21:45
HQ
58,513,875
sidebar broken on wordpress site
Ok I have a site im building and its beautiful. i love the theme. but on my shop page the sidebar is working fine but on the wcfm marketplace store page the sidebar is covering the page. its the mobile view the shop page is here https://melaninmart.com/shop/ the store page is here https://melaninmart.com/store/lustablesz-cosmetics/ Thanks in advance
<css><wordpress><coding-style><sidebar>
2019-10-23 00:22:45
LQ_EDIT
58,514,136
The meaning of Loop
I saw a loop in a demo code: ```` b <- 3 n <- 4 set.seed(1) (i <- sample(rep(1:n, b)) ) (g <- rep(1:b, each=n) ) (x <- rnorm(n) ) m <- rep(NA, max(g)) for (j in 1:max(g) ) { k <- i[ g == j ] m[j] <- mean(x[k]) print (j) print (k) } ```` The max(g) = 3, so the loop run 3 times. but I don't understand the second row of the loop ` k <- i[ g == j ] `. What is the meaning of this part? Thank you!
<r><for-loop>
2019-10-23 01:12:14
LQ_EDIT
58,515,100
How to declare variable in django html file. not pass from any view. and i also update that variable
<p>I check all blogs in <strong>stackorverflow</strong> but i doesn't find any solution.</p> <p><a href="https://stackoverflow.com/questions/8659560/django-template-increment-the-value-of-a-variable">Django Template - Increment the value of a variable</a></p> <p>This link solution doesn't work. please tell me Other solution.</p>
<python><django>
2019-10-23 03:36:34
LQ_CLOSE
58,515,238
I am having several errors when compiling my code
#include <iostream> #include <iomanip> #include <string>> using namespace std; const double uData = 45; const double mData = 25; const double lData = 15; const double militaryY = 0.10; const double militaryN = 0.00; int main () { double uData, mData, lData, subTotal, tAmount, fTotal, ssTotal, pLines; char dataType, miitaryY, militaryN uData = U mData = M lData = L pLines >=1 if (militaryY) { ssTotal = (pLines + uData) * militaryY; subTotal = ssTotal + pLines + uData fTotal = (subTotal * tAmount) + subtotal } else if (militaryN) { subTotal = fTotal + pLines + uData fTotal = (subTotal * tAmount) + subtotal } else if (militaryY) { ssTotal = (pLines + mData) * militaryY; subTotal = ssTotal + pLines + mData fTotal = (subTotal * tAmount) + subtotal } else if (militaryN) { subTotal = fTotal + pLines + mData fTotal = (subTotal * tAmount) + subtotal } else if (militaryY) { ssTotal = (pLines + lData) * militaryY; subTotal = ssTotal + pLines + lData fTotal = (subTotal * tAmount) + subtotal } else if (militaryN) { subTotal = fTotal + pLines + lData fTotal = (subTotal * tAmount) + subtotal } cout << "How many phone lines are there(Max 3, **Cannot enter 0**) " << pLines << " ? " << endl; cout << "Are you active or retired military (Y or N) " << militaryY << militaryN << " ? " << endl; cout << "What type of data plan are you using (U, M, L) " << uData << mData << lData << " ? " << endl; cout << "Your subtotal is " << subTotal << " $ . " << endl; system("pause"); return 0; } //3 18 C:\Users\adamp\Desktop\DevCppFiles\Project 4\Powers4.cpp [Warning] extra tokens at end of #include directive //C:\Users\adamp\Desktop\DevCppFiles\Project 4\Powers4.cpp In function 'int main()': //21 1 C:\Users\adamp\Desktop\DevCppFiles\Project 4\Powers4.cpp [Error] expected initializer before 'uData' //32 2 C:\Users\adamp\Desktop\DevCppFiles\Project 4\Powers4.cpp [Error] 'else' without a previous 'if' //35 3 C:\Users\adamp\Desktop\DevCppFiles\Project 4\Powers4.cpp [Error] expected ';' before 'fTotal' //41 3 C:\Users\adamp\Desktop\DevCppFiles\Project 4\Powers4.cpp [Error] expected ';' before 'fTotal' //46 3 C:\Users\adamp\Desktop\DevCppFiles\Project 4\Powers4.cpp [Error] expected ';' before 'fTotal' //52 3 C:\Users\adamp\Desktop\DevCppFiles\Project 4\Powers4.cpp [Error] expected ';' before 'fTotal' //57 3 C:\Users\adamp\Desktop\DevCppFiles\Project 4\Powers4.cpp [Error] expected ';' before 'fTotal'
<c++><compiler-errors><runtime-error><compiler-warnings>
2019-10-23 03:54:30
LQ_EDIT
58,515,324
How do i create a brute force function in python without using any API and other library?
I know there are already some answers here. But see my code what i wanna do. genpass = '' #This is the password that we want to crack. psd = 'feed' #This is characters list. This is an array. chr = {'a','b','c','d','e','f','g','h'} def brute_force(psd, chr, genpass): # this function generates password # and check if this is match to psd or not. if genpass == psd: print('password found!', genpass)
<python><arrays><brute-force>
2019-10-23 04:06:04
LQ_EDIT
58,516,299
Can't get Root View from Data Binding after enabling safe-args plugin
<p>I'm working on an Android app using dataBinding and am currently trying to add the safe-args plugin, but after enabling the plugin, I can no longer get the root view via binding.root - Android Studio gives the error: </p> <pre><code>Unresolved Reference None of the following candidates is applicable because of a receiver type mismatch: * internal val File.root: File defined in kotlin.io </code></pre> <p>How can I get databinding and safe-args to play nice together?</p> <p>Note that while the code snippet is in Kotlin I will happily take Java answers. Not as comfortable in Java but I can easily read it and translate it.</p> <p>I haven't been able to find anyone else with the same problem by Googling the error message and "safe args". I tried first with the classpath listed in the Android docs here: <a href="https://developer.android.com/guide/navigation/navigation-pass-data" rel="noreferrer">https://developer.android.com/guide/navigation/navigation-pass-data</a></p> <pre><code>classpath "androidx.navigation:navigation-safe-args-gradle-plugin:2.1.0" </code></pre> <p>And then also found a tutorial suggesting I use:</p> <pre><code>classpath "android.arch.navigation:navigation-safe-args-gradle-plugin:1.0.0-alpha07" </code></pre> <p>Both had the same issue: binding.root gave an error with the plugin activated</p> <p>Here is my onCreateView() for my fragment. That return line works properly when safe-args isn't enabled and doesn't work when it is enabled</p> <pre><code> override fun onCreateView( inflater: LayoutInflater, container: ViewGroup?, savedInstanceState: Bundle? ): View? { binding = DataBindingUtil.inflate(inflater, R.layout.fragment_encoder, container, false) return binding.root } </code></pre> <p>Any help solving or understanding this problem is most appreciated!</p>
<android><kotlin><android-databinding><android-safe-args>
2019-10-23 05:55:20
HQ
58,519,586
Dynamically created Button added to Dictionary made exception when i try use it. WPF
<p>I create Button in my c# kod and add this button to dictionary. I have method to run buttons. When i run this method in Task it make exception:</p> <blockquote> <p>The calling thread cannot access this object because it belongs to a different thread.</p> </blockquote> <pre><code>private void RefreshTags() { var r = new Random(); lock (dictTagModel) { foreach (var item in dictTagModel) { Canvas.SetLeft(item.Value, r.Next(1, 1400)); } } } private void btn1_Click(object sender, RoutedEventArgs e) { var r = new Random(); listTagModel.Add(new TagModel { TagMac = r.Next(1, 10) }); lock (dictTagModel) { foreach (var tag in listTagModel) { if (!dictTagModel.ContainsKey(tag.TagMac)) { var button1 = new Button { //Name = item.Angle.ToString(), Background = Brushes.Black, Height = 8, Width = 8, Content = 0.ToString(), FontSize = 10, }; Canvas.SetLeft(button1, 100); Canvas.SetTop(button1, tagHight); canvas.Children.Add(button1); dictTagModel.Add(tag.TagMac, button1); tagHight -= 10; } } } if(tagHight == 325) { Task.Run(() =&gt; { while (true) { Thread.Sleep(1000); RefreshTags(); } }); } } </code></pre> <p>When it isnt in Task and i only run 1 time this method it work.</p>
<c#><wpf>
2019-10-23 09:23:21
LQ_CLOSE
58,520,499
¿Can someone explain this behaviour to me?
I was just trying some simple stuff with golang and got this behavior Can someone explain to me why? I feel I have a wrong misunderstanding of it... ``` package main import ( "fmt" ) func main() { s := []int{1, 2, 3} fmt.Println(s) fmt.Println("----") a:= s[0:2] fmt.Println(s) fmt.Println(a) a = append(a, 5) fmt.Println("----") fmt.Println(s) fmt.Println(a) a= append(a, 6) fmt.Println("----") fmt.Println(s) fmt.Println(a) } ``` Response: ``` [1 2 3] ---- [1 2 3] [1 2] ---- [1 2 5] [1 2 5] ---- [1 2 5] [1 2 5 6] ``` I was expecting: ``` [1 2 3] ---- [1 2 3] [1 2] ---- [1 2 3] [1 2 5] ---- [1 2 3] [1 2 5 6] ``` Thanks in advance, :)
<go><slice>
2019-10-23 10:10:57
LQ_EDIT
58,521,079
array.sort()-Methode isn't working as it should
i want to display a Array of names in a table. ist like a timetable and i have a sort-button because if i want to add a new Student, the Student should be classified at the right place. My Array contains this values - Benj - Zebra - Yves - Anna but if i press the sort button the output is like this - Zebra - Yves - Anna - Benj That dosent make sense ist not ascending and not descending Here is the code function sort(){ students.sort(); for(var i = 0;i<students.length+1;i++){ if(i!=0){ alert(students[i-1].innerHTML); <!--table.rows[i].cells[0].innerHTML = students[i-1].innerHTML;--> } } }
<javascript><html>
2019-10-23 10:44:26
LQ_EDIT
58,524,770
Remove duplicates from JSON file
<p>My JSON file is very big so I won't show here all the data, but here's the example.</p> <pre><code>[ { "firstName": "C. Ronaldo", "lastName": "dos Santos Aveiro", "commonName": "Cristiano Ronaldo" }, { "firstName": "Luka", "lastName": "Modrić", "commonName": "" }, { "firstName": "C. Ronaldo", "lastName": "dos Santos Aveiro", "commonName": "Cristiano Ronaldo" } ] </code></pre> <p>What I want to achive is to remove duplicated players that have same values inside.</p> <p>So I want to get a result like:</p> <pre><code>[ { "firstName": "C. Ronaldo", "lastName": "dos Santos Aveiro", "commonName": "Cristiano Ronaldo" }, { "firstName": "Luka", "lastName": "Modrić", "commonName": "" } ] </code></pre> <p>Thx in advance :)</p>
<bash><variables><jq>
2019-10-23 14:09:20
LQ_CLOSE
58,525,071
Idiomatic way of handling a goroutine with one "return" value?
<p>Imagine I want to write a function that returns a random number divided by 2:</p> <pre><code>func randomIntInHalf() int { return rand.Int() / 2 } </code></pre> <p>But then I decide I want to build this function for concurrency so I end up with:</p> <pre><code>func randomIntInHalf(c chan&lt;- int) { c &lt;- rand.Int() / 2 } func main() { // Generate 10 random ints in parallel amount := 10 c := make(chan int, amount) for i := 0; i &lt; amount; i++ { go randomIntInHalf(c) } for i := 0; i &lt; amount; i++ { fmt.Println(&lt;-c) } close(c) } </code></pre> <p>I see some issues with this approach. For example, I require the caller to close the channel when it's done generating, making it possible that someone might call the function and leave the channel open indefinitely. It was sort of my understanding that you always want the sender to close the channel. A) is that true and b) is it even possible in this case? Is there a better way to write this code or approach this problem?</p> <p>And, generally, is there a better, idiomatic approach for running a function in a parallel that only ever writes 1 (or a known N) value to the channel?</p> <p>Thanks.</p>
<go><channels>
2019-10-23 14:24:45
LQ_CLOSE
58,525,387
MockMvc no longer handles UTF-8 characters with Spring Boot 2.2.0.RELEASE
<p>After I upgraded to the newly released <code>2.2.0.RELEASE</code> version of Spring Boot some of my tests failed. It appears that the <code>MediaType.APPLICATION_JSON_UTF8</code> has been deprecated and is no longer returned as default content type from controller methods that do not specify the content type explicitly.</p> <p>Test code like</p> <pre><code>String content = mockMvc.perform(get("/some-api") .contentType(MediaType.APPLICATION_JSON)) .andExpect(status().isOk()) .andExpect(content().contentType(MediaType.APPLICATION_JSON_UTF8)) .andReturn() .getResponse() .getContentAsString(); </code></pre> <p>suddenly did not work anymore as the content type was mismatched as shown below</p> <pre><code>java.lang.AssertionError: Content type Expected :application/json;charset=UTF-8 Actual :application/json </code></pre> <p>Changing the code to <code>.andExpect(content().contentType(MediaType.APPLICATION_JSON))</code> resolved the issue for now. </p> <p>But now when comparing <code>content</code> to the expected serialized object there is still a mismatch if there are any special characters in the object. It appears that the <code>.getContentAsString()</code> method does not make use of the UTF-8 character encoding by default (any more).</p> <pre><code>java.lang.AssertionError: Response content expected:&lt;[{"description":"Er hörte leise Schritte hinter sich."}]&gt; but was:&lt;[{"description":"Er hörte leise Schritte hinter sich."}]&gt; Expected :[{"description":"Er hörte leise Schritte hinter sich."}] Actual :[{"description":"Er hörte leise Schritte hinter sich."}] </code></pre> <p>How can I get <code>content</code> in UTF-8 encoding?</p>
<spring-boot><spring-mvc><jackson><spring-test>
2019-10-23 14:40:15
HQ
58,528,384
Ionic 4 Angular Application Mac Address App restart needed after allowing permission
<p>Implemented ionic code with required plugin but it gives the message "Please Restart App!". Without restart app Mac address getting null. After restart getting proper Mac address. How to get Mac address without restart app.</p> <p>Link refered : <a href="https://www.freakyjolly.com/ionic-4-get-unique-device-id-other-uids-of-uuid-imei-imsi-iccid-and-mac-using-native-cordova-plugins/" rel="nofollow noreferrer">https://www.freakyjolly.com/ionic-4-get-unique-device-id-other-uids-of-uuid-imei-imsi-iccid-and-mac-using-native-cordova-plugins/</a></p>
<angular><cordova-plugins><ionic4>
2019-10-23 17:45:55
LQ_CLOSE
58,529,141
How can I detect if a number is greater than 20 or greater than 50 with an if
<p>I try to detect when a number is greater than 10,20,30,40, etc. But this code does not work.</p> <pre><code>var number = 35; var text; if(number &gt;= 10){ text = "&gt; 10" } else if(number &gt;= 20){ text = "&gt; 20" } else if(number &gt;= 30){ text = "&gt; 30" } </code></pre> <p>It only takes me the first if</p>
<javascript>
2019-10-23 18:36:27
LQ_CLOSE
58,529,473
Change name of a cell in data frame in R
<p>I have a data set:</p> <pre><code> x y z 1 apple a 4 2 orange d 3 3 banana b 2 4 strawberry c 1 </code></pre> <p>How can I change the name "banana" to "grape"? I want to get:</p> <pre><code> x y z 1 apple a 4 2 orange d 3 3 grape b 2 4 strawberry c 1 </code></pre> <p>Reproducible code:</p> <pre><code>example&lt;-data.frame( x = c("apple", "orange", "banana", "strawberry"), y = c("a", "d", "b", "c"), z = c(4:1) ) </code></pre>
<r><dataframe>
2019-10-23 19:02:41
LQ_CLOSE
58,529,803
c# display array length when a number is inputted
I want to input a number which corresponds to the length of an array and I want the number at that position to be displayed int[] array1 = {0,6,7,8,5}; Console.WriteLine("ENter the length"); int[] array1 = { 0, 6, 7, 8, 5 }; int lenght = Int32.Parse(Console.ReadLine()); for (int i = 0; i <= lenght; i++) { lenght = array1.Length; Console.WriteLine(lenght); Console.ReadLine(); } I expect the output of 2 to be 7 but I can't seem to figure it out
<c#>
2019-10-23 19:29:54
LQ_EDIT
58,529,933
Change <li> list vertically to horozontally with 4 lines interval
<p>I have a list with ul li like this</p> <ul> <li>Item line 1</li> <li>Item line 2</li> <li>Item line 3</li> <li>Item line 4</li> <li>Item line 5</li> <li>Item line 6</li> <li>Item line 7</li> <li>Item line 8</li> <li>Item line 9</li> <li>Item line 10</li> <li>Item line 11</li> <li>Item line 12</li> </ul> <p>And I need to change to this, its possible only with CSS ?</p> <pre> Item line 1 Item line 5 Item line 9 Item line 2 Item line 6 Item line 10 Item line 3 Item line 7 Item line 11 Item line 4 Item line 8 Item line 12 </pre> <p>Regards</p> <p>Daniel</p>
<html><css>
2019-10-23 19:40:05
LQ_CLOSE
58,530,314
SQL: Check if entry exists and return if it DOESN'T
I want to check if an entry exists in one table based on a value from a 2nd table, but if it DOESN'T exist then select the value from the 2nd table. To explain, I have a table called `devices` and a table called `tests`. Each device in `devices` has a unique identifier (an integer). Each test in `tests` references the a device that the test was run on. Therefore, every `test` is associated with a `device`. However, not every `device` has been tested. Moreover, multiple tests could have been run on a single device. So what I want to `SELECT` is all entries in `devices` that are NOT referenced by at least one entry in `tests`.
<sql><oracle><join><subquery><left-join>
2019-10-23 20:09:49
LQ_EDIT
58,530,639
Removing sandbox accounts from tvOS 13
<p>I have been developing a tvOS app that uses in-app purchasing. As part of the development process, the app must be tested using iTunes sandbox user accounts. When beginning the in-app purchase using a local build, the user is prompted for the account credentials to one of these sandbox accounts.</p> <p>The problem arises with tvOS 13, which does not appear to let you log out from or remove a sandbox account from the device once entered. While this might be okay for purchasing a single time, going through the purchase process again requires a new sandbox account, since otherwise, the purchase would be treated as a renewal rather than a new purchase.</p> <p>Has anyone figured out a way to log out of a sandbox account with an Apple TV running tvOS 13? The only workaround I have found is to perform a reset on the device and go through the setup process again costing a great deal of time.</p>
<in-app-purchase><tvos><apple-tv><tvos13>
2019-10-23 20:35:14
HQ
58,530,741
How to truncate a decimal to 2 places?
<p>I have a value 100.0000. I need truncate it to only two decimal places like 100.00 I need to do it when it have 00's in 3rd and 4 places. How to do it??</p>
<c#><.net>
2019-10-23 20:43:30
LQ_CLOSE
58,531,018
Selenium 3.141 supports for jdk 13?
Confirmation on below issue issue : Selenium 3.141 supports for jdk 13? Refer me which version of java or selenium perfectly can i use
<java><selenium><selenium-webdriver><webdriver><java-13>
2019-10-23 21:09:05
LQ_EDIT
58,531,382
Error in an array, java.lang.NullPointerException
<p>So, i'm using an array in my program, and it gives me this error:</p> <p><code>Exception in thread "AWT-EventQueue-0" java.lang.NullPointerException</code></p> <p>The error is in fourth line of this code: </p> <pre><code>int n = numbers.length, numBigger10 = 0; for (int i = 0; i &lt; n; i++) if (numbers[i] &gt; 10) numbersBigger10[i] = numbers[i]; numBigger10++; </code></pre> <p>What can I do to solve?</p> <p>If you want to know more details about the error please feel free to ask.</p>
<java><arrays><nullpointerexception>
2019-10-23 21:44:30
LQ_CLOSE
58,531,765
Flexbox -how to get first child 50% widht and 100% height while stacking remaining children?
<p>I can't do much with the markup, if I could I'd just add 2 containers side by side. Basically it is a UL that looks like this:</p> <pre><code>&lt;ul&gt; &lt;li&gt;one&lt;/li&gt; &lt;li&gt;two&lt;/li&gt; &lt;li&gt;three&lt;/li&gt; &lt;li&gt;four&lt;/li&gt; &lt;/ul&gt; </code></pre> <p>I need the first child to fill the height of the container at 50% width. The remaining children should have 50% width but auto height and stack on the right side of the container.</p> <p><a href="https://i.stack.imgur.com/KVJiQ.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/KVJiQ.jpg" alt="enter image description here"></a></p>
<css><flexbox>
2019-10-23 22:30:40
LQ_CLOSE
58,531,998
Prevent coercion of pandas data frames while indexing and inserting rows
<p>I'm working with individual rows of pandas data frames, but I'm stumbling over coercion issues while indexing and inserting rows. Pandas seems to always want to coerce from a mixed int/float to all-float types, and I can't see any obvious controls on this behaviour.</p> <p>For example, here is a simple data frame with <code>a</code> as <code>int</code> and <code>b</code> as <code>float</code>:</p> <pre><code>import pandas as pd pd.__version__ # '0.25.2' df = pd.DataFrame({'a': [1], 'b': [2.2]}) print(df) # a b # 0 1 2.2 print(df.dtypes) # a int64 # b float64 # dtype: object </code></pre> <p>Here is a coercion issue while indexing one row:</p> <pre><code>print(df.loc[0]) # a 1.0 # b 2.2 # Name: 0, dtype: float64 print(dict(df.loc[0])) # {'a': 1.0, 'b': 2.2} </code></pre> <p>And here is a coercion issue while inserting one row:</p> <pre><code>df.loc[1] = {'a': 5, 'b': 4.4} print(df) # a b # 0 1.0 2.2 # 1 5.0 4.4 print(df.dtypes) # a float64 # b float64 # dtype: object </code></pre> <p>In both instances, I want the <code>a</code> column to remain as an integer type, rather than being coerced to a float type.</p>
<python><pandas><coercion>
2019-10-23 23:00:39
HQ
58,534,671
C# Read a string with a particular format
I have some strings like string text = "these all are strings, 000_00_0 and more strings are there I have here 649_17_8, and more with this format 975_63_7." So here I wanted to read only 000_00_0, 649_17_8, 975_64_7.... All the string with this format Please help me with the situation Thanks in advance
<c#>
2019-10-24 05:28:06
LQ_EDIT
58,535,218
How to update single column based on conditions
How to update single column based on two or multiple conditions in mssql. I have table called show_list and it looks like emp_id to_date show_flag 1 2019-01-01 2 2019-01-01 3 2019-01-01 4 2019-01-01 I have to update emp_id 1 and 3 with show_flag = 1 and emp_id 2 and 4 with show_flag = 0.
<sql-server><database>
2019-10-24 06:18:21
LQ_EDIT
58,535,367
c# dictionary get all keys with same value
I have a Dictionary with Keys and Values. Is it possible to get all Key who has de same Value? Exemple 1=456894, 2=548962, 3=548962, 4=654876... and den get de Key 2 and 3 because it has the same value. ```Dictionary<int, int> doublechek = new Dictionary<int, int>();```
<c#><dictionary>
2019-10-24 06:28:16
LQ_EDIT
58,536,268
Jquery click doesn't work with custom cursor (div following mouse)
<p>I have a div following the mouse, to make a custom cursor, but the issue is, then no jquery click listeners on anything works, because technically I'm clicking the "cursor", not what I'm trying to click on, I've tried changing the z-index but that doesn't seem to help, </p> <p>Any help appreciated.</p>
<javascript><jquery><css>
2019-10-24 07:30:20
LQ_CLOSE
58,536,343
Regex Python, how to match this string?
I need to take away characters from such type of string: \xa0(Geändert am 01.Aug. 2013) \xa0(Geändert am 05.Dez. 2014) to keep only : 01.Aug. 2013, 05.Dez. 2014 So far I ended up with: [(\xa0)(Geändert)(am)] but it is not working properly [![enter image description here][1]][1] [1]: https://i.stack.imgur.com/xGYlQ.png
<python><regex><string>
2019-10-24 07:34:31
LQ_EDIT
58,537,023
Obfuscate text using JavaScript?
<p>I'm looking to obfuscate (to make obscure, unclear, or unintelligible) paragraph text. Essentially </p> <ul> <li>I need to be able to control where it starts and stops.</li> <li>I don't want people previewing the source and getting the original text where it is hidden.</li> <li>The obfuscated text needs to follow the original formatting - keeping the spacing, line breaks, capitalisation and punctuation etc.</li> <li>Alphabetical characters need swapping with another random alphabetical character.</li> </ul> <p>I'm trying to hide text in an article. What would be the best way to do this using javascript?</p> <p><strong>Example</strong></p> <p>See the following example from the <a href="https://makebook.io/" rel="nofollow noreferrer">Make book</a></p> <p><a href="https://i.stack.imgur.com/bz7fJ.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/bz7fJ.png" alt="enter image description here"></a></p> <p>Note: I came across the <a href="https://camwiegert.github.io/baffle/#demo" rel="nofollow noreferrer">baffle library</a> does something similar but doesn't quite do the job... </p>
<javascript><node.js>
2019-10-24 08:14:51
LQ_CLOSE
58,537,307
Its my first time here! using a friends script, Its returning PHP Warning: Illegal string offset 'error'
I a using a friends script in winSCP using putty and when i do 'create' in the script, it returns this error. I REALLY need help with this please, my friend is away for a week. it directs me to 'line 86' in the php file. I have went ahead and copy and pasted the other lines surrounding line 86 to give a better idea. ERROR FACED: PHP Warning: Illegal string offset 'error' in /root/100tb/includes/100tb.php on line 86 Line 86 is- $errorMessage = (isset($result['data']['error']['message']))? $result['data']['error']['message'] : $result['data']['error']; All help appreciated. } } curl_setopt($handle, CURLOPT_RETURNTRANSFER, TRUE); $response = curl_exec($handle); if (isset($response[0])) { if ($response[0] == '[' || $response[0] == '{') { $response = json_decode($response, TRUE); } } $result = array( 'data' => $response, 'info' => curl_getinfo($handle), ); curl_close($handle); if ($result['info']['http_code'] !== 200) { $errorMessage = (isset($result['data']['error']['message']))? $result['data']['error']['message'] : $result['data']['error']; throw new Exception($errorMessage,$result['info']['http_code']); } return $result['data']; }
<php>
2019-10-24 08:32:21
LQ_EDIT
58,540,800
How to write replacement information in mySQL if no value is post | PDO mySQL
I have the following PDO script that looks for the values. $stmt = $pdo->prepare( ' INSERT INTO `table1` (`person`, `player`, `card) VALUES (:person, :player, :card) ' ); $stmt->execute([ 'person' => $_POST['person'], 'player' => $_POST['player'], 'card' => $_POST['card'] ]); If the value for player for example is not posted, the value should automatically write the value `Nothing`. How can this be implemented using mySQL and PDO?
<php><mysql>
2019-10-24 11:51:44
LQ_EDIT
58,541,260
Difference between git-lfs and dvc
<p>What is the difference between these two? We used git-lfs in my previous job and we are starting to use dvc alongside git in my current one. They both place some kind of index instead of file and can be downloaded on demand. Has dvc some improvements over the former one?</p>
<git><git-lfs><dvc>
2019-10-24 12:19:46
HQ
58,541,748
Last digit of the power of 2 numbers without performing the operation in javascript
<p>I would like to know how to find the units digit of a number raised to another number without calculating the result of the operation, i.e 5**7 = 78125, so I want to write a function that returns 5 as the last digit of the operation.</p>
<javascript>
2019-10-24 12:46:53
LQ_CLOSE
58,542,286
How to implement two methods one from each interfaces which contain more method definition?
<pre><code>interface Ia { void m1(); void m2(); } interface Ib { void m3(); void m4(); } </code></pre> <p>Here how to implement m1, and m3 in a class?</p>
<c#><oop>
2019-10-24 13:18:59
LQ_CLOSE
58,545,772
Is there a easy way to get files from S3 by python?
<p>I tried to create a script which get a file from specific Bucket in S3, <br> <b>for example:</b> from <code>"s3://my-bucket/veryCoolFile.img"</code> I want to get veryCoolFile.img<br> what is the easiest way to do this?</p>
<python><amazon-s3>
2019-10-24 16:44:54
LQ_CLOSE
58,545,839
how to set cors setting
my project go-gin so i tried setting cors When I submitted the following code, ``` package middleware import ( "github.com/gin-contrib/cors" "github.com/gin-gonic/gin" ) func Use() { gin.SetMode(gin.ReleaseMode) cors.Default() return } ``` ``` func main() { log.Printf("Server started") r := gin.Default() route.Route(r) middleware.Use() log.Fatal(r.Run(":8080")) } ``` but it was pointed out that cors did not work, and this method worked fine with the application I created before, but I know what the problem is with this application Is not ... If anyone knows it would be nice to tell you thanks
<go><cors><go-gin>
2019-10-24 16:49:06
LQ_EDIT
58,547,477
can't run: The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe
when i try to run my program it gives this error : The system cannot find the file C:\ProgramData\Oracle\Java\javapath\java.exe
<java><path>
2019-10-24 18:46:43
LQ_EDIT
58,547,530
Issues in downloading Github package
<p>I am looking to download a PCA package in the Sklearn download, and download errors continuously pop up. </p> <p>I am attempting to use the pip command to download directly from GitHub, but keep getting the message that 'Git' is not installed </p> <pre><code> pip install git+git://github.com/mGalarnyk/Python_Tutorials/tree/master/Sklearn Collecting git+git://github.com/mGalarnyk/Python_Tutorials/tree/master/Sklearn Cloning git://github.com/mGalarnyk/Python_Tutorials/tree/master/Sklearn to c:\users\ommited\appdata\local\temp\pip-req-build-ggw1h5ld Running command git clone -q git://github.com/mGalarnyk/Python_Tutorials/tree/master/Sklearn 'C:\Users\omitd~1\AppData\Local\Temp\pip-req-build-ggw1h5ld' ERROR: Error [WinError 2] The system cannot find the file specified while executing command git clone -q git://github.com/mGalarnyk/Python_Tutorials/tree/master/Sklearn 'C:\Users\omit~1\AppData\Local\Temp\pip-req-build-ggw1h5ld' ERROR: Cannot find command 'git' - do you have 'git' installed and in your PATH? </code></pre> <p>Should be a cut and paste install</p>
<python><git><github>
2019-10-24 18:51:04
LQ_CLOSE
58,547,907
Swift/iOS13 - Access SceneDelegate window variable in a ViewController
<p>Is it possible to access window variable from SceneDelegate in a ViewController? Basically I need an alternative for this <code>UIApplication.shared.delegate.window</code> but can't find anything</p>
<ios><swift><ios13>
2019-10-24 19:21:17
HQ
58,549,883
How would you convert this C++ program to a C program?
<p>Thank you for your time in advance, I'm struggling on how to turn this code into C language, I'm just starting in the programming world, so if you have any doubt, I can answer, this is the code... </p> <pre><code>// C++ program for implementation of Heap Sort #include &lt;iostream&gt; using namespace std; // To heapify a subtree rooted with node i which is // an index in arr[]. n is size of heap void heapify(int arr[], int n, int i) { int largest = i; // Initialize largest as root int l = 2*i + 1; // left = 2*i + 1 int r = 2*i + 2; // right = 2*i + 2 // If left child is larger than root if (l &lt; n &amp;&amp; arr[l] &gt; arr[largest]) largest = l; // If right child is larger than largest so far if (r &lt; n &amp;&amp; arr[r] &gt; arr[largest]) largest = r; // If largest is not root if (largest != i) { swap(arr[i], arr[largest]); // Recursively heapify the affected sub-tree heapify(arr, n, largest); } } // main function to do heap sort void heapSort(int arr[], int n) { // Build heap (rearrange array) for (int i = n / 2 - 1; i &gt;= 0; i--) heapify(arr, n, i); // One by one extract an element from heap for (int i=n-1; i&gt;=0; i--) { // Move current root to end swap(arr[0], arr[i]); // call max heapify on the reduced heap heapify(arr, i, 0); } } /* A utility function to print array of size n */ void printArray(int arr[], int n) { for (int i=0; i&lt;n; ++i) cout &lt;&lt; arr[i] &lt;&lt; " "; cout &lt;&lt; "\n"; } // Driver program int main() { int arr[] = {12, 11, 13, 5, 6, 7}; int n = sizeof(arr)/sizeof(arr[0]); heapSort(arr, n); cout &lt;&lt; "Sorted array is \n"; printArray(arr, n); } </code></pre> <p>After that, I would have to add another function, but thats a story for another day, being able to convert it would help me a lot on starting to use C++. Also, which one should I try to specialize on first? English isn't my main language, sorry if I have some mistakes.</p>
<c++><c><arrays><sorting>
2019-10-24 22:25:35
LQ_CLOSE
58,550,627
Writing a function called open_file(). The program will try to open a file. An error message should be shown if the file cannot be opened
I need to define a function called open_file(prompt_str): This function receives a string which is the message to diplay when prompting the user to enter a filename. The program will try to open a file. An error message should be shown if the file cannot be opened. This function will loop until it receives proper input and successfully opens the file. It returns a file pointer. fp = open(filename, "r ") for this hw assignment i was given the already defined variable "Option" OPTION = "\nMenu\ \n\t1: Display data by year\ \n\t2: Display data by country\ \n\t3: Display country codes\ \n\t4: Stop the Program\ \n\n\tEnter option number: " "Enter the filename to read: " "File not found! Try Again!" "Enter year: " "Year needs to be between 2009 and 2017. Try Again!" "Do you want to plot (yes/no)? " "Enter country code: " "Country code is not found! Try Again!" "\nCountry Code Reference" "Invalid option. Try Again!" "\nThanks for using this program!" import matplotlib.pyplot as plt import csv from operator import itemgetter MIN_YEAR = 2009 MAX_YEAR = 2017 def open_file(prompt_str): ''' WRITE DOCSTRING HERE!!! ''' filename = input(Option) #Do i use a if statment or try except or while to check whether file is able to be opened fp = open(filename, "r ", encoding = "utf-8 ")
<python><file-io>
2019-10-25 00:13:42
LQ_EDIT
58,551,729
What is internal implementation of make(map[type1]type2) in Golang?
<p>Golang is a native programming language. So there is a lot of limitation than dynamic languages (like python and ruby).</p> <p>When initialize Maps as <code>m := make(Map[string]int)</code>, this map <code>m</code> seems to be able to contain infinity many key-values.</p> <p>But when initialize Maps with maps literal or make with cap, The maps cannot contain infinity many key-values.</p> <p>Some article said that make without cap allocate a huge amount of memory to this map. But this is not option, because if it was true, there will be a giant memory consumption when initialize single map. But no matter what computer hardware monitoring tools I use, the memory is no difference between before and during my program runs.</p> <pre><code> func main(){ Hello() } func Hello(){ m := make(SizeRecord) l := 10000000 for i := 0; i &lt; l; i++ { m[strconv.Itoa(i)] = Size{float64(rand.Intn(100)), float64(rand.Intn(100)), float64(rand.Intn(100))} } fmt.Println(m) } </code></pre> <p>The program take a while to be executed.</p> <p>I also read an article <a href="https://blog.golang.org/go-maps-in-action" rel="nofollow noreferrer">Go maps in action</a>, it said (I don't know if I have understood correctly) that make without cap use an alternative implementation to represent map and use an unified interface to access the map as the other maps with limited capacity.</p> <p>If my understanding is wrong, could any body tell me what correct one is?</p> <p>If I am correct, why didn't golang implement all maps in this way?</p>
<go><hashmap><maps><native>
2019-10-25 03:16:46
LQ_CLOSE
58,552,982
What is the algorithm Who have the worst complexity O(2^2^n)?
<p>Their are many complexity type like O(1) ... But the worst complexity is O(2^2^n) Is There an algorithm Who have this complexity O(2^2^n)? Who is it?</p>
<algorithm><time-complexity><complexity-theory>
2019-10-25 06:02:18
LQ_CLOSE
58,553,266
Hoverable sidebar manu or right side
<p>I am searching for sidebar manu on right side. I want a hidden sidebar which appears when you scroll on it. Very similar sidebar to that of <a href="https://www.psx.com.pk" rel="nofollow noreferrer">https://www.psx.com.pk</a></p>
<javascript><jquery><html><css><twitter-bootstrap>
2019-10-25 06:26:20
LQ_CLOSE
58,553,366
What is Robust in java
<p>I know that <strong>Robust</strong> is a Feature of java programming language. But I don't know what is the exact meaning of it and how to any programmer benefited by it.</p>
<java>
2019-10-25 06:33:45
LQ_CLOSE
58,553,678
Not able to convert date to epoch time
<p>This is my sample code</p> <pre><code> String dt = "Oct 24 2019 12:00:00.000 AM UTC"; String dt1="Oct 24 2019 11:59:59.000 PM UTC"; SimpleDateFormat df = new SimpleDateFormat("MMM dd yyyy HH:mm:ss.SSS aa zzz"); Date date = df.parse(dt); Date date1 = df.parse(dt1); long epoch = date.getTime(); long epoch1 = date1.getTime(); System.out.println(epoch); System.out.println(epoch1); </code></pre> <p>Here specifying the AM and PM but its not taking the value for that and throwing the exception as</p> <pre><code>{"error_code":"INVALID_PARAMETER_VALUE","message":"Time range must have a start time earlier than the end time"} </code></pre> <p>How to specify AM/PM in the java code. How can I take yesterday's date and time for today in java code as an input to convert to epoch.</p>
<java><datetime-format><epoch>
2019-10-25 06:58:35
LQ_CLOSE
58,554,066
random string generator in laravel
<p>I have 1 file: testController.php</p> <pre><code>use Illuminate\Support\Str; $Quantity = 5; $Promo_code = Str::random($length = 10); for($i = 0; $i &lt; $Quantity; $i++){ \Debugbar::info($Promo_code); } </code></pre> <p>result:</p> <pre><code>a366PPbdB6 a366PPbdB6 a366PPbdB6 a366PPbdB6 a366PPbdB6 a366PPbdB6 </code></pre> <p>I want the result to be random code For example:</p> <pre><code>rxXELTrs9z BOja7WVDHl 6NWL91Den1 GxAdiVHuIV Lyaf9GPwn9 </code></pre> <p>thanks you for help me!</p>
<php><laravel>
2019-10-25 07:29:23
LQ_CLOSE
58,554,449
Google Cloud Platform - one test app - $90/month cost - why?
<p>I have a small test Angular static html app(10MB) deployed via Firebase Console and thought it is completely free. It's not a Node.js app. When I take a look a the billing panel a month later I sow these nice lines:</p> <p>Compute Engine N1 Predefined Instance Core running in Americas: 2159.983 Hours - $68.28.</p> <p>Compute Engine N1 Predefined Instance Ram running in Americas: 8099.938 Gibibyte-hours - $34.32</p> <p><a href="https://i.stack.imgur.com/sQuTk.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sQuTk.jpg" alt="enter image description here"></a></p> <p>GCP, I love you much!!!</p> <p>Tell me guys, how this can be? I almost didn't use this app, just opened it 10 - 15 times during a month.</p> <p>Sorry but I completely can't see the benefits of GCP. I can have Apache hosting in my country just for $3 - $5 per a MONTH but not per a day and no pain at all.</p>
<firebase><google-cloud-platform>
2019-10-25 07:57:55
LQ_CLOSE
58,555,862
Python: remove tuple from list similar to tuple in another list
i am new to python and to programming in general. I have a problem with removing tuples from a list that have similarity with tuples from another list. List1=[(1,2,3,4,5),(1,3,6,7,8)] `List2=[(1,2,3,7,9),(1,4,8,9,10),(1,3,8,9,10)]` I want to remove tuples from List2 that have 3 similar element in tuples of List1. Outputlist=[(1,4,8,9,10)] What is the most efficient way to do it? Thanks in advance.
<python><list><tuples>
2019-10-25 09:32:18
LQ_EDIT
58,557,561
Logcat full of "input svInfo.flags is 8" while app is running
<p>When I run almost any app on android studio, my logcat gets full of messages like:</p> <p>"? E/GnssHAL_GnssInterface: gnssSvStatusCb: a: input svInfo.flags is 8 ? E/GnssHAL_GnssInterface: gnssSvStatusCb: b: input svInfo.flags is 8"</p> <p>What's this? Is there something wrong about my app?</p>
<android><android-studio><compiler-errors><logcat>
2019-10-25 11:20:12
HQ
58,559,171
All unit tests Inconclusive when run in VS 2019
<p>I'm using <code>Unit Test Explorer</code> and <code>Unit Test Sessions</code> to run my tests and suddenly get the below error.</p> <p>When running in <code>Test -&gt; Test explorer</code>, the tests do not run at all and I see no errors.</p> <p>In both cases there is nothing in <code>Output</code> window. I've reinstalled R#, cleared VS cache (in <code>%USERPROFILE%\AppData\Local\Microsoft</code>), restarted windows, restarted VS.</p> <pre><code>2019.10.25 14:54:08.058 ERROR Remote: An exception occurred while invoking executor 'executor://mstestadapter/v2': Method not found: 'Void Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.set_CancellationTokenSource(System.Threading.CancellationTokenSource)'. --- EXCEPTION #1/1 [LoggerException] Message = “Remote: An exception occurred while invoking executor 'executor://mstestadapter/v2': Method not found: 'Void Microsoft.VisualStudio.TestTools.UnitTesting.TestContext.set_CancellationTokenSource(System.Threading.CancellationTokenSource)'.” ExceptionPath = Root ClassName = JetBrains.Util.LoggerException HResult = COR_E_APPLICATION=80131600 StackTraceString = “ at JetBrains.ReSharper.UnitTesting.MSTest.Provider.New.TestHost.TestHostMsTestRunner.TestExecutionEventHandler.HandleLogMessage(TestMessageLevel level, String message) at Microsoft.TestPlatform.VsTestConsole.TranslationLayer.VsTestConsoleRequestSender.SendMessageAndListenAndReportTestResults(String messageType, Object payload, ITestRunEventsHandler eventHandler, ITestHostLauncher customHostLauncher) (...) </code></pre>
<resharper><visual-studio-2019>
2019-10-25 13:10:17
HQ
58,559,662
C# Console App Unable to load Program.cs or <Project_Name>.csproj
For my console app, I am getting the error Assets file 'D:\Folder Name\Tool Name\Tool Name\obj\project.assets.json' not found. Run a NuGet package restore to generate this file. Tool Name C:\Program Files\dotnet\sdk\2.2.204\Sdks\Microsoft.NET.Sdk\targets\Microsoft.PackageDependencyResolution.targets 208 The issue with this is that the <Folder Name> path in actuality is "D:\ProductName%20Utilities", but the solution seems to be looking for "D:\ProductName Utilities" instead. Is there a way to change the solution to look for a the correct filepath?
<c#><visual-studio><asp.net-core>
2019-10-25 13:38:55
LQ_EDIT
58,559,881
How do I make my table visible to phpstorm?
I am using phpstorm, when I execute it the browser shows me: you have created case --- test ---- Table 'test.users' doesn't exist ---- But the table users does exist? How do I fix this? My php code looks like this: ``` <?php define('dbuser','root'); define('dbpass',''); define('dbserver','localhost'); define('dbname','test'); $conn = mysqli_connect(dbserver,dbuser,dbpass,dbname); if(!$conn){ die('error connecting to database'); } echo 'you have created case'; ?> <h1>test</h1> <?php $query = "SELECT * FROM users"; $result = $conn->query($query); if (!$result) die($conn->error); ?> ``` and in my microsoft sql server I have a database named test with table users with one user in it.
<php><mysql><sql><phpstorm>
2019-10-25 13:52:17
LQ_EDIT
58,559,992
how to move element from one point to another with animation?
<p>I have a div with position absolute. I want to move it from one point to another say from (50,50) to (400,500). the points are change every time I click the button to move the element. I want to use animation for the transition. </p> <p>How to do it in general solution or is there npm packages does that? </p>
<javascript><css>
2019-10-25 13:57:30
LQ_CLOSE
58,560,629
How to send e-mail with excel when date in column equal or smaller than today's date?
I have 3 columns : A) Enterprises B) Email adress matching the enterprise C) Date of reminder When the date of reminder is smaller or equal than today'S date, I want to automaticaly send a message to the email adress corresponding. Thank you for advices. I havn't wrote any code yet cause i'm new to VBA.
<excel><vba><outlook>
2019-10-25 14:38:23
LQ_EDIT
58,561,352
Resize a border in css
I would like to make a border that does like in the following photo : [(this one)][1] [1]: https://i.stack.imgur.com/O2EcM.png My code is actually the following : ```html <div id="ametg" class="marketorder"> <img src="https://cdn.discordapp.com/emojis/618876932825677835.png?v=1"> <font color="yellow"><p> Graines en amethyste </p> <div id="amgp"> <p> Prix : <span>800</span>$/stack </p> </div> <br /><button onclick="orderga"> Commander </button></font> </div> ``` And, for the style of the class : ```css .marketorder{ border-style: solid } ``` I hope somebody can help me as soon as possible!
<html><css><styles><border>
2019-10-25 15:20:06
LQ_EDIT
58,562,838
How to uninstall bluej? Is netbeans better?
<p>Can i have intalled on my computer both bluej and netbeans? I have bluej now, if i uninstall it , everything related with it will be unistalled to (every libraries). And generally is netbeans better option?</p>
<java><netbeans><bluej>
2019-10-25 17:04:04
LQ_CLOSE
58,563,456
how to solve aws lambda creation Error creating application: You are not authorized to perform: serverlessrepo:GetApplication
can u tell me any solution to solve this error... Error creating application: You are not authorized to perform: serverlessrepo:GetApplication. while creating lambda applicaion by IAM user account.
<amazon-web-services><amazon-s3><aws-lambda><aws-sdk>
2019-10-25 17:54:37
LQ_EDIT
58,563,904
why am i not able to work with the doGet()?
while i was learning servlet i used the method doGet() and i was using Get request method ,the HTTP Status 500 error showed up ,but while using doPost() and post request was working perfectly fine.why am i not able to work with the doGet(). HTTP Status 500 – Internal Server Error Type Exception Report Message null Description The server encountered an unexpected condition that prevented it from fulfilling the request. Exception java.lang.NumberFormatException: null java.lang.Integer.parseInt(Unknown Source) java.lang.Integer.parseInt(Unknown Source) com.kiran.AddServlet.doGet(AddServlet.java:12) javax.servlet.http.HttpServlet.service(HttpServlet.java:634) javax.servlet.http.HttpServlet.service(HttpServlet.java:741) org.apache.tomcat.websocket.server.WsFilter.doFilter(WsFilter.java:53) Note The full stack trace of the root cause is available in the server logs. Apache Tomcat/9.0.27
<java><jsp><servlets>
2019-10-25 18:30:09
LQ_EDIT
58,564,119
Your project exceeded quota for free storage for projects
we've started to get an error while querying error={"location":"free.stor age","message":"Quota exceeded: Your project exceeded quota for free storage for projects. For more information, see https://cloud.google.com/bigquery/troubleshooting-errors","reason":"quotaExceeded"}) But I can't find any info about "quota fo free storage" What exactly the quota is about?
<google-bigquery><limit>
2019-10-25 18:46:22
LQ_EDIT
58,565,584
How can I see how TypeScript computes types?
<p>Problem: I'm working on a file that has a lot of conditional types that derive their types from previously defined conditional types and this has become very complex and difficult to debug how a type is being derived.</p> <p>I'm trying to find a way to "debug" or list how the TypeScript compiler is making its determination on a conditional type and picking a path to derive the ultimate type.</p> <p>I've looked through the <a href="https://www.typescriptlang.org/docs/handbook/compiler-options.html" rel="noreferrer">compiler options</a> and have not found anything in that area yet...</p> <p>An analogy to what I'm looking for right now is the equivalent of the <code>DEBUG=express:*</code> type of setting that one might use if you wanted to see what an express server was doing.</p> <p>However, the actual problem I'm trying to solve is to be able to deconstruct and debug how a type is derived in a large complex hierarchical type definition.</p> <p>Important Note: I'm not trying to debug the runtime execution of TypeScript project. I'm trying to debug how the types are computed by the TypeScript compiler.</p>
<typescript><typescript-generics>
2019-10-25 20:52:00
HQ
58,566,361
Javascript: Comparing elements in nested arrays using nested for loops
<p>I'm working with an array of arrays that looks like this:</p> <p><code>let matrix = [[0,1,1,2], [0,5,0,0], [2,0,3,3]]</code></p> <p>I want to loop through each array and compare the value to the same element in the other arrays i.e. I want to compare the 0th element in the 0th array to the 0th elements in the 1th and 2nd array (in this case I would be comparing 0 to 0 and 2 respectively).</p> <p>I want to iterate through the arrays comparing the current array element in the current array to it's counterpart in the following arrays i.e. look at the 0th element of this array and compare it to the 0th element in the next two arrays, then look at the 1th element in this array and compare it to the 1th element in the next two arrays, and so forth.</p> <pre><code>Compare the values 0, 0, 2 Then compare 1,5,0 Then compare 1,0,3, Then compare 2, 0, 3 </code></pre> <p>How can I do this with nested for loops? Is there a better way to do this not involving nested for loops?</p>
<javascript><arrays><loops><multidimensional-array><nested>
2019-10-25 22:14:09
LQ_CLOSE
58,568,175
Upgrade to python 3.8 using conda
<p>Python 3.8.0 is out, but I haven't been able to find any post on how to update to python 3.8 using conda - maybe they will wait for the official release? Any suggestions?</p>
<python><python-3.x><anaconda><conda>
2019-10-26 04:55:03
HQ
58,570,569
getting the SUM() of claps and at the same time counting bookmarks in one query
I TRIED A LOT OF SOLUTION THAT LOOKS SIMILAR TO MY PROBLEM BUT NO ONE WORKED FOR ME . i have 5 tables (USERS, POSTS, BOOKMARKS, CLAPS, COMMENTS) **USERS** TABLE: ``` +----+-------+----------------+-------------+------------+ | id | name | email | password | register | +----+-------+----------------+-------------+------------+ | 1 | lofy | hello@hi.com | 123 | 2019-05-06 | | 2 | jake | jake@joke.com | 123 | 2019-06-22 | | 3 | moly | moly@liky.com | 123 | 2019-05-15 | +----+-------+----------------+-------------+------------+ ``` **POSTS** TABLE: ``` +----+-------+-------------------+--------------+------------+ | id | title | body | writer_id | date | +----+-------+-------------------+--------------+------------+ | 1 | lofy | blah blah blah.. | 1 | 2019-05-06 | | 2 | jake | blah blah blah.. | 2 | 2019-06-22 | | 3 | moly | blah blah blah.. | 2 | 2019-05-15 | +----+-------+-------------------+--------------+------------+ ``` **BOOKMARKED** TABLE: ``` +---------+-----------+ | user_id | post_id | +---------+-----------+ | 1 | 1 | | 2 | 2 | | 3 | 2 | +---------+-----------+ ``` **CLAPS** TABLE: ``` +---------+-----------+------------+ | user_id | post_id | claps_times| +---------+-----------+------------+ | 1 | 1 | 5 | | 2 | 2 | 13 | | 3 | 2 | 7 | +---------+-----------+------------+ ``` i used this query to get the posts details + the user name and avatar + how many times this post is bookmarked by the users ```SELECT posts.*, users.name, users.avatar , count(bookmarks.post_id) as bookmarksCount FROM posts LEFT JOIN users ON users.id = posts.owner LEFT Join bookmarks ON bookmarks.post_id = posts.id GROUP BY posts.id ; ``` EVERY THING IS GOOD TILL NOW . **THE PROBLEM:** i wanted to get the SUM() of the claps for each post so i added 2 more lines to the previous query , this is the query now: ``` SELECT posts.*, users.name, users.avatar , count(bookmarks.post_id) as bookmarksCount , SUM(claps.claps_count) AS totalClaps FROM posts LEFT JOIN users ON users.id = posts.owner LEFT Join bookmarks ON bookmarks.post_id = posts.id LEFT JOIN claps ON claps.post_id = posts.id GROUP BY posts.id ; ``` THE PROBLEM IS THAT THE RESULT OF THE CLAPS OF THE POST.ID "2" IS DOUBLED IT'S 40 INSTEAD OF 20, ITS LIKE THE JOIN OF THE COUNT() OF THE BOOKMARKS OF THE POST IS CAUSING THE PROBLEM , IN OTHER WORDS IF THE SUM() OF THE CLAPS ARE 10 AND THE POST IS BOOKMARKED 5 TIMES AFTER COUNT() THAN THE RESULT OF THE CLAPS WILL BE 50 INSTEAD OF 5. I TRYIED TO SUBQUERY THE SUM() OF THE CLAPS BUT I DIDN'T KNOW HOW TO DO IT . **CAN YOU PLEASE GIVE ME THE SOLUTION IN SUBQUERY WAY WITH A SOME EXPLANATION CAUSE I WILL ADD THE COUNT() OF THE COMMENTS LATER ON AND MAYBE MORE SUBQUEERIES TOO** **TY IN ADVANCE**
<mysql><sql><subquery>
2019-10-26 12:01:14
LQ_EDIT
58,571,506
Simple Search System Not Working PHP SQL HTML
<p>So I'm new to SQL, PHP and HTML. I'm trying to create a search system for my database that contains a table for foods and their prices. I've searched everywhere for people who have the same problem as me but none of the solutions seem to help me. </p> <p>I've searched far and wide over all the forums I could find, loads of tutorials on YouTube yet to no avail.</p> <p>Main PHP code:</p> <pre><code>&lt;!doctype html&gt; &lt;html&gt; &lt;head&gt; &lt;meta charset = "utf-8"&gt; &lt;title&gt;Lists of foods and prices! Input yours here!&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;h1&gt;Insert your fav food!&lt;/h1&gt; &lt;table&gt; &lt;form action = "" method = "post"&gt; &lt;tr&gt; &lt;td&gt;Food: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="Food"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Price: &lt;/td&gt;&lt;td&gt;&lt;input type="integer" name="Price"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;Supermarket: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="Supermarket"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="submit" name = "submit"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/form&gt; &lt;/table&gt; &lt;table&gt; &lt;form action = "" method = "post"&gt; &lt;tr&gt; &lt;td&gt;Search: &lt;/td&gt;&lt;td&gt;&lt;input type="text" name="Search"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;tr&gt; &lt;td&gt;&lt;input type="submit" name = "Search"&gt;&lt;/td&gt;&lt;/tr&gt; &lt;/form&gt; &lt;/table&gt; &lt;?php if(isset($_POST["submit"])){ include 'dbconfig.php'; include 'New Text Document.js'; $Food = $_POST['Food']; $Price = $_POST['Price']; $Supermarket = $_POST['Supermarket']; mysqli_query($conn,"INSERT INTO costsoffood VALUES('$Food', '$Price', '$Supermarket')"); } if(isset($_POST["Search"])){ include 'dbconfig.php'; $search = $_POST["Search"]; $query="SELECT * FROM costsoffood WHERE Food LIKE %$search%"; $result=mysqli_query($conn,"SELECT * FROM costsoffood WHERE Food LIKE '%$search%'"); if(mysqli_num_rows($result)&gt;0){ while($row = mysqli_fetch_array($result)){ echo "&lt;tr&gt;&lt;td&gt;". $row['food']."&lt;/td&gt;&lt;td&gt;". $row['price']."&lt;/td&gt;&lt;td&gt;".$row['supermarket']."&lt;/td&gt;&lt;/tr&gt;"; } echo "&lt;/table&gt;"; } else{ echo "no results"; } } ?&gt; &lt;/body&gt; &lt;/html&gt; </code></pre> <p>dbconfig.php</p> <pre><code>&lt;?php $servername = "localhost"; $username = "root"; $password = ""; $dbname = "dataone"; // Create connection $conn = new mysqli($servername, $username, $password, $dbname); // Check connection if ($conn-&gt;connect_error) { die("Connection failed: " . $conn-&gt;connect_error); } ?&gt; </code></pre>
<php><html><mysql>
2019-10-26 14:08:14
LQ_CLOSE
58,572,293
How to identify a variable data type in java
I'm building a program for homework and I want do do a type checking a certain array string that is composed of numbers and some characters in order to do something. Like, if the element of that string is a integer, do something, else, do another thing. How can I do that? Is that possible?
<java><character-encoding>
2019-10-26 15:47:31
LQ_EDIT
58,573,822
C# method running with worksheet
<p>Maybe it is a beginner question but I can not seem to figure it out. How do I run the method as seen in the picture?</p> <p>[[image]: <a href="https://i.stack.imgur.com/1QlnL.png][1]" rel="nofollow noreferrer">https://i.stack.imgur.com/1QlnL.png][1]</a></p>
<c#><visual-studio><methods>
2019-10-26 19:03:07
LQ_CLOSE
58,574,552
array.map does not change array values
<p>Why doesn't array.map work?</p> <p>My code is:</p> <pre><code>let myArray = [000,111,222,333,444,555,666,777,888,999]; myArray.map((value) =&gt; { return = 1000 - value; }); console.log(myArray); </code></pre> <p>The result is: [0, 111, 222, 333, 444, 555, 666, 777, 888, 999]</p>
<javascript>
2019-10-26 20:41:36
LQ_CLOSE
58,574,607
ls -l command in Unix, cannot remember file size
I created a new file on a Unix server. But when I run the ls -l command, I get the following: -rwxr-xr-x 1 mccorm14 student 49508 Oct 26 11:29 4th I cannot remember if the file size is block or bytes. If its block, how do I convert it to bytes? Thank you!
<shell><unix><ls>
2019-10-26 20:50:24
LQ_EDIT
58,575,016
What is the difference between Pipeline and Release Pipeline in azure devops?
<p>An yaml file is generated while you choose this option shown below: </p> <p><a href="https://i.stack.imgur.com/srDc7.png" rel="noreferrer"><img src="https://i.stack.imgur.com/srDc7.png" alt="enter image description here"></a></p> <p>In this yaml file, you can define an entire deployment cycle starting from <code>restore -&gt; build -&gt; run tests -&gt; publish and -&gt; deploy to azure app service web app</code>. </p> <p>then, why there is the releases option? If i can define an entire lifecycle via the <code>Pipelines -&gt; Pipelines</code> option, what is the purpose of the <code>Pipelines -&gt; Releases</code> option? </p> <p><a href="https://i.stack.imgur.com/zb6ax.png" rel="noreferrer"><img src="https://i.stack.imgur.com/zb6ax.png" alt="enter image description here"></a></p>
<azure-devops><azure-pipelines><azure-pipelines-release-pipeline>
2019-10-26 21:53:24
HQ
58,575,299
Repository pattern - Do I "need" a service layer in REST API?
<p><em>Im making this question to get your opinions on the matter, and to see if I'm being dumb or pedantic.</em></p> <hr> <h1>Question (tl;dr;)</h1> <p>Do I "need" the service layer (for good practice) when the repository layer already can do most of the things (like FindUserByID) with queries in a faster way, when the service has to do all these things manually in a much more inefficient and super manual way?</p> <h1>Description (for those who want to read about my motives)</h1> <p>So, I've been dealing with Clean Architecture, which is great, but not for REST architecture. Since, Clean Architecture is literally made with a Controllers layer, and RPC is the one that handles controllers, not REST. REST handles resources. <strong>So, I removed the "controller" layer, and I'm also thinking if I really need a "service" layer as well.</strong></p> <p>So REST needs <strong>"services"</strong> and/or <strong>"repositories"</strong>. The strange thing, is that I think these two overlap. I know that <strong>services</strong> are supposed to <strong>handle "business rules"</strong>. But here's the thing:</p> <h2>Repositories can do the same job with services, but repositories can do the <strong>same job in a much more efficient way</strong>.</h2> <p>Since Repositories are allowed to have direct communication with the database, they can use database queries (sql, or nosql ones). Which are much more <strong>efficient to write</strong>, much more <strong>efficient to read</strong>, much more <strong>efficient on performance</strong>.</p> <h3>Service way:</h3> <p>Say, you need to find a user by his ID, and then pick a specific friend from his friendlist by his name.</p> <ul> <li>You get all the users from <strong>repository</strong></li> <li>You make a <strong>loop</strong> for all the users</li> <li>You make a <strong>condition</strong> where you check which user has the ID you want</li> <li>You make a <strong>loop</strong> for all his friends in the friendlist</li> <li>You make a <strong>condition</strong> to check the friend's name</li> </ul> <p><strong>Summary? Like 20-30 lines of code and slower performance?</strong></p> <h3>Repository way:</h3> <pre class="lang-golang prettyprint-override"><code>filter := bson.M{ "_id": id, "friendlist.name": friendsName, } projection := bson.M{ "friendlist": 1 } friend, err := mongoDb.find(filter, projection) </code></pre> <p><strong>Summary? Like 3-4 lines of code, and 99% database performance.</strong></p> <p>So, is there any real need for the "Service layer" part? Is there any real architectural benefit on splitting it to a service layer and a repository layer, when repository can already do all the jobs much more efficiently by itself?</p>
<rest><architecture><repository-pattern>
2019-10-26 22:46:43
LQ_CLOSE
58,575,473
Getting started with react-redux with typescript
<p>I am looking for some links that provide "getting started" documentation for react-redux with typescript.</p> <p>I have react application with multiple components - some of which are nested. Now I need to wire them up so that they can communicate with each other. Some online research led to me to believe that redux is something that should be used in such cases. However I could not find any online tutorial that deals with react, react-redux and typescript. Can anyone point me to right direction?</p>
<reactjs><typescript><react-redux>
2019-10-26 23:23:55
LQ_CLOSE
58,576,143
UINaviagationBar ignoring background color settings
<p>ios 13, objective-c, can't get the navigation bar background color set.</p> <p>I've tried setting the color via the UI in interface builder, and several examples off the web (and here).</p> <pre><code>UINavigationBarAppearance* navBarAppearance = [self.navigationController.navigationBar standardAppearance]; navBarAppearance.backgroundColor = [UIColor colorWithRed:172.0f green:193.0f blue:197.0f alpha:1.0f]; </code></pre> <p>I would expect the above code to set the background color, but it's still white.</p>
<ios><objective-c>
2019-10-27 02:14:56
LQ_CLOSE
58,576,228
Get values from URL in Java
<p>I want to get "BusinessId" from this URL in Java: <a href="https://example.com/?link=https://play.google.com/store/apps/details?id=com.example.cp&amp;hl=es&amp;apn=com.picker.cp&amp;st=Share+this+app&amp;utm_source=AndroidApp?businessId=5d8648b561abf51ff7a6c189" rel="nofollow noreferrer">https://example.com/?link=https://play.google.com/store/apps/details?id=com.example.cp&amp;hl=es&amp;apn=com.picker.cp&amp;st=Share+this+app&amp;utm_source=AndroidApp?businessId=5d8648b561abf51ff7a6c189</a></p> <p>What can i do? I need some help, please :C</p>
<java><android-studio><url>
2019-10-27 02:34:43
LQ_CLOSE
58,578,570
value of using React.forwardRef vs custom ref prop
<p>I see that React.forwardRef seems to be the sanctioned way of passing a ref to a child functional component, from the react docs:</p> <pre><code>const FancyButton = React.forwardRef((props, ref) =&gt; ( &lt;button ref={ref} className="FancyButton"&gt; {props.children} &lt;/button&gt; )); // You can now get a ref directly to the DOM button: const ref = React.createRef(); &lt;FancyButton ref={ref}&gt;Click me!&lt;/FancyButton&gt;; </code></pre> <p>However, what is the advantage of doing this over simply passing a custom prop?:</p> <pre><code>const FancyButton = ({ innerRef }) =&gt; ( &lt;button ref={innerRef} className="FancyButton"&gt; {props.children} &lt;/button&gt; )); const ref = React.createRef(); &lt;FancyButton innerRef={ref}&gt;Click me!&lt;/FancyButton&gt;; </code></pre> <p>The only advantage I can think of is maybe having a consistent api for refs, but is there any other advantage? Does passing a custom prop affect diffing when it comes to rendering and cause additional renders, surely not as the ref is stored as mutable state in the <code>current</code> field?</p> <p>Say for example you wanted to pass multiple refs (which tbh, might indicate code smell, but still), then the only solution I can see would be to use customRef props.</p> <p>I guess my question is what is the value of using <code>forwardRef</code> over a custom prop?</p>
<javascript><reactjs><performance>
2019-10-27 10:33:53
HQ
58,579,267
How can we override the constructor while still using the `class` keyword?
<p>Two notable ways to create a class are shown below:</p> <pre><code>class Klass: pass Klass = type("Klass", tuple(), dict()) </code></pre> <p>I would like to override the constructor (<code>__call__</code>) while still using the <code>class</code> keyword instead of doing something else, like directly calling <code>type</code>. I really do want to override (<code>__call__</code>), not <code>__init__</code></p> <p>My failed attempts are shown below:</p> <h2>Attempt 1</h2> <pre><code>class Foo: @classmethod def __call__(*args): print("arr har") return super(type(args[0]), args[0]).__call__(*args) instance = Foo() # did not print "arr har" </code></pre> <h2>Attempt 2</h2> <pre><code>class BarMeta(type): def __call__(*args): print("hello world") return super(type(args[0]), args[0]).__call__(*args[1:]) </code></pre> <ul> <li><h2>Attempt 2A</h2> <pre><code>class Bar: __metaclass__ = BarMeta instance = Bar() # did not print "hello world" </code></pre></li> <li><h2>Attempt 2B</h2> <pre><code>Baz = BarMeta("Baz", tuple(), dict()) instance = Baz() # Did print "hello world," but we weren't able to use the `class` keyword to create `Baz` </code></pre></li> </ul>
<python><python-3.x><metaprogramming><metaclass><constructor-overloading>
2019-10-27 12:05:09
LQ_CLOSE
58,579,774
Convert an existing Flutter Kotlin project to Flutter Java project
<p>I created a Flutter project using default values, which are Kotlin for Android and Swift for iOS. Halfway through the project I needed to integrate a 3rd party Android SDK that requires Java. Can I convert a Flutter project to Java for Android after creation?</p> <p>I know I will need yo use Platform Channels to integrate native code with my Flutter app, this is not my concern.</p>
<java><android><kotlin><flutter>
2019-10-27 13:20:32
HQ