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
57,619,405
c# dao recordset findfirst operation not supported
Please refrain from the "Nobody uses DAO" tropes. I am a new hobbyist to C# but have a whole library of VBA DAO code/logic I am hoping to utilize (i.e. translate) in C#. I can get a table open in a recordset. But trying to check for an existing record with FindFirst throws "Operation is not supported for this type of object." And I can't find a way to refine a Recordset via SELECT or SQL. When working in the IDE, FindFirst is offered when working with DAO.Recordset variables so it must be part of the object. I recognize by how hard it is to find information that this is not a popular area. But it is supported and I assume that is because at least some are still utilizing it. For the near term, simply being able to check for existing records in a DB will go a long ways for me. So any help resolving this error would be GREATLY APPRECIATED. But I would further appreciate any help cracking open the door to C# DAO documentation, references or any other knowledge. (MS site only references VB.) I'm having no luck finding the right search terms. Thx
<c#><dao>
2019-08-23 03:08:42
LQ_EDIT
57,619,656
how to add a required positional argument to a python file using this code?
this code works great however I am having trouble with the variable called "time". therefor it is throwing an error saying - File "C:\Users\7\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 865, in run self._target(*self._args, **self._kwargs) TypeError: customDraw() missing 1 required positional argument: 'time' I have tried everyway I could think of to best define time in terms of the code I have for example below import win32api, win32con, win32gui, win32ui, timer, threading windowText = 'Ecclesiastes' hWindow = 0 def main(): hInstance = win32api.GetModuleHandle() className = 'MyWindowClassName' wndClass = win32gui.WNDCLASS() wndClass.style = win32con.CS_HREDRAW | win32con.CS_VREDRAW wndClass.lpfnWndProc = wndProc wndClass.hInstance = hInstance wndClass.hIcon = win32gui.LoadIcon(0, win32con.IDI_APPLICATION) wndClass.hCursor = win32gui.LoadCursor(None, win32con.IDC_ARROW) wndClass.hbrBackground = win32gui.GetStockObject(win32con.WHITE_BRUSH) wndClass.lpszClassName = className wndClassAtom = win32gui.RegisterClass(wndClass) exStyle = win32con.WS_EX_COMPOSITED | win32con.WS_EX_LAYERED | win32con.WS_EX_NOACTIVATE | win32con.WS_EX_TOPMOST | win32con.WS_EX_TRANSPARENT style = win32con.WS_DISABLED | win32con.WS_POPUP | win32con.WS_VISIBLE hWindow = win32gui.CreateWindowEx( exStyle, wndClassAtom, None, style, 0, # x 0, # y win32api.GetSystemMetrics(win32con.SM_CXSCREEN), # width win32api.GetSystemMetrics(win32con.SM_CYSCREEN), # height None, # hWndParent None, # hMenu hInstance, None # lpParam ) win32gui.SetLayeredWindowAttributes(hWindow, 0x00ffffff, 255, win32con.LWA_COLORKEY | win32con.LWA_ALPHA) ####### COLOR win32gui.SetWindowPos(hWindow, win32con.HWND_TOPMOST, 0, 0, 0, 0, win32con.SWP_NOACTIVATE | win32con.SWP_NOMOVE | win32con.SWP_NOSIZE | win32con.SWP_SHOWWINDOW) thr = threading.Thread(target=customDraw, args=(hWindow,)) thr.setDaemon(False) thr.start() win32gui.ShowWindow(hWindow, win32con.SW_SHOWNORMAL) win32gui.UpdateWindow(hWindow) timer.set_timer(10000, customDraw) win32gui.PumpMessages() counter = 0 def customDraw(timer_id, time): global hWindow global counter global windowText if counter > 1589: counter = 0 text = ["1:1 The words of the Preacher, the son of David, king in Jerusalem.", "12:14 For God shall bring every work into judgment, with every secret thing, whether it be good, or whether it be evil. ",] windowText = text[counter] counter = counter + 1 win32gui.InvalidateRect(hWindow, None, True) def wndProc(hWnd, message, wParam, lParam): if message == win32con.WM_PAINT: hdc, paintStruct = win32gui.BeginPaint(hWnd) dpiScale = win32ui.GetDeviceCaps(hdc, win32con.LOGPIXELSX) / 60.0 fontSize = 18 lf = win32gui.LOGFONT() lf.lfFaceName = "Comic Sans" lf.lfHeight = int(round(dpiScale * fontSize)) hf = win32gui.CreateFontIndirect(lf) win32gui.SelectObject(hdc, hf) rect = win32gui.GetClientRect(hWnd) win32gui.DrawText(hdc, windowText, -1, rect, win32con.DT_LEFT | win32con.DT_BOTTOM | win32con.DT_SINGLELINE ) win32gui.EndPaint(hWnd, paintStruct) return 0 elif message == win32con.WM_DESTROY: print('Being destroyed') win32gui.PostQuitMessage(0) return 0 else: return win32gui.DefWindowProc(hWnd, message, wParam, lParam) calrect = win32gui.DrawText(hdc, text, -1, rect, textformat | win32con.DT_CALCRECT); rect.top = rect.bottom - calcrect.bottom; win32gui.DrawText(hDC, text, -1, rect, textformat) if __name__ == '__main__': main() I expected all of this code I have put together would run the file without any errors but I keep getting the following message > Exception in thread Thread-1: Traceback (most recent call last): File "C:\Users\7\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 917, in _bootstrap_inner self.run() File "C:\Users\7\AppData\Local\Programs\Python\Python37-32\lib\threading.py", line 865, in run self._target(*self._args, **self._kwargs) TypeError: customDraw() missing 1 required positional argument: 'time' I cannot for the life of me get rid of the error. and the worst part is the error window/terminal must stay open for the code to continue running. I am trying to finish this script without errors so that theres no bugs down the line relating to this bugaboo. but sheesh its killing me.
<python><windows>
2019-08-23 03:47:37
LQ_EDIT
57,619,752
what is multiple recursive in java
<p>I am trying to understand what 'multiple recursive in java' is I know that it's an activation of a method can cause more than one recursive activation of the same method. But I can't still quite understand. Please show me some code examples in java (if possible) that is easy to digest </p> <p>Thank you so much.</p>
<java><recursion>
2019-08-23 04:00:46
LQ_CLOSE
57,620,689
What code can I use to recreate the picture?
I need to recreate this photo, colors and all. Having trouble with positioning the turtle to stack the circles. Any help? I've already tried setheading and position[enter image description here][1] [1]: https://i.stack.imgur.com/qOZWS.png
<python><turtle-graphics>
2019-08-23 06:10:46
LQ_EDIT
57,620,799
React Hook "useEffect" is called conditionally
<p>React is complaining about code below, saying it useEffect is being called conditionally:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="true"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code>import React, { useEffect, useState } from 'react' import VerifiedUserOutlined from '@material-ui/icons/VerifiedUserOutlined' import withStyles from '@material-ui/core/styles/withStyles' import firebase from '../firebase' import { withRouter } from 'react-router-dom' function Dashboard(props) { const { classes } = props const [quote, setQuote] = useState('') if(!firebase.getCurrentUsername()) { // not logged in alert('Please login first') props.history.replace('/login') return null } useEffect(() =&gt; { firebase.getCurrentUserQuote().then(setQuote) }) return ( &lt;main&gt; // some code here &lt;/main&gt; ) async function logout() { await firebase.logout() props.history.push('/') } } export default withRouter(withStyles(styles)(Dashboard))</code></pre> </div> </div> </p> <p>And that returns me the error:</p> <p><div class="snippet" data-lang="js" data-hide="false" data-console="false" data-babel="false"> <div class="snippet-code"> <pre class="snippet-code-js lang-js prettyprint-override"><code> Line 48: React Hook "useEffect" is called conditionally. React Hooks must be called in the exact same order in every component render react-hooks/rules-of-hooks</code></pre> </div> </div> </p> <p>Does anyone happen to know what the problem here is?</p>
<javascript><reactjs><react-hooks>
2019-08-23 06:19:38
HQ
57,623,017
Difference between SDK vs LIB?
<p>What is the difference between an SDK vs Library and any examples of custom implementation in Java ?</p> <p>BR /norbix</p>
<java>
2019-08-23 09:04:48
LQ_CLOSE
57,624,477
Print method "invalid syntax" reversing a string
<p>Trying to reverse a string in python and can't figure out what is wrong with my program that this is seen as invalid syntax. </p> <pre><code>print(r) ^ SyntaxError: invalid syntax``` </code></pre> <p>Thanks so much here is my code.</p> <pre><code> s = "Hello! my name is MangoKitty" r = ''.join(reversed(s.split('')) print(r) </code></pre>
<python><printing>
2019-08-23 10:31:30
LQ_CLOSE
57,624,499
Need help creating a logo using html and css
<!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <!DOCTYPE html> <html> <style> .hr{ margin-top: 0px; margin-bottom: 0px; width: 35%; } .logo{ top:0; left:0; position: absolute; } </style> <body> <div class="logo"> <h1>GTD</h1> <hr> <h3>Web Design</h3> </div> </body> </html> <!-- end snippet --> My only problem is I can’t figure out how to center the text to the line and how do I make it where the words are directly above and below the line?
<html><css><graphical-logo>
2019-08-23 10:32:52
LQ_EDIT
57,626,971
Custom Package in main golang
<p>Package main no look my package.</p> <p>Struct project: </p> <p><img src="https://sun9-23.userapi.com/c853528/v853528063/d2aa5/OnQlmJvxd4s.jpg" alt="struct"></p> <p>Sunrise.go have name package <code>sunrise</code></p> <p>Sunrise.go have function;</p> <pre><code>func getSunriseConst() [64]struct { x float64 y float64 z float64 } { return sunrise } </code></pre> <p>I want call function in main.go, but main no view my package. Help guys</p>
<go>
2019-08-23 13:06:49
LQ_CLOSE
57,627,843
How to make a swift get query to specific url
<p>I am new to swift programming and need sam help. I want to know how I can make a get query to specific url and save the response data to variable. I am sorry that I can't show you the url but its a company secret. I can tell you that the response I a json. I really need help and I am going to be very happy if some helps me. If I am not explaining well, this is my first stack overflow account, just ask me for more info.</p>
<ios><swift><xcode>
2019-08-23 13:56:56
LQ_CLOSE
57,628,238
Can't remove space on top of nav_host_fragment
<p>I just implemented a bottom navigation (AS's default - File -> New -> Activity -> Bottom Navigation Activity) Everything is fine except for a space on the top of the <code>nav_host_fragment</code>. </p> <p><img src="https://i.ibb.co/vwYBJPG/space.png" alt="wrong space"></p> <p>Since it was generated in a ConstraintLayout, I tried to clean the constraints and set the top constraint with <code>parent</code>, setting <code>margin</code> to '0dp' and set <code>height</code> to <code>match_constraint</code>.</p> <p>I unsuccessfully deleted the constraints and tried over and over again.</p> <p>I used <code>Clean Project</code>.</p> <p>I changed to RelativeLayout and set arguments like this:</p> <pre><code> &lt;fragment android:id="@+id/nav_host_fragment" android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentTop="true" android:layout_above="@+id/nav_view" app:defaultNavHost="true" app:navGraph="@navigation/mobile_navigation" /&gt; </code></pre> <p>But the space between <code>nav_host_fragment</code> and the top is still there.</p> <p>Here's the lyout file:</p> <pre><code>&lt;RelativeLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/container" android:layout_width="match_parent" android:layout_height="match_parent" android:paddingTop="?attr/actionBarSize"&gt; &lt;com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/nav_view" android:layout_width="match_parent" android:layout_height="wrap_content" android:layout_alignParentBottom="true" android:background="?android:attr/windowBackground" app:menu="@menu/bottom_nav_menu" /&gt; &lt;fragment android:id="@+id/nav_host_fragment" android:name="androidx.navigation.fragment.NavHostFragment" android:layout_width="match_parent" android:layout_height="match_parent" android:layout_alignParentTop="true" android:layout_above="@+id/nav_view" app:defaultNavHost="true" app:navGraph="@navigation/mobile_navigation" /&gt; &lt;/RelativeLayout&gt; </code></pre>
<android><android-fragments><bottomnavigationview>
2019-08-23 14:25:28
HQ
57,628,890
Why people use `rel="noopener noreferrer"` instead of just `rel="noreferrer"`
<p>I often see following pattern:</p> <pre><code>&lt;a href="&lt;external&gt;" target="_blank" rel="noopener noreferrer"&gt;&lt;/a&gt; </code></pre> <p>But as far as I see, <code>noreferrer</code> implies the effect of <code>noopener</code>. So why is <code>noopener</code> even needed here?</p> <p><a href="https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer" rel="noreferrer">https://html.spec.whatwg.org/multipage/links.html#link-type-noreferrer</a></p> <blockquote> <p><code>&lt;a href="..." rel="noreferrer" target="_blank"&gt;</code> has the same behavior as <code>&lt;a href="..." rel="noreferrer noopener" target="_blank"&gt;</code>.</p> </blockquote> <p>Note that <code>noreferrer</code> browser support is strictly wider that one of <code>noopener</code> <a href="https://caniuse.com/#feat=rel-noreferrer" rel="noreferrer">https://caniuse.com/#feat=rel-noreferrer</a> <a href="https://caniuse.com/#feat=rel-noopener" rel="noreferrer">https://caniuse.com/#feat=rel-noopener</a></p>
<html><security>
2019-08-23 15:07:58
HQ
57,629,432
HTML/CSS performance: flexbox vs table for large data tables
<p>I'm writing a table component in React that would potentially have hundreds of lines, and variable cell widths (in fractions) depending on the table.</p> <p>What would be the best way to implement this in HTML/CSS, flexbox or a traditional table?</p>
<javascript><html><css><reactjs>
2019-08-23 15:43:43
LQ_CLOSE
57,629,456
how are function parameters initialized implicitly?
<p>I'm attempting to understand how are <code>image</code> and <code>imageData</code> populated. They are not declared anywhere. How does the parent function know what values to pass to these two parameters?</p> <pre><code>var Jimp = require("jimp"); module.exports = function (context, myBlob) { Jimp.read(myBlob, function(err, image) { image.getBuffer(Jimp.MIME_TIFF, function(error, imageData) { context.bindings.outputBlob = imageData; context.done(); }); }); }; </code></pre>
<javascript><node.js>
2019-08-23 15:45:38
LQ_CLOSE
57,629,751
how can I run python number of 10 programs simultaneously?
I have `a_1.py`~`a_10.py` I want to run parallel 10 python program I tried ``` from multiprocessing import Process import os def info(title): I want to execute python program def f(name): for i in range(10): info('a_'+str(i)+'.py') if __name__ == '__main__': info('main line') p = Process(target=f) p.start() p.join() ``` but it doesn't work how to I solve this?
<python>
2019-08-23 16:07:35
LQ_EDIT
57,630,267
all of nodes in linkedlist are the same, seems insertion is not working
whatsup guys i have a linked list in cpp , after inserting several nodes now i see all of them are the same , thou im using different values to add to node each time ,but its like all of them are same , even when trying to change a node all of them are changing together or its the same node that is always being returnd idk. class node { public: int ochance=3; string question; string option1; int peopleeffectop1; int courteffectop1; int treasuryeffectop1; string option2; int peopleeffectop2; int courteffectop2; int treasuryeffectop2; node *next; }; class list { private: node *head, *tail; public: list() { head=NULL; tail=NULL; } void createnode(int value , string q , string ans1 , int ans1ef1 , int ans1ef2, int ans1ef3 , string ans2, int ans2ef1 , int ans2ef2, int ans2ef3 ) { node *temp=new node; temp->ochance=value; temp->question = q; temp->option1 = ans1; temp->peopleeffectop1 = ans1ef1; temp->courteffectop1 = ans1ef2; temp->treasuryeffectop1 = ans1ef3; temp->option2 = ans2; temp->peopleeffectop2 = ans2ef1; temp->courteffectop2 = ans2ef2; temp->treasuryeffectop2 = ans2ef3; temp->next=NULL; if(head==NULL) { head=temp; tail=temp; temp=NULL; } else { tail->next=temp; tail=temp; } } node getnth(int pos) { node* tmp = new node; tmp= head; int i =0 ; while(tmp!=NULL){ if (i=pos) { return *tmp; } i++; tmp = tmp->next; } } int getlen(){ node* tmp = new node; tmp= head; int i =0 ; while(tmp!=NULL){ i++; tmp = tmp->next; } return i; } void minus(int pos){ node* tmp = new node; tmp= head; int i =0 ; while(tmp!=NULL){ if (i=pos) { tmp->ochance -=1; } i++; tmp = tmp->next; } } void delete_first() { node *temp=new node; temp=head; head=head->next; delete temp; } void delete_last() { node *current=new node; node *previous=new node; current=head; while(current->next!=NULL) { previous=current; current=current->next; } tail=previous; previous->next=NULL; delete current; } void delete_position(int pos) { node *current=new node; node *previous=new node; current=head; for(int i=1;i<pos;i++) { previous=current; current=current->next; } previous->next=current->next; } };
<c++><pointers><linked-list>
2019-08-23 16:47:20
LQ_EDIT
57,630,709
convert List of Dicts into a 2 deep Nested Dict
<p>Ive been banging my head against a wall for some time with this now, so hoping somebody will be able to point me in the right direction</p> <p>I am writing a flask app and my query returns the following list of dictionaries (via cur.fetchall) ..</p> <pre><code>MyQueryResult = [{'gameID': 'game_1', 'prediction': 41, 'bonus': 'no', 'userName': 'Paul'}, {'gameID': 'game_2', 'prediction': 77, 'bonus': 'no', 'userName': 'Paul'}, {'gameID': 'game_1', 'prediction': 62, 'bonus': 'no', 'userName': 'Steve'}, {'gameID': 'game_2', 'prediction': 77, 'bonus': 'yes', 'userName': 'Steve'} ] </code></pre> <p>I need to convert this into a nested dictionary so that i can use it to build an html table with jinja2 templating ...the table will have 'gameID' as Y axis, 'userName' as X axis, with prediction as the value in the table.. there could be any number of games or users in any particular week</p> <p>Ideally, for me to iterate over it in jinja2, i need to convert the above 'flat' list of dictionaries to a nested dictionary keyed on 'userName' and then 'gameID' ..so that it looks like this</p> <pre><code>MyDict = { 'Paul': { 'game_1': { 'prediction': 'home_win', 'bonus': 'no' }, 'game_2': { 'prediction': 'away_win', 'bonus': 'no' }}, 'Steve': { 'game_1': { 'prediction': 'home_win', 'bonus': 'no' }, 'game_2': { 'prediction': 'away_win', 'bonus': 'yes' } } } </code></pre> <p>This format will enable me to iterate over on a per user /per game basis in Jinja2 and thus enable me to build a table</p> <p>Does anyone have any idea on how i can perform the above conversion ...ive been trying for ages now and really struggling to figure it out :(</p> <p>Any help would be greatly appreciated</p>
<python><dictionary>
2019-08-23 17:27:25
LQ_CLOSE
57,631,278
TypeError: Cannot property of value between two getJSON functions
When the length of my 2 json's are the same, I dont get an error but when they arent I get a `TypeError: Connt read property of undefined`. JSON: json1: [ { "date": "2019-07-05", "x": 1246567, "y": 598045 }, { "date": "2019-07-06", "x": 1021607, "y": 452854 }, { "date": "2019-07-07", "x": 1031607, "y": 467854 } ] json2: [ { "date": "2019-07-05", "v": 3132769, "pv": 6643094 }, { "date": "2019-07-06", "v": 2643611, "pv": 6059584 } ] JavaScript $.getJSON(json1, result => { result.forEach((elem, i, array) => { $('#x').text(elem.x); $('#y').text(elem.y); }); $.getJSON(json2, result => { result.forEach((elem, i, array) => { let yo = 0; if ((elem.date.indexOf(json[i].date) !== -1)) { yo = json[i].x/elem.v) $('#v').text(elem.v); $('#pv').text(elem.pv); $('#vpv').text(yo); } }); }); When the length of the arrays's they match each other but when is longer than the other I get `TypeError: Cannot read property x of undefined` (at `json[i].x`). I am even adding the condition `if ((elem.date.indexOf(json[i].date) !== -1))`. I thought that would fix that. But I am still getting the error. How can I fix this?
<javascript><jquery><arrays><json><typeerror>
2019-08-23 18:18:56
LQ_EDIT
57,633,095
For each and every element want to add unique content:url();
<p>When I hover over word it should shows an appropriate pict as background</p> <p>Considering to make it with js dataset but it still won't work</p> <pre class="lang-html prettyprint-override"><code> &lt;ul&gt; &lt;li&gt;&lt;a href="#"&gt;word&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;word2&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;word3&lt;/a&gt;&lt;/li&gt; &lt;li&gt;&lt;a href="#"&gt;word4&lt;/a&gt;&lt;/li&gt; &lt;/ul&gt; </code></pre> <pre class="lang-css prettyprint-override"><code> li a { display: block; text-decoration: none; font-size: 3.3rem; color: $dark-clr; padding: 10px; transition: all 0.4s ease; font-weight: bold; letter-spacing: 1.2px; text-transform: capitalize; &amp;:hover { color: $icons-clr; } } li a::before { content: url(/pict/1.jpg); position: absolute; top: 50%; left: 50%; transform: translate(-50%, -50%); opacity: 0; z-index: -1; transition: all 0.4s ease; } li a:hover::before { opacity: 0.5; } </code></pre> <p>Can't use attr src</p>
<css><css-selectors>
2019-08-23 21:14:02
LQ_CLOSE
57,633,122
Is there an Azure Dev Ops pipeline variable for current pull request number?
<p>I want to use the current pull request number in my web.config file when I publish my website. Is there a variable that I can access that stores that value?</p>
<c#><azure><azure-devops><devops>
2019-08-23 21:18:31
LQ_CLOSE
57,635,654
How do you display an image from s3 on a website?
<p>I am new to web development and to s3 and was wondering how I might be able to display an image thats inside my bucket, Im able to get a list of image and folder names inside the bucket but I want to find out how to display the images. Would I need to provide a URL for my image tag in html?</p>
<node.js><angular><amazon-web-services><amazon-s3>
2019-08-24 06:30:32
LQ_CLOSE
57,635,963
Gradle : DSL element 'useProguard' is obsolete and will be removed soon
<p>Since the 3.5 update of Android Studio, I have this warning when building my app :</p> <blockquote> <p>DSL element 'useProguard' is obsolete and will be removed soon. Use 'android.enableR8' in gradle.properties to switch between R8 and Proguard..</p> </blockquote>
<android><gradle><proguard><android-r8>
2019-08-24 07:29:37
HQ
57,637,594
ngModel property not working in my sub html component
<p>I guys, I am new in angular. I created an angular app and in it I have 3 other generated components to test angular navigation. Here is what I need help with, in the "index.html" when I use "[(ngModel)]" in the an input element, it flags no error but if I try to use <strong>"[(ngModel)]"</strong> in any of the 3 created components html file, it gives my error. I have imported "FormsModule" in the app.module.ts.</p> <p>Please I do I make the ngModel property available in my sub html components?</p> <p>It will be appreciated if you answer with examples.</p> <p>Cheers</p>
<html><angular>
2019-08-24 11:37:16
LQ_CLOSE
57,637,912
The IDLE editor in Python will not output the result of my code. Instead a dialog box appears showing me Python Folder 37-32
I have written code in a New file window in IDLE. When I run the code there is no output. Instead a dialog box appears showing a window accessing Python Folder 37-32. I have attached a screenshot showing the code and the dialog box that appears when the Module is run
<python><python-idle>
2019-08-24 12:22:22
LQ_EDIT
57,638,040
Generate Apk from ionic cordova
**> cordova.cmd build android Checking Java JDK and Android SDK versions ANDROID_SDK_ROOT=undefined (recommended setting) ANDROID_HOME=C:\Users\Newsoft\AppData\Local\Android\sdk (DEPRECATED) Could not find an installed version of Gradle either in Android Studio, or on your system to install the gradle wrapper. Please include gradle in your path, or install Android Studio [ERROR] An error occurred while running subprocess cordova.** please can any one help me i need to generate build apk from ionic angular project but they have an problem for android environment and sdk root i setup android studio with all configuration but the error is still
<angular><cordova><android-studio><ionic-framework><cordova-plugins>
2019-08-24 12:40:52
LQ_EDIT
57,639,044
Simple VBA IF statement problem. Only Else is printed
I am in the first steps of learning VBA and I am facing a problem that seems to be huge. I have a simple if statement that only the else value is printed. Please can anyone help me to understand my mistake? The code is the following: Sub checkifstatement() Dim result As String Dim rng As Range Set rng = Application.InputBox("Select a range", "Obtain Range Object", Type:=8) rngoff = rng.Offset(, 1) For Each c In rng If c.Value >= 0.5 Then rngoff = 1 Else rngoff = "smaller" End If Next c End Sub Also if after the else I replace the code with the: Range("B" & c.Row) = "smaller" it works fine. I cannot understand why I have a problem here. Regards.
<excel><vba><if-statement>
2019-08-24 14:54:01
LQ_EDIT
57,639,742
Blockchain security
<p>My question is about blockchain security. If l make any change in data in a blockchain,the hash value changes according to the blockchain algorithm. But how other members can identify that it is a tampered block?</p>
<blockchain>
2019-08-24 16:34:22
LQ_CLOSE
57,640,292
How does this simple program not represent recursion?
<p>How does this "not" demonstrate recursion? It is a simple high/low find where I set "mid" to be the guess of the program's randomly selected number within the range. I am in a pissing match with an instructor. What do you think?</p> <pre><code>#include &lt;iostream&gt; #include &lt;cstdlib&gt; #include &lt;time.h&gt; using namespace std; int main() { // define variables int left = 1, mid, range, secret, y = 0; // query user defined range, assign to variable range cout &lt;&lt; "Please enter top of range: " &lt;&lt; endl; cin &gt;&gt; range; // seed random number generator with time srand(time(NULL)); // generate secret number based between left and range secret = rand() % range; do { // define and assign primary value of mid updating on each iteration mid = ((range + left) / 2); if (mid &gt; secret) { // set range to mid range = mid; // iterate y++; } else if (mid &lt; secret) { // set left to mid left = mid; // iterate y++; } else { // escape condition met cout &lt;&lt; "Found secret number " &lt;&lt; secret &lt;&lt; " in " &lt;&lt; y &lt;&lt; " tries. " &lt;&lt; endl; return 0; } } while (mid != secret); return 0; } </code></pre>
<c++><recursion>
2019-08-24 17:48:33
LQ_CLOSE
57,640,787
how do i use an initializer list on a derived class?
I'm writing a `Qt` application where I have a derived class of `QDialog`. My derived class also uses a initializer list to for a couple of private members (that get set through the constructor). Now I am a bit confused even in terms of allowed syntax. I found this [post][1], tried to follow it in my little demo script and came up with the following: #include <QString> #include <QSettings> #include <QtWidgets/QWidget> #include <QtWidgets/QDialog> class foo { Q_OBJECT public: foo(QSettings* const set=nullptr, const QString s="", QWidget *parent=nullptr) : QDialog{ public: foo(QSettings* const set=nullptr, const QString s="", QWidget *parent): QDialog(parent){} }; QString nme_get() {return name;} void qux(void); private: const QString name; QSettings * const settings; }; void foo::qux(void) { QSettings *test = settings; QString name = nme_get(); test->beginGroup(name); /* * ... */ test->endGroup(); } int main (void) { QWidget *parent = nullptr; QSettings *sttngs = new QSettings(QSettings::NativeFormat,QSettings::UserScope,"GNU","scaper",nullptr ); foo inst{sttngs, QString("quux"), parent}; inst.qux(); return 0; } which the compiler throws out with: foo.cpp: In constructor ‘foo::foo(QSettings*, QString, QWidget*)’: foo.cpp:10:91: error: type ‘QDialog’ is not a direct base of ‘foo’ foo(QSettings* const set=nullptr, const QString s="", QWidget *parent=nullptr) : QDialog{ ^ foo.cpp:11:9: error: expected primary-expression before ‘public’ public: ^ foo.cpp:11:9: error: expected ‘}’ before ‘public’ foo.cpp:10:9: error: uninitialized const member in ‘class QSettings* const’ [-fpermissive] foo(QSettings* const set=nullptr, const QString s="", QWidget *parent=nullptr) : QDialog{ ^ foo.cpp:20:28: note: ‘QSettings* const foo::settings’ should be initialized QSettings * const settings; ^ foo.cpp:11:9: error [1]: https://stackoverflow.com/questions/33092076/initializer-list-for-derived-class#33092161
<c++><linux><qt><g++><initializer-list>
2019-08-24 19:02:50
LQ_EDIT
57,641,444
Code executes when typed into console but not in script
<p>I have a javascript project i am running,and i have finished the first phase.The second phase requires for me to start by assigning a <code>variable</code> to a <code>dom</code> object.</p> <p>I assigned the <code>variable</code> and it worked.Then i updated the <code>code</code> into my project <code>script</code>.Now,the problem is that whenever i run the <code>script</code> the <code>script</code> will execute but,the <code>variable</code> i assigned and updated into my <code>script</code> won't assign and the <code>code</code> line won't run.</p> <pre><code> var element = document.getElementById('inputElement'); </code></pre> <p>Every time i run that line in the <code>console</code> maybe by copy/paste or typing it personally it works but,the <code>code</code> won't execute when it is in a script.</p>
<javascript><dom>
2019-08-24 20:51:24
LQ_CLOSE
57,642,601
What's the difference in both the code snippets? How does it matter to compiler if I am not telling how many bytes needed for array
<p>The basic program of concatenating two strings. I am not getting the point of how not defining the length of str1 array is leading to core dump.</p> <p>If I define the length of str1 let's say to str1[100] then the program is working fine. </p> <pre><code>void myStrcat(char *a, char *b) { int m = strlen(a); int n = strlen(b); int i; for (i = 0; i &lt;= n; i++){ a[m+i] = b[i]; } } int main() { char str1[] = "String1 "; char *str2 = "String2"; myStrcat(str1, str2); printf("%s ", str1); return 0; } </code></pre> <p><strong>* stack smashing detected *</strong>: terminated Aborted (core dumped)</p>
<c><concatenation><c-strings>
2019-08-25 01:23:18
LQ_CLOSE
57,643,411
why isnt it piping to the cd command?
<p>I read that if you use the | command then it pipes the output of the first command to the input of the second,then why is it working?</p> <p>Thank you!</p> <pre><code>find -size 1033c | cd </code></pre>
<linux><bash>
2019-08-25 05:10:26
LQ_CLOSE
57,643,894
How to adapt my data to a recycler view in kotlin
<p>I wrote a wrapper for a website that has a method get_page(pag: Int, cat: Int), and ot returns a list of maps and each map has keys like "name" "price" and "id". How do I adapt this data to a recycler view ?</p>
<android><kotlin>
2019-08-25 06:55:41
LQ_CLOSE
57,644,154
Why can’t name the variable const, but in objects can
<p>I wrote.</p> <pre><code>let const = 10; </code></pre> <p>and got error.and for objects everything works</p> <pre><code>let x = {const:10} </code></pre> <p>What is the difference.</p>
<javascript>
2019-08-25 07:41:18
LQ_CLOSE
57,644,413
Can you explain this recursive function?
<p>I recently bumped into a factorial project where I have to build a function which simulates the factorial process which is demonstrated in the example below: take an integer n and calculate n! = n x (n−1) x (n−2) x (n−3) ⋅⋅⋅⋅ x 3 x 2 x 1. The exercise asks to use a function to do this. I obviously got stuck and googled a solution to better understand this problem. That didn't exactly work and I got stuck with a new concept I can barely understand which is recursion. Here the solution I googled:</p> <pre><code>def factorial_recursive(n): if n == 1: return 1 # Recursive case: n! = n * (n-1)! else: return n * factorial_recursive(n-1) </code></pre> <p>What I want to understand is what happens in the second branch Also, given this example test:</p> <pre><code>&gt;&gt;&gt; factorial_recursive(5) 120 </code></pre> <p>Why do the return values accumilate into one? It was not specified in the function body. All I know is that a function is calling itself based on certain conditions but how does this work exactly. And if so wouldn't that loop forever? Is the n value changing or not because it seems so even if its not so obvious when I look at the code but the resuts show otherwise. And why are the multiple return values stacked into one? I hope my questions can be answered and any linked docs or duplicates are appreciated if there are any.</p>
<python><recursion>
2019-08-25 08:27:28
LQ_CLOSE
57,644,425
To create a page then get data and store it in java script object then send data to .Net with HTTPPOST
<p>My senior asked me to create a page get data and store it in java script object then send data to .Net with HTTPPOST.Then Call webservice in .Net .But I absolutely have no idea how to do that and where to start... Can someone light me up with some simple examples </p> <p>I don't know how to get data from this input and store it in javascript object and send data to .Net with HTTPPost then use web service in .NET.I need simple examples to do so I appreciate your help.</p> <p>I've been googling how to do it but it's been a while i can't find an answer</p>
<javascript><c#><.net>
2019-08-25 08:29:56
LQ_CLOSE
57,644,503
Install Python distribution or Not
<p>I am running Debian 10 and am wondering whether it is recommended to install a python distribution on it or not. This question comes because I see that Debian 10 comes with pre-installed python 2 and python 3 plus many python modules.</p> <p>Is it not wastage of system space installing extra python distributions like anaconda python or any similar python distribution on such system? </p>
<python-3.x><python-2.7><debian-buster>
2019-08-25 08:41:08
LQ_CLOSE
57,644,669
Create a one-time subscription to capture authState
Is it possible to create a subscription that attempts to get the user's auth state repeatedly until `user != null`: ngOnInit() { this.isMobile = this.breakpointObserver.observe([Breakpoints.Handset]); this.authSubscription = this.afAuth.authState.subscribe(user => { if(user) { localStorage.setItem('uid', user.uid); this.store.dispatch(userActions.getData()); } }) } The console output is as follows which causes the browser to crash: [![enter image description here][1]][1] My action is as follows: @Effect() getData$ = this.actions$.pipe( ofType(UserActions.getData), switchMap(() => { return this.userService.getUserById(localStorage.getItem('uid')).pipe( map( (data: IUser) => UserActions.dataReceived({ payload: UserService.parseData(data) }) ) ); } ) ); [1]: https://i.stack.imgur.com/avKlw.png
<angular><typescript><ngrx>
2019-08-25 09:03:25
LQ_EDIT
57,645,170
Exit Vim External Command Line Shell
<p>I accidentally put ping 8.8.8.8 in the Vim External Command Line Shell by executing :! ping 8.8.8.8 Now the command won't stop and I am not able to return to my file editing buffer in Vim. When I press Ctrl+Z it suspends the entire vim process and takes me back to Linux Shell. Is there any way to suspend/kill the Vim Shell subprocess in case it goes into some kind of infinite execution and return back to Vim buffer ?</p>
<linux><shell><vim><command-line>
2019-08-25 10:18:05
LQ_CLOSE
57,646,384
Add 2 new columns to existing dataframe using apply
<p>I want to use the apply function that: - Takes 2 columns as inputs - Outputs two new columns based on a function.</p> <p>An example is with this add_multiply function. </p> <pre class="lang-py prettyprint-override"><code>#function with 2 column inputs and 2 outputs def add_multiply (a,b): return (a+b, a*b ) #example dataframe df = pd.DataFrame({'col1': [1, 2], 'col2': [3, 4]}) #this doesn't work df[['add', 'multiply']] = df.apply(lambda x: add_multiply(x['col1'], x['col2']), axis=1) </code></pre> <p>ideal result: </p> <pre class="lang-py prettyprint-override"><code>col1 col2 add multiply 1 3 4 3 2 4 6 8 </code></pre>
<python><pandas><dataframe><apply>
2019-08-25 13:20:23
HQ
57,646,756
Go Programming (Golang) reusing Struct to reduce heap usage
Please explain what is happening in following code. The part I don't understand is the service struct. The service struct is a wrapper around the APIClient struct. When the NewAPIClient is called, it is embedding the service struct inside and copying onto itself. I cannot seem to wrap my head around this. Please advise and elaborate. Thank you. type APIClient struct { cfg *Configuration // Reuse a single struct instead of // allocating one for each service on the heap. common service // API Services AccountApi *AccountApiService ContractApi *ContractApiService FYIApi *FYIApiService IBCustApi *IBCustApiService MarketDataApi *MarketDataApiService OrderApi *OrderApiService PnLApi *PnLApiService PortfolioApi *PortfolioApiService PortfolioAnalystApi *PortfolioAnalystApiService ScannerApi *ScannerApiService SessionApi *SessionApiService TradesApi *TradesApiService } type service struct { client *APIClient } func NewAPIClient(cfg *Configuration) *APIClient { if cfg.HTTPClient == nil { cfg.HTTPClient = http.DefaultClient } c := &APIClient{} c.cfg = cfg c.common.client = c c.AccountApi = (*AccountApiService)(&c.common) c.ContractApi = (*ContractApiService)(&c.common) c.FYIApi = (*FYIApiService)(&c.common) c.IBCustApi = (*IBCustApiService)(&c.common) c.MarketDataApi = (*MarketDataApiService)(&c.common) c.OrderApi = (*OrderApiService)(&c.common) c.PnLApi = (*PnLApiService)(&c.common) c.PortfolioApi = (*PortfolioApiService)(&c.common) c.PortfolioAnalystApi = (*PortfolioAnalystApiService)(&c.common) c.ScannerApi = (*ScannerApiService)(&c.common) c.SessionApi = (*SessionApiService)(&c.common) c.TradesApi = (*TradesApiService)(&c.common) return c }
<go><struct>
2019-08-25 14:08:18
LQ_EDIT
57,647,892
How to add a delay in Javascript
<p>I need to add a delay to some JavaScript code without importing anything. How do I do it?</p> <p>I need this for a unity project I am working on. It's like Minecraft but better and I need to add block break times. I have had a look on other websites but got nothing.</p> <p>I want the code to wait the delay time before proceeding on to the next task. I am quite new to JavaScript too.</p>
<javascript>
2019-08-25 16:43:56
LQ_CLOSE
57,648,841
window.open() doesn't open the website, what to do?
<p>I have this piece of code:</p> <pre><code> ((JavascriptExecutor)driver).executeScript("Object.assign(document.createElement('a'), { target: '_blank', href: 'https://facebook.com'}).click()"); ((JavascriptExecutor)driver).executeScript("window.open('https://google.com')'"); </code></pre> <p>First command is meant to create a new tab and open facebook.com and it does, first is meant to open google.com but nothing happens, am I doing anything wrong?</p> <p>Disclaimer:<br> 1.I am not familiar with Javascript at all, this is a Java Selenium project (hence why the <code>(JavascriptExecutor)driver).executeScript</code> part and I need to use Javascript for these few lines.<br> 2.I tried multiple simpler piece of codes instead of this one but nothing worked hence why I ended up with this which is not the simplest.</p>
<javascript><selenium-webdriver>
2019-08-25 18:52:48
LQ_CLOSE
57,648,952
How to get the name of a created object (not the class itself) in Python 3.X
<p>I've always wondered if when you define a variable, you can somehow get the name you defined it with, and manipulate it as a string. I am trying to make some code more efficient in doing this.</p> <p>I looked this up and didn't seem to hit the spot with what I found. I found some code that can retrieve the name of the class itself, but not the name of the created object.</p> <pre><code>class A: @classmethod def getname(cls): return cls.__name__ def usename(self): return self.getname() &gt;&gt; example = A() &gt;&gt; print (example.usename()) A </code></pre> <p>I thought I would get a result looking like this: </p> <pre><code>example </code></pre> <p>It being literally the name of the object, not the class.</p> <p>Is there a way of doing this? If there is, I would really appreciate it. </p> <p>PS: if this question turns out to be a duplicate, sorry, would love it if ya'll point me to the answer :) and not delete this.</p>
<python>
2019-08-25 19:08:46
LQ_CLOSE
57,650,535
Pushing variables onto an array inside an object?
<p>I am trying to push data at the end of the student tags array which is in an object, I was wondering how I could do this? </p> <pre><code>var tags = "2019 Student" { "first_name": "Thomas", "last_name": "Lee", "email": "tjhunt03@gmail.com", "student_tags": ["2020 Student"] } </code></pre>
<javascript><arrays><json><google-apps-script><javascript-objects>
2019-08-25 23:55:58
LQ_CLOSE
57,650,623
Deserialize JSON data and trim off the name ,only values
I have a JSON data loaded from database using AJAX, it has name and value pair after serializing using JavaScriptSerializer, but I need to use it without the names, only the values is needed, how can I serialize the same data without the names Original [{"Code":"af","Total":16.63},{"Code":"al","Total":11.58},{"Code":"ve","Total":285.21},{"Code":"vn","Total":101.99}] Expected [{"af":"16.63","al":"11.58","ve":"285.21","vn":"101.99"}]
<javascript><json>
2019-08-26 00:16:42
LQ_EDIT
57,651,992
Can someone give a explanation and a solution to fix this issue?
In Jupyter Notebook I run this code without any errors. but in VScode there is an error ***"Unable to import 'PIL'pylint(import-error)"***. I've already install Pillow. But still, there is the error. import os from PIL import Image # open an image file (.bmp,.jpg,.png,.gif) you have in the working folder imageFile = "Cat.jpg" im1 = Image.open(imageFile) # adjust width and height to your needs width = 480 height = 300 # use one of these filter options to resize the image im2 = im1.resize((width, height), Image.NEAREST) ext = ".jpg" im2.save("NEAREST" + ext) os.system("d:/python24/i_view32.exe %s" % "BILINEAR.jpg")
<python><visual-studio-code><image-resizing><vscode-settings>
2019-08-26 05:00:40
LQ_EDIT
57,654,307
hwo to check if drive in the raid array is failed using ansible
I want to write a ansible playbook to find out if the drive in the raid array md0 or md2 or md1 is failed. If it is failed then remove and re-add the drive. How can I do this check using ansible. Drive on the server is /dev/nvme0n1 and /dev/nvme1n1.
<ansible>
2019-08-26 08:26:56
LQ_EDIT
57,654,544
VBA - If a cell equals a certain value do a certain string otherwise do another string
I am trying to create a Macro. But am not entirely show how to get it to work. I want the Macro to run if cell A1 is not blank. If cell A1 is blank I want a msgbox to appear informing the user to fill in cell A1 before the Macro will work. IE in formula terms =if(A1<>"",do resest of macro,"Populate cell A1") If someone could please help me create the condition do x or y depending on A1's value I would be most appreciative. I think it should work something like below Sub Code () If("A1")<>"""" Goto String1 Else Goto String2 String1: MsgBox "Populate cell A1" String2: Rest of code
<excel><vba><conditional-statements><race-condition>
2019-08-26 08:43:37
LQ_EDIT
57,654,780
UIPickerView data notshowing in a subview
i have a container view in which i am showing text field in which picker view is connected . picker view not showing data in container view @IBOutlet var txtfield: UITextField! var pickerView = UIPickerView() pickerView.delegate = self pickerView.dataSource = self tYear.inputView = pickerViewYear <----- Thread 1: Fatal error: Unexpectedly found nil while unwrapping an Optional value
<ios><swift><uipickerview>
2019-08-26 08:59:24
LQ_EDIT
57,654,834
How can we decrypt a password which has been encrypted first using md5 and then using sha1?
<p>Is it possible to decrypt a password which has been encrypted using md5 and then using sha1?</p> <p>$newHPass = sha1(md5($password));</p>
<php><encryption><md5><sha1>
2019-08-26 09:03:07
LQ_CLOSE
57,654,898
Need suggestion in optimizing the below code
<p>I need some guidance as how can I optimize the below code. As one can see , i am creating a new object everytime to set each value. How can I do it in a better way</p> <pre><code>Balance[] balance = new Balance[3]; CurAmt curAmt = new CurAmt(); Balance bal = new Balance(); bal.setBalType("currentBalance"); curAmt.setCurCode(entry.getValue().get(0).getAs("CURRENT_BALANCE_CURRENCY_CODE")); curAmt.setContent(entry.getValue().get(0).getAs("CURRENT_BALANCE")); bal.setCurAmt(curAmt); balance[0] = bal; CurAmt curAmt1 = new CurAmt(); Balance bal1 = new Balance(); bal1.setBalType("availableBalance"); curAmt1.setCurCode(entry.getValue().get(0).getAs("AVAILABLE_BALANCE_CURRENCY_CODE")); curAmt1.setContent(entry.getValue().get(0).getAs("AVAILABLE_BALANCE")); bal1.setCurAmt(curAmt1); balance[1] = bal1; CurAmt curAmt2 = new CurAmt(); Balance bal2 = new Balance(); bal2.setBalType("interestEarnedYtd"); curAmt2.setCurCode(entry.getValue().get(0).getAs("YTD_CURRENCY_CODE")); curAmt2.setContent(entry.getValue().get(0).getAs("TD_AMOUNT")); bal2.setCurAmt(curAmt2); balance[2] = bal2; Obj.setBalance(balance); </code></pre>
<java>
2019-08-26 09:07:44
LQ_CLOSE
57,656,697
Normalised Weapon Damage Formula
<p>I would like to create a balanced weapon Formula as the start for the damage output of the player. Other factors will be stacked on this formula, but i would like a base to start with. </p> <p>So what i am looking for is a formulae that lets different types of weapons deal the same damage over a 10 second interval.</p> <p>For example, my assault rifle has an rpm of 700 which makes it shoot 11 times per second. </p> <p>Whereas my pistol has an rpm of 120 which makes it shot twice per second.</p> <p>I want to calculate how much damage each weapon does on each shot to accumulate For example, 200 damage in 10 seconds, regardless of fire rate.</p> <p>How would i go about doing this?</p>
<c#><math><formula>
2019-08-26 11:06:18
LQ_CLOSE
57,657,237
Erreur de segmentation (core dumped) when trying to print %s
I follow an online course about intrusion at https://www.root-me.org/fr/Documentation/Applicatif/Chaine-de-format-lecture-en-memoire and it gives a segmentation error when I'm trying to print %s
<c>
2019-08-26 11:39:22
LQ_EDIT
57,660,798
What wrong with BST
<p>I want to print all the key in BST. Why it printing only "the tree is empty" It just printing the tree is empty 2 times. my coding first method is about creating a node to be a leaf and second is creating the leaf into the tree and thrid is printing the tree by inorder. If my coding is too bad can you fix it? </p> <pre class="lang-cpp prettyprint-override"><code>#include &lt;iostream&gt; class BST { private: struct Node { int key; Node *left; Node *right; }; Node* root; Node* createLeafPrivate(int key,Node* ptr); void addLeafPrivate(int key,Node* ptr); void printInoderPrivate(Node* ptr); public: BST():root(nullptr){} Node* createLeaf(int key); void addLeaf(int key); void printInorder(); }; BST::Node* BST::createLeaf(int key) { Node* newNode=new Node(); newNode-&gt;key=key; newNode-&gt;left=nullptr; newNode-&gt;right=nullptr; return newNode; } void BST::addLeaf(int key) { addLeafPrivate(key,root); } void BST::addLeafPrivate(int key,Node* Ptr) { if(root == nullptr) root=createLeaf(key); else if (key &lt; Ptr-&gt;key) { if(Ptr-&gt;left != nullptr) addLeafPrivate(key,Ptr-&gt;left); else Ptr-&gt;left=createLeaf(key); } else if (key &gt; Ptr-&gt;key) { if(Ptr-&gt;right != nullptr) addLeafPrivate(key,Ptr-&gt;right); else Ptr-&gt;right=createLeaf(key); } else { std::cout&lt;&lt;"The key "&lt;&lt;key&lt;&lt;"has already been added to the tree\n"; } } void BST::printInorder() { printInoderPrivate(root); } void BST::printInoderPrivate(Node* Ptr) { if(root != nullptr) { if(Ptr-&gt;left != nullptr) printInoderPrivate(Ptr-&gt;left); std::cout&lt;&lt;Ptr-&gt;key&lt;&lt;" "; if(Ptr-&gt;right != nullptr) printInoderPrivate(Ptr-&gt;right); } else { std::cout&lt;&lt;"The tree is empty\n"; } } int main() { BST myTree; std::cout&lt;&lt;"----Printing the empty tree----\n"; myTree.printInorder(); for(int i=16;i&lt;=0;i--) myTree.addLeaf(i); std::cout&lt;&lt;"----Printing the data tree-----\n"; myTree.printInorder(); std::cout&lt;&lt;std::endl; return 0; } </code></pre>
<c++>
2019-08-26 15:24:59
LQ_CLOSE
57,662,158
prototype does not match function definition, but it does
<p>I have a program with 2 functions, one of them counts number of words in a file, and works perfectly, and the other one counts the number of tymes a specific word appears in file. This las function does work perfectly (i have tested it isolated from the main), but when i ordered everything in the main, with a functions.h file, i get this.</p> <p>The function with the problem is word_cnt(FILE*, char*)</p> <p>when i compile, i get this:</p> <p><code>word.c:3:5: error: conflicting types for ‘word_cnt’ </code> <code>int word_cnt(FILE* fp, char* argv[2]) </code></p> <pre><code>In file included from word.c:1: functions.h:7:5: note: previous declaration of ‘word_cnt’ was here int word_cnt(FILE*, char*); </code></pre> <p>in the word.c file, (file which contains the word_cnt function with the problem) the function is defined like this </p> <pre><code>int word_cnt(FILE* fp, char* argv[2]) </code></pre> <p>and in the header file, the prototype is like this:</p> <pre><code>int word_cnt(FILE*, char*); </code></pre> <p>I do not understand....the definition is correct, why does the compiler think i am redefyning it?</p> <p>IMAGE HERE <a href="https://drive.google.com/open?id=1zhS3iaFURJ0HyRgcy733NsT4trfzFDve" rel="nofollow noreferrer">https://drive.google.com/open?id=1zhS3iaFURJ0HyRgcy733NsT4trfzFDve</a></p>
<c><types><declaration>
2019-08-26 17:10:01
LQ_CLOSE
57,662,881
Getting error `\365\277\357\376 in the terminal
<p>The task is to output every second word from the string</p> <p>I made a loop to check every character in the string and while it reaches a space the boolean will change it value to the opposite so before it reaches the next space it will copy the characters from first string to the second</p> <pre><code>int main(void) { char str1[max]="Hellow my name is Tom why not today"; char str2[max]; int i; bool a=false; for (i=0;i&lt;strlen(str1);i++) { if ((int)str1[i]==32) { a=!a; } if (a==true) { str2[i]=str1[i]; } } printf ("%s\n",str2); return 0; } </code></pre> <p>The terminal shows: `\365\277\357\376 my\365\277\357\376 isu</p>
<c><string><output>
2019-08-26 18:12:27
LQ_CLOSE
57,662,894
What is the difference between read() and readline() in python?
<p>I am learning file handling in python right now. If i write read() method , it does work same as readline() method . There must be a difference between them and i want to learn that</p>
<python>
2019-08-26 18:13:35
LQ_CLOSE
57,663,779
Why comparing strings inside a method doesn't work?
<p>I've got 2 classes, object of the second class is created inside the first class. I'm using next() method to increase the value of seconds, then I want to check if its value is 0 and cannot get through by using .equals("0") method. </p> <p>I'm writing in Eclipse, java 11</p> <pre><code>public void tick(){ seconds.next(); //var "seconds" is of type second class(calling // seconds means toString() from 2nd class) if(seconds.equals("0")) { System.out.println("CANNOT ACCESS THIS ????"); } </code></pre> <p>Method next() from second class: </p> <pre><code>public void next() { if(value==upperLimit) value=0; else ++value; } public String toString() { return value+""; } </code></pre> <p>I expect to run first if statement inside tick() method, but it doesn't.</p>
<java><string>
2019-08-26 19:23:26
LQ_CLOSE
57,664,106
How do I transform this data set using SQL?
<p>How do I write SQL that will transform data set 1 into data set 2?</p> <blockquote> <p>Data Set 1</p> </blockquote> <pre><code>id Name Home_Phone Work_Phone Mobile_Phone --- ----------------------- ------------ ------------ ------------ 44 Mary James NULL NULL 333-832-1066 44 Mary James 111-747-7048 NULL NULL 46 James Smith NULL NULL 111-354-2092 46 James Smith 111-737-8936 NULL NULL 45 Shelley Berlin NULL NULL 222-960-5115 45 Shelley Berlin NULL 222-845-2422 NULL 39 Brad Saito NULL NULL NULL 39 Brad Saito Invalid Invalid Invalid 55 Debbie Peters NULL NULL NULL 55 Debbie Peters NULL NULL NULL 55 Debbie Peters NULL 222-960-7778 NULL </code></pre> <blockquote> <p>Data Set 2</p> </blockquote> <pre><code>id Name Home_Phone Work_Phone Mobile_Phone --- ----------------------- ------------ ------------ ------------ 44 Mary James 111-747-7048 NULL 333-832-1066 46 James Smith 111-737-8936 NULL 111-354-2092 45 Shelley Berlin NULL 222-845-2422 222-960-5115 39 Brad Saito Invalid Invalid Invalid 55 Debbie Peters NULL 222-960-7778 NULL </code></pre>
<sql-server>
2019-08-26 19:48:25
LQ_CLOSE
57,666,155
FIRAnalyticsConnector: building for Mac Catalyst, but linking in object file built for iOS Simulator
<p>When trying to build for Mac using Catalyst, I get the following build error:</p> <p><code>FIRAnalyticsConnector(FIRConnectorUtils_77ff1e12be6740765c87f1be0d421683.o), building for Mac Catalyst, but linking in object file built for iOS Simulator</code></p> <p>The project builds fine for iOS andiPadOS.</p>
<ios><xcode><macos><ipados>
2019-08-26 23:56:52
HQ
57,666,620
Is it possible for a NavigationLink to perform an action in addition to navigating to another view?
<p>I'm trying to create a button that not only navigates to another view, but also run a function at the same time. I tried embedding both a NavigationLink and a Button into a Stack, but I'm only able to click on the Button.</p> <pre><code> ZStack { NavigationLink(destination: TradeView(trade: trade)) { TradeButton() } Button(action: { print("Hello world!") //this is the only thing that runs }) { TradeButton() } } </code></pre>
<swiftui>
2019-08-27 01:22:54
HQ
57,666,697
Customise array of object to string
<p>Hi now i'm working on some laravel generator stuff to provide user to user admin panel for generator. <a href="https://github.com/nicoaudy/laravelmanthra" rel="nofollow noreferrer">laravel manthra</a>. i have some issue when to merging and custom array to string. I have array like this :</p> <pre class="lang-php prettyprint-override"><code>array:3 [ 0 =&gt; array:2 [ "name" =&gt; "name" "type" =&gt; "string" ] 1 =&gt; array:2 [ "name" =&gt; "slug" "type" =&gt; "string" ] 2 =&gt; array:2 [ "name" =&gt; "content" "type" =&gt; "text" ] ] </code></pre> <p>i want merge array object with <code>#</code> separator, each object should separates with <code>;</code>. Result something like this</p> <pre class="lang-php prettyprint-override"><code>name#string;slug#string;content#text; </code></pre> <p>how can i achieve this, thanks for your help! 🔥</p>
<javascript><php><arrays><laravel><object>
2019-08-27 01:35:25
LQ_CLOSE
57,668,992
How to connect two html elements avoiding other elements
<p>I've this html/css structure: <a href="https://codepen.io/Pestov/pen/BLpgm" rel="noreferrer">Codepen</a></p> <p>I need to connect two html elements with line when I choose them (clicked on first element and then second element). </p> <p>I've already tried to draw straight line between them and it's successful. But the problem is, this line should avoid other html elements</p> <p>I'm choosing two elements like this:</p> <pre class="lang-js prettyprint-override"><code>let selected; let count = 0; $('a').on('click', function(){ selected = $('.selected'); if (!$(this).hasClass('selected') &amp;&amp; count !== 2){ count++; $(this).addClass('selected count' + count); } else { $(this).removeClass(); count--; } if (count === 2) { // Here I'll draw line } }); </code></pre>
<javascript><jquery><html><css>
2019-08-27 06:44:46
HQ
57,669,751
Find and Replace , between 2 characters
<p>So I have a CSV file with some anomaly for eg</p> <pre><code>2019-07-25 00:00:00,1014488,2019-07-25 12:24:12,112629,Amy,Flutmus,84004,GM,0001,2.99,312,FFO &amp; CS PLATE ||22,10999,90027,90062||Sand w/ Options,1,0,0.2,18.85,0,1 </code></pre> <p>i want to replace , between these characters || ||. So I'm expecting </p> <pre><code>2019-07-25 00:00:00,1014488,2019-07-25 12:24:12,112629,Amy,Flutmus,84004,GM,0001,2.99,312,FFO &amp; CS PLATE ,22,*10999*90027*90062,Sand w/ Options,1,0,0.2,18.85,0,1 </code></pre>
<regex><csv><replace><find>
2019-08-27 07:33:55
LQ_CLOSE
57,670,510
How to get rid of Incremental annotation processing requested warning?
<p>I have just started using android development and trying to use Room library. Since yesterday I am facing this warning message</p> <blockquote> <p>w: [kapt] Incremental annotation processing requested, but support is disabled because the following processors are not incremental: androidx.lifecycle.LifecycleProcessor (NON_INCREMENTAL), androidx.room.RoomProcessor (NON_INCREMENTAL).</p> </blockquote> <p>I have tried to research and fix but unable to avoid this error here is my grale.build file. please suggest/advice what I am doing wrong.</p> <pre><code>apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' apply plugin: 'kotlin-kapt' android { compileSdkVersion 29 buildToolsVersion "29.0.2" defaultConfig { applicationId "ps.room.bookkeeper" minSdkVersion 15 targetSdkVersion 29 versionCode 1 versionName "1.0" testInstrumentationRunner "androidx.test.runner.AndroidJUnitRunner" javaCompileOptions { annotationProcessorOptions { arguments = ["room.schemaLocation":"$projectDir/schemas".toString()] } } 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 'androidx.constraintlayout:constraintlayout:1.1.3' implementation 'com.google.android.material:material:1.0.0' testImplementation 'junit:junit:4.12' androidTestImplementation 'androidx.test:runner:1.2.0' androidTestImplementation 'androidx.test.espresso:espresso-core:3.2.0' // life cycle dependencies def lifecycle_version = "2.0.0" implementation "android.arch.lifecycle:extensions:$lifecycle_version" kapt "android.arch.lifecycle:compiler:$lifecycle_version" //Room dependencies //def room_version = "2.1.0" implementation 'android.arch.persistence.room:runtime:2.1.0' kapt 'android.arch.persistence.room:compiler:2.1.0' //annotationProcessor 'android.arch.persistence.room:compiler:2.1.0' // implementation "android.arch.lifecycle:extensions:$room_version" // kapt "android.arch.persistence.room:compiler:$room_version" // androidTestImplementation "android.arch.persistence.room:testing:$room_version" //implementation 'androidx.room:room-runtime:2.1.0' //annotationProcessor 'androidx.room:room-compiler:2.1.0' } </code></pre>
<android><android-room><android-lifecycle>
2019-08-27 08:23:31
HQ
57,670,635
Mysql: Select in Select
I had create two table (Table A and Table B) and try using INNER JOIN both table but the result will be in different row even the ID is same. Is there any mysql select to extract all the value with same ID in one row as shown in 'Result' table? [Image][1] [1]: https://i.stack.imgur.com/Zviw3.png
<mysql>
2019-08-27 08:31:29
LQ_EDIT
57,671,144
What is mean 'return a|b|c' in the non void java function?
<p>I'm new at java, and I'm a little confused by the functions '|' in non void java functions return</p> <pre><code>private int donUnderstand() { return 1 | 2 | 3 | 4; //return 7, where is 7 come from? } </code></pre> <p>Function above will return 7, but I don't get it where is 7 come from. I need some explanation. What is '|' character really mean at that function?</p>
<java><android><android-studio>
2019-08-27 09:02:23
LQ_CLOSE
57,673,913
VSC PowerShell. After npm updating packages .ps1 cannot be loaded because running scripts is disabled on this system
<p>I design websites in VSC and PowerShell is my default terminal.</p> <p>After updating and deploying a website to firebase earlier, I was prompted to update firebase tools - which I did using npm. Immediately after I cannot run/access any firebase scripts wthout the folllowing error:</p> <p><code>firebase : File C:\Users\mada7\AppData\Roaming\npm\firebase.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1</code></p> <p><code>firebase + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess</code></p> <p>I've spent a few hours searching around and can't find a solid answer the problem. Many threads are several years old and I find it bizarre I've not had this problem in the past year until today. I can still access firebase scripts if I set my default terminal to cmd.</p> <p>Assuming the problem was related to firebase-tools I've carried on working but have now updated vue.js and get the error again when trying to run any vue commands in powershell:</p> <p><code>vue : File C:\Users\mada7\AppData\Roaming\npm\vue.ps1 cannot be loaded because running scripts is disabled on this system. For more information, see about_Execution_Policies at https:/go.microsoft.com/fwlink/?LinkID=135170. At line:1 char:1</code></p> <p><code>vue + CategoryInfo : SecurityError: (:) [], PSSecurityException + FullyQualifiedErrorId : UnauthorizedAccess </code></p> <p><code>VSCode Version: Version: 1.37.1 (user setup) Commit: f06011a Date: 2019-08-15T16:17:55.855Z Electron: 4.2.7 Chrome: 69.0.3497.128 Node.js: 10.11.0 V8: 6.9.427.31-electron.0 OS: Windows_NT x64 10.0.18362 OS Version: Windows 10 Home Version - 1903 OS build - 18362.295</code></p> <p>I've been reading around and seen many threads around permissions for scripts, but I haven't changed any - indeed the PowerShell scripts worked right up until I updated my packages. No other settings touched in the mean time. I don't want to be changing PowerShell settings unnecessarily.</p>
<firebase><powershell><vue.js><npm><visual-studio-code>
2019-08-27 11:41:06
HQ
57,674,804
Is there a regular expression for "foldernameMM_DD__YYYY"
<p>I am setting up Perl script that runs periodically and delete unwanted folders and to identity auto generated folder my organization following naming convention like </p> <blockquote> <p>foldernameMM_DD_YYYY</p> </blockquote> <p>can someone please help me with this regex</p>
<regex><perl>
2019-08-27 12:32:50
LQ_CLOSE
57,675,405
Fill NaN based on previous value of row
<p>I have a data frame (sample, not real):</p> <p>df = </p> <pre><code> A B C D E F 0 3 4 NaN NaN NaN NaN 1 9 8 NaN NaN NaN NaN 2 5 9 4 7 NaN NaN 3 5 7 6 3 NaN NaN 4 2 6 4 3 NaN NaN </code></pre> <p>Now I want to fill NaN values with previous couple(!!!) values of row (fill Nan with left existing couple of numbers and apply to the whole row) and apply this to the whole dataset.</p> <ul> <li>There are a lot of answers concerning filling the columns. But in this case I need to fill based on rows.</li> <li>There are also answers related to fill NaN based on other column, but in my case number of columns are more than 2000. This is sample data</li> </ul> <p>Desired output is:</p> <p>df = </p> <pre><code> A B C D E F 0 3 4 3 4 3 4 1 9 8 9 8 9 8 2 5 9 4 7 4 7 3 5 7 6 3 6 3 4 2 6 4 3 4 3 </code></pre>
<python><pandas>
2019-08-27 13:07:33
HQ
57,676,108
How do I replace all of Column A's values with Column B's values unless Column B's value is NaN?
<p>Given the following DataFrame:</p> <pre><code>import numpy as np import pandas as pd df = pd.DataFrame({"ColA": [1, 2, np.nan, 4, np.nan], "ColB": [np.nan, 7, np.nan, 9, 10]}) ColA ColB 0 1.0 NaN 1 2.0 7.0 2 NaN NaN 3 4.0 9.0 4 NaN 10.0 </code></pre> <p>I want to replace the values of ColA with those of ColB, but I never want a NaN value to replace a non-NaN value. My desired output is the following DataFrame:</p> <pre><code> ColA ColB 0 1.0 NaN 1 7.0 7.0 2 NaN NaN 3 9.0 9.0 4 10.0 10.0 </code></pre> <p>My actual data is quite large, so while I know that I can iterate row-by-row I am looking for a more efficient approach.</p>
<python><pandas><numpy>
2019-08-27 13:47:50
LQ_CLOSE
57,676,859
Blocked autofocusing on a form control in a cross-origin subframe
<p>Using Chrome, when I'm trying to change values of an input located in an IFrame of another app on our server, I get an error in Chrome:</p> <blockquote> <p>"Blocked autofocusing on a form control in a cross-origin subframe."</p> </blockquote> <p>On production (when the two apps are hosted on the same domain) it's working, but on localhost development I can't make it to work.</p> <p>I've already tried starting Chrome with the following:</p> <ul> <li>--disable-web-security </li> <li>--ignore-certificate-errors </li> <li>--disable-site-isolation-trials </li> <li>--allow-external-pages </li> <li>--disable-site-isolation-for-policy</li> </ul> <p>but none worked.</p> <p>Has anyone has an idea how to make it work? If any change on server side needed, it's also an option.</p>
<security><iframe><cross-domain>
2019-08-27 14:25:55
HQ
57,677,481
Jupyter command `jupyter-lab` not found
<p>I have tried to install jupyter lab on my Kubuntu machine. If I install jupyter lab with 'pip3 install jupyter jupyterlab' the command 'jupyter notebook' works completly fine. But if I try to run 'jupyter lab' every time I get the message:</p> <pre><code>Traceback (most recent call last): File "/usr/local/bin/jupyter", line 11, in &lt;module&gt; sys.exit(main()) File "/usr/local/lib/python3.6/dist-packages/jupyter_core/command.py", line 230, in main command = _jupyter_abspath(subcommand) File "/usr/local/lib/python3.6/dist-packages/jupyter_core/command.py", line 133, in _jupyter_abspath 'Jupyter command `{}` not found.'.format(jupyter_subcommand) Exception: Jupyter command `jupyter-lab` not found. </code></pre> <p>What is wrong?</p> <p>I tried to reinstall jupyter and jupyterlab multiple times with the same issue.</p>
<python><jupyter-notebook><jupyter><jupyter-lab><lab>
2019-08-27 14:58:31
HQ
57,679,221
ASP.NET Core 2.2 Site Warmup
<p>I've migrated a .NET Framework 4.6 WebApi to .NETCore 2.2 and am having trouble getting the IIS ApplicationInitialization module to call my endpoints on a startup/slot swap/scale out. </p> <p>I added a Web.Config like:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;configuration&gt; &lt;location path="." inheritInChildApplications="false"&gt; &lt;system.webServer&gt; &lt;handlers&gt; &lt;add name="aspNetCore" path="*" verb="*" modules="AspNetCoreModuleV2" resourceType="Unspecified" /&gt; &lt;/handlers&gt; &lt;aspNetCore processPath="dotnet" arguments=".\FR911.Api.Core.dll" stdoutLogEnabled="false" stdoutLogFile="\\?\%home%\LogFiles\stdout" hostingModel="inprocess" /&gt; &lt;applicationInitialization doAppInitAfterRestart="true"&gt; &lt;add initializationPage="api/Warmup&gt; &lt;add initializationPage="/" /&gt; &lt;/applicationInitialization&gt; &lt;/system.webServer&gt; &lt;/location&gt; &lt;/configuration&gt; </code></pre> <p>But if I keep the default hosting model of "inprocess" my warmup never gets called. If I change to "outofprocess" hosting, my warmup does get called before the swap is completed. </p> <p>I think the issue below is likely related:</p> <p><a href="https://github.com/aspnet/AspNetCore/issues/8057" rel="noreferrer">https://github.com/aspnet/AspNetCore/issues/8057</a></p> <p>I'm not looking to just manually ping or otherwise hit my endpoint because I want the existing feature in the module that IIS is Azure won't actually swap the endpoints until the warmup requests have finished (thus initing EFCore etc.)</p> <p>Has anyone had any luck getting this to work with the inprocess hosting model?</p>
<azure><asp.net-core><azure-web-sites><asp.net-core-webapi>
2019-08-27 16:56:13
HQ
57,679,241
How can I improve my Android Studio App Performance
<p>It just so happened, that I have created a class that has 1000+ lines. After installing the app on the device, the application starts slowing the device really hard. Will rewriting this script to three different classes, approximately 300 lines each, solve my issue?</p>
<java><android><android-studio>
2019-08-27 16:57:59
LQ_CLOSE
57,681,885
How to get Current Location using SwiftUI, without ViewControllers?
<p>I've prepared in my project the following class to retrieve the user current location:</p> <pre><code>LocationManager.swift import Foundation import CoreLocation class LocationManager: NSObject { // - Private private let locationManager = CLLocationManager() // - API public var exposedLocation: CLLocation? { return self.locationManager.location } override init() { super.init() self.locationManager.delegate = self self.locationManager.desiredAccuracy = kCLLocationAccuracyBest self.locationManager.requestWhenInUseAuthorization() } } // MARK: - Core Location Delegate extension LocationManager: CLLocationManagerDelegate { func locationManager(_ manager: CLLocationManager, didChangeAuthorization status: CLAuthorizationStatus) { switch status { case .notDetermined : print("notDetermined") // location permission not asked for yet case .authorizedWhenInUse : print("authorizedWhenInUse") // location authorized case .authorizedAlways : print("authorizedAlways") // location authorized case .restricted : print("restricted") // TODO: handle case .denied : print("denied") // TODO: handle default : print("unknown") // TODO: handle } } } // MARK: - Get Placemark extension LocationManager { func getPlace(for location: CLLocation, completion: @escaping (CLPlacemark?) -&gt; Void) { let geocoder = CLGeocoder() geocoder.reverseGeocodeLocation(location) { placemarks, error in guard error == nil else { print("*** Error in \(#function): \ (error!.localizedDescription)") completion(nil) return } guard let placemark = placemarks?[0] else { print("*** Error in \(#function): placemark is nil") completion(nil) return } completion(placemark) } } } </code></pre> <p>But I'm not sure how to use it, while using SwiftUI, from my ContentView file. How am I supposed to get the exposedLocation without using the approach I would have used in a standard ViewController (in this case the use of guard, let and return of course generates all kind of errors, since I'm not supposed to use returns in this context, if I got it right). Any hint about how to achieve this? I would like to get the user location whenever a button is pressed (at the moment I've used just mockup data). </p> <pre><code>ContentView.swift import SwiftUI struct Location: Identifiable { // When conforming to the protocol Identifiable we have to to implement a variable called id however this variable does not have to be an Int. The protocol only requires that the type of the variable id is actually Hashable. // Note: Int, Double, String and a lot more types are Hashable let id: Int let country: String let state: String let town: String } struct ContentView: View { // let’s make our variable a @State variable so that as soon as we change its value (by for eexample adding new elements) our view updates automagically. @State var locationList = [ Location(id: 0, country: "Italy", state: "", town: "Finale Emilia"), Location(id: 1, country: "Italy", state: "", town: "Bologna"), Location(id: 2, country: "Italy", state: "", town: "Modena"), Location(id: 3, country: "Italy", state: "", town: "Reggio Emilia"), Location(id: 4, country: "USA", state: "CA", town: "Los Angeles") ] // - Constants private let locationManager = LocationManager() // THIS IS NOT POSSIBLE WITH SWIFTUI AND GENERATES ERRORS guard let exposedLocation = self.locationManager.exposedLocation else { print("*** Error in \(#function): exposedLocation is nil") return } var body: some View { // Whenever we use a List based of an Array we have to let the List know how to identify each row as unique // When confirming to the Identifiable protocol we no longer have to explicitly tell the List how the elements in our Array (which are conforming to that protocol) are uniquely identified NavigationView { // let’s add a title to our Navigation view and make sure you always do so on the first child view inside of your Navigation view List(locationList) { location in NavigationLink(destination: LocationDetail(location: location)) { HStack { Text(location.country) Text(location.town).foregroundColor(.blue) } } } .navigationBarTitle(Text("Location")) .navigationBarItems( trailing: Button(action: addLocation, label: { Text("Add") })) } } func addLocation() { // We are using the native .randomElement() function of an Array to get a random element. The returned element however is optional. That is because in the case of the Array being empty that function would return nil. That’s why we append the returned value only in the case it doesn’t return nil. if let randomLocation = locationList.randomElement() { locationList.append(randomLocation) } } } struct ContentView_Previews: PreviewProvider { static var previews: some View { ContentView() } } </code></pre>
<core-location><swiftui>
2019-08-27 20:33:15
HQ
57,682,335
Xcode 11 beta 6 behind Xcode 11 beta 7 download link?
<p>I have tried to download several times Xcode beta version which should be Xcode 11 beta 7 with iOS 13.1 beta support. I am downloading it from this link: <a href="https://download.developer.apple.com/Developer_Tools/Xcode_11_Beta_7/Xcode_11_Beta_7.xip" rel="noreferrer">https://download.developer.apple.com/Developer_Tools/Xcode_11_Beta_7/Xcode_11_Beta_7.xip</a></p> <p>Also, when unpacking, it's obviously saying that it's unpacking Xcode 11 beta 7:</p> <p><a href="https://i.stack.imgur.com/GYJbo.png" rel="noreferrer"><img src="https://i.stack.imgur.com/GYJbo.png" alt="enter image description here"></a></p> <p>But after unpacking it (on 27th of August around 23:05), I am seeing following:</p> <p><a href="https://i.stack.imgur.com/ZSw17.png" rel="noreferrer"><img src="https://i.stack.imgur.com/ZSw17.png" alt="enter image description here"></a></p> <p>And when I start Xcode I see this:</p> <p><a href="https://i.stack.imgur.com/AkFVy.png" rel="noreferrer"><img src="https://i.stack.imgur.com/AkFVy.png" alt="enter image description here"></a></p> <p>Any ideas what might be happening?</p> <p>Thanks in advance for any kind of answer.</p>
<xcode><xcode11>
2019-08-27 21:13:05
HQ
57,682,889
Resize Width and Height of an Image During Upload
<p>I have an upload script that renames and uploads .png files to directory of my website. I want the script to be able to scale the image down to 256x256 pixels during the upload process.</p> <p>I was looking around here and I can't figure out how to include it in the code I already have.</p> <pre><code>&lt;?php $z = $_POST['z']; $x = $_POST['x']; $y = $_POST['y']; $target_dir = "/DIRECTORY/$z-$x-$y.png"; $target_file = $target_dir . basename($_FILES["fileToUpload"]["name"]); $uploadOk = 1; $imageFileType = strtolower(pathinfo($target_file,PATHINFO_EXTENSION)); // Check if image file is a actual image or fake image if(isset($_POST["submit"])) { $check = getimagesize($_FILES["fileToUpload"]["tmp_name"]); if($check !== false) { echo "File is an image - " . $check["mime"] . "."; $uploadOk = 1; } else { echo "File is not an image."; $uploadOk = 0; } } // Check if file already exists if (file_exists($target_file)) { echo "Sorry, file already exists."; $uploadOk = 0; } // Check file size if ($_FILES["fileToUpload"]["size"] &gt; 500000) { echo "Sorry, your file is too large."; $uploadOk = 0; } // Allow certain file formats if($imageFileType != "png") { echo "Sorry, only PNG files are allowed."; $uploadOk = 0; } // Check if $uploadOk is set to 0 by an error if ($uploadOk == 0) { echo "Sorry, your file was not uploaded."; // if everything is ok, rename then try to upload file } else { if (move_uploaded_file($_FILES["fileToUpload"]["tmp_name"], $target_dir)) { echo "The file ". basename( $_FILES["fileToUpload"]["name"]). " has been uploaded."; echo '&lt;a href="mywebsite"&gt;To The Drawbox! &lt;/a&gt;'; } else { echo "Sorry, there was an error uploading your file."; } } ?&gt; </code></pre> <p>So far it only renames the files but does not resize.</p>
<php>
2019-08-27 22:17:26
LQ_CLOSE
57,682,895
Input type number increment using scroll
<p>I'm having some hard time figuring out how to implement "input type number" increment using scroll feature. </p> <p>My question may sound confusing, so I attached an example. </p> <p><a href="https://i.stack.imgur.com/JXMRg.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/JXMRg.png" alt="enter image description here"></a></p> <p><strong>Live preview: <a href="https://webuyfiredamagedhouses.com/cash-offer/" rel="nofollow noreferrer">https://webuyfiredamagedhouses.com/cash-offer/</a></strong></p>
<jquery><html><css>
2019-08-27 22:18:20
LQ_CLOSE
57,683,104
Why is the value of my expression for two parameters incorrect?
<p>I am working on a homework problem for an introductory level Python class and am having difficulty understanding functions involving defining multiple parameters.</p> <p>I have already tried numerous attempts from a variety of online resources without any luck.</p> <p>The question asks "Write the definition of a function typing_speed, that receives two parameters. The first is the number of words that a person has typed (an int greater than or equal to zero) in a particular time interval. The second is the length of the time interval in seconds (an int greater than zero). The function returns the typing speed of that person in words per minute (a float)."</p> <p>This is the code that is displaying an incorrect expression. </p> <pre><code>def typing_speed(num_words,time_interval): num_words&gt;=0 time_interval&gt;0 result=float((num_words)/(time_interval*60)) return result </code></pre> <p>Thank you for any help</p>
<python><function>
2019-08-27 22:51:25
LQ_CLOSE
57,683,206
What is the reverse of "kubectl apply"?
<p>I was playing around in minikube and installed the wrong version of istio. I ran:</p> <pre><code>kubectl apply -f install/kubernetes/istio-demo-auth.yaml </code></pre> <p>instead of:</p> <pre><code>kubectl apply -f install/kubernetes/istio-demo.yaml </code></pre> <p>I figured I would just undo it and install the right one.</p> <p>But I cannot seem to find an <code>unapply</code> command.</p> <p><strong>How do I <em>undo</em> a "kubectl apply" command?</strong></p>
<kubernetes>
2019-08-27 23:09:19
HQ
57,683,303
How can I see the full expanded contract of a Typescript type?
<p>If I have a collection of types that looks a bit like this, only more verbose:</p> <pre><code>type ValidValues = string | number | null type ValidTypes = "text" | "time" | "unknown" type Decorated = { name?: string | null type?: ValidTypes value?: ValidValues title: string start: number } type Injected = { extras: object } // overriding the types from Decorated type Text = Decorated &amp; Injected &amp; { name: string type: "text" value: string } </code></pre> <p>My actual code has more going on, but this shows the core idea. I don't want to have to trust myself to get the relationships between types just right. I want tooling to show me what the type definition for <code>Text</code> "evaluates" to, after all the type algebra.</p> <p>So for the above example, I'm hoping the fields specified in <code>Text</code> will override the previous declarations made in the <code>Decorated</code> type, and the output of my hypothetical tooltip would (I hope) show me something like this:</p> <pre><code>{ name: string type: "text" value: string title: string start: number extras: object } </code></pre> <p>Is there any convenient way to get this information?</p>
<typescript><visual-studio-code><algebraic-data-types>
2019-08-27 23:26:28
HQ
57,683,872
How to stop AndroidStudio from overwriting .idea/codeStyles/Project.xml
<p>In our project, we have committed .idea/codeStyles/Project.xml to source control with the goal of enforcing a common style among all contributors to the project without affecting the style of other projects. </p> <p>However, Android Studio appears to be making unwanted changes to this file. </p> <p>Pulling down the latest code from git and then simply opening Android Studio and then checking <code>git status</code> produces:</p> <pre><code>Changes not staged for commit: (use "git add &lt;file&gt;..." to update what will be committed) (use "git checkout -- &lt;file&gt;..." to discard changes in working directory) modified: my-project/.idea/codeStyles/Project.xml no changes added to commit (use "git add" and/or "git commit -a") </code></pre> <p>The changes it is making look like this: <a href="https://i.stack.imgur.com/kpfnk.png" rel="noreferrer"><img src="https://i.stack.imgur.com/kpfnk.png" alt="enter image description here"></a></p> <p>As you can see it is removing some XML-formatting settings. </p> <p>I am running Android Studio 3.5, but I can't guarantee that everyone else is, and we would like to keep the project agnostic with respect to IDE-version. </p> <p>Is there a way to prevent Android Studio from changing these settings? Is there a more recommended way to achieve uniform code-style?</p>
<android-studio><android-studio-3.5>
2019-08-28 01:10:04
HQ
57,684,259
Why using operator OR (logical operator) in if-else, why not using AND (logcial operator) in if-else
<p>I made the alphabet with the appearance of using stars to form the alphabet, but I was confused as to why to use the OR operation instead of the AND operation on if-else?</p> <pre><code>int row,column; for(row=1;row&lt;=4;row++){ for(column=1;column&lt;=7;column++){ if((column==1 || column==2 || column==3 || column==5 || column==6 || column==7) &amp;&amp; (row==1)) printf(" "); else if((column==1 || column==2 || column==4 || column==6 || column==7) &amp;&amp; (row==2)) printf(" "); else if((column==1 || column==7) &amp;&amp; (row==3)) printf(" "); else if((column==2 || column==3 || column==4 || column==5 || column==6) &amp;&amp; (row==4)) printf(" "); else printf("*"); } printf("\n"); } </code></pre> <p>Why using operator || in if-else? why not using operator &amp;&amp; in if-else for condition column...</p>
<c>
2019-08-28 02:18:49
LQ_CLOSE
57,684,786
State of Thread before start of run is not New, its runnable, Isn't it wrong
<p>I am new to threads in Java from the basic learning I understand that when a thread is created, it is in the new state. The thread has not yet started to run when the thread is in this state </p> <pre><code>public class MainClassForThread { public static void main(String[] args) { // TODO Auto-generated method stub Thread t1 = new ExtendingThreadClass(); Thread t2 = new ExtendingThreadClass(); Thread t3 = new ExtendingThreadClass(); System.out.println("Before start of thread the state of thread is " + t1.currentThread().getState()); t1.start(); t2.start(); t3.start(); } } package Threads; public class ExtendingThreadClass extends Thread { public void run() { System.out.println("Thread running : " + Thread.currentThread().getId()); for (int i = 0; i &lt; 100; i++) { System.out.println("Thread " + Thread.currentThread().getName() + " is running for value of i " + i); System.out.println("State " + Thread.currentThread().getState()); } } } </code></pre> <p>I am expecting the output of the first line of code should be NEW as the thread t1 is not started yet, but Output is as below</p> <pre><code>Before start of thread the state of thread is RUNNABLE Thread running : 10 Thread running : 12 Thread Thread-2 is running for value of i 0 Thread running : 11 Thread Thread-0 is running for value of i 0 State RUNNABLE Thread Thread-0 is running for value of i 1 State RUNNABLE Thread Thread-0 is running for value of i 2 </code></pre>
<java><multithreading>
2019-08-28 03:47:20
LQ_CLOSE
57,685,791
How to assign an overloaded class method to anonymous method?
<p>In Delphi, we can assign a class method (declared as <code>procedure of object</code>) as parameter of type anonymous method.</p> <p>For overloaded methods (same method names), passing the object method fail with compilation error:</p> <pre><code>[dcc32 Error] Project56.dpr(40): E2010 Incompatible types: 'System.SysUtils.TProc&lt;System.Integer,System.Integer&gt;' and 'Procedure of object' </code></pre> <p>The following example show the situation. Is that possible to let the overloaded method pass as anonymous method parameter?</p> <pre><code>type TTest = class public procedure M(a: Integer); overload; procedure M(a, b: Integer); overload; end; procedure TTest.M(a, b: Integer); begin WriteLn(a, b); end; procedure TTest.M(a: Integer); begin WriteLn(a); end; procedure DoTask1(Proc: TProc&lt;Integer&gt;); begin Proc(100); end; procedure DoTask2(Proc: TProc&lt;Integer,Integer&gt;); begin Proc(100, 200); end; begin var o := TTest.Create; DoTask1(o.M); // &lt;-- Success DoTask2(o.M); // &lt;-- Fail to compile: E2010 Incompatible types: 'System.SysUtils.TProc&lt;System.Integer,System.Integer&gt;' and 'Procedure of object' ReadLn; end. </code></pre>
<delphi>
2019-08-28 05:48:11
HQ
57,686,218
Creating BaseView class in SwiftUI
<p>Lately started learning/developing apps with SwiftUI and seems pretty easy to build the UI components. However, struggling creating a BaseView in SwiftUI. My idea is to have the common UI controls like background , navigation , etc in BaseView and just subclass other SwiftUI views to have the base components automatically.</p>
<swift><user-interface><swiftui>
2019-08-28 06:27:00
HQ
57,686,905
How would I make a user who is verifed have a blue tick next to their name in Django
<p>I would like to know how I would go about adding a system so that if a user if verified, a tick will appear next to their name. I think I will have to make a variable called verifed and make it a bool and only admins can change it. So how would I display an icon next to their name if verified == True?</p> <p>I haven't tried anything because whenever I Google it, tutorials on how to get verified on Instagram flood everything</p>
<python><html><django><web>
2019-08-28 07:19:01
LQ_CLOSE
57,688,146
Custom Keyboard UI in Mobile Browser
<p>I have some problem with user request to custom keyboard UI when using in pwa application in textarea form. is that possible to custom that keyboard? or custom keyboard is only change with setting phone?</p>
<javascript><html><css>
2019-08-28 08:34:18
LQ_CLOSE
57,688,242
SwiftUI. How to change the placeholder color of the TextField?
<p>I want to change the placeholder color of the TextField, but I can't find a method for it.</p> <p>I tried to set <code>foregroundColor</code> and <code>accentColor</code>, but it doesn't change the placeholder color.</p> <p>Here is the code:</p> <pre><code>TextField("Placeholder", $text) .foregroundColor(Color.red) .accentColor(Color.green) </code></pre> <p>Maybe there is no API for this yet?</p>
<swift><swiftui>
2019-08-28 08:38:37
HQ
57,688,276
how to refresh cloud firebase database ..sometimes it shows old values
when i open the page sometimes it shows old values of cloud firebase so for that i need when activity opens firstly it should refresh and then proceed. I tried to refresh it but its not working.. mfirestore.collection("Design1").addSnapshotListener(new EventListener<QuerySnapshot>() { @Override public void onEvent(QuerySnapshot documentSnapshots, FirebaseFirestoreException e) { for (DocumentChange doc : documentSnapshots.getDocumentChanges()) { if (doc.getType() == DocumentChange.Type.ADDED) { Users users = doc.getDocument().toObject(Users.class); usersList.add(users); usersrecycleradapter.notifyDataSetChanged(); } } } }); Toolbar toolbar = findViewById(R.id.toolbar); setSupportActionBar(toolbar); FloatingActionButton fab = findViewById(R.id.fab); fab.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View view) { Intent intent=new Intent(Pic1.this,Cart1.class); startActivity(intent); } }); mfirestore.collection("Extraimage").document("Design1").get().addOnSuccessListener(new OnSuccessListener<DocumentSnapshot>() { @Override public void onSuccess(DocumentSnapshot documentSnapshot) { String image1=documentSnapshot.getString("image1"); Glide.with(Pic1.this).load(image1).into(imageView); } }); context(); } public void context(){ refresh(1000); } private void refresh(int milisecond){ final Handler handler=new Handler(); final Runnable runnable=new Runnable() { @Override public void run() { context(); } }; handler.postDelayed(runnable,milisecond); } }
<android><google-cloud-firestore>
2019-08-28 08:40:28
LQ_EDIT
57,689,636
Handling Dependency 4XX in REST
<p>I am wondering what would be the appropriate error code to bubble upto my clients when I get 4XX from my dependencies. Say for example, one of my downstream services returns to me a 401 code. This means my own server was not authorised for this request. How should I bubble this information to my clients? Would 424 be the appropriate code to bubble up? I read that it was added to HTTP as an extension, so is it recommended to use it?</p>
<rest><http>
2019-08-28 09:53:35
LQ_CLOSE
57,690,979
Miliseconds in C# - long or int?
<p>I'm working with Milisecond and I've used it like </p> <pre><code>Timeout = (int)TimeSpan.FromMinutes(TimeoutVal).TotalMilliseconds </code></pre> <p>But I read on few places people are casting it to <code>long</code> instead of <code>int</code>? Why is that?</p>
<c#><timespan>
2019-08-28 11:06:24
LQ_CLOSE
57,691,143
Fill textbox with cell value based om id
<p>I need the corresponding invoice id to be on the invoice frame called frmTrade and the rest of the data in the other textboxes..</p> <p>I am by no means an expert so any help is appreciated. I only succeeded in coloring the relevant id's red.</p> <p>No error messages, but it is not choosing the relevant id double clicking on the lstInvoiceView listbox.</p> <pre><code>Private Sub lstInvoiceView_DblClick(ByVal Cancel As MSForms.ReturnBoolean) WatchInvoiceSheetId End Sub Sub WatchInvoiceSheetId() On Error Resume Next Worksheets("Faktura").Activate Dim ws As Worksheet Dim numRow As Integer Dim found As Boolean Set ws = ThisWorkbook.Worksheets("Faktura") strRows = ws.Range("E" &amp; ws.Rows.Count).End(xlUp).row Worksheets("Faktura").Range("A2:A" &amp; strRows).Interior.ColorIndex = 0 If frmCostumer.lstInvoiceView.ListCount &lt;&gt; 0 Then frmCostumer.lstInvoiceView.Clear End If i = 0 For numRow = 1 To strRows If frmCostumer.txtCostumerId.Value = ws.Range("E" &amp; numRow).Text Then i = i + 1 frmCostumer.txtQuantityInvoice.Value = i If Worksheets("Faktura").Range("A" &amp; numRow &amp; ":A" &amp; numRow).Interior.ColorIndex = 3 Then Worksheets("Faktura").Range("A" &amp; numRow &amp; ":A" &amp; numRow).Interior.ColorIndex = 3 ElseIf Worksheets("Faktura").Range("A" &amp; numRow &amp; ":A" &amp; numRow).Interior.ColorIndex = 1 Then Exit Sub Else Worksheets("Faktura").Range("A" &amp; numRow &amp; ":A" &amp; numRow).Interior.ColorIndex = 3 With frmTrade.txtInvoicNumber .Value = Worksheets("Faktura").Range("A" &amp; numRow - frmCostumer.lstInvoiceView.ListCount - numRow &amp; ":A" &amp; numRow - frmCostumer.lstInvoiceView.ListCount - numRow).Value End With DoEvents frmCostumer.Hide frmTrade.Show End If found = True 'Exit For End If Next numRow If found = False Then frmCostumer.txtQuantityInvoice.Value = i frmTrade.txtInvoicNumber.Value = "Findes ikke!" End If End Sub </code></pre>
<listbox><cell><id>
2019-08-28 11:16:40
LQ_CLOSE
57,691,320
Is there a .NET Core socket-io client implementation?
<p>Is there a c# client that follows the socket.io protocol? I have an NodeJS application that runs a socket-io server and I need a client in another application in .Net Core that needs to communicate with the socket-io server.</p> <p>These are some implementations that I've found:</p> <p><a href="https://github.com/Quobject/SocketIoClientDotNet" rel="noreferrer">SocketIoClientDotNet</a> - Deprecated</p> <p><a href="https://archive.codeplex.com/?p=socketio4net" rel="noreferrer">socketio4net</a> - Deprecated</p> <p><a href="https://github.com/IBM/socket-io" rel="noreferrer">IBM.Socket-IO</a> - Doesn't Work in .NET Core</p> <p>Is there anything more recent that is being maintained that can accomplish this task?</p>
<asp.net-core><websocket><socket.io>
2019-08-28 11:26:11
HQ
57,693,490
How to wrap height of Android ViewPager2 to height of current item?
<p>This question is for the new <strong>ViewPager2</strong> class.</p> <p>There is a <a href="https://stackoverflow.com/questions/34484833/how-to-wrap-the-height-of-a-viewpager-to-the-height-of-its-current-fragment">similar question for the old ViewPager</a>, but the solution requires extending <strong>ViewPager</strong>. However, ViewPager2 is final so cannot be extended.</p> <p>In my situation, I have a ViewPager2 that contains three different fragments. One of these fragments is much taller than the other two, which means when you swipe to one of the shorter fragments, there is a lot of empty space. So how do I effectively wrap the ViewPager2 to the height of the current fragment?</p>
<android><android-fragments><android-viewpager><android-viewpager2>
2019-08-28 13:22:16
HQ
57,693,506
Converting a string with decimal pointers and thousand seperators interchangeably to a float in PHP
<p>I was wondering how to be able to convert any string to a float with the thousand separators and decimal pointers being able to be switched around. This is very useful when dealing with both European and American formats. E.g. <code>'2,192,520.12'</code> or <code>'2.192.520,12'</code></p>
<php><string><floating-point><type-conversion>
2019-08-28 13:23:05
LQ_CLOSE
57,694,345
Sql query two first rows group by userId
<p>I have the data like this</p> <pre><code>deviceId | userId | Time 20 | 1 | 2-Jan-18 21 | 1 | 2-Jan-19 22 | 1 | 2-Jan-10 30 | 2 | 2-Jan-18 30 | 2 | 2-Jan-19 </code></pre> <p>I would like to query 2 first devices that the user uses and also the time (group by userId)</p> <pre><code>userId|firstDeviceId|firstDeviceTime|secondDeviceId|secondDeviceTime 1 |20 | 2-Jan-18 | 21 | 2-Jan-19 2 |30 | 2-Jan-18 | 30 | 2-Jan-19 </code></pre> <p>Could you guys show me the way to do it? Thanks</p>
<sql>
2019-08-28 14:07:29
LQ_CLOSE
57,696,372
Store procedure in c - problem with output parameter. How can I use string?
I applied this code https://dev.mysql.com/doc/refman/5.5/en/c-api-prepared-call-statements.html. That's all right if I use int output variable. But what to do with MYSQL_TYPE_STRING? Adding this case to others is not enought. Any advices?
<mysql><c><linux><mysql-workbench>
2019-08-28 16:08:02
LQ_EDIT