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
60,251,802
How to find all possible combinations from a list with only two elements and no duplicates with Python?
<p>I have the following:</p> <pre><code>list = ["player1", "player2", "player3"] </code></pre> <p>I want to find all possible combinations of two elements of that list, but with no duplicates. I have tried to work with the itertools.combinations() but without the desired result.</p> <p>I'm looking for a result like this:</p> <pre><code>player1, player2 player1, player3 player2, player3 </code></pre> <p>Can someone help me in the right direction?</p> <p>Thanks in advance</p>
<python><itertools>
2020-02-16 18:31:34
LQ_CLOSE
60,252,713
write one specific formula in python
<p>I have a question, everyone knows how can I write this formula with python? </p> <p><a href="https://i.stack.imgur.com/eg7G5.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/eg7G5.png" alt="enter image description here"></a></p>
<python><math>
2020-02-16 20:05:36
LQ_CLOSE
60,252,859
JavaScript Event Listeners inside methods
<p>I was hoping to be able to call object methods from an event listener, however, I am unable to access object properties on the called function:</p> <pre><code>import {action} from '../desktopIntegration/actions.js' class Object { constructor() { this.property = 2 } addListener() { action.on("keyup", this.printEvent) } printEvent() { console.log(this.property) } } </code></pre> <p>This code gives the error:</p> <pre><code> unable to access property of undefined </code></pre> <p>when addListener is called.</p> <p>Is there a way to make this work? I want to keep the callback as a method function so that I can delete the listener on each instance of Object. </p> <p>Thanks!</p>
<javascript>
2020-02-16 20:22:44
LQ_CLOSE
60,253,101
JAVA: How do I determine if the input is a palindrome?
<p>Please use the method below. </p> <p>I am trying to get rid of all white spaces, punctuations and make everything lowercase. Then I want to see whether the string is a palindrome (same when read from the front and back.</p> <p>I can't figure it out.</p> <pre><code>public static void main(String[] args) { String word=null; String reverse=""; Scanner console = new Scanner(System.in); System.out.print("Please enter a word or a phrase:"); word = console.nextLine(); word=word.replaceAll("\\s+",""); //removes white space word=word.replaceAll("[^a-zA-Z ]", ""); //removes all punctuation word=word.toLowerCase(); for(int i=word.length()-1; i&gt;=0; i--) { reverse +=word.charAt(i); } for(int i=0; i&lt;word.length(); i++) { System.out.print(word); if(word.charAt(i) != reverse.charAt(i)) { System.out.println("Not a Palindrome"); }else { System.out.println("Palindrome");``` </code></pre>
<java>
2020-02-16 20:54:01
LQ_CLOSE
60,253,151
PHP Float subtraction returning wrong results
<p>When i try to do <strong>(50.00 - 49.99)</strong> it returns to me <strong>0.009999999999998</strong>, why? How do i solve this?</p>
<php><math><subtraction><operation>
2020-02-16 20:59:52
LQ_CLOSE
60,253,775
Date formatting error assistance in bash shell script issue
<p>I'm having issue identifying what exactly my issue is with this bash shell script. I copied exactly what my teacher has but cannot get it to run properly. Thank you in advance.</p> <p>Script: [Script code for the program<a href="https://i.stack.imgur.com/VYqAX.png" rel="nofollow noreferrer">1</a></p> <p>Outcome: <a href="https://i.stack.imgur.com/DdF9j.png" rel="nofollow noreferrer">Outcome</a></p>
<linux><bash><shell><unix>
2020-02-16 22:26:45
LQ_CLOSE
60,254,970
Can someone help me figure out why my mini-max tic-tac-toe AI does not work?
This is me trying to make a minimax tic-tac-toe game. The AI for some reason still goes in order in which the spot turns up on the list for the board. It looks like it is calculating the scores, but I do not think it is utilizing them for some reason. It is supposed to pick the spot with the highest score. It outputs many "You win", "TIE", and "You lose" strings because I wanted to make sure it was iterating through the spaces and combinations. Please help! ```` import random import math three = [0, 0, 0] game = True turnai = False result = "" b = [" ", " ", " ", " ", " ", " ", " ", " ", " "] x = "X" o = "O" ur = b[2] um = b[1] ul = b[0] ml = b[3] mm = b[4] mr = b[5] ll = b[6] lm = b[7] lr = b[8] cw = " " AI = "" player = "" def board(ul, um, ur, ml, mm, mr, ll, lm, lr): print("|" + " " + ul + " " + "|" + " " + um + " " + "|" + " " + ur + " " + "|") print("|" + " " + ml + " " + "|" + " " + mm + " " + "|" + " " + mr + " " + "|") print("|" + " " + ll + " " + "|" + " " + lm + " " + "|" + " " + lr + " " + "|") board(ul, um, ur, ml, mm, mr, ll, lm, lr) print("This is the game of tic-tac-toe") print("You will be playing against an AI") print("Type where you want to place your letter Ex: ur = upper right, mm = middle middle, and ll = lower right") first = "P" player = "X" AI = "O" def checkwinner(): ur = b[2] um = b[1] ul = b[0] ml = b[3] mm = b[4] mr = b[5] ll = b[6] lm = b[7] lr = b[8] row1 = [ul, ml, ll] row2 = [um, mm, lm] row3 = [ur, mr, lr] column1 = [ul, um, ur] column2 = [ml, mm, mr] column3 = [ll, lm, lr] diagonal1 = [ul, mm, lr] diagonal2 = [ur, mm, ll] if row1 == ["X", "X", "X"] or row2 == ["X", "X", "X"] or row3 == ["X", "X", "X"] or column1 == ["X", "X", "X"] or column2 == [ "X", "X", "X"] or column3 == ["X", "X", "X"] or diagonal1 == ["X", "X", "X"] or diagonal2 == ["X", "X", "X"]: if player == x: print("You win! (X)") return "X" if player != x: print("You lose!") return "O" if row1 == ["O", "O", "O"] or row2 == ["O", "O", "O"] or row3 == ["O", "O", "O"] or column1 == ["O", "O", "O"] or column2 == [ "O", "O", "O"] or column3 == ["O", "O", "O"] or diagonal1 == ["O", "O", "O"] or diagonal2 == ["O", "O", "O"]: if player == o: print("You win! (O)") return "X" if player != o: print("You lose") return "O" if b[0] != " " and b[1] != " " and b[2] != " " and b[3] != " " and b[4] != " " and b[5] != " " and b[ 6] != " " and b[7] != " " and b[8] != " ": print("TIE!") winner = True return "0" return "null" def minimax(b, depth, isMaximizing): result = checkwinner() if result != "null": return scores[result] if (isMaximizing): bestScore = -math.inf j = 0 for str in b: if str == " ": b[j] = AI score = minimax(b, depth + 1, False) b[j] = " " bestScore = max(score, bestScore) j += 1 return bestScore else: bestScore = math.inf k = 0 for str in b: if str == " ": b[k] = player score = minimax(b, depth + 1, True) b[k] = " " bestScore = min(score, bestScore) k += 1 return bestScore if (first == "P"): while (game == True): i = 0 scores = { 'O': 1, 'X': -1, '0': 0 } bestScore = -math.inf turnai = False i = 0 for str in b: if str == " ": b[i] = AI score = minimax(b, 0, True) b[i] = " " print(score) if score > bestScore and turnai == False: bestScore = score b[i] = AI turnai = True i += 1 turnai = False print("") # b = [ul, um, ur, ml, mm, mr, ll, lm, lr] ur = b[2] um = b[1] ul = b[0] ml = b[3] mm = b[4] mr = b[5] ll = b[6] lm = b[7] lr = b[8] board(b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8]) cw = checkwinner() if cw == "X" or cw == "O" or cw == "0": game = False break print("Where do you want to place your letter?") turn = input(": ") if turn == "ur" and ur == " ": b[2] = player uru = True if turn == "um" and um == " ": b[1] = player umu = True if turn == "ul" and ul == " ": b[0] = player ulu = True if turn == "mr" and mr == " ": b[5] = player mru = True if turn == "mm" and mm == " ": b[4] = player mmu = True if turn == "ml" and ml == " ": b[3] = player mlu = True if turn == "lr" and lr == " ": b[8] = player lru = True if turn == "lm" and lm == " ": b[7] = player lmu = True if turn == "ll" and ll == " ": b[6] = player llu = True # b = [ul, um, ur, ml, mm, mr, ll, lm, lr] board(b[0], b[1], b[2], b[3], b[4], b[5], b[6], b[7], b[8]) sw = checkwinner() if cw == "X" or cw == "O" or cw == "0": game = False break # MAKE SURE TO MOVE WHERE THE TIE MECH IS WHEN MAKING OTHER TURN SYSTEM AND SCORE LOOK UP TABLE ````
<python><artificial-intelligence><minimax>
2020-02-17 01:51:55
LQ_EDIT
60,255,456
Bash redirect and process questions
[image][1] [1]: https://i.stack.imgur.com/zXkz0.png hi,why use ">" no data, use ">>" have data,thanks very much GNU bash, version 4.4.12
<bash><redirect>
2020-02-17 03:11:06
LQ_EDIT
60,255,464
In most of cases machine learning algorithm gets over-fit. Anyone can explain me in clear way
<p>when it gets over-fit most articles say, algorithm tries to memories, the data points which are give as train input.In a clear way could anyone explain how algorithm memorizes?</p>
<algorithm><machine-learning><deep-learning><artificial-intelligence><data-science>
2020-02-17 03:13:34
LQ_CLOSE
60,256,296
Failure to get nonnegative integer single number
number = int(input('Enter a nonnegative integer: ')) product=1 for i in range(number): product = product * (i+1) print(product) The result is the nonnegative integer is 1 2 6 24... 5040 But I only need the nonnegative integer of 7 which is 5040, how do I get that?
<python><integer>
2020-02-17 05:15:24
LQ_EDIT
60,256,467
how to use val insted of var in scala
I simply want to remove var and use Val instead in below code def getConfigId: Long = { val object1: java.util.List[objectA] = objectRepo.findByUser(User(session.id)) var object2: objectA = null if (object1.size() == 1) { object2 = object1.get(0) } else if (object1.size() > 1) { object2 = object1.get(0) object1.forEach(a => if (a.endDate.compareTo(object2.endDate) >= 0) { object2 = a }) } object2.configId } I am trying to use case match but not working def getConfigId: Long = { val object1: java.util.List[objectA] = objectRepo.findByUser(User(session.id)) val object2: objectA = { case x if object1.size() == 1 => object1.get(0) case x => if (object1.size() > 1) { object1.get(0) object1.forEach(a => if(a.endDate.compareTo(object2.endDate) >= 0) { object2 = a }) }
<java><scala><if-statement><collections><functional-programming>
2020-02-17 05:38:36
LQ_EDIT
60,259,610
Flutter - how to filter debug console in vscode
<p>For a few days, and without changing anything, at least deliberately, in <code>DEBUG CONSOLE</code> in <code>VSCODE</code> I get messages like:</p> <pre><code>W/.arae_blueprin(14366): Accessing hidden method Lsun/misc/Unsafe;-&gt;getInt(Ljava/lang/Object;J)I (greylist, linking, allowed) W/.arae_blueprin(14366): Accessing hidden method Lsun/misc/Unsafe;-&gt;compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed) W/.arae_blueprin(14366): Accessing hidden method Lsun/misc/Unsafe;-&gt;compareAndSwapObject(Ljava/lang/Object;JLjava/lang/Object;Ljava/lang/Object;)Z (greylist, linking, allowed) W/.arae_blueprin(14366): Accessing hidden method Lsun/misc/Unsafe;-&gt;putObject(Ljava/lang/Object;JLjava/lang/Object;)V (greylist, linking, allowed) D/EGL_emulation(14366): eglMakeCurrent: 0xe1641400: ver 2 0 (tinfo 0xd5f83710) D/EGL_emulation(14366): eglMakeCurrent: 0xc1f7c2e0: ver 2 0 (tinfo 0xbd495c10) D/eglCodecCommon(14366): setVertexArrayObject: set vao to 6 (6) 0 0 W/.arae_blueprin(14366): Accessing hidden method Lsun/misc/Unsafe;-&gt;getInt(Ljava/lang/Object;J)I (greylist, linking, allowed) I/DynamiteModule(14366): Considering local module com.google.android.gms.ads.dynamite:0 and remote module com.google.android.gms.ads.dynamite:21200 I/DynamiteModule(14366): Selected remote version of com.google.android.gms.ads.dynamite, version &gt;= 21200 D/eglCodecCommon(14366): setVertexArrayObject: set vao to 4 (4) 0 0 D/eglCodecCommon(14366): setVertexArrayObject: set vao to 0 (0) 1 2 D/eglCodecCommon(14366): setVertexArrayObject: set vao to 0 (0) 1 2 D/eglCodecCommon(14366): setVertexArrayObject: set vao to 4 (4) 1 30 </code></pre> <p>These messages make it difficult for me to read the logs that I send by console.</p> <p>How can I filter them so they don't appear, or at least filter my own logs?. Thanks.</p>
<flutter><visual-studio-code>
2020-02-17 09:41:23
HQ
60,259,853
Moving Background Image with custom segue swift
[I want to get moving background animation like this.][1] 1.Can anyone help me with this problem. 2.Is it possible to make this kind of animation in horizontally [1]: https://www.google.com/url?sa=i&url=https%3A%2F%2Fstackoverflow.com%2Fquestions%2F27848409%2Fcustom-segue-with-separate-moving-background&psig=AOvVaw3uk7bWBM2G2D1alZzP4UY9&ust=1582018785523000&source=images&cd=vfe&ved=0CAIQjRxqFwoTCLC7qLGl2OcCFQAAAAAdAAAAABAD
<swift><xcode><animation><uiviewcontroller><segue>
2020-02-17 09:56:48
LQ_EDIT
60,260,485
How does a vector as a key works internally in C++?
<p>This SO answers says that <a href="https://stackoverflow.com/questions/8903737/stl-map-with-a-vector-for-the-key">STL Map with a Vector for the Key</a> the vector can be used as a key. So when we use a vector as a key. How does that actually work since the key needs to be unique so when we insert another vector with the same elements will the <code>map</code> check for duplicate element by element or the name of the vector does specify something? Like the name of the array represents the base address. So an array can be used as a key since the base address can be used as a key in this case but what is the key in case of a vector. How does it work internally.</p> <p>Because when I print the name of the vector, I do get an error</p> <pre><code>vector&lt;int&gt; v; cout&lt;&lt;v; //error </code></pre>
<c++><arrays><dictionary><vector><stl>
2020-02-17 10:30:09
HQ
60,260,970
Angular material design
We are using angular material mat radio button and it is selected. This radio button gets unchecked on opening angular modal pop up with another set of angular material radio button.
<angular><angular-material>
2020-02-17 10:56:54
LQ_EDIT
60,261,501
Kali Linux Installing Bluto
<p>Could somebody help me with the following problem? It would be much appreciated.</p> <p><strong>Goal</strong> : To install Bluto on Kali Linux 2020.1 using <code>sudo pip install bluto</code> command</p> <p><strong>Problem</strong> : Install does not complete</p> <p><strong>Error message:</strong></p> <p><code>ERROR: Command errored out with exit status 1: command: /usr/bin/python -c 'import sys, setuptools, tokenize; sys.argv[0] = '"'"'/tmp/pip-install-9scbuzrf/pdfminer/setup.py'"'"'; __file__='"'"'/tmp/pip-install-9scbuzrf/pdfminer/setup.py'"'"';f=getattr(tokenize, '"'"'open'"'"', open)(__file__);code=f.read().replace('"'"'\r\n'"'"', '"'"'\n'"'"');f.close();exec(compile(code, __file__, '"'"'exec'"'"'))' egg_info --egg-base /tmp/pip-install-9scbuzrf/pdfminer/pip-egg-info cwd: /tmp/pip-install-9scbuzrf/pdfminer/ Complete output (8 lines): Traceback (most recent call last): File "&lt;string&gt;", line 1, in &lt;module&gt; File "/tmp/pip-install-9scbuzrf/pdfminer/setup.py", line 3, in &lt;module&gt; from pdfminer import __version__ File "/tmp/pip-install-9scbuzrf/pdfminer/pdfminer/__init__.py", line 5 print __version__ ^ SyntaxError: Missing parentheses in call to 'print'. Did you mean print(__version__)? ---------------------------------------- ERROR: Command errored out with exit status 1: python setup.py egg_info Check the logs for full command output. </code></p> <p>Im running : Kali Linux 2020.1<br> Python 3.8.1 (default, Jan 19 2020, 22:34:33) git version 2.25.0 pip 20.0.2 from /home/kali/.local/lib/python3.8/site-packages/pip (python 3.8)</p> <p><strong>Screenshot</strong> </p> <p><a href="https://i.stack.imgur.com/8jhm4.png" rel="nofollow noreferrer">Bluto Kali Linux install error</a></p>
<linux><pip><kali-linux>
2020-02-17 11:29:12
LQ_CLOSE
60,262,591
How to prevent a base class from inheritance in C++?
<p>I don't want to make the base class from being derived to a new class. Is there any way to achieve this? I want to tell the compiler that you can't inherit the base class just like a final keyword in java</p>
<c++><inheritance>
2020-02-17 12:33:31
LQ_CLOSE
60,262,635
CI/CD pipeline with PostgreSQL failed with "Database is uninitialized and superuser password is not specified" error
<p>I'm using Bitbucket pipeline with PosgreSQL for CI/CD. According to this <a href="https://confluence.atlassian.com/bitbucket/test-with-databases-in-bitbucket-pipelines-856697462.html" rel="noreferrer">documentation</a> PostgreSQL service has been described in <code>bitbucket-pipelines.yml</code> this way:</p> <pre><code>definitions: services: postgres: image: postgres:9.6-alpine </code></pre> <p>It worked just fine until now. But all my latest pipelines failed with following error:</p> <pre><code> Error: Database is uninitialized and superuser password is not specified. You must specify POSTGRES_PASSWORD for the superuser. Use "-e POSTGRES_PASSWORD=password" to set it in "docker run". You may also use POSTGRES_HOST_AUTH_METHOD=trust to allow all connections without a password. This is *not* recommended. See PostgreSQL documentation about "trust": https://www.postgresql.org/docs/current/auth-trust.html </code></pre> <p>How can I fix it? There was no changes in <code>bitbucket-pipelines.yml</code> file which could be the reason of such error..</p>
<postgresql><docker><pipeline>
2020-02-17 12:36:34
HQ
60,263,030
Is there third party package repository for Swift?
<p>I came from web development/design (still are) and I started to learn Swift 5 for iOS app development. In web development, there's a lot of sites or repo where I can download pre-written codes for the web like packagist.org. My question is, is there a similar site where I can pull pre-written code in Swift so I can extend the functionality of an iOS app? Thank you!</p>
<ios><swift>
2020-02-17 13:01:06
LQ_CLOSE
60,264,110
How do I resolve Activity Not Found Exception
<p>In my android app, I've added an activity <em>MainActivity</em> in the manifest file, on navigating to that activity using an inten I get <code>activity not found error</code> asking if I've added it to manifest</p> <p>here is my manifest activity</p> <pre><code> &lt;activity android:name=".MainActivity" android:clearTaskOnLaunch="true" android:configChanges="orientation|keyboardHidden|screenSize" android:icon="@mipmap/ic_launcher" android:rotationAnimation="seamless" android:screenOrientation="portrait" android:theme="@style/Theme.AppCompat" tools:targetApi="O"&gt; &lt;intent-filter&gt; &lt;action android:name="android.intent.action.MAIN" /&gt; &lt;category android:name="android.intent.category.OPENABLEk" /&gt; &lt;/intent-filter&gt; &lt;!-- Register as a system camera app--&gt; &lt;intent-filter&gt; &lt;action android:name="android.media.action.IMAGE_CAPTURE" /&gt; &lt;action android:name="android.media.action.STILL_IMAGE_CAMERA" /&gt; &lt;action android:name="android.media.action.VIDEO_CAMERA" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;/intent-filter&gt; &lt;!-- App links for http/s --&gt; &lt;intent-filter android:autoVerify="true"&gt; &lt;action android:name="android.intent.action.VIEW" /&gt; &lt;category android:name="android.intent.category.DEFAULT" /&gt; &lt;category android:name="android.intent.category.BROWSABLE" /&gt; &lt;data android:scheme="http" /&gt; &lt;data android:scheme="https" /&gt; &lt;data android:host="example.android.com" /&gt; &lt;data android:pathPattern="/camerax" /&gt; &lt;/intent-filter&gt; &lt;!-- Declare notch support --&gt; &lt;meta-data android:name="android.notch_support" android:value="true" /&gt; &lt;/activity&gt; </code></pre> <p>here is the log</p> <pre><code>E/AndroidRuntime: FATAL EXCEPTION: main Process: com.virtusync.scanningtool, PID: 28538 android.content.ActivityNotFoundException: Unable to find explicit activity class {com.virtusync.scanningtool/com.android.example.cameraxbasic.MainActivityKt}; have you declared this activity in your AndroidManifest.xml? at android.app.Instrumentation.checkStartActivityResult(Instrumentation.java:2005) at android.app.Instrumentation.execStartActivity(Instrumentation.java:1673) at android.app.Activity.startActivityForResult(Activity.java:4586) at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:675) at android.app.Activity.startActivityForResult(Activity.java:4544) at androidx.fragment.app.FragmentActivity.startActivityForResult(FragmentActivity.java:662) at android.app.Activity.startActivity(Activity.java:4905) at android.app.Activity.startActivity(Activity.java:4873) at com.android.example.cameraxbasic.SelectOperation$1.onClick(SelectOperation.java:36) at android.view.View.performClick(View.java:7044) at android.view.View.performClickInternal(View.java:7017) at android.view.View.access$3200(View.java:784) at android.view.View$PerformClick.run(View.java:26596) at android.os.Handler.handleCallback(Handler.java:873) at android.os.Handler.dispatchMessage(Handler.java:99) at android.os.Looper.loop(Looper.java:193) at android.app.ActivityThread.main(ActivityThread.java:6819) at java.lang.reflect.Method.invoke(Native Method) at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run(RuntimeInit.java:497) at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:912) </code></pre> <p>I've done this <a href="https://stackoverflow.com/questions/54634397/how-to-fix-android-content-activitynotfoundexception-android-studio-2-3-3">How to fix &quot;android.content.ActivityNotFoundException&quot; android-studio 2.3.3</a> no solution yet</p>
<java><android><kotlin><activitynotfoundexception>
2020-02-17 13:59:10
LQ_CLOSE
60,264,259
How secure is GIT bundle
<p>I have two identical repositories on two separated internet-less machines.<br> The code is sensitive and cannot be exposed to the outside world (even not its diff).</p> <p>How secure is a git bundle file which contains only a delta update?<br> I know that one cannot pull from it if he does not have the initial base - <code>git bundle verify</code> will fail.<br> Opening the file with text editor does not reveal any segment of code.<br> Is there a way for a third party to open and see the code within?<br> <strong>How secure is it?</strong></p>
<git><git-bundle>
2020-02-17 14:07:27
LQ_CLOSE
60,264,848
Mapbox Examples in android studio - how to begin
I'd like to begin loading mapbox examples in AndroidStudio. I followed guides, but I'm struggling with dependencies problems. Can someone help me, please? I downloaded examples from github and loaded it in my AndroidStudio. I follow all explanations, dependencies.... repositories... ecc I syncronized Gradle and it is ok. But example don't works ! Is there any example that simply I can download and works? Thank and bye.
<android><sdk><mapbox>
2020-02-17 14:43:05
LQ_EDIT
60,264,933
Runtime error with Angular 9 and Ivy: Cannot read property 'id' of undefined ; Zone
<p>We have an Angular 8 project with tests. We are attempting to upgrade to Angular 9 and went through all the steps in <a href="https://update.angular.io/#8.0:9.0l3" rel="noreferrer">https://update.angular.io/#8.0:9.0l3</a>. This all went smoothly, no issues. The app compiles with no errors and all of the tests run fine. We are getting this error at runtime. When we turn off Ivy, it runs fine so definitely seems related to Ivy. </p> <pre><code>zone-evergreen.js:659 Unhandled Promise rejection: Cannot read property 'id' of undefined ; Zone: &lt;root&gt; ; Task: Promise.then ; Value: TypeError: Cannot read property 'id' of undefined at registerNgModuleType (core.js:35467) at core.js:35485 at Array.forEach (&lt;anonymous&gt;) at registerNgModuleType (core.js:35481) at core.js:35485 at Array.forEach (&lt;anonymous&gt;) at registerNgModuleType (core.js:35481) at new NgModuleFactory$1 (core.js:35649) at compileNgModuleFactory__POST_R3__ (core.js:41403) at PlatformRef.bootstrapModule (core.js:41768) TypeError: Cannot read property 'id' of undefined at registerNgModuleType (http://localhost:8080/vendor.js:41436:27) at http://localhost:8080/vendor.js:41454:14 at Array.forEach (&lt;anonymous&gt;) at registerNgModuleType (http://localhost:8080/vendor.js:41450:17) at http://localhost:8080/vendor.js:41454:14 at Array.forEach (&lt;anonymous&gt;) at registerNgModuleType (http://localhost:8080/vendor.js:41450:17) at new NgModuleFactory$1 (http://localhost:8080/vendor.js:41602:13) at compileNgModuleFactory__POST_R3__ (http://localhost:8080/vendor.js:46530:27) at PlatformRef.bootstrapModule (http://localhost:8080/vendor.js:46859:16) </code></pre>
<angular><angular9>
2020-02-17 14:47:08
HQ
60,265,461
matching regex in awk/gawk
<p>Can someone make the <code>awk</code> line below work in awk please. The syntax uses the standard PCRE regex standard (and i need to expect that some non-numeric characters are preceded to the first number, that is the string can look like <code>"++3.59 ± 0.04* "</code>). (note that I tried <code>[0-9]</code> and <code>[:digit:]</code> instead of <code>\d</code>) also note that I did read <a href="https://www.gnu.org/software/gawk/manual/gawk.html#Regexp" rel="nofollow noreferrer">https://www.gnu.org/software/gawk/manual/gawk.html#Regexp</a></p> <pre><code>gawk 'BEGIN{test="3.59 ± 0.04";match(test, /^.*?(\d+?\.\d+?)\s*?±\s*?(\d+?\.\d+?)$/, arr);print arr[1];}' </code></pre>
<regex><awk><regex-greedy>
2020-02-17 15:18:45
LQ_CLOSE
60,266,310
-0.1.ToString("0") is "-0" in .NET Core and "0" in .NET Framework
<pre><code>(-0.1).ToString("0") </code></pre> <p>evaluates to "-0" in .NET Core and "0" in .NET Framework when value is double or float. On the other hand when value is decimal:</p> <pre><code>(-0.1M).ToString("0") </code></pre> <p>it evaluates to "0" in both frameworks.</p> <p>Does anyone have more details on this change and which one is correct?</p>
<c#><.net><.net-core><tostring>
2020-02-17 16:07:44
HQ
60,267,506
Splitting a string that is converted to a list with a single item into multiple items
<p>I have a string that is converted to a list using the split() function, and I want to split my single item into multiple items each containing one character.</p> <p>Here's my code:</p> <pre><code>string = "ABCDEFG" x = string.split() print(x) </code></pre> <p>Thank you for your time!:D</p>
<python><list><indexing><split><whitespace>
2020-02-17 17:18:04
LQ_CLOSE
60,268,306
(Eliminate duplicates)
(Eliminate duplicates) Write a method that returns a new array by eliminating the duplicate values in the array using the following method header: public static int[] eliminateDuplicates(int[] list) Write a test program that reads in 10 integers, invokes the method, and displays the distinct numbers separated by exactly one space. Here is a sample run of the program: Enter 10 numbers: 1 2 3 2 1 6 3 4 5 2 The distinct numbers are: 1 2 3 6 4 5 package bucky; import java.util.Scanner; public class Arrays { public static void main(String[] args) { Scanner in = new Scanner(System.in); System.out.print("Enter ten numbers: "); int[] list = new int[10]; for (int i = 0; i < list.length; i++) { list[i] = in.nextInt(); } eliminateDuplicates(list); System.out.print("The distinct numbers are: "); for (int i = 0; i < list.length; i++) { System.out.print(list[i]); } } public static int[] eliminateDuplicates(int[] list) { int count = 0; int j = 0; int[] nArray = new int[list.length]; while (j < list.length) { for (int i = 1; i < list.length; i++) { int low = list[j]; if (list[i] == low) { count++; } else { nArray[i] = low; } } j++; } return nArray; } }
<java>
2020-02-17 18:13:46
LQ_EDIT
60,268,564
how to calculate the exponent from a power a law fitting of the data in python
<p>how to calculate the exponent from a power a law fitting of the data. I want to fit my data with y=x^a now I want to know the value of a (where x and y is given).I am using python.</p>
<python><python-3.x>
2020-02-17 18:37:01
LQ_CLOSE
60,268,719
How I use an external javasrript file inside .ts file without converting it?
<p>i have external javascript file. I want to use it in .ts file without converting it. Anyone have idea to use it inside typescript without converting.</p>
<javascript><angular><typescript><ionic-framework><ionic4>
2020-02-17 18:48:41
LQ_CLOSE
60,270,181
How can I check in javascript if it's day time or night time on the client?
<p>Using <a href="https://date-fns.org/v2.9.0/docs/isBefore" rel="nofollow noreferrer"><code>date-nfs</code></a>, how can I check if <code>new Date()</code> is between 8am and 8pm?</p>
<javascript><date><date-nfs>
2020-02-17 20:47:40
LQ_CLOSE
60,270,386
Count number of matching words from an array of words with another array of sentence in Javascript
<pre><code>var word_array = ['apple', 'mango', 'school']; var sentences = [ {name: 'Jon', info: 'Jon takes apple in school'}, {name: 'Anna', info: 'Anna loves to eat mango'}, {name: 'Dani', info: 'Dani wants to go to park today'} ]; </code></pre> <p>I want to count the matched words for each names of the sentences.</p> <pre><code>Output: Result = [ {name: 'Jon', count: 2}, {name: 'Anna', count: 1}, {name: 'Dani', count: 0} ]; </code></pre>
<javascript>
2020-02-17 21:04:35
LQ_CLOSE
60,270,488
How to create brick pattern in WPF in code?
<p>This question is similar to others, but my research has not uncovered the answer I seek. I am trying to fill a rectangle with a brick pattern. I understand there is not a HatchBrush in WPF and if there was perhaps I would do this: <code>HatchBrush brush = new HatchBrush(HatchStyle.DiagonalBrick,System.Drawing.Color.Black);</code> But since there is not I am using a DrawingBrush as follows, which fills the rectangle with a darkblue solid color. Where do I specify the DiagonalBrick?</p> <pre><code>Rectangle fillRect = new Rectangle(); //Try to fill fillRect with a pattern Rect aRect = new Rect(); aRect.Width = fillRect.Width; aRect.Height = fillRect.Height; GeometryGroup rectangle = new GeometryGroup(); GeometryDrawing geomDrawing = new GeometryDrawing(Brushes.DarkBlue,null, rectangle); DrawingBrush drawingBrush = new DrawingBrush(); rectangle.Children.Add(new RectangleGeometry(aRect, 0, 0)); geomDrawing.Geometry = rectangle; drawingBrush.Drawing = geomDrawing; fillRect.Fill = drawingBrush; </code></pre>
<c#><wpf>
2020-02-17 21:15:25
LQ_CLOSE
60,271,134
Which way is faster when stripping part of string in JavaScript
<p>I need to strip part of JWT token and I am courious which one is faster, or less complex internally.</p> <p>Example input string:</p> <pre><code>const input = "eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJzdWIiOjMsInR5cGUiOjAsImlhdCI6MTU4MTk3NDk1MCwiZXhwIjoxNTgxOTc4NTUwfQ.oEwxI51kVjB6jJUY2N5Ct6-hO0GUCUonolPbryUo-lI" </code></pre> <p>Which one of those methods is faster?</p> <pre class="lang-js prettyprint-override"><code>const output = input.split('.').slice(2,3).join('.'); </code></pre> <pre class="lang-js prettyprint-override"><code>const output = input.replace("eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.",""); </code></pre> <pre class="lang-js prettyprint-override"><code>const output = //REGEX replace </code></pre> <p>I not found any informations about speeds of those methods and I am not exactly master in making tests :D</p>
<javascript><performance><strip><code-complexity>
2020-02-17 22:15:35
LQ_CLOSE
60,273,387
Will I be Charged for a VM instance which was running in a project I shut down?
<p>I have recently shut down a project and I had a VM instance running in that. Will that charge my free trial credit even after shut down?? If yes, will it charge even after deletion(after 30 days of shut down)</p>
<google-cloud-platform><google-compute-engine><gcloud>
2020-02-18 03:35:37
LQ_CLOSE
60,275,113
hi please help my multidex is not resolving
Gayatri Anushka 1 second ago hi please help, my android.support.multidex.MultiDexApplication is still red after all the steps :( please help, not able to resolve this. im following a course online but no help. can I omit multidex? android { compileSdkVersion 28 buildToolsVersion "29.0.2" defaultConfig { applicationId "com.example.ping" minSdkVersion 21 targetSdkVersion 28 multiDexEnabled true versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android-optimize.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation "org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'androidx.appcompat:appcompat:1.0.2' implementation 'androidx.core:core-ktx:1.0.2' implementation 'com.android.support:support-v4:28.0.0' implementation 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.android.support:multidex:1.0.3' implementation 'com.google.firebase:firebase-analytics:17.2.2' implementation 'com.google.firebase:firebase-auth:19.2.0' implementation 'com.google.firebase:firebase-firestore:21.4.0' implementation 'com.google.firebase:firebase-storage:19.1.1' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test.ext:junit:1.1.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.1.1' } apply plugin: 'com.google.gms.google-services' manifest- <?xml version="1.0" encoding="utf-8"?> <manifest xmlns:android="http://schemas.android.com/apk/res/android" package="com.example.ping"> <application android:name="android.support.multidex.MultiDexApplication" (this part is showing error) >
<android><firebase><android-multidex>
2020-02-18 06:37:22
LQ_EDIT
60,276,013
Property 'allSettled' does not exist on type 'PromiseConstructor'.ts(2339)
<p>I try to use <a href="https://developer.mozilla.org/zh-CN/docs/Web/JavaScript/Reference/Global_Objects/Promise/allSettled" rel="noreferrer">Promise.allSettled</a> API with TypeScript. Code here:</p> <p><code>server.test.ts</code>:</p> <pre class="lang-js prettyprint-override"><code>it('should partial success if QPS &gt; 50', async () =&gt; { const requests: any[] = []; for (let i = 0; i &lt; 51; i++) { requests.push(rp('http://localhost:3000/place')); } await Promise.allSettled(requests); // ... }); </code></pre> <p>But TSC throws an error: </p> <blockquote> <p>Property 'allSettled' does not exist on type 'PromiseConstructor'.ts(2339)</p> </blockquote> <p>I already added these values to <code>lib</code> option of <code>tsconfig.json</code>:</p> <p><code>tsconfig.json</code>:</p> <pre><code>{ "compilerOptions": { /* Basic Options */ "target": "ES2015" /* Specify ECMAScript target version: 'ES3' (default), 'ES5', 'ES2015', 'ES2016', 'ES2017','ES2018' or 'ESNEXT'. */, "module": "commonjs" /* Specify module code generation: 'none', 'commonjs', 'amd', 'system', 'umd', 'es2015', or 'ESNext'. */, "lib": [ "ES2015", "ES2016", "ES2017", "ES2018", "ES2019", "ES2020", "ESNext" ] // ... } </code></pre> <p>TypeScript version: <code>"typescript": "^3.7.3"</code></p> <p>So, how can I solve this? I know I can use an alternative module, but I am curious about working with TypeScript natively.</p>
<javascript><typescript><es6-promise>
2020-02-18 07:43:35
HQ
60,279,884
How to get params from response API Google via PHP
<p>I use PHP call API from Google, but the API response is a function. someone know how can I get params "results" in response. Thanks</p> <p><a href="https://i.stack.imgur.com/FxH9S.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FxH9S.png" alt="G"></a></p>
<php><json><api><parameters><response>
2020-02-18 11:28:59
LQ_CLOSE
60,281,914
vb.net FileExist returns false
I have a weird problem. I have a folder with 700+ .jpgs Then I have a Textbox with one filename per line. Now I want to check which file does not exist in the folder, but should be there. This is my code: Dim Counter As Integer = 0 For Each Line As String In tbFileNames.Lines Counter = Counter + 1 If (IO.File.Exists(tbFolder.Text & "\" & tbFileNames.Lines(Counter - 1).ToString & ".jpg")) = False Then tbNotExistingFiles.Text = tbNotExistingFiles.Text & vbNewLine & (tbFileNames.Lines(Counter - 1).ToString) Else End If Next Problem: I get more than 300 "missing" files, but there should be only 7. When I search for the output filenames, they are in the folder, so the FileExists functions returns false, but it shouldn´t.. Where is the problem? Is it the amount of files? Thank you.. :) Bets regards
<vb.net>
2020-02-18 13:23:11
LQ_EDIT
60,282,611
What does the "!!" operator mean in Kotlin?
<p>I'm reading this <a href="https://developer.android.com/jetpack/docs/guide" rel="nofollow noreferrer">guide</a> from Google for Android and they have the snippet bellow.</p> <p>What does the <code>!!</code> do in <code>userDao.save(response.body()!!)</code>?</p> <pre><code>private fun refreshUser(userId: String) { // Runs in a background thread. executor.execute { // Check if user data was fetched recently. val userExists = userDao.hasUser(FRESH_TIMEOUT) if (!userExists) { // Refreshes the data. val response = webservice.getUser(userId).execute() // Check for errors here. // Updates the database. The LiveData object automatically // refreshes, so we don't need to do anything else here. userDao.save(response.body()!!) } } } </code></pre>
<android><kotlin>
2020-02-18 13:59:40
LQ_CLOSE
60,287,591
How to Replace a PHP File With an Existing PHP File
<p>So currently I have two PHP files, they are identical. There is a function that updates the current file being used to add data and also a clear function. I want the clear function on the first file to replace itself with the content of the second. </p>
<php>
2020-02-18 18:48:47
LQ_CLOSE
60,289,095
How to scrape tables from some URL in Javascript?
<p>In Python it is very simple: pandas.read_html("some URL");</p> <p>I am wondering what's the best way to do this in Javascript. Is there some existing library that can help with this?</p>
<javascript><python><web-scraping>
2020-02-18 20:38:13
LQ_CLOSE
60,290,309
error NG6002: Appears in the NgModule.imports of AppModule, but could not be resolved to an NgModule class
<p>First time using firestore and I'm getting this error. It seems to be a problem with Ivy, from my research. I don't have a lot of experience modifying tsconfig.app.json, which is the direction I've been pointed to, following other answers.</p> <p>The only thing I was able to modify from the original project was to use Angular Fire 6 instead of 5, which I had done initially to follow a tutorial. </p> <p>Here's package.json:</p> <pre><code>{ "name": "language", "version": "0.0.0", "scripts": { "ng": "ng", "start": "ng serve", "build": "ng build", "test": "ng test", "lint": "ng lint", "e2e": "ng e2e" }, "private": true, "dependencies": { "@angular/animations": "~9.0.1", "@angular/cdk": "^9.0.0", "@angular/common": "~9.0.1", "@angular/compiler": "~9.0.1", "@angular/core": "~9.0.1", "@angular/fire": "^6.0.0-rc.1", "@angular/flex-layout": "^9.0.0-beta.29", "@angular/forms": "~9.0.1", "@angular/material": "^9.0.0", "@angular/platform-browser": "~9.0.1", "@angular/platform-browser-dynamic": "~9.0.1", "@angular/router": "~9.0.1", "firebase": "^7.8.2", "rxjs": "~6.5.4", "rxjs-compat": "^6.5.4", "tslib": "^1.10.0", "zone.js": "~0.10.2" }, "devDependencies": { "@angular-devkit/build-angular": "~0.900.2", "@angular/cli": "~9.0.2", "@angular/compiler-cli": "~9.0.1", "@angular/language-service": "~9.0.1", "@types/node": "^12.11.1", "@types/jasmine": "~3.3.8", "@types/jasminewd2": "~2.0.3", "codelyzer": "^5.1.2", "jasmine-core": "~3.4.0", "jasmine-spec-reporter": "~4.2.1", "karma": "~4.1.0", "karma-chrome-launcher": "~2.2.0", "karma-coverage-istanbul-reporter": "~2.0.1", "karma-jasmine": "~2.0.1", "karma-jasmine-html-reporter": "^1.4.0", "protractor": "~5.4.0", "ts-node": "~7.0.0", "tslint": "~5.15.0", "typescript": "~3.7.5", "@angular-devkit/architect": "^0.900.0-0 || ^0.900.0", "firebase-tools": "^7.12.1", "fuzzy": "^0.1.3", "inquirer": "^6.2.2", "inquirer-autocomplete-prompt": "^1.0.1" } } </code></pre> <p>angular.json</p> <pre><code>{ "$schema": "./node_modules/@angular/cli/lib/config/schema.json", "version": 1, "newProjectRoot": "projects", "projects": { "language": { "projectType": "application", "schematics": { "@schematics/angular:component": { "style": "scss" } }, "root": "", "sourceRoot": "src", "prefix": "app", "architect": { "build": { "builder": "@angular-devkit/build-angular:browser", "options": { "outputPath": "dist/language", "index": "src/index.html", "main": "src/main.ts", "polyfills": "src/polyfills.ts", "tsConfig": "tsconfig.app.json", "aot": true, "assets": [ "src/favicon.ico", "src/assets" ], "styles": [ "./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css", "src/styles.scss" ], "scripts": [] }, "configurations": { "production": { "fileReplacements": [ { "replace": "src/environments/environment.ts", "with": "src/environments/environment.prod.ts" } ], "optimization": true, "outputHashing": "all", "sourceMap": false, "extractCss": true, "namedChunks": false, "extractLicenses": true, "vendorChunk": false, "buildOptimizer": true, "budgets": [ { "type": "initial", "maximumWarning": "2mb", "maximumError": "5mb" }, { "type": "anyComponentStyle", "maximumWarning": "6kb", "maximumError": "10kb" } ] } } }, "serve": { "builder": "@angular-devkit/build-angular:dev-server", "options": { "browserTarget": "language:build" }, "configurations": { "production": { "browserTarget": "language:build:production" } } }, "extract-i18n": { "builder": "@angular-devkit/build-angular:extract-i18n", "options": { "browserTarget": "language:build" } }, "test": { "builder": "@angular-devkit/build-angular:karma", "options": { "main": "src/test.ts", "polyfills": "src/polyfills.ts", "tsConfig": "tsconfig.spec.json", "karmaConfig": "karma.conf.js", "assets": [ "src/favicon.ico", "src/assets" ], "styles": [ "./node_modules/@angular/material/prebuilt-themes/deeppurple-amber.css", "src/styles.scss" ], "scripts": [] } }, "lint": { "builder": "@angular-devkit/build-angular:tslint", "options": { "tsConfig": [ "tsconfig.app.json", "tsconfig.spec.json", "e2e/tsconfig.json" ], "exclude": [ "**/node_modules/**" ] } }, "e2e": { "builder": "@angular-devkit/build-angular:protractor", "options": { "protractorConfig": "e2e/protractor.conf.js", "devServerTarget": "language:serve" }, "configurations": { "production": { "devServerTarget": "language:serve:production" } } }, "deploy": { "builder": "@angular/fire:deploy", "options": {} } } } }, "defaultProject": "language" } </code></pre> <p>tsconfig.app.json</p> <pre><code>{ "extends": "./tsconfig.json", "compilerOptions": { "outDir": "./out-tsc/app", "types": [], }, "files": [ "src/main.ts", "src/polyfills.ts" ], "include": [ "src/**/*.d.ts" ], "exclude": [ "src/test.ts", "src/**/*.spec.ts" ] } </code></pre> <p>Thanks!</p>
<angular><google-cloud-firestore><angularfire>
2020-02-18 22:24:39
HQ
60,291,542
150 years ago today in PHP
<p>I am looking to have a one line return function to get the date 150 years ago from today.</p> <p>I currently have,</p> <pre><code>return date('Y-m-d', strtotime('-150 year')); </code></pre> <p>The problem is this returns 1970-01-01 instead of 150 years ago.</p> <p>Why is this?</p>
<php><function><date>
2020-02-19 00:58:41
LQ_CLOSE
60,292,096
Why C# List<T> Add method is very slow
I have asp.net mvc project with dapper read data from database and I need export to excel. Dapper is fast ! `ExecuteReader` only 35 seconds. But `list.Add(InStock);` spend too much time !!! Over 1020 seconds !! Is there any idea ?? Thank you !! public List<InStock> GetList(string stSeId, string edSeId, string stSeDay, string edSeDay, string qDate) { List<InStock> list = new List<InStock>(); InStock InStock = null; IDataReader reader; using (var conn = _connection.GetConnection()) { try { conn.Open(); //******************Only 35 seconds***** reader = conn.ExecuteReader(fileHelper.GetScriptFromFile("GetInStock"), new { STSeId = stSeId, EDSeId = edSeId, STSeDay = stSeDay, EDSeDay = edSeDay, qDate = qDate }); //************************************* //******************Over 1020 seconds********** while (reader.Read()) { InStock = new InStock(); InStock.ColA = reader.GetString(reader.GetOrdinal("ColA")); InStock.ColB = reader.GetString(reader.GetOrdinal("ColB")); InStock.ColC = reader.GetString(reader.GetOrdinal("ColC")); list.Add(InStock); } //********************************************* return list; } catch (Exception err) { throw err; } } } [1]: https://i.stack.imgur.com/gJJ1k.png
<c#><.net><ado.net><dapper><generic-list>
2020-02-19 02:22:09
LQ_EDIT
60,293,057
Regex to Filter string with unicode characters and emojis for java
<p>I'm developing a Spring boot chat application. How can I create a regex to achieve followings,</p> <ul> <li>Remove special characters</li> <li>remove newlines tabs etc..</li> <li>Accept Unicode characters</li> <li>Accept for emojis</li> </ul> <p>further, DB tables <code>CHARACTER SET</code> <code>utf8mb4</code> and <code>COLLATE</code> <code>utf8mb4_bin</code>.</p>
<java><regex><spring-boot><unicode><emoji>
2020-02-19 04:30:57
LQ_CLOSE
60,293,646
How can I select max TASK_ID and CREATED_DATE from below data? Have already tried using MAX and DISTINCT
I have this data: REFERENCE_NO TASK_ID CREATED_DATE 244038 83102 2020-01-14 09:23:21:000000 244038 83114 2020-01-14 09:23:21:867000
<sql><sql-server>
2020-02-19 05:32:15
LQ_EDIT
60,294,250
How to transform given dataset in python?
<pre><code> 1 0.0 6.400000000 2 6.400000000 27.0 2 27.0 27.100000000 2 27.100000000 27.400000000 2 27.400000000 27.700000000 2 27.700000000 30.600000000 1 30.600000000 31.0 1 31.0 36.600000000 1 36.600000000 36.900000000 1 36.900000000 37.100000000 1 37.100000000 37.100000000 1 37.100000000 37.300000000 1 37.300000000 37.800000000 1 37.800000000 38.900000000 1 38.900000000 39.200000000 1 39.200000000 39.300000000 1 39.300000000 39.500000000 1 39.500000000 39.700000000 2 39.700000000 42.600000000 2 42.600000000 42.600000000 2 42.600000000 42.800000000 1 42.800000000 44.900000000 1 44.900000000 45.600000000 2 45.600000000 51.0 1 51.0 51.800000000 </code></pre> <pre><code> 1 0.0 6.400000000 2 6.400000000 30.600000000 1 30.600000000 39.500000000 ... so on </code></pre> <p>I want to transform my data in the above format. I tried this with groupBy min and max for column but it seems like it doesn't give me the desirable results. </p>
<python><pandas><numpy>
2020-02-19 06:26:00
LQ_CLOSE
60,295,938
Change many values with specific
<p>I have data like this:</p> <pre><code>data.frame(text1 = c("Amazon", "Google", "other")) </code></pre> <p>Add I would like to replace whatever is in the list with a specific value</p> <pre><code>mylist &lt;- c("Amazon", "Google") </code></pre> <p>replace what is in the mylist with stock value</p> <p>Expected output:</p> <pre><code>data.frame(text1 = c("stock", "stock", "other")) </code></pre>
<r>
2020-02-19 08:30:31
LQ_CLOSE
60,297,809
HTML filepicker multi - get files in use
<p>The following problem occured using Firefox v73 on Window 7:</p> <p>In my code i use a multi-file-picker in html to upload up to 100-files parallal:</p> <pre><code>&lt;input type="file" id="files" name="files" multiple&gt; </code></pre> <p>The files will be sent to a REST-API which process them afterwards. When i select a single file (in the file-explorer) which is currently in use, i get a error-message (probably by window) which tells me, that the file cannot be picked because it is in use. If i try to pick multiple-files which contain one or more files in use, i have no error occuring but the upload seems to stop when the file-in-use is reached and waiting for the file to be released. This leads to request to wait for a timeout (which is 1 minute in my case).</p> <p>Is there any option to catch the problem (in use file) before trying to upload the files?</p> <p>PS: I've tried the same in Chrome and it returns a error before sending the request to the REST-API.</p>
<html><firefox><multifile-uploader><filepicker>
2020-02-19 10:09:09
HQ
60,298,691
Jquery - Get all the option fields of a select and save the value and id and compare with var string and is inside
I have a select with several option, each option has an id and the value. This select is loaded with an ajax in jquery. There is also a string variable that contains a text, with which you would have to compare all the option values and if any of them are within this text, select the option value as selected. Example: var mytexto = 'Ipad Mini 4 16GB/1GB Azul'; <select id="nombre_modelo" class="form-control"> <option value="" disabled="disabled" selected="selected">Select one model name</option> <option id="25">Ipad 3</option> <option id="26">Ipad 4</option> <option id="27">Mini 4</option> <option id="28">Mini Wifi A1403</option> <option id="29">Mini Wifi A1432</option> </select> In this example you would have to get the id = '27 'and the value =' Mini 4 'of "<option id="27"> Mini 4</option>" which is the one inside the string. How do I get these two values, the id and the value?
<javascript><jquery><html>
2020-02-19 10:53:37
LQ_EDIT
60,301,120
JavaFx and file
<p>How can I write to file using javaFx and scene builder for a simple form? </p> <p>I just want the user data to be saved in the file. Also, I have problems creating the file. Should I create the file in a new java Class, or? </p>
<java><file><javafx>
2020-02-19 13:09:20
LQ_CLOSE
60,303,315
Why hasn't this list changed?
<p>In the following code, the function modify_list want to modify b, but it failed, the print result is [1,2,3]. why hasn't the list a changed?</p> <pre><code>def modify_list(b): b = [1,2] a = [1,2,3] modify_list(a) print(a) </code></pre>
<python><list>
2020-02-19 15:07:31
LQ_CLOSE
60,304,580
Regex for matching decimals only, not integers
<p>I'm looking for a regex to match decimal numbers only, but to fail on integers.</p> <p>For example, the following numbers should pass</p> <pre><code>0.00 1.00 -1.00 3.3 2.22123 </code></pre> <p>But the following should fail</p> <pre><code>-1 -3 4 559 </code></pre> <p>I don't know why this is so hard to find/create, but I'm not having any luck. All available regexes that I found online don't exclude integers.</p>
<regex>
2020-02-19 16:08:31
LQ_CLOSE
60,305,061
Python type hints for types not yet defined
<p>How do I provide type hints for an alternative constructor for a class? For example if I have a method like this converting something to my new class,</p> <pre><code>class MyClass: @classmethod def from_string(cl: Type[????], s: str) -&gt; ????: p, q = some_function(s) return cl(p, q) </code></pre> <p>what should I write for <code>????</code>? It should by nature just be <code>MyClass</code>, but that variable is not defined yet at the time when the method definition is executed.</p>
<python><typing>
2020-02-19 16:34:10
LQ_CLOSE
60,305,152
How to query document reference type from firestore using flutter
<p>I have a field in my customers collection referencing a list of collection references that point to orders, how do I retrieve all the orders from my customer collection. What I hope to do is retrieve a list of orders for a specific customer based on an id. Thank you!</p> <p><a href="https://i.stack.imgur.com/IkStg.png" rel="nofollow noreferrer">Customers collection with order references</a></p> <p><a href="https://i.stack.imgur.com/y6cJP.png" rel="nofollow noreferrer">Order data that I want to retrieve</a></p>
<firebase><flutter><dart><google-cloud-firestore>
2020-02-19 16:38:09
LQ_CLOSE
60,305,158
REVERSE function returns just a single char
<p>Using the built in REVERSE function on a nvarchar I expect '51.02' to be returned but instead receive 2.</p> <pre><code>DECLARE @HourMins nvarchar = '20.15' SELECT REVERSE(@HourMins) digs </code></pre> <p>Can anyone tell me why?</p> <p><a href="https://i.stack.imgur.com/sAlpu.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/sAlpu.png" alt="enter image description here"></a></p>
<sql><tsql>
2020-02-19 16:38:30
LQ_CLOSE
60,306,854
Creating objects in bulk and prining the names of the objects
<p>I wanted to make a 100 objects from the same class and print the names of the objects each time they were created. Something like this:</p> <pre><code>class Human(): def __init__(self): #print the name of the object human1 = Human() human2 = Human() human3 = Human() human4 = Human() human5 = Human() ....... </code></pre> <p>I was able to come this far:</p> <pre><code>class Human(): def __init__(self): #print the name of the object for i in range(1,101): #'human' + str(i) = Human() </code></pre> <p>But I got stuck since in python you cannot define objects as the way I tried to and I couldn't find a way to print the name of the object. Anything that could help?</p>
<python><python-3.x><class><oop><object>
2020-02-19 18:20:36
LQ_CLOSE
60,307,044
JavaScript alert not showing up in the browser page but at the right hand side of screen
<p>Visual Studio Code must have had an update. I wasn't able to find anything on their website but I wasn't seeing my alert I created like it used to appear on the browser page and then I noticed that the alert is at the bottom right hand of the screen outside of the browser page but inside the Visual Studio Code. Is there any way to make this show up in the browser preview using extension for Live Server?<a href="https://i.stack.imgur.com/aS6Mh.jpg" rel="nofollow noreferrer">See attached screen shot - scroll to the bottom right to see the alert.</a></p>
<javascript>
2020-02-19 18:32:38
LQ_CLOSE
60,307,864
unresolved external symbol _MsiLocateComponentW@12
<p>I know that simply posting code and asking for a solution isn't a good idea, but I have no idea what's causing this.</p> <p>I'm trying to find the installation path of PowerPoint based on <a href="https://docs.microsoft.com/en-us/previous-versions/office/troubleshoot/office-developer/find-office-installation-path" rel="nofollow noreferrer">this code</a>, however, the compiler gives this error:</p> <pre><code>error LNK2019: unresolved external symbol _MsiLocateComponentW@12 referenced in function _WinMain@16 </code></pre> <p>I'm using Visual Studio 2019 and IntelliSense doesn't notice the error, only the compiler. Here's the code:</p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;Windows.h&gt; #include &lt;msi.h&gt; int APIENTRY WinMain(_In_ HINSTANCE hInstance, _In_opt_ HINSTANCE hPrevInstance, _In_ LPSTR lpCmdLine, _In_ int nShowCmd) { LPCWSTR PowerPoint = L"{CC29E94B-7BC2-11D1-A921-00A0C91E2AA2}"; DWORD size = 300; INSTALLSTATE installstate; LPWSTR sPath; sPath = new wchar_t[size]; installstate = MsiLocateComponent(PowerPoint, sPath, &amp;size); if (installstate == INSTALLSTATE_LOCAL || installstate == INSTALLSTATE_SOURCE) MessageBox(NULL, sPath, L"PowerPoint path", MB_OK | MB_ICONASTERISK ); delete[] sPath; return 0; } </code></pre> <p>As you can see, I included the <code>msi.h</code> header. What's wrong with my code?</p>
<c++><windows><winapi>
2020-02-19 19:30:43
LQ_CLOSE
60,307,935
How do you make a div shaped like an ellipse in CSS?
<p>I am trying to make the following shapes with css. I don't know how I can do this, can you help?</p> <p><a href="https://i.stack.imgur.com/TnFna.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/TnFna.png" alt="ellipse divs"></a></p>
<html><css>
2020-02-19 19:35:05
LQ_CLOSE
60,308,405
Get value to the right of the decimal in python
<p>If I print 5/4 I get 1.25. How do I just get the .25 part. </p> <pre><code>print(5/4) 1.25 </code></pre>
<python>
2020-02-19 20:06:50
LQ_CLOSE
60,308,643
Stack has not been tested with GHC & Cabal versions
<p>In my Haskell project when I <code>stack run</code>, it is showing the following, but still runs. What warning is this? How can I get rid of it?</p> <pre><code>Stack has not been tested with GHC versions above 8.6, and using 8.8.2, this may fail Stack has not been tested with Cabal versions above 2.4, but version 3.0.1.0 was found, this may fail </code></pre>
<haskell><cabal><haskell-stack>
2020-02-19 20:23:26
HQ
60,309,261
C++: How do I assign a value from a 2D dynamic array to another 2D dynamic array since 'temp[0][0] = array[0][0]' doesn't work?
<p>I'm new to c++, and I'm trying to figure out how to get a 2D dynamic array called temp to get values from another 2D dynamic array called array. I couldn't figure out how to assign any values from array to temp because the statement 'temp[0][0] = array[0][0];' doesn't seem to assign the value of array[0][0] which is 1 to temp[0][0]. Instead, temp[0][0] seems to have the same random number in it after 'temp[0][0] = array[0][0]' before any value was assign to temp[0][0]. I tried to assign temp[0][0] to 2 and it works. I don't really know how to exactly assign values from one 2d dynamic array to another. Anyway thanks in advance for helping me out!</p> <pre><code> ... //initializing first 2D dynamic array int x=2; int y=2; int** array = new int*[x]; for(int i=0; i&lt;x; i++) array[i] = new int[y]; //initializing second 2D dynamic array int new_x=3; int new_y=3; int** temp = new int*[new_x]; for(int i=0; i&lt;new_x; i++) temp[i] = new int[new_y]; //assigning values array[0][0] = 1; cout &lt;&lt; array[0][0] &lt;&lt; endl; //output is 1 //before assigning values to temp[0][0] cout &lt;&lt; temp[0][0] &lt;&lt; endl; //out is a huge random number temp[0][0] = array[0][0]; cout &lt;&lt; temp[0][0] &lt;&lt; endl; //output is the same huge random number temp[0][0] = 2; cout &lt;&lt; temp[0][0] &lt;&lt; endl; //output is 2 ... </code></pre>
<c++><dynamic-arrays><assign>
2020-02-19 21:09:26
LQ_CLOSE
60,310,873
Execution failed for task ':app:mergeDexDebug'. Firestore | Flutter
<p>Trying to use Firestore in my project. My project is a brand new one, but having problems running the app on my device without getting an error: <strong>Execution failed for task ':app:mergeDexDebug'.</strong></p> <p>My app is using AndroidX. I've added my google-services.json file, followed the steps etc.</p> <p>Yaml file:</p> <pre><code>dependencies: cloud_firestore: ^0.13.3 </code></pre> <p>android/build.gradle:</p> <pre><code>com.google.gms:google-services:4.3.3 </code></pre> <p>Full error:</p> <blockquote> <p>FAILURE: Build failed with an exception.</p> <p>What went wrong: Execution failed for task ':app:mergeDexDebug'. A failure occurred while executing com.android.build.gradle.internal.tasks.Workers$ActionFacade com.android.builder.dexing.DexArchiveMergerException: Error while merging dex archives: The number of method references in a .dex file cannot exceed 64K. Learn how to resolve this issue at <a href="https://developer.android.com/tools/building/multidex.html" rel="noreferrer">https://developer.android.com/tools/building/multidex.html</a></p> </blockquote>
<flutter><dart><google-cloud-firestore>
2020-02-19 23:36:15
HQ
60,311,633
Average of empty list throws InvalidOperationException: Sequence contains no elements
<p>The following code</p> <pre><code>double avg = item?.TechnicianTasks?.Average(x =&gt; x.Rating) ?? 0 </code></pre> <p>throws </p> <blockquote> <p>InvalidOperationException: Sequence contains no elements</p> </blockquote> <p>the <code>item.TechnicianTasks</code> was supposed to be null, however I saw that it is an empty list, however why wouldn't the average just be zero? I'm not understanding the exception.</p>
<c#><linq>
2020-02-20 01:20:54
LQ_CLOSE
60,313,479
How can I write this in one line?
<p>Hey So I'm working on a problem that asks me to manipulate a dictionary by grabbing all the keys and values and formatting them into a single string for every key/value pair. I have to do this in one line, or so I think, the problem is better explained in the image.<a href="https://i.stack.imgur.com/aODwN.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/aODwN.png" alt="enter image description here"></a></p>
<python>
2020-02-20 05:31:58
LQ_CLOSE
60,314,531
How I can give access for everyone around the world to my spring boot app that started on my computer?
<p>I started my spring boot app on my computer, and now I can easily make Http requests to <code>http://localhost:8080/</code>. How I can give access to everyone around the world to make Http requests to my app without deploying this app anywhere? </p>
<java><spring><spring-boot><http><ip>
2020-02-20 07:06:54
LQ_CLOSE
60,319,192
Recursion with array's PHP
<p>I have a function (listarUrls ()) that returns / scans all the urls it finds on a web page. I need that for each of the urls that the function returns to me, I return to the list / scan all the urls of that page many times as requested by the user, that is</p> <pre><code> .If the user asks for 1 iteration of the url www.a.com, bring back: -$arry[0] www.1.com -$arry[1] www.2.com -..... So with all the urls you find in www.a.com .If the user asks for 2 iteration of the url www.a.com, bring back: -$arry[0] www.1.com -$arry[0][0] www.1-1.com -$arry[0][1] www.1-2.com -...So with all the urls you find in www.1.com -$arry[1] www.2.com -$arry[1][0] www.2-1.com -$arry[1][1] www.2-2.com -...So with all the urls you find in www.2.com -... .If the user asks for 3 iteration of the url www.a.com, bring back: -$arry[0] www.1.com -$arry[0][0] www.1-1.com -$arry[0][0][0] www.1-1-1.com -$arry[0][0][1] www.1-1-2.com -...So with all the urls you find in www.1-1.com -$arry[0][1] www.1-2.com -$arry[0][1][0] www.1-2-1.com -$arry[0][1][1] www.1-2-2.com -...So with all the urls you find in www.1-2.com -$arry[1] www.2.com -$arry[1][0] www.2-1.com -$arry[1][0][0] www.2-1-1.com -$arry[1][0][1] www.2-1-2.com -...So with all the urls you find in www.2-1.com -$arry[1][1] www.2-2.com -$arry[1][1][0] www.2-2-1.com -$arry[1][1][1] www.2-2-2.com -...So with all the urls you find in www.2-2.com -... </code></pre> <p>Could someone shed some light on the subject please?</p>
<php><arrays><recursion>
2020-02-20 11:44:32
LQ_CLOSE
60,320,534
Custom markers icons not displayed on android
<p>I have this code : </p> <pre><code>this.service.getListe(data).forEach((data: any) =&gt; { const marker: Marker = this.map.addMarkerSync(data); marker.on(GoogleMapsEvent.MARKER_CLICK).subscribe((params) =&gt; { this.click(params); }); }); </code></pre> <p>Now the <code>getListe()</code> looks like : </p> <pre><code>getListe(merchants: any) { const Liste: BaseArrayClass&lt;any&gt; = new BaseArrayClass&lt;any&gt;(); merchants.map(item =&gt; { Liste.push({ title: item.name, animation: 'DROP', position: { lat: item.lat, lng: item.long }, icon: 'http://icons.iconarchive.com/icons/iconarchive/red-orb-alphabet/24/Number-1-icon.png', disableAutoPan: true }); }); return Markers; } </code></pre> <p>I tried and like this : </p> <pre><code>icon: { url: 'http://icons.iconarchive.com/icons/iconarchive/red-orb-alphabet/24/Number-1-icon.png' } </code></pre> <p>But the same behaviour, the problem is that on emulator and on real device the icon is not changing. On browser mode I have for markers the correct icon that I indicate in BaseArrayClass, but on emulator I have default icon. Have you an idea about that ? </p>
<angular><google-maps><ionic-framework><ionic3>
2020-02-20 12:59:54
LQ_CLOSE
60,320,610
NameError: name '*' is not defined
<p>Why this line <code>add(root, sum, 0)</code> gets <code>NameError: name 'add' is not defined</code> error?</p> <pre><code>class Solution: def rob(root: TreeNode) -&gt; int: sum = [0, 0] add(root, sum, 0) if sum[0] &lt; sum[1]: return sum[1] else: return sum[0] def add(node: TreeNode, sum: List[int], index: int): if not node: return sum[index] += node.val index += 1 if index &gt;= len(sum): index = 0; add(node.left, sum, index) add(node.right, sum, index) </code></pre>
<python-3.x>
2020-02-20 13:04:52
LQ_CLOSE
60,321,460
Linq Query to Sum into new list
<p>I want to create a 2nd list from 1st list to show the sum with descending order.</p> <pre><code>1st list : ID Value 1 20 2 40 3 10 2nd List: ID Value 1 70 2 50 3 10 </code></pre>
<c#><linq>
2020-02-20 13:48:45
LQ_CLOSE
60,322,831
How do I append an HTTP header in this format in PHP (cURL)?
<p>I am trying to make a GET request in PHP using cURL and here is what the documentation says about my header:</p> <blockquote> <p>Append an HTTP header called zuluapi using the created signature.</p> <p><code>zuluapi &lt;publicKey&gt;:&lt;base 64 encoded signature&gt;</code></p> </blockquote> <p>I have the publicKey and signature, I just can't seem to figure out how to attach the header in the way they want. When I try to add the header, like below, I get bad header error.</p> <pre><code>$headers = [ "zuluapi {$public}:{$signedMessage}" ]; </code></pre>
<php><api><curl><http-headers>
2020-02-20 15:01:07
LQ_CLOSE
60,323,069
Java: check if value is 100 or 200 or 300 or x00
<p>In java, I increase a value in a <code>while</code> statement and I would like to perform an action when this value has specific values (without hardcoding it because it can in theory go to infinite):</p> <p>100, 200, 300, x00, etc.</p> <p>I know this has a specific name, but I cannot remember it (Modulo ? But if so, how ?).</p>
<java>
2020-02-20 15:13:58
LQ_CLOSE
60,323,245
excel, check if string contains a character a-z or A-Z
<p>I have a column with unstructured data. I need to detect if the string has an alphabetical character meaning a-z or A-Z. I am not sure how to do this in excel with a formula or other. I am thinking this could be a long countif and sumproduct. Or maybe regex in excel. I will post an attempt try once I try this out more. But I am looking for some advice. While searching online, I could not find a formula to do this. Thanks for your help. Please see below screenshot for sample data.</p> <p><a href="https://i.stack.imgur.com/ucKOl.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/ucKOl.png" alt="enter image description here"></a></p>
<excel><excel-formula>
2020-02-20 15:23:16
LQ_CLOSE
60,323,541
How to create an array object in the main method in java?
<p>I've just started Java this semester and I'm very new to it. I'm struggling to get an array method to print out anything through my main method. The example given below is from the notes, except for the info in the main method which I added, but I cannot get it to print anything through the main method since it gives me an error every time I try to compile it. </p> <p>This is the array method example that was given:</p> <pre><code>import java.util.*; </code></pre> <p>import java.text.*; public class ArrayDemo {</p> <pre><code>private static Random rng = new Random(); private static DecimalFormat format =new DecimalFormat(); static{ format.setMaximumFractionDigits(4); } public static void main(String [] args){ int num1 = 5; arrayDemo(num1); } public void arrayDemo(int n){ double [] a = new double[n]; double [] c = {42, -99.9999, rng.nextGaussian() * 50}; for (int i = 0; i &lt; a.length; i++){ a [i] = rng.nextDouble(); } double sum = 0; for (int i =0; i&lt; a.length; i++){ sum += a[i]; } System.out.println("The values add up to" + format.format(sum)); System.out.println("The elements are:" + Arrays.toString(a)); } } </code></pre> <p>The error that I keep getting is "non static method arrayDemo(int n) cannot be referenced from a static context.".</p> <p>I've searched up many tutorials on arrays but I still cannot figure out why I keep getting this error. Any help will be greatly appreciated.</p>
<java><arrays><methods>
2020-02-20 15:38:28
LQ_CLOSE
60,327,101
PHP will not echo variables
<p>I have the following very basic PHP script:</p> <pre><code> &lt;?php $username = $_POST['username']; $password = $_POST['password']; echo "This is the username: "; echo $username; ?&gt; </code></pre> <p>And this is the output:</p> <pre><code>This is the username: </code></pre> <p>I have my username and password parameters in my url. Why won't it echo the username?</p>
<php><output><echo>
2020-02-20 19:17:45
LQ_CLOSE
60,331,526
getElementById works only in Firefox
No much to say, my script works fine in Firefox but its not in Chrome or IE or Opera var ids = ['id1','id2']; function myfunction() { for (var i = 0; i < ids.length; i++) { var x = document.getElementById(ids[i]); if (x.style.display === "none") { x.style.display = "revert"; } else { x.style.display = "none"; } } }
<javascript><css>
2020-02-21 02:53:25
LQ_EDIT
60,331,539
ERROR in The Angular Compiler requires TypeScript >=3.6.4 and <3.8.0 but 3.8.2 was found instead
<p>I ran</p> <pre><code>ng version </code></pre> <p>and got the following output:</p> <pre><code>Angular CLI: 9.0.3 Node: 12.16.1 OS: win32 x64 Angular: 9.0.2 ... animations, common, compiler, compiler-cli, core, forms ... language-service, platform-browser, platform-browser-dynamic ... router Ivy Workspace: Yes Package Version ----------------------------------------------------------- @angular-devkit/architect 0.803.25 @angular-devkit/build-angular 0.803.25 @angular-devkit/build-optimizer 0.803.25 @angular-devkit/build-webpack 0.803.25 @angular-devkit/core 8.3.25 @angular-devkit/schematics 9.0.3 @angular/cdk 8.2.3 @angular/cli 9.0.3 @angular/material 8.2.3 @ngtools/webpack 8.3.25 @schematics/angular 9.0.3 @schematics/update 0.900.3 rxjs 6.5.4 typescript 3.8.2 webpack 4.39.2 </code></pre> <p>If I try set the type script lower it complains the project is Angular 9 and can't use that type of type script. Not sure what to do, any help welcomed, thanks.</p>
<angular><angular9>
2020-02-21 02:55:01
HQ
60,332,668
Why the return type of getchar() is int?
<p>I searched for the answer on Internet but I could not understand what is this 'EOF'? Please let me know from basic about what is getchar() and what are it's uses? Note that I am just a beginner of C language.</p>
<c><char><int><return-type><getchar>
2020-02-21 05:27:48
LQ_CLOSE
60,332,984
Hello. I want an efficient way to truncate unwanted part from string in a DataFrame column
Data looks like these. Particulars<br/> IMPS/P2A/924413019791/CRYSTALV/THEGREAT/<br/> MOB/QYW6RJS14956/Ratnakar Bank CreditCard<br/> IMPS/P2A/924517325604/rajdha/HDFCBAN/X539003/<br/> BY CASH DEPOSIT-BNA/SWRO12802/9635/040919/JABALPU<br/> IMPS/P2A/924809539696/pradee/THEGREA/X783336/<br/> IMPS/P2A/924911569760/HARISHMA/ICICIBAN/NA<br/> IMPS/P2A/924916252301/pradee/THEGREA/X783336/<br/> BY CASH DEPOSIT-BNA/SWRO12802/462/070919/JABALPU<br/> AXMOB/MBR/38VRWY425344/915010029584916/080919<br/> NEFT/MB/AXMB192527472717/Pradeep sbi<br/> I need it in this manner. To be truncated after second forward slash(/) IMPS/P2A<br/> MOB/QYW6RJS14956<br/> IMPS/P2A<br/> BY CASH DEPOSIT-BNA/SWRO12802<br/> IMPS/P2A IMPS/P2A IMPS/P2A BY CASH DEPOSIT-BNA/SWRO12802<br/> AXMOB/MBR NEFT/MB Obviously I have used lstrip and rstrip here but it doesnt work. Please let me know if there is any other way I can solve this problem. Any recommendations are welcome. Thanks in advance and please ignore any mistakes in posting my question as it is my first time.
<python><pandas><dataframe>
2020-02-21 06:05:42
LQ_EDIT
60,333,482
Translate ECMAScript 6's arrow function to a regular function
<p>Im trying to convert the script below to a normal function, but fail to understand how. </p> <p>The script counts the numbers of instances (model) in a Array (productList.Lockers) and appends it to a target div. </p> <pre><code>productList.Lockers.forEach(o =&gt; $('#' + o.model).siblings('#modelcount').text((i, t) =&gt; ( parseInt(t, 10) || 0) + 1 )); var modelCount = document.getElementById('allcount'); modelCount.innerHTML = productList.Lockers.length; </code></pre>
<javascript>
2020-02-21 06:52:09
LQ_CLOSE
60,335,115
HTTP Request, Object/Array Destructuring
<p>I have an array of objects, that are on an api.</p> <pre><code>{ "ErrorCode": 0, "ErrorMessage": null, "Warehouses": [ { "Code": null, "Name": "Depozit Fabrica", "WarehouseID": "cb4fbab4-b8db-4807-a2b0-fad710f1fd9e" }, { "Code": "3", "Name": "Depozit Magazin", "WarehouseID": "dfa08a15-e3a0-4d43-8af6-c24a9d43101c" }, { "Code": null, "Name": "Depozit Ograda", "WarehouseID": "0dc8318d-305c-4e09-a31c-aa6fd44bf2ca" } ] } </code></pre> <p>I got the "Name" of "Warehouses" showed in my DOM. These "Name" have different ID's. SO, what I'm trying to do is everytime I click on a certain "Name" object, I get its ID and further call another REST API, with this ID, that shows an assortment list for example.</p> <pre><code>async function getWarehouse() { const response = await fetch(url); const data = await response.json(); const { Warehouses } = data; for (var i = 0; i &lt; Warehouses.length; i++) { const dataItem = Warehouses[i].Name; console.log(dataItem); document.getElementById("depList").innerHTML += ` &lt;ul&gt; &lt;li class="data-item"&gt;${dataItem}&lt;/li&gt; &lt;/ul&gt; ` ... </code></pre>
<javascript><arrays><rest><api><object>
2020-02-21 08:54:26
LQ_CLOSE
60,335,328
Date Split and remove of timezone
I have array which contains the following the dates ``` { Mon Feb 17 2020 00:00:00 GMT+0530 (India Standard Time) ,Tue Feb 18 2020 00:00:00 GMT+0530 (India Standard Time) ,Wed Feb 19 2020 00:00:00 GMT+0530 (India Standard Time) ,Thu Feb 20 2020 00:00:00 GMT+0530 (India Standard Time) } ``` How can i remove the time zone and convert this date to ("date/month/year") i need these with the (/) and return them to a grid column wise. example like this <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> - |[17/02/2020] | [18/02/2020] | [19/02/2020] 1 ----- | - | - | - 2 ----- | - | - | - <!-- end snippet --> <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js -->
<javascript><arrays><model-view-controller>
2020-02-21 09:09:22
LQ_EDIT
60,335,706
Looping through JSON and printing child nodes
I have the following JSON: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> var departments = { "Department-1": [{ "fr": "Dept 1 - French", "en": "Dept 1" }], "Department-2": [{ "fr": "Dept 2 - French", "en": "Dept 2" }], "Department-3": [{ "fr": "Dept 3 - French", "en": "Dept 3" }] } <!-- end snippet --> What I'm trying to do is, if the user is on the French site (/fr), then show the French (fr) headers. To achieve this, I'm trying to loop through the object. Here's what I have tried to far: <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> if (window.location.href.indexOf("fr") > -1) { for (var key in departments) { if (departments.hasOwnProperty(key)) { console.log(key + " -> " + departments[key]); $(".department").append('<option value="' + key + '">' + key + '</option>'); } } } <!-- end snippet --> The above has the following console log: Department-1 -> [object Object] Department-2 -> [object Object] Department-3 -> [object Object] And my `select` markup looks like this: <select class="department" name="department" id="department"> <option>Department-1</option> <option>Department-2</option> <option>Department-3</option> </select> Whereas I'm after: <select class="department" name="department" id="department"> <option>Dept 1 - French</option> <option>Dept 2 - French</option> <option>Dept 3 - French</option> </select>
<javascript><json><loops>
2020-02-21 09:32:49
LQ_EDIT
60,341,523
Why we are using equals() method in HashMap and HashSet without implementing comparator interface?
<p>Why we are using equals() method in HashMap and HashSet without implementing the comparator interface?. I have seen some example programs in the above concept. But there without comparator interface, they are using equals() and hashcode() method. My question is ,can we use those methods without comparator interface? And also can we use equals() and hashcode() and compareTo() methods with comparable interface ?</p>
<java><collections>
2020-02-21 15:13:32
LQ_CLOSE
60,342,176
Adding 2 array `type`s in Golang
<p>I have a <code>type</code> called <code>EmployeeList</code> which is just an array of <code>Employee</code> structs. </p> <p>If I have to add/combine <code>EmployeeList</code> objects, I thought I could add them as follows</p> <pre><code>package main import ( "fmt" ) type Employee struct { Id int `json:"id"` Name string `json:"name"` } type EmployeeList []Employee func main() { listA := EmployeeList{ Employee{Id: 1, Name: "foo"}, Employee{Id: 2, Name: "bar"}, } listB := EmployeeList{ Employee{Id: 3, Name: "baz"}, } // Print the combined lists fmt.Println(append(listA, listB)) } </code></pre> <p>However the <code>append</code> is throwing an error:</p> <pre><code>./prog.go:24:21: cannot use listB (type EmployeeList) as type Employee in append </code></pre> <p>I get that it has to do with a mismatched / unexpected type, but I'm not sure how to add these two lists together? </p> <p>Thanks!</p>
<arrays><go><struct>
2020-02-21 15:53:18
LQ_CLOSE
60,342,476
Python if something repeat function
<p>I don't how to make the script repeat this function if the user doesn't input the correct information.</p> <pre><code>def installer(x): if x == "Y" or x == "y": print("Ok, Getting On with the install") noncustompath() elif x == "N" or x == "n": print("Ok, Cool") else: #Repeat function </code></pre> <p>Thanks.</p>
<python><if-statement>
2020-02-21 16:12:04
LQ_CLOSE
60,344,548
How to change string to lower case?
<p>Trying to make it so that if the user enters any vowel capitalized, it will return true. So, that's where I added the "letter = letter.toLowerCase();" but it's not working still..</p> <pre><code> public static boolean isVowel (String letter) { letter = letter.toLowerCase(); if (letter == "a" || letter == "e" || letter == "i" || letter == "o" || letter == "u" ) { return true; } else { return false; } } </code></pre>
<java><lowercase>
2020-02-21 18:40:37
LQ_CLOSE
60,344,818
How can I read in a specific number of characters from a line? (C++)
<p>I am working on a homework assignment where I need to error check the first line of a .txt file. In this case, the first line of the text file should read "Number of samples: ", followed by an unspecified number. If the line DOES NOT start with "Number of samples: ", I need to terminate the program after displaying an error message. Assuming that the line DOES start with the proper string, I need to read in the number as an unsigned integer. </p> <p>In summary, I need to read in 19 characters from a .txt file line. How do I go about doing that, while still being able to read in the rest of the line to store it as a variable?</p> <p>The libraries I'm using are iostream, string, ofstream, and ifstream if that matters.</p>
<c++><string><ifstream>
2020-02-21 19:04:21
LQ_CLOSE
60,345,358
when i want to connect have this problem "error": "Internal Server Error", "message": "No message available",
<p><a href="https://i.stack.imgur.com/waLH8.png" rel="nofollow noreferrer"> i have this code i can create a user i can get the username and password but i have an error when i want to connect </a></p> <p>@PostMapping("/signin")</p> <pre><code>public ResponseEntity&lt;?&gt; authenticateUser(@Valid @RequestBody LoginRequest loginRequest) { System.out.println("a"+loginRequest.getUsername()+loginRequest.getPassword()); Authentication authentication = authenticationManager.authenticate( new UsernamePasswordAuthenticationToken(loginRequest.getUsername(), loginRequest.getPassword())); System.out.println("a"+loginRequest.getUsername()+loginRequest.getPassword()); // new RuntimeException("Error: cccccc is not found."); SecurityContextHolder.getContext().setAuthentication(authentication); String jwt = jwtUtils.generateJwtToken(authentication); new RuntimeException("Error: cccccc is not found."+ jwt); // new RuntimeException("Error: cccccc is not found."); UserDetailslmpl userDetails = (UserDetailslmpl) authentication.getPrincipal(); List&lt;String&gt; roles = userDetails.getAuthorities().stream() .map(item -&gt; item.getAuthority()) .collect(Collectors.toList()); // new RuntimeException("Error: aaaa is not found."); return ResponseEntity.ok(new JwtResponse(jwt, userDetails.getId(), userDetails.getUsername(), userDetails.getEmail(), roles)); } </code></pre> <p><a href="https://i.stack.imgur.com/LftFB.png" rel="nofollow noreferrer">this is the error</a></p> <p><a href="https://i.stack.imgur.com/DZSHG.png" rel="nofollow noreferrer">the error on postman</a></p>
<spring><spring-boot><spring-security><jwt><jwt-auth>
2020-02-21 19:50:03
LQ_CLOSE
60,345,372
Is there a python function to replace a specific index in a specific list that is in a text file?
<p>What I want to do: I have a few lists in a text file now and want to change just 1 element of 1 of the lists using python. What I have done so far:</p> <p>Current txt file:</p> <pre><code>food,bought oranges,yes strawberry,no apples,no </code></pre> <p>I want it to appear like this after using the code to replace one of the "no" to "yes":</p> <pre><code>food,bought oranges,yes strawberry,no apples,yes </code></pre> <p>Is there any way to specifically change one index of the list?</p>
<python>
2020-02-21 19:51:48
LQ_CLOSE
60,345,653
Java arraylist project String and Ints
<p>I have to make a project using an array list and reading data from a file The file will contain input that looks something like this: </p> <p>4</p> <p>34 F</p> <p>23 M</p> <p>32 M</p> <p>43 F</p> <p>The 4 refers to how many racers there are; the numbers represent that racer's score and the F and M represent gender I have to output: Lowest score overall, Lowest female score, Lowest male score</p> <p>So from the data I inputted above, it would output</p> <p>23</p> <p>34</p> <p>32 </p> <p>This is what I have. I am in an intro java class and so it's not supposed to be a difficult project. I have no idea what to do. Please help. </p> <pre><code>import java.util.Scanner; import java.io.File; import java.io.IOException; import java.util.ArrayList; public Class Num public static void main(String[] args) throws IOException { Scanner inFile = new Scanner(new File("input")); ArrayList&lt;String&gt; list = new ArrayList&lt;&gt;(); ArrayList&lt;Integer&gt; scores = new ArrayList&lt;Integer&gt;(); int time = 0; String gender = ""; while (inFile.hasNext()){ list.add(inFile.nextLine()); scores.add(inFile.nextInt()); } int num = list.size(); } } </code></pre>
<java><arraylist>
2020-02-21 20:14:38
LQ_CLOSE
60,346,513
How to excecute script every 6 hours? JQUERY
I need to refresh token every 6hours so then I can use an api without doing login again. I'm trying like this: setInterval(function(){ var code = window.location.href.split("=").pop(); var xhr = new XMLHttpRequest(); xhr.open("POST", "https://api.mercadolibre.com/oauth/token?grant_type=authorization_code&client_id="+appID+"&client_secret="+secretKey+"&code="+code+"&redirect_uri="+redirectUri, true); xhr.onload = function () { console.log(xhr.responseText); }; xhr.send(); } }, 21600); Any Idea how could achieve this?
<javascript>
2020-02-21 21:36:26
LQ_EDIT
60,346,626
Enable remote errors with ASP.NET Core
<p>Normal ASP.NET (not core) applications could add this to the web.config to see errors from remote locations:</p> <pre><code>&lt;system.webServer&gt; &lt;httpErrors errorMode="Detailed" /&gt; &lt;/system.webServer&gt; </code></pre> <p>It was helpful for when you could not login to the actual server to see what the error message was.</p> <p>I can't seem to find the same setting in .Net Core.</p> <p><strong>How do I turn on remote error messages in ASP.NET Core?</strong></p>
<asp.net-core><.net-core><asp.net-core-3.1>
2020-02-21 21:46:31
LQ_CLOSE
60,350,762
How can I estimate standard error in maximum likelihood destinati in
<p>I can’t estimate standard error for parametri in maximum likelihood estimation. How could I do?</p>
<r><log-likelihood>
2020-02-22 09:30:49
LQ_CLOSE
60,354,200
Foobar - Test cases not passing - Disorderly escape (python)
0/10 test cases are passing. Here is the challenge description: (to keep formatting nice - i put the description in a paste bin) Link to challenge description: [https://pastebin.com/UQM4Hip9][1] [1]: https://pastebin.com/UQM4Hip9 Here is my trial code - PYTHON - (0/10 test cases passed) from math import factorial from collections import Counter from fractions import gcd def cycle_count(c, n): cc=factorial(n) for a, b in Counter(c).items(): cc//=(a**b)*factorial(b) return cc def cycle_partitions(n, i=1): yield [n] for i in range(i, n//2 + 1): for p in cycle_partitions(n-i, i): yield [i] + p def solution(w, h, s): grid=0 for cpw in cycle_partitions(w): for cph in cycle_partitions(h): m=cycle_count(cpw, w)*cycle_count(cph, h) grid+=m*(s**sum([sum([gcd(i, j) for i in cpw]) for j in cph])) return grid//(factorial(w)*factorial(h)) print(solution(2, 2, 2)) #Outputs 7 This code works in my python compiler on my computer but not on the foobar challenge?? Am I losing accuracy or something? Thank you for any time and help you can provide. If you downvote, can you provide a reason and not be so rude as this is a good question. I don't see anythign wrong with it.
<python><math><factorial><fractions>
2020-02-22 16:25:13
LQ_EDIT
60,355,185
can I start the code from a certain line in C++?
<p>Basically I want the code to go back and start again from a certain line after it's done something. For example, I have a menu where you can choose an action and if everything is finished in that action I want it to display the menu again.</p> <p>Here's some rough code to illustrate.</p> <pre><code> int option; cout &lt;&lt; "1"; cout &lt;&lt; "2"; cout &lt;&lt; "3"; cout &lt;&lt; "What option do you choose?"; cin &gt;&gt; option; if (option = 1) { //do something here //if finished start again with the menu options } else if (option = 2) { //do something here //if finished start again with the menu options } else { //do something here //if finished start again with the menu options } </code></pre>
<c++>
2020-02-22 18:05:41
LQ_CLOSE
60,355,189
Parsing Json in Golang (using struct)
I'm trying to parse JSON using Golang (I'm a n00b in Golang). Can anyone tell me why this is not working as expected?(I'm expecting it to print the Name here) : https://play.golang.org/p/tzY5hFUckhD
<go>
2020-02-22 18:06:05
LQ_EDIT
60,355,455
bad alloc c++ loading file in matrix
<p>I try to load a large file (20gb) and load it into a matrix. However I get a bad_alloc error when it tries to load the file in the matrix. My code is working on Mac but doesn't on Linux. </p> <p>Here is my code: </p> <pre><code>std::ifstream ifs(filename, std::ifstream::binary); loadModel(ifs); void loadModel(std::istream&amp; in) { input_ = std::make_shared&lt;Matrix&gt;(); input_-&gt;load(in); // bad_alloc } </code></pre>
<c++><bad-alloc>
2020-02-22 18:35:21
LQ_CLOSE
60,355,555
How can I right pad a numpy array with zeroes?
<p>I have a <code>numpy</code> array with shape <code>(1, 79, 161)</code>. I need to make the shape <code>(1, 100, 161)</code> by padding the center axis with zeroes to the right. What's the best way to accomplish this?</p>
<python><numpy>
2020-02-22 18:45:53
LQ_CLOSE