Id int64 34.6M 60.5M | Title stringlengths 15 150 | Body stringlengths 33 36.7k | Tags stringlengths 3 112 | CreationDate stringdate 2016-01-01 00:21:59 2020-02-29 17:55:56 | Y stringclasses 3 values |
|---|---|---|---|---|---|
57,459,727 | Why an ObservedObject array is not updated in my SwiftUI application? | <p>I'm playing with SwitUI, trying to understand how ObservableObject works. I have an array of Person objects. When I add a new Person into the array, it is reloaded in my View. However, if I change the value of an existing Person, it is not reloaded in the View </p>
<pre><code>// NamesClass.swift
import Foundation
import SwiftUI
import Combine
class Person: ObservableObject,Identifiable{
var id: Int
@Published var name: String
init(id: Int, name: String){
self.id = id
self.name = name
}
}
class People: ObservableObject{
@Published var people: [Person]
init(){
self.people = [
Person(id: 1, name:"Javier"),
Person(id: 2, name:"Juan"),
Person(id: 3, name:"Pedro"),
Person(id: 4, name:"Luis")]
}
}
</code></pre>
<pre><code>struct ContentView: View {
@ObservedObject var mypeople: People
var body: some View {
VStack{
ForEach(mypeople.people){ person in
Text("\(person.name)")
}
Button(action: {
self.mypeople.people[0].name="Jaime"
//self.mypeople.people.append(Person(id: 5, name: "John"))
}) {
Text("Add/Change name")
}
}
}
}
</code></pre>
<p>If I uncomment the line to add a new Person (John), the name of Jaime is shown properly. However if I just change the name, this is not shown in the View.</p>
<p>I'm afraid I'm doing something wrong or maybe I don't get how the ObservedObjects work with Arrays.</p>
<p>Any help or explanation is welcome!</p>
| <swiftui> | 2019-08-12 10:43:10 | HQ |
57,463,744 | If input says x and y then print | Hi I'm trying to get this example code to work:
a = ("good ")
b = ("morning")
z = input("Hi: ")
z
if z == "hello":
print("good day!")
elif z == a and b:
print("Good Night")
else:
print("nope")
so I want it to print "Good Night" if the typed input is good morning (a and b) but it's not doing that, instead it's printing "nope", what's the mistake I'm doing?
| <python><string><concatenation> | 2019-08-12 15:05:55 | LQ_EDIT |
57,463,944 | the pointers to some c-strings, declared and defined in a function, are no longer valid when the program retunrs from that function. Why? | <p>I want to initialize a program with some configuration data. It receives them as an url-encoded json via argv[], decodes and deserializes them and hand them to a method inside a class, that is supposed to set the relevant variables to the submitted values.</p>
<p>The variables have the type c-string, so i do the conversion first before assigning the values to the variables declared outside the method.
If reading out those newly set values from the pointers, everything is fine, as long as i am staying inside this method. Upon leaving it, the variables with their values set from the handed configuration data do contain garbage only, while the one filled from the string literal is perfectly ok.</p>
<p>I printed out information about the variables type (typeid().name()). While they are not necessarily human readable, comparison between shows, that they all are of the type they are supposed to be. Next is compared the values of the pointers inside and out side the method - they were the same.</p>
<pre class="lang-cpp prettyprint-override"><code>/* Config.cpp */
using json = nlohmann::json;
const char *Config::DB_HOST;
const char *Config::DB_USER;
const char *Config::DB_PASSWORD;
const char *Config::DB_NAME;
const char *Config::DB_SOCK;
Config::Config() {}
void Config::initDB(json dbConfig) {
string host = dbConfig["host"];
DB_HOST = host.c_str();
string user = dbConfig["user"];
DB_USER = user.c_str();
string pass = dbConfig["pass"];
DB_PASSWORD = pass.c_str();
string name = dbConfig["name"];
DB_NAME = name.c_str();
DB_SOCK = "/var/run/mysqld/mysqld.sock";
}
</code></pre>
<p>I am especially puzzled about the differences between the values set by the variables and the value set by the string literal. The first fails, the latter works. Whats the difference between them? After some reading in the forum i had the understanding, c_str() should return exactly the same data type (a null-terminated pointer to the data) as the literal.</p>
<p>Thanks for your hints!</p>
| <c++><pointers><c-strings> | 2019-08-12 15:19:06 | LQ_CLOSE |
57,464,154 | Python and Regex - Replace Date | <p>I have multiple strings in the form of : </p>
<pre><code>AM-2019-04-22 06-47-57865BCBFB-9414907A-4450BB24
</code></pre>
<p>And I need the month from the date part replaced with something else, for example:</p>
<pre><code>AM-2019-07-22 06-47-57865BCBFB-9414907A-4450BB24
</code></pre>
<p>How can I achieve this using python and regex?</p>
<p>Also, I have multiple text files that contain a line similar to this:</p>
<pre><code>LocalTime: 21/4/2019 21:48:41
</code></pre>
<p>And I need to do the same thing as above (replace the month with something else).</p>
| <python><regex> | 2019-08-12 15:33:04 | LQ_CLOSE |
57,464,240 | Is it possible to, with a C# program, get a list of PDF readers installed on a given PC? | <p>I need to list all the PDF readers available in a given PC.
I've found many ways to get the default one, or to get just the adobe acrobat, but I need to be able to list them all like:
Adobe Acrobat
Foxit
...</p>
| <c#> | 2019-08-12 15:39:00 | LQ_CLOSE |
57,465,036 | How to extract 3 integers from "v%d.%d.%d" string format? | <p>I'm trying to extract 3 numbers out of the semantic version string which has the following format: <code>"v%d.%d.%d"</code></p>
<p>Here's my example code:</p>
<pre><code>std::string myVersion = "v3.49.1";
int versionMajor, versionMinor, versionPatch;
getVersionInfo(myVersion, versionMajor, versionMinor, versionPatch);
std::cout << versionMajor << " " << versionMinor << " " << versionPatch << '\n';
</code></pre>
<p>The expected result:</p>
<pre><code>3 49 1
</code></pre>
<p>How can I design the function <code>getVersionInfo()</code>?</p>
<p>What would be the most elegant solution?</p>
| <c++> | 2019-08-12 16:37:15 | LQ_CLOSE |
57,465,190 | numbers present in an array | <p>i have a text file containing several lines of real numbers, I should count how many numbers are present in each line. My idea is to insert with a for loop each row inside an array of unknown size. But I don't know how to count how many numbers are present in each array per line of text. How could I do it? Thanks</p>
<pre><code>#define n 1000
#include <fstream>
#include <iostream>
using namespace std;
int main(){
ifstream in("input.txt");
ofstream out("output.txt");
for(int i=0; i<100; i++){
double* vec= new doule[n];
for(int j=0; j<n; j++)
in >> vec[j];
}
}
</code></pre>
| <c++><vector><file-io> | 2019-08-12 16:49:30 | LQ_CLOSE |
57,465,599 | SCSS formatter for angular 5 | <p>In our angular 5.2 project, we keep getting the below errors in scss files,</p>
<p><a href="https://i.stack.imgur.com/B9cED.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/B9cED.png" alt="SCSS erros related to spaces"></a></p>
<p>do we have a VS code plugin OR a Scss formatter which can take care these space issues in the scss??</p>
| <angular><sass> | 2019-08-12 17:25:04 | LQ_CLOSE |
57,465,968 | cannot use nil as type model.Article in return argument | <p>I have this function which is supposed to query database and return an <code>article</code> if found, and nil if the article is not found:</p>
<pre><code>func GetArticleBySlug(slug string) (model.Article, error) {
var err error
var article model.Article
err = database.SQL.Get(&article, "SELECT * FROM article WHERE slug=? LIMIT 1", slug)
if err != nil {
log.Println(err)
return nil, err //<- Problem here
}
return article, nil
}
</code></pre>
<p>Where <code>Article</code> is a struct defined in <code>model</code> package. </p>
<p>But I get this error:</p>
<pre><code>cannot use nil as type model.Article in return argument
</code></pre>
<p>How can I fix this?</p>
| <go> | 2019-08-12 17:54:46 | LQ_CLOSE |
57,465,973 | Go; call operator by name | what is the golang equivelent of python's `operator` package for calling builtin operators by name?
https://docs.python.org/3.4/library/operator.html
Meaning, how can I do something like
```
func f(op func(int, int)bool, a int, b int)
return op(a, b)
f(operators.LessThan, 1, 2) // true
``` | <go> | 2019-08-12 17:55:03 | LQ_EDIT |
57,467,376 | Converting UTC Time Field To Browser Time Using Momemnt.js | I'm receiving ONLY UTC time from my db like 02:10:12, I want to convert this time to users browser time.
I tried below links
https://stackoverflow.com/questions/32540667/moment-js-utc-to-local-time https://stackoverflow.com/questions/19401426/changing-the-utc-date-to-local-date-using-moment-js https://stackoverflow.com/questions/42596669/convert-utc-time-to-local-time-of-browser
but none of them worked for me since most of them work with datetime field, mine is only time type in my database.
What I want to do is this,if my db UTC time is 02:10:12 then using moment.js we detect users browser timezone and convert this UTC time to that time zone and show in UI. | <javascript><momentjs> | 2019-08-12 19:45:55 | LQ_EDIT |
57,467,508 | Value of type 'IndividualContact' has no subscripts Error Swift | Trying to sort the array of JSON objects in the array by "name" alphabetically. Gives error of "Value of type 'IndividualContact' has no subscripts" Not sure what that means. Any help is appreciated.
[Screenshot of Code][1]
[1]: https://i.stack.imgur.com/IpMvE.png | <json><swift><sorting> | 2019-08-12 19:56:31 | LQ_EDIT |
57,467,895 | How to instantiate a class within an C++ implementation file? | <p>I am trying to make use of some features of a third-party tool written in C++ and thought to just create a make file and include the sources of the tool. That was easy enough, but then I ran into some class declarations that were nested in an implementation file (*.cpp). </p>
<p>The problem is, I would like to make use of those class declarations but not sure how. I have this *.cpp file in a library now and would like to include AClass in my app sources and link against this library.</p>
<p>Here is an example of how the file (cclass.cpp) in this package is laid out.</p>
<pre><code>#include "cclass.h"
class AClass { ... };
int ClassC::getNumber()
{
AClass ac;
int num = ac.useIt();
return num;
}
</code></pre>
<p>Is there a way to include AClass in my app and have this app link against a library which has cclass.cpp in it?</p>
| <c++><c++11><c++14><c++17> | 2019-08-12 20:33:23 | LQ_CLOSE |
57,468,318 | I'm novice in python programming, and i have a issue that how can i re-written SSN such that the first five numbers are hidden from view? | I want to rewrite the SSN # such that the first five numbers are hidden from view.
The following csv file like the below :
Emp ID,Name,DOB,SSN,State
15,Samantha Lara,1993-09-08,848-80-7526,Colorado
expected data :
15,Samantha,Lara,09/08/1993,***-**-7526,CO
# create a list to store the data from csv file
empl_ssn = []
reform_ssn = row["3"]
reform_ssn = ........
I don't know how to modify it. | <python><regex><python-3.x><csv> | 2019-08-12 21:12:43 | LQ_EDIT |
57,469,322 | Are there potential performance penalties for `auto o = SomeType(args)` instead of `SomeType o(args)`? | <p>I'm a great fan of <code>auto</code> and prefer writing <code>auto o = SomeType(args)</code>.</p>
<p>It almost always results in calling a constructor only.</p>
<p>@NathanOliver <a href="http://wandbox.org/permlink/KVmWnL9NJ72rJ2fn" rel="nofollow noreferrer">showed</a> that <code>-fno-elide-constructors</code> is capable of turning off copy elision and resulting in a call to a constructor and an assignment operator.</p>
<p>Are there real-world cons of writing <code>auto o = SomeType(args)</code>?</p>
| <c++> | 2019-08-12 23:13:33 | LQ_CLOSE |
57,469,529 | How to validate username and navigate to another page | Trying to validate username and password
let passwordInput = document.getElementById('password').value;
let userName = document.getElementById('userName').value;
function validateLogin(){
event.preventDefault();
// Set errors to an empty array
let errors = [];
// Conditions for password validation
if(passwordInput.length < 8) {
errors.push('Your password must be at least 8 characters long')
}
if(passwordInput.search(/[a-z]/) < 0) {
errors.push('Your password must cotain at least one lowercase letter')
}
if(passwordInput.search(/[A-Z]/) < 0) {
errors.push('Your password must conatin at least one uppercase letter')
}
if(passwordInput.search(/[0-9]/) < 0) {
errors.push('Password must contain at least one number!')
}
if(passwordInput.search(/[\!\@\#\$\%\^\&\*\(\)\_\+\.\,\;\:\-]/) < 0) {
errors.push("Your password must contain at least one special character.")
}
// Login
if (errors.length > 0) {
document.getElementById("errors").innerHTML = errors.join("<br>")
return false;
} else if(!errors && userName.value){
console.log('Youre logged in!')
}
};
`` | <javascript> | 2019-08-12 23:47:26 | LQ_EDIT |
57,469,676 | python One hot encoding for comma separated values | <p>my dataset looks like this</p>
<pre><code>Type Date Issues
M 1 Jan 2019 A12,B56,C78
K 2 May 2019 B56, D90
M 5 Feb 2019 A12,K31
K 3 Jan 2019 A12,B56,K31,F66
.
.
.
</code></pre>
<p>I want to do one hot encoding for the issues column</p>
<p>so my dataset looks like this</p>
<pre><code>Type Date A12 B56 C78 D90 E88 K31 F66
M 1 Jan 2019 1 1 1 0 0 0 0
K 2 May 2019 0 1 0 1 0 0 0
M 5 Feb 2019 1 0 0 0 0 1 0
K 3 Jan 2019 1 1 0 0 0 1 1
.
.
.
</code></pre>
<p>How to do that in Python</p>
| <python><one-hot-encoding> | 2019-08-13 00:15:40 | LQ_CLOSE |
57,470,614 | how to use permission_send Manifest android inside subclass? | <p>I made an application using the tab navigation in android studio. On one of the tabs I want to make an SMS sending feature. I've added permissions to AndroidManifest.xml but the feature still won't work</p>
<p>This is My AndroidManifest.xml</p>
<pre><code><?xml version="1.0" encoding="utf-8"?>
<manifest xmlns:android="http://schemas.android.com/apk/res/android"
package="com.melani.dprdbkt">
<uses-permission android:name="android.permission.SEND_SMS" />
<uses-permission android:name="android.permission.INTERNET"/>
<uses-permission android:name="android.permission.ACCESS_WIFI_STATE"/>
<uses-permission android:name="android.permission.CHANGE_WIFI_STATE"/>
<application
android:allowBackup="true"
android:icon="@mipmap/ic_launcher"
android:label="@string/app_name"
android:roundIcon="@mipmap/ic_launcher_round"
android:supportsRtl="true"
android:theme="@style/AppTheme">
<activity android:name=".MainActivity">
<intent-filter>
<action android:name="android.intent.action.MAIN" />
<category android:name="android.intent.category.LAUNCHER" />
</intent-filter>
</activity>
<activity
android:name=".SendSMSActivity"
android:parentActivityName=".MainActivity" />
</application>
</manifest>
</code></pre>
<p>This is My MainActivity.java</p>
<pre><code>package com.melani.dprdbkt;
import android.os.Build;
import android.os.Bundle;
import android.support.design.widget.TabItem;
import android.support.design.widget.TabLayout;
import android.support.v4.content.ContextCompat;
import android.support.v4.view.ViewPager;
import android.support.v7.app.AppCompatActivity;
import android.support.v7.widget.Toolbar;
public class MainActivity extends AppCompatActivity {
Toolbar toolbar;
TabLayout tabLayout;
ViewPager viewPager;
PageAdapter pageAdapter;
TabItem tabHome;
TabItem tabBerita;
TabItem tabAgenda;
TabItem tabAnggota;
TabItem tabLink;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_main);
toolbar = findViewById(R.id.toolbar);
toolbar.setTitle(getResources().getString(R.string.app_name));
setSupportActionBar(toolbar);
tabLayout = findViewById(R.id.tablayout);
tabHome = findViewById(R.id.tabHome);
tabBerita = findViewById(R.id.tabBerita);
tabAgenda = findViewById(R.id.tabAgenda);
tabAnggota = findViewById(R.id.tabAnggota);
tabLink = findViewById(R.id.tabLink);
viewPager = findViewById(R.id.viewPager);
pageAdapter = new PageAdapter(getSupportFragmentManager(), tabLayout.getTabCount());
viewPager.setAdapter(pageAdapter);
tabLayout.addOnTabSelectedListener(new TabLayout.OnTabSelectedListener() {
@Override
public void onTabSelected(TabLayout.Tab tab) {
viewPager.setCurrentItem(tab.getPosition());
if (tab.getPosition() == 1) {
toolbar.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorHome));
tabLayout.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorHome));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(ContextCompat.getColor(MainActivity.this,
R.color.colorHome));
}
} else if (tab.getPosition() == 2) {
toolbar.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorBerita));
tabLayout.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorBerita));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(ContextCompat.getColor(MainActivity.this,
R.color.colorBerita));
}
}
else if (tab.getPosition() == 3) {
toolbar.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorAgenda));
tabLayout.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorAgenda));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(ContextCompat.getColor(MainActivity.this,
R.color.colorAgenda));
}
} else if (tab.getPosition() == 4) {
toolbar.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorAnggota));
tabLayout.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorAnggota));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(ContextCompat.getColor(MainActivity.this,
R.color.colorAnggota));
}
}
else {
toolbar.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorLink));
tabLayout.setBackgroundColor(ContextCompat.getColor(MainActivity.this,
R.color.colorLink));
if (Build.VERSION.SDK_INT >= Build.VERSION_CODES.LOLLIPOP) {
getWindow().setStatusBarColor(ContextCompat.getColor(MainActivity.this,
R.color.colorLink));
}
}
}
@Override
public void onTabUnselected(TabLayout.Tab tab) {
}
@Override
public void onTabReselected(TabLayout.Tab tab) {
}
});
viewPager.addOnPageChangeListener(new TabLayout.TabLayoutOnPageChangeListener(tabLayout));
}
}
</code></pre>
<p>Send SMSActivity.java</p>
<pre><code>package com.melani.dprdbkt;
import android.os.Bundle;
import android.telephony.SmsManager;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
public class SendSMSActivity extends MainActivity {
private static final int MY_PERMISSION_REQUEST_SEND_SMS=0;
private EditText txtMobile;
private EditText txtMessage;
private Button btnSms;
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.fragment_link);
txtMobile = (EditText)findViewById(R.id.editTextPhoneNo);
txtMessage = (EditText)findViewById(R.id.editTextSMS);
btnSms = (Button)findViewById(R.id.buttonSend);
btnSms.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v) {
try{
SmsManager smgr = SmsManager.getDefault();
smgr.sendTextMessage(txtMobile.getText().toString(),null,txtMessage.getText().toString(),null,null);
Toast.makeText(SendSMSActivity.this, "SMS Sent Successfully", Toast.LENGTH_SHORT).show();
}
catch (Exception e){
Toast.makeText(SendSMSActivity.this, "SMS Failed to Send, Please try again", Toast.LENGTH_SHORT).show();
}
}
});
}
}
</code></pre>
<p>linkFragment.java</p>
<pre><code>package com.melani.dprdbkt;
import android.os.Bundle;
import android.support.v4.app.Fragment;
import android.view.LayoutInflater;
import android.view.Menu;
import android.view.MenuInflater;
import android.view.MenuItem;
import android.view.View;
import android.view.ViewGroup;
import android.widget.Toast;
//import android.app.m
/**
* A simple {@link Fragment} subclass.
*/
public class LinkFragment extends Fragment {
@Override
public View onCreateView(LayoutInflater inflater, ViewGroup container,
Bundle savedInstanceState) {
// Inflate the layout for this fragment
setHasOptionsMenu(true);
return inflater.inflate(R.layout.fragment_link, container, false);
}
@Override
public void onCreateOptionsMenu(Menu menu, MenuInflater inflater) {
inflater.inflate(R.menu.menu_link, menu);
}
@Override
public boolean onOptionsItemSelected(MenuItem item) {
if (item.getItemId() == R.id.action_link) {
Toast.makeText(getActivity(), "Clicked on " + item.getTitle(), Toast.LENGTH_SHORT)
.show();
}
return true;
}
}
</code></pre>
<p>fragment_link.xml</p>
<pre><code><FrameLayout xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:tools="http://schemas.android.com/tools"
android:layout_width="match_parent"
android:layout_height="match_parent"
tools:context="com.melani.dprdbkt.LinkFragment">
<!-- TODO: Update blank fragment layout -->
<TextView
android:id="@+id/textViewPhoneNo"
android:layout_width="63dp"
android:layout_height="50dp"
android:layout_marginTop="10dp"
android:text="Ke : "
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<EditText
android:id="@+id/editTextPhoneNo"
android:layout_width="337dp"
android:layout_height="wrap_content"
android:layout_gravity="right"
android:layout_marginTop="0dp"
android:phoneNumber="true"></EditText>
<TextView
android:id="@+id/textViewSMS"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginTop="45dp"
android:text="Pesan : "
android:textAppearance="@style/TextAppearance.AppCompat.Medium" />
<EditText
android:id="@+id/editTextSMS"
android:layout_width="fill_parent"
android:layout_height="120dp"
android:gravity="top"
android:inputType="textMultiLine"
android:lines="5"
android:layout_marginTop="70dp"
/>
<Button
android:id="@+id/buttonSend"
android:layout_width="180dp"
android:layout_height="wrap_content"
android:layout_gravity="center_horizontal"
android:layout_marginTop="190dp"
android:text="Send" />
</FrameLayout>
</code></pre>
| <java><android><xml><android-studio><android-fragments> | 2019-08-13 03:03:48 | LQ_CLOSE |
57,470,812 | What is a webView exactly? | <p>I'm setting up a new business app that I want to get some infomation and a page from a website. I don't know how to get a webView to work and I can't find any tutorials that show how to use one. Can someone please show me how to activate a webView?</p>
| <ios><webview> | 2019-08-13 03:36:50 | LQ_CLOSE |
57,472,069 | Vertical aligning a <span> text in a header in React | <p>I have a react header component that looks like this:</p>
<pre><code>const Header = () => {
return (
<div className="navbar">
<div className="logo-container">
<img id='logo' alt='header-logo' src={Logo}/><span id="header-title">Dashboard</span>
</div>
</div>
);
}
export default Header;
</code></pre>
<p>The stylesheet for this component looks like</p>
<pre><code>.navbar {
height: 4em;
background-color: #f9f9f9;
width: 100%;
background: #00bceb;
}
#logo {
margin-left: 2em
}
#header-title {
display: inline-block;
vertical-align: middle;
margin-left: 0.5em;
color: #f9f9f9;
}
</code></pre>
<p><a href="https://i.stack.imgur.com/VpGf3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/VpGf3.png" alt="enter image description here"></a></p>
<p>(I'm hiding the logo)</p>
<p>The text is not middle aligned.</p>
<p>Any help?</p>
| <html><css><reactjs> | 2019-08-13 06:15:12 | LQ_CLOSE |
57,473,417 | Change text color while typing in angular | <p>I am working on a Note Taking application, Requirement is when user types the text, It should in Red color, If he wants the rest of the text to be in black color while typing that also has to be achieved</p>
| <angular> | 2019-08-13 07:54:37 | LQ_CLOSE |
57,473,534 | Attempted import error: 'addLocaleData' is not exported from 'react-intl' | <p>It's return error when i try this code </p>
<p>react-intl version 3.1.6 &&
react version 16.9</p>
<pre><code>import { IntlProvider, FormattedMessage , addLocaleData} from 'react-intl';
</code></pre>
| <reactjs><react-intl> | 2019-08-13 08:02:57 | HQ |
57,474,644 | second add to cart link | <p>in functions.php of my templatefolder, I add this code to be able to have a second link on the product page.</p>
<p>but the result is an error 500.</p>
<p>I guess the product id part is wrong. Does anybody see how to solve this?</p>
<p>Woocommerce Version 3.4.5</p>
<pre><code>
function my_extra_button_on_product_page() {
global $product;
echo '<a class="single_add_to_cart_button button alt" href="?add-to-cart'<?=$product->get_id() ?>'">Second Link</a>';
}
</code></pre>
<p>I expect that the link that gets generated, has the add-to-cart=['product_id'] of course with the correct Product_id </p>
<p>But I get error 500</p>
| <php><woocommerce> | 2019-08-13 09:17:53 | LQ_CLOSE |
57,475,849 | Getting an error while reversing vowels in a string | <p>I know there are similar questions about this topic but I wanted to know error in my approach.</p>
<p>I'm writing a code to reverse vowels in a string. I first took all the vowels of a string into a vector and then I looped the string from backwards by replacing the vowels but I keep getting an error.</p>
<pre><code>#include <iostream>
#include <algorithm>
#include <vector>
#include <string>
using namespace std;
string reverseVowels(string s)
{
vector<char>v;
vector<char>v2;
char c;
for (int i = 0; i < s.size(); i++)
{
//taking all the vowels of the string into a vector
if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u')
{
v.push_back(s[i]);
}
}
//reversing the vowels of the string
for (int i = s.size() - 1; i >= 0; i--)
{
if (s[i] == 'a' || s[i] == 'e' || s[i] == 'i' || s[i] == 'o' || s[i] == 'u')
{
s[i] = v[i]; //Getting an error here
}
}
return s;
}
int main()
{
//Required output is "holle"
string s = "hello";
string p = reverseVowels(s);
cout << p << endl;
return 0;
}
</code></pre>
| <c++><arrays><string><vector><data-structures> | 2019-08-13 10:27:52 | LQ_CLOSE |
57,476,533 | Why is statically linking glibc discouraged? | <p>Most of the sources online state that you can statically link glibc, but discourage from doing so; e.g. <a href="https://centos.pkgs.org/7/centos-updates-x86_64/glibc-static-2.17-260.el7_6.4.x86_64.rpm.html" rel="noreferrer">centos package repo</a>:</p>
<pre><code>The glibc-static package contains the C library static libraries
for -static linking. You don't need these, unless you link statically,
which is highly discouraged.
</code></pre>
<p>These sources rarely (or never) say why that would be a bad idea.</p>
| <c++><c><linker><glibc><static-linking> | 2019-08-13 11:10:53 | HQ |
57,476,635 | allocate memory in complecated objects | i have two classes, the first is myarray that have 2 filelds: size and int pointer. the class Supposed to make an array of size that was sent
the second class(list_of_my_aray) have two fileds, pointer my class and size
How do I build the non-default constructor of list_of_my_aray
class MyArray
{
public:
int size;
int* myArray;
MyArray();
MyArray(int size,int* arr);
};
class list_of_myArray
{
public:
int size;
MyArray* list;
GroupArray();
GroupArray(int size,MyArray*list);
}; | <c++><arrays> | 2019-08-13 11:16:36 | LQ_EDIT |
57,478,006 | what is the difference between "withRun" and "inside" in Jenkinsfile? | <p>I have a Jenkinsfile in which I am trying to execute <code>npm run test</code> inside a container.
When I run with <code>inside</code> it fails but when I run with <code>withRun</code> it runs as I want to.</p>
<p>Code for reference
with <code>inside</code></p>
<pre><code>stage('Test') {
docker.image('justinribeiro/chrome-headless').inside ("-p 9222:9222 --security-opt seccomp=$WORKSPACE/chrome.json") {
sh label:
'Running npm test',
script: '''
npm run test
'''
}
}
</code></pre>
<p>With <code>withRun</code></p>
<pre><code>stage('Test') {
docker.image('justinribeiro/chrome-headless').withRun ("-p 9222:9222 --security-opt seccomp=$WORKSPACE/chrome.json") {
sh label:
'Running npm test',
script: '''
npm run test
'''
}
}
</code></pre>
<p>Now I want to understand what is the difference between them.</p>
<p>I have observed that <code>inside</code> adds volumes and runs <code>cat</code> on container whereas <code>withRun</code> does not.</p>
<p>I also read the documentation <a href="https://jenkins.io/doc/book/pipeline/docker/" rel="noreferrer">https://jenkins.io/doc/book/pipeline/docker/</a> but did not understand well enough.</p>
<p>A much more detailed explanation will be much appreciated.</p>
<p>Thanks.</p>
| <docker><jenkins><jenkins-pipeline> | 2019-08-13 12:45:22 | HQ |
57,480,588 | How i can change the PickerStyle in SwiftUI like Embed in Form, but static and not scrollable? | I would like to have a picker who is like involved in form{}. it should look like it's a navigation link. that problem is if i program it into a form{}, then it is scrollable and i do not want that. I want to have it static.
or one knows a solution how to make forms static and not scrollable | <swift><swiftui><picker> | 2019-08-13 15:05:03 | LQ_EDIT |
57,480,994 | How can I send an SMS for free with python? | <p>I am trying to find a free API that allows me to send an SMS for free. I have not started programming the software yet, in case you needed to know</p>
<p>I have been searching online, but I can only find ones that cost money</p>
| <python><python-3.x><sms> | 2019-08-13 15:28:22 | LQ_CLOSE |
57,484,022 | Typescript how to move child nodes in array to parent array? | <p>Here is my json</p>
<pre><code>[{"Name":"Ancil Abdul Rahuman","map":{"Core Java":null,"JSP":null,"HTML":"Level 1: Proficient","JavaScript":null,"Spring MVC":null,"SOAP":null,"REST Web Services":null,"Oracle DB":null,"Tomcat":null}},{"Name":"Neha Agrawal","map":{"Core Java":null,"JSP":null,"HTML":null,"JavaScript":null,"Spring MVC":null,"SOAP":null,"REST Web Services":null,"Oracle DB":null,"Tomcat":null}}]
</code></pre>
<p>I need to move the items from the "map" array into the level where it says "Name"</p>
<p>I tried
to use map.map but it gives an error</p>
| <javascript><typescript> | 2019-08-13 19:12:25 | LQ_CLOSE |
57,484,817 | Comparing Two Hashmaps in Java | <p>What's the recommended approach for comparing hashmaps in Java for equality so that I can determine if they have identical keys and values?</p>
<pre><code>Map<String,List<String>> data1 = new HashMap<>();
data1.put("file1", Arrays.asList("one","two","three"));
Map<String,List<String>> data2 = new HashMap<>();
data2.put("file1", Arrays.asList("one","two","three"));
</code></pre>
| <java> | 2019-08-13 20:21:21 | LQ_CLOSE |
57,485,878 | Can someone explain why we use random_state when we split the data into training and testing? | <p>I've just started building models in Machine Learning and I was wondering why do we have t0 create a random_state variable when we split the data.</p>
| <python><validation><machine-learning><scikit-learn> | 2019-08-13 22:07:24 | LQ_CLOSE |
57,486,267 | What is the purpose of using the -i and -1 in the following: array[name.Length - i] = name[i - 1]; | <p>array[name.Length - i] = name[i - 1];</p>
<p>In the piece of code above, I understand that the purpose of it is is taking each letter of the name array and placing it into the array named array. What I am not sure about is the logical explanation as to what exactly the -i and the -1 is doing. Is this just syntax I have to memorize?</p>
<p>Thus far, I understand that the left side of the assignment state is indicating where the letters are going ( 1 letter a at time) while the right side is indicating where the letters are coming from (1 letter at a time). However, the reason for the structure is still not clear to me.</p>
<p>The purpose of the code is to ask the user to enter their name. Use an array to reverse the name and then store the result in a new string.
/// Display the reversed name on the console.</p>
<pre><code> {
Console.Write("What's your name? ");
var name = Console.ReadLine();
var array = new char[name.Length];
for (var i = name.Length; i > 0; i--)
array[name.Length - i] = name[i - 1];
var reversed = new string(array);
Console.WriteLine("Reversed name: " + reversed);
}
</code></pre>
| <c#><arrays> | 2019-08-13 22:58:57 | LQ_CLOSE |
57,488,548 | Array Object processing need a array with all Id exist in array object using JavaScript | <p>I have an array like this.</p>
<pre><code>[
{
"id": 13,
"name": "VA"
},
{
"id": 14,
"name": "NA"
},
{
"id": 15,
"name": "PA"
}
]
</code></pre>
<p>I need a new array with all id values like this [13,14,15]. Using javascript.</p>
| <javascript> | 2019-08-14 05:21:54 | LQ_CLOSE |
57,488,622 | converting csv to Json without pandas (python) | <p>I am a student and I have an assignment where I have to convert a csv file to Json format without using Pandas. Is there a way to achieve this in python?</p>
<p>Thank you,</p>
| <python><json><csv> | 2019-08-14 05:30:41 | LQ_CLOSE |
57,488,720 | How is the usage of constructors an implementation of data-hiding? | <p>I know what constructors are used for, and kinda know what data hiding means.... found <strong>absolutely no link</strong> among the two (im a dimwit, sedd).... please help?</p>
| <c++><data-hiding> | 2019-08-14 05:42:46 | LQ_CLOSE |
57,489,868 | how to calculate the difference between two columns with datatype timestamp | i am having a two columns login,logout with values "2019-08-07 20:37:12" in login column and "2019-08-07 21:14:16" in logout column.
i want the difference between time values from login and logout columns
sql
SELECT logintime,CONVERT(varchar(6),DATEDIFF(second, login, logout)/3600)
+ ':'
+ RIGHT('0' + CONVERT(varchar(2),(DATEDIFF(second, login,logout) % 3600) / 60), 2)
+ ':'
+ RIGHT('0' + CONVERT(varchar(2),DATEDIFF(second, login, logout) % 60), 2) AS 'HH:MM:SS' from face_login_logout
expected result is '2019-08-07 01:23:04 ' | <sql><sql-server><tsql><date-arithmetic><sqldatetime> | 2019-08-14 07:18:27 | LQ_EDIT |
57,492,546 | What is the difference between .js and .mjs files? | <p>I have started working on an existing project based on nodejs. I was just trying to understand the flow of execution, where I encountered with some .mjs files. I have searched the web where I found that these are module based JS files. </p>
<p>I want to know how is it different from .js files (how does it benefit) ?</p>
| <javascript><node.js><mjs> | 2019-08-14 10:04:31 | HQ |
57,493,774 | how to use Sql IN Statement with list of Items selected from treeviewlist? | how to join string values from "For Next Loop" into one single string
Private Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
Dim accid As String
Dim iLast As Integer
iLast = trv.Nodes.Count
Dim p As Integer = 0
For p = 0 To iLast - 1
If TrV.Nodes(p).Checked = True Then
accid = Strings.Left(TrV.Nodes(p).Text, 9)
MsgBox(accid)
End If
Next
End Sub
this give me seperate output of string "accid"
i want this output = "accid1,accid2,accid3"
thanks for supporting | <vb.net> | 2019-08-14 11:25:50 | LQ_EDIT |
57,495,819 | Detect AND, OR in the sentence and split it | <p>I have the following user queries:</p>
<pre><code>Boeing AND Airbus OR twitter
Boeing AND Airbus
</code></pre>
<p>I need to split words in them by AND, OR so, in the end, I will have something like this:</p>
<pre><code>"Boeing" AND "Airbus"
"Boeing" AND "Airbus" OR "twitter"
</code></pre>
<p>How can I do this with split or any other method? </p>
| <javascript> | 2019-08-14 13:33:14 | LQ_CLOSE |
57,496,094 | Getting errors when executing app in real device first time from Android Studio | <p>I have recently installed Android Studio and executing my first android app in real device but getting belows errors. </p>
<p>Can anyone please help me regarding this</p>
<blockquote>
<p>org.gradle.internal.exceptions.LocationAwareException: Could not
determine the dependencies of task ':app:processDebugResources'. at
org.gradle.initialization.exception.DefaultExceptionAnalyser.transform(DefaultExceptionAnalyser.java:99)
at
org.gradle.initialization.exception.DefaultExceptionAnalyser.collectFailures(DefaultExceptionAnalyser.java:65)
at
org.gradle.initialization.exception.MultipleBuildFailuresExceptionAnalyser.transform(MultipleBuildFailuresExceptionAnalyser.java:47)
at
org.gradle.initialization.exception.StackTraceSanitizingExceptionAnalyser.transform(StackTraceSanitizingExceptionAnalyser.java:29)
at
org.gradle.initialization.DefaultGradleLauncher.finishBuild(DefaultGradleLauncher.java:174)
at
org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:165)
at
org.gradle.initialization.DefaultGradleLauncher.executeTasks(DefaultGradleLauncher.java:134)
at
org.gradle.internal.invocation.GradleBuildController$1.execute(GradleBuildController.java:58)
at
org.gradle.internal.invocation.GradleBuildController$1.execute(GradleBuildController.java:55)
at
org.gradle.internal.invocation.GradleBuildController$3.create(GradleBuildController.java:82)
at
org.gradle.internal.invocation.GradleBuildController$3.create(GradleBuildController.java:75)
at
org.gradle.internal.work.DefaultWorkerLeaseService.withLocks(DefaultWorkerLeaseService.java:183)
at
org.gradle.internal.work.StopShieldingWorkerLeaseService.withLocks(StopShieldingWorkerLeaseService.java:40)
at
org.gradle.internal.invocation.GradleBuildController.doBuild(GradleBuildController.java:75)
at
org.gradle.internal.invocation.GradleBuildController.run(GradleBuildController.java:55)
at
org.gradle.tooling.internal.provider.runner.ClientProvidedBuildActionRunner.run(ClientProvidedBuildActionRunner.java:55)
at
org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at
org.gradle.launcher.exec.ChainingBuildActionRunner.run(ChainingBuildActionRunner.java:35)
at
org.gradle.launcher.exec.BuildOutcomeReportingBuildActionRunner.run(BuildOutcomeReportingBuildActionRunner.java:58)
at
org.gradle.tooling.internal.provider.ValidatingBuildActionRunner.run(ValidatingBuildActionRunner.java:32)
at
org.gradle.launcher.exec.BuildCompletionNotifyingBuildActionRunner.run(BuildCompletionNotifyingBuildActionRunner.java:39)
at
org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$3.call(RunAsBuildOperationBuildActionRunner.java:49)
at
org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner$3.call(RunAsBuildOperationBuildActionRunner.java:44)
at
org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:315)
at
org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:305)
at
org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
at
org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:101)
at
org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
at
org.gradle.launcher.exec.RunAsBuildOperationBuildActionRunner.run(RunAsBuildOperationBuildActionRunner.java:44)
at
org.gradle.launcher.exec.InProcessBuildActionExecuter$1.transform(InProcessBuildActionExecuter.java:49)
at
org.gradle.launcher.exec.InProcessBuildActionExecuter$1.transform(InProcessBuildActionExecuter.java:46)
at
org.gradle.composite.internal.DefaultRootBuildState.run(DefaultRootBuildState.java:78)
at
org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:46)
at
org.gradle.launcher.exec.InProcessBuildActionExecuter.execute(InProcessBuildActionExecuter.java:31)
at
org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:42)
at
org.gradle.launcher.exec.BuildTreeScopeBuildActionExecuter.execute(BuildTreeScopeBuildActionExecuter.java:28)
at
org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:78)
at
org.gradle.tooling.internal.provider.ContinuousBuildActionExecuter.execute(ContinuousBuildActionExecuter.java:52)
at
org.gradle.tooling.internal.provider.SubscribableBuildActionExecuter.execute(SubscribableBuildActionExecuter.java:59)
at
org.gradle.tooling.internal.provider.SubscribableBuildActionExecuter.execute(SubscribableBuildActionExecuter.java:36)
at
org.gradle.tooling.internal.provider.SessionScopeBuildActionExecuter.execute(SessionScopeBuildActionExecuter.java:68)
at
org.gradle.tooling.internal.provider.SessionScopeBuildActionExecuter.execute(SessionScopeBuildActionExecuter.java:38)
at
org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:37)
at
org.gradle.tooling.internal.provider.GradleThreadBuildActionExecuter.execute(GradleThreadBuildActionExecuter.java:26)
at
org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:43)
at
org.gradle.tooling.internal.provider.ParallelismConfigurationBuildActionExecuter.execute(ParallelismConfigurationBuildActionExecuter.java:29)
at
org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:60)
at
org.gradle.tooling.internal.provider.StartParamsValidatingActionExecuter.execute(StartParamsValidatingActionExecuter.java:32)
at
org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:55)
at
org.gradle.tooling.internal.provider.SessionFailureReportingActionExecuter.execute(SessionFailureReportingActionExecuter.java:41)
at
org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:48)
at
org.gradle.tooling.internal.provider.SetupLoggingActionExecuter.execute(SetupLoggingActionExecuter.java:32)
at
org.gradle.launcher.daemon.server.exec.ExecuteBuild.doBuild(ExecuteBuild.java:67)
at
org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at
org.gradle.launcher.daemon.server.exec.WatchForDisconnection.execute(WatchForDisconnection.java:37)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at
org.gradle.launcher.daemon.server.exec.ResetDeprecationLogger.execute(ResetDeprecationLogger.java:26)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at
org.gradle.launcher.daemon.server.exec.RequestStopIfSingleUsedDaemon.execute(RequestStopIfSingleUsedDaemon.java:34)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at
org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:74)
at
org.gradle.launcher.daemon.server.exec.ForwardClientInput$2.call(ForwardClientInput.java:72)
at org.gradle.util.Swapper.swap(Swapper.java:38) at
org.gradle.launcher.daemon.server.exec.ForwardClientInput.execute(ForwardClientInput.java:72)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at
org.gradle.launcher.daemon.server.exec.LogAndCheckHealth.execute(LogAndCheckHealth.java:55)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at
org.gradle.launcher.daemon.server.exec.LogToClient.doBuild(LogToClient.java:62)
at
org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at
org.gradle.launcher.daemon.server.exec.EstablishBuildEnvironment.doBuild(EstablishBuildEnvironment.java:81)
at
org.gradle.launcher.daemon.server.exec.BuildCommandOnly.execute(BuildCommandOnly.java:36)
at
org.gradle.launcher.daemon.server.api.DaemonCommandExecution.proceed(DaemonCommandExecution.java:104)
at
org.gradle.launcher.daemon.server.exec.StartBuildOrRespondWithBusy$1.run(StartBuildOrRespondWithBusy.java:50)
at
org.gradle.launcher.daemon.server.DaemonStateCoordinator$1.run(DaemonStateCoordinator.java:295)
at
org.gradle.internal.concurrent.ExecutorPolicy$CatchAndRecordFailures.onExecute(ExecutorPolicy.java:63)
at
org.gradle.internal.concurrent.ManagedExecutorImpl$1.run(ManagedExecutorImpl.java:46)
at
org.gradle.internal.concurrent.ThreadFactoryImpl$ManagedThreadRunnable.run(ThreadFactoryImpl.java:55)
Caused by:
org.gradle.api.internal.tasks.TaskDependencyResolveException: Could
not determine the dependencies of task ':app:processDebugResources'.
at
org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext.getDependencies(CachingTaskDependencyResolveContext.java:68)
at
org.gradle.execution.plan.TaskDependencyResolver.resolveDependenciesFor(TaskDependencyResolver.java:46)
at
org.gradle.execution.plan.LocalTaskNode.getDependencies(LocalTaskNode.java:106)
at
org.gradle.execution.plan.LocalTaskNode.resolveDependencies(LocalTaskNode.java:79)
at
org.gradle.execution.plan.DefaultExecutionPlan.addEntryTasks(DefaultExecutionPlan.java:167)
at
org.gradle.execution.taskgraph.DefaultTaskExecutionGraph.addEntryTasks(DefaultTaskExecutionGraph.java:139)
at
org.gradle.execution.TaskNameResolvingBuildConfigurationAction.configure(TaskNameResolvingBuildConfigurationAction.java:48)
at
org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:57)
at
org.gradle.execution.DefaultBuildConfigurationActionExecuter.access$200(DefaultBuildConfigurationActionExecuter.java:26)
at
org.gradle.execution.DefaultBuildConfigurationActionExecuter$2.proceed(DefaultBuildConfigurationActionExecuter.java:63)
at
org.gradle.execution.DefaultTasksBuildExecutionAction.configure(DefaultTasksBuildExecutionAction.java:44)
at
org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:57)
at
org.gradle.execution.DefaultBuildConfigurationActionExecuter.access$200(DefaultBuildConfigurationActionExecuter.java:26)
at
org.gradle.execution.DefaultBuildConfigurationActionExecuter$2.proceed(DefaultBuildConfigurationActionExecuter.java:63)
at
org.gradle.execution.ExcludedTaskFilteringBuildConfigurationAction.configure(ExcludedTaskFilteringBuildConfigurationAction.java:47)
at
org.gradle.execution.DefaultBuildConfigurationActionExecuter.configure(DefaultBuildConfigurationActionExecuter.java:57)
at
org.gradle.execution.DefaultBuildConfigurationActionExecuter.access$200(DefaultBuildConfigurationActionExecuter.java:26)
at
org.gradle.execution.DefaultBuildConfigurationActionExecuter$1.run(DefaultBuildConfigurationActionExecuter.java:43)
at org.gradle.internal.Factories$1.create(Factories.java:25) at
org.gradle.api.internal.project.DefaultProjectStateRegistry.withLenientState(DefaultProjectStateRegistry.java:132)
at
org.gradle.api.internal.project.DefaultProjectStateRegistry.withLenientState(DefaultProjectStateRegistry.java:124)
at
org.gradle.execution.DefaultBuildConfigurationActionExecuter.select(DefaultBuildConfigurationActionExecuter.java:39)
at
org.gradle.initialization.DefaultGradleLauncher$CalculateTaskGraph.run(DefaultGradleLauncher.java:333)
at
org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301)
at
org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293)
at
org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
at
org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
at
org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at
org.gradle.initialization.DefaultGradleLauncher.constructTaskGraph(DefaultGradleLauncher.java:218)
at
org.gradle.initialization.DefaultGradleLauncher.doBuildStages(DefaultGradleLauncher.java:155)
... 73 more Caused by:
org.gradle.api.internal.artifacts.ivyservice.DefaultLenientConfiguration$ArtifactResolveException:
Could not resolve all task dependencies for configuration
':app:_internal_aapt2_binary'. at
org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.rethrowFailure(DefaultConfiguration.java:1175)
at
org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access$2100(DefaultConfiguration.java:135)
at
org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationTaskDependency.visitDependencies(DefaultConfiguration.java:1657)
at
org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext$TaskGraphImpl.getNodeValues(CachingTaskDependencyResolveContext.java:106)
at
org.gradle.internal.graph.CachingDirectedGraphWalker$GraphWithEmpyEdges.getNodeValues(CachingDirectedGraphWalker.java:211)
at
org.gradle.internal.graph.CachingDirectedGraphWalker.doSearch(CachingDirectedGraphWalker.java:121)
at
org.gradle.internal.graph.CachingDirectedGraphWalker.findValues(CachingDirectedGraphWalker.java:73)
at
org.gradle.api.internal.tasks.CachingTaskDependencyResolveContext.getDependencies(CachingTaskDependencyResolveContext.java:66)
... 102 more Caused by:
org.gradle.internal.resolve.ModuleVersionResolveException: Could not
resolve com.android.tools.build:aapt2:3.4.2-5326820. Required by:
project :app at org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.resolveModule(RepositoryChainComponentMetaDataResolver.java:103)
at
org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.resolve(RepositoryChainComponentMetaDataResolver.java:63)
at
org.gradle.api.internal.artifacts.ivyservice.resolveengine.ComponentResolversChain$ComponentMetaDataResolverChain.resolve(ComponentResolversChain.java:95)
at
org.gradle.api.internal.artifacts.ivyservice.clientmodule.ClientModuleResolver.resolve(ClientModuleResolver.java:63)
at
org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.ComponentState.resolve(ComponentState.java:193)
at
org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.ComponentState.getMetadata(ComponentState.java:143)
at
org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.EdgeState.calculateTargetConfigurations(EdgeState.java:173)
at
org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.EdgeState.attachToTargetConfigurations(EdgeState.java:129)
at
org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.attachToTargetRevisionsSerially(DependencyGraphBuilder.java:318)
at
org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.resolveEdges(DependencyGraphBuilder.java:217)
at
org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.traverseGraph(DependencyGraphBuilder.java:170)
at
org.gradle.api.internal.artifacts.ivyservice.resolveengine.graph.builder.DependencyGraphBuilder.resolve(DependencyGraphBuilder.java:131)
at
org.gradle.api.internal.artifacts.ivyservice.resolveengine.DefaultArtifactDependencyResolver.resolve(DefaultArtifactDependencyResolver.java:121)
at
org.gradle.api.internal.artifacts.ivyservice.DefaultConfigurationResolver.resolveGraph(DefaultConfigurationResolver.java:171)
at
org.gradle.api.internal.artifacts.ivyservice.ShortCircuitEmptyConfigurationResolver.resolveGraph(ShortCircuitEmptyConfigurationResolver.java:86)
at
org.gradle.api.internal.artifacts.ivyservice.ErrorHandlingConfigurationResolver.resolveGraph(ErrorHandlingConfigurationResolver.java:73)
at
org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$7.run(DefaultConfiguration.java:580)
at
org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:301)
at
org.gradle.internal.operations.DefaultBuildOperationExecutor$RunnableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:293)
at
org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
at
org.gradle.internal.operations.DefaultBuildOperationExecutor.run(DefaultBuildOperationExecutor.java:91)
at
org.gradle.internal.operations.DelegatingBuildOperationExecutor.run(DelegatingBuildOperationExecutor.java:31)
at
org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveGraphIfRequired(DefaultConfiguration.java:571)
at
org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access$600(DefaultConfiguration.java:135)
at
org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$6.run(DefaultConfiguration.java:551)
at
org.gradle.api.internal.project.DefaultProjectStateRegistry$SafeExclusiveLockImpl.withLock(DefaultProjectStateRegistry.java:244)
at
org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveExclusively(DefaultConfiguration.java:547)
at
org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveToStateOrLater(DefaultConfiguration.java:542)
at
org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.resolveGraphForBuildDependenciesIfRequired(DefaultConfiguration.java:692)
at
org.gradle.api.internal.artifacts.configurations.DefaultConfiguration.access$3700(DefaultConfiguration.java:135)
at
org.gradle.api.internal.artifacts.configurations.DefaultConfiguration$ConfigurationTaskDependency.visitDependencies(DefaultConfiguration.java:1652)
... 107 more Caused by:
org.gradle.internal.resolve.ModuleVersionResolveException: Could not
resolve com.android.tools.build:aapt2:3.4.2-5326820. at
org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.lambda$resolveComponentMetaData$5(ErrorHandlingModuleComponentRepository.java:161)
at
org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.tryResolveAndMaybeBlacklist(ErrorHandlingModuleComponentRepository.java:251)
at
org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.tryResolveAndMaybeBlacklist(ErrorHandlingModuleComponentRepository.java:227)
at
org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.performOperationWithRetries(ErrorHandlingModuleComponentRepository.java:220)
at
org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.resolveComponentMetaData(ErrorHandlingModuleComponentRepository.java:158)
at
org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ComponentMetaDataResolveState.process(ComponentMetaDataResolveState.java:69)
at
org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ComponentMetaDataResolveState.resolve(ComponentMetaDataResolveState.java:61)
at
org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.findBestMatch(RepositoryChainComponentMetaDataResolver.java:138)
at
org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.findBestMatch(RepositoryChainComponentMetaDataResolver.java:119)
at
org.gradle.api.internal.artifacts.ivyservice.ivyresolve.RepositoryChainComponentMetaDataResolver.resolveModule(RepositoryChainComponentMetaDataResolver.java:92)
... 137 more Caused by: org.gradle.api.resources.ResourceException:
Could not get resource
'<a href="https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.4.2-5326820/aapt2-3.4.2-5326820.pom" rel="nofollow noreferrer">https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.4.2-5326820/aapt2-3.4.2-5326820.pom</a>'.
at
org.gradle.internal.resource.ResourceExceptions.failure(ResourceExceptions.java:74)
at
org.gradle.internal.resource.ResourceExceptions.getFailed(ResourceExceptions.java:57)
at
org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.copyToCache(DefaultCacheAwareExternalResourceAccessor.java:201)
at
org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.access$300(DefaultCacheAwareExternalResourceAccessor.java:54)
at
org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor$1.create(DefaultCacheAwareExternalResourceAccessor.java:89)
at
org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor$1.create(DefaultCacheAwareExternalResourceAccessor.java:81)
at
org.gradle.cache.internal.ProducerGuard$AdaptiveProducerGuard.guardByKey(ProducerGuard.java:97)
at
org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.getResource(DefaultCacheAwareExternalResourceAccessor.java:81)
at
org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.downloadByCoords(DefaultExternalResourceArtifactResolver.java:133)
at
org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.downloadStaticResource(DefaultExternalResourceArtifactResolver.java:97)
at
org.gradle.api.internal.artifacts.repositories.resolver.DefaultExternalResourceArtifactResolver.resolveArtifact(DefaultExternalResourceArtifactResolver.java:64)
at
org.gradle.api.internal.artifacts.repositories.metadata.AbstractRepositoryMetadataSource.parseMetaDataFromArtifact(AbstractRepositoryMetadataSource.java:69)
at
org.gradle.api.internal.artifacts.repositories.metadata.AbstractRepositoryMetadataSource.create(AbstractRepositoryMetadataSource.java:59)
at
org.gradle.api.internal.artifacts.repositories.metadata.DefaultMavenPomMetadataSource.create(DefaultMavenPomMetadataSource.java:38)
at
org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver.resolveStaticDependency(ExternalResourceResolver.java:243)
at
org.gradle.api.internal.artifacts.repositories.resolver.MavenResolver.doResolveComponentMetaData(MavenResolver.java:126)
at
org.gradle.api.internal.artifacts.repositories.resolver.ExternalResourceResolver$RemoteRepositoryAccess.resolveComponentMetaData(ExternalResourceResolver.java:444)
at
org.gradle.api.internal.artifacts.ivyservice.ivyresolve.CachingModuleComponentRepository$ResolveAndCacheRepositoryAccess.resolveComponentMetaData(CachingModuleComponentRepository.java:373)
at
org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.lambda$resolveComponentMetaData$3(ErrorHandlingModuleComponentRepository.java:159)
at
org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.lambda$tryResolveAndMaybeBlacklist$15(ErrorHandlingModuleComponentRepository.java:228)
at
org.gradle.api.internal.artifacts.ivyservice.ivyresolve.ErrorHandlingModuleComponentRepository$ErrorHandlingModuleComponentRepositoryAccess.tryResolveAndMaybeBlacklist(ErrorHandlingModuleComponentRepository.java:242)
... 145 more Caused by:
org.gradle.internal.resource.transport.http.HttpRequestException:
Could not GET
'<a href="https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.4.2-5326820/aapt2-3.4.2-5326820.pom" rel="nofollow noreferrer">https://dl.google.com/dl/android/maven2/com/android/tools/build/aapt2/3.4.2-5326820/aapt2-3.4.2-5326820.pom</a>'.
at
org.gradle.internal.resource.transport.http.HttpClientHelper.performRequest(HttpClientHelper.java:93)
at
org.gradle.internal.resource.transport.http.HttpClientHelper.performRawGet(HttpClientHelper.java:76)
at
org.gradle.internal.resource.transport.http.HttpClientHelper.performGet(HttpClientHelper.java:80)
at
org.gradle.internal.resource.transport.http.HttpResourceAccessor.openResource(HttpResourceAccessor.java:42)
at
org.gradle.internal.resource.transport.http.HttpResourceAccessor.openResource(HttpResourceAccessor.java:28)
at
org.gradle.internal.resource.transfer.DefaultExternalResourceConnector.openResource(DefaultExternalResourceConnector.java:56)
at
org.gradle.internal.resource.transfer.ProgressLoggingExternalResourceAccessor.openResource(ProgressLoggingExternalResourceAccessor.java:37)
at
org.gradle.internal.resource.transfer.AccessorBackedExternalResource.withContentIfPresent(AccessorBackedExternalResource.java:130)
at
org.gradle.internal.resource.BuildOperationFiringExternalResourceDecorator$11.call(BuildOperationFiringExternalResourceDecorator.java:237)
at
org.gradle.internal.resource.BuildOperationFiringExternalResourceDecorator$11.call(BuildOperationFiringExternalResourceDecorator.java:229)
at
org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:315)
at
org.gradle.internal.operations.DefaultBuildOperationExecutor$CallableBuildOperationWorker.execute(DefaultBuildOperationExecutor.java:305)
at
org.gradle.internal.operations.DefaultBuildOperationExecutor.execute(DefaultBuildOperationExecutor.java:175)
at
org.gradle.internal.operations.DefaultBuildOperationExecutor.call(DefaultBuildOperationExecutor.java:101)
at
org.gradle.internal.operations.DelegatingBuildOperationExecutor.call(DelegatingBuildOperationExecutor.java:36)
at
org.gradle.internal.resource.BuildOperationFiringExternalResourceDecorator.withContentIfPresent(BuildOperationFiringExternalResourceDecorator.java:229)
at
org.gradle.internal.resource.transfer.DefaultCacheAwareExternalResourceAccessor.copyToCache(DefaultCacheAwareExternalResourceAccessor.java:199)
... 163 more Caused by:
org.apache.http.conn.HttpHostConnectException: Connect to
dl.google.com:443 [dl.google.com/172.217.166.14] failed: Connection
timed out: connect at
org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:159)
at
org.apache.http.impl.conn.PoolingHttpClientConnectionManager.connect(PoolingHttpClientConnectionManager.java:373)
at
org.apache.http.impl.execchain.MainClientExec.establishRoute(MainClientExec.java:394)
at
org.apache.http.impl.execchain.MainClientExec.execute(MainClientExec.java:237)
at
org.apache.http.impl.execchain.ProtocolExec.execute(ProtocolExec.java:185)
at
org.apache.http.impl.execchain.RetryExec.execute(RetryExec.java:89)
at
org.apache.http.impl.execchain.RedirectExec.execute(RedirectExec.java:110)
at
org.apache.http.impl.client.InternalHttpClient.doExecute(InternalHttpClient.java:185)
at
org.apache.http.impl.client.CloseableHttpClient.execute(CloseableHttpClient.java:83)
at
org.gradle.internal.resource.transport.http.HttpClientHelper.performHttpRequest(HttpClientHelper.java:132)
at
org.gradle.internal.resource.transport.http.HttpClientHelper.performHttpRequest(HttpClientHelper.java:109)
at
org.gradle.internal.resource.transport.http.HttpClientHelper.executeGetOrHead(HttpClientHelper.java:98)
at
org.gradle.internal.resource.transport.http.HttpClientHelper.performRequest(HttpClientHelper.java:89)
... 179 more Caused by: java.net.ConnectException: Connection timed
out: connect at
org.apache.http.conn.ssl.SSLConnectionSocketFactory.connectSocket(SSLConnectionSocketFactory.java:339)
at
org.apache.http.impl.conn.DefaultHttpClientConnectionOperator.connect(DefaultHttpClientConnectionOperator.java:142)
... 191 more</p>
</blockquote>
| <android><android-studio> | 2019-08-14 13:51:55 | LQ_CLOSE |
57,497,227 | How to find if type is float64 | <p>I am trying to find if a variable is of type float64: </p>
<pre><code>package main
import ("fmt")
func main() {
myvar := 12.34
if myvar.(type) == float64 {
fmt.Println("Type is float64.")
}
}
</code></pre>
<p>However, it is not working and giving following error: </p>
<pre><code>./rnFindType.go:6:10: use of .(type) outside type switch
./rnFindType.go:6:21: type float64 is not an expression
</code></pre>
<p>What is the problem and how can it be solved?</p>
| <go><types> | 2019-08-14 14:56:55 | LQ_CLOSE |
57,497,411 | Finding the null rate of the column deice_id | I'm trying to write a code that will display the null count for a column in a table
I wrote the code below but i've been running into a syntax issue
SELECT device_id AS FIELD, COUNT (*) FROM (SELECT * FROM TABLE WHERE
TRIM(UPPER(device_id) IN ('','NULL',) OR device_id IS NULL OR SUBSTRING(TRIM(UPPER(device_id)), 1,1) = '-')
AND (event_date between '2019-05-20' AND '2019-05-27'));
I've been experiencing a syntax error | <mysql><sql><hive> | 2019-08-14 15:06:41 | LQ_EDIT |
57,497,812 | Getting a value in ViewController from AppDelegate | <p>I am trying to get the value in ViewController from AppDelegate, but I am not able to do so. </p>
<p>I have only one ViewController. I tried to make the value as a constant or variable. None of them works. </p>
<p>I am not sure if this is the correct approach, but I tried to use rootViewController to access. </p>
<pre><code>class ViewController: UIViewController {
override func viewWillAppear(_ animated: Bool) {
super.viewWillAppear(animated)
var test:String = "test"
// let test = "test"
}
}
</code></pre>
<p>in AppDelegate</p>
<pre><code> func application(_ application: UIApplication,
didFinishLaunchingWithOptions launchOptions: [UIApplication.LaunchOptionsKey: Any]?) -> Bool {
let viewController = self.window?.rootViewController as? ViewController
print("from_viewC \(String(describing: viewController?.test)))")
}
</code></pre>
| <ios><swift> | 2019-08-14 15:32:21 | LQ_CLOSE |
57,497,871 | How do I stop my divs from moving on other computers | <p>On my website template I have divs that look fine on my screen. but if I restore down the browser or look at it on another computer the divs are moved.
Is there some sort of tag I can use to make my div stay in place.</p>
<p>//example of a div </p>
<pre><code>#divtest{
width:450px;
height:75px;
margin:20px;
margin-top: 150px;
display:flex;
border-width: 2px;
border-color: black;
border-style: solid;
margin-left: -7%;
}
</code></pre>
| <html><css> | 2019-08-14 15:36:16 | LQ_CLOSE |
57,499,002 | Can't install pytorch with pip on Windows | <p>I'm trying to install Pytorch with Windows and I'm using the commands of the official site
<a href="https://pytorch.org/get-started/locally/" rel="noreferrer">https://pytorch.org/get-started/locally/</a></p>
<pre><code>pip3 install torch==1.2.0 torchvision==0.4.0 -f https://download.pytorch.org/whl/torch_stable.html
</code></pre>
<p>This is the command if I choose Windows, Cuda 10.0, and Python 3.7
But if I run this I get the error message:</p>
<pre><code>ERROR: Could not find a version that satisfies the requirement torch==1.2.0 (from versions: 0.1.2, 0.1.2.post1, 0.1.2.post2)
ERROR: No matching distribution found for torch==1.2.0
</code></pre>
<p>So why does this happen?
My pip is version 19.2 and I am in a newly installed python 3.7 environment</p>
| <python><python-3.x><pytorch><python-3.7> | 2019-08-14 16:54:57 | HQ |
57,499,420 | Creating a button with JS | <p>I am trying to create a button and append it to HTML in Javascript.</p>
<p>This is my code:</p>
<pre><code><html>
<head>
<script>
var btn=document.createElement("button");
btn.className = "YourClass";
btn.className += " YourClass2";
btn.id ='someId';
document.getElementById("main").appendChild(btn);
</script>
</head>
<body>
<div id = 'main'>
</div>
</body>
</html>
</code></pre>
<p>Unfortunately, this does not work and i don't understand why.</p>
| <javascript><html> | 2019-08-14 17:28:25 | LQ_CLOSE |
57,499,553 | Is it possible to prevent `useLazyQuery` queries from being re-fetched on component state change / re-render? | <p>Currently I have a <code>useLazyQuery</code> hook which is fired on a button press (part of a search form). </p>
<p>The hook behaves normally, and is only fired when the button is pressed. However, once I've fired it once, it's then fired every time the component re-renders (usually due to state changes).</p>
<p>So if I search once, then edit the search fields, the results appear immediately, and I don't have to click on the search button again. </p>
<p>Not the UI I want, and it causes an error if you delete the search text entirely (as it's trying to search with <code>null</code> as the variable), is there any way to prevent the <code>useLazyQuery</code> from being refetched on re-render?</p>
<p>This can be worked around using <code>useQuery</code> dependent on a 'searching' state which gets toggled on when I click on the button. However I'd rather see if I can avoid adding complexity to the component.</p>
<pre class="lang-js prettyprint-override"><code>const AddCardSidebar = props => {
const [searching, toggleSearching] = useState(false);
const [searchParams, setSearchParams] = useState({
name: ''
});
const [searchResults, setSearchResults] = useState([]);
const [selectedCard, setSelectedCard] = useState();
const [searchCardsQuery, searchCardsQueryResponse] = useLazyQuery(SEARCH_CARDS, {
variables: { searchParams },
onCompleted() {
setSearchResults(searchCardsQueryResponse.data.searchCards.cards);
}
});
...
return (
<div>
<h1>AddCardSidebar</h1>
<div>
{searchResults.length !== 0 &&
searchResults.map(result => {
return (
<img
key={result.scryfall_id}
src={result.image_uris.small}
alt={result.name}
onClick={() => setSelectedCard(result.scryfall_id)}
/>
);
})}
</div>
<form>
...
<button type='button' onClick={() => searchCardsQuery()}>
Search
</button>
</form>
...
</div>
);
};
</code></pre>
| <graphql><apollo><react-hooks><react-apollo><apollo-client> | 2019-08-14 17:37:44 | HQ |
57,499,918 | How to create object inside object in JS | <p>I want to create an object inside an object in JavaScript like this:</p>
<pre><code> {
"test": {
{},
{}
}
}
</code></pre>
<p>In more detail, I want to create a new object if "test" doesn't exist in the object, and create a new object in the same location as the old one if "test" exists.</p>
<p>Please help if this is possible.</p>
| <javascript> | 2019-08-14 18:06:33 | LQ_CLOSE |
57,500,123 | Where can I find documentation on the pyparsing module? | <p>I am working through some code to integrate Anaconda environments with ArcGIS. The tutorial I'm following makes use of the pyparsing module. I'd like to better understand the module but am having difficulty finding a good overview of the commands within it. Where can I find documentation for the module?</p>
| <python><pyparsing> | 2019-08-14 18:22:59 | LQ_CLOSE |
57,500,245 | loop taking some time and resulting wrong value; first n prime | <p>I'm trying to write a method that gives the collection of first n prime numbers. I googled and many of my code is similar to the ones I found online. but my loop takes long time and print 2, 0
Here's my code </p>
<pre><code>public static boolean isPrime(int numb) {
if(numb < 0) {
return false;
}
for(int i = 2; i < numb; i++) {
if((numb % i) != 0) {
return false;
}
}
return true;
}
public static int[] firstPrimeNumbers(int n) {
int[] pNumbs = new int[n];
int count = 0;
int number = 2;
while(count != n) {
if(isPrime(number)) {
pNumbs[count] = number;
count++;
}
number++;
}
return pNumbs;
}
public static void main(String[] args) {
int[] a = firstPrimeNumbers(2);
for(int x: a) {
System.out.println(x);
}
}
</code></pre>
| <java> | 2019-08-14 18:33:21 | LQ_CLOSE |
57,501,059 | I get the error CS1061 in unity (are you missing a using directive or an assembly reference?) | <p>The error message was like this :
'GameObject' does not contain a definition for 'Transform' and no accessible extension method 'Transform' accepting a first argument of type 'GameObject' could be found (are you missing a using directive or an assembly reference?)</p>
<p>this is my code
(<a href="https://i.stack.imgur.com/VY6iZ.png" rel="nofollow noreferrer">https://i.stack.imgur.com/VY6iZ.png</a>)
.
.
This is my error message
(<a href="https://i.stack.imgur.com/oMvh1.png" rel="nofollow noreferrer">https://i.stack.imgur.com/oMvh1.png</a>)</p>
| <c#><unity3d><compiler-errors> | 2019-08-14 19:43:44 | LQ_CLOSE |
57,502,867 | How to insert a 3D Photo using only Html and Css | <p>I created a 3d photo and i want to upload it to my website, and by animation that photo will be always rotating like a 3D Photo, but the command <code><img src="example.glb" alt="3D Photo"></code> doesn't work so i am having trouble inserting the photo.</p>
<pre><code><div class="photo">
<img src="dino 3d.glb" alt="">
</div>
</code></pre>
| <html><css> | 2019-08-14 22:32:37 | LQ_CLOSE |
57,503,385 | ArrayList<String> objects point to null. Why? | <p>I have a piece of code that takes in an <code>ArrayList<String></code> object and eventually takes that object and adds it to a <code>HashMap</code> object as the key. When I print the hashmap, the key's are all null while the values are correct.</p>
<p>I already know I can fix the code by passing in a copy of the <code>ArrayList<String></code> object and that fixes my issue (i.e. <code>buildHash(new ArrayList<String>(key))</code>. But why does it point to null otherwise?</p>
<pre class="lang-java prettyprint-override"><code>HashMap<ArrayList<String>, ArrayList<String>> hash = new HashMap<>();
ArrayList<String> key = new ArrayList<String>();
for (int i = 0; i <= 9999999; i++) {
key.add(//different strings depending on the iteration);
if ( !hash.contains(key) ) {
buildHash(key);
}
key.clear();
}
private void buildHash(ArrayList<String> key) {
ArrayList<String> follows = new ArrayList<String>();
for (int index = 0; index <= 9999999; index++) {
// add stuff to follows...
}
hash.put(key, follows);
}
</code></pre>
<p>I thought that the value of the key would be added to the hash, and the hash's keys would point to the value it was before it was cleared by <code>key.clear()</code>. That way I could reuse key over and over without creating another object in memory. </p>
<p>I'm new to Java (and coding) so I'm probably naive, but I thought I could save memory by utilizing the mutability of <code>ArrayLists</code> as opposed to <code>Lists</code> as the number of operations and key's generated for this project are well into the millions, if not more. Is there no avoiding that? And if not, is there any other optimization I could do?</p>
| <java><arraylist> | 2019-08-14 23:57:18 | LQ_CLOSE |
57,503,441 | Python listens for MacOS global events | Python listens for MacOS global events
from AppKit import *
from PyObjCTools import AppHelper
import CoreFoundation
def handler(event):
NSLog(event)
print(event)
NSEvent.addGlobalMonitorForEventsMatchingMask_handler_(NSLeftMouseDownMask, handler)
AppHelper.runConsoleEventLoop()
But, this just runs forever, does not respond to mouse events, what's wrong with that? | <python><pyobjc> | 2019-08-15 00:07:32 | LQ_EDIT |
57,503,735 | Many Error displays in netbeans with codename one | <p>I can compile a simple app fine using codename one and netbeans. but my editor displays many errors all over making my code ugly and unreadable. See attached screenshot</p>
<p><img src="https://i.imgur.com/3ojl6BP.png" alt="netbeans"></p>
<p>Its very buggy. The first string displays no error but all the other ones do, but the code compiles and works fine. What the hell ?</p>
<p>also autocomplete dosent seem to work. but works fine with real java.</p>
| <codenameone> | 2019-08-15 01:03:47 | LQ_CLOSE |
57,504,464 | Efficiently generate all combinations (at all depths) whose sum is within a specified range | <p>I have a set of 80 numbers and I would like to find the list of combinations which totals up to a given number. The below code works fine but its takes too long could someone please help me with an enhanced version which would process it faster ?</p>
<pre><code>public void sum_up(List<int> numbers, int target)
{
sum_up_recursive(numbers, target, new List<int>());
}
public void sum_up_recursive(List<int> numbers, int target, List<int> partial)
{
int s = 0;
foreach (int x in partial) s += x;
if (s == target)
val +=" sum(" + string.Join(",", partial.ToArray()) + ")=" + target + Environment.NewLine;
if (s == target && string.Join(",", partial.ToArray()).Contains("130") &&
string.Join(",", partial.ToArray()).Contains("104"))
{
string gg = " sum(" + string.Join(",", partial.ToArray()) + ")=" + target;
val += " || || sum(" + string.Join(",", partial.ToArray()) + ")=" + target + Environment.NewLine;
}
if (s >= target)
return;
for (int i = 0; i < numbers.Count; i++)
{
List<int> remaining = new List<int>();
int n = numbers[i];
for (int j = i + 1; j < numbers.Count; j++) remaining.Add(numbers[j]);
List<int> partial_rec = new List<int>(partial);
partial_rec.Add(n);
sum_up_recursive(remaining, target, partial_rec);
}
lblResult.Text = val;
}
private void btnCheck_Click(object sender, EventArgs e)
{
string[] vendorVal = txtvendor.Text.Split(',');
int[] myInts = Array.ConvertAll(vendorVal, s => int.Parse(s));
List<int> numbers = myInts.ToList();
int target = Convert.ToInt32(txtDifference.Text);
sum_up(numbers, target);
}
</code></pre>
<p>Any help is appreciated...</p>
| <c#><algorithm><checksum> | 2019-08-15 03:16:47 | LQ_CLOSE |
57,504,739 | Implement different concretions to an abstract class that implements a generic service | <p>I have a generic interface and one generic class with generic methods to query the database.</p>
<pre><code> public interface IRepositoryBase<Entity> {
IEnumerable<TEntity> GetAll(Func<IQueryable<TEntity>, IncludableQueryable<TEntity, object>> include = null);
}
public class RepositoryBase<TEntity>
: IDisposable, IRepositoryBase<TEntity>
where TEntity : class
{
public IEnumerable<TEntity> GetAll(Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null)
{
IQueryable<TEntity> query = _context.Set<TEntity>();
if (include != null)
query = include(query);
return query.ToList();
}
}
</code></pre>
<p>I also have several classes that I call "services" that have the business logic and implement another generic interface.</p>
<pre><code> public interface IServiceBase<TEntity>
where TEntity : class
{
IEnumerable<TEntity> GetAll(Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null);
}
public class ServiceBase<TEntity>
: IDisposable, IServiceBase<TEntity>
where TEntity : class
{
private readonly IRepositoryBase<TEntity>
_repository;
public ServiceBase(
IRepositoryBase<TEntity> repository)
{
_repository = repository;
}
public ServiceBase()
{
}
public IEnumerable<TEntity> GetAll(Func<IQueryable<TEntity>, IIncludableQueryable<TEntity, object>> include = null)
{
return _repository.GetAll(include);
}
}
public class PizzaService : ServiceBase<Piza>, IPizzaService
{
private readonly IPizzaRepository _pizzaRepository;
public PizzaService (IPizzaRepository pizzaRepository)
: base(pizzaRepository)
{
_pizzaRepository= pizzaRepository;
}
}
</code></pre>
<p>This way each service have their methods acessing their own table plus the methods in the ServiceBase.</p>
<p>There is a scenario where I have 3 concrete services like PizzaService, each one querying its own table, with really similar code, because of the table and the logic similarity.</p>
<p>I want to refactor those concrete services into one, changing only the method param and the repository being acessed, to be in compliance to DRY and ISP.</p>
<p>What I currently have:</p>
<pre><code> public interface IStopRule
{
string DsTerm { get; set; }
bool ShouldDelete { get; set; }
}
public interface IExampleRuleStopWordsBase<TEntity> : IServiceBase<TEntity>
where TEntity : class
{
}
public abstract class ExampleRuleStopWordsBase
: ServiceBase<IStopRule>, IExampleRuleStopWordsBase<IStopRule>
{
private readonly IRepositoryBase<IStopRule> _repo;
public ExampleRuleStopWordsBase(IRepositoryBase<IStopRule> repo)
: base()
{
_repo = repo;
}
public virtual string ApplyRule(string input)
{
var terms = GetAll();
foreach (var item in terms)
{
string regexPattern = @"\b(" + item.DsTerm + @")\b";
if (item.ShouldDelete && Regex.Match(input, regexPattern, RegexOptions.IgnoreCase).Success)
input = input.Replace(item.DsTerm, string.Empty);
}
input = input.Trim();
return input;
}
}
public class PizzaService : ExampleRuleStopWordsBase, IImportRule
{
public PizzaService(IRepositoryBase<IStopRule> repo)
: base(repo)
{
}
public void ApplyRule(Pizza pizza)
{
base.ApplyRule(pizza.Name);
}
}
public class PizzaProducerService : ExampleRuleStopWordsBase, IImportRule
{
public PizzaProducerService(IRepositoryBase<IStopRule> repo)
: base(repo)
{
}
public void ApplyRule(Pizza pizza)
{
base.ApplyRule(pizza.Producer.Name);
}
}
</code></pre>
<p>But I can't figure it out how to pass to the consturctor of ImportRuleStopWordsBase the right entity to make it use the right repository...</p>
<p>Obs: All interfaces and service implementations reside in Domain layers, whereas the implementation of the repository resides in Infrastructure layer.</p>
| <c#><.net><autofac><generic-programming><abstraction> | 2019-08-15 04:05:26 | LQ_CLOSE |
57,505,611 | Multiplication of positive integers results in 0 (__int64) | <p>I am trying to multiply four integers into a <code>__int64</code>. The value it should have is <code>4096 * 1024 * 64 * 64 = 17,179,869,184</code>. This is too large of a number to store in an <code>int</code>, thats why I'm using <code>__int64</code>.
The output I get however is <code>0</code>.</p>
<p>I've tried casting every single one of the integers to a <code>__int64</code>, which doesnt change the output from being <code>0</code>.
Also, if I check with a debugger, the value of <code>test</code> is in fact <code>0</code>, so it is not a problem with outputting it.</p>
<pre><code>#include <stdio.h>
#include <stdlib.h>
int main() {
__int64 test = (__int64)4096 * (__int64)1024 * (__int64)64 * (__int64)64;
printf("%d", test);
getchar();
}
</code></pre>
<p>The output:</p>
<pre><code>0
</code></pre>
<p>The expected output:</p>
<pre><code>17179869184
</code></pre>
| <c> | 2019-08-15 06:26:21 | LQ_CLOSE |
57,506,018 | C# How to deal with arrays inside a struct? | I'm looking for a way to replace some of my List objects with arrays in my project to boost performance. The reasoning is that the List I would replace do not change size often (sometimes only once), so it would make sense to swap them out with arrays. Also, I would like to prevent allocations on the heap as much as possible.
So my idea is to create a struct with two members "Count" and "Array". The struct would have some functions to add/remove/get/set/ect... elements in the array. The count would keep count of the elements that are usable in the array, and the array would only increase in size, never decrease.
Note that this is for a very particular case because I know the array size won't be very big.
So the main problem I have with that set up is when I use the assignment operator to copy the struct as the array is now shared between two variables instead of a having a new copy of the array.
The only thing I could come up with as an idea was trying to override the assignment operator so that it would create a new array on assignment... but obviously that does not work.
My ArrayStruct
```c#
public struct ArrayStruct<T>
{
[SerializeField] private int m_Count;
[SerializeField] private T[] m_Array;
public int Count => m_Count;
public void Initialize(int startSize)
{
m_Count = 0;
m_Array = new T[startSize];
}
public T GetAt(int index)
{
return m_Array[index];
}
public void SetAt(int index, T newValue)
{
m_Array[index] = newValue;
}
public void Add(T newElement)
{
if (m_Array == null) {
m_Array = new T[1];
} else if (m_Array.Length == m_Count) {
System.Array.Resize(ref m_Array, m_Count + 1);
}
m_Array[m_Count] = newElement;
m_Count++;
}
public void Remove(T element)
{
for (int i = 0; i < m_Count; ++i) {
if (!element.Equals(m_Array[i])) {
continue;
}
for (int j = index; j < m_Count - 1; ++j) {
m_Array[j] = m_Array[j + 1];
}
m_Count--;
m_Array[m_Count] = default(T);
break;
}
}
//Trying to overload the = operating by creating a auto cast, this gives a compile error
/*public static implicit operator ArrayStruct<T>(ArrayStruct<T> otherArray)
{
var newArray = new ArrayStruct<T>();
newArray.m_Count = otherArray.Count;
newArray.m_Array = new T[otherArray.Length];
otherArray.m_Array.CopyTo(newArray.m_Array);
return newArray;
}*/
```
An example showcasing the problem
```c#
var a = new ArrayStruct<string>()
a.Add("hello");
var b = a;
print (b.GetAt(0)); //"hello"
a.SetAt(0, "new value for a");
print(b.GetAt(0));//"new value for a" , changing a changed b because the array is the same in both, this is bad
a.Add("resizing array");
print (b.GetAt(1)); //"Out of range exception" , because the array was resized for a but not for b therefore the connection broke
```
So do any of you have an idea of how I could make a new copy the array when I assign the struct to another variable?
Of course, I know I could use a function to do something like so
b = new ArrayStruct(a);
But I want it to be implicit. Or if there was a way to prevent assignments that would also work for me.
var a = new ArrayStruct();//let this work
var b = a; //Prevent this from happening
If you have any other solutions for replacing Lists with arrays conveniently please let me know | <c#> | 2019-08-15 07:09:52 | LQ_EDIT |
57,506,248 | Regular Expression to extract specific text from string | <p>I am new to Regex and try to extract a 16x character piece of text from a list of strings. </p>
<p>Sample list:</p>
<pre><code>myString = [' pon-3-1 | UnReg 5A594F4380661123 1234567890 Active',
' pon-3-1 | UnReg 5A594F43805FA456 1234567890 Active',
' pon-3-1 | UnReg 4244434D73B24789 1234567890 Active',
' pon-3-1 | UnReg 5A594F43805FB000 1234567890 Active',
'sw-frombananaramatoyourmama-01'
]
</code></pre>
<p>I cannot use a simple regex like (\w{16}) as this will include all text with 16 characters.
I also tried (\w+A) which, depending on the characters in the string, don't return the correct results. </p>
<pre class="lang-py prettyprint-override"><code>newArry = []
for i in myString:
number = re.search('(\w{16})', i)
newArr.append(number[0])
print(newArr)
</code></pre>
<p>Returns:</p>
<pre class="lang-py prettyprint-override"><code>['5A594F4380661123', '5A594F43805FA456', '4244434D73B24789', '5A594F43805FB000', 'frombananaramato']
</code></pre>
<ol>
<li>I want to extract only:
<ul>
<li>5A594F4380661123</li>
<li>5A594F43805FA456</li>
<li>4244434D73B24789</li>
<li>5A594F43805FB000</li>
</ul></li>
</ol>
<p>Any ideas?</p>
<p>Many thanks in advance</p>
| <python><regex> | 2019-08-15 07:32:46 | LQ_CLOSE |
57,506,456 | Not Able to Get Index of Element in Array in JavaScript | <p>Can you please take a look at this code and let me know why I am not getting the index of each array element which is not 0 in this loop properly?</p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>let st = "0,1,0,0,1,1";
let arr = [];
arr = st.split(',');
for(var i = 0; i < arr.length; i++){
if( arr[i] != 0){
console.log(arr.indexOf(i))
}
}</code></pre>
</div>
</div>
</p>
| <javascript> | 2019-08-15 07:51:20 | LQ_CLOSE |
57,506,688 | Protractor: Support for the Firefox >=48 | For quite sometime now I have been trying to run protractor with Firefox(Windows) v48 and above to run my AngularJS application.
However, as per [protractor docs][1]
> WebDriver support fr Firefox has changed recently, and FireFox version
> 48 does not work properly with the current tools. For the moment, we
> recommend testing against FireFox 47
This information was updated 3 years ago and nothing seems to have been done afterwards.
**Versions**
- OS - Windows 10 64-bit
- Protractor - 5.4.2
- Firefox - 68
- selenium-stanalone-server: 2.53.1
- AngularJS - 1.6.9
I did raise an issue recently on [github][2] for the same, but it has not received traction yet.
I would like to know if anyone has been able to get around the issue for Windows.
[1]: https://github.com/angular/protractor/blob/master/docs/browser-support.md
[2]: https://github.com/angular/protractor/issues/5299 | <firefox><protractor><webdriver-manager> | 2019-08-15 08:10:19 | LQ_EDIT |
57,506,980 | Why 0/0 is NaN but 0/0.00 isn't | <p>Using <code>DataTable.Compute</code>, and have built some cases to test:</p>
<pre><code>dt.Compute("0/0", null); //returns NaN when converted to double
dt.Compute("0/0.00", null); //results in DivideByZero exception
</code></pre>
<p>I have changed my code to handle both. But curious to know what's going on here?</p>
| <c#><datatable><double><decimal><formula> | 2019-08-15 08:35:42 | HQ |
57,508,014 | Fatal Exception: java.lang.StackOverflowError stack size 8MB android.view.View.hasIdentityMatrix | <p>This is a very rare bug that's happening in my app. Users open <code>SettingsActivity</code> and notice the app has frozen, after which it crashes (5 - 10s later?).<br>
I have no idea how to proceed, I've tried debugging but can't reproduce the issue. I've seen other similar questions, but their stack traces had application methods that were the cause of an infinite loop. Here, there is no application code that's responsible (at least, the stack trace doesn't reveal anything)</p>
<p>Stack trace shows only a bunch of Android core library methods (<code>View</code>, <code>ViewGroup</code>, <code>RecyclerView</code>), and has something to do with accessibility.</p>
<p>This perplexes me, since:</p>
<ul>
<li>I'm not using RecyclerView anywhere in <code>SettingsActivity</code>, <code>SettingsFragment</code>, or their layouts</li>
<li>The only place I am using it, works perfectly, as proven by a few screenshots and videos users have sent me</li>
<li>I haven't overriden any accessibility callbacks in any of my activities</li>
<li>I added breakpoints in every method the stack trace shows, but those breakpoints were never hit. In any activity. (<strong>wtf</strong>)</li>
</ul>
<p>Considering the stack trace doesn't show any custom classes/methods part of my codebase, how am I supposed to proceed? Is this a known bug in <code>androidx.recyclerview</code>, for example?</p>
<p>I know for sure that the app crashes in <code>SettingsActivity</code>, since Firebase tracks activities in Crashlytics for you. (the flow was <code>MainActivity -> [AnyActivity] -> SettingsActivity -> <freeze> -> <crash></code>).</p>
<p>Our entire team can't reproduce this issue (using the same exact Play Store version), but it seems like there are around 100 users that are experiencing this crash. All devices that show these fatal exceptions are being used by our team to debug, to no avail.</p>
<h3>Stack trace</h3>
<pre><code>Fatal Exception: java.lang.StackOverflowError: stack size 8MB
at android.view.View.hasIdentityMatrix (View.java:14669)
at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6138)
at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6189)
at android.view.ViewGroup.getChildVisibleRect (ViewGroup.java:6121)
at android.view.View.getGlobalVisibleRect (View.java:16064)
at android.view.View.isVisibleToUser (View.java:9065)
at android.view.View.isVisibleToUser (View.java:9023)
at android.view.View.onInitializeAccessibilityNodeInfoInternal (View.java:8814)
at android.view.ViewGroup.onInitializeAccessibilityNodeInfoInternal (ViewGroup.java:3642)
at android.view.View$AccessibilityDelegate.onInitializeAccessibilityNodeInfo (View.java:27387)
at androidx.core.view.AccessibilityDelegateCompat.onInitializeAccessibilityNodeInfo (AccessibilityDelegateCompat.java:275)
at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:124)
at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
at androidx.recyclerview.widget.RecyclerViewAccessibilityDelegate$ItemDelegate.onInitializeAccessibilityNodeInfo (RecyclerViewAccessibilityDelegate.java:131)
at androidx.core.view.AccessibilityDelegateCompat$AccessibilityDelegateAdapter.onInitializeAccessibilityNodeInfo (AccessibilityDelegateCompat.java:86)
at android.view.View.onInitializeAccessibilityNodeInfo (View.java:7776)
at android.view.View.createAccessibilityNodeInfoInternal (View.java:7737)
at android.view.View$AccessibilityDelegate.createAccessibilityNodeInfo (View.java:27485)
at android.view.View.createAccessibilityNodeInfo (View.java:7720)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchDescendantsOfRealNode (AccessibilityInteractionController.java:1147)
at android.view.AccessibilityInteractionController$AccessibilityNodePrefetcher.prefetchAccessibilityNodeInfos (AccessibilityInteractionController.java:972)
at android.view.AccessibilityInteractionController.findAccessibilityNodeInfoByAccessibilityIdUiThread (AccessibilityInteractionController.java:336)
at android.view.AccessibilityInteractionController.access$400 (AccessibilityInteractionController.java:67)
at android.view.AccessibilityInteractionController$PrivateHandler.handleMessage (AccessibilityInteractionController.java:1324)
at android.os.Handler.dispatchMessage (Handler.java:106)
at android.os.Looper.loop (Looper.java:193)
at android.app.ActivityThread.main (ActivityThread.java:6898)
at java.lang.reflect.Method.invoke(Method.java)
at com.android.internal.os.RuntimeInit$MethodAndArgsCaller.run (RuntimeInit.java:537)
at com.android.internal.os.ZygoteInit.main (ZygoteInit.java:858)
</code></pre>
<h3>SettingsActivity</h3>
<pre class="lang-java prettyprint-override"><code>public class SettingsActivity extends AppCompatActivity {
@Override
protected void onCreate(Bundle savedInstanceState) {
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_settings);
settingsFragment = new SettingsFragment();
getSupportFragmentManager().beginTransaction()
.setTransition(FragmentTransaction.TRANSIT_FRAGMENT_FADE)
.replace(R.id.settings_container, settingsFragment, "Settings")
.commit();
... // also contains code to init an IAP helper,
// but that doesn't use RecyclerView either (obviously)
}
</code></pre>
<h3>SettingsFragment</h3>
<pre class="lang-java prettyprint-override"><code>public class SettingsFragment extends PreferenceFragmentCompat implements OnPreferenceChangeListener {
@Override
public void onCreatePreferences(Bundle savedInstanceState, String rootKey) {
...
addPreferencesFromResource(R.xml.preferences);
...
}
</code></pre>
| <android><android-recyclerview><android-preferences> | 2019-08-15 10:04:01 | HQ |
57,508,392 | How Do I Get All Records From A DNS Server? | <p>How do I get all records from a DNS server? For example, I want to host a local DNS server so that I would get faster DNS access (I know about the huge size). How do I download the hosts file from a DNS server?</p>
| <dns> | 2019-08-15 10:37:37 | LQ_CLOSE |
57,508,768 | How does the global variable behave inside function(Python) | <p>Case 1</p>
<pre><code>A = '213'
def wow():
print(A)
wow()
Output: '213'
</code></pre>
<p>Case 2</p>
<pre><code>A = '213'
def wow():
print(A)
A = 12
wow()
Output: UnboundLocalError: local variable 'A' referenced before assignment
</code></pre>
<p>I'd thought that the output in the case 2 would be identical to the case 1, since A is a global variable and I called "print(A)" <em>before</em> reassigning value to A within the function. So my question is, why in the case 1 calling A is perfectly fine, but case 2 throws error?</p>
| <python><variables><scope> | 2019-08-15 11:10:15 | LQ_CLOSE |
57,509,531 | Why does the value of mycounter[0] change when myCounters[2] is reset? (Theory) | <p>This is supposed to happen for the task that I'm currently doing, but I don't understand why this is taking place. When <code>myCounter[2].Reset()</code> is called it resets the values of both myCounters[0] and myCounters[2]. Why is this occuring</p>
<p>Program.cs</p>
<pre><code>namespace CounterTest
{
public class MainClass
{
private static void PrintCounters(Counter[] counters)
{
foreach ( Counter c in counters)
{
Console.WriteLine("Name is: {0} Value is: {1}", c.Name, c.Value);
}
}
public static void Main(string[] args)
{
Counter[] myCounters = new Counter[3];
myCounters[0] = new Counter("Counter 1");
myCounters[1] = new Counter("Counter 2");
myCounters[2] = myCounters[0];
for (int i=0; i<4 ; i++)
{
myCounters[0].Increment();
}
for (int i = 0; i < 9; i++)
{
myCounters[1].Increment();
}
MainClass.PrintCounters(myCounters);
myCounters[2].Reset();
MainClass.PrintCounters(myCounters);
}
}
}
</code></pre>
<p>Class1.cs</p>
<pre><code>namespace CounterTest
{
public class Counter
{
private int _count;
public int Value
{
get
{return _count;}
}
private string _name;
public string Name
{
get {return _name; }
set {_name = value; }
}
public Counter(string Name)
{
_name = Name;
_count = 0;
}
public void Increment()
{ _count = _count + 1; }
public void Reset()
{_count = 0;}
}
}
</code></pre>
<p>The output is:</p>
<p>Name is: Counter 1 Value is: 4</p>
<p>Name is: Counter 2 Value is: 9</p>
<p>Name is: Counter 1 Value is: 4</p>
<p>Name is: Counter 1 Value is: 0</p>
<p>Name is: Counter 2 Value is: 9</p>
<p>Name is: Counter 1 Value is: 0</p>
<p>Thank you for any help.</p>
| <c#> | 2019-08-15 12:18:02 | LQ_CLOSE |
57,511,077 | Naming convention for models that get posted against a controller? | <p>We use the term <em>ViewModel</em> for classes that get returned from a controller and are passed to the view. Instead of using ViewBag or ViewData, we are using a strongly typed class which basically stores every value the view needs.</p>
<pre><code>public IActionResult OrderStep1()
{
var model = new ViewModelStep1()
{
SomeProperty = "SomeValue",
...
}
return View(model);
}
</code></pre>
<p>I'm looking for a naming convention that specifies how we should name a class that contains the properties that are posted from the submit button of a form to the controller. In the following example, I've chosen <code>OrderStep2</code> as a temporary name for that class. </p>
<p>For our multiple step order wizard, we are using <a href="https://en.wikipedia.org/wiki/Post/Redirect/Get" rel="nofollow noreferrer">Post/Redirect/Get</a> pattern. Therefore, I can enrich the information from <code>OrderStep2</code> and return a specific ViewModel <code>OrderStep2VM</code>.</p>
<pre><code>[HttpPost]
[ValidateAntiForgeryToken]
[Route("order/step2")]
public async Task<IActionResult> OrderStep2(OrderStep2 model)
{
// save some changes into the database and retrieve a GUID configurationId
return RedirectToAction(nameof(OrderStep2()), new { configurationId = "GUID" });
}
[Route("order/step2/{configurationId}")]
public IActionResult OrderStep2(Guid configurationId)
{
// retrieve configuration from database based on the configurationID
// do something else
var model = new OrderStep2VM()
{
....
};
return View(model);
}
</code></pre>
<p>Since I want the code to be well organized, I'd like to group classes such as <code>OrderStep2</code> into a seperate namespace. Currently, I'm thinking of calling them <em>PostModels</em>, i.e., <code>OrderStep2PM</code>, but I don't want to define a new term for something that probably already exists.</p>
<p>(In case you are wondering why I'm not using TempData: The workflow of the application requires saving incomplete form data which allows me to skip TempData since I need to store in the database anyway).</p>
| <c#><asp.net-core><asp.net-core-mvc><naming-conventions> | 2019-08-15 14:18:42 | LQ_CLOSE |
57,512,649 | Deep Learning + ML + CV > Requirements.txt file | <p>I need to know any place or link or personal requirements.txt for either ML , DL or Computer Vision. It will save my time to install all again . </p>
<p>I also need help me in making Ubuntu image st to port environments to other computer.</p>
| <machine-learning><deep-learning><computer-vision><ubuntu-18.04> | 2019-08-15 16:05:10 | LQ_CLOSE |
57,513,387 | DataTable not binding to DataGrid in WPF MVVM | <p>Can't figure out why my DataGrid isn't populating when I fill it's binded DataTable. I've checked other Stackoverflow posts but nothing seems to solve my problem. I know that my DataTable is getting filled up because the row count is over 50. The method that fills the DataTable (ReturnOperators) is sucessfully getting called (It's when the SelectedItem in a listbox is changed)</p>
<p>Here is my code:</p>
<p>Xaml:</p>
<pre><code> <DataGrid x:Name="dgOperators"
ItemsSource="{Binding DtOperators}"
AutoGenerateColumns="True"
Background="#0d0d0d"
Foreground="White"
Margin="10"
Grid.Row="1"
IsReadOnly="True" />
</code></pre>
<p>MainWindow.xaml.cs:</p>
<p>private ViewModel vm;</p>
<pre><code> public MainWindow()
{
InitializeComponent();
vm = new ViewModel();
this.DataContext = vm;
}
</code></pre>
<p>ViewModel:</p>
<pre><code>private DataTable dtOperators;
public DataTable DtOperators
{
get { return dtOperators; }
set
{
dtOperators = value;
OnPropertyChanged("DtOperators");
}
}
public void ReturnOperators()
{
string query = "My SQL Query Here";
using (SqlConnection con = new SqlConnection(connectionString))
using (SqlCommand cmd = new SqlCommand(query, con))
using (SqlDataAdapter adapter = new SqlDataAdapter(cmd))
{
DtOperators.Clear();
adapter.Fill(DtOperators);
}
}
</code></pre>
| <c#><wpf><visual-studio><mvvm><datagrid> | 2019-08-15 17:02:53 | LQ_CLOSE |
57,515,444 | How can I check a condition if the path equal a folder name? | <p>Path = c:\users\source\ <strong>reports</strong>\projects\ .file</p>
<p>How can I check if the projects folder inside a folder name == "reports"?</p>
<p>for example:
If (reports)
.....do a condition</p>
| <c#><file><path> | 2019-08-15 19:54:30 | LQ_CLOSE |
57,515,973 | Is there a way to apply a function on all elements of a slice in go? | <p>How do I apply a function to all elements of go slice without having to explicitly iterate over the slice? </p>
<p>Is there something similar to Java </p>
<p><code>stream().map(<fn>)</code> <a href="https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html#map-java.util.function.Function-" rel="nofollow noreferrer">https://docs.oracle.com/javase/8/docs/api/java/util/stream/Stream.html#map-java.util.function.Function-</a></p>
<p>(OR)</p>
<p><code>forEach(<fn>)</code> <a href="https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html#forEach-java.util.function.Consumer-" rel="nofollow noreferrer">https://docs.oracle.com/javase/8/docs/api/java/lang/Iterable.html#forEach-java.util.function.Consumer-</a></p>
| <go> | 2019-08-15 20:39:05 | LQ_CLOSE |
57,516,114 | Regex text (including period) and number C# | <p>I'm having a string which contains text (that may have periods in it) followed by a number, and I'm trying to separate text from the number, the code I'm using evaluates the string char by char but is taking too long, so I've tried to use regex but I can't include the period.</p>
<p>If the input is A.B123, y need an array or list like: ["A.B","123"]</p>
| <c#><regex> | 2019-08-15 20:53:01 | LQ_CLOSE |
57,516,930 | Prevent HTML file input from selecting files in Google Drive while using Android's native file chooser | <p>Currently I'm working on a page that allows users to upload a file to Firebase Storage. When opening the site through Google Chrome on Android and selecting a file for upload from a standard HTML file input, it uses Android's native file chooser.</p>
<p>In most cases, a user would choose a file stored locally on the device, but the file chooser also shows their Google Drive files and a user currently isn't prevented from selecting one of those files. The file is returned as a File object in Javascript, but when the upload to Firebase Storage is attempted it throws the error: "net::ERR_UPLOAD_FILE_CHANGED" and eventually exceeds it's retry limit.</p>
<p>To prevent confusion for the user, I'd like to prevent the user from selecting a Google Drive file in Android's file chooser, or at the very least recognize that it can't be uploaded and warn the user.</p>
<p>I considered checking the File object returned by the input element, but there isn't any indication to tell a local file from a Google Drive file.</p>
<pre class="lang-html prettyprint-override"><code><input type="file" id="upload_input" class="hide"/>
</code></pre>
<pre><code>$("#upload_input").change(function(e) {
if (!e.target.files) {
return;
}
const file = e.target.files[0];
uploadFile(file);
});
uploadFile(file) {
...
const storageRef = firebase.storage().ref();
const fileRef = storageRef.child(`${userID}/uploads/${file.name}`);
const uploadTask = fileRef.put(file);
...
}
</code></pre>
| <javascript><firebase><google-chrome><google-drive-api><firebase-storage> | 2019-08-15 22:28:02 | HQ |
57,516,944 | stack new command failing to download build plan for lts-14.1 | <p>Stack fails with a 404 HTTP status to download a build plan for lts-14.1:</p>
<pre><code>$ stack new my-project
[...]
Downloading lts-14.1 build plan ...
RedownloadInvalidResponse Request {
host = "raw.githubusercontent.com"
port = 443
secure = True
requestHeaders = []
path = "/fpco/lts-haskell/master//lts-14.1.yaml"
queryString = ""
method = "GET"
proxy = Nothing
rawBody = False
redirectCount = 10
responseTimeout = ResponseTimeoutDefault
requestVersion = HTTP/1.1
}
"/home/michid/.stack/build-plan/lts-14.1.yaml" (Response {responseStatus = Status {statusCode = 404, statusMessage = "Not Found"}, responseVersion = HTTP/1.1, responseHeaders = [("Content-Security-Policy","default-src 'none'; style-src 'unsafe-inline'; sandbox"),("Strict-Transport-Security","max-age=31536000"),("X-Content-Type-Options","nosniff"),("X-Frame-Options","deny"),("X-XSS-Protection","1; mode=block"),("X-GitHub-Request-Id","10DA:4457:1D507:285B9:5D55DA2D"),("Content-Length","15"),("Accept-Ranges","bytes"),("Date","Thu, 15 Aug 2019 22:18:21 GMT"),("Via","1.1 varnish"),("Connection","keep-alive"),("X-Served-By","cache-mxp19828-MXP"),("X-Cache","MISS"),("X-Cache-Hits","0"),("X-Timer","S1565907502.529821,VS0,VE176"),("Vary","Authorization,Accept-Encoding"),("Access-Control-Allow-Origin","*"),("X-Fastly-Request-ID","9f869169dd207bbd8bb8a8fd4b274acf6580ba4f"),("Expires","Thu, 15 Aug 2019 22:23:21 GMT"),("Source-Age","0")], responseBody = (), responseCookieJar = CJ {expose = []}, responseClose' = ResponseClose})
</code></pre>
<p>Everything works fine if I specify <code>--resolver lts-13.19</code> on the command line so I'm assuming this is a bug.</p>
<ul>
<li>Anything I can do locally to work around this problem?</li>
<li>What is the best place to report the issue or check whether it is a known one? I came across <a href="https://github.com/commercialhaskell/stack" rel="noreferrer">https://github.com/commercialhaskell/stack</a> but am not sure whether this is the right place. </li>
</ul>
| <haskell><haskell-stack> | 2019-08-15 22:29:28 | HQ |
57,517,003 | pandas series,isnull() is not working inside list comprehension | <p>for the following simple code:</p>
<pre><code>drop_cols = [col for col in train.columns if col[0] == 'V' and train[col].isnulll().sum()/len(train) > 0.76]
drop_cols
</code></pre>
<p>I get this error:</p>
<blockquote>
<p>AttributeError Traceback (most recent call
last) in ()
----> 1 drop_cols = [col for col in train.columns if col[0] == 'V' and train[col].isnulll().sum()/len(train) > 0.76]
2 drop_cols</p>
<p> in (.0)
----> 1 drop_cols = [col for col in train.columns if col[0] == 'V' and train[col].isnulll().sum()/len(train) > 0.76]
2 drop_cols</p>
<p>C:\Anaconda3\lib\site-packages\pandas\core\generic.py in
<strong>getattr</strong>(self, name) 5065 if self._info_axis._can_hold_identifiers_and_holds_name(name): 5066<br>
return self[name]
-> 5067 return object.<strong>getattribute</strong>(self, name) 5068 5069 def <strong>setattr</strong>(self, name, value):</p>
<p>AttributeError: 'Series' object has no attribute 'isnulll'</p>
</blockquote>
<p>isnull() is working elsewhere. What is the cause and fix for this?</p>
| <python><pandas><null><list-comprehension> | 2019-08-15 22:38:33 | LQ_CLOSE |
57,517,332 | How to write the definition of a derived class in c++? | <p>I don't know the syntax for writing the definition of a class function with templates. </p>
<p>I get an error, the complier expected ; , so that be
void plus;
Anyone knows to fix that!</p>
<pre><code>template<class Type
class basic{
protected:
Type x;
public:
int value;
//virtual void print() =0;
basic(Type xArg):x(xArg){}
};
template<class Type>
class plus:public basic<Type>{
public:
Type y;
plus(Type xArg, Type yArg):basic<Type>(xArg),y(yArg){}
void print();
};
//template<class Type>
void plus<Type>::print(){
cout << "x : " << x << endl;
cout << "y : " << y << endl;
}
</code></pre>
| <c++><templates><inheritance><virtual> | 2019-08-15 23:27:51 | LQ_CLOSE |
57,517,420 | recursion with or without return statement | <p>this is the problem I solved for recursion<br/></p>
<blockquote>
<p>phone_book return <br/>
[119, 97674223, 1195524421] false <br/>
[123,456,789] true <br/>
[12,123,1235,567,88] false</p>
</blockquote>
<p>when it have the prefix of the any number it will return false <br/>
anyway here is my solution <br/></p>
<pre><code>def solution(phone_book):
answer = True
arr = []
print(phone_book,len(phone_book))
if len(phone_book) <=1: return True
phone_book.sort(key = lambda s: len(str(s)))
length = len(str(phone_book[0]))
for st in phone_book[1:]:
if phone_book[0] == st[:length]: return False
return solution(phone_book[1:])
</code></pre>
<p>but for last recursion part <br/>
if I remove the return it return the None value <br/>
I want to know why it return the None value <br/></p>
<blockquote>
<pre><code> solution(phone_book[1:]) ---> this will return None value without return statemetn
</code></pre>
</blockquote>
| <python><recursion> | 2019-08-15 23:41:50 | LQ_CLOSE |
57,517,846 | How to implement complex arrays? | <p>For example, when <code>id</code> is equal to 1, an array is <code>['a', 'b']</code>, and when <code>id</code> is equal to 2, another array is <code>['c']</code>. The result of these two arrays is <code>[["a","b "],["c"]]</code></p>
<p><strong>I want the results as follows:</strong></p>
<pre><code>[["a","b"],["c"]]
</code></pre>
<p><strong>my code:</strong></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var data = [{
id: 1,
name: 'a'
},
{
id: 1,
name: 'b'
},
{
id: 2,
name: 'c'
}
]</code></pre>
</div>
</div>
</p>
| <javascript> | 2019-08-16 01:11:44 | LQ_CLOSE |
57,518,050 | Conda install and update do not work also solving environment get errors | <p>I am using anaconda as below:</p>
<pre><code>(base) C:\Users\xxx>conda info
active environment : base
active env location : C:\Users\xxx\Documents\ANACONDA
shell level : 1
user config file : C:\Users\xxx\.condarc
populated config files : C:\Users\xxx\.condarc
conda version : 4.7.11
conda-build version : 3.18.9
python version : 3.6.9.final.0
virtual packages :
base environment : C:\Users\xxx\Documents\ANACONDA (writable)
channel URLs : https://repo.anaconda.com/pkgs/main/win-64
https://repo.anaconda.com/pkgs/main/noarch
https://repo.anaconda.com/pkgs/free/win-64
https://repo.anaconda.com/pkgs/free/noarch
https://repo.anaconda.com/pkgs/r/win-64
https://repo.anaconda.com/pkgs/r/noarch
https://repo.anaconda.com/pkgs/msys2/win-64
https://repo.anaconda.com/pkgs/msys2/noarch
package cache : C:\Users\xxx\Documents\ANACONDA\pkgs
C:\Users\xxx\.conda\pkgs
C:\Users\xxx\AppData\Local\conda\conda\pkgs
envs directories : C:\Users\xxx\Documents\ANACONDA\envs
C:\Users\xxx\.conda\envs
C:\Users\xxx\AppData\Local\conda\conda\envs
platform : win-64
user-agent : conda/4.7.11 requests/2.22.0 CPython/3.6.9 Windows/10 Windows/10.0.16299
administrator : False
netrc file : None
offline mode : False
</code></pre>
<p>Now I have 2 issues that stop my work.
1) I cannot use <code>conda install</code> for any package.
It will give me the error in <code>solving environment</code> list this:</p>
<pre><code>failed with initial frozen solve. Retrying with flexible solve.
</code></pre>
<p>then it will fail again and give message like this:</p>
<pre><code>Found conflicts! Looking for incompatible packages.
This can take several minutes. Press CTRL-C to abort.
</code></pre>
<p>Even after the checking for incompatible packages, it didn't give me the solution.</p>
<p>2) When I want to upgrade or downgrade conda by the command:</p>
<pre><code>conda update -n base conda
</code></pre>
<p>or</p>
<pre><code>conda install conda = 4.6.11
</code></pre>
<p>It will give me errors again in the <code>solving environment</code>, and I think this is related to the first issue.</p>
<p>Now I cannot use conda for anything, please advise and thank you!</p>
| <python><anaconda><conda> | 2019-08-16 01:51:23 | HQ |
57,518,410 | Understanding relative position in css | <p>Following this <a href="https://www.w3schools.com/css/css_positioning.asp" rel="nofollow noreferrer">link</a>.</p>
<p>It states:</p>
<blockquote>
<p>An element with position: relative; is positioned relative to its normal position.</p>
</blockquote>
<p>How can we define 'normal position'? Is it in context of parent element or overall screen(viewport)?</p>
| <css><css-position> | 2019-08-16 02:54:11 | LQ_CLOSE |
57,518,634 | How does JS remove the quotation marks before and after the string? | <p>How can I remove the quotation marks on both sides?</p>
<p><strong>Want the result as follows</strong></p>
<pre><code>[{"id":1,"photo":"111"},{"id":2,"photo":"222"}]
</code></pre>
<p><strong>my code:</strong></p>
<p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
<div class="snippet-code">
<pre class="snippet-code-js lang-js prettyprint-override"><code>var a = "[{"id":1,"photo":"111"},{"id":2,"photo":"222"}]"</code></pre>
</div>
</div>
</p>
| <javascript> | 2019-08-16 03:36:13 | LQ_CLOSE |
57,518,663 | How to display LIVE time with specific timezone? | <p>I'm trying to display a live time on my website, but with a specific timezone (GMT-4, Toronto). Since my javascript knowledge is minimal, I tried googling for a solution but it's difficult to understand. I took a look at luxon.js but not sure how to work with it. I found a snippet of code that displays current system time but not sure what to do with it. any help would be appreciated!</p>
<pre><code>function checkTime(i) {
if (i < 10) {
i = "0" + i;
}
return i;
}
function startTime() {
var today = new Date();
var h = today.getHours();
var m = today.getMinutes();
var s = today.getSeconds();
// add a zero in front of numbers<10
m = checkTime(m);
s = checkTime(s);
document.getElementById('time').innerHTML = h + ":" + m + ":" + s;
t = setTimeout(function() {
startTime()
}, 500);
}
startTime();
</code></pre>
| <javascript><html><css> | 2019-08-16 03:42:54 | LQ_CLOSE |
57,519,348 | Is Java a dynamic programming language? | <p>The definition of Dynamic Programming language says "These languages are those which perform multiple general behaviours at run-time in contrary to static programming languages which do the same at compile time. It can be by addition of new code, by extending objects and definitions".</p>
<p>To the best of my knowledge many programming languages have encapsulation in form of packages like Java or header files like C++. So, the code that as a programmer I will write will certainly expand at compile time and would be eventually converted to assembly code and finally to machine code. So does every high level language becomes dynamic?</p>
| <java><programming-languages><computer-science> | 2019-08-16 05:36:56 | LQ_CLOSE |
57,519,512 | String and dots filling | <p>Write a program (without using loops) which given a string, of size less
than 5, and a positive integer less than 100, prints both of them with
enough dots in between so that the whole string has 20 characters in them.</p>
<p>I know that if I am not using loops I have to use print(..., sep="") supresses the blank between the objects ,printed.</p>
<p>Can somebody tell me How do I restrict new string length to 20 characters?</p>
| <python><python-3.x><string> | 2019-08-16 05:57:52 | LQ_CLOSE |
57,519,863 | How can read from some files and write content of them with different form into files with same names | <p>I have some files with names f_1to2.txt, f_1to3.txt, f_2to1.txt, f_2to3.txt, ..., f_99to100.txt. I want to do something with the contents of these files and then write these changed files with the same names into another folder. How can I do it? thanks a lot.</p>
| <c++> | 2019-08-16 06:30:55 | LQ_CLOSE |
57,520,573 | No podspec found for `React-fishhook` | <p>When I upgrade react-native version 0.60.4 to 0.60.5, I find this error message after I try to <code>pod install</code> my iOS project. And I can not find any file under <code>node_models/react-native/Libraries/React-fishhook</code>, how should install it?</p>
| <ios><react-native> | 2019-08-16 07:33:30 | HQ |
57,520,927 | Array of dynamic length in c | #include <stdio.h>
#include <string.h>
#include<stdlib.h>
int main(void)
{
char *names = NULL;
int capacity = 0;
int size = 0;
printf("Type 'end' if you want to stop inputting
names\n");
while (1)
{
char name[100];
printf("Input:\n");
fgets(name, sizeof(name), stdin);
if (strncmp(name, "end", 3) == 0)
{
break;
}
if (size == capacity)
{
char *temp = realloc(names, sizeof(char) * (size + 1));
if (!temp )
{
if (names)
{
return 1;
}
}
names = temp;
capacity++;
}
names[size] = name;
size++;
}
for(int i=0;i<size; i++)
{
printf("OUTPUT :%c\n", names[i]);
}
if (names)
{
free(names);
}
}
I am trying to create an array of dynamic length in c but I don't know what is wrong with my code? I think it is cause of how I take the user input and the problem occurs when the code" names [size]= name " is executed | <c><arrays><pointers><dynamic-memory-allocation> | 2019-08-16 08:00:28 | LQ_EDIT |
57,521,050 | How to add VAT in Stripe Checkout? | <p>I'm using Stripe Checkout to create a subscription in Stripe Billing. Checkout also auto creates the Stripe customer object.</p>
<p>How can I add right right VAT rate based on where the customer is based? The customer should be able to see the price both including and excluding VAT/GST both in the checkout session itself and on the invoice.</p>
<p>The "create subscription" API call allows you to set the field "default_tax_rates" which sounds like what I need, but the problem is that with Stripe Checkout the subscription (and the customer object) are created automatically by Stripe Checkout so I cannot explicitly pass parameters to these creation calls.</p>
<p>I know how to calculate the VAT rate and I don't want to integrate with another third party vendor just for tax, so I'm not looking for something like Quaderno or Taxamo.</p>
<p>How do people solve this problem? I'm starting to think that maybe I should have integrated with Chargebee instead of Stripe :-(</p>
| <stripe-payments><tax> | 2019-08-16 08:09:35 | HQ |
57,523,499 | How to select second colomn of every xts in list | I have a list containing 100 xts files of same dimensions. Now I want to select second column of every file.
I have used following code but this selects second row of every file
```
lapply(list,"["c,(2))
````
Plz suggest how to modify above code to select columns | <r> | 2019-08-16 11:03:55 | LQ_EDIT |
57,523,580 | Generate password with minimum and maximum length : batch file | <p>Trying to generate password with given characters but need to define minimum and maximum password string length inside batch file.</p>
<p>i created batch file which is generating password string perfectly but i was unable to define length of string in Min_RNDLength & Max_RNDLength field.</p>
<pre><code>@Echo Off
Setlocal EnableDelayedExpansion
Set Min_RNDLength=8
Set Max_RNDLength=30
Set _Alphanumeric=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz0123456789
Set _Str=%_Alphanumeric%987654321
:_LenLoop
IF NOT "%_Str:~18%"=="" SET _Str=%_Str:~9%& SET /A _Len+=9& GOTO :_LenLoop
SET _tmp=%_Str:~9,1%
SET /A _Len=_Len+_tmp
Set _count=0
SET _RndAlphaNum=
:_loop
Set /a _count+=1
SET _RND=%Random%
Set /A _RND=_RND%%%_Len%
SET _RndAlphaNum=!_RndAlphaNum!!_Alphanumeric:~%_RND%,1!
If !_count! lss %_RNDLength% goto _loop
Echo Random string is !_RndAlphaNum!
</code></pre>
<p>not sure how to overcome this issue.</p>
| <batch-file> | 2019-08-16 11:09:44 | LQ_CLOSE |
57,523,918 | inner product two rows in matrix C++ with Eigen | <p>I want to do an inner product as below.
MatrixXd a= [1,2,3,4]
MatrixXd b= [1,2,3,4]</p>
<p>a*b = [1,4,9,16] <=> c[i] = a[i]*b[i].</p>
<p>How to do it with Eigen MatrixXd?</p>
<p>Thanks.</p>
| <c++><arrays><matrix><eigen> | 2019-08-16 11:34:05 | LQ_CLOSE |
57,524,467 | How do I enclose multiple rails database queries into an atomic statement? | I'm manipulating multiple rails database queries which includes two different databases. I want them to enclose such that if one of the queries fails, all others must rollback. In short, I wanna convert them into an atomic statement.
a). LocationRole.create!(
role: new_params[:role],
resource_type: 'Hub',
resource_id: hub_data[:hub_id],
user_id: new_params[:user_id]
)
b). LocationRole.create!(
role: new_params[:role],
resource_type: 'Cluster',
resource_id: input[:cluster_id],
user_id: new_params[:user_id]
)
c). User.create(:email=>email,:password=>password,:user_type=>user_type) | <ruby-on-rails> | 2019-08-16 12:13:27 | LQ_EDIT |
57,527,754 | Using MS SQL how to use select criteria based on sum | Given the below table and using SQL (sql-server preferred), how can I do a select so that only the ProductID's that sum to the first 200 orders or less is returned. In other works, I'd like ID's for 'Corn Flakes', 'Wheeties' returned since this is close to the sum of 200 orders but returning anything more would be over the limit.
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/x88aZ.png | <sql><sql-server> | 2019-08-16 16:00:51 | LQ_EDIT |
57,528,277 | How to pass data to component to another component | <p>I need help, at the last days I was tring to pass data between components... I followed alot of samples around internet, and none of those works.</p>
<p>The most tutorials says to me to use @input and @output. i think this is the most correct way to pass data in angular...</p>
<p>Here is my structure:</p>
<p>The componentA is called in html of componentC, like this: </p>
<pre><code><app-componentA</app-componentA>
</code></pre>
<p>The componentB is called via modalController</p>
<p><a href="https://i.stack.imgur.com/By6jF.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/By6jF.png" alt="my structure"></a></p>
<p>in my actual code, i pass the data generated in componentB to componentC like this:</p>
<pre class="lang-js prettyprint-override"><code>// componentB.ts
dimiss(filters?: any) {
this.modalController.dismiss(filters);
}
</code></pre>
<p>and recive in componentC:</p>
<pre class="lang-js prettyprint-override"><code>// componentC.ts
const filters = await modal.onDidDismiss();
this.Myfilters = filters ;
</code></pre>
<p>now how i pass the data from componentB to ComponentA?</p>
| <angular><typescript><input><output><ionic4> | 2019-08-16 16:41:10 | LQ_CLOSE |
57,528,785 | Why does a hash value change while hashing from different file formats? | <p>I have observed that when I hash data from a *.txt file and a *.docx file the both hash generated are different even though the data is same in both the file.
Why does this happen?</p>
| <python><hash><cryptography><digital-signature><sha256> | 2019-08-16 17:23:02 | LQ_CLOSE |
57,528,927 | how i can start with this problem and fix my code? | the question : write a program that gets a list of numbers ( lets say 4 numbers ) and an extra number and checks if the extra number equals to the multiplying of two numbers from the list , if yes return true else return false , for example a number list is ( 2,4,8,16) an extra number is 32 , the program checks if 32 is equal to two numbers of the numbers from the list , and return true , in this example it will , because 32 equals to , my solution is below but its not correct , any help appreciated :-
[code below][1]
[1]: https://i.stack.imgur.com/MyRoy.png | <c> | 2019-08-16 17:37:13 | LQ_EDIT |
57,529,635 | PYQT5 self.close() will close the program even though selfEvent() has self.ignore() inside | when i click 'X' on my application, and press "No" from MessageBox, the program **will not be closed**. But when i click "Quit" from the Menu and click "No" from the MessageBox, the program **will still be closed** successfully....
my code is something like this:
```
exitAction = menu.addAction("Quit")
exitAction.triggered.connect(self.close)
```
then my closeEvent() code is:
```
def closeEvent(self, event):
reply = QMessageBox.question(self, 'Quit', 'Are You Sure to Quit?', QMessageBox.No | QMessageBox.Yes)
if reply == QMessageBox.Yes:
event.accept()
else:
event.ignore()
``` | <python><python-3.x><pyqt5> | 2019-08-16 18:42:44 | LQ_EDIT |
57,529,726 | C# error cannot convert sytem.text.regularexpressions.match to string | <p>The following block of code captures text from an HTML page, but I get the compile error on the following line:</p>
<pre><code>St = Regex.Match(St, @"(?i)(?<= |^)order(?= |$) (?i)(?<= |^)Term (?i)(?<= |^)oF [0-9]* (?i)(?<= |^)years (?<= |^)or (?<= |^)Longer");
</code></pre>
<p><strong>The code Block</strong>: </p>
<pre><code> if (textordernode.InnerHtml.Contains("Order Term"))
{
String St = textordernode.InnerHtml;
St = St.Replace(@"\r", "");
St = St.Replace(@"\n", "");
St = Regex.Replace(St, @"<[^>]+>|&nbsp;", " ").Trim();
St = Regex.Match(St, @"(?i)(?<= |^)order(?= |$) (?i)(?<= |^)Term (?i)(?<= |^)oF [0-9]* (?i)(?<= |^)years (?<= |^)or (?<= |^)Longer");
int pFrom = St.IndexOf("Order Term of ") + "Order Term of ".Length;
int pTo = St.LastIndexOf("or longer");
try
{
textorderterm = St.Substring(pFrom, pTo - pFrom) + "or longer";
break;
}
catch (Exception ex)
{
textorderterm = "";
Console.WriteLine(ex.Message);
}
}
</code></pre>
<p>Could I get some help with this please?</p>
| <c#><regex> | 2019-08-16 18:50:29 | LQ_CLOSE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.