Recent Questions - Stack Overflow most recent 30 from stackoverflow.com 2019-06-26T18:45:56Z https://stackoverflow.com/feeds http://www.creativecommons.org/licenses/by-sa/3.0/rdf https://stackoverflow.com/q/56779273 0 How to display an object's variable's name? Jacob https://stackoverflow.com/users/8915182 2019-06-26T18:45:14Z 2019-06-26T18:45:14Z <p>I seem to be repeating myself when building a detail class to display object data. Is there a way to *ngFor: for each attribute of the rug object, display the attribute's name, and then bind it to the object's value?</p> <p>(The same question, for Ruby.)[<a href="https://stackoverflow.com/questions/43369851/accessing-a-variables-name-from-an-object]">Accessing a variable&#39;s name from an object</a></p> <pre><code>//rug-detail.component.ts &lt;div class="row"&gt; &lt;div class="col-md-3"&gt;Name:&lt;/div&gt; &lt;div class="col-md-6"&gt;{{rug.name}}&lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div class="col-md-3"&gt;ID:&lt;/div&gt; &lt;div class="col-md-6"&gt;{{rug.id}}&lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div class="col-md-3"&gt;Availability:&lt;/div&gt; &lt;div class="col-md-6"&gt;{{rug.availability}}&lt;/div&gt; &lt;/div&gt; &lt;div class="row"&gt; &lt;div class="col-md-3"&gt;Price:&lt;/div&gt; &lt;div class="col-md-6"&gt;{{rug.price|currency:"USD":"symbol"}}&lt;/div&gt; </code></pre> <pre><code>//rug.ts export interface Rug{ name: string; id: number; availability: String; price: number; } </code></pre> https://stackoverflow.com/q/56779270 0 How to fix react-native-static-server websocket error on iOS? Tavo Parra https://stackoverflow.com/users/2734484 2019-06-26T18:44:52Z 2019-06-26T18:44:52Z <p>I am using react-native-static-server to run an HTML game locally and render it in a WebView. It works correctly on android physical devices but for iOS I am getting the following error when starting the server:</p> <blockquote> <p>TypeError: Cannot read property 'start' of undefined</p> <p>This error is located at: in RocketView (at DownloadedGameView.js:54)...</p> </blockquote> <p>This is the part of the that's refered on the error:</p> <blockquote> <p>import StaticServer from 'react-native-static-server';</p> <p>startServer() { this.server = new StaticServer(0, this.props.localPath, { localOnly: true });</p> <pre><code>this.server.start().then(url =&gt; { this.setState(prevState =&gt; { if (!prevState.source) prevState.source = {}; prevState.source = { uri: url + '/' + this.props.htmlName }; prevState.serverReady = true; return prevState; }); }); } </code></pre> </blockquote> <p>And the following error appears on the console:</p> <blockquote> <p>Error: not opened at WebSocket.send (/Users/tavo.parra/Documents/Development/discovery/discovery-kids-app/dkidsworld/node_modules/ws/lib/WebSocket.js:219:16) at send (/Users/octavio.parra/Documents/Development/discovery/discovery-kids-app/dkidsworld/node_modules/react-native/local-cli/server/util/webSocketProxy.js:26:12) at WebSocket.debuggerSocket.onmessage (/Users/octavio.parra/Documents/Development/discovery/discovery-kids-app/dkidsworld/node_modules/react-native/local-cli/server/util/webSocketProxy.js:48:48) at WebSocket.onMessage (/Users/octavio.parra/Documents/Development/discovery/discovery-kids-app/dkidsworld/node_modules/ws/lib/WebSocket.js:442:14) at emitTwo (events.js:126:13) at WebSocket.emit (events.js:214:7) at Receiver.ontext (/Users/octavio.parra/Documents/Development/discovery/discovery-kids-app/dkidsworld/node_modules/ws/lib/WebSocket.js:841:10) at /Users/octavio.parra/Documents/Development/discovery/discovery-kids-app/dkidsworld/node_modules/ws/lib/Receiver.js:536:18 at /Users/octavio.parra/Documents/Development/discovery/discovery-kids-app/dkidsworld/node_modules/ws/lib/Receiver.js:368:7 at /Users/octavio.parra/Documents/Development/discovery/discovery-kids-app/dkidsworld/node_modules/ws/lib/PerMessageDeflate.js:249:5</p> </blockquote> <p>Any idea on how to solve this? I didn't find any information related and have been struggling with this for several days</p> https://stackoverflow.com/q/56779268 0 Animate an Shape/Image Swift using a Timer Tarun R https://stackoverflow.com/users/11698944 2019-06-26T18:44:43Z 2019-06-26T18:44:43Z <p>I mostly code in JavaScript, but I have to write in Swift for a project. As such to speed up my learning process, I am looking to write Swift code very similar to how I would write in JavaScript.</p> <p>In JavaScript, I have a method draw(), I call that method every millisecond. In draw() for example, I could draw a Square to the canvas (scene). Then if I increments the square's X position, when draw() gets called again, the Square moves. The same can be done with images, thus with that basic logic, a game can be built.</p> <p>Now in Swift, I have tried to do something similar, to make a method similar to draw(), and call that method over and over. However, the animation is really choppy and laggy, if I were to do the same thing in JavaScript it looks fine.</p> <pre><code>import UIKit import PlaygroundSupport import Foundation public class sim : UIView{ var circleX = 100; var circleY = 135; public init(){ super.init(frame: CGRect(x: 0, y: 0, width: 500, height: 300)) self.backgroundColor = #colorLiteral(red: 0.9428111294, green: 0.9428111294, blue: 0.9428111294, alpha: 1) var simulationTimer = Timer.scheduledTimer(timeInterval: 0.00001, target: self, selector: #selector(drawScene), userInfo: nil, repeats: true) } @objc func drawScene(){ let background = UIView(frame: CGRect(x: 0, y: 0, width: 500, height: 300)) background.backgroundColor = #colorLiteral(red: 0.9428111294, green: 0.9428111294, blue: 0.9428111294, alpha: 1) self.addSubview(background) circleX+=5 let circle = UIView(frame: CGRect(x: circleX, y: circleY, width: 30, height: 30)) circle.backgroundColor = #colorLiteral(red: 0.4633018092, green: 0.4633018092, blue: 0.4633018092, alpha: 1) circle.layer.cornerRadius = 15 circle.layer.borderWidth = 3.0 circle.layer.borderColor = #colorLiteral(red: 0.2512571216, green: 0.2528424561, blue: 0.2970899045, alpha: 1) self.addSubview(circle) } public required init?(coder aDecoder: NSCoder) { fatalError("init(coder:) has not been implemented") } } PlaygroundPage.current.liveView = sim() </code></pre> https://stackoverflow.com/q/56779267 0 Is it overfitting? Sherlock Lo https://stackoverflow.com/users/11475666 2019-06-26T18:44:38Z 2019-06-26T18:44:38Z <p>I have a CNN model that is performing very well (98% accuracy, 1.~ loss) on training data but poorly (50% accuracy, 3.5 loss) on testing data.</p> <p>The architecture is below:</p> https://stackoverflow.com/q/56779265 0 why is my while loop skipping over the first line of my file KA97 https://stackoverflow.com/users/11119563 2019-06-26T18:44:37Z 2019-06-26T18:44:37Z <p>I have a file with 64 lines in it. I want to extract the first and fifth word of each line to a new file, so i have a while loop running to do this. However, my output file just has 63 lines, and after checking I see that the first line is missing. This is the code I have: </p> <pre><code>tail -n +9 table.$1 &gt; tab.$1 while read -r do awk -v OFS='\t' '{print $1, $5}' &gt; rtable.$1 done &lt; tab.$1 </code></pre> <p>The tail at the beginning is to get the 64 lines I want from a larger file. However it is not the issue as the tab.$1 file is fine, but rtable.$1 file which is shorter. </p> https://stackoverflow.com/q/56779264 0 How find turning angle in track with latitude and longitude Érika Soares Coelho https://stackoverflow.com/users/11268155 2019-06-26T18:44:25Z 2019-06-26T18:44:25Z <p>I have one <code>data.frame = loc</code> with 36 <code>Ptt's</code> (ID's for animals), <code>Dates</code> between 2016-2018, <code>Latitude</code> and <code>Longitude</code> in decimal degree and (the <code>data.frame</code> has more than 25 thousand lines), here is an example of the <code>data.frame (with only two</code>Ptt`):</p> <pre><code>Ptt Date Latitude Longitude 172002 2017-10-24 21:26:31 -17.8926 -39.3607 172002 2017-10-24 21:48:14 -17.8948 -39.3659 172002 2017-10-24 23:23:34 -17.8923 -39.3591 172002 2017-10-25 00:06:00 -17.8948 -39.3667 . . . 111868 2016-10-23 05:39:18 -20.3108 -40.2825 111868 2016-10-23 08:08:56 -20.3103 -40.2822 111868 2016-10-23 08:50:41 -20.3108 -40.2861 111868 2016-10-23 09:39:41 -20.3098 -40.2815 &gt; class(loc_2$Date) [1] "POSIXct" "POSIXt" &gt; class(loc_$Latitude) [1] "numeric" &gt; class(loc_$Longitude) [1] "numeric" </code></pre> <p>I tried to convert the Latitude and Longitude in UTM, but didn't works with this:</p> <pre><code>library(rgdal) LatLong &lt;- data.frame(X = c(loc$Longitude), Y = c(loc $Latitude)) names(LatLong) &lt;- c("X","Y") # Convert it to a sp object coordinates(LatLong) &lt;- ~ Y + X # longitude first # Add a coordinate reference system proj4string(LatLong) &lt;- CRS("+proj=longlat +ellps=WGS84 +datum=WGS84") LatLong # Project using spTransform Utm &lt;- spTransform(LatLong, CRS("+proj=utm +zone=24 ellps=WGS84")) Utm utm1&lt;-as.data.frame(Utm) loc&lt;-merge(loc,utm1) </code></pre> <p>But results in just one value for <code>X</code> and <code>Y</code> in all <code>data.frame</code></p> <p>I tried to use the <code>library(adehabitatLT)</code> like this way, but shows the Error below:</p> <pre><code>&gt; test &lt;- as.ltraj(xy = loc[,c("Y","X")], date = loc$Date, id = "Ptt") Error in as.ltraj(xy = loc_teste2[, c("Y", "X")], date = loc_teste2$Date, : non unique dates for a given burst </code></pre> <p>Inside the function <code>as.ltraj</code> says that don't can't be duplicates in Dates, right? But in my data.frame have a lot of Dates duplicate because the locations were obtained with a little time interval. This have any solution?</p> <p>And, I tried too use <code>library(Argosfilter)</code> too:</p> <pre><code>&gt; head(bearingTrack(loc_teste2$Latitude, loc_teste2$Longitude)) [1] 43.16253 119.67865 -140.55725 -157.87309 -176.36721 -157.57760 </code></pre> <p>But I don't know if its right, on CRAN they says that: <code>bearing</code>(another function) returns the bearing, in degrees, between the first location and the second location. 0 is North. <code>bearingTrack</code> returns a vector of bearings between the sequence of locations.</p> <p>In resume: I need to know the turning angle between the locations and per each <code>Ptt</code> in degrees (0-360°), it's possible?</p> https://stackoverflow.com/q/56779263 0 Why that code don't draw sprites C++ SFML Rafal Fuchs https://stackoverflow.com/users/11704897 2019-06-26T18:44:25Z 2019-06-26T18:44:25Z <p>I wanted to draw sprites on screen having only information about it in my struct and next draw text on it</p> <p>Information are good X and Y scale=1 Path is good and point to graphic position and rotation =0;</p> <p>int free have a good number</p> <p>But Text works so i don't know why Sprite don't </p> <p>I tried commenting code with drawing and making text don't work</p> <pre class="lang-cpp prettyprint-override"><code>struct ObjectInfo { float Xpoz,Ypoz; std::string TexPath; float Xscale,Yscale; float Rotation; }; ObjectInfo OI[1000]; int free; void Draw() { for(int i=0;i&lt;free;i++) { sf::Texture t; t.loadFromFile(OI[i].TexPath); sf::Sprite s; s.setTexture(t); s.setPosition(OI[i].Xpoz,OI[i].Ypoz); s.setScale(OI[i].Xpoz,OI[i].Ypoz); s.setRotation(OI[i].Rotation); okno.draw(s); sf::Text text; text.setFont(font); text.setCharacterSize(48); text.setColor(sf::Color::Black); text.setPosition(s.getPosition()); text.setString(IntToString(i)); okno.draw(text); } } </code></pre> <p>I expected that sprites and Text display but only text display</p> https://stackoverflow.com/q/56779262 0 Search Bar causes the Collection View to display the wrong image JohnR https://stackoverflow.com/users/11704922 2019-06-26T18:44:25Z 2019-06-26T18:44:25Z <p>As I search, the clothingName is narrowed down correctly, yet the clothingImage remains the same. I understand this is because the collection view is displaying the image of the first cell, I'm wondering how I'd be able to change the first cell's image to match the clothingName that's being searched.</p> <p>import UIKit</p> <p>class SecondViewController: UIViewController, UICollectionViewDelegate, UICollectionViewDataSource, UISearchBarDelegate {</p> <pre><code>func collectionView(_ collectionView: UICollectionView, numberOfItemsInSection section: Int) -&gt; Int { if searching { return searchingName.count } else { return clothingName.count } } func collectionView(_ collectionView: UICollectionView, cellForItemAt indexPath: IndexPath) -&gt; UICollectionViewCell { let cell = collectionView.dequeueReusableCell(withReuseIdentifier: "Cell", for: indexPath) as! CollectionViewCell let clothingImageView = cell.viewWithTag(1) as! UIImageView clothingImageView.image = clothingImage[indexPath.row] cell.layer.borderColor = UIColor.lightGray.cgColor cell.layer.borderWidth = 0.5 if searching { cell.clothingLabel.text = searchingName[indexPath.item] } else { cell.clothingLabel.text = clothingName[indexPath.item] cell.clothingImageView.image = clothingImage[indexPath.item] } return cell } @IBOutlet weak var collectionView: UICollectionView! @IBOutlet weak var searchBar: UISearchBar! var clothingName = ["Supreme","yeezy","Bape","Off-White","Jordan","Palace","LV","Adidas"] var searchingName = [String()] var searching = false var arrayOfIDs = [String]() var clothingImage: [UIImage] = [ UIImage(named: "supreme")!, UIImage(named: "yeezy")!, UIImage(named: "bape")!, UIImage(named: "off-white")!, UIImage(named: "jordan")!, UIImage(named: "palace")!, UIImage(named: "lv")!, UIImage(named: "adidas")!, ] override func viewDidLoad() { super.viewDidLoad() collectionView.dataSource = self collectionView.delegate = self searchBar.delegate = self let layout = self.collectionView.collectionViewLayout as! UICollectionViewFlowLayout layout.sectionInset = UIEdgeInsets(top: 0,left: 5,bottom: 5,right: 5) layout.minimumInteritemSpacing = 5 layout.itemSize = CGSize(width: (self.collectionView.frame.size.width - 20)/2, height: self.collectionView.frame.size.height/3) arrayOfIDs = ["supreme","yeezy"] } func collectionView(_ collectionView: UICollectionView, didSelectItemAt indexPath: IndexPath) { let cell = collectionView.cellForItem(at: indexPath) cell?.layer.borderColor = UIColor.gray.cgColor cell?.layer.borderWidth = 3 let name = arrayOfIDs[indexPath.row] let viewController = storyboard?.instantiateViewController(withIdentifier: name) self.navigationController?.pushViewController(viewController!, animated: true) } func collectionView(_ collectionView: UICollectionView, didDeselectItemAt indexPath: IndexPath) { let cell = collectionView.cellForItem(at: indexPath) cell?.layer.borderColor = UIColor.lightGray.cgColor cell?.layer.borderWidth = 0.5 } func searchBar(_ searchBar: UISearchBar, textDidChange searchText: String) { searchingName = clothingName.filter({$0.lowercased().prefix(searchText.count) == searchText.lowercased()}) searching = true collectionView.reloadData() } func searchBarCancelButtonClicked(_ searchBar: UISearchBar) { searching = false searchBar.text = "" searchBar.endEditing(true) collectionView.reloadData() } </code></pre> <p>}</p> https://stackoverflow.com/q/56779261 0 Passing variables from one python to another (which is called by qsub) Sameer https://stackoverflow.com/users/10435027 2019-06-26T18:44:23Z 2019-06-26T18:44:23Z <p>I have two scripts a.py and b.py. </p> <p><strong>a.py</strong></p> <pre><code>x=3 y=9 returns z=x+y </code></pre> <p><strong>b.py</strong></p> <p>uses z in some form and utilizes the multiprocessing module in Python</p> <p><strong>jobfile</strong></p> <p>Invokes the use of b.py</p> <p>When I execute the following for running it on a cluster</p> <pre><code>qsub jobfile.pbs </code></pre> <p>An error to the extent that z is undefined comes. How to declare variables so that this error is obviated?</p> https://stackoverflow.com/q/56779235 -2 Declaring array size max caused me TLE Expectations vs Reality https://stackoverflow.com/users/10520585 2019-06-26T18:42:58Z 2019-06-26T18:44:31Z <p><a href="https://codeforces.com/contest/1183/problem/D" rel="nofollow noreferrer">https://codeforces.com/contest/1183/problem/D</a> on this problem in codeforces recent contest I was getting TLE when I was declaring array size to arr[max+5] but after the contest finish when I declared array size to arr[n+5] code stops giving TLE and runned in just 1/3rd time it was running previously</p> <p>I just cant find why this is happening</p> <p><a href="https://codeforces.com/contest/1183/submission/56128769" rel="nofollow noreferrer">https://codeforces.com/contest/1183/submission/56128769</a> -TLE submission<br> <a href="https://codeforces.com/contest/1183/submission/56128561" rel="nofollow noreferrer">https://codeforces.com/contest/1183/submission/56128561</a> -AC submission</p> <p>Is there something wrong with codeforces judge or I am missing something out because from what I know declaring array of max size is standard practice so why that happened</p> https://stackoverflow.com/q/56779232 0 Invariant Violation: Objects are not valid as a React child when firing a function BARNOWL https://stackoverflow.com/users/7174241 2019-06-26T18:42:48Z 2019-06-26T18:45:48Z <p>Having an issue firing this function if <code>this.state.number</code> is equal to the numbers in the array.</p> <pre><code> delay = async () =&gt; { const sleep = ms =&gt; new Promise(resolve =&gt; setTimeout(resolve, ms)) await sleep(1000); return &lt;Redirect to="/dashboard" /&gt; } </code></pre> <p>error</p> <blockquote> <p>Invariant Violation: Objects are not valid as a React child (found: [object Promise]). If you meant to render a collection of children, use an array instead.</p> </blockquote> <p><strong>Home.js</strong></p> <pre><code>import React, {Component} from 'react'; import {Redirect} from "react-router-dom"; import Grid from '@material-ui/core/Grid'; import './App.css'; import { withRouter } from 'react-router-dom' class Home extends Component { state = { number: "", numbers: ["111-111-1112, 111-111-1111, 111-111-1116, 111-111-1118"] }; onChange = e =&gt; { e.preventDefault(); this.setState({ number: e.target.value }); }; delay = async () =&gt; { const sleep = ms =&gt; new Promise(resolve =&gt; setTimeout(resolve, ms)) await sleep(1000); return &lt;Redirect to="/dashboard" /&gt; } validate = myNum =&gt; this.state.numbers.find(num =&gt; num === myNum); render(){ const validatedNumber = ( &lt;div&gt; &lt;span style={{ color: "green" }}&gt;Activated ✅ &lt;/span&gt; {this.delay()} &lt;/div&gt; ); return ( &lt;div className="main"&gt; &lt;Grid container &gt; &lt;Grid item sm={8} md={12} &gt; &lt;input type="text" placeholder="Validate Number" value={this.state.number} onChange={this.onChange} /&gt; &lt;h2&gt; {this.validate(this.state.number) ? ( validatedNumber ) : ( &lt;div&gt;Not in the system&lt;/div&gt; )} &lt;/h2&gt; &lt;/Grid&gt; &lt;/Grid&gt; &lt;/div&gt; ); } } export default Home; </code></pre> https://stackoverflow.com/q/56779169 0 In Python, is it possible to accept a function call template as a parameter? Mark Green https://stackoverflow.com/users/2890451 2019-06-26T18:38:13Z 2019-06-26T18:44:26Z <p>As part of improving the syntax for Aspect-Oriented Programming in Python based on the excellent answer by jsbueno: <a href="https://stackoverflow.com/questions/12356713/aspect-oriented-programming-aop-in-python">Aspect oriented programming (AOP) in Python</a> , I was wondering if it's possible to accept a function template as a parameter in Python with any decoration.</p> <p>Eg, being able to call <code>foo(bar(5))</code> with <code>bar</code> undefined, and have <code>foo</code> receive an object representing the expression <code>bar(5)</code>; rather than an error that <code>bar</code> is undefined. (This would then be used as an input to construct a rule for matching incoming network messages indicating that another node has run function <code>bar</code> with parameter 5.)</p> <p>Is there any better way to do this than passing the template as a string and parsing it with <code>ast</code>?</p> https://stackoverflow.com/q/56779142 0 How to generate the UUID when the input payload is read from external file user9142486 https://stackoverflow.com/users/9142486 2019-06-26T18:36:02Z 2019-06-26T18:44:37Z <p>${__UUID()} is not working when sending the payload content which was read from an external file</p> <ol> <li>i am making a post call with input payload read from an external file.</li> <li>In the HTTPRequest post body data, i am using this function to read the external file : ${__FileToString(${__eval(./HTTP/payload.txt)},,)}</li> <li>I can verify that data from the external file is read and being used when the post call is being made.</li> </ol> <p>The issue is that, when making the post call, in the payload, against ID element, ${__UUID()} is not replaced/parsed by the UUID value, the static text "${__UUID()}" is being sent in the payload.</p> <p>How to generate the UUID when the input payload is read from external file ?</p> <p>Note: i also tried reading the file content line by line in BeanShell PreProcessor, and sending it as body data, same issue, UUID function is not parsed.</p> <pre><code>{ "id":"${__UUID()}", "fname":"Hello", "lname":"World" } </code></pre> <p>the expected result is : ${__UUID()} should be parsed and the actual UUID value should be send as part of the request.</p> https://stackoverflow.com/q/56778960 -1 Given a list of strings find each of its string's closest match (edit distance) in another big list of strings user281989 https://stackoverflow.com/users/6089366 2019-06-26T18:23:37Z 2019-06-26T18:44:20Z <p>I have a list of strings <code>small_list = ['string1', 'this is string 2', ...]</code> and a larger list of strings <code>big_list = ['is string 2', 'some other string 3', 'string 1', ...]</code>. I want to find the string that is closest by edit distance for all of the strings in small_list in big_list.</p> <p>I found <a href="https://stackoverflow.com/questions/11630031/find-the-closest-match-of-a-list-in-a-list-containing-lists/">this</a> which does the same with numbers.</p> <p>One of the approache that I came up with was creating a trie (or some kind of a tree) with the concatenated big_list of strings and query that trie to find matches. Due to lack of experience in this, was hoping for some package suggestions or some code that I could start off of.</p> <p>I tried doing this brute force in the following way.</p> <pre><code>from difflib import get_close_matches import datetime a = datetime.datetime.now() print(get_close_matches(str(small_list.iloc[0]), big_list.values.astype(str), n=3, cutoff=0.7)) b = datetime.datetime.now() c = b - a print(c.seconds) </code></pre> <p>But for my dataset and for that one record, it took me <code>834 seconds</code>. <code>len(big_list) = 27989793</code> and <code>len(small_list) = 9329931</code> so performance is of at most importance.</p> <p>Expected output: <code>[3, 1, ...]</code> which are positions of the closest match in big_list.</p> https://stackoverflow.com/q/56778891 -2 What's the difference between global or local variables regarding the main function? Defender https://stackoverflow.com/users/11699594 2019-06-26T18:19:19Z 2019-06-26T18:45:18Z <p>While I know what's the difference between local and global variables I just can't understand if it's important at all, especially when talking about local variables inside the main function. For example what's the difference here except that we can't use the testvar in the second case in other functions?</p> <p>First Case:</p> <pre><code>#include &lt;stdio.h&gt; int testvar; </code></pre> <p>Second Case:</p> <pre><code>#include &lt;stdio.h&gt; int main(void){ int testvar; } </code></pre> <p><strong>Edit: What I mean is that if I am going only to use a variable inside main then does declaring it as global have any advantage Or that in this specefic case nothing different at all?</strong></p> https://stackoverflow.com/q/56778826 3 Match multiple changing time periods between two datasets Fionn https://stackoverflow.com/users/11644783 2019-06-26T18:14:29Z 2019-06-26T18:45:17Z <p>I have two data frames, the first of which spans 3 months and has recordings of depth every 2.5 minutes.</p> <pre><code>shark depth temperature datetime date location A 49.5 26.2 20/03/2018 08:00 20/03/2018 SS04 A 49.5 25.3 20/03/2018 08:02 20/03/2018 SS04 A 53.0 24.2 20/03/2018 08:04 20/03/2018 SS04 A 39.5 26.5 20/03/2018 08:32 20/03/2018 Absent A 43.0 26.2 21/03/2018 09:10 21/03/2018 Absent A 44.5 26.5 21/03/2018 10:18 21/03/2018 SS04 </code></pre> <p>I have a second data frame which lists the tidal state during these three months.</p> <pre><code> date time depth tide_state datetime 18/03/2018 02:33 2.09 High 20/03/2018 02:33 18/03/2018 08:39 0.45 Low 20/03/2018 08:39 18/03/2018 14:47 2.14 High 20/03/2018 14:47 18/03/2018 20:54 0.41 Low 20/03/2018 20:54 19/03/2018 03:01 2.13 High 21/03/2019 03:01 19/03/2018 09:09 0.41 Low 21/03/2019 09:09 </code></pre> <p>I would like to create a new dataset which inserts the tidal state for all the values on the first dataset, based on the datetime column in each. For example if low tide was at 08:39, and high tide at 14:47, I would like every value in df1 greater than 08:39 but less than 14:47 to be recorded as 'Low', and values after this but before the next low tide to be 'High'.</p> <p>As the time of the tides change three to four times per day, I'm not quite sure how I could go about merging these in R. I'm not sure if there is an easy way to do this using data.table?</p> <p>I have both datetime columns in each dataframe set as POSIXct values.</p> <p>Ideally I would like to produce a table a dataframe like this:</p> <pre><code>shark depth temperature datetime date location tide_state A 49.5 26.2 20/03/2018 08:00 20/03/2018 SS04 High A 49.5 25.3 20/03/2018 08:02 20/03/2018 SS04 High A 53.0 24.2 20/03/2018 08:04 20/03/2018 SS04 High A 39.5 26.5 20/03/2018 08:32 20/03/2018 Absent Low A 43.0 26.2 20/03/2018 09:10 21/03/2018 Absent Low A 44.5 26.5 20/03/2018 10:18 21/03/2018 SS04 Low </code></pre> https://stackoverflow.com/q/56778701 0 ListView.builder somehow caches in a wrong way Kevin Lücke https://stackoverflow.com/users/8967264 2019-06-26T18:04:45Z 2019-06-26T18:44:17Z <p>I have a ListView like this but it isn't updating when the value of "mats" changes. The build function is called every time there is an update of my list of mats. The print shows the correct data but the ListView doesn't update correct. Only the number of items updates correct. </p> <p>flutter: MATS: [[8163b55b-9a4c-44e8-a95e-064b3f5e8a67, , 26.06.2019, [], 0.00 EUR]] flutter: MATS: [[8163b55b-9a4c-44e8-a95e-064b3f5e8a67, Unnamed, 26.06.2019, [], 0.00 EUR]]</p> <pre><code> Widget build(BuildContext context) { print('MATS: $mats'); return Padding( padding: const EdgeInsets.all(8.0), child: mats.length == 0 ? Center( child: Text('Add your first mat to start the party.'), ) : mats != null ? ListView.builder( key: Key('matsList'), itemCount: mats?.length ?? 0, itemBuilder: (context, index) { final viewModel = mats[index]; return MatCardView( key: Key('viewModel.toString()'), viewModel: viewModel, onSelect: onSelect, ); }) : Container( child: Center( child: Text('No beer mat yet'), ), ), ); } </code></pre> https://stackoverflow.com/q/56778326 0 SQL Developer connectivity error with Oracle DB 12C Aakash Basu https://stackoverflow.com/users/5536733 2019-06-26T17:35:42Z 2019-06-26T18:44:30Z <p><strong>Error: Status : Failure -Test failed: IO Error: The Network Adapter could not establish the connection</strong></p> <p>I am extremely new to Oracle DB setup and connectivity and am facing issue in connecting SQL Developer with Oracle DB.</p> <p>Steps followed:</p> <p>1) Installed Oracle DB 12c. The following are the installation details:</p> <p>Oracle base: D:\app\admin\virtual</p> <p>Software Location: D:\app\admin\virtual\product\12.2.0\dbhome_1</p> <p>Database file location: D:\app\admin\virtual\oradata</p> <p>Database edition: Standard Edition 2 (5.5GB)</p> <p>Character set: Unicode (AL32UTF8)</p> <p>Global database name: orcl.abc.com</p> <p>password: ******</p> <p>Pluggable database name: orclpdb</p> <p>Note: Oracle Enterprise Manager Database Express URL: <a href="https://localhost:5500/em" rel="nofollow noreferrer">https://localhost:5500/em</a></p> <p>2) Tried connecting to the DB wih sqlplus and it connected like a charm, PFB:</p> <pre><code>C:\Users\Aakash.basu&gt;sqlplus sys as sysdba SQL*Plus: Release 12.2.0.1.0 Production on Wed Jun 26 17:15:28 2019 Copyright (c) 1982, 2016, Oracle. All rights reserved. Enter password: Connected to: Oracle Database 12c Standard Edition Release 12.2.0.1.0 - 64bit Production SQL&gt; </code></pre> <p>3) Unzipped and opened <strong>Oracle SQL Developer</strong> and gave:</p> <p>a) A name</p> <p>b) username (tried with): system, sys and pdbadmin</p> <p>c) password as is given</p> <p>d) Hostname: localhost</p> <p>e) port: 1521</p> <p>f) SID: First used default <strong>xe</strong> (which gave me the error: Status : Failure -Test failed: Listener refused the connection with the following error: ORA-12505, TNS:listener does not currently know of SID given in connect descriptor), so tried with <strong>CLRExtProc</strong> from <strong>tnsnames.ora</strong> file</p> <p>But now, the error is, <strong>Status : Failure -Test failed: IO Error: The Network Adapter could not establish the connection</strong></p> <p>It is a <strong>Windows 10 Machine with x64 based processor</strong>. Please let me know if you need any further details.</p> <p>What to do? Please help!</p> <p>Edit: Even though the question is a duplicate of <a href="https://stackoverflow.com/questions/23851161/oracle-database-12c-error-while-trying-to-connect-the-network-adapter-could-not">this link</a> but none of the answers could solve my problem.</p> https://stackoverflow.com/q/56778087 0 Simplest Node config to turn React into String on server user1791914 https://stackoverflow.com/users/1791914 2019-06-26T17:19:12Z 2019-06-26T18:45:01Z <p>I'm trying to convert react JSX to an HTML string on a node server with the most minimal configuration possible. My best attempt is below, but babel isn't transpiling the JSX - it's throwing an error "SyntaxError: <code>Unexpected token &lt;</code> </p> <p>How can I get this to work? And does it require webpack?</p> <pre><code>require('@babel/core').transform('code', { plugins: ['@babel/plugin-transform-react-jsx'] }); const React = require('react'); const { renderToString } = require('react-dom/server'); const html = renderToString(&lt;p&gt;Hello, world!&lt;/p&gt;); // Should log the html as a string, but I get "SyntaxError: Unexpected token &lt;" since the JSX wasn't compiled through babel console.log('HTML is...', html); </code></pre> https://stackoverflow.com/q/56777786 0 Path for windows cert store in dockerfile Shri Humrudha https://stackoverflow.com/users/11633515 2019-06-26T16:58:38Z 2019-06-26T18:44:29Z <p>I have the certificate installed in my host machine. I want to make the certificates available in the docker image. Taking the route of mounting volumes, I want to know the cert path that is understandable inside docker file.</p> <pre><code>FROM xx VOLUME [“cert:/localmachine/my”,“cert:/localmachine/my”] WORKDIR XX </code></pre> https://stackoverflow.com/q/56777653 0 UIbutton stretching after runtime Ali Alzahrani https://stackoverflow.com/users/1484193 2019-06-26T16:49:57Z 2019-06-26T18:45:17Z <p>I have form page with few textfields and a button. I have added constraints for each component as well. </p> <p>The issue is that the button getting stretched after running the app. Please see below screenshots for my issue. </p> <p><strong>1- button size in storyboard</strong> <a href="https://i.stack.imgur.com/FVegE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/FVegE.png" alt="button size in storyboard"></a></p> <p><strong>2- constraints</strong> </p> <p><a href="https://i.stack.imgur.com/rGDrD.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/rGDrD.png" alt="enter image description here"></a></p> <p><strong>3- result in simulator</strong> </p> <p><a href="https://i.stack.imgur.com/32h9K.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/32h9K.png" alt="enter image description here"></a></p> https://stackoverflow.com/q/56774812 0 Convert list of IOB formatted data to simple IOB formatted data Priyanka Lanjewar https://stackoverflow.com/users/11186092 2019-06-26T14:08:34Z 2019-06-26T18:44:32Z <p>I am a beginner in nlp and want to generate IOB format from the list of sentences.</p> <p>I have data in IOB format in the pattern below:</p> <pre class="lang-py prettyprint-override"><code>[('in', 'O'), ('this', 'B-DATE'), ('week', 'I-DATE'), ('how', 'O'), ('many', 'O'), ('activities', 'O'), ('do', 'O'), ('i', 'O'), ('have', 'O'), ('?', 'O')] </code></pre> <p>The expected output is </p> <pre class="lang-none prettyprint-override"><code>in O this B-DATE week I-DATE how O many O activities O do O i O have O ? O </code></pre> https://stackoverflow.com/q/56772315 0 Desired State Configuration - What gets executed where and will my server use all nodes? SimonS https://stackoverflow.com/users/5084424 2019-06-26T12:00:03Z 2019-06-26T18:44:40Z <p>I'm reading into PowerShell DSC but I already got some questions. I'm using a pull server, where I would run the code below. My questions are:</p> <ul> <li>I read about a server can only have one configuration, one <code>.mof</code> File. In the code below, I would target <code>srv01</code> in 2 nodes. would this be saved into a single <code>.mof</code> file? </li> <li>If I would have another Configuration in the same or another <code>.ps1</code> File which targets <code>srv01</code>, would this be merged together into the same <code>.mof</code> or would this create a second <code>.mof</code> for the server and therefore not work?</li> <li>I think I need to run this code on the pull server, is this correct?</li> <li>where would the command <code>Enable-PSRemoting -Force</code> be executed? Since that comes before the configuration, I would assume that this will only be executed on the pull server, right?</li> </ul> <p>Thank you very much for helping me start my DSC journey!</p> <pre><code>$Configuration = @{ AllNodes = @( @{ NodeName = 'srv01' Role = 'WebServer' } @{ NodeName = 'srv02' Role = 'FileServer' } ) } Enable-PSRemoting -Force Configuration Test { Param() Import-DSCResource -ModuleName PSDesiredStateConfiguration node srv01 { WindowsFeature TestFeature { Ensure = "Present" Name = "Telnet-Client" } } node $AllNodes.where.{ $_.Role -eq "WebServer" }.NodeName { WindowsFeature IIS { Ensure = "Present" Name = "Web-Server" } } } Test -ConfigurationData $Configuration </code></pre> https://stackoverflow.com/q/56769116 0 List all users of AD B2C saperlipopette https://stackoverflow.com/users/7689896 2019-06-26T09:07:52Z 2019-06-26T18:44:33Z <p>I'm very new to AD B2C and I'm having trouble with the AD Graph API.</p> <p>My goal is to list all the users registered to my AD. I would like to perform this only by HTTP requests. </p> <p>So far, I found that I have to use this endpoint : </p> <pre><code>https://graph.windows.net/my_tenant.onmicrosoft.com/users?api-version=1.6 </code></pre> <p>My issue is that I cannot find where I can obtain the token used in the <code>Authorization</code> Header. </p> <p>For now, i'm authentificating via this URL : </p> <pre><code>https://my_tenant.b2clogin.com/my_tenant.onmicrosoft.com/oauth2/v2.0/authorize? client_id=27fb84fe-4baf-4b6b-bfe7-f2d0638f2790 &amp;response_type=code &amp;redirect_uri=http%3A%2F%2Flocalhost &amp;response_mode=query &amp;scope=27fb84fe-4baf-4b6b-bfe7-f2d0638f2790%20offline_access &amp;state=data &amp;p=B2C_1_SignUporSignIn </code></pre> <p>I obtain a code through my redirect_uri, and I send back this code to this endpoint to get a token : </p> <pre><code>https://my_tenant.b2clogin.com/my_tenant.onmicrosoft.com/oauth2/v2.0/token?p=b2c_1_signuporsignin </code></pre> <p>Following the docs here : <a href="https://docs.microsoft.com/fr-fr/azure/active-directory-b2c/active-directory-b2c-access-tokens" rel="nofollow noreferrer">https://docs.microsoft.com/fr-fr/azure/active-directory-b2c/active-directory-b2c-access-tokens</a>, I send these parameters :</p> <pre><code>grant_type:authorization_code client_secret:my_secret client_id:27fb84fe-4baf-4b6b-bfe7-f2d0638f2790 scope:openid code:code </code></pre> <p>The problem is that I don't get a response like the one shown in the docs. I only get an <code>id_token</code>, <code>token_type</code>, <code>not_before</code>, <code>id_token_expires_in</code>, <code>profile_info</code>. However, the <code>id_token</code> seems to correspond to the <code>access_token</code> in the docs.</p> <p>So the question is, is it this token which must be used in the Authorization header to send requests to the AD Graph API ?</p> <p>Because if I use this token, I get the following error : <code>Authentication_ExpiredToken</code> - Your access token has expired. Please renew it before submitting the request.</p> <p>Thanks in advance for your help</p> https://stackoverflow.com/q/56761431 -1 Import Excel / Array data to a database Thomas Bée https://stackoverflow.com/users/10387658 2019-06-25T20:17:47Z 2019-06-26T18:45:13Z <p>I'm writing a code in VB to have a company site with updated employee information. My goal was to: collect certain data from an Excel file Save the data into an 2D Array Update the array data into a database that is accessible by the website create the website and easly use the database data (so the site can easly be edited)</p> <p>i have run into two problems :</p> <ol> <li>i used a Try &amp; Catch to resolve a Nullreference Exception on blank cells - the script is very slow when reading cols with alot off blank cells</li> <li>I don't know how to correctly put the collected data into a database (sql accces / not important)</li> </ol> <p>Currently we use an Excel file with macro's &amp; Excel VB to generate the site (having output directly written to an html file - so it's very static..)</p> <p>Due to private employee information i cannot share the excel file, but i shared the code (i know, it's a bit sloppy since this is the first time i have worked with excel data, so i have done alot off 're-editing' my code)</p> <p>(at the end i added a listbox1 update to verify the last record is correctly added )</p> <p>If there are better solutions (direct import from excel to database) , please share :) </p> <p>Thanks to you all in advance!</p> <pre><code>Imports Excel = Microsoft.Office.Interop.Excel Public Class WieiswieForm Private Sub WieiswieForm_Load(sender As Object, e As EventArgs) Handles MyBase.Load End Sub Public Sub ChoseFile_Click(sender As Object, e As EventArgs) Handles ChoseFile.Click OpenFileDialog1.Filter = "Excel | *.xlsm" Dim result As DialogResult = OpenFileDialog1.ShowDialog() FileTextBox.Text = OpenFileDialog1.FileName UpdateButton.Enabled = True End Sub Public Sub UpdateButton_Click(sender As Object, e As EventArgs) Handles UpdateButton.Click UpdateButton.Enabled = False ListBox1.Items.Add(DateAndTime.Now.ToString &amp; ": starten...") Dim Filepath As String = OpenFileDialog1.FileName Dim Afdeling_cell As String = "C" Dim Functie_cell As String = "D" Dim Naam_cell As String = "E" Dim Organistaie_cell As String = "N" Dim Badgenummer_cell As String = "R" Dim Draagbaar_cell As String = "Y" Dim VastNummer_cell As String = "X" Dim GSM_cell As String = "AB" Dim Werkrooster_cell As String = "AE" Dim Normtijd_cell As String = "AF" Dim Afwezigheid_cell As String = "AG" Dim Vestiging_cell As String = "AI" Dim Cell_index(11) As String Cell_index(0) = Naam_cell Cell_index(1) = Afdeling_cell Cell_index(2) = Functie_cell Cell_index(3) = Organistaie_cell Cell_index(4) = Vestiging_cell Cell_index(5) = Werkrooster_cell Cell_index(6) = VastNummer_cell Cell_index(7) = Draagbaar_cell Cell_index(8) = GSM_cell Cell_index(9) = Afwezigheid_cell Cell_index(10) = Badgenummer_cell Cell_index(11) = Normtijd_cell If Filepath = "" Then MsgBox("Geen bestand geselecteerd..") Else ListBox1.Items.Add(DateAndTime.Now.ToString &amp; ": Excel bestand openen...") Dim range As Excel.Range Dim file As System.IO.StreamWriter ' Get the Excel application object. Dim excel_app As New Excel.ApplicationClass() ' Make Excel visible (optional). excel_app.Visible = False ' Open the workbook read-only. Dim workbook As Excel.Workbook = excel_app.Workbooks.Open( Filename:=Filepath, ReadOnly:=True) ' Get the first worksheet. Dim sheet As Excel.Worksheet = DirectCast(workbook.Sheets(1), Excel.Worksheet) ' Get the number of rows (to avoid an index out-of-range) Dim LastRow As Integer LastRow = sheet.UsedRange.Rows.Count '################## SUB START 'Create the data array ListBox1.Items.Add(DateAndTime.Now.ToString &amp; ": data verzamel object maken...") Dim DataArray(11, LastRow - 1) As String 'Create the object to retrieve the data from the range Dim saRet(,) As Object Dim iRows As Long Dim iCols As Long ' ######################################################################################### ' Start the data colletion loop Dim arrayindex1 As Integer = 0 Dim arrayindex2 As Integer = 0 Dim c As Integer = 0 ProgressBar1.Value = 10 'Namen oplijsten : ListBox1.Items.Add(DateAndTime.Now.ToString &amp; ": namen ophalen...") MaakArray(arrayindex1, arrayindex2, c, sheet, LastRow, range, saRet, iRows, iCols, Cell_index, DataArray) 'Afdeling ophalen ListBox1.Items.Add(DateAndTime.Now.ToString &amp; ": afdelingen ophalen...") ProgressBar1.Value = 20 c = c + 1 '1 arrayindex1 = arrayindex1 + 1 arrayindex2 = 0 MaakArray(arrayindex1, arrayindex2, c, sheet, LastRow, range, saRet, iRows, iCols, Cell_index, DataArray) 'Functie binnen de afdeling : ListBox1.Items.Add(DateAndTime.Now.ToString &amp; ": functies ophalen...") ProgressBar1.Value = 30 c = c + 1 '2 arrayindex1 = arrayindex1 + 1 arrayindex2 = 0 MaakArray(arrayindex1, arrayindex2, c, sheet, LastRow, range, saRet, iRows, iCols, Cell_index, DataArray) 'Organisatie ophalen ListBox1.Items.Add(DateAndTime.Now.ToString &amp; ": organisaties ophalen...") ProgressBar1.Value = 40 c = c + 1 '3 arrayindex1 = arrayindex1 + 1 arrayindex2 = 0 MaakArray(arrayindex1, arrayindex2, c, sheet, LastRow, range, saRet, iRows, iCols, Cell_index, DataArray) 'Vestiging ophalen ListBox1.Items.Add(DateAndTime.Now.ToString &amp; ": vestigingen ophalen...") ProgressBar1.Value = 50 c = c + 1 '4 arrayindex1 = arrayindex1 + 1 arrayindex2 = 0 MaakArray(arrayindex1, arrayindex2, c, sheet, LastRow, range, saRet, iRows, iCols, Cell_index, DataArray) 'werkrooster ophalen ListBox1.Items.Add(DateAndTime.Now.ToString &amp; ": werkroosters ophalen...") ProgressBar1.Value = 60 c = c + 1 '5 arrayindex1 = arrayindex1 + 1 arrayindex2 = 0 MaakArray(arrayindex1, arrayindex2, c, sheet, LastRow, range, saRet, iRows, iCols, Cell_index, DataArray) 'vastnummer ophalen ListBox1.Items.Add(DateAndTime.Now.ToString &amp; ": vaste telefoonnummers ophalen...") ProgressBar1.Value = 70 c = c + 1 '6 arrayindex1 = arrayindex1 + 1 arrayindex2 = 0 MaakArray(arrayindex1, arrayindex2, c, sheet, LastRow, range, saRet, iRows, iCols, Cell_index, DataArray) 'draagpaar ophalen ListBox1.Items.Add(DateAndTime.Now.ToString &amp; ": draagbarenummers ophalen...") ProgressBar1.Value = 75 c = c + 1 '7 arrayindex1 = arrayindex1 + 1 arrayindex2 = 0 MaakArray(arrayindex1, arrayindex2, c, sheet, LastRow, range, saRet, iRows, iCols, Cell_index, DataArray) 'GSM ophalen ListBox1.Items.Add(DateAndTime.Now.ToString &amp; ": GSM nummers ophalen...") ProgressBar1.Value = 80 c = c + 1 '8 arrayindex1 = arrayindex1 + 1 arrayindex2 = 0 MaakArray(arrayindex1, arrayindex2, c, sheet, LastRow, range, saRet, iRows, iCols, Cell_index, DataArray) 'Afwezigheden ophalen ListBox1.Items.Add(DateAndTime.Now.ToString &amp; ": Afwezigheden nummer ophalen...") ProgressBar1.Value = 85 c = c + 1 '9 arrayindex1 = arrayindex1 + 1 arrayindex2 = 0 MaakArray(arrayindex1, arrayindex2, c, sheet, LastRow, range, saRet, iRows, iCols, Cell_index, DataArray) 'Badgenummers ophalen ListBox1.Items.Add(DateAndTime.Now.ToString &amp; ": badgenummers ophalen...") ProgressBar1.Value = 90 c = c + 1 '10 arrayindex1 = arrayindex1 + 1 arrayindex2 = 0 MaakArray(arrayindex1, arrayindex2, c, sheet, LastRow, range, saRet, iRows, iCols, Cell_index, DataArray) 'Normtijd ophalen ListBox1.Items.Add(DateAndTime.Now.ToString &amp; ": Normtijd ophalen...") ProgressBar1.Value = 95 c = c + 1 '10 arrayindex1 = arrayindex1 + 1 arrayindex2 = 0 MaakArray(arrayindex1, arrayindex2, c, sheet, LastRow, range, saRet, iRows, iCols, Cell_index, DataArray) ' Save the changes and close the workbook. workbook.Close(SaveChanges:=False) ' Close the Excel server. excel_app.Quit() ProgressBar1.Value = 100 ListBox1.Items.Add(DateAndTime.Now.ToString &amp; ": Bestand opgeladen!") ListBox1.Items.Add(DataArray(0, 501) &amp; " " &amp; DataArray(1, 501) &amp; " " &amp; DataArray(2, 501) &amp; " " &amp; DataArray(3, 501) &amp; DataArray(4, 501) &amp; DataArray(5, 501) &amp; DataArray(6, 501) &amp; DataArray(7, 501) &amp; DataArray(8, 501)) UpdateButton.Enabled = True MsgBox((DataArray(0, 501) &amp; " " &amp; DataArray(1, 501) &amp; " " &amp; DataArray(2, 501) &amp; " " &amp; DataArray(3, 501) &amp; " " &amp; DataArray(4, 501) &amp; " " &amp; DataArray(5, 501) &amp; " " &amp; DataArray(6, 501) &amp; " " &amp; DataArray(7, 501) &amp; " " &amp; DataArray(8, 501) &amp; " " &amp; DataArray(9, 501) &amp; " " &amp; DataArray(10, 501))) End If End Sub Sub MaakArray(arrayindex1 As Integer, arrayindex2 As Integer, c As Integer, sheet As Excel.Worksheet, LastRow As Integer, range As Excel.Range, saret As Object, iRows As Long, iCols As Long, Cell_index() As String, ByRef DataArray(,) As String) Dim LoopTime As Integer = 0 Do Until LoopTime = 11 'Get a range of data. range = sheet.Range(Cell_index(c) &amp; "2", Cell_index(c) &amp; LastRow) 'Retrieve the data from the range. saret = range.Value 'Determine the dimensions of the array. iRows = saret.GetUpperBound(0) iCols = saret.GetUpperBound(1) 'Build a string that contains the data of the array. Dim valueString As String 'valueString = "" + vbCrLf Dim rowCounter As Long Dim colCounter As Long Dim i As Integer For rowCounter = 1 To iRows For colCounter = 1 To iCols 'Write the next value into the string. Try valueString = saret(rowCounter, colCounter).ToString() 'If String.IsNullOrEmpty(valueString) Then 'valueString = "" ' End If Catch valueString = "" End Try DataArray(arrayindex1, arrayindex2) = valueString If arrayindex2 = LastRow - 1 Then arrayindex2 = arrayindex2 Else arrayindex2 = arrayindex2 + 1 End If ProgressBar1.Value = ProgressBar1.Value + 1 / 10 Next colCounter Next rowCounter LoopTime = LoopTime + 1 Loop '######################################################################### End Sub End Class </code></pre> https://stackoverflow.com/q/56740029 0 Reverse for 'ratio' with arguments '('',)' and keyword arguments '{}' not found shimmy4 https://stackoverflow.com/users/11676914 2019-06-24T15:46:20Z 2019-06-26T18:45:06Z <p>Caught an exception while trying to render:</p> <pre><code>django.urls.exceptions.NoReverseMatch: Reverse for 'ratio' with arguments '('',)' not found. 1 pattern(s) tried: ['dashboards/ratio'] </code></pre> <p>Here is the views.py:</p> <pre><code>def ratio(request, ticker1, ticker2): tickers_values = TSDB.objects.filter(TICKER__in = [ticker1, ticker2]).values("DATE", "TICKER", "CLOSE") tickers_list = [] for ticker in tickers_values: tickers_list.append([ticker['DATE'], ticker['TICKER'], ticker['CLOSE']]) df = pd.DataFrame(tickers_list, columns = ['DATE', 'TICKER', 'CLOSE']) df = df.pivot_table(values = 'CLOSE', index = 'DATE', columns = 'TICKER') print(df) json_list = [] df['RATIO'] = df[ticker1]/df[ticker2] for i in df[['RATIO']].itertuples(): json_list.append([totimestamp(i[0])*1000, i[1]]) return JsonResponse(json_list, safe = False) </code></pre> <p>I don't have the slightest clue of where this error is coming from. I'm going to assume that it is what I am passing in $.getJSON(). (I am new to django and I am trying to create a data plot using Highcharts.)</p> https://stackoverflow.com/q/56726661 1 firebase react-native: convert anonymous user to a permanent user via phone auth b_a_n_a_n_a https://stackoverflow.com/users/2950788 2019-06-23T18:18:20Z 2019-06-26T18:44:43Z <p>My react-native application allows users to sign in anonymously using firebase. After that I am hoping to allow user to create an account via firebase phone auth and convert this anonymous account into a permanent account. </p> <p>I think this is possible based on the api &amp; documentation provided by firebase </p> <p>anonymous account creation: <a href="https://rnfirebase.io/docs/v5.x.x/auth/reference/auth#signInAnonymously" rel="nofollow noreferrer">https://rnfirebase.io/docs/v5.x.x/auth/reference/auth#signInAnonymously</a></p> <p>phone auth creation &amp; retrieve credential: <a href="https://rnfirebase.io/docs/v5.x.x/auth/reference/PhoneAuthProvider#credential" rel="nofollow noreferrer">https://rnfirebase.io/docs/v5.x.x/auth/reference/PhoneAuthProvider#credential</a></p> <p>Linking an existing user with a new credential: <a href="https://rnfirebase.io/docs/v5.x.x/auth/reference/User#linkWithCredential" rel="nofollow noreferrer">https://rnfirebase.io/docs/v5.x.x/auth/reference/User#linkWithCredential</a></p> <p><a href="https://firebase.google.com/docs/auth/web/account-linking" rel="nofollow noreferrer">https://firebase.google.com/docs/auth/web/account-linking</a></p> <p>Here's what I did</p> <p>anonymous account creation:</p> <pre><code>const {user: {uid: userID}} = await firebase.auth().signInAnonymously(); // successfully created and save this user's id </code></pre> <p>get the users to authenticate and get the phone auth credential: </p> <pre><code>const credential = firebase.auth.PhoneAuthProvider.credential(verificationId, code); </code></pre> <p>at this point I would have a valid credential &amp; an existing anonymous user ready for linking</p> <p>I then provide the phone auth credential to my anonymous user for linking</p> <pre><code>const authUser = await firebaseAuth.currentUser.linkWithCredential(credential); </code></pre> <p>I expected a successful linking to happen based on my inputs, but I'm getting errors instead, the error I'm getting is </p> <pre><code>Error: This credential is already associated with a different user account. </code></pre> <p>Error code is: <code>ERROR_CREDENTIAL_ALREADY_IN_USE</code></p> <p>in the documentation under <code>ERROR_CREDENTIAL_ALREADY_IN_USE</code>, they did mention: </p> <p>this error could be thrown if you are upgrading an anonymous user to a Google user by linking a Google credential to it and the Google credential used is already associated with an existing Firebase Google user.The fields error.email, error.phoneNumber, and error.credential (AuthCredential) may be provided, depending on the type of credential. You can recover from this error by signing in with error.credential directly via auth#signInWithCredential.</p> <p>But I have not been able to find error.credential under the error object to come back from the error.</p> <p>I have seen many working example of linking anonymous user with other auth providers, but never seen the linking of a firebase anonymous user with a firebase phone auth crendential. Does anyone know if this type of linking is supported? Could anyone point out what I'm doing wrong here?</p> https://stackoverflow.com/q/56709277 0 How to create HTML tags (with content) on the fly with JavaScript? FlightHoldings https://stackoverflow.com/users/11546401 2019-06-21T19:17:40Z 2019-06-26T18:44:37Z <p>I am trying to convert this HTML code to be generated by Javascript on the fly for live data.</p> <pre><code>&lt;div class="dropdown"&gt; &lt;button class="dropbtn"&gt;Dropdown&lt;/button&gt; &lt;div class="dropdown-content"&gt; &lt;a href="#"&gt;Link 1&lt;/a&gt; &lt;a href="#"&gt;Link 2&lt;/a&gt; &lt;a href="#"&gt;Link 3&lt;/a&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>Ive found a few methods like: appendChild, getElementById, innerHTML and so on. Here is what I've tried so far. I can't seem to get the data to show up.</p> <pre><code> stringy = data2.Items[0].groupName.values[i]; var para = document.createElement("div"); var node = document.createTextNode(stringy); para.appendChild(node); var element = document.getElementById("parental"); element.appendChild(para); //create div and give it a class para.setAttribute('class', 'dropbtn'); var div = document.createElement("div"); div.setAttribute('class', 'dropdown-content'); para.parentNode.insertBefore(div, para.nextSibling); //create link tags and give them text var alinky = document.createElement("a"); alinky.setAttribute('id', 'linky'); document.getElementById('linky').innerHTML = "linky poo" div.appendChild(alinky); </code></pre> <p>Hopefully someone could fill in the blanks on getting this HTML code to be reproduced with javascript. Thanks in advance!</p> <p>EDIT:</p> <p>I am trying to create a dropdown menu like this: <a href="https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_js_dropdown_hover" rel="nofollow noreferrer">https://www.w3schools.com/howto/tryit.asp?filename=tryhow_css_js_dropdown_hover</a></p> <p>However, I am trying to create multiple dropdown menus, that dynamically change in quantity based on a query to DynamoDB (AWS). therefore I am using javascript to create the html tags.</p> <p>The problem is that the scope of the query function does not allow me to see the data outside of the query function, or even inject data into it.</p> <p>For example, if I try to get a button description from the query, and write to it <code>descriptionArray[0] = data2.Items[0].description;</code> so that I can append the button to the dropdown div, it doesn't know which iteration I'm on in the for loop due to scope. In this example, <code>descriptionArray[0]</code> will work, but <code>descriptionArray[i]</code> will not work because the for loop is outside the query.</p> <p>Here is the entire logic:</p> <pre><code> //group data var length = data2.Items[0].groupName.values.length; // create elements const dpdown1 = document.createElement('div'); // set dpdown1 class dpdown1.setAttribute('class', 'dropdown'); console.log(dpdown1); var button = new Array(); var dpdown2 = new Array(); var membersArray = new Array(); var descriptionArray = new Array(); var linksArray = new Array(); var stringy = new Array; //list groups for(i = 0; i&lt;length; i++){ // create button, set button attribs button[i] = document.createElement('button'); button[i].setAttribute('class','dropbtn'); //create dropdown div, set attributes dpdown2[i] = document.createElement('div'); dpdown2[i].setAttribute('class', 'dropdown-content'); //list of group names stringy[i] = data2.Items[0].groupName.values[i]; var stringyy = stringy[i]; var desc; //query group members and description var docClient1 = new AWS.DynamoDB.DocumentClient({ region: AWS.config.region }); var identityId = AWS.config.credentials.identityId; var paramsyy = { ExpressionAttributeValues: { ":v1": stringyy }, KeyConditionExpression: "groupName = :v1", TableName: "group" }; docClient1.query(paramsyy, function(err, data2) { if (err) { console.error(err); }else{ descriptionArray[0] = data2.Items[0].description; //traverse members for(k = 0; k&lt;data2.Items[0].members.values.length; k++){ // create dropdown links of members membersArray[k] = data2.Items[0].members.values[k]; linksArray[k] = document.createElement('a'); linksArray[k].setAttribute('href', '#') linksArray[k].innerText = membersArray[k]; // nest into dpdown2 div, set dpdown2 attribs dpdown2[0].appendChild(linksArray[k]); } } }); button[i].innerText = stringyy + ": " + descriptionArray[0]; // nest into dpdown1 dpdown1.appendChild(button[i]); dpdown1.appendChild(dpdown2[i]); } // append to DOM const target = document.getElementById('target'); target.appendChild(dpdown1); </code></pre> <p>if I use the I from the first for loop inside the query function, it will give me undefined results.</p> https://stackoverflow.com/q/56670645 0 Wait for DevTools to load Matt Thomas https://stackoverflow.com/users/3063273 2019-06-19T14:55:39Z 2019-06-26T18:45:05Z <p>In CefSharp you can bring up the DevTools window with the <code>ShowDevTools()</code> extension method. I want to direct the embedded browser to load a page only after DevTools has been loaded (specifically, after it has attached its JavaScript debugger). However, <code>ShowDevTools()</code> seems to execute asynchronously.</p> <p>How can I detect when DevTools has finished loading?</p> https://stackoverflow.com/q/52587553 0 Calculation of maximum floating point error Joseph Arnold https://stackoverflow.com/users/6774392 2018-10-01T08:54:13Z 2019-06-26T18:45:06Z <p><code>pow(x,y)</code> is computed as <code>e^(y*log(x))</code> Generally math libraries compute <code>log(x)</code> in quad precision (which is time consuming) in order to avoid loss of precision when computing <code>y*log(x)</code> as precision errors will magnify in the computation of <code>e^(y*log(x))</code>. Now, in case I would want to compute <code>pow(x,y)</code> in the following steps.</p> <pre><code>double pow(double x,double y) { return exp(y*log(x)); // Without any quad precision multiplication } </code></pre> <p>What would be the maximum ULP error of this function. I do know that IEEE-754 standard says that any floating point operation should have less than 0.5 ULP error i.e <code>0.5*2^(-52)</code>. So if my operation <code>y*log(x)</code> suffers from a 0.5 ULP error, how do I compute the largest possible ULP error for <code>e^(y*log(x))</code></p> <hr> <p>Agreed that the computation of <code>pow(x,y)</code> is fairly complicated. Algorithms generally compute <code>log(x)</code> in a higher precision and the multiplication between <code>y</code> and <code>log(x)</code> is not straightforward. Since the ULP error depends on <code>y*log(x)</code>, the maximum error would be for the largest value of <code>Y*log(x)</code> for which <code>e^(y*log(x))</code> is not infinity. Right? How do I compute the number of ULP for such a case? What are the maximum number of bits of the mantissa in the double precision format that would vary form the actual value in case of the largest value of <code>y*log(x)</code> ? </p> <hr> <p>Updated the question. Thanks for all the help!</p> <p>So a 10 bit difference would result in how much ULP error? I calculated it as, </p> <pre><code> ULP = (actual - computed)/ 2^(e-(p-1)) </code></pre> <p>where e is the exponent of the actual number, p=53 for double precision. I read that I ULP = 2^(e-(p-1)) Let's assume,</p> <pre><code> Actual = 1.79282279439444787915898270592 *10^308 Computed = 1.79282279439451553814547593293 * 10^308 error= actual - computed = 6.7659e+294 </code></pre> <p>Now </p> <pre><code>1 ULP = 2^(e- (p-1)) e = 1023 (exponent of the actual number - bias) 1 ULP = 2^(1023 - (53-1)) = 2^971 ULP error = error/ 1 ULP = 339 </code></pre> <p>Is this correct?</p>