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 |
|---|---|---|---|---|---|
55,857,956 | Types cannot be provided in put mapping requests, unless the include_type_name parameter is set to true | <p>I am using <a href="https://github.com/babenkoivan/scout-elasticsearch-driver" rel="noreferrer">https://github.com/babenkoivan/scout-elasticsearch-driver</a> to implement Elasticsearch with Laravel Scout. Ivan mentions this at Github:</p>
<blockquote>
<p>Indices created in Elasticsearch 6.0.0 or later may only contain a single mapping type. Indices created in 5.x with multiple mapping types will continue to function as before in Elasticsearch 6.x. Mapping types will be completely removed in Elasticsearch 7.0.0.</p>
</blockquote>
<p>If I understood right here: <a href="https://www.elastic.co/guide/en/elasticsearch/reference/master/removal-of-types.html" rel="noreferrer">https://www.elastic.co/guide/en/elasticsearch/reference/master/removal-of-types.html</a> I either need to use: </p>
<p>1) PUT index?include_type_name=true</p>
<p>or, better</p>
<p>2)
PUT index/_doc/1
{
"foo": "baz"
}</p>
<p>I am stucked since I have no idea how to use either 1) or 2)</p>
<p>How can I add the parameter include_type_name=true?</p>
<p>How can I create the right mapping without using the include_type_name parameter?</p>
<pre><code>class TestIndexConfigurator extends IndexConfigurator
{
use Migratable;
/**
* @var array
*/
protected $settings = [
];
protected $name = 'test';
}
</code></pre>
| <laravel><elasticsearch> | 2019-04-25 21:35:46 | HQ |
55,858,317 | How to display these results in bootstrap 3 tables | I would like to display the information in the columns of a database using php but need the table to be styled using bootstrap 3 and not the default html table tag.
I would like to display the information in the columns of a database using php but need the table to be styled using bootstrap 3 and not the default html table tag.
I would like to display the information in the columns of a database using php but need the table to be styled using bootstrap 3 and not the default html table tag.
<?php
$connect = mysqli_connect("localhost", "root", "", "oas");
if ($connect) {
$search = "";
$query = "SELECT distinct(M.`s_id`) as `s_id`,
M.`s_mark`,
U.`s_name`
FROM `t_usermark` as M
JOIN `t_user_data` as U on M.s_id = U.s_id WHERE `s_name` like '%$search%'";
$result = mysqli_query($connect, $query);
if ($result) {
if (mysqli_num_rows($result) > 0) {
echo "
<table>
<tr>
<th>ID</th>
<th>Name</th>
<th>Mark</th>
</tr>
";
while ($row = mysqli_fetch_array($result)) {
$id = $row['s_id'];
$mark = $row['s_mark'];
$name = $row['s_name'];
echo "
<tr>
<td>$id</td>
<td>$name</td>
<td>$mark</td>
</tr>
";
// echo "<p>$id</p><p>$mark</p><p>$name</p>";
}
} else {
echo "No results";
}
echo "</table>";
} else {
echo mysqli_error($connect);
}
} else {
echo "Database connection failed";
}
?> | <php><twitter-bootstrap> | 2019-04-25 22:14:46 | LQ_EDIT |
55,858,588 | How to convert u8 to &[u8] in Rust? | <p>I am new and lost in Rust a bit.</p>
<p>I would like to add keys and values to a data store that has a put function that takes two byte string literals:</p>
<pre><code>batch.put(b"foxi", b"maxi");
</code></pre>
<p>I generate a bunch of these k-v pairs:</p>
<pre><code>for _ in 1..1000000 {
let mut ivec = Vec::new();
let s1: u8 = rng.gen();
let s2: u8 = rng.gen();
ivec.push(s1);
ivec.push(s2);
debug!("Adding key: {} and value {}", s1, s2);
vec.push(ivec);
}
let _ = database::write(db, vec);
</code></pre>
<p>I have a fn that tries to add them:</p>
<pre><code>pub fn write(db: DB, vec: Vec<Vec<u8>>) {
let batch = WriteBatch::new();
for v in vec {
batch.put(v[0], v[1]);
}
db.write(&batch).unwrap();
}
</code></pre>
<p>When I try to compile this I get:</p>
<pre><code>error[E0308]: mismatched types
--> src/database.rs:17:19
|
17 | batch.put(v[0], v[1]);
| ^^^^ expected &[u8], found u8
|
= note: expected type `&[u8]`
found type `u8`
error[E0308]: mismatched types
--> src/database.rs:17:25
|
17 | batch.put(v[0], v[1]);
| ^^^^ expected &[u8], found u8
|
= note: expected type `&[u8]`
found type `u8`
</code></pre>
<p>I was ping-ponging with the borrow checker for a while now but I could not get it working. What is the best way to have byte literal strings from u8s?</p>
| <rust> | 2019-04-25 22:48:23 | LQ_CLOSE |
55,859,949 | How do I get the current time from the internet? | <p>I have browsed the whole site to find a solution. But none of the ones I found worked. And most of them were pretty old. So I want to get the current UTC time from the internet. Completely independent from the phone.</p>
<p>Would be nice if someone could help me.</p>
| <java><android><time><utc><ntp> | 2019-04-26 02:17:24 | LQ_CLOSE |
55,860,171 | protect_from_forgery in Rails 6? | <p>The <code>protect_from_forgery</code> method isn't included in my application controller with a default Rails 6 app, but there's the embedded ruby <code><%= csrf_meta_tags %></code> in the main application layout. Does this mean that the <code>protect_from_forgery</code> method has been abstracted and is no longer explicitly needed in the application controller? </p>
<p>I've bought the Pragmatic Programmer's Rails 6 book and the only thing I could find was "the csrf_meta_tags() method sets up all the behind-the-scenes data needed to prevent cross-site request forgery attacks".</p>
| <ruby-on-rails><ruby><csrf><csrf-token> | 2019-04-26 02:52:30 | HQ |
55,860,243 | SharedPrefferences is saving only the last value | i try to use SharedPreferences but its only saving the last value.
Main Activity
```
mypreference.setPrice(txtPrice.text.toString().toFloat())
mypreference.setSABV(txtABV.text.toString().toFloat())
```
SharedPreference
```
class myPreferences(context: Context){
val PREFERENCENAME = "BeerNote"
val PRICE = 0.0f
val ALCOHOLBYVOLUME = 0.0f
val preference = context.getSharedPreferences(PREFERENCENAME,Context.MODE_PRIVATE)
fun setPrice(price:Float){
preference.edit().putFloat(PRICE.toString(),price).apply()
}
fun getPrice():Float{
return preference.getFloat(PRICE.toString(),0.0f)
}
fun setSABV(abv:Float){
preference.edit().putFloat(ALCOHOLBYVOLUME.toString(),abv).apply()
}
fun getABV():Float{
return preference.getFloat(ALCOHOLBYVOLUME.toString(),0.0f )
}
}
```
when i try to recover the data
```
Toast.makeText(this, "Price:"+mypreference.getPrice(), Toast.LENGTH_LONG).show()
Toast.makeText(this, "ABV:"+mypreference.getABV(), Toast.LENGTH_LONG).show()
```
only saves the ABV value in Price and ABV | <android><kotlin><sharedpreferences> | 2019-04-26 03:02:00 | LQ_EDIT |
55,860,628 | Program doesn't run. Says I am trying to assign value to a pointer. Please help to fix | I am trying to read file into an array, but the code doesn't run. Says I am trying to assign value to a pointer. Please help to fix
#include <stdio.h>
int main(){
FILE *ifile;
float num;
float*numbers[8001];
float pointer=numbers;
int i=0;
ifile = fopen("lotsOfNumbers.txt", "r");
if (ifile == NULL) {
printf("File not found!! Exiting.\n");
} else {
while (fscanf(ifile, "%f ", &num)!=EOF) {
//printf("I read %d from the file. \n", num);
numbers[i]=#
if (i<8801){
i++;
}
else
return 0;
}
}
fclose(ifile);
return 0;
} | <c> | 2019-04-26 03:59:46 | LQ_EDIT |
55,861,003 | How to increase the collection view image width & height equal to screen in swift 4.2? | How to increase the collection view image width & height equal to screen in swift 4.2 ? | <ios><uicollectionviewcell><swift4.2> | 2019-04-26 04:53:21 | LQ_EDIT |
55,862,051 | android studio issue in signing in to an application | I have an issue regarding signing in..!
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
package com.example.myapplication;
import android.app.ProgressDialog;
import android.content.Intent;
import android.support.annotation.NonNull;
import android.support.v7.app.AppCompatActivity;
import android.os.Bundle;
import android.text.TextUtils;
import android.view.View;
import android.widget.Button;
import android.widget.EditText;
import android.widget.Toast;
import com.google.android.gms.tasks.OnCompleteListener;
import com.google.android.gms.tasks.Task;
import com.google.firebase.auth.FirebaseAuth;
import com.google.firebase.database.DataSnapshot;
import com.google.firebase.database.DatabaseError;
import com.google.firebase.database.DatabaseReference;
import com.google.firebase.database.FirebaseDatabase;
import com.google.firebase.database.ValueEventListener;
import java.util.HashMap;
public class RegisterActivity extends AppCompatActivity
{
private Button CreateAccountButton;
private EditText InputName, InputPhoneNumber, InputPassword;
private ProgressDialog loadingBar;
FirebaseAuth mAuth;
@Override
protected void onCreate(Bundle savedInstanceState)
{
super.onCreate(savedInstanceState);
setContentView(R.layout.activity_register);
CreateAccountButton = (Button) findViewById(R.id.main_register_btn);
InputName = (EditText) findViewById(R.id.register_username_input);
InputPassword = (EditText) findViewById(R.id.register_password_input);
InputPhoneNumber = (EditText) findViewById(R.id.register_phone_number_input);
loadingBar = new ProgressDialog(this);
mAuth = FirebaseAuth.getInstance();
CreateAccountButton.setOnClickListener(new View.OnClickListener() {
@Override
public void onClick(View v)
{
CreateAccount();
}
});
}
private void CreateAccount()
{
String name = InputName.getText().toString();
String phone = InputPhoneNumber.getText().toString();
String password = InputPassword.getText().toString();
if (TextUtils.isEmpty(name))
{
Toast.makeText(this, "please enter your name", Toast.LENGTH_SHORT).show();
}
else if (TextUtils.isEmpty(phone))
{
Toast.makeText(this, "please enter your phone number", Toast.LENGTH_SHORT).show();
}
else if (TextUtils.isEmpty(password))
{
Toast.makeText(this, "please enter your password", Toast.LENGTH_SHORT).show();
}
else
{
loadingBar.setTitle("Create Account");
loadingBar.setMessage("Please wait, While we are checking the credentials");
loadingBar.setCanceledOnTouchOutside(false);
loadingBar.show();
validatephonenumber(name, phone, password);
}
}
private void validatephonenumber(final String name, final String phone, final String password)
{
final DatabaseReference RootRef;
RootRef = FirebaseDatabase.getInstance().getReference();
RootRef.addListenerForSingleValueEvent(new ValueEventListener()
{
@Override
public void onDataChange(@NonNull DataSnapshot dataSnapshot)
{
if(dataSnapshot.child("Users").child(phone).exists())
{ Toast.makeText(RegisterActivity.this, "this" +phone+ "alredy exists", Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
Toast.makeText(RegisterActivity.this, "Please try using another phone number", Toast.LENGTH_SHORT).show();
Intent intent= new Intent(RegisterActivity.this, MainActivity.class);
startActivity(intent);
}
else
{
HashMap<String, Object> userdataMap = new HashMap<>();
userdataMap.put("Phone", phone);
userdataMap.put("password", password);
userdataMap.put("name", name);
RootRef.child("User").child(phone).updateChildren(userdataMap)
.addOnCompleteListener(new OnCompleteListener<Void>() {
@Override
public void onComplete(@NonNull Task<Void> task)
{
if (task.isSuccessful())
{
Toast.makeText(RegisterActivity.this, "Congratulations your account has been created ", Toast.LENGTH_SHORT).show();
loadingBar.dismiss();
Intent intent= new Intent(RegisterActivity.this, loginActivity.class);
startActivity(intent);
}
else
{
loadingBar.dismiss();
Toast.makeText(RegisterActivity.this, "Network Error: Please try again", Toast.LENGTH_SHORT).show();
}
}
});
}
}
@Override
public void onCancelled(@NonNull DatabaseError databaseError) {
}
});
}
}
<!-- end snippet -->
when I'm using this code and signing in with a phone number for second it should actually prompt "this number already exists" but its working and upon siging in with same number again all the older names and passwords are being replpaced by new ones....how can i solve this issue??? | <java><android><firebase><firebase-authentication> | 2019-04-26 06:36:13 | LQ_EDIT |
55,862,573 | create an array till any particular number in reactjs | <p>I am a beginner in React js and trying to do some operations.</p>
<p>I want to create an array till the length of any array (particular number)
suppose my array length is 10 , then the array should be</p>
<p>my state variables-</p>
<pre><code> this.state{
length = 10,
length_array= []
}
handleClick = () =>{
this.setState{
length_array:[1,2,3,4,5,6,7,8,9,10]
}}
</code></pre>
<p>I want to display this array in my table header</p>
<pre><code><Table>
<tr>
<th>
this.state.length_array.map((item, key) =>
<th>{item.name}</th>
);
</th>
</tr>
</Table>
</code></pre>
<p>Thanks.</p>
| <javascript><reactjs> | 2019-04-26 07:15:26 | LQ_CLOSE |
55,864,302 | How to parse JSON to MySql | I have a JSON string from a http request I need to store in a MySql table, columns and rows
I need to do it in Node.js. It's not a problem to get the JSON string via the http request. http://lonobox.com/api/index.php?id=100004854
The problem is to convert it to columns and rows and store it in MySql. Alternative postgre | <mysql><node.js><json><http> | 2019-04-26 09:08:52 | LQ_EDIT |
55,864,381 | Strange behaviour of Array.reduce() | Data:
arr = [0, 0, 0, 1, 1]
Code:
###1
!arr[0] + !arr[1] + !arr[2] + !arr[3] + !arr[4]
// 3, correct!
but ...
###2
arr.reduce((a, b) => (!a + !b));
// 1, bullshit?!
Question:
Why is **1**. and **2**. not the same? Makes no sense to me? How can I reduce() my array to give me the same as in **1**.
| <javascript><reduce> | 2019-04-26 09:13:31 | LQ_EDIT |
55,865,219 | when to use move in function calls | <p>I am currently learning mor about all the c++11/14 features and wondering when to use std::move in function calls.</p>
<p>I know I should not use it when returning local variables, because this breaks Return value optimisation, but I do not really understand where in function calls casting to a rvalue actually helps.</p>
| <c++><move> | 2019-04-26 10:01:39 | HQ |
55,865,661 | Convert arrays with object to array | <pre><code>{"result":[{"id":1,"currency":"USD"},{"id":2,"currency":"PLN"},{"id":3,"currency":"EUR"}],"success":true}
</code></pre>
<p>I would like to have array with only id:</p>
<pre><code>[1, 2, 3]
</code></pre>
| <javascript><arrays><reactjs><object> | 2019-04-26 10:28:00 | LQ_CLOSE |
55,866,623 | How to convert string dd-MMM-yyyy HH:mm int0 datetime format in javascript | <p>I have string value like "26-APR-2019 16:40". I want to convert this in to date time in java script. Please help me.</p>
| <javascript> | 2019-04-26 11:26:20 | LQ_CLOSE |
55,866,635 | Why String.split(":") doesn't work correctly | I have problem with `split()` method. I am parsing response from `api` and splitting time to hours and minutes. I've found out that split() gives me wrong values. I've made screenshot of my code while debugging because I didn't know how can i show it to you<br>
[![enter image description here][1]][1]
<br><br>
As you can see `time` value is "08:15" but `tTime[0]` is "".<br>
Weird thing is while parsing I am getting `time` inside `for` loop and I get "08:15" when I'm reading 10th item, all from 0 to 8 are fine. Is it problem with code or `split()` method itself?
[1]: https://i.stack.imgur.com/32KZ1.png | <java><string> | 2019-04-26 11:27:06 | LQ_EDIT |
55,868,000 | Is it possible to remove property from Custom Class in c# | <pre><code>public class abc
{
public int id{get;set;}
public string name{get;set;}
}
</code></pre>
<p>I want to remove property name from class abc dynamically. is it possible in c#?</p>
| <c#> | 2019-04-26 12:47:55 | LQ_CLOSE |
55,869,429 | How to route from one application to another application in angular 2+ | <p>I have two different application in angular 7 and I want to navigate between them. How do I achieve it by using angular routing?</p>
| <angular><angular2-routing> | 2019-04-26 14:10:43 | LQ_CLOSE |
55,870,046 | cant resolve method getInputStream() | i am creating app in anroidstudio i implemeted a method but getting error: cant resolve method "getInputStream"
BufferedReader in = new BufferedReader( new
InputStreamReader(clienSocket.getInputStream()));
.getInputStream() method not resolving | <java><android> | 2019-04-26 14:47:17 | LQ_EDIT |
55,870,127 | Module 'tensorflow' has no attribute 'contrib' | <p>I am trying to train my own custom object detector using Tensorflow Object-Detection-API </p>
<p>I installed the tensorflow using "pip install tensorflow" in my google compute engine. Then I followed all the instructions on this site: <a href="https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html" rel="noreferrer">https://tensorflow-object-detection-api-tutorial.readthedocs.io/en/latest/training.html</a> </p>
<p>When I try to use train.py I am getting this error message:</p>
<blockquote>
<p>Traceback (most recent call last):
File "train.py", line 49, in
from object_detection.builders import dataset_builder
File "/usr/local/lib/python3.6/dist-packages/object_detection-0.1->py3.6.egg/object_detection/builders/dataset_builder.py", line 27, in
from object_detection.data_decoders import tf_example_decoder
File "/usr/local/lib/python3.6/dist-packages/object_detection-0.1-py3.6.egg/object_detection/data_decoders/tf_example_decoder.py", line 27, in
slim_example_decoder = tf.contrib.slim.tfexample_decoder
AttributeError: module 'tensorflow' has no attribute 'contrib'</p>
</blockquote>
<p>Also I am getting different results when I try to learn version of tensorflow.</p>
<blockquote>
<p>python3 -c 'import tensorflow as tf; print(tf.<strong>version</strong>)' : 2.0.0-dev20190422</p>
</blockquote>
<p>and when I use</p>
<blockquote>
<p>pip3 show tensorflow: </p>
<p>Name: tensorflow
Version: 1.13.1
Summary: TensorFlow is an open source machine learning framework for everyone.
Home-page: <a href="https://www.tensorflow.org/" rel="noreferrer">https://www.tensorflow.org/</a>
Author: Google Inc.
Author-email: opensource@google.com
License: Apache 2.0
Location: /usr/local/lib/python3.6/dist-packages
Requires: gast, astor, absl-py, tensorflow-estimator, keras-preprocessing, grpcio, six, keras-applications, wheel, numpy, tensorboard, protobuf, termcolor
Required-by: </p>
</blockquote>
<pre><code> sudo python3 train.py --logtostderr --train_dir=training/ --
pipeline_config_path=training/ssd_inception_v2_coco.config
</code></pre>
<p>What should I do to solve this problem? I couldn't find anything about this error message except this: <a href="https://stackoverflow.com/questions/38238192/tensorflow-module-object-has-no-attribute-contrib">tensorflow 'module' object has no attribute 'contrib'</a></p>
| <tensorflow> | 2019-04-26 14:53:01 | HQ |
55,870,255 | change the currently being displayed string from an array | <p>I would like to change the current string displayed on the screen by pressing buttons. for example:</p>
<p>I have an array of strings here:</p>
<pre><code>std::string test[] = { "hey", "how", "are", "you" };
</code></pre>
<p>then i have some code here to change the current displayed string from the array:</p>
<pre><code>if (GetAsyncKeyState(VK_LEFT))
//display one string left from the array
else if (GetAsyncKeyState(VK_RIGHT))
//display string next to the current one in array
std::cout << test;
</code></pre>
<p>so what kind of code should i put to the commented parts???</p>
| <c++> | 2019-04-26 15:00:46 | LQ_CLOSE |
55,870,581 | What's The Best Practices To Store Large Data Into MYSQL Database | What's your best practice to store large data into MYSQL?
E.g I want to create a site showing second hand car details with following items:
1. List item
2. Car Name
3. Car Model
4. Car Brand Name
5. Car Info 4
6. Car Info 5
7. Car Info 6
8. Car Info 7
9. Car Description........
These are some of the (text) related information which I want to store and it might be more than 30 items.
Now, there are some Images and Videos related to the car, owner information and many other details.
Now, what's the best practice of storing large data into the database?
| <mysql><database> | 2019-04-26 15:18:47 | LQ_EDIT |
55,871,383 | why is the value of b when printed 23 and not 46? | var a = 23;
var b = a;
a = 46;
console.log(a);
console.log(b);
**why is the value of b when printed 23 and not 46 ?
O/P : a=46, b=23, why?
** | <javascript> | 2019-04-26 16:10:35 | LQ_EDIT |
55,871,711 | I WANT TO RETRIEVE MAX VALUE FROM TWO COLUMN - SQL TABLE | WANT TO GET MAX VALUE FROM COLUMN COL1 AND COL2
Emp_id col1 col1
1251 2019-01-25 00:01:35.000 2019-01-25 08:56:30.000
1251 2019-01-25 15:15:06.000 2019-01-25 16:09:25.000
1251 2019-01-25 18:00:26.000 NULL | <sql><sql-server> | 2019-04-26 16:32:56 | LQ_EDIT |
55,872,104 | I want to understand how can i run a google app-script to extract information of schools in a certain state | Im trying to create a data base for all the school in a certain state. I have written a google app-script that pulls the details of a school and inserts it in a spreadsheet. The problem is that I want to automate the process of changing the name of the school in the url based on the ones I have.
I have looking also for to extract the place_id based on a Lat and Long and with type=school but is not working, only pulls 20 schools
function onOpen() {
var ui = SpreadsheetApp.getUi();
ui.createMenu('Google Place Search')
.addItem('Buscar Informacion','callgooglemapsapi')
.addToUi();
}
function callgooglemapsapi()
{
var response = UrlFetchApp.fetch("https://maps.googleapis.com/maps/api/place/findplacefromtext/json?input=El%20Colegio%20de%20Tamaulipas&inputtype=textquery&fields=formatted_address,type,place_id,geometry,icon,id,name,permanently_closed,photos,place_id,plus_code,user_ratings_total&key=AIzaSyDQlB5xlLhSQZhdIkBGR0WXiWPLVqMwKkM");
// Parse the JSON reply
var json = response.getContentText();
var data = JSON.parse(json);
Logger.log(data);
Logger.log(data["candidates"]);
Logger.log(data["candidates"][0]);
var sheet = SpreadsheetApp.getActiveSheet();
sheet.getRange(sheet.getLastRow() + 1,1).setValue(data["candidates"][0]["name"]);
sheet.getRange(sheet.getLastRow() + 0,2).setValue(data["candidates"][0]["formatted_address"]);
sheet.getRange(sheet.getLastRow() + 0,3).setValue(data["candidates"][0]["geometry"]["location"]["lng"]);
sheet.getRange(sheet.getLastRow() + 0,4).setValue(data["candidates"][0]["geometry"]["location"]["lat"]);
sheet.getRange(sheet.getLastRow() + 0,5).setValue(data["candidates"][0]["geometry"]["viewport"]["southwest"]["lng"]);
sheet.getRange(sheet.getLastRow() + 0,6).setValue(data["candidates"][0]["geometry"]["viewport"]["southwest"]["lat"]);
sheet.getRange(sheet.getLastRow() + 0,7).setValue(data["candidates"][0]["geometry"]["viewport"]["northeast"]["lng"]);
sheet.getRange(sheet.getLastRow() + 0,8).setValue(data["candidates"][0]["geometry"]["viewport"]["northeast"]["lat"]);
sheet.getRange(sheet.getLastRow() + 0,9).setValue(data["candidates"][0]["place_id"]);
sheet.getRange(sheet.getLastRow() + 0,10).setValue(data["candidates"][0]["photo_reference"]);
sheet.getRange(sheet.getLastRow() + 0,11).setValue(data["candidates"][0]["plus_code"]);
sheet.getRange(sheet.getLastRow() + 0,12).setValue(data["candidates"][0]["types"]);
I expect to extrat the detail information and photos and insert them to a spreadsheet, I have 4,000 school names.
| <sql><json><google-maps><google-apps-script> | 2019-04-26 17:02:24 | LQ_EDIT |
55,872,167 | convert "unspecified encoding" string to a binary string of zeros and ones | well ,i have an assignment to implement the operation modes of the DES algorithm
in CBC mode : i am stuck at the point where the output of the encryption function gives bytes like this : b'\xe4\x06-\x95\xf5!P4'
(i am using DES library from Crypto.Cipher)
i don't know what is that representation or how to convert it to a binary string of zeros and ones , to xor it with the 2nd plain text.
any help would be highly appreciated | <python><unicode><undefined><des><python-cryptography> | 2019-04-26 17:08:05 | LQ_EDIT |
55,872,340 | How to write a query that is an employee who has the highest sales to the customer who has made the most purchases.In Sql Server | I'm having trouble with this question in my Database homework And need to answer this question:
**Which employee has the highest sales to the customer who has made the most purchases?**
And these are my database tables
[![enter image description here][1]][1]
[1]: https://i.stack.imgur.com/HujP6.png
Please, help me to write this Query. | <sql><sql-server><group-by><aggregate-functions> | 2019-04-26 17:20:41 | LQ_EDIT |
55,872,901 | TypeError: must be str, not int, don't understand what i'm doing wrong | I need help with the following code, because i can't understand what i'm doing wrong.
It's a function for my the game Minesweeper which receives a position like "C3" and has to return an int to search a position in a list of available positions.
def evalua_jugada(posicion,posiciones_posibles):
"""Convierte a la posicion ingresada en un numero de la lista de posiciones posibles"""
indice_en_posiciones_posibles = (8 * list(ascii_uppercase).index(posicion[0].upper())) + (posicion[1] + 1)
return(posiciones_posibles[indice_en_posiciones_posibles])
this is my very first post so i don't know how to ident well jajaja.
Anyway hope you can help me.`` | <python-3.x> | 2019-04-26 18:06:34 | LQ_EDIT |
55,873,228 | how to fix KeyValuePair<char, int[]> in foreach statement? | how can i use KeyValuePair<char, int[]> in foreach statement?
the error is Cannot convert type 'char' to 'System.Collections.Generic.KeyValuePair<char, int[]>'
foreach(KeyValuePair<char, int[]> characterEntry in occ_counts_before.Keys)
{
characterEntry.Value[i] = characterEntry.Value[i - 1] + (characterEntry.Key == current ? 1 : 0);
} | <c#> | 2019-04-26 18:34:12 | LQ_EDIT |
55,873,443 | How to render first item in flatlist to full width and remaining items in 2 coloumns |
I need data in react native flaist to display as first item taking full width and remaining elements in single row 2 cloumns.
Item 1
Item 2 item3
Item4 item5
Item6 item 7 and so on | <reactjs><react-native><react-native-flatlist> | 2019-04-26 18:50:18 | LQ_EDIT |
55,874,536 | A weird error occurring when trying to implement useEffect | <p>I am trying to use useEffect inside of my cockpit function that returns a couple of elements, but I get this weird error saying that
"Line 6: React Hook "useEffect" is called in function "cockpit" which is neither a React function component or a custom React Hook function react-hooks/rules-of-hooks".</p>
<p>But surely my cockpit component is a function?</p>
<pre><code>import React, { useEffect } from 'react'
import classes from './Cockpit.css'
const cockpit = (props) => {
useEffect(() => {
console.log('I work!')
})
const assignedClasses = []
let btnClass = ''
if (props.showPersons) {
btnClass = classes.Red;
}
if (props.persons.length <= 2) {
assignedClasses.push(classes.red)
}
if (props.persons.length <= 1) {
assignedClasses.push(classes.bold)
}
return (
<div className={classes.Cockpit}>
<h1>{props.title}</h1>
<p className={assignedClasses.join(' ')}>HELLO, HELLO!</p>
<button
className={btnClass}
onClick={props.clicked}>Click me!</button>
</div>
)
}
export default cockpit
</code></pre>
| <reactjs><react-hooks> | 2019-04-26 20:27:03 | HQ |
55,874,595 | I am getting an error "SyntaxError: missing ) after argument list". How do i resolve it? | <p>I have an error message "SyntaxError: missing ) after argument list"
Kindly help resolve</p>
<p><a href="https://i.stack.imgur.com/3C7iU.png" rel="nofollow noreferrer">Image contains the code for which im getting an error</a></p>
| <javascript><node.js><amazon-web-services><syntax><aws-iot> | 2019-04-26 20:33:11 | LQ_CLOSE |
55,879,142 | python: How to fix this "ValueError"? | I loaded some images (with cv2.imread_color) into a list and i'm trying to get hsv (hue, saturnation, value) values from it with function "rgb_to_hsv".
I got red, green and blue values but when i'm trying to get hsv values i get ***an error about parameters***:
Traceback (most recent call last):
File "C:\Users\Downloads\preprocessing\program.py", line 69, in <module>
hue_images[i], saturnation_images[i], value_images[i] = rgb_to_hsv(hsv_red[i], hsv_green[i], hsv_blue[i])
File "C:\Users\Downloads\preprocessing\program.py", line 24, in rgb_to_hsv
mx = max(r, g, b)
ValueError: The truth value of an array with more than one element is ambiguous. Use a.any() or a.all()
This is the code i'm using:
```python
hue_images = list(range(len(image)))
saturnation_images = list(range(len(image)))
value_images = list(range(len(image)))
hsv_red = list(range(len(image)))
hsv_green = list(range(len(image)))
hsv_blue = list(range(len(image)))
def rgb_to_hsv(r, g, b):
r, g, b = r/255.0, g/255.0, b/255.0
mx = max(r, g, b)
mn = min(r, g, b)
df = mx-mn
if mx == mn:
h = 0
elif mx == r:
h = (60 * ((g-b)/df) + 360) % 360
elif mx == g:
h = (60 * ((b-r)/df) + 120) % 360
elif mx == b:
h = (60 * ((r-g)/df) + 240) % 360
if mx == 0:
s = 0
else:
s = (df/mx)*100
v = mx*100
return h, s, v
def hsv_get_red(img):
red = img.copy()
red[:, :, 0] = 0
red[:, :, 1] = 0
return red[:, :, 2]
def hsv_get_green(img):
green = img.copy()
green[:, :, 0] = 0
green[:, :, 2] = 0
return green[:, :, 1]
def hsv_get_blue(img):
blue = img.copy()
blue[:, :, 2] = 0
blue[:, :, 1] = 0
return blue[:, :, 0]
for i in range(len(image)):
hsv_red[i] = hsv_get_red(image[i])
hsv_green[i] = hsv_get_green(image[i])
hsv_blue[i] = hsv_get_blue(image[i])
for i in range(len(image)):
hue_images[i], saturnation_images[i], value_images[i] = rgb_to_hsv(hsv_red[i], hsv_green[i], hsv_blue[i])
```
My question is: How can I use list values as parameters in the function (it works with int numbers) to get results (another list values)?
Thanks | <python><cv2> | 2019-04-27 09:36:58 | LQ_EDIT |
55,879,550 | How to fix HttpException: Connection closed before full header was received | <p>I have recently upgraded my flutter version in my app. But when I want to debug the application, it shows me the following error.</p>
<p>Error connecting to the service protocol: HttpException: Connection closed before full header was received, uri = <a href="http://127.0.0.1:50795/ws" rel="noreferrer">http://127.0.0.1:50795/ws</a></p>
<p>Is there anyone facing the same issue after upgrading the flutter version? If is there any workaround, please share.</p>
| <http><flutter> | 2019-04-27 10:24:52 | HQ |
55,880,145 | please help hide yandex logo from map? yandex mapkit android | There is no method in the documentation that hides the logo from the map.
https://i.stack.imgur.com/ua4ns.jpg | <android><yandex-maps><yandex-mapkit> | 2019-04-27 11:36:19 | LQ_EDIT |
55,880,311 | How Can I pass a PHP array to a Javascript array | <p>I have an array which have some values stored in it but I want to transfer the elements of that array into javascript array for further processing. How can I do so?</p>
| <javascript><php> | 2019-04-27 11:56:04 | LQ_CLOSE |
55,880,816 | Does AWS supports the Oracle's autonomous Database? | Does AWS has an engine to support Oracle autonomous database ?
https://www.oracle.com/in/database/autonomous-database/feature.html | <amazon-web-services><amazon-rds> | 2019-04-27 13:02:30 | LQ_EDIT |
55,881,317 | "app keep stopping" why cant i run my app? | My app keeps stopping when I open the emulator when it opens.
tried putting in a different application only the first screen and class and still stopped.
its shows:
E/AndroidRuntime: FATAL EXCEPTION: main
Process: com.example.dearpet, PID: 31496
java.lang.RuntimeException: Unable to instantiate activity ComponentInfo{com.example.dearpet/com.example.dearpet.MainActivity}: java.lang.InstantiationException: java.lang.Class<com.example.dearpet.MainActivity> cannot be instantiated
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2839)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Caused by: java.lang.InstantiationException: java.lang.Class<com.example.dearpet.MainActivity> cannot be instantiated
at java.lang.Class.newInstance(Native Method)
at android.app.Instrumentation.newActivity(Instrumentation.java:1180)
at android.app.ActivityThread.performLaunchActivity(ActivityThread.java:2829)
at android.app.ActivityThread.handleLaunchActivity(ActivityThread.java:3030)
at android.app.ActivityThread.-wrap11(Unknown Source:0)
at android.app.ActivityThread$H.handleMessage(ActivityThread.java:1696)
at android.os.Handler.dispatchMessage(Handler.java:105)
at android.os.Looper.loop(Looper.java:164)
at android.app.ActivityThread.main(ActivityThread.java:6938)
at java.lang.reflect.Method.invoke(Native Method)
at com.android.internal.os.Zygote$MethodAndArgsCaller.run(Zygote.java:327)
at com.android.internal.os.ZygoteInit.main(ZygoteInit.java:1374)
Application terminated. | <java><android> | 2019-04-27 14:02:00 | LQ_EDIT |
55,881,647 | Is it possible to get all data from table and insert to another using single query? | <p>Is it possible to get all data from table and insert to another using single query?</p>
<p>Provided that two tables are the same structure</p>
| <mysql><sql> | 2019-04-27 14:39:38 | LQ_CLOSE |
55,882,399 | How to see appended child nodes in `View Page Source`? | <p>I create elements and append them to <code>BODY</code> tag but I don't see them in page source. How can I see newly created tags in the source code?</p>
| <javascript><dom><children> | 2019-04-27 16:07:27 | LQ_CLOSE |
55,882,575 | C++ error expected ";" before 'endl' how to fix it? | <p>Im just started studing c++ and im just learned how for , while , if works and im creating very simple decision game based in console and i have problems with endl; line bc its saying expected ';' before 'endl' and i have problem with it . oh and if someone is wondering what language im using in "" its polish</p>
<p>I tried everything i can ;_;</p>
<pre><code>#include <iostream>
#include <windows.h>
#include <cstdlib>
string wybor;
int main()
{
cout << "budzisz sie w totalej ciemnosci ale zauwazasz w oddali dom"endl;
cout << "A. idz do domu"endl; cout << "B.Podskocz w miejscu"endl;
cin >> wybor;
return 0;
}
</code></pre>
| <c++> | 2019-04-27 16:27:15 | LQ_CLOSE |
55,883,984 | Vue Axios CORS policy: No 'Access-Control-Allow-Origin' | <p>I build an app use vue and codeigniter, but I have a problem when I try to get api, I got this error on console</p>
<pre><code>Access to XMLHttpRequest at 'http://localhost:8888/project/login'
from origin 'http://localhost:8080' has been blocked by CORS policy:
Request header field access-control-allow-origin is not allowed
by Access-Control-Allow-Headers in preflight response.
</code></pre>
<p>I have been try like this on front-end (main.js)</p>
<pre><code>axios.defaults.headers.common['Content-Type'] = 'application/x-www-form-urlencoded'
axios.defaults.headers.common['Access-Control-Allow-Origin'] = '*';
</code></pre>
<p>and this on backend (controller)</p>
<pre><code>header('Access-Control-Allow-Origin: *');
header("Access-Control-Allow-Methods: GET, POST, OPTIONS, PUT, DELETE");
</code></pre>
<p>and vue login method</p>
<pre><code>this.axios.post('http://localhost:8888/project/login', this.data, {
headers: {
"Access-Control-Allow-Origin": "*",
"Access-Control-Allow-Methods": "GET, POST, PATCH, PUT, DELETE, OPTIONS",
"Access-Control-Allow-Headers": "Origin, Content-Type, X-Auth-Token"
}
}).then(res => {
console.log(res);
}).catch(err => {
console.log(err.response);
});
</code></pre>
<p>I've searched and tried in stackoverflow but does not work, how I can solve it? thank you so much for your help</p>
| <json><vue.js><axios> | 2019-04-27 19:11:22 | HQ |
55,884,318 | How to fade in part of a sentence? | <p>I'm trying to make the quotes at the beginning and end of a sentence fade in when someone clicks on a button. How can I make only the quotation marks to fade in instead of the whole sentence?</p>
| <javascript><html><css><fadein> | 2019-04-27 19:48:26 | LQ_CLOSE |
55,884,397 | Is there a way to 'buffer' a background-image in css? | <p>I want my bacgkround-image, which is fairly large, to slowly buffer (not sure if this is the correct use of the word), like first being bad quality then better and then best. IMHO the 'normal' loading mode of displaying a few lines until it has loaded looks ugly. Is there a way to do this?</p>
| <html><css><background-image> | 2019-04-27 19:58:26 | LQ_CLOSE |
55,884,604 | Please provide guidance in understanding recursion | <pre><code>public static int countX(String str) {
if (str.length() == 0) {
return 0;
}
if (str.charAt(0) == 'x') {
return 1 + countX(str.substring(1));
} else {
return countX(str.substring(1));
}
}
</code></pre>
<p>Given an input String of "xxx", the method above shall return 3.
I understand the flow of the method, the line <em>"return 1 + countX(str.substring(1));"</em> adds one if an 'x' is found. What I don't understand is how does that return value carry over to the next iteration/recursion? I don't see the value of the increment stored anywhere.</p>
| <java><recursion> | 2019-04-27 20:26:02 | LQ_CLOSE |
55,885,845 | What is the (condition) ? val1 : val2 statement called? | <p>I am working on a project and need to know what the name of the statement if officially called. I have used it a lot, I just no clue what the name is.</p>
<p>Example statement:</p>
<pre><code>let x = didJump ? 10 : 5
</code></pre>
| <swift><logical-operators> | 2019-04-27 23:50:35 | LQ_CLOSE |
55,886,676 | how to pass suspend function as parameter to another function? Kotlin Coroutines | <p>I want to send suspending function as a parameter, but it shows " Modifier 'suspend' is not applicable to 'value parameter" . how to do it?</p>
<pre><code>fun MyModel.onBG(suspend bar: () -> Unit) {
launch {
withContext(Dispatchers.IO) {
bar()
}
}
}
</code></pre>
| <kotlin-coroutines> | 2019-04-28 03:06:07 | HQ |
55,886,709 | Where did i go wrong in my code for word count C++ | Hey guys I'm having trouble my code wont count characters if I go to a new line, and for some reason will pick up chars in addition to spaces, where did I go wrong?? (I cant use strings only char and arrays)
void wordCount(ifstream& in_stream, ofstream& out_stream)
{
int counter = 0,i;
char next,last[5];
in_stream.get(next);
while (!in_stream.eof())
{
if (next == ' ')
(next >> last[5]);
for(i = 0; last[i] != '\0'; ++i)
{
if (last[i] == ' ')
counter++;
}
in_stream.get(next);
}
| <c++> | 2019-04-28 03:12:53 | LQ_EDIT |
55,887,962 | how to get sum of same value and different value in same row | **table 1** <br>
invno  percentage   cost <br>
1     18%    18.00 <br>
1     18%    18.00 <br>
2     18%    18.00 <br>
2     28%    28.00 <br>
<br>
**table 2**<br>
id  percentage<br>
1    18%<br>
2    28%
table 2 percentage is title of output . invno 1 have 2 entry but same percentage sum showing under 18% , but invno 2 have 2 entry different percentage so output sum showing different
<br>
**output**<br>
invno   percentage 18%   percentage 28% <br>
1        36.00        0.00<br>
2       18.00        28.00
<br>
please give me mysql query for this output | <php><mysql><dynamic><pivot> | 2019-04-28 07:19:27 | LQ_EDIT |
55,888,138 | Don't Match Numerical value starting with 4 up-to 5 digit | <i>I want to match all Numeric value except digit starting with 4 up-to 5 digit's
i wrote a regex which match Numeric starting with 4 up-to 5 digit but i want to invert this match.</i>
c = '475555'
e = (re.search(r'(\A4[0-9]{5})',c).group(0)) | <python><regex> | 2019-04-28 07:47:45 | LQ_EDIT |
55,889,740 | How to do a tekken/street fighter like slider/bar Unity3D | Hi I am trying to create a health bar which transition from healthValueX to healthValueY over time. Curently I am decreasing the value like this:
void Update ()
{
myVar-= 100 * Time.deltaTime;
slider.value = myVar;
}
and there is 2 methods which I call on press to manage the slider in addition.
void addHealth()
{
myVar+=250; //Harcoded for the short question
}
void forceRemoveHealth()
{
myVar-=250; //Harcoded for the short question
}
I like the transition in the `Update` it looks good. But when I mage a huge change for example in `addHealth()` or `forceRemoveHealth()` I would to color the gap and then to transition instead of go from 300 health directly to 50 for example.
The tricky part is that I do both - decrease every frame and want to support a bigger decrease based on input. What's the best way to achive this. | <c#><unity3d> | 2019-04-28 11:21:55 | LQ_EDIT |
55,890,062 | what is wrong is here? | File "/Users/user/Desktop/Dp1/simplesocial/groups/views.py", line 24
messages.warning(self.request=,('Warning already a member!'))
SyntaxError: invalid syntax
from django.shortcuts import render
from django.contrib.auth.mixins import (LoginRequiredMixin,PermissionRequiredMixin)
from django.urls import reverse
from django.views import generic
from groups.models import Group,GroupMember
from django.shortcuts import get_object_or_404
from django.contrib import messages
# Create your views here.
class CreateGroup(LoginRequiredMixin,generic.CreateView):
fields = ('name','description')
model = Group
class SingleGroup(generic.DetailView):
model = Group
class ListGroups(generic.ListView):
model = Group
class JoinGroup(LoginRequiredMixin,generic.RedirectView):
def get_redirect_url(self,*args,**kwargs):
return reverse('groups:single',kwargs={'slug':self.kwargs.get('slug')})
def get(self,request,*args,**kwargs):
group = get_object_or_404(Group,slug=self.kwargs.get('slug'))
try:
GroupMember.objects.create(user=self.request.user,group=group)
except IntegrityError:
messages.warning(self.request=,('Warning already a member!'))
else:
messages.success(self.request,'You are now a member!')
return super().get(request,*args,**kwargs)
class LeaveGroup(LoginRequiredMixin,generic.RedirectView):
def get_redirect_url(self,*args,**kwargs):
return reverse('groups:single',kwargs={'slug':self.kwargs.get('slug')})
def get(self,request,*args,**kwargs):
try:
membership = models.GroupMember.objects.filter(user=self.request.user,group__slug=self.kwargs.get('slug')).get()
except models.GroupMember.DoesNotExist:
messages.warning(self.request,'Sorry you are not in this group!')
else:
membership.delete()
messages.success(self.request,'You have left the group!')
return super().get(request,*args,**kwargs) | <django><python-3.x> | 2019-04-28 12:03:14 | LQ_EDIT |
55,890,151 | Error in C program, using VS2017 for the first time | <p>I getting code 0 error while compiling very simple code. How do I solve it?
I using VS 2017 for the first time. </p>
<pre><code>#include <stdio.h>
void main()
{
printf("My name is Haim");
}
</code></pre>
<p><img src="https://i.ibb.co/wKsfMhp/haim.jpg" alt="a busy cat"></p>
<p>The two rows in the middle are not supposed to be there!</p>
<p>Haim</p>
| <c><visual-studio-2017> | 2019-04-28 12:17:14 | LQ_CLOSE |
55,890,490 | C# How to get last 5 variables from an Array? | <p>I'm creating mobile game in unity, all i need to know is how to get last 5 variables of an Array using <code>for</code> or <code>foreach</code>?</p>
| <c#> | 2019-04-28 12:57:50 | LQ_CLOSE |
55,891,054 | C4996 'scanf': This function or variable may be unsafe. Consider using scanf_s instead. To disable deprecation, use _CRT_SECURE_NO_WARNINGS | <p>I want to solve this problem without "#pragma warning (disable:4996)" please help me.
I tried many things.
I think it may have problem with visual studio.</p>
| <c><pragma> | 2019-04-28 14:06:15 | LQ_CLOSE |
55,891,135 | preg_match_all Why don't I get something out? | preg_match_all('!<div class="Description_Productinfo" itemprop="description"><p><span style="color:#7f8c8d;"><span style="font-family:Arial,Helvetica,sans-serif;"><span style="font-size:14px;">(.*?)</span></span></span></p></div>!',$html, $matches1, PREG_SET_ORDER);foreach ($matches1 as $soge2){print_r($soge2);} | <php><html><preg-match-all> | 2019-04-28 14:15:21 | LQ_EDIT |
55,892,600 | Python "triplet" dictionary? | <p>If we have <code>(a1, b1)</code> and <code>(a2, b2)</code> it's easy to use a dictionary to store the correspondences:</p>
<pre><code>dict[a1] = b1
dict[a2] = b2
</code></pre>
<p>And we can get <code>(a1, b1)</code> and <code>(a2, b2)</code> back no problem.</p>
<p>But, if we have <code>(a1, b1, c1)</code> and <code>(a2, b2, c2)</code>, is it possible to get something like:</p>
<pre><code>dict[a1] = (b1, c1)
dict[b1] = (a1, c1)
</code></pre>
<p>Where we can use either <code>a1</code> or <code>b1</code> to get the triplet <code>(a1, b1, c2)</code> back? Does that make sense? I'm not quite sure which datatype to use for this problem. The above would work but there would be duplicate data. </p>
<p>Basically, if I have a triplet, which data type could I use such that I can use either the first or second value to get the triplet back?</p>
| <python> | 2019-04-28 16:58:42 | HQ |
55,892,673 | variable with class name | <p>Can anybody explain me this line of code?</p>
<pre><code>public class Node {
// in the below line what is next and why the class name("node") is used
//with it
public Node next;
//what is object here and what is data
public Object data;
}
</code></pre>
| <c#><linked-list><nodes> | 2019-04-28 17:08:03 | LQ_CLOSE |
55,893,569 | PHP PDO Trouble with WHERE LIKE | I'm new to PHP and was wondering how I can execute a like query.
Here is my Model
//For search
public function getSearchResults($username){
$stmt = $this->_connection->prepare("SELECT * FROM users WHERE username LIKE :username");
$stmt->execute(['username' => $username]);
$stmt->setFetchMode(PDO::FETCH_CLASS, "User");
return $stmt->fetch();
}
Then in my controller
function search($name){
//Get search results
$searchResults = $this->model('User');
$searchResults = $searchResults->getSearchResults($name);
$data = (array) $searchResults;
$this->view('User/search', $data);
}
However this isn't working, how can I use a like clause?
**Edit Fixed It with the following**
I added $stmt->execute(['username' => '%'.$username.'%']);
instead of $stmt->execute(['username' => $username]);
| <php><pdo> | 2019-04-28 18:56:05 | LQ_EDIT |
55,895,611 | How to toggle the color of the border onclick? | <p>I have a panel which is of class panel-body. It has a default color blue. I have a button as well. When I click the button, I want to change the color of the border of the panel from blue to green and back to blue again (some transition would be even better). How can I achieve that with jquery and css.</p>
| <javascript><jquery><html><css> | 2019-04-29 00:08:04 | LQ_CLOSE |
55,896,091 | determine number n , know X is n th ugly number | > "Ugly numbers are numbers whose only prime factors are 2, 3 or 5. The
> sequence 1, 2, 3, 4, 5, 6, 8, 9, 10, 12, 15, … shows the first 11 ugly
> numbers. By convention, 1 is included."
Given number X, determine the order of X in that sequence.
Example : X = 12, output : 10.
I have an algorithm O(X) but X might be 1e18, what should I do?
There might be 10^5 queries, each query gives us a number X.
Thank you. | <c++><algorithm><math><optimization><numbers> | 2019-04-29 01:50:35 | LQ_EDIT |
55,896,744 | how do i make starked barplot in r utilising three columns, i want to use the barplot() function | i want a starked barplot in R with year as my x-axis, percentage as my y-axis, and landuse as a colour fill. my data is given below
Year Percentage LandUse
1 2015 49.8 Agriculture
2 2012 51.2 Agriculture
3 2009 50.2 Agriculture
10 2015 22.5 fishing
11 2012 21.4 fishing
12 2009 21.9 fishing
19 2015 14.7 services and residential
20 2012 16.0 services and residential
21 2009 17.1 services and residential
28 2015 0.8 mining and quarrying
29 2012 0.7 mining and quarrying
30 2009 0.7 mining and quarrying
37 2015 0.4 water and waste treatment
38 2012 0.5 water and waste treatment
39 2009 0.4 water and waste treatment
46 2015 0.8 Industry and Manufacturing
47 2012 0.8 Industry and Manufacturing
48 2009 0.9 Industry and Manufacturing | <r><dataframe><multidimensional-array><bar-chart><visualization> | 2019-04-29 03:54:09 | LQ_EDIT |
55,897,160 | What is the difference between jedi and python language server in VS code IDE? | <p>I am using VS code for python development. I had to disable python language server and enable jedi to fix an excessive RAM consumption problem with python language server. Many people encountered similar problems when you search on Google.</p>
<p>What is the difference between jedi and python language server?</p>
<p>I am using Windows 10 64-bit, python 3.7.3.</p>
| <python><visual-studio-code><ide><vscode-settings> | 2019-04-29 04:55:43 | HQ |
55,897,572 | How to remove quotes from scrapy output? | I am scraping Dmoz website and I made a lot of functions but I just wanna show you the function in which I am facing problem and that is whenever I print the output I get ```quotes``` in regional_subcategories b/w different region, and I wanna remove it. I used ```strip``` in list in ```for loop``` to remove ```\r\n```. But I faced another problem of ```quotes```. How to deal with that? Here is the image: https://imgur.com/jthsRyK
def Regional_category(self, response):
items = response.meta['items']
names = {'name1':'Regional_subcategories'
# 'name2':'Related_Categories',
# 'name3':'Site title',
# 'name4':'Site Description'
}
finder = {'finder1': '.browse-node::text',
# 'finder2': '.one-browse-node::text',
# 'finder3': '.site-title::text',
# 'finder4': '.site-descr::text',
}
for name, find in zip(names.values(), finder.values()):
items[name] = list(map(str.strip,response.css(find.strip()).extract()))
yield items | <python><scrapy> | 2019-04-29 05:42:07 | LQ_EDIT |
55,898,181 | update dart sdk for flutter | <p>I would like to use dart SDK >= 2.2.0 with flutter. But my current version used BY Flutter is 2.1.2</p>
<pre><code>flutter --version
Flutter 1.2.1 • channel stable • https://github.com/flutter/flutter.git
Framework • revision 8661d8aecd (2 months ago) • 2019-02-14 19:19:53 -0800
Engine • revision 3757390fa4
Tools • Dart 2.1.2 (build 2.1.2-dev.0.0 0a7dcf17eb)
</code></pre>
<p>I tried to install the 2.2.0 version independently and I succeed :</p>
<pre><code>dart --version
Dart VM version: 2.2.0 (Tue Feb 26 15:04:32 2019 +0100) on "macos_x64"
</code></pre>
<p>However, Flutter doesn't use this version as you can see above. I tried to replace files of the <code>dart-sdk</code> used by flutter (<code>flutter/bin/cache/dart-sdk</code>) by the version that I installed independently, but when I try to run Flutter after that I have a snapshot problem so I have put back the original <code>dart-sdk</code> folder in the flutter directory.</p>
<p>Do you have any ideas how can I update it? </p>
<p>PS: I downloaded flutter very recently (10 days ago) from here: <a href="https://flutter.dev/docs/get-started/install/macos" rel="noreferrer">https://flutter.dev/docs/get-started/install/macos</a></p>
| <dart><flutter><sdk> | 2019-04-29 06:41:54 | HQ |
55,899,305 | How to Fix This Erorr ((Exception)) in C#? | ERROR:
Activated Event Time Duration Thread
Exception: Exception thrown: 'System.TypeInitializationException' in EntityFramework.dll ("The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception."). Exception thrown: 'System.TypeInitializationException' in EntityFramework.dll ("The type initializer for 'System.Data.Entity.Internal.AppConfig' threw an exception.") 0.08s [6420] <No Name>
| <c#><entity-framework> | 2019-04-29 08:11:24 | LQ_EDIT |
55,899,494 | adding 'lat' and 'lng' to existing array | I have an array for a polygon and it isn't formatted correctly for google maps API. It's a simple javascript solution i'm sure, but I'm new to JS so wondering if you can tell me what I have wrong in the code below.
I know i'm close with the code below.
```
let path = [[59.523341487842316, -9.193736158410616],
[59.535126839526605, -9.175282560388155],
[59.529311101819324, -9.147215925256319],
[59.51395167489177, -9.158202253381319],
[59.51139973569412, -9.190560422936983],
[59.521402457849575, -9.174424253503389],
[59.50946015912328, -9.207211576501436]];
path.map ( e => ({lat: e[0], lng: e[1]}) )
console.log(path);
// Construct the polygon.
var geoFences = new google.maps.Polygon({
paths: path,
strokeColor: '#FF0000',
strokeOpacity: 0.8,
strokeWeight: 2,
fillColor: '#FF0000',
fillOpacity: 0.35
});```
You can see i'm setting path variable to what I have in terms of x,y coordinates and using .map to try and add proper json and lat lng text. I need the output to look like this:
path = [
{lat: 59.523341487842316, lng: -7.193736158410616},
{lat: 59.535126839526605, lng: -7.175282560388155},
etc...
]; | <javascript><arrays><google-maps> | 2019-04-29 08:25:04 | LQ_EDIT |
55,899,523 | How to make this code work in Javascript? | **Statement**
This code worked so far but I would like to make it run without using `<form>...</form>`
What should I need to change in the javascript part? *Any method or suggestion?*
- Using elememt.onclick() instead of using element.addEventListener() ?
geoconverter.html
```
<html>
<body>
<div class="row justify-content-center">
<div class="container">
<h3>Please enter location name :</h3>
<form id="locPost"> <!--HERE-->
<div class="form-group">
<input size="50" type="text" id="getGPS" required>
</div>
<button style="font-size:18px;border:2px solid black" type="submit" name="Convert" class="btn btn-primary">Convert <i class="fas fa-location-arrow"></i></button>
<button style="font-size:18px;border:2px solid black" onclick="location.reload();" class="btn btn-success">Refresh Page <i class="fas fa-sync"></i></button>
<div class="form-group"></div>
<div class="form-group">
<label>Latitude</label>: 
<input id="latte" style="font-size:1em" type="text" maxlength="10" step="any" name="lat" readonly>
</div>
<div class="form-group">
<label>Longitude</label>:
<input id="longer" style="font-size:1em" type="text" maxlength="10" step="any" name="lng" readonly>
</div>
<div class="row justify-content-center">
<button style="font-size:18px;border:2px solid black" onclick="window.close()" class="btn btn-danger">Close Geoconverter <i class="fas fa-times"></i></button>
</div>
</form> <!--AND HERE-->
</div>
</div>
</body>
</html>
<script>
// Get location form
var locationForm = document.getElementById('locPost');
// Listen for submit
locationForm.addEventListener('submit', geocode);
function geocode(e)
{
// Prevent actual submit
e.preventDefault();
var location = document.getElementById('getGPS').value;
axios.get('https://maps.googleapis.com/maps/api/geocode/json',{
params:{
address:location,
key:'xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx' //Paste your Google API KEY HERE!
}
})
.then(function(response)
{
// Get Lat-Long
var latpos = response.data.results[0].geometry.location.lat;
var lngpos = response.data.results[0].geometry.location.lng;
document.getElementById('latte').value = latpos;
document.getElementById('longer').value = lngpos;
})
}
</script>
```
**Expectation**
It will be able to run and get the result exactly the same as before. | <javascript><html> | 2019-04-29 08:27:02 | LQ_EDIT |
55,901,741 | Google Not Showing React-Helmet Title And Description | <p>I'm using react-helmet to give each of my pages a unique title and description for my React application. The title is rendering correctly in the browser tab and the title and description are rendering correctly when I inspect the page using Dev Tools. However, Google isn't showing either the title or description in their search results. What am I doing wrong? </p>
<p>I've looked into using prerender.io but as my site doesn't have a backend (it's just a marketing site for the moment) I'm not sure it's a good solution. I've removed some elements, but this is essentially how my code looks...</p>
<pre><code>import React, {Component} from 'react';
import {Helmet} from "react-helmet";
class Home extends Component {
render() {
return (
<div>
<Helmet>
<title> My title </title>
<meta name="description" content="My description"/>
</Helmet>
</div>
)
}
}
export default Home;
</code></pre>
| <reactjs><seo><metadata><meta-tags><react-helmet> | 2019-04-29 10:44:46 | HQ |
55,902,481 | How to achieve the below css animation effect | <p>I want to achieve the effect in <a href="https://wesbos.com" rel="nofollow noreferrer">https://wesbos.com</a> site where </p>
<p>In the first line the text keeps changing as well as it expands in a cool style on hovering. I have only basic css knowledge . So any pointers or codepens to achieve the same would be helpful.</p>
| <html><css><sass> | 2019-04-29 11:33:16 | LQ_CLOSE |
55,904,064 | How To Group and Sort Array element base Specific Character | <p>i have an array Like This :</p>
<pre><code>array("10", "1001","12", "1201","1002", "1202","120101", "120201","13");
</code></pre>
<p>i need Loop in Php to sort and group with Two Character of value to output Like This :</p>
<pre>
-10
--1001
--1002
-12
--1201
--- 120101
--1202
--- 120201
-13
</pre>
<p>Thanks!</p>
| <php><arrays> | 2019-04-29 13:06:20 | LQ_CLOSE |
55,904,191 | How to efficiently calculate prefix sum of frequencies of characters in a string? | <p>Say, I have a string</p>
<pre><code>s = 'AAABBBCAB'
</code></pre>
<p>How can I efficiently calculate the prefix sum of frequencies of each character in the string, i.e.:</p>
<pre><code>psum = [{'A': 1}, {'A': 2}, {'A': 3}, {'A': 3, 'B': 1}, {'A': 3, 'B': 2}, {'A': 3, 'B': 3}, {'A': 3, 'B': 3, 'C': 1}, {'A': 4, 'B': 3, 'C': 1}, {'A': 4, 'B': 4, 'C': 1}]
</code></pre>
| <python><python-3.x><string> | 2019-04-29 13:15:12 | HQ |
55,904,342 | List-initialization of an array without temporaries - not working in GCC | <p>Consider the following contrived example</p>
<pre><code>struct A {
A(int) {}
A(const A&) = delete;
~A() {}
};
struct B {
A a[2] = {{1}, {2}};
};
int main() {
B b;
}
</code></pre>
<p>It compiles fine in <strong>clang</strong> (any version) but not in <strong>GCC</strong> (any version, any standard >= C++11)</p>
<pre><code><source>: In constructor 'constexpr B::B()':
<source>:7:8: error: use of deleted function 'A::A(const A&)'
struct B {
^
<source>:3:5: note: declared here
A(const A&) = delete;
^
<source>: In function 'int main()':
<source>:12:7: note: synthesized method 'constexpr B::B()' first required here
B b;
^
</code></pre>
<p><a href="https://gcc.godbolt.org/z/DneRbb" rel="noreferrer">LIVE DEMO</a></p>
<p>When A's destructor is commented out, it compiles fine also in GCC.</p>
<p><strong>Question is</strong> - who is right, clang or GCC, and why?</p>
<p>Initially I thought GCC is wrong, but then I saw <a href="https://timsong-cpp.github.io/cppwp/n3337/dcl.init.list#5" rel="noreferrer">[dcl.init.list]/5</a> which states that temporaries are created. Though I'm not sure if that applies here or if there's another rule that overrides this.</p>
| <c++><c++11><gcc><language-lawyer> | 2019-04-29 13:23:25 | HQ |
55,905,801 | Can TypeScript's `readonly` fully replace Immutable.js? | <p>I have worked on a couple of projects using React.js. Some of them have used Flux, some Redux and some were just plain React apps utilizing Context. </p>
<p>I really like the way how Redux is using functional patterns. However, there is a strong chance that developers unintentionally mutate the state. When searching for a solution, there is basically just one answer - Immutable.js. To be honest, I hate this library. It totally changes the way you use JavaScript. Moreover, it has to be implemented throughout the whole application, otherwise you end up having weird errors when some objects are plain JS and some are Immutable structures. Or you start using <code>.toJS()</code>, which is - again - very very bad.</p>
<p>Recently, a colleague of mine has suggested using TypeScript. Aside from the type safety, it has one interesting feature - you can define your own data structures, which have all their fields labeled as <code>readonly</code>. Such a structure would be essentially immutable. </p>
<p>I am not an expert on either Immutable.js or TypeScript. However, the promise of having immutable data structures inside Redux store and without using Immutable.js seems too good to be true. Is TypeScript's <code>readonly</code> a suitable replacement for Immutable.js? Or are there any hidden issues?</p>
| <reactjs><typescript><redux><immutable.js> | 2019-04-29 14:47:32 | HQ |
55,908,292 | What will be correct SQL query for below question | I have created two table 1st(`Receive_Amount_Details`) for crediting amount from Site(Construction Site) Owner and 2nd(`SitewiseEmployee`) for debiting amount to pay laborer.
I want SUM of all `Amount_Received` from `Receive_Amount_Details`, SUM of `Amount` from `SitewiseEmployee` and single `Date` column as output table.
Here both table have `Date` column, but i want a single column for output.
Output table contain only three column `Date`, `Total_Receive_Amount_from_siteowner` and `Total_Amount_Payed_to_Labour`.
On output table if any single day amount not received and labour payed should be on the output table and also if any single day amount received but not payed to labour also need to come on the output table.
THANKS IN ADVANCE FOR HELP :)
```
CREATE TABLE `Receive_Amount_Details` (
`Id` int(10) NOT NULL AUTO_INCREMENT,
`SiteId` int(5) NOT NULL,
`Amount_Received` int(10) NOT NULL,
`Date` date NOT NULL,
PRIMARY KEY (`Id`),
KEY `SiteId` (`SiteId`),
CONSTRAINT `Receive_Amount_Details_ibfk_1` FOREIGN KEY (`SiteId`) REFERENCES `SiteList` (`Id`)
) ENGINE=InnoDB AUTO_INCREMENT=4 DEFAULT CHARSET=latin1
```
and
```
CREATE TABLE `SitewiseEmployee` (
`Id` int(10) NOT NULL AUTO_INCREMENT,
`SiteId` int(5) NOT NULL,
`EmployeeId` int(10) NOT NULL,
`Amount` varchar(10) DEFAULT NULL,
`Date` date NOT NULL,
PRIMARY KEY (`Id`),
KEY `SiteId` (`SiteId`),
KEY `EmployeeId` (`EmployeeId`),
CONSTRAINT `SitewiseEmployee_ibfk_1` FOREIGN KEY (`SiteId`) REFERENCES `SiteList` (`Id`),
CONSTRAINT `SitewiseEmployee_ibfk_2` FOREIGN KEY (`EmployeeId`) REFERENCES `Employee` (`id`)
) ENGINE=InnoDB AUTO_INCREMENT=6 DEFAULT CHARSET=latin1
``` | <mysql><sql> | 2019-04-29 17:32:54 | LQ_EDIT |
55,909,379 | How do I publish a website made with Symfony? | <p>I have made a website with Symfony. It works fine on my local server but when I try to publish it on my hosting space (OVH), I've got an "Index of" error.</p>
<p><a href="https://i.stack.imgur.com/wy50Y.png" rel="nofollow noreferrer">Home page - error "Index of"</a></p>
<p>I know people who use Symfony the same way I did and their websites work.
So what could be the problem ?</p>
<p>Thank you.</p>
| <symfony><publish><symfony4> | 2019-04-29 19:04:52 | LQ_CLOSE |
55,909,527 | typescript type of class that has tobe initialized | let circle: Circle;
This line says that circle is an instance of Circle. There is a case when I have a list of factories, they have not been initialized(list of classes). I have to process their static properties. What type should I use for?
I receive such error:
error TS2576: Property 'version' is a static member of type 'MigrationContainerBase' | <typescript><oop> | 2019-04-29 19:16:26 | LQ_EDIT |
55,910,399 | Is there a shortcut for b && b.c && b.c.d ? b.c.d : "default"; | <p>If I want to set a constant with a value from a nested object property that can be undefined or set it to a default value, I can do this:</p>
<pre><code>const a = b && b.c && b.c.d ? b.c.d : "default value";
</code></pre>
<p>I don't like this syntax because I find it unreadable. I prefer:</p>
<pre><code>const a = b.c.d || "default value";
</code></pre>
<p>But this syntax fails if <code>b</code> or <code>c</code> is not an object (undefined). Is there a syntax for this kind of need?</p>
| <javascript><ecmascript-6> | 2019-04-29 20:27:43 | LQ_CLOSE |
55,911,435 | Django ImportError: cannot import name 'render_to_response' from 'django.shortcuts' | <p>After upgrading to Django 3.0, I get the following error:</p>
<pre><code>ImportError: cannot import name 'render_to_response' from 'django.shortcuts'
</code></pre>
<p>My view:</p>
<pre><code>from django.shortcuts import render_to_response
from django.template import RequestContext
def index(request):
context = {'foo': 'bar'}
return render_to_response('index.html', context, context_instance=RequestContext(request))
</code></pre>
<p>Here is the full traceback:</p>
<pre><code>Traceback (most recent call last):
File "./manage.py", line 21, in <module>
main()
File "./manage.py", line 17, in main
execute_from_command_line(sys.argv)
File "/Users/alasdair/.virtualenvs/django30/lib/python3.7/site-packages/django/core/management/__init__.py", line 381, in execute_from_command_line
utility.execute()
File "/Users/alasdair/.virtualenvs/django30/lib/python3.7/site-packages/django/core/management/__init__.py", line 375, in execute
self.fetch_command(subcommand).run_from_argv(self.argv)
File "/Users/alasdair/.virtualenvs/django30/lib/python3.7/site-packages/django/core/management/base.py", line 323, in run_from_argv
self.execute(*args, **cmd_options)
File "/Users/alasdair/.virtualenvs/django30/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 60, in execute
super().execute(*args, **options)
File "/Users/alasdair/.virtualenvs/django30/lib/python3.7/site-packages/django/core/management/base.py", line 364, in execute
output = self.handle(*args, **options)
File "/Users/alasdair/.virtualenvs/django30/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 95, in handle
self.run(**options)
File "/Users/alasdair/.virtualenvs/django30/lib/python3.7/site-packages/django/core/management/commands/runserver.py", line 102, in run
autoreload.run_with_reloader(self.inner_run, **options)
File "/Users/alasdair/.virtualenvs/django30/lib/python3.7/site-packages/django/utils/autoreload.py", line 580, in run_with_reloader
start_django(reloader, main_func, *args, **kwargs)
File "/Users/alasdair/.virtualenvs/django30/lib/python3.7/site-packages/django/utils/autoreload.py", line 565, in start_django
reloader.run(django_main_thread)
File "/Users/alasdair/.virtualenvs/django30/lib/python3.7/site-packages/django/utils/autoreload.py", line 272, in run
get_resolver().urlconf_module
File "/Users/alasdair/.virtualenvs/django30/lib/python3.7/site-packages/django/utils/functional.py", line 48, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "/Users/alasdair/.virtualenvs/django30/lib/python3.7/site-packages/django/urls/resolvers.py", line 572, in urlconf_module
return import_module(self.urlconf_name)
File "/Users/alasdair/.pyenv/versions/3.7.2/lib/python3.7/importlib/__init__.py", line 127, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 1006, in _gcd_import
File "<frozen importlib._bootstrap>", line 983, in _find_and_load
File "<frozen importlib._bootstrap>", line 967, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 677, in _load_unlocked
File "<frozen importlib._bootstrap_external>", line 728, in exec_module
File "<frozen importlib._bootstrap>", line 219, in _call_with_frames_removed
File "/Users/alasdair/dev/myproject/myproject/urls.py", line 19, in <module>
from myapp import views
File "/Users/alasdair/dev/myproject/myapp/views.py", line 8, in <module>
from django.shortcuts import render_to_response
ImportError: cannot import name 'render_to_response' from 'django.shortcuts' (/Users/alasdair/.virtualenvs/django30/lib/python3.7/site-packages/django/shortcuts.py)
</code></pre>
| <python><django><python-3.x><django-views><django-3.0> | 2019-04-29 22:07:38 | HQ |
55,911,767 | Avro Serialization/Deserialization to/from Kafka Topic | <p>I am trying to create a generic utility which would read avro files from Kafka topic and write avro files to the topic in Java.
I could not find much documentation on the same.
Appreciate any working code.</p>
| <java><serialization><apache-kafka><deserialization><avro> | 2019-04-29 22:51:09 | LQ_CLOSE |
55,913,355 | c# - If data from database table column has country name then display "text on datatable" | I was able to retieve data from sql database and return it in json format . Now i have this region table which has the region and country name on it .
Now wen retrieving data from this table which has country name i want to display only the let say airport on that country only one airport .
public void GetAllRooms()
{
string cs = ConfigurationManager.ConnectionStrings["MYDB"].ConnectionString;
using (SqlConnection con = new SqlConnection(cs))
{
SqlCommand cmd = new SqlCommand();
cmd.Connection = con;
cmd.CommandType = System.Data.CommandType.Text;
cmd.CommandText = "SELECT tblResortsRooms.intResortID, tblResortsRooms.strRoomType,tblResortsRooms.strDescription, tblRegions.strRegion FROM ((tblResortsRooms INNER JOIN tblResorts ON tblResorts.intResortID = tblResortsRooms.intResortID) INNER JOIN tblRegions ON tblRegions.intRegionID = tblResorts.intResortID);";
con.Open();
DataTable dt = new DataTable();
// NEED HELP IN ENTRING THAT CODE HERE
SqlDataAdapter adapter = new SqlDataAdapter(cmd);
adapter.Fill(dt);
string JSONString = string.Empty;
JSONString = JsonConvert.SerializeObject(dt);
Context.Response.Write(JSONString);
} | <c#><sql> | 2019-04-30 02:53:01 | LQ_EDIT |
55,914,826 | Is there any JS method to parse date only by providing month and year as arguments? | <p>I'm working in a JavaScript date picker. I need to parse date by providing month and year. For example, if I'm giving argument as '01/2019', the output should be <code>Tue Jan 1 2019 00:00:00 GMT 05 30</code>. I'm aware this can be achieved by using <code>.toUTCString()</code> only if the argument should be a valid date i.e., it should be in the format of <code>dd mm yyyy</code>. But in my case, the format should be <code>mm yyyy</code>. Is there any JS built-in method to achieve this?</p>
<p><strong>Additional Info</strong>: Since date(dd) is not provided, the first date of the input month(mm) can be taken.
01/2019 - Tue Jan 1 2019 00:00:00 GMT 05 30</p>
| <javascript> | 2019-04-30 06:05:21 | LQ_CLOSE |
55,915,264 | <script>document.cookie = "humans_21909=1"; document.location.reload(true)</script> | <p>web API build with wordpress is showing error of</p>
<pre><code><script>document.cookie = "humans_21909=1"; document.location.reload(true)</script>
</code></pre>
<p>it works sometime on some network and sometime not working</p>
| <wordpress><wordpress-rest-api> | 2019-04-30 06:43:10 | HQ |
55,915,418 | Start adding children from right in Row | <p>I am designing an app in Flutter. I want to add elements from Right side rather than default left. Please guide how I can do this?</p>
| <dart><flutter> | 2019-04-30 06:54:01 | LQ_CLOSE |
55,917,317 | Homebrew PHP appears not to be linked. - Valet | <p>I had a problem which appeared all of the sudden saying:
<code>Unable to determine linked PHP.</code> which I could not solve so I uninstalled valet, php and dependencies. Then I installed fresh <code>php7.1</code> but when I run <code>valet install</code> I get quiet slightly similar error: <code>Homebrew PHP appears not to be linked.</code></p>
| <php><laravel><php-7.1><laravel-valet> | 2019-04-30 08:57:03 | HQ |
55,917,975 | Javascript: await function endend before loop continue | <p>i've a similar situation</p>
<pre><code>array.forEach(item => {
function_fetch(item)
})
</code></pre>
<p>now i need that before that loop continue he await that the function end and do what have to do, then recall the function with the other item</p>
| <javascript><function><asynchronous><async-await><fetch> | 2019-04-30 09:34:49 | LQ_CLOSE |
55,918,239 | Could not find method destination() for arguments on Report xml of type org.gradle.api.plugins.quality.internal.findbugs.FindBugsXmlReportImpl | <p>After updating the android studio version to 3.4.0 I updated the Gradle version to 5.1.1 and tried rebuilding the project it is throwing an exception in quality.gradle file.</p>
<pre><code> Task failed with an exception.
-----------
* Where:
Script '/home/Desktop/workplace/testProject/quality/quality.gradle' line: 35
* What went wrong:
A problem occurred evaluating script.
> Could not find method destination() for arguments [/home/Desktop/workplace/testProject/app/build/reports/findbugs/findbugs.xml] on Report xml of type org.gradle.api.plugins.quality.internal.findbugs.FindBugsXmlReportImpl.
* Try:
Run with --stacktrace option to get the stack trace. Run with --info or --debug option to get more log output. Run with --scan to get full insights.
</code></pre>
<p><strong>Android Project Level classpath URL and Gradle distribution URL</strong></p>
<p>classpath 'com.android.tools.build:gradle:3.4.0'
distributionUrl=https://services.gradle.org/distributions/gradle-5.1.1-all.zip</p>
<p>I tried doing invalidate the cache and restart the project. it keeps failing</p>
<p><strong>Here is my quality.gradle file</strong></p>
<pre><code>apply plugin: 'kotlin-android-extensions'
apply plugin: 'kotlin-android'
apply plugin: 'checkstyle'
apply plugin: 'findbugs'
apply plugin: 'pmd'
task checkstyle(type: Checkstyle) {
configFile file("${project.rootDir}/quality/checkstyle/checkstyle.xml")
configProperties = [
'checkstyle.cache.file': rootProject.file('build/checkstyle.cache'),
'checkstyleSuppressionsPath': file("${project.rootDir}/quality/checkstyle/suppressions.xml").absolutePath
]
source 'src'
include '**/*.java'
exclude '**/gen/**'
exclude '**/commons/**' //exclude copied stuff from apache commons
classpath = files()
}
task findbugs(type: FindBugs) {
ignoreFailures = false
effort = "max"
reportLevel = "high"
excludeFilter file("${project.rootDir}/quality/findbugs/findbugs-filter.xml")
classes = fileTree('build/intermediates/classes/')
source 'src'
include '**/*.java'
exclude '**/gen/**'
reports {
xml.enabled = false
html.enabled = true
xml {
destination "$project.buildDir/reports/findbugs/findbugs.xml"
}
html {
destination "$project.buildDir/reports/findbugs/findbugs.html"
}
}
classpath = files()
}
task pmd(type: Pmd) {
ignoreFailures = false
ruleSetFiles = files("${project.rootDir}/quality/pmd/pmd-ruleset.xml")
ruleSets = []
source 'src'
include '**/*.java'
exclude '**/gen/**'
reports {
xml.enabled = false
html.enabled = true
xml {
destination "$project.buildDir/reports/pmd/pmd.xml"
}
html {
destination "$project.buildDir/reports/pmd/pmd.html"
}
}
}
check.doLast {
project.tasks.getByName("checkstyle").execute()
project.tasks.getByName("findbugs").execute()
project.tasks.getByName("pmd").execute()
project.tasks.getByName("lint").execute()
}
checkstyle {
toolVersion '6.17' // set Checkstyle version here
}
</code></pre>
<p>This is happening when I use the Gradle version 5.1.1 and Gradle classpath version 3.4.0. Earlier I was using Gradle 4.10.1 and classpath version 3.3.2.</p>
| <android><gradle><android-gradle-plugin> | 2019-04-30 09:47:33 | HQ |
55,918,914 | Its showing some error .. How to correct this query? | My problem is when I run this query , its showing some error like
Warning: mysqli::query(): (21000/1242): Subquery returns more than 1 row
Help me to correct this query. Thank You in advance
"SELECT a.sname,a.date,a.Roll_Number,b.branch,
COUNT(DISTINCT a.date) AS totaldays,
(SELECT COUNT(a.attendance_status)
FROM attendance as a , branch as b
WHERE a.attendance_status='Present' and b.id='".$_GET['id']."' and a.branch=b.branch GROUP BY a.sid )
as present_days
FROM attendance as a , branch as b
WHERE b.id='".$_GET['id']."'
and a.branch=b.branch
GROUP BY a.sname "; | <php><mysql> | 2019-04-30 10:24:08 | LQ_EDIT |
55,920,738 | I like to know how to split a string on the basis of delimeters | I have a csv file which comprises of 5 columns of which i need only two columns which are seperated by pipe(|) delimeter.Here are few of them---
SERIAL_NO|N|1385,45,871,104|1|?
CUST_ID|N|1704,211,552,71|1|?
PROD_TYPE|A|367,286,1167,74|1|?
BRANCH_CODE|N|1892,429,254,74|1|?
BRANCH_NAME|A|682,412,774,72|1|?
DATE|N|2022,581,241,82-1863,581,137,75-1697,581,153,85|1|?
I want just the 0th and 2nd index data in a list so that i can feed that data to a image on the basis of given coordinates i am going to do cropping in image and save those images with file name same as the 0th index data.
In order to make it more clear here is what i want to do i have a image whose coordinates are in csv file(like this 1385,45,871,104)and after cropping on the basis of given coordinates i want to save file with the name of 0th index data of that row which is(SERIAL_NO).i have to do that for all the rows and some rows have more than one coordinates which was divided by - symbol.
So anybody who have idea how to do this kindly help i will be thankful to you. | <python><string><crop> | 2019-04-30 12:13:03 | LQ_EDIT |
55,920,964 | SFINAE works with deduction but fails with substitution | <p>Consider the following MCVE</p>
<pre><code>struct A {};
template<class T>
void test(T, T) {
}
template<class T>
class Wrapper {
using type = typename T::type;
};
template<class T>
void test(Wrapper<T>, Wrapper<T>) {
}
int main() {
A a, b;
test(a, b); // works
test<A>(a, b); // doesn't work
return 0;
}
</code></pre>
<p>Here <code>test(a, b);</code> works and <code>test<A>(a, b);</code> fails with:</p>
<pre><code><source>:11:30: error: no type named 'type' in 'A'
using type = typename T::type;
~~~~~~~~~~~~^~~~
<source>:23:13: note: in instantiation of template class 'Wrap<A>' requested here
test<A>(a, b); // doesn't work
^
<source>:23:5: note: while substituting deduced template arguments into function template 'test' [with T = A]
test<A>(a, b); // doesn't work
</code></pre>
<p><a href="https://gcc.godbolt.org/z/XLrOSX" rel="noreferrer">LIVE DEMO</a></p>
<p><strong>Question:</strong> Why is that? Shouldn't SFINAE work during <em>substitution</em>? Yet here it seems to work during <em>deduction</em> only.</p>
| <c++><c++11><templates><language-lawyer><sfinae> | 2019-04-30 12:26:59 | HQ |
55,923,116 | How to include jquery and bootstrap after instilling them with npm | <p>I was including frameworks and libraries by CDN, but I want to be more professional so I jumped to new tools to learn. I started wih NPM and I grasped all its basis like how to install, to update ....! but I puzzled how to include them in my project and when it comes to host should I add the node_modules folder too! </p>
<p>I know that including them this way
<code><link rel="stylesheet" href="./node_modules/bootstrap/css/bootstrap.min.css" /></code><br>
aint the way unless why the hell is npm for</p>
<p>my questions are:
what is the nxt step after installing ? and how to including them in my project?
when it comes to host or save it in git should I add the folder node_modules too?
thanks all of you</p>
| <jquery><twitter-bootstrap><npm> | 2019-04-30 14:28:23 | LQ_CLOSE |
55,923,684 | Get value from service.yml | <p>I would like to create constants value for all my application.</p>
<p>In order to do that, the documentation seems to do something like that, in app/config/services.yml</p>
<pre><code>parameters:
#parameter_name: value
CODE_OK: !php/const 200
CODE_CREATED: !php/const 201
CODE_MISSING_ARG : !php/const 400
CODE_INVALID_ARG : !php/const 419
</code></pre>
<p>Now I would like to be able to use those values inside a Controller...but I can't find the good way.May be using the service.yml isn't the right way.</p>
| <php><symfony><symfony-3.4> | 2019-04-30 14:58:35 | LQ_CLOSE |
55,923,955 | Error while Installing the python package? | [Error while installing dedupe package :][1]
[1]: https://i.stack.imgur.com/QzcAv.png
Please help me to solve this error...
| <python><package><python-dedupe> | 2019-04-30 15:12:42 | LQ_EDIT |
55,925,728 | How to compare randomly generated number with user entered number at run time in C? | <p>I am making Bubble game in c where randomly some numbers are generating on the console window and user need to enter that numbers appearing on the screen or console window and I need to compare that user input and random generated number and make that number invisible from the screen.</p>
<p>I have used rand() function in c and for user input I have used getch() function and i have tried every type conversion but not getting the solution yet.</p>
<pre><code>void main() {
char temp1 = 0;
char temp = 0;
temp1 = rand()%10;
temp = getch();
if(temp == temp1)
printf("ok");
}
</code></pre>
<p>I want to compare randomly generated value and user input at run time and input given by the user by seeing on console's number is equal i want to exit.</p>
| <c> | 2019-04-30 17:06:42 | LQ_CLOSE |
55,928,676 | How to define xvalue mixed category? | <p>Are all <code>xvalues</code> <code>glvalues</code> and <code>rvalues</code> at the same time? Or a <code>xvalue</code> may be either <code>glvalue</code> or a <code>rvalue</code>?</p>
<p>If it's a <code>glvalue</code> or/xor <code>rvalue</code>, can you give a example for each case?</p>
| <c++><value-categories> | 2019-04-30 21:08:40 | LQ_CLOSE |
55,929,472 | Django TemplateSyntaxError - 'staticfiles' is not a registered tag library | <p>After upgrading to Django 3.0, I get the following <code>TemplateSyntaxError</code>:</p>
<pre><code>In template /Users/alasdair//myproject/myapp/templates/index.html, error at line 1
'staticfiles' is not a registered tag library. Must be one of: admin_list admin_modify admin_urls cache i18n l10n log static tz
</code></pre>
<p>Here is my template</p>
<pre><code>{% load staticfiles %}
<img src="{% static 'my_image.html' %}">
</code></pre>
| <python><django><django-templates><django-3.0> | 2019-04-30 22:31:46 | HQ |
55,929,495 | Flutter Text Field: How to add Icon inside the border | <p><a href="https://i.stack.imgur.com/TfQ2u.jpg" rel="noreferrer">The Search Bar to Replicate</a></p>
<p>I would like to add the icon in the search bar. Here is my code so far:</p>
<pre><code>new TextField(
decoration: new InputDecoration(
icon: new Icon(Icons.search)
labelText: "Describe Your Issue...",
enabledBorder: const OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(20.0)),
borderSide: const BorderSide(
color: Colors.grey,
),
),
focusedBorder: OutlineInputBorder(
borderRadius: BorderRadius.all(Radius.circular(10.0)),
borderSide: BorderSide(color: Colors.blue),
),
),
),
</code></pre>
<p>This is the result of the code above (this is not what i want):</p>
<p><a href="https://i.stack.imgur.com/sgY8b.jpg" rel="noreferrer">Output of my code (this is not what i want)</a></p>
| <flutter><flutter-layout> | 2019-04-30 22:35:06 | HQ |
55,930,142 | Remove all but 1 type of character from String? | <p>So I'm having some issues with removing all characters except two from a string.</p>
<p>So for instance, if I had the string "Hello World, it's pretty out", and my character was "e" and "h", I'd hope to get the result "hee".</p>
<p>Anyone have any ideas on this? Thanks!</p>
| <javascript> | 2019-05-01 00:08:54 | LQ_CLOSE |
55,930,471 | How can I cancel a trade when another is open and keep the open trade for a given duration? | <p>I have written the code below that opens a buy and sell trade (a certain number of pips above and below the ask and bid price) at a specific time.</p>
<ol>
<li><p>How can I close/cancel one immediately when the other is opened?</p></li>
<li><p>How can I close the opened trade if it's say X pips in profit or after a minute (depending on which condition is reached first)?</p></li>
</ol>
<p>I'm a not too sure I've done the right thing in the code below and would really appreciate some help.</p>
<pre><code>double spread = Ask-Bid;
extern datetime time;
extern int pipGap = 7;
extern int lotSize = 0.01;
extern int closeTimeInSeconds = 60;
int start() {
if (TimeCurrent() >= StrToTime(time)){
OrderSend(Symbol(),OP_BUYSTOP,lotSize, Ask + Point*pipGap, 0,0,0);
OrderSend(Symbol(),OP_SELLSTOP,lotSize, Bid - Point*pipGap, 0,0,0);
}
for(int pos = OrdersTotal()-1; pos >= 0 ; pos--) if (
OrderSelect(pos, SELECT_BY_POS)
){
int duration = TimeCurrent() - OrderOpenTime();
if (duration >= closeTimeInSeconds)
OrderClose( OrderTicket(), OrderLots(), OrderClosePrice(),
3*Point);
}
return(0);
}
</code></pre>
| <mql4><metatrader4> | 2019-05-01 01:01:35 | HQ |
55,931,184 | Unable to search for a string in an Array | <p>The Program is designed to read in album information from a .txt file, once the user inputs their desired track, the program checks an array to see if it contains that track. I have been successfully able to read the tracks into the array, but my program cannot identify if a string lies in this array or not.</p>
<p>The Ruby File</p>
<pre><code>require './input_functions'
module Genre
POP, CLASSIC, JAZZ, ROCK = *1..4
end
$genre_names = ['Null', 'Pop', 'Classic', 'Jazz', 'Rock']
class Album
attr_accessor :title, :artist, :genre, :tracks
def initialize (title, artist, genre)
# insert lines here
@title = title
@artist = artist
@genre = genre
end
end
class Track
attr_accessor :name, :location
def initialize (name, location)
@name = name
@location = location
end
end
def read_track(music_file)
track_name = music_file.gets
track_location = music_file.gets
track = Track.new(track_name, track_location)
end
def read_tracks(music_file)
tracks = Array.new
count = music_file.gets.to_i
index = 0
while index < count
tracks << read_track(music_file)
index += 1
end
tracks
end
def print_tracks(tracks)
index = 0
while (index < tracks.length)
puts 'Track Number ' + index.to_s + ' is:'
print_track(tracks[index])
index = index + 1
end
tracks
end
def read_album music_file
album_artist = music_file.gets
album_title = music_file.gets
album_genre = music_file.gets
album = Album.new(album_title, album_artist, album_genre)
album
end
def print_album album
puts 'Album title is ' + album.title.to_s
puts 'Album artist is ' + album.artist.to_s
puts 'Genre is ' + album.genre.to_s
puts $genre_names[album.genre.to_i]
# print out the tracks
puts 'Tracks are ' + print_tracks(album.tracks).to_s
end
def print_track track
puts('Track title is: ' + track.name.to_s)
puts('Track file location is: ' + track.location.to_s)
end
** This is where I am having my problem
# search for track by name.
# Returns the index of the track or -1 if not found
def search_for_track_name(tracks, search_string)
search_string = gets.chomp
index = 0
while (index < tracks.length)
tracks.include?(search_string)
index = index + 1
end
if tracks.include?(search_string)
return index
else
index = -1
end
return index
end
# Reads in an Album from a file and then prints all the album
# to the terminal
def main
music_file = File.new("album.txt", "r")
if music_file
album = read_album(music_file)
album.tracks = read_tracks(music_file)
music_file.close()
end
search_string = read_string("Enter the track name you wish to find: ")
index = search_for_track_name(album.tracks, search_string)
if index.to_i > -1
puts "Found " + album.tracks[index].name + " at " + index.to_s
else
puts "Entry not Found"
end
end
main
</code></pre>
<p>This is the .txt file</p>
<pre><code>Neil Diamond
Greatest Hits
1
3
Crackling Rose
sounds/01-Cracklin-rose.wav
Soolaimon
sounds/06-Soolaimon.wav
Sweet Caroline
sounds/20-Sweet_Caroline.wav
</code></pre>
<p>When the user enters "Sweet Caroline", the program should return that it has found the track, instead it does:</p>
<pre><code>Enter the track name you wish to find:
Sweet Caroline
Entry not Found
Tracks are [#<Track:0x000000000331be58 @name="Crackling Rose\n", @location="sounds/01-Cracklin-rose.wav\n">, #<Track:0x000000000331bdb8 @name="Soolaimon\n", @location="sounds/06-Soolaimon.wav\n">, #<Track:0x000000000331bd18 @name="Sweet Caroline\n", @location="sounds/20-Sweet_Caroline.wav\n">]
</code></pre>
| <ruby> | 2019-05-01 03:13:36 | LQ_CLOSE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.