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
53,997,894
ALIGN JLABEL TO LEFT OR RIGHT ON JPANEL
Please how do i move/align the Yellow colored Jlabel in the JPanel to right AND other Jlabel to the left.
<java><swing><jlabel><layout-manager>
2019-01-01 18:28:17
LQ_EDIT
53,998,690
Downloading a PDF using Selenium, Chrome and Python
<p>I tried following previous posts on this topic such as these (<a href="https://stackoverflow.com/questions/43149534/selenium-webdriver-how-to-download-a-pdf-file-with-python?rq=1">post 1</a>, <a href="https://stackoverflow.com/questions/50677712/how-to-download-pdf-files-using-selenium-in-python">post 2</a>), but I'm still stuck. </p> <p>My script has to log into a site using a set of credentials, then navigate through some drop down menus to select a report. Once the report is selected, a new window pops up where parameters must be adjusted to generate the report. Once the parameters are set, the same pop up window refreshes with the generated report in PDF format and is displayed using Chrome's built in PDF viewer. I was under the impression that passing certain options to the webdriver would disable this PDF viewer and simply download the file, but the PDF viewer is still being displayed and nothing is automatically downloaded. Surely I'm missing something or I wrote something incorrectly. Here's the jist of my code:</p> <pre><code>from selenium import webdriver from selenium.webdriver.common.action_chains import ActionChains from selenium.webdriver.chrome.options import Options chrome_options = Options() chrome_options.add_experimental_option('prefs', { "download.default_directory": download_dir, "download.prompt_for_download": False, "download.directory_upgrade": True, "plugins.plugins_disabled": ["Chrome PDF Viewer"] } ) browser = webdriver.Chrome(options = chrome_options) driver = webdriver.Chrome() driver.get(url) #In between here are a bunch of steps here that navigates through drop down menus #This step may not be necessary, but I figured I'd include it to address when the pop up window refreshes and displays the report in PDF format through Chrome's PDF viewer driver.switch_to.window(driver.window_handles[1]) </code></pre> <p>So, at this point, Chrome still displays the PDF viewer even though I disabled it earlier. Nothing is downloaded, so I'm wondering if I need to provide another line of code or perhaps something else. </p> <p>Using Selenium version 3.141.0, Python 3.6.4, Chrome webdriver 2.45 on Windows 10.</p>
<python><selenium><selenium-chromedriver>
2019-01-01 20:24:56
HQ
53,999,889
Is there an R functon for easily display text as in Question function
I need to present the user with some text as in the help function. The help function display the text in a convenient way (for example, in emacs it uses a new buffer, in terminal opens vim, etc). So, is there a function that receives the string and does this job? Thanks
<r>
2019-01-02 00:00:43
LQ_EDIT
54,001,547
This site is not authotized
Please help me! I am creating find near by places application in android, when i request for places using UnRestricted key. It will response me fully. - But after restricting Key with my project name, Released SHA1 and Debug SHA1 it will not responding and give me error. "This IP, site or mobile application is not authorized to use this API key. Ask Question". - I am requesting using HttpURLConnection, - My request code is StringBuilder googlePlaceUrl = new StringBuilder ("https://maps.googleapis.com/maps/api/place/nearbysearch/json?location=" + latitude + "," + longitude + "&rankby=distance&type="+ nearbyPlace +"&key=xxxxxxxxxxx"); - I my manifest <meta-data android:name="com.google.android.geo.API_KEY" android:value="xxxxxxxxx" /> I am not expecting this answer. { "error_message" : "This IP, site or mobile application is not authorized to use this API key. Request received from IP address 103.24.99.82, with empty referer", "routes" : [], "status" : "REQUEST_DENIED" }
<android><google-nearby>
2019-01-02 05:17:54
LQ_EDIT
54,002,224
how to take hreaf into a variable nd give it to href="$vrable so"
<?php if (!empty($this->highlitsrightside)) { foreach ($this->highlitsrightside as $rightsidehlights){ if (!empty($rightsidehlights['highimage1']) || !empty($rightsidehlights['highimage2']) || !empty($rightsidehlights['highimage3']) || !empty($rightsidehlights['highimage4']) || !empty($rightsidehlights['highimage5'])) { ?> <?php $hrf1 = "www.google.com"; ?> <?php } else { $hrf1 = '#';} ?> <?php if (!empty($rightsidehlights['icontext'])) {?> <a class="off_clr_text link_chn_lo" href="$hrf1" data-options="" tabindex="0"><i class="<?php echo $rightsidehlights['icontext']; ?>" ></i> <?php echo $rightsidehlights['highlightname']; ?></a> <?php } else {?> <a class="off_clr_text link_chn_lo" href="$hrf1" data-options="" tabindex="0"> <img style=" display: inline-block;" src="<?php echo UPLOADS . 'images/highlights_icon/' . $rightsidehlights['highlighticon'] ?>"width="30" height="16" ></span></i> <?php echo $rightsidehlights['highlightname']; ?></a> <?php } }?>
<php><html>
2019-01-02 06:37:04
LQ_EDIT
54,002,557
Cant Acess Second Level of JSON String
So programming for a school project. Iam making a weather app where I need to display the current temperature. In the JSON string the current temp is in the second level which i cant figure out how to access. In furture I would also like to access the hourly and daily forecasts included in this string if you have any ideas on that. Any help would be appreciated here is my data: {"latitude":- 32.9283,"longitude":151.7817,"timezone":"Australia/Sydney","currently":{"time":1546405401,"summary":"Clear","icon":"clear-day","precipIntensity":0,"precipProbability":0,"temperature":93.03,"apparentTemperature":93.03,"dewPoint":58.07,"humidity":0.31,"pressure":1009.17,"windSpeed":14.77,"windGust":19.66,"windBearing":68,"cloudCover":0,"uvIndex":7,"visibility":7.75,"ozone":276.4},"hourly":{"summary":"Clear throughout the day.","icon":"clear-day","data":[{"time":1546405200,"summary":"Clear","icon":"clear-day","precipIntensity":0,"precipProbability":0,"temperature":93.25,"apparentTemperature":93.25,"dewPoint":57.89,"humidity":0.31,"pressure":1009.18,"windSpeed":14.78,"windGust":19.53,"windBearing":68,"cloudCover":0,"uvIndex":7,"visibility":7.58,"ozone":276.43},{"time":1546408800,"summary":"Clear","icon":"clear-day","precipIntensity":0,"precipProbability":0,"temperature":89.44,"apparentTemperature":89.44,"dewPoint":60.5,"humidity":0.38,"pressure":1008.99,"windSpeed":14.58,"windGust":21.84,"windBearing":66,"cloudCover":0,"uvIndex":4,"visibility":10,"ozone":275.8}, Imports System.IO Imports System.Net Imports System.Drawing Imports System.Web.Script.Serialization Imports Newtonsoft.Json Imports Newtonsoft.Json.Linq Dim request As HttpWebRequest Dim response As HttpWebResponse = Nothing Dim reader As StreamReader request = DirectCast(WebRequest.Create("https://api.darksky.net/forecast/412498ac9648999c8185723817a897d3/-32.9283,151.7817"), HttpWebRequest) response = DirectCast(request.GetResponse(), HttpWebResponse) reader = New StreamReader(response.GetResponseStream()) Dim data As String data = reader.ReadToEnd() Dim jsonObject As JObject = JObject.Parse(data) MessageBox.Show(jsonObject.SelectToken("currently").ToString) Dim JsonArray As JArray = JArray.Parse(jsonObject.SelectToken("currently").ToString) MessageBox.Show(jsonObject.SelectToken("temperature").ToString) Error Message: Newtonsoft.Json.JsonReaderException: 'Error reading JArray from JsonReader. Current JsonReader item is not an array: StartObject. Path '', line 1, position 1.'
<arrays><json><vb.net><parsing>
2019-01-02 07:11:12
LQ_EDIT
54,002,835
Match string in Item
Need to match by String in each item of a list and return the full item. i have lists and i want to match items of each list by string "Name" and "Address" ['Server: Corp', 'Address: 10.17.2.5\r', '\r', 'Name: b.resolvers.level3.net\r', 'Address: 4.2.2.2\r', '\r', ''] ['Server: Corp', 'Address: 10.17.2.5\r', '\r', 'Name: google-public-dns-a.google.com\r', 'Address: 8.8.8.8\r', '\r', ''] ['Server: Corp', 'Address: 10.17.2.5\r', '\r', 'Name: dns.quad9.net\r', 'Address: 9.9.9.9\r', '\r', ''] import re m = re.search(r'\bName\b'| \bAddress\b', line) for line in output: if m: print(m.group()) What i want : b.resolvers.level3.net , 4.2.2.2 google-public-dns-a.google.com , 8.8.8.8 dns.quad9.net , 9.9.9.9
<regex><python-2.7>
2019-01-02 07:42:35
LQ_EDIT
54,002,897
Cannot retrieve the JSON format data from php to android studio
It is a register function . I am able to add record to my database. But for the response made through the php script, I cannot show the response or get the response from the php to the andriod studio.... when the email is duplicated, the php should response a fail.... how could I get it show in android stuido Any help please@@@@@ register.php <?php include_once 'connection.php'; class User { private $db; private $connection; function __construct() { $this -> db = new DB_Connection(); $this -> connection = $this->db->getConnection(); } public function does_user_exist($name,$tel_no,$contact_point,$email,$address,$logo_url, $operation_time,$encrypted_password) { $query = "Select * from shop where email='$email' "; $result = mysqli_query($this->connection, $query); if(mysqli_num_rows($result)>0){ $json['fail'] = ' Already registered '.$email; echo json_encode($json); mysqli_close($this -> connection); }else{ $query = "insert into shop (name, tel_no, contact_point, email, address, logo_url, operation_time, password) values ( '$name','$tel_no','$contact_point','$email','$address','$logo_url','$operation_time','$encrypted_password')"; $inserted = mysqli_query($this -> connection, $query); if($inserted == 1 ){ $json['success'] = 'Account created'; }else{ $json['error'] = 'Wrong password'; } echo json_encode($json); mysqli_close($this->connection); } } } $user = new User(); .......... Register.java public class Register extends AppCompatActivity {private EditText nam, teln, contactpoin, emai, addres, logour, operationtim, pw1 , pw2; private Button btnregister; private RequestQueue requestQueue; private static final String Url = "http://XXXXXX/stampe/register.php"; private StringRequest request; @Override protected void onCreate(final Bundle savedInstanceState) { super.onCreate(savedInstanceState); setContentView(R.layout.activity_register); StrictMode.ThreadPolicy threadPolicy = new StrictMode.ThreadPolicy.Builder().permitAll().build(); StrictMode.setThreadPolicy(threadPolicy); ActionBar actionBar = getSupportActionBar(); actionBar.hide(); nam = (EditText) findViewById(R.id.name); teln = (EditText) findViewById(R.id.tel_no); contactpoin = (EditText) findViewById(R.id.contact_point); emai = (EditText) findViewById(R.id.email); addres = (EditText) findViewById(R.id.address); logour = (EditText) findViewById(R.id.logo_url); operationtim = (EditText) findViewById(R.id. operation_time); pw1 = (EditText) findViewById(R.id. password); pw2 = (EditText) findViewById(R.id. pwcheck); btnregister = (Button) findViewById(R.id.btn_register); requestQueue = Volley.newRequestQueue(this); btnregister.setOnClickListener(new View.OnClickListener() { @Override public void onClick(View v) { if(nam.getText().length()==0 ||teln.getText().length()==0 ||contactpoin.getText().length()==0 ||emai.getText().length()==0 ||pw1.getText().length()==0 ||pw2.getText().length()==0 ) { btnregister.setError("請輸入資料!"); }else if(!pw1.getText().toString().equals(pw2.getText().toString())){ System.out.println(pw1.getText().toString()); System.out.println(pw2.getText().toString()); pw1.setError("兩次輸入的密碼不一致"); } else{ request = new StringRequest(Request.Method.POST, Url, new Response.Listener<String>() { @Override public void onResponse(String response) { try { JSONObject jsonObject = new JSONObject(response); System.out.print(jsonObject); if(jsonObject.names().get(0).equals("success")){ Toast.makeText(getApplicationContext(),"SUCCESS "+jsonObject.getString("success"),Toast.LENGTH_SHORT).show(); startActivity(new Intent(getApplicationContext(),MainActivity.class)); }else { Toast.makeText(getApplicationContext(), "Error" +jsonObject.getString("error"), Toast.LENGTH_SHORT).show(); } } catch (JSONException e) { e.printStackTrace(); } startActivity(new Intent(getApplicationContext(),MainActivity.class)); } }, new Response.ErrorListener() { @Override public void onErrorResponse(VolleyError error) { } }){ @Override protected Map<String, String> getParams() throws AuthFailureError { HashMap<String,String> hashMap = new HashMap<String, String>(); hashMap.put("name",nam.getText().toString()); hashMap.put("tel_no",teln.getText().toString()); hashMap.put("contact_point",contactpoin.getText().toString()); hashMap.put("email",emai.getText().toString()); hashMap.put("address",addres.getText().toString()); hashMap.put("logourl",logour.getText().toString()); hashMap.put("operation_time",operationtim.getText().toString()); hashMap.put("password",pw1.getText().toString()); return hashMap; } };requestQueue.add(request); }}});}}
<java><php><android><mysql><json>
2019-01-02 07:48:32
LQ_EDIT
54,005,421
Is That Possible In C# Coding That Is VB.Net Coding
Data Grid view i tried if else condition in data grid view cells Dim RowIdx As Integer RowIdx = dgAttendance.CurrentRow.Index If dgAttendance.Item(3, RowIdx).Value = "P" Or dgAttendance.Item(3, RowIdx).Value = "P " Then dgAttendance.Item(3, RowIdx).Value = "A" EndIF Please Give The Solution in C#. Ho Do i use That If Else Statement In C#
<if-statement>
2019-01-02 11:22:25
LQ_EDIT
54,005,613
pivot Result Creation from sql query
I Have My First table like this,It contains platform and their platform code +-----------+------+ | platforms | code | +-----------+------+ | java | 1 | +-----------+------+ | .net | 2 | +-----------+------+ | perl | 3 | +-----------+------+ My Second Table Contains +-------+------+------++------+ | pname | code | year || deve | +-------+------+------++------+ | a | 1 | 2018 || abia | +-------+------+------++------+ | b | 1 | 2017 || arun | +-------+------+------++------+ | c | 2 | 2018 || abia | +-------+------+------++------+ | d | 3 | 2017 || arun | +-------+------+------++------+ | e | 2 | 2017 || arun | +-------+------+------++------+ | f | 3 | 2018 || abia | +-------+------+------++------+ Result Expected in Pivot Format like given +-----+-------+------+------+------+ | year| deve | .net | java | perl | +-----+-------+------+------+------+ | 2018| abia | 1 | 1 | 1 | +-----+-------+------+------+------+ | 2017| arun | 1 | 1 | 1 | +-----+-------+------+------+------+
<sql><sql-server>
2019-01-02 11:35:07
LQ_EDIT
54,005,994
Python reading only some lines of a text file
<p>I have text file like the following and what I would like to do it read three lines that start with 0 and three lines that start with 1 and so on until 30-40. And would like to print them on the same line. How could I accomplish this? Thank you very much!</p> <pre><code>0 something 0 something2 0 something3 0 something4 0 something5 0 something6 1 something 1 something2 1 something3 1 something4 1 something5 1 something6 </code></pre> <p>Desired output:</p> <pre><code>0 something something2 something3 1 something something2 something3 </code></pre>
<python>
2019-01-02 12:02:04
LQ_CLOSE
54,006,078
Python: Selection of Face of a STL by Face Normal values
I want to write a script in Python which can generate facegroups in a STL as per the Face Normal value condition. For example, Provided is the snap of Stl, Different colour signifies the face group containing the triangular faces satisfying my given face normal threshold. Is there any simple way to do this in python? [Face Group STL][1] [1]: https://i.stack.imgur.com/rRpWA.jpg
<python><mesh><meshlab><numpy-stl>
2019-01-02 12:07:13
LQ_EDIT
54,006,300
How to Improve For Loop Performance
<p>This code is pretty fast but I would like to make it faster without using HashMap.</p> <p>I have a list of Accounts and I am currently looping them to check if <code>account.getAccountNumber().equals(accountNumber)</code></p> <p>Is there a way to improve this using Java 8?</p> <pre><code>public Account getAccountFromCustomer(String customerID, String accountNumber) { List&lt;Account&gt; accounts = getAccountsFromCustomer(customerID); for(Account account : accounts) { if(account.getAccountNumber().equals(accountNumber)) { return account; } } return null; } </code></pre>
<java>
2019-01-02 12:21:11
LQ_CLOSE
54,006,405
How to recreate native iOS UI label with border in SWIFT?
As a beginner in SWIFT dev, I have a challenge replicating basic UI elements in Xcode. I am not aware how to replicate elements from [this picture][1]. The action that needs to happen is: when clicking on "On site", new View Controller is opened. I have assumed that "On Site" is a UIButton sitting on UIView White Rectangle with Grey Border on Top and Bottom. Is there a different/better way of doing this? [1]: https://i.stack.imgur.com/EkrZx.png
<ios><swift>
2019-01-02 12:28:21
LQ_EDIT
54,006,674
compilation error is showing while spliting 1 column into multiple column
while splitting my one column in dataFrame into 2 column using below code , i have tried with two type of code but both the time i got error while running the program.in IteliJ screen its not showing error(means no red mark) but while running it shows error on console. my data frame is: +---------+ |Wrap Time| +---------+ | 19.674| | 11.466| | 263.697| code: 1 val df2= df.withColumn("nested", split(col("Wrap Time"), ".")) .withColumn("Call Completion Code_1", $"nested".getItem(0)) .withColumn("Call Completion Code_2", $"nested".getItem(1)) .withColumn("Call Completion Code_3", $"nested".getItem(2)) .drop("nested") Error:(26, 43) could not find implicit value for parameter impl: breeze.linalg.split.Impl2[org.apache.spark.sql.Column,String,VR] val df2= df.withColumn("nested", split(col("Wrap Time"), ".")) Error:(26, 43) not enough arguments for method apply: (implicit impl: breeze.linalg.split.Impl2[org.apache.spark.sql.Column,String,VR])VR in trait UFunc. Unspecified value parameter impl. val df2= df.withColumn("nested", split(col("Wrap Time"), ".")) code: 2: val df2= df. withColumn("nested", split($"Wrap Time", ".")).select($"nested"(0) as "Call Completion Code_1", $"nested"(1) as "Call Completion Code_2") Error:(23, 33) could not find implicit value for parameter impl: breeze.linalg.split.Impl2[org.apache.spark.sql.ColumnName,String,VR] withColumn("nested", split($"Wrap Time", ".")).select($"nested"(0) as "Call Completion Code_1", $"nested"(1) as "Call Completion Code_2") Error:(23, 33) not enough arguments for method apply: (implicit impl: breeze.linalg.split.Impl2[org.apache.spark.sql.ColumnName,String,VR])VR in trait UFunc. Unspecified value parameter impl. withColumn("nested", split($"Wrap Time", ".")).select($"nested"(0) as "Call Completion Code_1", $"nested"(1) as "Call Completion Code_2") spark version is: spark-2.3.2 scala 2.11.8 jdk1.8.0_20 sbt-1.2.7
<scala><apache-spark><dataframe>
2019-01-02 12:47:50
LQ_EDIT
54,006,839
Is ssh key based authentication possible on a sftp server installed on a windows machine?
<p>I have a windows server 2012. I would like to install sftp server on the same and would like to connect to it through ssh key based authentication.</p> <p>Do we have something like authorized keys to add the ssh public keys?</p> <p>Is this possible?</p>
<linux><windows><ftp><sftp>
2019-01-02 12:59:25
LQ_CLOSE
54,007,051
Android Jetpack navigation, host fragment inside another host fragment
<p>I'm trying to achieve a simple design. One activity with a host fragment.</p> <p>The thing is, one of the destinations has a bottom navigation bar.</p> <p>Here's a paint sketch <a href="https://i.stack.imgur.com/VyZSl.png" rel="noreferrer"><img src="https://i.stack.imgur.com/VyZSl.png" alt="enter image description here"></a></p> <p>After a little bit of research, I discovered that the best practice is to have a single Activity with a host fragment. </p> <p>In my particular case, the bottom navigation bar should not be visible in the login and register fragments and just hiding it doesn't seem right to me.</p> <p>I managed to create an activity with a bottom navigation bar connecting <strong>main fragment</strong> to <strong>frag 1</strong>, <strong>frag 2</strong> or <strong>frag 3</strong>, but now I need to add the <strong>login fragment</strong> and <strong>register fragment</strong> and I'm not sure how to handle the navigation.</p> <p>Here's the code for the app without the authentication fragments.</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;LinearLayout xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:layout_width="match_parent" android:layout_height="match_parent" android:orientation="vertical" tools:context=".Presentation.MainActivity"&gt; &lt;androidx.appcompat.widget.Toolbar android:id="@+id/toolbar" app:title="Glucose Entries" android:layout_width="match_parent" android:layout_height="wrap_content" android:background="?colorPrimary" android:theme="@style/ToolbarTheme"/&gt; &lt;com.google.android.material.bottomnavigation.BottomNavigationView android:id="@+id/bottom_nav" android:layout_width="match_parent" android:layout_height="wrap_content" app:menu="@menu/bottom_navigation_bar"/&gt; &lt;fragment android:id="@+id/nav_host_fragment" android:layout_width="match_parent" android:layout_height="0dp" android:layout_weight="1" android:name="androidx.navigation.fragment.NavHostFragment" app:navGraph="@navigation/mobile_navigation" app:defaultNavHost="true" /&gt; &lt;/LinearLayout&gt; </code></pre> <p>Also:</p> <pre><code>class MainActivity : AppCompatActivity() { private lateinit var navController: NavController override fun onCreate(savedInstanceState: Bundle?) { super.onCreate(savedInstanceState) setContentView(R.layout.activity_main) setSupportActionBar(toolbar) navController = Navigation.findNavController(this, R.id.nav_host_fragment) bottom_nav.setupWithNavController(navController) NavigationUI.setupActionBarWithNavController(this, navController) } // stuff } </code></pre> <p>And the navigation file:</p> <pre><code>&lt;?xml version="1.0" encoding="utf-8"?&gt; &lt;navigation xmlns:android="http://schemas.android.com/apk/res/android" xmlns:app="http://schemas.android.com/apk/res-auto" xmlns:tools="http://schemas.android.com/tools" android:id="@+id/mobile_navigation" app:startDestination="@id/mainListFragment"&gt; &lt;!--frag 1 --&gt; &lt;fragment android:id="@+id/mainListFragment" android:name="com.gluco.Presentation.MainList.MainListFragment" android:label="Glucose Entries" tools:layout="@layout/main_list_fragment"&gt; &lt;/fragment&gt; &lt;!--frag 2 --&gt; &lt;fragment android:id="@+id/statisticsFragment" android:name="com.gluco.Presentation.Statistics.StatisticsFragment" android:label="statistics_fragment" tools:layout="@layout/statistics_fragment" /&gt; &lt;!--frag 3 --&gt; &lt;fragment android:id="@+id/settingsFragment" android:name="com.gluco.Presentation.Settings.SettingsFragment" android:label="SettingsFragment" /&gt; &lt;/navigation&gt; </code></pre> <p>Should I just hide the navigation bar on fragments where is not supposed to be?</p> <p>Also, I'm thinking another solution could be to not use the automatic navigation provided from the bottom navigation bar and create my own actions to navigate from <strong>main fragment</strong> to <strong>frag 1</strong>, <strong>frag 2</strong> or <strong>frag 3</strong></p>
<android><kotlin><android-jetpack>
2019-01-02 13:15:21
HQ
54,007,454
How to store image in a database using laravel and then display it
<p>I've seen some topics on stack about this question but none of them are exactly what i want. Mostly people are saying it's a bad idea to store image in a database. I know it but still I need to save an image in a database and be able to display it. please provide a code or some video how to do it. thanks in advance</p>
<php><mysql><laravel>
2019-01-02 13:43:54
LQ_CLOSE
54,008,366
How to structure Firestore database in chat app?
<p>The simplest way of storing chat messages is probably this:</p> <pre><code>message: -message1 { "user1" "user2" "message" "date" } -message2 -message3 </code></pre> <p>When the app grows in size (a lot of messages), and operations on database are done with <code>.whereEqualTo</code> are there any disadvantages of structuring chat app messages this way? Like with database iterating through all messages ?</p> <p>Because if there are problems with this approach, i've seen for example this way of structuring database, that would segregate messages in different chat rooms</p> <pre><code>chats: { -chat1 { "lastMessage" "timestamp" "users": {user1, user2} } -chat2 -chat3 } messages: { -chat1 { "message" "date" } } </code></pre> <p>But in this example, adding new message would require user to make 2 write operations, one writing new message and one updating <code>chat</code> document with new <code>lastMessage</code> and <code>timestamp</code> client-side, or creating a cloud function to update <code>chat</code> document with new values, when new message is added. </p> <p>So, is the first option valid, or should I go with something like the second example?</p>
<android><firebase><google-cloud-firestore>
2019-01-02 14:47:23
HQ
54,009,110
Read A bigges XML file
I know how to read a simple XML file in java using getelementbyTag but here i want to read the mac address from here which is 01-0C-CD-01-00-34 in java can anyone help me please. <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-html --> <Address> <P type="MAC-Address"xsi:type="tP_MACAddress">010C-CD-01-00-34</P> <P type="VLAN-ID" xsi:type="tP_VLAN-ID">000</P> <P type="VLAN-PRIORITY" xsi:type="tP_VLAN-PRIORITY">4</P> <P type="APPID" xsi:type="tP_APPID">0001</P> </Address> <!-- end snippet -->
<java><xml-parsing>
2019-01-02 15:38:41
LQ_EDIT
54,009,391
How to recognize the meaning of a linked list function in c++
<p>I'm currently stuck on some functions operating on single linked lists made with a struct in c++. </p> <p>I am supposed to find out what do these functions do without compiling, but I cannot seem to have understood the theory behind it completely, since my guesses are all to generic.</p> <p>Is there a way to guess the reason behind these function's existence just by looking at them? And what do they do?</p> <p>Also, what will happen if I call q(la, lb) if la=(2, 3, 4, 5, 1, 6) and lb=(3, 4, 5)?</p> <pre><code>bool u(List l, int x) { if (l=nullptr) return false; if (l-&gt;info == x) return true; return u(l-&gt;next, x); } void v(List&amp; l, int x) { List tmp = new (cell); tmp-&gt;info = x; tmp -&gt; next = l; l = tmp; } List q(List l1, List l2) { List aux = nullptr; while (l1!=nullptr) { if (!u(l2,l1-&gt;info)) v(aux,l1-&gt;info); l1=l1-&gt;next; } return aux; } </code></pre>
<c++><list><linked-list>
2019-01-02 15:59:02
LQ_CLOSE
54,009,721
How to disable Vuetify button without changing colors
<p>I'm using Vuetify's <a href="https://vuetifyjs.com/en/components/buttons" rel="noreferrer">v-btn</a> button component with a variety of colors set via the <code>color</code> prop. Once a user clicks the button, I set <code>disabled</code> to <code>true</code> so they can't click it again, but the button loses its color and gets greyed out.</p> <p>Is there any way to disable the button without changing its color to grey?</p>
<button><colors><vuetify.js><disable>
2019-01-02 16:21:01
HQ
54,010,650
understand the pointer pointer in c++ to get the function call
<p>I am little confused about the pointer statement in the following code. The purpose of the pointer is to access the virtual function from virtual table.here is link of the article. <a href="http://kaisar-haque.blogspot.com/2008/07/c-accessing-virtual-table.html" rel="nofollow noreferrer">http://kaisar-haque.blogspot.com/2008/07/c-accessing-virtual-table.html</a></p> <pre><code>1 #include &lt;iostream&gt; 2 3 using namespace std; 4 5 //a simple class 6 class X 7 { 8 public: 9 //fn is a simple virtual function 10 virtual void fn() 11 { 12 cout &lt;&lt; "n = " &lt;&lt; n &lt;&lt; endl; 13 } 14 15 //a member variable 16 int n; 17 }; 18 19 int main() 20 { 21 //create an object (obj) of class X 22 X *obj = new X(); 23 obj-&gt;n = 10; 24 25 //get the virtual table pointer of object obj 26 int* vptr = *(int**)obj; 27 28 // we shall call the function fn, but first the following assembly code 29 // is required to make obj as 'this' pointer as we shall call 30 // function fn() directly from the virtual table 31 __asm 32 { 33 mov ecx, obj 34 } 35 36 //function fn is the first entry of the virtual table, so it's vptr[0] 37 ( (void (*)()) vptr[0] )(); 38 39 //the above is the same as the following 40 //obj-&gt;fn(); 41 42 return 0; 43 } 44 </code></pre> <p>so, i want to know the how to understand the line number 26.</p>
<c++><pointers>
2019-01-02 17:28:24
LQ_CLOSE
54,011,364
Abstract base class design in GoLang vs C++
I am still learning the Go way of doing things, coming from a C++ background. I am looking for feedback contrasting OOP inheritance to interface composition. I have a design situation in a Go program where, if I was implementing in C++, I would solve with an abstract base class. Suppose I need a base class, which has many implementors. The base class has shared methods that do work on abstract data items. Different Worker implementations provide CRUD operations on different item types, but workers all use the shared methods of the base class for general work. In C++ I might do it this way class IItem { // virtual methods }; class IWorker { public: // one of many virtual functions that deal with IItem CRUD virtual IItem* createItem() = 0; // concrete method that works on interfaces void doWork() { IItem* item = createItem(); // do stuff with an IItem* } }; class Toy : public IItem { }; // one of many kinds of workers class ElfWorker : public IWorker { public: ElfWorker() { // constructor implicitly calls IWorker() } IItem* createItem() override { return new Toy; } }; in golang you dont have abstract virtual methods such as IWorker::createItem(). Concrete classes need to supply the base with an interface or function that do the right thing. So I think it is the case that the golang code the ew.ItemCRUD interface has to be explicitly set with a pointer to an ElfWorker. The elf knows how to createItem(), which in his case happens to be Toy object. Other workers would implement their own ItemCRUD for their data objects. type Item interface { // various methods } type ItemCRUD interface { create() Item // other CRUD } type Worker struct { ItemCRUD // embedded interface } func (w *Worker) doWork() { item := w.create() // do stuff with item } type Toy struct { } type ElfWorker struct { Worker // embedded // .. } func NewElfWorker() *ElfWorker { ew := &ElfWorker{} ew.ItemCRUD = ew // <-- #### set Worker ItemCRUD explicitly #### return ew } func (ew *ElfWorker) createItem() Item { return &Toy{} } // more ElfWorker Item CRUD func bigFunction(w *Worker) { // ... w.doWork() // .. } So the part that I am wrestling a bit with is explicit setting. Seems like the "Go way" of composition does require this **explicit** step if I want the base Worker class to provide shared methods on Items. Thoughts?
<go><virtual><composition>
2019-01-02 18:28:29
LQ_EDIT
54,011,637
Can I include and exclude html text with media queries?
<p>I've been using media queries quite a bit lately and I'm just trying to figure out what I can and can't change. My question is simple.</p> <p>Can you choose to exclude or include certain elements with @media queries?</p> <p>For example, having designed my website for a mobile device I'd like to also expand it and make it available to larger viewports! However with the bigger viewport, I feel like I'd like to add more content but of course, I don't know if I can do that without adding directly to the HTML code and of course if I do that I'll just add a bunch of stuff to my mobile design.</p> <p>What can I do in this circumstance? </p> <pre><code>.container { display: grid; grid-template-columns: 1fr; grid-template-rows: 50px 340px 1fr 50px; grid-template-areas: "header" "advert" "main" "footer"; text-align: center; } @media only screen /* Tablet */ and (min-width: 768px) { .container { grid-template-columns: 1fr; grid-template-rows: 50px 340px 1fr 50px; grid-template-areas: "header" "advert" "main" "footer"; } @media screen /* Desktop/Laptop */ and (min-width: 1900px) { .container { grid-template-columns: 200px 1fr; grid-template-rows: 80px 10fr 1fr; grid-template-areas: "header header" "advert main" "footer footer" } </code></pre>
<html><css><text><media-queries>
2019-01-02 18:50:11
LQ_CLOSE
54,014,913
Difference between single and double quotes in Flutter/Dart
<p>I know that single and double quotes have at least some level of equivelence in Dart. For example,</p> <pre><code>var myString = "Hello world"; // double quotes </code></pre> <p>and </p> <pre><code>var myString = 'Hello world'; // single quotes </code></pre> <p>have no programmatic difference to my knowledge. </p> <p>I keep seeing them used seemingly interchangeably in various examples and in some documentation. I'm wondering if there is a subtle difference that I am missing or if there is a recommended style to follow, especially in Flutter.</p> <p><em>This is a Q&amp;A self answer after reading the Flutter and Dart style guides.</em></p>
<string><dart><flutter>
2019-01-03 00:28:27
HQ
54,015,604
Disable python import sorting in VSCode
<p>I am trying to disable vscode from formatting my python imports when I save my file. I have some code that must run in between various imports so order is important, but every time I save it just shoves the imports to the top.</p> <p>I tried putting </p> <pre><code>"editor.codeActionsOnSave": { "source.organizeImports": false }, </code></pre> <p>in my user settings but that doesn't fix it.</p> <p>Thanks!</p> <p>EDIT- I would like to keep formatting on save on except for the imports</p>
<python><visual-studio-code><format>
2019-01-03 02:32:54
HQ
54,015,874
How to get multiple instances of dictionaries with classes
<p>I have the following python code:</p> <pre><code>class C: b={} c1=C() c2=C() c1.b[1]='s1' c2.b[1]='s2' print(c1.b[1]) </code></pre> <p>I expected the output to be "s1" but it actually outputs "s2". Why and how can i get around this? Sorry i'm a complete newbie to python this is probably a trivial question....</p>
<python>
2019-01-03 03:15:36
LQ_CLOSE
54,015,969
incorrect syntax error when trying to insert into sql using multiple values
I am trying to insert into a table I created using multiple values. It throws error on incorrect syntax near coma in the first values line end. I couldn't identify problem. I did try to insert separately, it inserted like a charm. Now I suspect the multi row inserting has some problem due to declared variable or GETDATE or both? It's not able to hold in session? I tried to put in transaction like begin tran and commit tran, still no luck. I have huge rows, any suggestions please? DECLARE @UID VARCHAR(40) SET @UID = SYSTEM_USER INSERT INTO MyTable ( Id, Name, Uid, Date) VALUES (1, 'Cris', @UID, GETDATE()), (1, 'Joel', @UID, GETDATE()), (1, 'Kris', @UID, GETDATE()); **Error I am getting is below** However, no error when inserting separately using the declare statement in individual insert. Msg 102, Level 15, State 1, Line 18 Incorrect syntax near ','.
<sql><sql-server><insert>
2019-01-03 03:30:01
LQ_EDIT
54,016,539
Automating software installation process with autoit where window is rebooting multiple times
How I can automate software installation with autoit where window is rebooting multiple time.
<autoit>
2019-01-03 04:53:32
LQ_EDIT
54,016,857
Importing multiple packages using brackets gives errors in go?
<p>So for some reason when I import on a single line like this it works fine:</p> <pre><code>package main import "fmt" func main() { fmt.Println("hi") } </code></pre> <p>But when I do this:</p> <pre><code>package main import { "fmt" "bufio" "os" "errors" "math" } func main() { fmt.Println("hi") } </code></pre> <p>I get this:</p> <p>main.go:3:8: expected 'STRING', found '{'</p> <p>main.go:4:3: expected ';', found "fmt"</p> <p>Does anyone know what's the problem? Thanks!</p>
<go><import>
2019-01-03 05:36:44
LQ_CLOSE
54,018,071
How to call print() with colorful text to android studio console in flutter
<p>I need a debug output with colorful string. like node.js chalk.</p> <p>I tried to find the packages, but there is no proper package.</p> <p>Thank you.</p>
<colors><dart><flutter>
2019-01-03 07:30:34
HQ
54,018,792
Video Editor in Flutter using dart
<p>I am looking for a plugin or example of a video editor in flutter using dart.</p> <p>I have tried the following plugin <a href="https://pub.dartlang.org/packages/video_player" rel="noreferrer">https://pub.dartlang.org/packages/video_player</a>, but it doesn't seems to have properties that I can edit the video. Example trim or add a watermark on the video.</p> <p>Many Thanks</p>
<android><ios><plugins><dart><flutter>
2019-01-03 08:36:14
HQ
54,020,575
Comparison between Big Data and Data Lakes , difference and similarities
<p>Can someone tell me the similarities and differences between Big data and Data Lakes.</p> <p>Can't find a satisfactory answer anywhere.</p>
<bigdata><data-science><data-lake>
2019-01-03 10:36:13
LQ_CLOSE
54,020,760
Is binary equality comparison of floats correct?
<p>I'm working on different memory block manipulation functions and during benchmarks I noticed, that my implementation of the <code>IsEqualRange(double* begin1, double* end1, double* begin2, double* end2)</code> is much faster then the <code>std::equals(...)</code> on MSVC and GCC as well. Further investigation showed, that doubles and floats are not block compared by <code>memcmp</code>, but in a for loop one by one. </p> <p>In what situation does binary comparison of floats lead to incorrect result? When is it ok to binary compare (equality) array of floats/doubles? Are there other fundamental types where I shouldn't use <code>memcmp</code>?</p>
<c++><floating-point><std>
2019-01-03 10:46:03
HQ
54,020,983
Sum the occurance of the string in the json array and store it in separate json array
I have a JSON array as follows: var teamDetails=[ { "pType" : "Search Engines", "value" : 5}, { "pType" : "Content Server", "value" : 1}, { "pType" : "Content Server", "value" : 1}, { "pType" : "Search Engines", "value" : 1}, { "pType" : "Business", "value" : 1,}, { "pType" : "Content Server", "value" : 1}, { "pType" : "Internet Services", "value" : 1}, { "pType" : "Search Engines", "value" : 6}, { "pType" : "Search Engines", "value" : 1} ]; *I want to take the count of the ptype dynamically and individually and should be applied if there is a change in ptype.* **`Expected output:`** var output = [{"label":"Search Engines"},{"Occurance":4},{"label":"Content Server"},{"Occurance":3},{"label":"Business"},{"Occurance":1},{"label":"Internet Services"},{"Occurance":1}];
<javascript><json>
2019-01-03 10:59:07
LQ_EDIT
54,021,037
How to mock window.location.href with Jest + Vuejs?
<p>Currently, I am implementing unit test for my project and there is a file that contained <code>window.location.href</code>.</p> <p>I want to mock this to test and here is my sample code:</p> <pre><code>it("method A should work correctly", () =&gt; { const url = "http://dummy.com"; Object.defineProperty(window.location, "href", { value: url, writable: true }); const data = { id: "123", name: null }; window.location.href = url; wrapper.vm.methodA(data); expect(window.location.href).toEqual(url); }); </code></pre> <p>But I get this error:</p> <pre><code>TypeError: Cannot redefine property: href at Function.defineProperty (&lt;anonymous&gt;) </code></pre> <p>I had tried some solutions but not resolve it. I need some hints to help me get out of this trouble. Plz help.</p>
<unit-testing><vue.js><vuejs2><jasmine><vue-test-utils>
2019-01-03 11:02:54
HQ
54,021,490
pandas replace NaN to None exhibits counterintuitive behaviour
<p>Given a series</p> <pre><code>s = pd.Series([1.1, 1.2, np.nan]) s 0 1.1 1 1.2 2 NaN dtype: float64 </code></pre> <p>If the need arises to convert the NaNs to None (to, for example, work with parquets), then I would like to have </p> <pre><code>0 1.1 1 1.2 2 None dtype: object </code></pre> <p>I would assume <code>Series.replace</code> would be the obvious way of doing this, but here's what the function returns:</p> <pre><code>s.replace(np.nan, None) 0 1.1 1 1.2 2 1.2 dtype: float64 </code></pre> <p>The NaN was forward filled, instead of being replaced. Going through the <a href="https://pandas.pydata.org/pandas-docs/stable/generated/pandas.Series.replace.html" rel="noreferrer">docs</a>, I see that if the second argument is None, then the first argument should be a dictionary. Based on this, I would expect <code>replace</code> to either replace as intended, or throw an exception. </p> <p>I believe the workaround here is </p> <pre><code>pd.Series([x if pd.notna(x) else None for x in s], dtype=object) 0 1.1 1 1.2 2 None dtype: object </code></pre> <p>Which is fine. But I would like to understand why this behaviour occurs, whether it is documented, or if it is just a bug and I have to dust off my git profile and log one on the issue tracker... any ideas?</p>
<python><pandas><replace>
2019-01-03 11:35:09
HQ
54,022,744
Python: Update columns in a list dependant on the value in another column
<p>Assume I have the following list: </p> <pre><code>list = [["A",0,"C"],["B",1,"C"]] </code></pre> <p>I want to do something that accomplishes the following: Set the values in the 1st column equal to "D" where the value in the 2nd column is equal to 0.</p> <p>So the list after the update should look like this:</p> <pre><code>list = [["D",0,"C"],["B",1,"C"]] </code></pre>
<python>
2019-01-03 12:55:36
LQ_CLOSE
54,022,921
How to call Kotlin suspending coroutine function from Java 7
<p>I'm trying to call Kotlin function from Java 7. I'm using coroutines and this called function is suspending, for example:</p> <pre><code>suspend fun suspendingFunction(): Boolean { return async { longRunningFunction() }.await() } suspend fun longRunningFunction() : Boolean { delay(400) return true } </code></pre> <p>I was using coroutines in version 0.25.3 and I could emulate simple Java callback style by passing <code>Continuation&lt;U&gt;</code> instance as an argument to suspending function, e.g.</p> <pre class="lang-java prettyprint-override"><code>CoroutinesKt.suspendingFunction(new Continuation&lt;Boolean&gt;() { @Override public CoroutineContext getContext() { return EmptyCoroutineContext.INSTANCE; } @Override public void resume(Boolean value) { doSomethingWithResult(value); } @Override public void resumeWithException(@NotNull Throwable throwable) { handleException(throwable); } }); </code></pre> <p>However, after updating to fully stable 1.0.1 release, I think it's no longer possible. Let's say updated version of suspending function looks like that:</p> <pre><code>suspend fun suspendingFunction(): Boolean { return GlobalScope.async { longRunningFunction() }.await() } </code></pre> <p><code>Continuation&lt;U&gt;</code> now uses <code>Result</code> class, which seems to be unusable from Java (which makes sense as it is inline class). I was trying to use some subclass of <code>Continuation</code> from coroutines but they are all internal or private.</p> <p>I know that usually it is <a href="https://stackoverflow.com/questions/52869672/call-kotlin-suspend-function-in-java-class">advised to transform coroutine to <code>CompletableFuture</code></a>, but I'm on Android, which means Java 7 only. Simple <code>Future</code> on the other hand is too dumb as I don't want to check periodically if function is finished - I just want to be called when it is finished. And I would really like to avoid adding new libraries or many additional classes/methods. </p> <p><strong>Is there any simple way to call suspending function directly from Java 7?</strong> </p> <p>As Kotlin tries to be very interoperable with Java I would imagine there would be some easy way to do that, but I'm yet to find it.</p>
<java><android><kotlin><coroutine><kotlinx.coroutines>
2019-01-03 13:06:32
HQ
54,023,177
How can I seperate data with typecasting in an array?
I want to add 2 different types in the same array of size 100x4.In the first column I want to add names of foods(with use of pointers) and in the second and third some numbers such as calories and hour of eating.(WITH TYPECASTING) I've been trying for this many days but I cannot find any solution.Is there a way to fix this with typecasting? #include <stdio.h> int main(){ char *table[100][4]; int n=0; int j; for (j=0;j<4;j++){ if (j==0){ printf ("Add your food:\n"); scanf("%s",&table[n][j]); }else if (j==1){ printf ("Add calories:\n"); (float) *table[n][j]; scanf("%d",&table[n][j]); }else if (j==2){ (float) *table[n][j]; printf ("Add the time you ate:\n"); scanf("%.2f",&table[n][j]); }else if (j==3){ printf ("Kati\n"); } } for (j=0;j<4;j++){ if (j==0){ printf ("food:%s",&table[n][j]); }else if (j==1){ (float) *table[n][j]; printf ("calories:%f",*table[n][j]); }else if (j==2){ (float) *table[n][j]; printf ("time you ate:%f",*table[n][j]); }else if (j==3){ printf ("Kati\n"); } } }
<c><pointers><types><casting>
2019-01-03 13:24:09
LQ_EDIT
54,023,358
How get informations in javascript from API JSON ?
I need help ! Can you tell me how can I get informations from this in javascript : I would like to get the Third values from the fisrt array (121,73) and also the Fourth (99,25) . Thank you in advance ! ---------- { "error": [], "result": { "XETHZEUR": [ [ 1545955200, "100.76", "121.73", "99.25", "120.16", "111.15", "186385.05723331", 25420 ], [ 1546041600, "120.52", "130.00", "115.91", "117.89", "121.47", "154551.36751227", 23261 ], "last": 1546387200 } }
<javascript><api>
2019-01-03 13:35:11
LQ_EDIT
54,023,808
Problem to import "ProgressDialog" in android studio
I want to use Progress Dialog in project,but its class does not add to the program! what is the problem?
<android><progressdialog>
2019-01-03 14:01:00
LQ_EDIT
54,025,026
What is lambda? How can you explain this sorting
<p>Please be gentle I'm still learning Python. I've an example where </p> <blockquote> <p>pairs = [(1, 'one'), (2, 'two'), (3, 'three'), (4, 'four')]</p> <p>pairs.sort(key=lambda pair: pair[1])</p> </blockquote> <p>The result is</p> <blockquote> <p>[(4, 'four'), (1, 'one'), (3, 'three'), (2, 'two')]</p> </blockquote> <p>Can you please help explain why this is the sequence?</p>
<python><lambda>
2019-01-03 15:13:13
LQ_CLOSE
54,026,986
Python: Remove one of two JSON elements if they have the same text
<p>How can I remove a JSON element if there's already one with the same text?</p>
<python><json>
2019-01-03 17:24:11
LQ_CLOSE
54,029,085
Python substitution of words
<p>Let's say that I have a text with me and I assigned it a variable. </p> <p>text = "Don't you want to play"</p> <p>I want to add a question at the end of the sentence, in order to do that, I need some code which helps me recognize and analyse the first word of the sentence and place a question mark at the end if the sentence starts off with a don't. </p> <p>The text which is getting back to me has to say: </p> <p>"Don't you want to play?"</p> <p>What libraries or what natural language processing software could I use to achieve this?</p>
<python>
2019-01-03 20:07:48
LQ_CLOSE
54,029,218
WPF. Is there a dialog window for selecting a font in WPF?
<p>Is there a dialog window for selecting a font in WPF? How to put the selected font to TextBox?</p>
<c#><wpf><textbox>
2019-01-03 20:18:46
LQ_CLOSE
54,030,235
How do I assign a value when rows header and column headers are matched in MS SQL 2012?
I have 400 columns and rows on my table. They are exactly same string value, you can imagine this as a matrix. However, the index values are blank and need to assign a value where the column and row names are same. Example, RIGHT NOW ## Column A ##, ## Column B ## ## Column A ## ## Column B ## OUTPUT SHOULD LIKE THIS ## Column A ##, ## Column B ## ## Column A ## 6 10 ## Column B ## 10 6 Can anybody help me get this output? SQL answers greatly appreciated if not Excel functions will also work. Thanks in advance!
<sql><sql-server><excel>
2019-01-03 21:45:36
LQ_EDIT
54,030,425
Select 3 items or 4 items out of 8 items
I am trying to get 3 or 4 items out of an array of 8 numbers (1-8). If i try to print the array of the 3 or 4 items. Most of the trys it worked but some times I only get some numbers and a 0 which isn't in the array. Like this [2, 5, 3, 0]. private int[] randomPeople() { int[] result = {0, 0, 0, 0}; int[] arr = {1, 2, 3, 4, 5, 6, 7, 8}; return getRandomPeople(result, arr); } private int[] getRandomPeople(int[] result, int[] arr) { int number; for (int i = 0; i < result.length; i++) { number = (int) (Math.random() * arr.length + 1); for (int j = 0; j < result.length; j++) { if (number == result[j]) { //check if the random number is already in the list --> new random int j = 0; number = (int) (Math.random() * arr.length + 1); } } for (int j = 0; j < arr.length; j++) { // adds the number to the new array and delete it in the old if (number == arr[j]) { result[i] = number; arr = searchDelete(arr, number); } } } System.out.println(Arrays.toString(result)); return result; } This method is for deleting the searched ID. You have to hand over an array and the int which should be deleted. private int[] searchDelete(int[] arr, int SRID) { int pos; for (pos = 0; pos < arr.length - 1; pos++) { if (arr[pos] == SRID) break; } while (pos < arr.length - 1) { arr[pos] = arr[pos + 1]; pos++; } int[] arr2 = new int[arr.length - 1]; System.arraycopy(arr, 0, arr2, 0, arr.length - 1); return arr2; }
<java><arrays>
2019-01-03 22:04:07
LQ_EDIT
54,030,815
os module of python regarding os.linesep
<p>Why has os.linesep() been used here in my code?</p> <pre><code>def GetInstruction(): print(os.linesep)#&lt;--------??? Instruction = input("&gt; ").lower() return Instruction </code></pre>
<python><python-3.x><python-2.7><python-requests>
2019-01-03 22:42:26
LQ_CLOSE
54,031,097
Why base class = new derived class cannot call derived class method? C#
I have some question which get me confused, I hope finally I can found answer here :) So. we have two classes A and B, B Derives from A, I created of A a = new B(); Why in my code when I call method of B that does not contain A I get error. Does it mean that Type Objec Pointer is of type A? and second why When I call SomeMethod it calls method of A not B? In the heap in this situation when created object instance, type object pointer points to A or B? class A { public void SomeMethod() { Console.Write("This is A"); } } class B : A { public void SomeMethod() { Console.Write("This is B"); } public void OtherMethod() { Console.Write("This is New method"); } } class Program { static void Main(string[] args) { A a = new B(); a.SomeMethod(); // This is A method a.OtherMethod(); // I get error here that a does not contain definition for this method } }
<c#><inheritance><clr>
2019-01-03 23:15:33
LQ_EDIT
54,031,245
how can I extract information from many XML from a directory and export it to an excel in java
I'm trying to get information from many xml files in a directory, how can I get specific infrmation from each one and send it to an excel file, in java file 1.xml file 2.xml file 3.xml ********* **file.csv** or .**xls** with the information of the 'n' files XML
<java><xml><extraction>
2019-01-03 23:32:15
LQ_EDIT
54,032,833
interview question hive partitioning and bucketing
<p>I am new to Hive and i recently had an interview in which i was asked below questions. can someone help with the right answer.</p> <ol> <li>While doing partioning what if data is missing from one column how will partitioning handle it?</li> <li>Can you import log file using sqoop? I gave the answer NO as sqoop is used to import data from RDBMS tables to hadoop.</li> <li>In the employee table if the value is null for any data can you still sqoop it?</li> <li>Employee table is given with employee id, location, salary, department, whaat column will be used in partioning and bucketting? I think we can use department as partioning and employee id, location and salary can be used as bucketing, please confirm.</li> </ol>
<hive>
2019-01-04 03:37:04
LQ_CLOSE
54,033,765
How to give Image src dynamically in react js?
<p>I am trying to give image name in src dynamically. I want to set image name dynamically using variable with path. but I am not able to set src correctly. I tried solutions on stackoverflow but nothing is working. </p> <p>I tried to give path like this </p> <pre><code>&lt;img src={`../img/${img.code}.jpg`}&gt;&lt;/img&gt; &lt;img src={'../img/' + img.code + '.jpg'}&gt;&lt;/img&gt; &lt;img src={'../img/{img.code}.jpg'}&gt;&lt;/img&gt; </code></pre> <p>my images are saved in src/img path if i give path like this</p> <pre><code>&lt;img src={require('../img/nokia.jpg')}/&gt; </code></pre> <p>image is showing </p> <p>I know this question is asked before but nothing is working for me. Please help me how can I set image path?</p>
<reactjs><react-redux>
2019-01-04 06:02:41
HQ
54,033,812
I am not sure why JS is acting so weird on this. Function name type error
[This works perfectly fine][1] [Function for the above example][2] [This produce a type error][3] [Function for the above example][4] [Error message][5] Both of these method is the same except for the underscore on the function name. Is someone out there kindly tell me what is the error. Thanks ! [1]: https://i.stack.imgur.com/yAceq.png [2]: https://i.stack.imgur.com/Wb6sX.png [3]: https://i.stack.imgur.com/4Ix8w.png [4]: https://i.stack.imgur.com/3q0f4.png [5]: https://i.stack.imgur.com/uyt92.png
<javascript><typeerror>
2019-01-04 06:07:58
LQ_EDIT
54,036,564
How i get the value of "ReferenceNumber" from data jason object? following are my object
Following are my code how i can accesses my reference no key ho to get it ssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssssss <!-- begin snippet: js hide: false console: true babel: false --> <!-- language: lang-js --> { "errors": [], "data": [ [ { "$": { "Type": "Shipment Confirmation Advice", "xmlns": "urn:microsoft-dynamics-nav/xmlports/x50065" }, "ReceiptAuthorization": [ { "DepositorCode": "A400", "ReferenceNumber": "00-001", "ShipmentDate": "12/07/18", "ExpArrivalDate": null, "ShipFrom": { "ShipFromCode": null, "ShipFromName": "AAWS", "ShipFromName2": null, "ShipFromAddr1": null, "ShipFromAddr2": null, "ShipFromCity": null, "ShipFromState": null, "ShipFromZip": null, "ShipFromCountry": null }, "Carrier": { "CarrierCode": "FDXE", "CarrierName": "Federal Express Corporation" }, "Container": null, "ProNumber": null, "Warehouse": "MAIN", "HdrUser1": null, "HdrUser2": null, "HdrUser3": null, "HdrUser4": null, "HdrUser5": "PURCHASE ORDER", "ShipFromRef": null, "TotalQtyDeclared": "2,000", "Temperature": "0", "MasterDocumentNumber": null, "RectLine": [ { "ItemNumber": "AFRIB-30", "DeclaredQty": "1,000", "UOM": "EACH", "ItemDesc1": "AFRICAN BIG BOOK SOFT COVER", "ItemDesc2": null, "SubPart1Number": null, "SubPart2Number": null, "LineReference": null, "LineUser1": null, "LineUser2": null, "LineUser3": null, "LineUser4": null, "LineUser5": null, "Pack1": "20", "Pack2": null, "UnitWeight": "0.85", "TareWeight": null, "Length": null, "Width": null, "Height": null, "Volume": null, "Category": "PRINTED MATERIALS", "Lot": null, "CodeDate": null, "GrsWeight": "850", "NetWeight": null, "DetailRef": null, "SubLot": null, "TagID": null, "Attribute1": null, "Attribute2": null, "Attribute3": null, "Attribute4": null, "Attribute5": null, "Attribute6": null }, { "ItemNumber": "ARMEB-30", "DeclaredQty": "1,000", "UOM": "EACH", "ItemDesc1": "ARMENIAN BIG BOOK", "ItemDesc2": null, "SubPart1Number": null, "SubPart2Number": null, "LineReference": null, "LineUser1": null, "LineUser2": null, "LineUser3": null, "LineUser4": null, "LineUser5": null, "Pack1": "20", "Pack2": null, "UnitWeight": "0.85", "TareWeight": null, "Length": null, "Width": null, "Height": null, "Volume": null, "Category": "PRINTED MATERIALS", "Lot": null, "CodeDate": null, "GrsWeight": "850", "NetWeight": null, "DetailRef": null, "SubLot": null, "TagID": null, "Attribute1": null, "Attribute2": null, "Attribute3": null, "Attribute4": null, "Attribute5": null, "Attribute6": null } ] }, { "DepositorCode": "A400", "ReferenceNumber": "PO000258", "ShipmentDate": "07/12/18", "ExpArrivalDate": null, "ShipFrom": { "ShipFromCode": null, "ShipFromName": "Pending RFQ", "ShipFromName2": null, "ShipFromAddr1": null, "ShipFromAddr2": null, "ShipFromCity": null, "ShipFromState": null, "ShipFromZip": null, "ShipFromCountry": null }, "Carrier": { "CarrierCode": null, "CarrierName": null }, "Container": null, "ProNumber": null, "Warehouse": "MAIN", "HdrUser1": null, "HdrUser2": null, "HdrUser3": null, "HdrUser4": null, "HdrUser5": "PURCHASE ORDER", "ShipFromRef": null, "TotalQtyDeclared": "1", "Temperature": "0", "MasterDocumentNumber": null, "RectLine": { "ItemNumber": "B-1", "DeclaredQty": "1", "UOM": "EACH", "ItemDesc1": "Big Book Hardcover 4th Edition", "ItemDesc2": null, "SubPart1Number": null, "SubPart2Number": null, "LineReference": "1", "LineUser1": null, "LineUser2": null, "LineUser3": null, "LineUser4": null, "LineUser5": null, "Pack1": "20", "Pack2": null, "UnitWeight": "1.6", "TareWeight": null, "Length": null, "Width": null, "Height": null, "Volume": null, "Category": "PRINTED MATERIALS", "Lot": null, "CodeDate": null, "GrsWeight": "1.6", "NetWeight": null, "DetailRef": null, "SubLot": null, "TagID": null, "Attribute1": null, "Attribute2": null, "Attribute3": null, "Attribute4": null, "Attribute5": null, "Attribute6": null } }, { "DepositorCode": "A400", "ReferenceNumber": "PO000254", "ShipmentDate": "07/12/18", "ExpArrivalDate": null, "ShipFrom": { "ShipFromCode": null, "ShipFromName": "Pending RFQ", "ShipFromName2": null, "ShipFromAddr1": null, "ShipFromAddr2": null, "ShipFromCity": null, "ShipFromState": null, "ShipFromZip": null, "ShipFromCountry": null }, "Carrier": { "CarrierCode": null, "CarrierName": null }, "Container": null, "ProNumber": null, "Warehouse": "MAIN", "HdrUser1": null, "HdrUser2": null, "HdrUser3": null, "HdrUser4": null, "HdrUser5": "PURCHASE ORDER", "ShipFromRef": null, "TotalQtyDeclared": "1", "Temperature": "0", "MasterDocumentNumber": null, "RectLine": { "ItemNumber": "B-1", "DeclaredQty": "1", "UOM": "EACH", "ItemDesc1": "Big Book Hardcover 4th Edition", "ItemDesc2": null, "SubPart1Number": null, "SubPart2Number": null, "LineReference": "1", "LineUser1": null, "LineUser2": null, "LineUser3": null, "LineUser4": null, "LineUser5": null, "Pack1": "20", "Pack2": null, "UnitWeight": "1.6", "TareWeight": null, "Length": null, "Width": null, "Height": null, "Volume": null, "Category": "PRINTED MATERIALS", "Lot": null, "CodeDate": null, "GrsWeight": "1.6", "NetWeight": null, "DetailRef": null, "SubLot": null, "TagID": null, "Attribute1": null, "Attribute2": null, "Attribute3": null, "Attribute4": null, "Attribute5": null, "Attribute6": null } }, { "DepositorCode": "A400", "ReferenceNumber": "PO000253", "ShipmentDate": "07/12/18", "ExpArrivalDate": null, "ShipFrom": { "ShipFromCode": null, "ShipFromName": "Pending RFQ", "ShipFromName2": null, "ShipFromAddr1": null, "ShipFromAddr2": null, "ShipFromCity": null, "ShipFromState": null, "ShipFromZip": null, "ShipFromCountry": null }, "Carrier": { "CarrierCode": null, "CarrierName": null }, "Container": null, "ProNumber": null, "Warehouse": "MAIN", "HdrUser1": null, "HdrUser2": null, "HdrUser3": null, "HdrUser4": null, "HdrUser5": "PURCHASE ORDER", "ShipFromRef": null, "TotalQtyDeclared": "5", "Temperature": "0", "MasterDocumentNumber": null, "RectLine": { "ItemNumber": "AMHAP-2", "DeclaredQty": "5", "UOM": "EACH", "ItemDesc1": "Amharic - 44 Questions", "ItemDesc2": null, "SubPart1Number": null, "SubPart2Number": null, "LineReference": "1", "LineUser1": null, "LineUser2": null, "LineUser3": null, "LineUser4": null, "LineUser5": null, "Pack1": "250", "Pack2": null, "UnitWeight": "0.076", "TareWeight": null, "Length": null, "Width": null, "Height": null, "Volume": null, "Category": "PRINTED MATERIALS", "Lot": null, "CodeDate": null, "GrsWeight": "0.38", "NetWeight": null, "DetailRef": null, "SubLot": null, "TagID": null, "Attribute1": null, "Attribute2": null, "Attribute3": null, "Attribute4": null, "Attribute5": null, "Attribute6": null } }, { "DepositorCode": "A400", "ReferenceNumber": "PO000260", "ShipmentDate": "07/12/18", "ExpArrivalDate": null, "ShipFrom": { "ShipFromCode": null, "ShipFromName": "Pending RFQ", "ShipFromName2": null, "ShipFromAddr1": null, "ShipFromAddr2": null, "ShipFromCity": null, "ShipFromState": null, "ShipFromZip": null, "ShipFromCountry": null }, "Carrier": { "CarrierCode": null, "CarrierName": null }, "Container": null, "ProNumber": null, "Warehouse": "MAIN", "HdrUser1": null, "HdrUser2": null, "HdrUser3": null, "HdrUser4": null, "HdrUser5": "PURCHASE ORDER", "ShipFromRef": null, "TotalQtyDeclared": "1", "Temperature": "0", "MasterDocumentNumber": null, "RectLine": { "ItemNumber": "B-1", "DeclaredQty": "1", "UOM": "EACH", "ItemDesc1": "Big Book Hardcover 4th Edition", "ItemDesc2": null, "SubPart1Number": null, "SubPart2Number": null, "LineReference": "1", "LineUser1": null, "LineUser2": null, "LineUser3": null, "LineUser4": null, "LineUser5": null, "Pack1": "20", "Pack2": null, "UnitWeight": "1.6", "TareWeight": null, "Length": null, "Width": null, "Height": null, "Volume": null, "Category": "PRINTED MATERIALS", "Lot": null, "CodeDate": null, "GrsWeight": "1.6", "NetWeight": null, "DetailRef": null, "SubLot": null, "TagID": null, "Attribute1": null, "Attribute2": null, "Attribute3": null, "Attribute4": null, "Attribute5": null, "Attribute6": null } } ] } ] ] } <!-- end snippet -->
<javascript><arrays><sorting>
2019-01-04 09:54:09
LQ_EDIT
54,037,640
whats the time complexity of my algorithm// plz help me out finding the time complexity of my code
i want to know the time complexity of my code. Plz help me out with my algorithm...... whats the time complexity of my algorithm// plz help me out finding the time complexity of my code { int q; int w; cout <<"please enter values" <<endl; cin>>q; for(w = 0; w<q; w++) { int p; int o; int sum = 0; cin>>p; for(o = 0; o < p; o++) { int x; int y; int z; cin>>x ; cin >>y; cin>>z; sum = sum + (x*z); } cout<<sum<<endl; } _getch(); return 0; }
<algorithm><time-complexity>
2019-01-04 10:58:52
LQ_EDIT
54,038,468
I want to achieve similar background in react native but do not know how to do it?
<p><a href="https://i.stack.imgur.com/U40DM.png" rel="nofollow noreferrer">Here is the backround what i wanted to achieve</a></p>
<react-native>
2019-01-04 11:52:05
LQ_CLOSE
54,038,628
set the color of the toolbar dynamically
I get color using intent. I need to set this color dynamically in the toolbar. The Internet has found only such a solution, but it does not work. Error `java.lang.IllegalArgumentException: Unknown color` private long randomAndroidColor; randomAndroidColor = getIntent().getLongExtra(EXTRA_COLOR, 0L); getSupportActionBar().setBackgroundDrawable(new ColorDrawable(Color.parseColor(String.valueOf(randomAndroidColor))));
<android><android-toolbar>
2019-01-04 12:03:39
LQ_EDIT
54,040,189
How to get the list with the highest last value in a list of lists
<p>I'm trying to get the list which has the highest value in a list of lists. I have something like this:</p> <pre><code>Lists = [[0,7,6,8],[1,4,6,5], [12,1,8,3]] </code></pre> <p>And I want to retrieve the list that has the highest last value, first list in this case. How should I go about this?</p>
<python><max><nested-lists>
2019-01-04 13:47:16
LQ_CLOSE
54,040,768
In Flutter, How can I change TextFormField validation error message style?
<p>I want to set a bigger font size for error message validation in TextFormField but I don't know how.</p>
<flutter>
2019-01-04 14:21:57
HQ
54,041,375
can anyone help me finding alternative algorithm solution - without using sort()?
<pre><code>function areSimilar(a, b){ return a.sort().join('') === b.sort().join(''); } console.log(areSimilar([1, 2, 3], [1, 2, 3])); //true console.log(areSimilar([1, 2, 3], [2, 1, 3])); //true console.log(areSimilar([1, 2, 2], [2, 1, 1])); //false </code></pre> <p>Two arrays are called similar if one can be obtained from another by swapping at most one pair of elements in one of the arrays.</p> <p>Given two arrays a and b, check whether they are similar.</p> <p><strong>Example</strong></p> <ul> <li>For a = [1, 2, 3] and b = [1, 2, 3], the output should be areSimilar(a, b) = true.</li> </ul> <p>The arrays are equal, no need to swap any elements.</p> <ul> <li>For a = [1, 2, 3] and b = [2, 1, 3], the output should be areSimilar(a, b) = true.</li> </ul> <p>We can obtain b from a by swapping 2 and 1 in b.</p> <ul> <li>For a = [1, 2, 2] and b = [2, 1, 1], the output should be areSimilar(a, b) = false.</li> </ul>
<javascript><algorithm><performance><big-o>
2019-01-04 14:57:24
LQ_CLOSE
54,042,444
Can anybody explain why int x=1_000_000 is a valid and prints 1000000 instead throwing an error?
<p>int x = 100_000_5; System.out.println(x);</p> <p>Instead of throwing an error it prints the result 1000005. If this is a valid case what other abnormalities are there with Integer?</p>
<java><int>
2019-01-04 16:07:51
LQ_CLOSE
54,043,157
Deserialize property as a value to c#
<p>You can not undo the following json code for a class c # the property is not a name is an incremental code or identifier.</p> <p>server result.</p> <pre><code>{ "success": 0, "persona": { "1000": { "nombre": "Nombre 1", "apellido": "Apellido 1", "edad": 18 }, "1001": { "nombre": "Nombre 2", "apellido": "Apellido 2", "edad": 18 } } } </code></pre> <p>the server response could be converted to the next valid format.</p> <pre><code>{ "success": 0, "persona": [ { "id": "1000", "nombre": "Nombre 1", "apellido": "Apellido 1", "edad": 18 }, { "id": "1001", "nombre": "Nombre 2", "apellido": "Apellido 2", "edad": 18 } ] } </code></pre>
<c#><.net><json>
2019-01-04 16:58:54
LQ_CLOSE
54,046,105
i got this interview question and i am not sure what is best answer When in the lifecycle would you bind to events? in reactjs
<p>When in the lifecycle would you bind to events? in reactjs</p>
<reactjs>
2019-01-04 21:11:12
LQ_CLOSE
54,047,798
How to print in swift, response body instead of header?
My current code prints the header information, but I want the body response. I'm trying to obtain a token to use for another request. request.httpMethod = "GET" request.allHTTPHeaderFields = headers let session = URLSession.shared let dataTask = session.dataTask(with: request as URLRequest, completionHandler: { (data, response, error) -> Void in if (error != nil) { print(error!) } else { let httpResponse = response as? HTTPURLResponse print(httpResponse!) }}) dataTask.resume()
<swift><nsurlsession>
2019-01-05 00:18:20
LQ_EDIT
54,050,415
Hadoop Developer
I have MacOs when I install Hadoop I used this Command Sudo apt install hadoop-yarn-resourcemanager I got this error Unable to locate an executable at "/Library/Java/JavaVirtualMachines/jdk-11.0.1.jdk/Contents/Home/bin/apt"
<java><macos><hadoop>
2019-01-05 08:47:24
LQ_EDIT
54,050,429
Max running time
So i's trying to solve a problem and ive run into a bit of an issue So i have to find the running average of a series of numbers for input 4 2 7 output 4 3 4.3333 Now heres the problem although i get the answer its not the precise answer [accuracy difference shown in the image][1] i cant find whats wrong , some help would be highly appreciated ! #include<stdio.h> main(){ int n; printf("set:"); scanf("%d",&n); float arr[n],resarr[n]; float sum=0; for(int i=1; i<=n; i++){ scanf("%f",&arr[i]); sum=arr[i]+sum; float res= sum/(float)i; resarr[i]=res; } int i=1; while(i<=n){ printf("%0.10f\n",resarr[i]); i++; } return 0; } [1]: https://i.stack.imgur.com/REO0W.png
<c><average><precision>
2019-01-05 08:49:54
LQ_EDIT
54,051,001
assign address to a iterator
<p>AS we know that iterators in cpp points to a certain element of a container like if we talk about vector </p> <pre><code>vector &lt;int&gt; v = {1,2,3,4,5} vector&lt;int&gt;::iterator ptr; ptr=v.begin(); </code></pre> <p>Than ptr will point to first block of memory say 200 Let's declare another iterator</p> <pre><code>vector&lt;int&gt;::iterator ptrend; ptrend=v.end() which point to just next follow of last element say will be equal to 220 </code></pre> <p>My doubts</p> <p>1) And we know that <code>v.end()-v.begin() = v.size()</code> but which is not true in our case <code>220 -200 =20 != size</code></p> <p>2) Lets say <code>vector&lt;int&gt;::iterator ptr=v.begin();</code> here can we assign something like this <code>ptr = &amp;a[3]</code></p>
<c++><iterator>
2019-01-05 10:18:05
LQ_CLOSE
54,051,945
C Logical in If's And & Or with a numerical value
<p>I am making a project for my school about digital locks and using an accelerometer. But the buzzer won't buzz with my code. I think I have some issues in logical operations in if's. </p> <pre><code>void loop() { recordAccelRegisters(); if((gForceX || gForceY || gForceZ) &gt; 1) { tone(2, 2000); delay(1000); noTone(2); } Serial.print(gForceX); Serial.print(" "); Serial.print(gForceY); Serial.print(" "); Serial.print(gForceZ); Serial.println(); delay(100); </code></pre>
<c><arduino>
2019-01-05 12:19:55
LQ_CLOSE
54,053,407
Unable to parse json data from url
I am working on json data for my project. Json data is to be fetched from url. For http://example.com/q=x json data is {"X":{"USD":158.47}} http://example.com/q=y json data is {"Y":{"USD":145}} I have javascript file where I need to store the value (158.47 and 145)vto a variable to output it. I tried: 1) $.getJSON(url, function(json) { const prices=json.$x."USD"; $(`#${symbol}-price`).text(prices.toLocaleString()) }) 2) SONObject obj = new JSONObject(IOUtils.toString(new URL(url), Charset.forName("UTF-8"))); JSONObject prices = obj.getJSONObject(x); But none of them are working. Pls help.
<javascript><jquery><json><promise>
2019-01-05 15:25:50
LQ_EDIT
54,054,388
C# - Exception while copying the array using foreach loop
Can someone tell me why i'm seeing below exception when i use foreach loop ? { 6 2 3 4 5 6 Unhandled Exception: System.IndexOutOfRangeException: Index was outside the bounds of the array. at W3ResourceArrays.Ex7.Main() in C:\Users\SudhaPraveen\Documents\Visual Studio 2017\Projects\CSharpPractice21DaysPlan\W3ResourceArrays\Ex7.cs:line 28 } but i don't see this exception if i use for loop. One thing i have noticed is index is starting at 1 if i use foreach loop . int[] array1 = new int[] { 1, 2, 3 }; int[] array2 = new int[] { 4, 5, 6 }; int[] mergedarray = new int[array1.Length+array2.Length]; array1.CopyTo(mergedarray, 0); array2.CopyTo(mergedarray, array1.Length); Console.WriteLine(mergedarray.Length); //for (int i = 0; i < mergedarray.Length; i++) //{ // Console.WriteLine(mergedarray[i]); ; //} foreach (var item in mergedarray) { Console.Write(mergedarray[item] + " "); }
<c#>
2019-01-05 17:25:03
LQ_EDIT
54,054,687
Swift 4 - Find number in string and return location and length
`let myStr = "I have 4.34 apples."` I need the location range and the length, because I'm using NSRange(location:, length:) to bold the number 4.34 extension String{ func findNumbersAndBoldThem()->NSAttributedString{ //the code } }
<swift><numbers><find><return><location>
2019-01-05 17:58:33
LQ_EDIT
54,055,026
Where would I put the .title function in order for the final output to have the words beginning with a capital letter?
<p>I know this is probably a simple problem but as a beginner I thought I would ask. I have created a simple Python script to run through terminal where, after being asked three questions, the user will be given an output with it all in. I would like to add to this by capitalising all words answered and I know I could use the .title function but im not sure where to put it. any help would be much appreciated.</p> <pre><code>#ask user for age name = input('What is your name?: ') print(name) #ask user age age = input('How old are you?: ') print(age) #ask user for city city = input('What city were you born in?: ') print(city) #ask user what they enjoy hobby = input('What do you enjoy doing in your spare time?: ') print(hobby) #create output text string = 'Your name is {} and you are {} years old. you were born in {} and you enjoy {}' output = string.format(name, age, city, hobby) #print output to screen print(output) </code></pre>
<python><input>
2019-01-05 18:33:51
LQ_CLOSE
54,055,194
How to secure a php connect file with database passwords
<p>I want to know how to secure a php file that has the <strong><em>database connect</em></strong> passwords (info). </p> <p>Currently I have just saved the file as <strong><em>connect.php</em></strong> because it is stored locally but now I need to upload the application and make it live. </p>
<php><passwords><content-management-system>
2019-01-05 18:54:03
LQ_CLOSE
54,057,600
Extract float numbers from string in python
<p>i want to extract the numbers from the <strong>following string</strong>:</p> <p>FRESENIUS44.42 BAYER64.90 FRESENIUS MEDICAL CARE59.12 COVESTRO45.34 BASF63.19</p> <p>I've tried the following approach but that didn't work:</p> <pre><code>l = [] for t in xs.split(): try: l.append(float(t)) except ValueError: pass </code></pre> <p>The <strong>result</strong> should be 44.42 64.90 59.12 45.34 63.19</p> <p>Thank you!</p>
<python>
2019-01-06 00:29:11
LQ_CLOSE
54,058,501
Issue running batch file in c# winforms app
As part of my program I need to run a batch file, the person I'm doing it for doesn't want anyone to be able to view the batch script, so I tried to include it in the winforms solution, but I can't get it to run, I just get a time out error
<c#><winforms><batch-file>
2019-01-06 03:53:43
LQ_EDIT
54,058,505
How to use Join query between CTE and two table.?
I want to use a join query in cte between two table Employee Details and second one is Machine Attendance,but getting confuse how it will use.? ;With CTE As ( `select ed.EmpName from EmployeeDetails ed)` `,cte1;` `AS` `( SELECT ma.EmpID, CAST(MA.Datetime as Date) AS [Date], CASE WHEN MA.INOUT = 1 THEN DateTime END AS INOUT_INTIME, CASE WHEN MA.INOUT = 2 THEN DateTime END AS INOUT_OUTTIME From MachineAttendance MA ), cte2 ` `as ( select EmpID, [Date], MAX(INOUT_INTIME) AS INTIME, MAX(INOUT_OUTTIME) AS OUTTIME , DATEDIFF(Hour, MAX(INOUT_INTIME), MAX(INOUT_OUTTIME)) as [Hours] FROM CTE1 GROUP BY EmpID, [Date] ) select EmpID, [Date], INTIME, OUTTIME, [Hours] , CASE WHEN [Hours] >= 8 THEN 1 WHEN [Hours] = 0 THEN 0 WHEN [Hours] >= 6 THEN 0.5 END AS [Day], CASE WHEN [Hours] > 8 then [Hours] - 8 else 0 End as OT, CASE WHEN [Hours] >= 8 then ([Hours] - 8) * 100 else 0 END AS OTAMount, Convert(varchar(10),Date,120) as [Date], Convert(varchar(10),INTIME,108) as [Time], Case When Convert(Time,INTIME,108) > '09:10' Then 1 else 0 end as Late from cte2 INNER Join cte On cte.EmpID=cte2.EmpID`
<sql><sql-server><join>
2019-01-06 03:55:25
LQ_EDIT
54,059,098
mysql select count long query time
3 million table records, select count query time is 0.6 seconds 3.2 million table records, select count query time is 8.4 seconds (200,000 new records) 3 million table records, select count query time is 8.4 seconds (delete 200,000 records) 1.2 million table records, select count query time is 9.7 seconds (more than 200,000 records deleted) Data are normal when they are less than 3 million. Insert 200,000 data at a time, execute multiple times, and delete tests. Mysql5.6, windows10 select count(1) from t_node; delete from t_Node limit 200000; insert into t_node select * from t_node limit 200000; i want select count query time < 1s
<mysql><database><bigdata>
2019-01-06 06:09:02
LQ_EDIT
54,059,622
infinite loop in the first function dont know how to fix
<p>Keep getting stuck in an infinite loop dont know where my logic went wrong</p> <p>used while eof and dont know what else is missing, also break statement didnt do anything but print out my test statement once </p> <pre><code>void readSetupData(string sfile, string efile, string afile, students studArray[]) { ifstream inS(sfile.c_str()); ifstream inA(afile.c_str()); ifstream inE(efile.c_str()); int numStudents = 0; while (!inS.eof()) { cout &lt;&lt; "BEEP" &lt;&lt; endl; int id; int examScore; string name; inS &gt;&gt; name &gt;&gt; studArray[numStudents].id &gt;&gt; studArray[numStudents].name; int examId; inE &gt;&gt; id &gt;&gt; examId &gt;&gt; examScore; int studentIndex = findStudent(id, studArray); int examIndex = findExam(examId, studArray[studentIndex].examArray); studArray[studentIndex].examArray[examIndex].pointsScored = examScore; int pointsAvail = studArray[studentIndex].examArray[examIndex].pointsAvail; studArray[studentIndex].examArray[examIndex].percentage = (float)examScore / (float)pointsAvail; } while (!inA.eof()) { int id; int assignId; int assignScore; inA &gt;&gt; id &gt;&gt; assignId &gt;&gt; assignScore; int studentIndex = findStudent(id, studArray); int assignIndex = findAssignment(assignId, studArray[studentIndex].assignArray); studArray[studentIndex].assignArray[assignIndex].pointsScored = assignScore; } } </code></pre> <p>the first void function is the problem and the test statement BEEP is repeated when compiled and ran with ./a.out student_info.txt exam_info assignment_info.txt exam_scores.txt assignment_scores grades.out </p>
<c++><while-loop><infinite-loop><infinite>
2019-01-06 07:50:07
LQ_CLOSE
54,059,781
Color change agter swift migration to swift 4.2
I upgraded my swift project to swift 4.2 and a very strange change occurred. The white color of my button became blue. In the story board, the color remains white but when I run the application, the color turns blue. I do not know what I have to do so any one with guidance should kindly put me through.
<ios><swift>
2019-01-06 08:17:10
LQ_EDIT
54,059,902
How to call a method from adapter in activity?
<p>I just want to call a method (which is declared in an adapter) from an activity . Is there any possible way to do it? </p>
<android><android-activity><adapter>
2019-01-06 08:38:14
LQ_CLOSE
54,061,365
Angualr js , submit dynamic value for reactive form
In the below code i am trying to submit 3 values , rid , amount and reason on form submit . <div class="row " *ngFor="let pendingrequest of pendingrequests" > <form [formGroup]="pf" (ngSubmit)="onSubmit()"> <div class="col" > <input type="hidden" formControlName="rid" name="requestid" value="{{pendingrequest.id}}" /> RNuo. : {{pendingrequest.id}} </div> <div class="row"> <div class="col"> <input type="number" formControlName="amount" class="form-control" id="exampleInputEmail1" aria-describedby="emailHelp" placeholder="Amount"> </div><div class="col"> <input type="text" formControlName="reason" class="form-control" id="exampleInputPassword1" placeholder="Reason"> </div><div class="col"> <button type="submit" class="btn btn-primary">Submit</button> </div> </div> </form> </div> I am retreiving the value on the component as : var rid = this.pf.get('rid').value ; var amount = this.pf.get('amount').value ; var reason = this.pf.get('reason').value ; I am getting Amount and Reason properly but not the rid values , which is already known to the form . It need not to be submitted , thats why i kept the input type as "hidden" for rid. Please let me know how to get this rid value at the component.
<angular><typescript>
2019-01-06 12:12:09
LQ_EDIT
54,062,299
How to count how many times a word appears in a list in python
<p>I have the following list in python</p> <pre><code>texts = [ ["great", "even", "for", "the", "non", "runner", "this", "sound", "track", "was", "brilliant"], ["cannot", "recommend", "as", "a", "former", "comrade", "i", "did", "not", "want", "to", "have", "to", "do", "this"] ] </code></pre> <p>and I want to go through the list and count how often each word appears in it.</p> <p>I have tried counting the individual words using <code>length()</code> and I get a <code>2</code> as a result which means it does not work.</p> <p>Is there any way I can count how often a word appears in a list as I intend storing the counted word in a new list and it's frequency in another list.</p> <p>Thanks in advance </p>
<python><python-3.x>
2019-01-06 14:07:08
LQ_CLOSE
54,062,457
Collectors.toMap vs. Collectors.groupingBy - toMap problem with not unique key in provided data
Code snippet: ------------- Map<Integer, Map<String, Integer>> collect = shopping.entrySet() .stream() .collect(Collectors.toMap/*groupingBy? */(e -> e.getKey().getAge(), e -> e.getValue().entrySet().stream().collect(Collectors.groupingBy(b -> b.getKey().getCategory(), Collectors.summingInt(Map.Entry::getValue))))); The problem comes from a fact, that the provided data **contains multiple values by key** - there are Clients with same ages, and the code works only for a single value by key. How could I make this code work also for multiple keys. I suppose it should be somehow changed to use collect `collect(Collectors.groupingBy)` -> Map<Integer, Map<String, Integer>> collect = shopping.entrySet() .stream() .collect(Collectors.groupingBy(/*...*/)) Shopping is basically a map: `Map <Client, Map <Product,Integer>>`, **Integer** indicates the number of product bought by specified Client
<java><java-stream>
2019-01-06 14:24:21
LQ_EDIT
54,063,482
Python - A better way for mylist[2][1][3] = mylist[2][1][3] + 1
I have the following code: mylist[2][1][3] = mylist[2][1][3] + 1 `mylist` is a list which contains numbers, and I want to add 1 to a specific number within that list. To change the number, however, I need to type `mylist[2][1][3]` multiple times, once on both sides of the `=` Is there a better way to write this code, since it makes it more unreadable once you have different variable names Current code: myDataID7[myDataID5[3][6]][myDataID3][7][4][1]] = myDataID7[myDataID5[3][6]][myDataID3][7][4][1]] + 1 Ideal code: something = myDataID7[myDataID5[3][6]][myDataID3][7][4][1]] something = something + 1
<python><python-3.x>
2019-01-06 16:19:41
LQ_EDIT
54,065,378
How to use echo with PHP's array_reverse() Function
<p>I'm not a big fan of using print_r and I prefer to use echo all the time when I can so how can I use echo with PHPs array_reverse() function </p> <p>This how the docs look like most of the time online they use print_r all the time for example</p> <pre><code>&lt;?php $a=array("a"=&gt;"Volvo","b"=&gt;"BMW","c"=&gt;"Toyota"); print_r(array_reverse($a)); ?&gt; </code></pre> <p>I tried to use echo with this example but it does not work with echo.</p> <pre><code>&lt;?php $a=array("a"=&gt;"Volvo","b"=&gt;"BMW","c"=&gt;"Toyota"); echo array_reverse($a); ?&gt; </code></pre> <p>So how can I get it to work with echo?</p>
<php>
2019-01-06 19:58:29
LQ_CLOSE
54,066,057
creating inteval object in r using lubridate package
<p>hi i have data from uber : <a href="https://i.stack.imgur.com/qZaKs.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/qZaKs.png" alt="enter image description here"></a></p> <p>about pick ups in NYC . im trying to add a column to the raw data, that indicates for each row, for which time interval (which is represented by a single timepoint at the beginning of thetime interval) it belongs. </p> <p>i want to Create a vector containing all relevant timepoints (i.e. every 15 minutes Use int_diff function from lubridate package on this vector to create an interval object. Run a loop on all the time points in the raw data and for each data point; indicate to which interval (which is represented by a single timepoint at the beginning of the time interval) it belongs. </p> <p>i tried looking for explanations how to use the int_diff function but i dont understand how my vector should look and how the syntax of int_diff works tanks for the help :)</p>
<r><database><time><intervals><lubridate>
2019-01-06 21:20:39
LQ_CLOSE
54,068,002
why is the output of System.out.println((5/2.0)*2); is 5.0?
<p>I think 5 is an int. But there are no variables. I don't know why the output is a double. I tried in Netbeans already.</p>
<java>
2019-01-07 02:45:58
LQ_CLOSE
54,068,110
Capture File and Folder Opening events in C#
I have a friend who live in HOSTEL, his roommates aren’t very trustworthy people, he said to me, to make something for him, so that He could know which files and folders were opened in his absence by his roommates? _(They have a mutual agreement of not opening someone personal folders)_ _(He is supposed to share PC and can’t hide or encrypt his personal folders)_ So I decided to go with C# because my friend is using Windows OS. So The task is to make a Windows Form Application that will logs name and location of every file and folder opened by user _(in file or DB doesn’t matter)_ during the application running time. I know there is a class of `FileSystemWatcher` but it only has four events of Changed, Created, Deleted & Renamed which I don’t need at all, It doesn’t matter if your is changing or deleting or creating or renaming something, all it does matter is which files & folders are opened by user ...? If it could be done in Java I am also ready to give it a shot, just point me in the right direction !!
<java><c#><file><logging><filesystems>
2019-01-07 03:05:50
LQ_EDIT
54,068,787
How to make an customized push notification message for weather app in android studio
<p>How to make an customized push notification message for weather app </p> <pre><code> Android Studio </code></pre> <p>Eg: if the climate is rainy that is 22 degree we want to send a message as a push notification "Take An Umbrella With You"</p>
<java><android-studio>
2019-01-07 05:04:21
LQ_CLOSE
54,070,271
How global scope works in javascript
<pre><code> var a = 10 function fun(){ var b = 20 } fun() </code></pre> <p>In this code var a has global scope but var b dont have global scope but functional scope. But as fun() itself is global function which will be global to everywhere why var b is not global</p>
<javascript><variables><scope>
2019-01-07 07:39:08
LQ_CLOSE
54,070,698
Is there any software can help assure the quality in c++ code?
<p><strong>Is there any software can help assure the quality in c++ code?</strong></p> <p>the software can check the code and report some bad code with warnings.</p> <p><strong>For example:</strong></p> <p>the length of function should less than 50 lines.</p> <p>the input variable of function should less than 5.</p> <p>the name of variable is not obey the camel-case.</p> <p>thanks!</p>
<c++><qa>
2019-01-07 08:17:02
LQ_CLOSE
54,072,104
Why removing second last element from arraylist remove method doesn't throw ConcurrentModificationException ?
List<Integer> number = new ArrayList<Integer>(); number.add(11); number.add(45); number.add(12); number.add(32); number.add(36); number.removeIf(num -> num % 2 == 0); System.out.println(number); Why the above code not throws ConcurrentModificationException?
<java>
2019-01-07 09:59:27
LQ_EDIT
54,072,626
Used List<MapPdf> to var
I have a program that I used a variable of type List<MapPdf> that I will detach in variables when filling I would like to have the possibility to use it another time but I did not have the right to identify it again as <MapPdf> public static void Create(List<MapPdf> pps, Saison s, Agence agence) { foreach (var pelerins in grouped) { if (string.IsNullOrEmpty(pelerins.Key) || pelerins.Count() <= 0) break; if (writer.PageEvent == null) { writer.PageEvent = new Header_List() { travel = ctx.Travels.Include("Transport").First(v => v.UniqueId == pelerins.Key), travelretour = ctx.Travels.Find(pelerins.First().UniqueIdRetour), Agence = agence, CountAllPelerin = pelerins.Count().ToString(), CountFeminin = pelerins.Count(x => x.Sexe == PelerinSexe.Feminin).ToString(), CountMasculin = pelerins.Count(x => x.Sexe == PelerinSexe.Masculin).ToString(), NomGroupe = pelerins.First().Groupe, NumeroDoc = writer.PageNumber }; } } } And i want to use pls as a List<MapPdf> when i used in another function when it is of this declaration CreateFr(pls, false, cb, s); I used List < MapPdf > pls = pelerins.ToList(); but it does not work
<c#><wpf><data-binding>
2019-01-07 10:32:00
LQ_EDIT
54,072,688
What if in java I override "equals()" but not hashCode()?
<p>[Core java programming] says if I overrides Object.equals(), then I should override Object.hashCode() at the same time.</p> <p>This is quite odd to me, if I don't override hashCode() at the same time, is there any possibility that something wrong could happen in logic?</p> <p>Would you help to give such an example to indicate?</p> <p>Thanks a lot.</p>
<java><object><overriding><equals><hashcode>
2019-01-07 10:35:42
LQ_CLOSE
54,073,740
How to take array members and put them in HTML divs one by one?
<p>I have an array: ["5","4","2"].</p> <p>How can I put them in DIV elements so that the first DIV will have 5 in it, second 4, third 2 and so on.</p>
<javascript><jquery><html><arrays>
2019-01-07 11:40:43
LQ_CLOSE
54,073,915
how to generate the series 'a','a',1,2,3,4,5,7,9,11 using R technology with rep and seq functions
<p>Below is the series need to get using R with rep and seq series : 'a','a',1,2,3,4,5,7,9,11</p> <pre><code>I am Leaning R as beginner. Please try to help me on the above query </code></pre>
<r>
2019-01-07 11:51:14
LQ_CLOSE
54,074,305
This code doesnt seem to run when compiled
I am creating a program in Java for a restaurant. I am using Array List but for some reason my starter class doesn't seem to run in the main menu. This is my starter class. import java.util.ArrayList; `public class Starter` `{` Starter() { String[] myList = {"Coffee", "Tea", "Somosas", "Cake"}; //System.out.println(myList[]); } `}` this seems to be correct but when i try to choose from the Main menu it doesn't seem to work. Main Menu ` import java.util.Scanner; ` `import javax.swing.*;` `import java.awt.*;` `import java.awt.event.*;` `public class Menu` { static Scanner input = new Scanner(System.in); ` public static void main(String[]args)` `{ System.out.println("1=Starter"); System.out.println("2= Main Course"); System.out.println("3=Desert");` int a =input.nextInt(); input.nextLine(); if(a==1) { System.out.println("Starter"); Starter OS1=new Starter(); System.out.println("Your starter is "+OS1.myList[]); } The error i get is '.class' expected `System.out.println("Your starter is "+OS1.myList[]);` How to fix this?
<java><compiler-errors>
2019-01-07 12:17:23
LQ_EDIT
54,074,490
How to replace characters in the same position in each line of a text with natural numbers?
<p>I have a multi-line repeating text like this, each line is same.</p> <pre><code>aaa0bbb aaa0bbb ... aaa0bbb </code></pre> <p>How can I change it to</p> <pre><code>aaa0bbb aaa1bbb ... aaa2bbb </code></pre> <p>I tried to use awk or sed to handle it, but it's hard to me.</p>
<bash><awk><sed>
2019-01-07 12:30:28
LQ_CLOSE