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
54,164,059
send email with python after specific time
I want to make python script send email with attachment (txt) every 30 minutes here is my code it send mail with attachment without any problem import smtplib from email.mime.text import MIMEText from email.mime.multipart import MIMEMultipart from email.mime.base import MIMEBase from email import encoders import os.path email = 'myaddress@gmail.com' password = 'password' send_to_email = 'sentoaddreess@gmail.com' subject = 'This is the subject' message = 'This is my message' file_location = 'C:\\Users\\You\\Desktop\\attach.txt' msg = MIMEMultipart() msg['From'] = email msg['To'] = send_to_email msg['Subject'] = subject msg.attach(MIMEText(message, 'plain')) filename = os.path.basename(file_location) attachment = open(file_location, "rb") part = MIMEBase('application', 'octet-stream') part.set_payload((attachment).read()) encoders.encode_base64(part) part.add_header('Content-Disposition', "attachment; filename= %s" % filename) msg.attach(part) server = smtplib.SMTP('smtp.gmail.com', 587) server.starttls() server.login(email, password) text = msg.as_string() server.sendmail(email, send_to_email, text) server.quit() thanks
<python><email>
2019-01-12 21:32:29
LQ_EDIT
54,164,304
What if I use 1 million IPv6 addresses per second then how long would it take to exhaust all the addresses?
<p>if I use 1 million IPv6 addresses per second then how long would it take to exhaust all the addresses. Explain </p>
<networking><ipv6>
2019-01-12 22:07:29
LQ_CLOSE
54,166,660
I am having an issue displaying Clip-Path on iphone chrome/safari browser
<p>I have created a test project at <a href="http://secretchickens.com/" rel="nofollow noreferrer">http://secretchickens.com/</a> using clip-paths to adjust the background. It works great on computer browsers, but on my iPhone with chrome/safari I can't see the clip-path. Do I need to do anything to make this work?</p>
<css><clip-path>
2019-01-13 06:42:41
LQ_CLOSE
54,167,349
How i can take JavaScript value inside php
<p>I have created a javascript function. And the work of that function is to store the value which is selected by the user. Now I want to do that if the user selects the value then that value should be searched inside the database.</p> <pre><code>&lt;script&gt; function test(){ var a=$("#to_artist").val(); var aakash="&lt;option&gt;Select If you want to change&lt;/option&gt;&lt;?php define('DB_HOST','localhost'); define('DB_USERNAME','username'); define('DB_PASSWORD','password'); define('DB_NAME','dbname'); //echo '&lt;script&gt; $("#to_artist").val(); &lt;/script&gt;'; $con = mysqli_connect(DB_HOST,DB_USERNAME,DB_PASSWORD,DB_NAME) or die("Unable to connect"); $sql = mysqli_query($con, "SELECT * FROM album;"); $row2 = mysqli_num_rows($sql2); ?&gt;"; aakash+="&lt;?php while ($row2 = mysqli_fetch_array($sql)){echo "&lt;option value='". $row2['album_name'] ."'&gt;" .$row2['album_name'] ."&lt;/option&gt;" ;} ?&gt;" ; $("#to_album").append(aakash); } &lt;/script&gt; </code></pre> <p>I want to use <code>Select * from album where artist=a</code> this query inside PHP but i don't know how i can use this can any one help me.</p>
<javascript><php>
2019-01-13 08:55:59
LQ_CLOSE
54,167,547
MySQL - Products names where name contains specific words
<p>I have a MySQL table <code>products(id, name, sku)</code> and I have an array of strings: <code>$words = ['1' =&gt; 'Carlsberg', '2' =&gt; 'Premium', '3' =&gt; '250ml'];</code></p> <p>How to get from database names of products where product name includes one, two or all words of $words array?</p> <p>I need some help with writing a sql query to get these products from the database</p>
<php><mysql>
2019-01-13 09:27:05
LQ_CLOSE
54,167,571
Mysqli result while loop returns null
<p>This code used to work last time i checked then i made some changes (but didn't change the core actions) and now it doesn't and i can't understand why, is there something i'm missing?</p> <pre><code>require("./dbAccess.php"); mysqli_set_charset($dbConnection, 'utf8mb4'); if($query = mysqli_query($dbConnection, "SELECT * FROM table")){ mysqli_close($dbConnection); while($row = mysqli_fetch_assoc($query)); { var_dump($row); } } else {echo (mysqli_error($dbConnection)); mysqli_close($dbConnection);} </code></pre> <p>The table has 2 rows, mysqli_num_rows confirms it and if i var_dump without the loop i correctly get the first row but as soon as it goes through the loop the var_dump results null.</p> <p>Thanks</p>
<php><arrays><mysqli><while-loop>
2019-01-13 09:29:42
LQ_CLOSE
54,168,187
How to re-factor this snippet?
I've just started working on ruby.. I've a function like below. I'm just wondering if there is a nice way to rewrite this piece. I did google and went through few documents, would like to know what would be the best thing to do there. I don't want this to be counted as so many lines of code increasing the complexity of my function. def test { testId: self.test_id, testTime: self.test_time, testType: self.test_type, city: self.city ......... many such variables } end
<ruby>
2019-01-13 10:59:33
LQ_EDIT
54,168,590
Parse error: syntax error, unexpected end of file in C:\Users\p\Desktop\xampp\htdocs\myproject\login.php on line 55
<p>Parse error: syntax error, unexpected end of file in C:\Users\p\Desktop\xampp\htdocs\myproject\login.php on line 55</p> <p>So I dont know what is causing this problem I have only started to learn Php and Html. Can anyone help fix this.</p> <p>Here is the code.</p> <p>Line 55 is at the bottom. <pre><code>if(isset($_POST['submit'])) { $username = $_POST['username']; $password = $_POST['password']; $connection = mysqli_connect('localhost', 'root', 'root', 'loginapp'); if($connection) { echo "We are connected"; } else { } die("Database connection failed"); ?&gt; &lt;!DOCTYPE html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;meta charset="UTF-8"&gt; &lt;title&gt;Document&lt;/title&gt; &lt;link rel="stylesheet" href="https://maxcdn.bootstrapcdn.com/bootstrap/3.3.2/css/bootstrap.min.css"&gt; &lt;/head&gt; &lt;body&gt; &lt;div class="container"&gt; &lt;div class="col-sm-6"&gt; &lt;form action="login.php" method="post"&gt; &lt;div class="form-group"&gt;&lt;/div&gt; &lt;label for="username"&gt;Username&lt;/label&gt; &lt;input type="text" name="username" class="form-control"&gt; &lt;div class="form-group"&gt; &lt;label for="password"&gt;Password&lt;/label&gt; &lt;input type="password" name="password" class="form-control"&gt; &lt;input class="btn btn-primary" type="submit" name="submit" value="Submit"&gt; &lt;/div&gt; &lt;/form&gt; &lt;/div&gt; &lt;/div&gt; &lt;/body&gt; &lt;/html&gt; </code></pre>
<php>
2019-01-13 11:51:55
LQ_CLOSE
54,168,835
i am trying to add new elementes to my arraylist but it shows er*or
I am trying to add a new element into my arraylist but it shows er*or and I do not know why. I have tried to change it but the error does not go away. I cannot think of saomething else.Plese help me if you want to fix it. this is my code: //main class import java.util.ArrayList; public class Ticket { static ArrayList<T> arrayticket = new ArrayList <T>(); //T for Ticket( Generic Type) public static void main(String[] args) { BuyTicket ticket1 = new BuyTicket(); ticket1.BuyaTicket(); } class T { // instance variables private String type; private int RoutesOrDays; private String kind; private String name; private String email; private int TicketCode; private String ExpirationDate; //constructor public T(String type, int RoutesOrDays, String kind, String name, String email, int TicketCode, String ExpirationDate) { this.type = type; this.RoutesOrDays = RoutesOrDays; this.kind = kind; name = " "; email = " "; TicketCode = 0; ExpirationDate = " "; } //++setters aand getters } public class BuyTicket extends MyInterface { //METHOD int BuyaTicket() { Save save_dataA = new Save(); save_dataA.Person3(type, hostOfRoutes, kind); } } public class SaveData extends T { private String name; private String email; private int code; static AtomicInteger codeSequence = new AtomicInteger(); //Creates a new AtomicInteger with initial value 0 //contructor public SaveData(String name, String email, int code ) { name =" "; email =" "; this.code = codeSequence.incrementAndGet(); //Atomically increments by one the current value. } //contructor of super public SaveData(String type, int RoutesOrDays, String kind, String name, String email, int TicketCode, String ExpirationDate) { super(type, RoutesOrDays, kind, name, email, TicketCode, ExpirationDate); } void Person3(String type, int RoutesOrDays, String kind){ System.out.println("Type your full name."); String name = input.nextLine(); System.out.println("Please type your email. "); String email = input.nextLine(); code = codeSequence.incrementAndGet(); arrayticket.add(new T(type, RoutesOrDays, kind, code,email, name)); //here is the er*or } I am very new to java so what can I change in order to fix it???
<java><arraylist>
2019-01-13 12:24:41
LQ_EDIT
54,168,882
How Can I Short Array Elements by Their Property
<p>I want to short array elements by their property. As a output I don't want to take string value. I just want int values.</p> <pre><code>Example: var array = [1,2,3,4,5,'chicken']; Output: 1,2,3,4,5 </code></pre>
<javascript><arrays>
2019-01-13 12:30:55
LQ_CLOSE
54,169,783
how can i defined meta tags for related post thumbnails in tumblr?
<p>I am using shareaholic but problem is that all related post thumbnails are picking profile picture image instead of post images. Now all thumbnail images are showing same image i want different image for every thumbnail. How can i defined meta tags in head section of my tumblr theme? I tried some but i'm not successful because I have little knowledge of html and meta tags. </p>
<html><tumblr><meta-tags>
2019-01-13 14:21:17
LQ_CLOSE
54,169,814
Jquery clear form after submission success
<p>Let's say we have a code like this:</p> <pre><code>&lt;script type="text/javascript"&gt; $(document).ready(function() { $("#signup").click(function(e) { e.preventDefault(); var email = $("#email").val(); var fname = $("#fname").val(); $.post("signup.php", {email:email, fname:fname}, function(data) { $("#result").html(data); }); return false; }); }); &lt;/script&gt; </code></pre> <p>After clicking the submit button, we can get an error message if the fields are not properly filled, in that case, the form can still retain the values, but if "submission successful" message was returned, how do I conditionally reset the form fields</p>
<javascript><jquery><forms>
2019-01-13 14:25:41
LQ_CLOSE
54,171,138
Python array program not giving correct output
<p>I am using below code for adding an element in array but it is giving me below error while running it</p> <pre><code>cars = ["Ford", "Volvo", "BMW"] cars.append("Honda") cars[4] = "BMWq"; for x in cars: print(x) Output error </code></pre> <p>List assignment index out of range</p> <p>Not able to understand reason of this error</p>
<python><arrays>
2019-01-13 17:00:25
LQ_CLOSE
54,171,434
If is still returning bad array
<p>I am working on script, which have to remove temp. mail users, but if() is still activating array_push</p> <p>I am using newest xampp on windows, php 7. I have tryed this if() with smaller amount of <code>||something..</code> and changing</p> <pre><code>if($emdomain == "google.com" || "gmail.com") { array_push("google domain"); } else { array_push("not google domain"); } </code></pre> <p>to</p> <pre><code>if($emdomain != "google.com" || "gmail.com") { array_push("not google domain"); } else { array_push("google domain"); } </code></pre> <p>But not working..</p> <pre><code>if($emdomain == "google.com" || "gmail.com") { array_push("google domain"); } else { array_push("not google domain"); } </code></pre> <p>I am getting "google domain" everytime, so i can use yahoo.com, alzashop.com, anything, and i get "google domain" Idk why</p>
<php>
2019-01-13 17:34:44
LQ_CLOSE
54,172,215
How to get text between data and comma in a string? Python 3
I am parsing text from a website, where I got string: "Some Event 21.08.2019—31.08.2019 Standart (1+1) , Some text" or something same. I need to get text beetween last data and comma, here is "Standart (1+1)" slice. How to do that? I use Python 3 str1 = "Some Event 21.08.2019—31.08.2019 Standart (1+1) , Some text" Answer: str2 = "Standart (1+1)"
<python><python-3.x><string><indexing>
2019-01-13 19:03:54
LQ_EDIT
54,172,366
Picking data storage type in AWS
<p>What would you choose for data storage, S3 or EBS, provided no code change should be made in the existing on premise application?</p>
<amazon-web-services>
2019-01-13 19:21:57
LQ_CLOSE
54,173,806
'How to define 'p' with ROOT' using Python and Flask
I am trying to launch a full stack web application using Python and Flask and inside my server interface/top layer file the ROOT line with 'p' is saying that it is not defined. Is there another set of variables I can assign to it in the same file to solve the problem when attempting to launch in terminal? I have already tried launching with different versions of Python in terminal and assigning p to path in the code but then it says user isn't defined. import sqlite3 as sql from os import path ROOT = path.dirname(p/Users/matthewdeyn/Coffea/app.pyath.relpath((__file__))) def create_post(name, content): con = sql.connect(path.join(ROOT, 'database.db')) cur = con.cursor() cur.execute('insert into posts (name, content) values(?, ?)', (name, content)) con.commit() con.close() def get_posts(): con = sql.connect(path.join(ROOT, 'database.db')) cur = con.cursor() cur.execute('select * from posts') posts = cur.fetchall() return posts Expected results are that the app.py file will load in terminal and I will know where to find it in the browser.
<python><flask>
2019-01-13 22:27:58
LQ_EDIT
54,177,359
How to become the page responsive?
I want to make this website mobile responsive. But when I add image with the text it breaks its size. I am trying to keep the image and text side by side. I can't understand what should be the width and height. <div class="row"> <div class="col-md-6"> <div class="box2"> <img src="image/p1.jpg" width="160" height="140" align="left" > <h3>PETER L.MARUZ </h3> <p> Lorem Ipsum is simply dummy text of the printing and typesetting industry.Lorem Ipsum has been the industry's standard dummy text ever since the 1500s </p> <img src="image/f.jpg" width="35" height="30" > <img src="image/twitter-bird-white-on-blue.jpg" width="35" height="30" > </div> </div> [enter image description here][1] [1]: https://i.stack.imgur.com/zNqUZ.png
<html><css>
2019-01-14 07:38:00
LQ_EDIT
54,178,938
To show admob banner and interstitial ads we need play Console account?
I'm created my application in android studio and attach banner and interstitial ads with Test id after successfully build my app i use my admob ad unit id of banner and interstitial but 10 days go already and my ads not displaying. 1. Do we need a play Console account compulsory to display ads ? 2. i have 1 image and one button in my layout , how many content we need to have display ads in my app ? because i see many videos on YouTube they say we need content in your apps. 3. My friend have a Play Console account i use there (keystore) .jsk file to signed my application after signed apps start displaying ads also i use "Apk Editor Pro" to sign apk its start displaying ads . how ? Please help me out to fix this. thanks in Advance.
<android><admob><adsense>
2019-01-14 09:43:14
LQ_EDIT
54,179,316
Mysql like query search
I am working on crud functionality in php and mysql for user table.I have keep user status "a" and "d" for "active" and "deactive" respectivaly in database .My problem is when user search on frontend lets say "active" then how I can query to fetch all active status record.Please help..
<php><mysql><sql>
2019-01-14 10:07:02
LQ_EDIT
54,181,175
how to change the content of two tabs container by using one tab using bootstrap 4.x?
I'm trying to create two tabs containers one of them are used to describe the content of a set of files and the second are used as a list of download links for the described files. now what I did is try to control the two containers using one tab only, I saw a solution used {data-trigger} with two ID's like data-trigger="#TabA1, #TabB1" but it seems this option is not working with bootstrap 4.x, so is there any solution or workaround to solve this issue. anyway here is my code, if anyone can help me in this. <div class="row"> <div class="col-sm-8"> <div class="card text-center "> <div class="card-header"> <ul class="nav nav-tabs card-header-tabs"> <li class="nav-item"> <a class="nav-link active" href="#TabA1" data-trigger="#A1, #B1" data-toggle="tab" role="tab" aria-selected="true">A1/B1</a> </li> <li class="nav-item"> <a class="nav-link" href="#TabA2" data-trigger="#A2, #B2" data-toggle="tab" role="tab" aria-selected="false">A2/B2</a> </li> <li class="nav-item"> <a class="nav-link" href="#TabA3" data-trigger="#A3, #B3" data-toggle="tab" role="tab" aria-selected="false">A3/B3</a> </li> <li class="nav-item"> <a class="nav-link" href="#TabA4" data-trigger="#A4, #B4" data-toggle="tab" role="tab" aria-selected="false">A4/B4</a> </li> </ul> </div> <div class="card-body" style="text-align: left; overflow-y: scroll; max-height: 600px;"> <div class="tab-content" id="myTabContent_A"> <div class="tab-pane fade show active" id="TabA1" role="tabpanel"> A1 </div> <div class="tab-pane fade" id="TabA2" role="tabpanel"> A2 </div> <div class="tab-pane fade" id="TabA3" role="tabpanel"> A3 </div> <div class="tab-pane fade" id="TabA4" role="tabpanel"> A4 </div> </div> </div> </div> </div> <div class="col-sm-4"> <div class="card"> <h5 class="card-header">Files</h5> <div class="card-body"> <h5 class="card-title"></h5> <div class="tab-content" id="myTabContent_B"> <div class="tab-pane fade show active" id="TabB1" role="tabpanel"> B1 </div> <div class="tab-pane fade" id="TabB2" role="tabpanel"> B2 </div> <div class="tab-pane fade" id="TabB3" role="tabpanel"> B3 </div> <div class="tab-pane fade" id="TabB4" role="tabpanel"> B4 </div> </div> </div> </div> </div> </div> with the mentioned HTML code only I can see changes happened to the first tabs container. but I expected to see the changes happened in both of the containers A and B.
<javascript><jquery><twitter-bootstrap><bootstrap-4>
2019-01-14 12:02:20
LQ_EDIT
54,181,338
Android Studio: Asset File is not being read correctly by InputStream/Reader
I want to build my own password generator. Therefore I created files containing all symbols, which are currently lying in the manually created folder "assets". I also created a method, that shall return a single files content as a string array. The method already seems to recognize the given files because it catches no "FileNotFoundException" and it gets the file's amount of lines correctly. Now my problem is, that the Array returned does not contain the file's content but just an amount of "null"s, corresponding to the file's amount of lines. I hope that information will do. Can anyone help me? I already tried using different Charsets and moving the files to the folder "/res/raw/". public String[] getList(String filename) { String[] zeichenliste = new String[0]; try { InputStream is = getAssets().open(filename); BufferedReader br = new BufferedReader (new InputStreamReader(is)); int length = 0; while (br.readLine() != null) length++; zeichenliste = new String[length]; br = new BufferedReader (new InputStreamReader(is)); for (int i = 0; i < length; i++) zeichenliste[i] = br.readLine(); br.close(); is.close(); } catch (IOException e) { e.printStackTrace(); return(null); } return zeichenliste; }
<java><android><android-studio>
2019-01-14 12:12:00
LQ_EDIT
54,181,449
Angular 6 - why is my component property (and thus console.log() value) still undefined after my API call method?
export class CaseStudyDetailComponent implements OnInit { casestudy: CaseStudy; constructor ( private caseStudyService: CaseStudyService, private route: ActivatedRoute, public titleService: Title ) { } ngOnInit() { this.route.params.subscribe((params: { Handle: string }) => { this.caseStudyService.getCaseStudy(params.Handle).subscribe(casestudy => this.casestudy = casestudy); }); console.log(this.casestudy); } }
<angular6>
2019-01-14 12:18:08
LQ_EDIT
54,182,268
error syntax error: operand expected (error token is ""0"") on my code
i have a question about bash script. this is my code but i have an error when running it.please tell me what is problem and how i can fix it? #!/bin/bash clear old_IFS=$IFS IFS=$'\n' lines={$(cat dic.txt)} IFS=$old_IFS linesNum=${#lines[@]} i=0 while [ $i -lt $linesNum ] do curl --silent --data '__VIEWSTATE=/wEPDwUKMjA2NTYzNTQ5MmRkM9W6oZR3v6vTlgum6RRE+XBA1YwwnX5efXI7H3VYGhb90nffjJgTX9BC2vcXTKn5JQP7gGZqRX5i6+UBKQJYpA==&__VIEWSTATEGENERATOR=6A475423&__EVENTVALIDATION=/wEdAAaQshnEBVjtUzZSOPhpyCK04ALG8S7ZiLlJqSsuXBsjGz/LlbfviBrHuco87ksZgLcCRt9NnSPADSFObzNVq3ShPZSQos3ErAwfDmhlNwH4qEsT6FfmV7ULQ7j/FGM5sO744qbWJoRwx8DdO7AyAGSCIHJNCxliL9wbeJx4BbqKpujh8LdA0lq2IWQA/fzdzgdrfpaMf8EyK24t6s+s9NNx&TxtMiddle=<r F51851="" F80351="935255415" F80401="${lines[\"$i\"]}" F83181="" F51701=""/>&Fm_Action=09&Frm_Type=&Frm_No=&TicketTextBox=' https://reg.pnu.ac.ir/forms/authenticateuser/main.htm | grep "کد1" >> /dev/null ; check=$? if [ $check -eq '0' ] then echo " Password not found!" else echo " Password is: ${lines[\"$i\"]}" break fi ((i++)) done
<bash>
2019-01-14 13:14:26
LQ_EDIT
54,182,591
How to removed pined marker and set it new location google javascript api
How to i clear the old pined `marker` location and place it on new location? Am using google javascript api map with autocomplete search. When i search for a location the marker will pin on the location in map, if i type new location it will add another `marker`, but i don't want it that way, i want it to add `marker` to new location and clear the old pined location. Sample image [![enter image description here][1]][1] From the above image, i want only one green marker on current typed location, if location change it will be place only on new one not create multiple markers. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> var autocomplete; var countryRestrict = {'country': 'us'}; var MARKER_PATH = 'https://developers.google.com/maps/documentation/javascript/images/marker_green'; var componentForm = { route: 'long_name', locality: 'long_name', administrative_area_level_1: 'short_name', country: 'long_name' }; var initOptions = { 'current': { center: {lat: 2.9248795999999997, lng: 101.63688289999999}, zoom: 15, country: 'MY', componentRestrictions: {'country': 'us'} } }; var customLabel = { restaurant: { label: 'R' }, bar: { label: 'B' } }; function initGoogleMap() { var map = new google.maps.Map(document.getElementById('map'), { zoom: initOptions['current'].zoom, center: initOptions['current'].center, mapTypeControl: false, panControl: false, zoomControl: false, streetViewControl: false, clickableIcons: false, fullscreenControl: false }); var input = document.getElementById('SeachLOcationToBuy'); autocomplete = new google.maps.places.Autocomplete(input); autocomplete.bindTo('bounds', map); /*map.controls[google.maps.ControlPosition.TOP_LEFT].push(input);*/ autocomplete.setComponentRestrictions({'country': initOptions['current'].country}); var markerLetter = String.fromCharCode('A'.charCodeAt(0) + (1 % 26)); var markerIcon = MARKER_PATH + markerLetter + '.png'; var infoWindow = new google.maps.InfoWindow; autocomplete.addListener('place_changed', function() { var place = autocomplete.getPlace(); if (!place.geometry) { return; } if (place.geometry.viewport) { map.fitBounds(place.geometry.viewport); } else { map.setCenter(place.geometry.location); map.setZoom(17); } var point = new google.maps.LatLng(place.geometry.location.lat(), place.geometry.location.lng()); var marker = new google.maps.Marker({ map: map, position: point, icon: markerIcon, label: 'P' }); fillInAddress(place); document.getElementById('UpdateFoodAddress').disabled = false; document.getElementById('full_address').value = input.value; /*Set the position of the marker using the place ID and location.*/ marker.setPlace({ placeId: place.place_id, location: place.geometry.location }); marker.setVisible(true); }); downloadUrl("_api/setGeoXmlLocation.php?geolocate=true", function(data) { var xml = data.responseXML; var markers = xml.documentElement.getElementsByTagName('marker'); var counts = xml.documentElement.getElementsByTagName('counter')[0].childNodes[0]; Array.prototype.forEach.call(markers, function(markerElem) { var id = markerElem.getAttribute('id'); var name = markerElem.getAttribute('name'); var logo = markerElem.getAttribute('logo'); var address = markerElem.getAttribute('address'); var type = markerElem.getAttribute('type'); var page = markerElem.getAttribute('page'); var point = new google.maps.LatLng( parseFloat(markerElem.getAttribute('lat')), parseFloat(markerElem.getAttribute('lng')) ); var infowincontent = document.createElement('div'); var strong = document.createElement('strong'); var img = document.createElement('img'); var imgbox = document.createElement('div'); var br = document.createElement('br'); var span = document.createElement('span'); var text = document.createElement('text'); /*WINDOW*/ infowincontent.setAttribute("class", "app-map-info-window"); text.textContent = address; infowincontent.appendChild(text); var icon = customLabel[type] || {}; var marker = new google.maps.Marker({ map: map, position: point, label: icon.label }); marker.addListener('click', function() { infoWindow.setContent(infowincontent); infoWindow.open(map, marker); }); }); }); } function fillInAddress(place) { for (var component in componentForm) { document.getElementById(component).value = ''; document.getElementById(component).disabled = false; } for (var i = 0; i < place.address_components.length; i++) { var addressType = place.address_components[i].types[0]; if (componentForm[addressType]) { var val = place.address_components[i][componentForm[addressType]]; document.getElementById(addressType).value = val; } } } function geolocate() { if (navigator.geolocation) { navigator.geolocation.getCurrentPosition(function(position) { var geolocation = { lat: position.coords.latitude, lng: position.coords.longitude }; var circle = new google.maps.Circle({ center: geolocation, radius: position.coords.accuracy }); autocomplete.setBounds(circle.getBounds()); }); } } function downloadUrl(url, callback) { var request = window.ActiveXObject ? new ActiveXObject('Microsoft.XMLHTTP') : new XMLHttpRequest; request.onreadystatechange = function() { if (request.readyState == 4) { request.onreadystatechange = doNothing; callback(request, request.status); } }; request.open('GET', url, true); request.send(null); } function doNothing(){ } initGoogleMap(); <!-- language: lang-html --> <script src="https://maps.googleapis.com/maps/api/js?key=AIzaSyAkkzv-gkVsQSAUDOjUdEBmXVqmaDphVjc&libraries=places&callback=initMap"></script> <input id="SeachLOcationToBuy" class="map-form-control form-control" type="text" name="setMyNewAddress" placeholder="Enter your address" onFocus="geolocate()" value=""/> <div class="PageBodyContainerMap"> <span class="container"> <span class="GeoMap"> <div id="map"></div> <div id="infowindow-content"> <span id="place-name" class="title"></span><br> Place ID <span id="place-id"></span><br> <span id="place-address"></span> </div> </span> </span> </div> <!-- end snippet --> [1]: https://i.stack.imgur.com/jdIMy.png
<javascript><google-maps><google-maps-markers>
2019-01-14 13:36:19
LQ_EDIT
54,182,909
I don't know why it happens, It seems angular can't understand what I'm writing
This is my HttpClient code what I wrote: import { Component, OnInit } from '@angular/core'; import { HttpClient } from '@angular/common/http'; import { CreeperUser } from '../Models/CreeperUser'; import { Observable } from 'rxjs'; @Component({ templateUrl: 'friends.component.html' }) export class FriendsComponent { users: number; constructor(private http: HttpClient) { this.DisplayUser(); } public CallApi_HttpGet(): Observable<CreeperUser[]> { return this.http.get<CreeperUser[]> ('https://localhost:44399/api/user'); } public DisplayUser(){ this.CallApi_HttpGet().subscribe(response => { this.users = response[0].userId; }); } } And when I use the code to run on my server, the Chrome's console told me this: Error: Uncaught (in promise): Error: StaticInjectorError(AppModule) [enter image description here][1] [1]: https://i.stack.imgur.com/GbpFI.jpg And I don't know how can I do. Please help me!
<angular><angular-httpclient>
2019-01-14 13:57:11
LQ_EDIT
54,183,142
How to continue programm after first iteration with input
After the end of the first round of my program (Collatz function) i want my program to continue to calculate from the previous result I wrote a program with the possibility of one iteration, which starts from the input def collatz(number): if number % 2 == 0: #parity conditions value return number // 2 if number % 2 == 1: #parity oddness value return 3 * number + 1 result = 5 while True: print ('Type your number') result = int(input()) print (collatz(result))
<python><algorithm><while-loop>
2019-01-14 14:11:57
LQ_EDIT
54,186,672
Python least squares optimization
I am trying to solve the problem below: Given the input data (25 columns), find the optimal coefficients and powers to return the least squared sum of errors based on the target value. Coefficients must be bound between [0, inf) and powers are bound between [0,3], both inclusive. I am having trouble figuring out the best way to do this in Python. I currently have the data in a csv that I imported as a Dataframe. I was thinking scipy.optimize.lsq_linear might work, but I am unsure how this would look because of the large number of input variables.
<python><optimization>
2019-01-14 17:47:34
LQ_EDIT
54,187,790
Can I query the neo4j database from a Javascript file?
I have created a geohash neo4j database for NYC Taxi data. Now the next step is to visualize it within a map, for that i choosed Leaflet as a Javascript library. with static data i can plot geohash data in Leaflet, but now i want to query that data from the neo4j database and render it then. so is it possible to do that ?
<javascript><ajax><neo4j><neo4j-driver>
2019-01-14 19:17:06
LQ_EDIT
54,188,321
Javascript issue "Unexpected token :"
> Error Like the title says, I have an error of javascript with `Uncaught SyntaxError: Unexpected token :` The result of this error is this: ``` {"id":19728251846714,"properties":null,"quantity":1,"variant_id":19728251846714,"key":"19728251846714:f1a55a69aed71e7c10ca53fd3549edda","title":"Ritual Petalos de rosas y vino tinto - Obispado","price":139900,"original_price":139900,"discounted_price":139900,"line_price":139900,"original_line_price":139900,"total_discount":0,"discounts":[],"sku":"","grams":0,"vendor":"Casa Azul Spa","taxable":false,"product_id":1959512244282,"gift_card":false,"url":"\/products\/ritual-petalos-de-rosas-y-vino-tinto?variant=19728251846714","image":"https:\/\/cdn.shopify.com\/s\/files\/1\/0087\/2267\/7818\/products\/PETALOS_DE_ROSAS_Y_VINO_TINTO.jpg?v=1538589224","handle":"ritual-petalos-de-rosas-y-vino-tinto","requires_shipping":false,"product_type":"","product_title":"Ritual Petalos de rosas y vino tinto","product_description":"\u0026lt;!--\ntd {border: 1px solid #ccc;}br {mso-data-placement:same-cell;}\n--\u003eRitual Pétalos de Rosas y Vino tinto, Exquisito masaje que ofrece bienestar, relajación e hidrata la piel. Realizamos el ritual con mascarilla hidratante y antioxidante, piedras calientes, y cuarzos para ofrecer un delicioso y aromático descanso a todo el cuerpo.","variant_title":"Obispado","variant_options":["Obispado"]} ``` While I was reading the JSON and validate the JSON between multiple platforms I cannot see the error here... > Code The following error is due to this function: ``` jQuery.getJSON('/products/'+getProduct.product_handle+'.js', function(product) { product.variants.forEach(function(variant) { if (getProduct.sucursal == variant.title){ jQuery.post('/cart/add.js', { quantity: 1, id: variant.id }); } }); }); ``` > Platforms I'm working with Shopify with the template language Liquid, inside this liquid I have a `<script>` tag that runs AJAX for calling a method from Shopify. > More information I know that the error it must have javascript syntax but like I said before I didn't see the error. **Anyone knows about this error?** I appreciate every answer.
<javascript><ajax><shopify><liquid>
2019-01-14 19:58:19
LQ_EDIT
54,190,099
What is the best practice for organizing a piece of reusable code? Python
I am building a text-based encryption and decryption game. There are different levels, and each level uses a different cipher for encrypting a text. I am trying to figure out the best practice for the series of questions and prompts (the narrative) I give the user to determine if he wants to practice, do the test, encrypt, or decrypt. 90% of the narrative is the same for each level, so I don't want to repeat myself with identical code. What is the best way to do this? My first thought was to define a function that contained the general script, and to call the specific functions as parameters. (This is what I have attempted to do below). But I seem to run into a scope problem. When I call the caesar() function as one of the arguments in the script() function, I need to enter the text to be encryprted, but this text isn't provided by the user until the script() function has already started running. Should I be using a Class to define the narrative portion of the program, and then inherit to more specific types? Or should I just repeat the narrative code at the different levels? Here is the narrative script(): def script(encrypt, decrypt): """Asks user if they want to practice (encode or decode) or take the test, and calls the corresponding function.""" encrypt = encrypt decrypt = decrypt while True: print('Type Q to quit. Type M to return to the main menu.') prac_test = input('would you like to practice or take the test? P/T') if prac_test.lower() == 'p': choice = input('Would you like to encrypt or decrypt? E/D ') if choice.lower() == 'e': text = input('Enter the text you would like to encode: ') encrypt elif choice.lower() == 'd': text = input('Enter the text you would like to decode: ') key = int(input('Enter the key: ')) decrypt else: print('You must enter either "E" or "D" to encode or decode a text. ') elif prac_test.lower() == 't': text = random.choice(text_list) encrypted_text = encrypt print(encrypted_text[0]) answer = input('s/nCan you decode this string? ') if answer.lower() == ran_str.lower(): print('Congrats! You solved level 1!\n') pass elif answer != ran_str: print("Sorry, that's not correct. Why don't you practice some more?\n") script(encrypt, decrypt) elif prac_test.lower() == 'q': exit() elif prac_test.lower() == 'm': break else: print('Please enter a valid choice.') Here is one of the levels using a caesar cipher: def caesar(mode, text, key=None): """ ... The dictionaries that convert between letters and numbers are stored in the .helper file, imported above. """ mode = mode if mode == 'encrypt': key = random.randint(1, 25) elif mode == 'decrypt': key = key str_key = str(key) text = text.lower() # converts each letter of the text to a number num_list = [alph_to_num[s] if s in alph else s for s in text] if mode == 'encrypt': # adds key-value to each number new_list = [num_to_alph[(n + key) % 26] if n in num else n for n in num_list] elif mode == 'decrypt': # subtracts key-value from each number new_list = [num_to_alph[(n - key) % 26] if n in num else n for n in num_list] new_str = '' for i in new_list: new_str += i return new_str, str_key And here is who I would try to use them together: script(caesar('encrypt' text), caesar('decrypt', text, key)) Please instruct me on the best way to organize this reusable narrative code. Thank you.
<python><oop><code-organization>
2019-01-14 22:25:46
LQ_EDIT
54,190,247
Ruby - counting number of string occurence in a string/array
This code returns the word with the most occurences in a given string. But, it's not working if there's for exemple two string equals to the max. For exemple, if i was adding 3 'cool' to the text, it would still return : The words with the most frequencies is 'really' with a frequency of 4. Even if cool is also equal to 4. t1 = "This is a really really really cool experiment cool really " frequency = Hash.new(0) words = t1.split words.each { |word| frequency[word.downcase] += 1 } frequency = frequency.map.max_by {|k, v| v } puts "The words with the most frequencies is '#{frequency[0]}' with a frequency of #{frequency[1]}." i'm expecting to be able to return all word(s) with the max occurences from a given string. It would be nice if you guys could tell me if those method would work on a array too instead of a string because im still learning that some methods wont work on different type of data and i might have to use this code on arrays. Thanks !
<ruby><string>
2019-01-14 22:38:55
LQ_EDIT
54,191,165
the using system and attribute don't appear in their right color instead they appear in light blue. what does that mean?
[class Book[\]\[1\]][1] [class program][2] [1]: https://i.stack.imgur.com/WeOOb.png [2]: https://i.stack.imgur.com/nfGv8.png this is the code, I've tried rewriting it in a new program but its the same problem as soon as I create a class the "using system" and the others appear in light blue as well as attributes
<c#><visual-studio><using-directives>
2019-01-15 00:31:59
LQ_EDIT
54,191,983
How to initialize public Spinner array in Android
Why can't I initialize this Spinner array in this way? I need to access the content inside the array in another method not included here, that is why the array is declared public. public class AnotherActivity extends AppCompatActivity{ public Spinner [] jobSites; Spinner x, y; @Override protected void OnCreate(Bundle savedInstanceState){ x= findViewById(R.id.job1); y= findViewById(R.id.job2); jobSites = {x,y}; }
<java><android><android-spinner>
2019-01-15 02:35:42
LQ_EDIT
54,192,445
Not able to install openpyxl in windows 7 64 bit
I am using windows 7 64 bit. when I install openpyxl library from the link below, it is a file.tar.gz file. 1. first conern is I am unable to extract this file. ? Since I am unable to extact the file, Cant install the same. Can any one help me to get this openpyxl installed as I need to work with some of the excel file asap. Thank you very much. https://openpyxl.readthedocs.io/en/stable/
<python><python-2.7><openpyxl>
2019-01-15 03:47:35
LQ_EDIT
54,193,465
Stuck on Rosalind Python Village - Variables and Some Arithmetics
http://rosalind.info/problems/ini2/ Given: Two positive integers a and b, each less than 1000. Return: The integer corresponding to the square of the hypotenuse of the right triangle whose legs have lengths a and b ex)for dataset 3,4 return 25 the dataset is always different for every trial. a=859 b=938 print( a**2 + b**2 ) I've tried this code on my computer, and it worked. But Rosalind won't take it. What might be wrong in this code?
<python><biopython><rosalind>
2019-01-15 06:03:19
LQ_EDIT
54,196,345
I dont know how can I solve this problem with my python code
Im trying to get only the names of playlist from a json file that I have but I cannot make it {'playlists': [{'description': '', 'lastModifiedDate': '2018-11-20', 'name': 'Piano', 'numberOfFollowers': 0, 'tracks': [{'artistName': 'Kenzie Smith Piano', 'trackName': "You've Got a Friend in Me (From " '"Toy Story")'}, {'artistName': 'Kenzie Smith Piano', 'trackName': 'A Whole New World (From "Aladdin")'}, {'artistName': 'Kenzie Smith Piano', 'trackName': 'Can You Feel the Love Tonight? (From ' '"The Lion King")'}, {'artistName': 'Kenzie Smith Piano', 'trackName': "He's a Pirate / The Black Pearl " '(From "Pirates of the Caribbean")'}, {'artistName': 'Kenzie Smith Piano', 'trackName': "You'll be in My Heart (From " '"Tarzan") [Soft Version]'}, import json from pprint import pprint json_data=open('C:/Users/alvar/Desktop/Alvaro/Nueva carpeta/Playlist.json', encoding="utf8").read() playlist = json.loads(json_data) pprint(playlist) #here is where is not workint for names in playlist_list: print(names['name']) print '\n' What I want is to extract only the names of the playlists.
<python><json>
2019-01-15 09:48:59
LQ_EDIT
54,197,130
Date format problem in c#? while retriving data from excel
Below is the image of my code please have a look on it. I am trying to retrive data from excel sheet and storing it into database table through sql bulkcopy. Error: The date format is:05-01-2019 It insert 2019-05-01 (database) incorrect correct date is=2019-01-05 When date is greater than 12 it stores in correct format. 2019-12-25(database)correct Excel(25-12-2019) [1]: https://i.stack.imgur.com/NWyHK.png
<c#><asp.net><.net><sql-server><sqlbulkcopy>
2019-01-15 10:35:13
LQ_EDIT
54,198,513
How to get last seven days in laravel?
I am trying last seven days record using below query but it does not working DB::table('data_table') ->select(DB::raw('SUM(fee) as counter, left(DATE(created_at),10) as date')) ->whereIn('user_id',$descendants) ->whereRaw('DATE(created_at) = DATE_SUB(CURDATE(), INTERVAL 7 DAY)') ->groupBy(DB::raw('left(DATE(created_at),10)')) ->get() Can someone kindly guide me how make it correct
<php><sql><laravel><laravel-5>
2019-01-15 12:07:39
LQ_EDIT
54,202,570
Using bubble sort on strings in ArrayList with multiple inputs
<p>I have trouble using bubble-sort on my ArrayList sorting them in an alphabetical order. </p> <p>I tried to read up (and copy) some of the bubble sorting methods i've found online but nothing has worked so far. </p> <pre><code>private void listUsers() { int x; User temp; User temp2; if (users.isEmpty()) { System.out.println("Error: no users in register"); } else { for (User item : users) { sortedUsers.add(item); if (!sortedUsers.isEmpty()) { for (x = 0; x &lt; sortedUsers.size(); x ++) { if (sortedUsers.get(x).getName().compareTo(sortedUsers.get(x+1).getName()) &gt; 0) { temp = sortedUsers.get(x); temp2 = sortedUsers.get(x+1); sortedUsers.set(x, temp2); sortedUsers.set(x+1, temp); } } } //System.out.println(item); System.out.println(item); } } } </code></pre> <p>As of now i'm getting a java.lang.IndexOutOfBoundsException, I understand that with the x+1 i'm trying to get indexes without items but don't really understand how to fix it. </p>
<java><bubble-sort>
2019-01-15 16:04:08
LQ_CLOSE
54,203,588
IS "this" is only a local variable(reference) in java?
I have read recently that "this" is a local variable which contain a reference ID of the current object and can be used inside in any instance function. But when i explicitly declare "this" as in int argument i am getting compile time error stated: "the receiver type doesn't match the enclosing class type". class ThisDemo { void show(int this) { System.out.println(this); } } class ThisDemo1 { public static void main(String... s) { ThisDemo a=new ThisDemo(); int x=10; a.show(x); } }
<java><this>
2019-01-15 17:01:59
LQ_EDIT
54,205,809
Parse error: syntax error, unexpected '::' (T_PAAMAYIM_NEKUDOTAYIM), expecting ')'
<p>I use PHP 5.5. I try to add an arrow instead of a colon, but it still does not work. How to fix the code so that it works? My code: <pre><code> function add($a,$b){ return $a + $b; } function div($a,$b){ return $a / $b; } $server = new soap_server(); $server-&gt;configureWSDL("Jemix WS ","urn:http://jemiaymen.com"); $server-&gt;register("add", array('a'::'xsd:int','b'::'xsd:int'), array('return'-&gt;'xsd:int'), // namespace "http://jemiaymen.com", // soapaction false, // style 'rpc', // use 'encoded', // description 'A simple add web method'); $HTTP_RAW_POST_DATA = isset($HTTP_RAW_POST_DATA) ? $HTTP_RAW_POST_DATA : ''; $server::service($HTTP_RAW_POST_DATA); ?&gt; </code></pre>
<php>
2019-01-15 19:43:24
LQ_CLOSE
54,207,073
Python Tkinter Radiobutton issues in second window
I have a school project on making a website in tkinter python. My problem is in the function "Whats_for_dinner". Both my check, and radio buttons are not replacing the variable for me to find out which one is selected (I.E the radio button stays at zero instead of changing to 1, 2, 3, ect.). Also the radio buttons have more than one selected. Any help is appreciated. I am pretty new to coding in python so the simplest fixes may be the best for me to understand.
<python><user-interface><variables><tkinter><radio-button>
2019-01-15 21:28:08
LQ_EDIT
54,207,774
PHP: How can I get the input of HTML time input
<p>I am new to PHP. I have a PHP file(form1.php) with an HTML form. I would like to get the value of an input box(type=time), save it to PHP variable and transfer it to another PHP page without clicking the submit button. How can I access the input and do this with just PHP, Can i trigger some event?</p> <p>Form.php</p> <pre><code> &lt;?php ?&gt; &lt;!doctype html&gt; &lt;html lang="en"&gt; &lt;head&gt; &lt;title&gt;Form&lt;/title&gt; &lt;/head&gt; &lt;body&gt; &lt;form action="file2.php" method="post"&gt; &lt;input type="time" name="startTime"&gt; &lt;/form&gt; &lt;/html&gt; </code></pre>
<php><html>
2019-01-15 22:27:14
LQ_CLOSE
54,207,990
Why is this Java code returning a memory address?
<p>This code is returning a memory address of an array being returned by the rgb2hsv function. I am not sure as to why this is, or if it is even a memory address that it is returning as I am familiar with memory addresses looking something along the lines of "0x038987086" but the code is returning something that looks more like this : "[F@12bb4df8", I am not sure as to why this is, if you could answer why and what it exactly what it is returning that would be extremely beneficial. Here is the code:</p> <pre><code> public class HelloWorld{ public static float max(float[] nums) { if (nums[0] &gt; nums [1] &amp;&amp; nums[0] &gt; nums[2]) { return nums[0]; } if (nums[1] &gt; nums [0] &amp;&amp; nums[1] &gt; nums[2]) { return nums[1]; } if (nums[2] &gt; nums[0] &amp;&amp; nums[2] &gt; nums[1]) { return nums[2]; } return 0; } public static float min(float[] nums) { if (nums[0] &lt; nums [1] &amp;&amp; nums[0] &lt; nums[2]) { return nums[0]; } if (nums[1] &lt; nums [0] &amp;&amp; nums[1] &lt; nums[2]) { return nums[1]; } if (nums[2] &lt; nums[0] &amp;&amp; nums[2] &lt; nums[1]) { return nums[2]; } return 0; } public static float[] rgb2hsv(float r,float g, float b) { float h; //Initializes h h=0; float s; float v; // Floats added to avoid operator precedence float x; float a; float hue; //Divides by 255 r=r/255; g=g/255; b=b/255; float[] rgbArray = {r,g,b}; float mx= max(rgbArray); float mn= min(rgbArray); float df= mx-mn; if (mx == mn) { h=0; } if (mx==r) { x=g-b; a=x/df+360; hue=a % 360; h=hue; } if (mx==g) { x=b-r; a=x/df+120; hue=a % 360; h=hue; } if (mx==b) { x=r-g; a=x/df+240; hue=a % 360; h=hue; } if(mx==0) { s=0; } else { s=df/mx; } v=mx; float[] hsvArray = {h,s,v}; return hsvArray; } public static void main(String []args){ float[] x=rgb2hsv(255, 255, 0); System.out.println(x); } </code></pre> <p>}</p> <p>This should of outputted something along the lines of 3 distinct numbers telling me hue, value, and saturation. Instead it returns something similar to "[F@12bb4df8"</p>
<java><arrays><rgb><hsv>
2019-01-15 22:50:45
LQ_CLOSE
54,208,043
How to change default color of points in ggplot2 conditional aes?
<p>I want to change the default colors (currently blue and red) of the points in ggplot2 to another color set.</p> <pre><code>ggplot(data = mpg) + geom_point(mapping = aes(x = displ, y = hwy, color=displ&lt;5)) </code></pre> <p><a href="https://i.stack.imgur.com/tbEcW.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/tbEcW.png" alt="enter image description here"></a></p>
<r><ggplot2>
2019-01-15 22:57:19
LQ_CLOSE
54,208,115
whois lookup shows correct ip but why my browser cant find ip of domain?
I am facing very strange situation. my website suddenly stooped working. when i search for the domain name in WHOIS websites its showing the correct server ip address and correct DNS IP address. I can reach the website by its IP address but somehow when i am trying domain name in browser its not working and its showing "This site can’t be reached"!! There is no error in my server log. I tried different browser and different system and its same issue. I am really confused. even when i am sending GET request with Postman to my domain it not reachable but sending request to IP is working!
<web><dns>
2019-01-15 23:05:23
LQ_EDIT
54,208,334
Is it possible to track geolocation with a service worker while PWA is not open
<p>Is it possible to read from local storage and track geolocation in PWAs with a service worker while app is not open on phone (in background)</p> <p>So far my research is pointing to no, and I am finding that the PWA needs to be open for location services.</p> <p>Thank you,</p>
<service-worker><progressive-web-apps><service-worker-events>
2019-01-15 23:30:21
HQ
54,208,501
DownloadString value check for a if statement in c#
im new to c# so sorry in advance. i am attempting to create a crawler that returns only links from a website and i have it to a point that it returns the htmlscript. i am now wanting to use a if statement to check that the string is returned and if it is returned, it searches for all <a tags and shows me the href link. but i dont know what object to check or what value i should be checking for. here is what i have so far namespace crawler_pt._2 { class Program { static void Main(string[] args) { System.Net.WebClient wc = new System.Net.WebClient(); string WebData wc.DownloadString("https://www.abc.net.au/news/science/"); Console.WriteLine(WebData); if } }
<c#><webclient-download>
2019-01-15 23:52:26
LQ_EDIT
54,211,908
Using dot notation with variable to get object value in javascript
<p>I have a config object like this</p> <pre><code>{ config: { params: { football: { url: '' }, soccer: { url: '' } } } </code></pre> <p>I simply need to get at the <code>football</code> or <code>soccer</code> url value using a variable, so something like </p> <pre><code>let sport = 'soccer'; let path = config.params.`sport`.url; </code></pre> <p>I've tried bracket notation like <code>config.params[sport]</code> and the <code>eval</code> function but neither seem to do the trick. I'm sure I'm misnaming what I'm trying to do which is likely why I can't seem to find an answer.</p> <p>thanks</p>
<javascript>
2019-01-16 07:04:52
LQ_CLOSE
54,212,091
How to filter in multidimensional array?
I am working on a filter menu. I have an array something like below. From my filter menu I will get an array result: {gm: "FS H", rm: "RSM1", am: "BKK PULL", sales: "BKK SR1", state: "delhi", …} From this result I need to find the associated sa_id and pr_id. From above result: gm is top menu. rm is filtered based on gm selected. Given is my whole array. Now I dont know how to filter to get my id. { "FS H": { "RSM1": { "BKK PULL": { "BKK SR1": { mumbai: { sa_id: 34, pr_id: 12 }, delhi: { sa_id: 12, pr_id: 32 } } }, "BKK PUSH": { "BKK BCDE1": [], "BKK BAKE SE1": [] } }, }
<javascript><jquery>
2019-01-16 07:18:48
LQ_EDIT
54,213,179
How can i run the code with my own smaller dataset?
<p>I want to run <a href="https://github.com/TropComplique/shufflenet-v2-tensorflow" rel="nofollow noreferrer">https://github.com/TropComplique/shufflenet-v2-tensorflow</a> with my own smaller dataset. how can I do it?!!!!</p>
<python>
2019-01-16 08:44:15
LQ_CLOSE
54,213,349
Automatically fetch date from string in javascript and return same string with formatted Date
I'm having input string like - Hi, I'll reach on 17 Dec 2019 Its basically - [some words] + [date in any format] + [any other words optional] Will be whatever user enters. My requirement is to fetch the date form the given string and format it and store it with same string. So the result would be like - [some words] + [date in my format] + [any other words optional] Would this be possible in javascript (without nodejs) as Im running this on browser directly. Tried new Date(fullString) and I get the date but loose the other parts of the string var input = "Hi, I'll reach on 17/12/2019. Please wait." var userDate = new Date(input); Expected - "Hi, I'll reach on Dec 17, 2019. Please wait."
<javascript>
2019-01-16 08:54:22
LQ_EDIT
54,213,439
Remove A string from B string
<p>I have manufacture name and a product name which has manufacture name and I want to remove manufacture name form product name, I use the following code but didn't work</p> <p>I tried both sub and replace methods but didn't work</p> <pre><code>import re menufacture_name = "AMPHENOL ICC (COMMERCIAL PRODUCTS)" product_name = "AMPHENOL ICC (COMMERCIAL PRODUCTS) - D-SUB CONNECTOR, PLUG, 9POS" // product_name = re.sub(menufacture_name + " - ", "", product_name) product_name.replace(menufacture_name + " - ", '') print("Product name : " + product_name) </code></pre> <p>This should be the result Product name : D-SUB CONNECTOR, PLUG, 9POS</p>
<python><python-3.x><python-2.7>
2019-01-16 08:59:14
LQ_CLOSE
54,213,654
sql in ms-access
<p>I have a table name customers with two columns, case id and owner. I need to write a query to select random 5 caseids for every name in owner column.please help </p>
<sql><ms-access>
2019-01-16 09:12:16
LQ_CLOSE
54,213,662
how to get last modified record from spreadsheet and insert into database(mysql) + ajax?
I have created app in script.google.com and define below function which is auto trigger when any cell is changed from spreadsheet. Now i would like to update that value in my database (mysql). Please help me. Below is the code which i used in my current system. =========================== script code (which is defined in script.google.com) =========================== function onEdit(e) { var row_res = e.range.getRow(); var column = e.range.getColumn(); $.ajax({ url : 'http://dev.digitalvidya.com/assist/sheet/sort', type : 'GET', data : { 'row' : row_res }, dataType:'json', success : function(data) { alert('Data: '+data); }, error : function(request,error) { alert("Request: "+JSON.stringify(request)); } }); } ==================================
<mysql><google-apps-script><google-sheets><triggers>
2019-01-16 09:12:43
LQ_EDIT
54,214,605
Android 3.3.0 update, ERROR: Cause: invalid type code: 68
<p>After the new update of Android Studio (3.3.0) I'm getting error from Gradle sync saying "ERROR: Cause: invalid type code: 68". Even in project, that have been created before the update and hasn't changed at all. I've tried to reinstall Android Studio, which hasn't helped either, so there has to be something incompatible with my project, but it doesn't say what and why.</p> <p>App gradle:</p> <pre><code>apply plugin: 'com.android.application' apply plugin: 'kotlin-android' apply plugin: 'kotlin-android-extensions' android { compileSdkVersion 28 defaultConfig { applicationId "cz.cubeit.cubeit" minSdkVersion 21 targetSdkVersion 28 versionCode 1 versionName "1.0" testInstrumentationRunner "android.support.test.runner.AndroidJUnitRunner" } buildTypes { release { minifyEnabled false proguardFiles getDefaultProguardFile('proguard-android.txt'), 'proguard-rules.pro' } } } dependencies { implementation fileTree(dir: 'libs', include: ['*.jar']) implementation"org.jetbrains.kotlin:kotlin-stdlib-jdk7:$kotlin_version" implementation 'com.android.support:appcompat-v7:28.0.0' implementation 'com.android.support:cardview-v7:28.0.0' implementation 'com.android.support.constraint:constraint-layout:1.1.3' testImplementation 'junit:junit:4.12' androidTestImplementation 'com.android.support.test:runner:1.0.2' androidTestImplementation 'com.android.support.test.espresso:espresso-core:3.0.2' implementation 'com.android.support:support-v4:28.0.0' implementation 'com.android.support:design:28.0.0' } </code></pre> <p>Project gradle:</p> <pre><code>// Top-level build file where you can add configuration options common to all sub-projects/modules. buildscript { ext.kotlin_version = '1.3.11' ext.anko_version='0.10.7' repositories { google() jcenter() } dependencies { classpath 'com.android.tools.build:gradle:3.3.0' classpath "org.jetbrains.kotlin:kotlin-gradle-plugin:$kotlin_version" // NOTE: Do not place your application dependencies here; they belong // in the individual module build.gradle files } } allprojects { repositories { google() jcenter() } } task clean(type: Delete) { delete rootProject.buildDir } </code></pre>
<java><android><android-studio><kotlin>
2019-01-16 10:03:23
HQ
54,215,791
how to show and hide the div on button click using jquery
<p>In my application i have a html button where i need to hide few elements which are in div on button click and show the same elements on again click the same button i am able to hide the div but how can i again show the div elements.Belo is my html and jquery code</p> <p>Html</p> <pre><code>&lt;button type="button" id="btnsearch" style="background-color: white"&gt;Search&lt;/button&gt; &lt;div id="Show"&gt;&lt;/div&gt; </code></pre> <p>JQuery</p> <pre><code>$("#btnsearch").click(function () { $("#Show").hide(); }); </code></pre>
<jquery><html>
2019-01-16 11:10:23
LQ_CLOSE
54,215,841
Can i use the following powershell command to theck the port availability "netstat -ano | findstr 161 "
I am trying to check the availability on UDP port 389,161 on a remote server The windows server version is 2012R2 netstat -ano | findstr 161 I expect the output such as "Port 161 listening"
<powershell>
2019-01-16 11:14:00
LQ_EDIT
54,216,376
I'm getting a stack overflow exception in my get method
<p>while I was refactoring my code, I got a System.StackOverflowException thrown by my <strong>get</strong> method when my view try to access a member of my class. That's the first time that I'm using the <strong>?? (null-coalescing operator)</strong> in c#.</p> <p>That's my <strong>model</strong>:</p> <pre><code>using System; using System.ComponentModel.DataAnnotations; namespace Extranet45.Models { public class Complaint { public string Nome { get =&gt; Nome ?? "Nome não informado."; private set =&gt; Nome = value ?? "Nome não informado."; } public string Email { get =&gt; Email ?? "Email não informado."; private set =&gt; Email = value ?? "Email não informado."; } [Required(ErrorMessage = "A denuncia não possui o texto obrigatório do seu conteúdo. (Corpo da Mensagem)")] public string Denuncia { get =&gt; Denuncia ?? "O texto da denuncia não foi encontrado."; private set =&gt; Denuncia = value ?? throw new ArgumentNullException("O campo denúncia é obrigatório."); } public Complaint() { } public Complaint(string nome, string email, string denuncia) { Nome = nome; Email = email; Denuncia = denuncia; } } } </code></pre> <p>That's my <strong>controller/action</strong>:</p> <pre><code>using System; using System.Web.Mvc; using Extranet45.Models; using Utils; namespace Extranet45.Controllers { public class ComplaintController : Controller { public ActionResult Index() { return RedirectToAction("Send"); } // GET: Complaint/Send public ActionResult Send() { return View(new Complaint()); } } } </code></pre> <p>That's the <em>part of</em> my <strong>view</strong> where the exception is raised.</p> <pre><code>@model Extranet45.Models.Complaint @{ Layout = "~/Views/Shared/_Layout.cshtml"; ViewBag.Title = "Denúncia"; ViewBag.ShowHeader = false; ViewBag.BodyClass = "profile-page"; //Faz com que o header fique com a altura menor, porém ñão é uma solução elegante, refatorar ViewBag.HeaderImageUrl = "https://github.com/creativetimofficial/material-kit/blob/master/assets/img/city-profile.jpg?raw=true"; } @using (Html.BeginForm("Send", "Complaint", FormMethod.Post, new { @Class = "contact-form"})) { &lt;div class="section section-contacts"&gt; &lt;div class="col-md-8 ml-auto mr-auto"&gt; @ViewBag.ErrorMessage &lt;h2 id="main-title" class="text-center title"&gt;Denuncie&lt;/h2&gt; &lt;h4 class="text-center description"&gt;Caso você tenha alguma reclamação ou precise comunicar algo incorreto ao Ceape, nos envie uma mensagem abaixo ou um email para &lt;a href="mailto:denuncias@ceapema.org.br"&gt;denuncias@@ceapema.org.br&lt;/a&gt;&lt;/h4&gt; &lt;div class="row justify-content-center"&gt; &lt;div class="col-md-8"&gt; &lt;div class=" form-group bmd-form-group"&gt; &lt;label for="textbox-nome" class="bmd-label-static"&gt;Nome - Opcional&lt;/label&gt; @Html.TextBoxFor(m =&gt; m.Nome, new { @id = "textbox-nome", @Type = "Text", @Class = "form-control", name = "nome" }) &lt;/div&gt; &lt;/div&gt; &lt;/div&gt; </code></pre> <p>More precisely at this line, when the view try to access the member <strong>m.Nome</strong></p> <pre><code>@Html.TextBoxFor(m =&gt; m.Nome, new { @id = "textbox-nome", @Type = "Text", @Class = "form-control", name = "nome" }) </code></pre> <p>I don't know why my usage of null coalescing operator is causing an stack overflow.</p>
<c#><asp.net-mvc>
2019-01-16 11:44:47
LQ_CLOSE
54,216,425
Get a value from Entry
<p>this is a part of my code, i'm trying to get the value from the Entry bf, but when i run it shows that: "AttributeError: 'NoneType' object has no attribute 'get'". Does anyone knows why that is happening?</p> <p>Code:</p> <pre><code>from tkinter import * window = Tk() window.geometry("650x450+500+300") def Calcular(): print("teste") print(bf.get()) Geom = LabelFrame(window, text = "Dados Geométricos", font="Arial 12", width=200) Geom.place(x=290, y=10) Label(Geom, text ="bf: ", font="Arial 12").grid(column=0, row=0, sticky=E) Label(Geom, text =" cm", font="Arial 12").grid(column=2, row=0, sticky=W) bf = Entry(Geom, width=5, justify= RIGHT, font="Arial 12").grid(column=1, row=0) btnCalcular = Button(window, text="Calcular", font="Arial 12", command=Calcular) btnCalcular.place(x=50, y=180, width = 150) window.mainloop() </code></pre>
<python><tkinter>
2019-01-16 11:47:17
LQ_CLOSE
54,216,469
How to print array elements inversely in a given range in c programming?
An array A of N real numbers and two integers K and L (1 ≤ K < L ≤ N) are given. Change the order of the array elements between AK and AL (including these elements) to inverse one.
<c#><arrays>
2019-01-16 11:50:01
LQ_EDIT
54,218,556
How to generate JPA Metamodel with Gradle 5.x
<p>I am currently trying to upgrade from gradle 4.8.1 to 5.1.1 but fail with generating the hibernate metamodel for our code.</p> <p>The problem is that gradle 5 ignores the annotation processor passed with the compile classpath, but all plugins I found are using this (i.e <code>"-proc:only"</code>).</p> <p>I tried to specify the annotation processor explicitly as pointed out by gradle (<a href="https://docs.gradle.org/4.6/release-notes.html#convenient-declaration-of-annotation-processor-dependencies" rel="noreferrer">https://docs.gradle.org/4.6/release-notes.html#convenient-declaration-of-annotation-processor-dependencies</a>) <code>annotationProcessor 'org.hibernate:hibernate-jpamodelgen'</code></p> <p>But this does not help and I still get the following error:</p> <blockquote> <p>warning: Annotation processing without compilation requested but no processors were found.</p> </blockquote> <p>Maybe also the plugins need to be updated, but as I said all plugins which I found are passing the annotation processor with the classpath. We are currently using this one: <a href="https://github.com/Catalysts/cat-gradle-plugins/tree/master/cat-gradle-hibernate-plugin" rel="noreferrer">https://github.com/Catalysts/cat-gradle-plugins/tree/master/cat-gradle-hibernate-plugin</a></p>
<java><hibernate><jpa><gradle><metamodel>
2019-01-16 13:51:46
HQ
54,218,632
How to use local proxy settings in docker-compose
<p>I am setting up a new server for our Redmine installation, since the old installation was done by hand, which makes it difficult to update everything properly. I decided to go with a Docker image but am having trouble starting the docker container due to an error message. The host is running behind a proxy server, which I think, is causing this problem, as everything else such as wget, curl, etc. is working fine.</p> <p>Error message:</p> <pre><code>Pulling redmine (redmine:)... ERROR: Get https://registry-1.docker.io/v2/: dial tcp 34.206.236.31:443: connect: connection refused </code></pre> <p>I searched on Google about using Docker/Docker-Compose with a proxy server in the background and found a few websites where people had the same issue but none of these really helped me with my problem.</p> <p>I checked with the Docker documentation and found a guide but this does not seem to work for me: <a href="https://docs.docker.com/network/proxy/" rel="noreferrer">https://docs.docker.com/network/proxy/</a></p> <p>I also found an answered question here on StackOverflow: <a href="https://stackoverflow.com/questions/53477114/using-proxy-on-docker-compose-in-server">Using proxy on docker-compose in server</a> which might be the solution I am after but I am unsure where exactly I have to put the solution. I guess the person means the docker-compose.yml file but I could be wrong.</p> <p>This is what my docker-compose.yml looks like:</p> <pre><code>version: '3.1' services: redmine: image: redmine restart: always ports: - 80:3000 environment: REDMINE_DB_MYSQL: db REDMINE_DB_PASSWORD: SECRET_PASSWORD db: image: mysql:5.7 restart: always environment: MYSQL_ROOT_PASSWORD: SECRET_PASSWORD MYSQL_DATABASE: redmine </code></pre> <p>I expect to run the following command without the above error message</p> <pre><code>docker-compose -f docker-compose.yml up -d </code></pre>
<proxy><docker-compose><redmine>
2019-01-16 13:55:34
HQ
54,219,598
Does Python support Default Keyord and Default Variable Length Arguments?
I know that Python supports variable arguments `*args` and keyword arguments `**kwargs` but is there a way to have a default for these fields ? <br> ```*args = (1,'v')) , **kwargs = {'a':20}```. I am not saying that I have a use case for this but it seems there is also no reason to disallow this. I do understand that it is trivial to get around this by checking for empty `args`
<python><python-3.x><default-arguments><keyword-argument>
2019-01-16 14:49:05
LQ_EDIT
54,219,671
Variable extraction to var in Intellij IDEA
<p>When extracting a variable (ctrl+alt+v) in Intellij IDEA with Java 11, I would like for the default to be that it is extracted to a <code>var</code> instead of the verbose type. </p> <pre><code>var home = "127.0.0.1"; </code></pre> <p>instead of </p> <pre><code>String home = "127.0.0.1"; </code></pre> <p>Is there a way to configure Intellij IDEA to do this?</p>
<java><intellij-idea><java-11>
2019-01-16 14:52:37
HQ
54,221,481
Remove underline from HTML
<p>I am looking for how to remove the underline from this bit of HTML </p> <p>I tried this but have no idea where to place it in this line. (I am not a developer) </p> <pre><code>&lt;a href="%%unsubscribe%%"&gt;&lt;span style="color:#15BECE;"&gt;Unsubscribe&lt;/span&gt;&lt;/a&gt; from email communications&lt;br&gt; </code></pre>
<html>
2019-01-16 16:35:54
LQ_CLOSE
54,223,069
Java Program : Split an Array into two array via them types
How can I Write a program to input a string (consist of symbol and number) into an array, the program then should store number into array1, and symbol into array2. for example I want to split this Array [Im 18 years old & 22 days ] then our out put should be Array1[Im,years,old,days] Array2 [18,&,22] thanks for your helps in advance !!
<java><arrays><data-structures><split>
2019-01-16 18:18:32
LQ_EDIT
54,224,322
How can I add a String to a 2-dimensional array?
<p>I have a project I am working in in my comp sci class and I completely forgot how to add a String to a 2-dimensional array. Any help would be appreciated. </p>
<java><arrays><multidimensional-array>
2019-01-16 19:49:34
LQ_CLOSE
54,228,663
Can't figure out why simple method is infinitely looping in Java
<p>It's just a simple little method that gets user input to convert an integer from decimal to binary. It uses do-while loops to restart and verify valid input. When it catches an InputMismatchException, it starts to infinitely loop this:</p> <pre><code>Must enter a positive integer, try again. Enter positive integer for binary conversion: </code></pre> <p>I don't know why the Scanner isn't causing the program to wait for new input when I call nextInt().</p> <p>Here's the code for the method:</p> <pre><code>public static void main (String[] theArgs) { final Scanner inputScanner = new Scanner(System.in); boolean invalidInput = false; boolean running = true; int input = 0; do { do { System.out.println("Enter positive integer for binary conversion:"); try { input = inputScanner.nextInt(); if (input &lt; 1) { System.out.println("Must be a positive integer, try again."); invalidInput = true; } else { invalidInput = false; } } catch (final InputMismatchException e) { System.out.println("Must enter a positive integer, try again."); invalidInput = true; } } while (invalidInput); System.out.println(StackUtilities.decimalToBinary(input)); System.out.println("Again? Enter 'n' for no, or anything else for yes:"); if (inputScanner.next().equals("n")) { running = false; } } while (running); } </code></pre>
<java><java.util.scanner><infinite-loop>
2019-01-17 03:38:29
LQ_CLOSE
54,228,900
Cannot assign value of type '[asd]?' to type 'asd'
I've some variable in this class class qwerty: UIViewController, UIPickerViewDelegate, UIPickerViewDataSource { var userData = clsReqData() var arrayMissingLI [String] = [] var arrayInLI [String] = [] var arrayLN [String] = [] override func viewDidLoad() { reqSpinnerCIN() } func reqSpinnerCIN(){ NetworkingService.shared.reqSpinnerCIN(phone_number: user.phone_number!) {spinnerResponse in if (spinnerResponse == nil){ self.view.makeToast("Technical problem, please try again...") } else { if (spinnerResponse?.success == Const.ResponseKey.Success){ print(spinnerResponse ?? "") self.userData = spinnerResponse?.data! //error "Cannot assign value of type '[clsSpinnerNominalCashin]?' to type 'clsSpinnerNominalCashin'" } else if (spinnerResponse?.success == Const.ResponseKey.SessionEnd) { self.sessionEnd() } else { let popup = PopupDialog(title: "Failed to get data", message: spinnerResponse?.error) let buttonOK = DefaultButton(title: "OK"){ } popup.addButton(buttonOK) self.present(popup,animated: true,completion: nil) } } } } } Let's say `spinnerResponse` is class `clsReqDataResponseFromServer` that i use in escape handling Alamofire to getting the response from server. And the variable inside this class is : class clsReqDataResponseFromServer: Mappable { var tag: String? var success: String? var error: String? var data: [clsReqData]? required init? (map: Map) { } init () { } func mapping(map: Map) { tag <- map ["tag"] success <- map ["success"] error <- map ["error"] data <- map ["data"] } } And variable inside class `clsReqData` is : class clsReqData: Mappable { var Type: String? var ListId: String? var ListName: String? required init? (map: Map) { } init () { } func mapping(map: Map) { Type <- map ["type"] ListId <- map ["list_i"] ListName <- map ["list_name"] } } in this case, `spinnerResponse.data` is the `clsReqData` but it declared as `array` and i use it for getting the response from server. Because of that, i can't put this response into `userData` inside `spinnerResponse.data`, it have some variable like `T, LI,` and `LN` I want to put those data from `spinnerResponse.data` into `userData` because i want to filter the data inside `spinnerResponse.data` For example if the response that i get from `clsReqData` is //T = Type //LI = ListId //LN = ListName T = In LI = 001 LN = CG1 T = Out LI = 001 LN = CG2 T = Missing LI = 001 LN = CG3 T = Out LI = 002 LN = CG4 T = In LI = 002 LN = CG5 If the `T` is `Missing`, i want to put variable `LI` into `arrayMissingLI` and `LN` into `arrayLN` and use it in the Pickerview. And here's i think : if userData.type == "Missing" { //put all data from "LI" that variable "Type / T" is "Missing" that i got from `spinnerResponse?.data` and save it into arrayMissingLI //put all data from "LN" that variable "Type / T" is "Missing" that i got from `spinnerResponse?.data` and save it into arrayMissingLN } if i use `self.userData = spinnerResponse?.data!`, it'll show `Cannot assign value of type '[clsReqData]?' to type 'clsReqData'` error. How can i solve this problem so i can filter those array and use it in the `PickerView` for showing the data if i choose `Missing, Out,` and `In`
<ios><arrays><swift><xcode><uipickerview>
2019-01-17 04:11:13
LQ_EDIT
54,228,910
Self-made slideToggle()
<p>I've been using <code>slideToggle()</code> and I love the effect. How does this <code>slideToggle()</code> work and how do I recreate it using CSS + Javascript? How does it give the sliding effect as I can't simply just play with <code>height: 0</code> and <code>height: auto</code>?</p>
<javascript><jquery><css>
2019-01-17 04:12:32
LQ_CLOSE
54,229,251
printing a float has unexpected value
<p>Why has '32' been added to the value of v in the output below?</p> <pre><code>int main() { float v = 9.999e8; std::cout &lt;&lt; "v --&gt; " &lt;&lt; v &lt;&lt; std::endl; std::cout &lt;&lt; std::fixed; std::cout &lt;&lt; "v --&gt; " &lt;&lt; v &lt;&lt; std::endl; return 0; } </code></pre> <p>output:</p> <pre><code>v --&gt; 9.999e+08 v --&gt; 999900032.000000 ^^ </code></pre> <p>Is it an artefact of printing the value, or that 9.999e+08 cannot be accurately represented in a float? </p> <p>Changing v to a double resolves the issue but I want to understand the actual cause.</p> <p><strong>strong text</strong></p>
<c++><io><floating-point><precision>
2019-01-17 04:52:28
LQ_CLOSE
54,229,285
Constructing list from multi level map in Java 8
<p>I have a multi-level map as follows:</p> <pre><code> Map&lt;String, Map&lt;String, Student&gt; outerMap = {"cls1" : {"xyz" : Student(rollNumber=1, name="test1")}, "cls2" : {"abc" : Student(rollNumber=2, name="test2")}} </code></pre> <p>Now I want to construct a list of string from the above map as follows:</p> <pre><code>["In class cls1 xyz with roll number 1", "In class cls2 abc with roll number 2"] </code></pre> <p>I have written as follows, but this is not working, in this context I have gone through the post as well: <a href="https://stackoverflow.com/questions/51818929/java-8-streams-nested-maps-to-list">Java 8 Streams - Nested Maps to List</a>, but did not get much idea. </p> <pre><code> List&lt;String&gt; classes = outerMap.keySet(); List&lt;String&gt; studentList = classes.stream() .map(cls -&gt; outerMap.get(cls).keySet().stream() .map(student -&gt; "In class "+ cls + student + " with roll number " + outerMap.get(cls).get(student).getRollNum() +"\n" ).collect(Collectors.toList()); </code></pre>
<java><list><java-8><hashmap>
2019-01-17 04:58:19
HQ
54,230,685
How to check an android device is rebootable
I am using custom ROM and able to reboot the device. Is their a way to programatically check if an android device supports re reboot.
<android><android-reboot>
2019-01-17 07:08:50
LQ_EDIT
54,230,691
how can i fill null value with S.T in postgersSQL?
Does anyone know how to fill null value in postgerSQL? For example, Null values are replaced with X column A B Null C D Null column A B x C D x
<sql><postgresql>
2019-01-17 07:09:41
LQ_EDIT
54,232,430
signtool.exe set proxy for timestamp in a batch
I want reach the timestamp server for sign a file with signtool.exe behind a firewall, this is my batch file: signtool.exe timestamp /t http://timestamp-server foo.exe has sign tool some feature for set the proxy?
<signtool>
2019-01-17 09:11:11
LQ_EDIT
54,232,501
Adding an image before each new line Angular4 renderer
I am trying to add an image before each new line (img) Apple (img) Ball (img) Cat (img) Dog create() { this.tooltip = this.renderer.createElement('div'); this.tooltipTitle.split(',').forEach((text) => { this.renderer.appendChild(this.tooltip, this.renderer.createText(text)); this.renderer.appendChild(this.tooltip, this.renderer.createElement('br')); this.renderer.appendChild(document.body, this.tooltip); }); } this.renderer.addClass(this.tooltip,'classA') .classA{ positon:absolute; max-width: 150px; font-size: 14px; color: black; padding: 3px 8px; background: grey; border-radius: 4px; z-index: 100; opacity: 0; } So the addClass is adding styles to the whole tooltip.That is good and working what I am further trying is to add an image at beginning of new line as well
<javascript><html><angular><dom><angular-renderer2>
2019-01-17 09:15:11
LQ_EDIT
54,232,530
Merge values in map kotlin
<p>I need merge maps <code>mapA</code> and<code>mapB</code> with pairs of "name" - "phone number" into the final map, sticking together the values for duplicate keys, separated by commas. Duplicate values should be added only once. I need the most idiomatic and correct in terms of language approach.</p> <p>For example:</p> <pre><code>val mapA = mapOf("Emergency" to "112", "Fire department" to "101", "Police" to "102") val mapB = mapOf("Emergency" to "911", "Police" to "102") </code></pre> <p>The final result should look like this:</p> <pre><code>{"Emergency" to "112, 911", "Fire department" to "101", "Police" to "102"} </code></pre> <p>This is my function:</p> <pre><code>fun mergePhoneBooks(mapA: Map&lt;String, String&gt;, mapB: Map&lt;String, String&gt;): Map&lt;String, String&gt; { val unionList: MutableMap &lt;String, String&gt; = mapA.toMutableMap() unionList.forEach { (key, value) -&gt; TODO() } // here's I can't come on with a beatiful solution return unionList } </code></pre>
<java><kotlin>
2019-01-17 09:16:52
HQ
54,233,203
not able to run function in php
<p>I'am not able to run a function in php oops concept. My data gets inserted without checking the validation code in check_data(). My form directly points to insert_payment_cash() function.</p> <pre><code>function check_data() { $error =0; $balance = ($_POST["pay_amount"])-($_POST["cash_amount"]); $invoice_id = $_POST["id"]; if($_POST["cash_amount"]&gt;$_POST["pay_amount"]) { $_SESSION['message'] = "Amount cannot be greater than pay amount&lt;br&gt;"; $error=1; } else if($balance == 0 &amp;&amp; $_POST["penalty"] &gt; 0) { $_SESSION['message'] .= "If balance is zero(0), penalty will no be applied"; $error =1; } if($error == 1) { header("location:../payment_details.php?id=$invoice_id"); } } function insert_payment_cash() { $this-&gt;check_data(); #rest insertion code } </code></pre>
<php><oop>
2019-01-17 09:54:10
LQ_CLOSE
54,233,407
How to sort results in PHP?
<pre><code> foreach($domainCheckResults as $domainCheckResult) { switch($domainCheckResult-&gt;status) { case Transip_DomainService::AVAILABILITY_INYOURACCOUNT: $result .= "&lt;p style='color:red;'&gt;".$domainCheckResult-&gt;domainName."&lt;/p&gt;"; break; case Transip_DomainService::AVAILABILITY_UNAVAILABLE: $result .= "&lt;p style='color:red;'&gt;".$domainCheckResult-&gt;domainName."&lt;/p&gt;"; break; case Transip_DomainService::AVAILABILITY_FREE: $result .= "&lt;p style='color:#1aff1a;'&gt;".$domainCheckResult-&gt;domainName." "."&lt;a href='ticket.php'&gt;&lt;img src='img/next.png' alt='house' width='20' height='20' align='right' title='domein aanvragen?'&gt;&lt;/a&gt;"."&lt;/p&gt;"; break; case Transip_DomainService::AVAILABILITY_NOTFREE: $result .= "&lt;p style='color:#ff9933;'&gt;".$domainCheckResult-&gt;domainName." "."&lt;a href='contactform.php'&gt;&lt;img src='img/65.png' alt='house' width='20' height='20' align='right' title='domein laten verhuizen?'&gt;&lt;/a&gt;"."&lt;/p&gt;"; break; } } </code></pre> <p>So I have 4 possible results for domain availability. I have a array with 20 domains and when I get the results I get them in the sorting of my array. But How can I sort is on availability, so the once that are free all at the top and the once that are not free for whatever reason down? What can I use? I used the sort() tag but that won`t help.</p>
<php>
2019-01-17 10:04:34
LQ_CLOSE
54,233,480
How to convert String e.g. "01/01/2019" to date in Java 8
<p>I'm trying to use Java 8's DateTimeFormatter to turn strings such as "17/01/2019" into dates of exactly the same format.</p> <p>I'm currently using:</p> <pre><code>DateTimeFormatter format = DateTimeFormatter.ofPattern("dd/MM/yyyy", Locale.ENGLISH); LocalDateTime dExpCompletionDate = LocalDateTime.parse(sExpCompletionDate, format); LocalDateTime dExpCommencementDate = LocalDateTime.parse(sExpCommencementDate, format); </code></pre> <p>and getting the error:</p> <blockquote> <p>java.time.format.DateTimeParseException: Text '' could not be parsed at index 0</p> </blockquote> <p>Which would suggest there's something wrong with my format.</p> <p>Currently, I've tried using the default format as well as using LocalDate instead of LocalDateTime</p>
<java><date><java-8>
2019-01-17 10:08:52
LQ_CLOSE
54,234,515
Get by HTML element with React Testing Library?
<p>I'm using the <code>getByTestId</code> function in React Testing Library: </p> <pre><code>const button = wrapper.getByTestId("button"); expect(heading.textContent).toBe("something"); </code></pre> <p>Is it possible / advisable to search for HTML elements instead? So something like this:</p> <pre><code>const button = wrapper.getByHTML("button"); const heading = wrapper.getByHTML("h1"); </code></pre>
<react-testing-library>
2019-01-17 11:03:33
HQ
54,235,441
How can I loop through a determinated range of rows?
<p>I am stuck with the beginning of my analysis. Perhaps the question could be stupid, but I would like to request your help for some tips. I have a dataframe with several variables; and each variable has 10 observations. My doubt is how can I estimate for each variable the max of the first 5 observations, and the max of the following 5 observations. </p> <p>This is an example of my code:</p> <pre><code> for (i in 1:length(ncols)){ max.value &lt;- max(var1) } </code></pre> <p>Thank you very much in advance </p>
<r><for-loop>
2019-01-17 11:57:17
LQ_CLOSE
54,235,752
Flutter - how to get Text widget on widget test
<p>I'm trying to create a simple widget test in Flutter. I have a custom widget that receives some values, composes a string and shows a Text with that string. I got to create the widget and it works, but I'm having trouble reading the value of the Text component to assert that the generated text is correct.</p> <p>I created a simple test that illustrates the issue. I want to get the text value, which is "text". I tried several ways, if I get the finder asString() I could interpret the string to get the value, but I don't consider that a good solution. I wanted to read the component as a Text so that I have access to all the properties.</p> <p>So, how would I read the Text widget so that I can access the data property?</p> <pre><code>import 'package:flutter/material.dart'; import 'package:flutter_test/flutter_test.dart'; void main() { testWidgets('my first widget test', (WidgetTester tester) async { await tester .pumpWidget(MaterialApp(home: Text("text", key: Key('unit_text')))); // This works and prints: (Text-[&lt;'unit_text'&gt;]("text")) var finder = find.byKey(Key("unit_text")); print(finder.evaluate().first); // This also works and prints: (Text-[&lt;'unit_text'&gt;]("text")) var finderByType = find.byType(Text); print(finderByType.evaluate().first); // This returns empty print(finder.first.evaluate().whereType&lt;Text&gt;()); // This throws: type 'StatelessElement' is not a subtype of type 'Text' in type cast print(finder.first.evaluate().cast&lt;Text&gt;().first); }); } </code></pre>
<testing><flutter>
2019-01-17 12:16:06
HQ
54,235,886
getenv + string in c and converting types
<p>I want to add /home/username + "/path.png?5667!http-get:*:image/png:!!!!!" just as in Java. but in C</p> <p><code>name = malloc(strlen(hm)+strlen("/path.png?5667!http-get:*:image/png:!!!!!") + 2);</code></p> <pre><code>#include &lt;stdlib.h&gt; #include&lt;stdlib.h&gt; #include&lt;string.h&gt; char *hm; char *full; hm = getenv("HOME"); full = malloc(strlen(hm)+strlen("/path.png?5667!http-get:*:image/png:!!!!!") + 2); printf("name = %s\n",name); </code></pre> <p>I expect: <code>/home/username/path.png?5667!http-get:*:image/png:!!!!!"</code></p>
<c>
2019-01-17 12:22:46
LQ_CLOSE
54,236,221
Hamburger menu not working on iPhone 5SE?
I have been going in circles looking for a solution to a problem I never thought could exist in 2019. I am busy building a site and made use of the Hamburger menu for smaller screen sizes. Everything looks good in Google Dev tools for multiple devices, but once I do a real world test on my iPhone the hamburger menus is dead, and the styling of the "Order now!" button is messed up? Is there an easy way to change the css or JS so that the site can work on ios? The site is under construction but you can look here to see: http://www.encoreservices.co.za/ESMS/index.html
<javascript><ios><css><iphone><hamburger-menu>
2019-01-17 12:42:49
LQ_EDIT
54,236,932
Web development question? I am using MEN stack(mongo, express,node)
I'm working on a project wherein I am using a news api to show the contents of a specified user typed topic,for eg "technology" , but the problem is sometimes i get thousands of results and all are displayed on a single page,but i want the number of pages of the search result to change dynamically with the typed topic,for example tech may have 100 pages while sports may have 500 pages. How do i do this for my website? Any sources,links,source code might help me a lot. Thanks.
<javascript><node.js><mongodb><express><web-deployment>
2019-01-17 13:24:59
LQ_EDIT
54,237,586
Python 3.6.7 is not found 'winreg' module
'winreg' module is not found python 3.6.7. When I am not facing when I am using Python 3.4. Is any third-party app in 'winreg' that I can use same code or how can I solve this. `from winreg import *` <b>ModuleNotFoundError: No module named 'winreg'</b>
<python><python-3.6><winreg>
2019-01-17 14:01:51
LQ_EDIT
54,237,618
Error when accessing Sas url through javaServer failed to authenticate the request
I am getting error saying that Server failed to authenticate the request. Make sure the value of Authorization header is formed correctly including the signature I want to access my blob and download a particular file to local i am stuck in first step only. i tried to get the Blob containers to SAS url with account name and key it can access and through desktop application i am able to access and download file, But though code i can't. CloudBlobContainer container = new CloudBlobContainer(new URI(uri)); ArrayList<ListBlobItem> items= (ArrayList<ListBlobItem>) container.listBlobs();
<java><azure><azure-blob-storage>
2019-01-17 14:03:44
LQ_EDIT
54,239,399
Discriminated Union - Allow Pattern Matching but Restrict Construction
<p>I have an F# Discriminated Union, where I want to apply some "constructor logic" to any values used in constructing the union cases. Let's say the union looks like this:</p> <pre><code>type ValidValue = | ValidInt of int | ValidString of string // other cases, etc. </code></pre> <p>Now, I want to apply some logic to the values that are actually passed-in to ensure that they are valid. In order to make sure I don't end up dealing with <code>ValidValue</code> instances that aren't really valid (haven't been constructed using the validation logic), I make the constructors private and expose a public function that enforces my logic to construct them.</p> <pre><code>type ValidValue = private | ValidInt of int | ValidString of string module ValidValue = let createInt value = if value &gt; 0 // Here's some validation logic then Ok &lt;| ValidInt value else Error "Integer values must be positive" let createString value = if value |&gt; String.length &gt; 0 // More validation logic then Ok &lt;| ValidString value else Error "String values must not be empty" </code></pre> <p>This works, allowing me to enforce the validation logic and make sure every instance of <code>ValidValue</code> really is valid. However, the problem is that no one outside of this module can pattern-match on <code>ValidValue</code> to inspect the result, limiting the usefulness of the Discriminated Union. </p> <p>I would like to allow outside users to still pattern-match and work with the <code>ValidValue</code> like any other DU, but that's not possible if it has a private constructor. The only solution I can think of would be to wrap each value inside the DU in a single-case union type with a private constructor, and leave the actual <code>ValidValue</code> constructors public. This would expose the cases to the outside, allowing them to be matched against, but still mostly-prevent the outside caller from constructing them, because the values required to instantiate each case would have private constructors:</p> <pre><code>type VInt = private VInt of int type VString = private VString of string type ValidValue = | ValidInt of VInt | ValidString of VString module ValidValue = let createInt value = if value &gt; 0 // Here's some validation logic then Ok &lt;| ValidInt (VInt value) else Error "Integer values must be positive" let createString value = if value |&gt; String.length &gt; 0 // More validation logic then Ok &lt;| ValidString (VString value) else Error "String values must not be empty" </code></pre> <p>Now the caller can match against the cases of <code>ValidValue</code>, but they can't read the actual integer and string values inside the union cases, because they're wrapped in types that have private constructors. This can be fixed with <code>value</code> functions for each type:</p> <pre><code>module VInt = let value (VInt i) = i module VString = let value (VString s) = s </code></pre> <p>Unfortunately, now the burden on the caller is increased:</p> <pre><code>// Example Caller let result = ValidValue.createInt 3 match result with | Ok validValue -&gt; match validValue with | ValidInt vi -&gt; let i = vi |&gt; VInt.value // Caller always needs this extra line printfn "Int: %d" i | ValidString vs -&gt; let s = vs |&gt; VString.value // Can't use the value directly printfn "String: %s" s | Error error -&gt; printfn "Invalid: %s" error </code></pre> <p>Is there a better way to enforce the execution of the constructor logic I wanted at the beginning, without increasing the burden somewhere else down the line?</p>
<f#><pattern-matching><discriminated-union>
2019-01-17 15:41:46
HQ
54,240,966
jQuery sum input values of each divs?
<p>I'm looking for a way to create a sum of inputs within an element. </p> <p>I'm running into this problem that whenever I'm using each, the function itself sums all values and not just those within the div. </p> <p>Working with this isn't working as hoped:</p> <pre><code>$('div').each(function(){ var sum = 0; $(this).find('input').each(function(){ sum += Number($(this).val()); }); $('.sum').val(sum); }); </code></pre> <p>home someone can help:</p> <p><a href="http://jsfiddle.net/1keyup/q7rL2a38" rel="nofollow noreferrer">http://jsfiddle.net/1keyup/q7rL2a38</a></p>
<jquery>
2019-01-17 17:07:39
LQ_CLOSE
54,241,243
Unload chromedriver when manually closing the browser
I am developing an automatic web unit test with Selenium WebDriver. i know that i can use the driver.close() and driver.quit() method to close the browser and to release the chromedriver from the memory after the test but it's not good for me because i want that the chrome browser will stay open so i will be able to continue to work on the site from the place the automatic test finished. the problem is, that when I am closing the chrome browser manually, the chromedriver.exe staying in the memory of the machine and not terminated so in the next test i will have another chromedriver.exe in the memory and so on. Will be great if i can tell to the chromedriver.exe to terminate itself when the last chrome insistence will be closed. As i explained, i can not do it grammatically because the test method already ended. I know that i can loop over all the process each time i am executing the test and kill any active webdriver process but i don't like that way.
<selenium><exception><selenium-webdriver><exception-handling><webdriver>
2019-01-17 17:24:38
LQ_EDIT
54,241,396
Flutter: Test that a specific exception is thrown
<p>in short, <code>throwsA(anything)</code> does not suffice for me while unit testing in dart. How to I test for a <strong>specific error message or type</strong>?</p> <p>Here is the error I would like to catch:</p> <pre><code>class MyCustErr implements Exception { String term; String errMsg() =&gt; 'You have already added a container with the id $term. Duplicates are not allowed'; MyCustErr({this.term}); } </code></pre> <p>here is the current assertion that passes, but would like to check for the error type above:</p> <p><code>expect(() =&gt; operations.lookupOrderDetails(), throwsA(anything));</code></p> <p>This is what I want to do:</p> <p><code>expect(() =&gt; operations.lookupOrderDetails(), throwsA(MyCustErr));</code></p>
<dart><flutter><flutter-test>
2019-01-17 17:37:48
HQ
54,241,910
EXCEL VBA IF CELL A2:A1000 CONTAINS ANY LETTER OR NUMBER, PUT TODAY'S DATE ON SAME ROW
working on the project at work and tried to search but can't find any answers. Like the title says, if cell a2 to a1000 contains any letter or number, I would like to input today's date on row E (same row but today's date 4 rows over on column E). Please see example of what I want picture below. Thanks in advance. [enter image description here][1] [1]: https://i.stack.imgur.com/EBP6u.png
<excel><vba>
2019-01-17 18:13:13
LQ_EDIT
54,241,913
How can i display multiple value of an array in angular
How can i display mutliple value of an array? I manage to display one but i don't know how i can display all the value of my array public products: product[] = [ { id: 1, name: "McFlurry", price: 2, enseigne:"McDonalds" }, { id: 2, name: "Potatoes", price: 3, enseigne:"McDonalds" }, { id: 3, name: "BigMac", price: 4, enseigne:"KFC" }, { id: 4, name: "Nuggets", price: 3, enseigne:"KFC" }]; searchEnseigne(){ let server = this.products.find(x => x.enseigne === "McDonalds"); console.log(server); }
<javascript><typescript>
2019-01-17 18:13:20
LQ_EDIT
54,242,369
Go tests: does using the same package pollute the compiled binary?
###TL;DR: Do test written within a package end up in the final exported package? Do they add any garbage or weight to a compiled binary? ###Longer version: Let's say that I have a `foo` Go package: ``` pkg/ foo/ bar.go bar_test.go ``` I'm aware of the [black box vs white box](https://stackoverflow.com/questions/19998250/proper-package-naming-for-testing-with-the-go-language/31443271#31443271) approaches to testing in go. A short recap is that I can either: 1. have `bar_test.go` declare a `foo_test` package, or 2. have it part of the main `foo` package. Approach 1 is considered better because I get to focus on the public API of the package, as I can only access the exported identifiers of `foo`. Also, when application code imports the `foo` package with `import "pkg/foo"`, only the files containing the main `foo` package are compiled. That's nice. However, there are cases where putting the tests in `foo` is a convenient compromise. I don't particularly like it myself, but I can see it in several codebases and I understand why at times it's necessary. My question is about what happens to these tests. Since they're part of the package `foo`, when `foo` is imported somewhere, I'd expect the tests to be brought along. Or is the compiler smart enough to strip them?
<go><testing>
2019-01-17 18:45:07
LQ_EDIT
54,243,123
No genera el refresh_token en txt python-O365
<p>Me encuentro utilizando la librería o365 de python y cuando genero el txt por medio de account.con.request_token(result_url) no me genera el refresh.token simplemente me genera el access_token, este es mi código </p> <pre><code>from O365 import Account scopes_graph = protocols.get_scopes_for('message_send') credential = ('client_id', 'client_secret') account = Account(credentials=credential, scopes=scopes_graph) account.con.get_authorization_url() result_url = input('Paste the result url here...') #'aqui crea el txt pero no genera el account.con.request_token(result_url) m = account.new_message() m.to.add('examples@example.com') m.subject = 'Testing!' m.body = "George Best quote: I've stopped drinking, but only while I'm asleep." m.send() </code></pre> <p>necesito el "refresh_token":"...." gracias</p>
<python><o365-flow>
2019-01-17 19:37:58
LQ_CLOSE
54,244,119
NxN Matrix of random numbers using nested for loop
<p>I skipped a semester and completely forgot the basics of coding and my new professor at my new campus is jumping right into coding problems instead of reviewing like i figured he would do. I am to write a program that creates a 4x4 matrix of random integer values from 0-9, and then reduces it to a 2x2 matrix of doubles by averaging the 4 quadrants. I vaguely remember how to do a random number generator but the matrix alludes me. If someone would be willing to help me and walk through it with me i would much appreciate it!</p> <p>An example of what it is suppose to look like would be something along the lines of this.</p> <p>Initial matrix</p> <p>8 9 0 8</p> <p>8 4 5 3</p> <p>3 0 1 1</p> <p>3 9 5 6</p> <p>Result matrix</p> <p>7.25 4.0</p> <p>3.75 3.25</p>
<java><eclipse>
2019-01-17 20:53:48
LQ_CLOSE
54,244,683
how to pass string from intent to secendactivity(not working)
I send my string with intent but when I run program stobed. here is my mainActivivty list = (ListView) findViewById(R.id.list); list.setOnItemClickListener(new AdapterView.OnItemClickListener() { @Override public void onItemClick(AdapterView<?> arg0, View arg1,int position, long arg3) { Intent intent =new Intent(getApplicationContext(),LAstActivity.class); intent.putExtra("name",notes.get(position)); startActivity(intent,my); } }); and secendActivivty protected void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_last); TextView tv=findViewById(R.id.textView5); Intent intent = getIntent(); String data = intent.getStringExtra("name"); tv.setText(data); }
<android><android-intent><textview>
2019-01-17 21:39:24
LQ_EDIT