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 |
|---|---|---|---|---|---|
59,587,063 | My bruteforce machine (built with java using selenium and web-driver) is way too fast that it does not login properly even with correct login info | <p>I am building a brute-force machine with Java using selenium and web-driver. The program basically asks the user for URL of the website login page, inspect element selector for username, password, and login button, and it would automatically input the passwords and click on the login button automatically at a very fast speed. </p>
<p>However because of its high speed, the program cannot actually go to the logged in account (when you put correct login info), because another password would be inputted into the box before the web has the chance to load the next page and show us that the password was correct. For this, even when I have correct login info, the program is not able to recognize and tell the users that one of the passwords was correct.</p>
<p>This doesn't happen when I add a give a time gap (create a lag) between each login attempts, using codes such as <code>Thread.sleep(2000)</code> but I don't really want to do this because the point of a brute force machine is to try as many login attempts, and at a high speed. </p>
<p>How can I fix this issue? Is there any inspect element "value" that would change to "true" (or something like that) if the login info is correct? Even if the web is incapable of actually logging into the page due to the high speed of login attempts, I would like my java program to tell the users what the correct password found was.</p>
| <java><selenium><webdriver><brute-force> | 2020-01-04 01:02:38 | LQ_CLOSE |
59,587,706 | C# Palindrome Test | <p>I need to create a IsPalindrome function where it will determine if a provided string is a palindrome. Alphanumeric chars will be considered when evaluating whether or not the string is a palindrome. With this said, I am having trouble trying to disreguard the spaces and the Caps. Here is what my function looks like now.
If this makes a difference: After this function is done I will then have to have parse a JSON file and have each element in the "strings" array, into the IsPalindrome function.
Any tips?</p>
<pre><code> private static bool IsPalindrome(string value)
{
var min = 0;
var max = value.Length - 1;
while (true)
{
if (min > max)
return true;
var a = value[min];
var b = value[max];
if (if (char.ToLower(a) == char.ToLower(b))
{
return true;
}
else {
return false;
}
min++;
max--;
}
</code></pre>
| <c#><function><palindrome> | 2020-01-04 03:44:08 | LQ_CLOSE |
59,588,031 | How do run a task in background and even if app terminated in xamarin forms? | <p>I need to run a task at a specified time even if my app in the background or terminated in Xamarin Forms(Android and iOS). Please suggest me the best way to do it.</p>
| <c#><xamarin><xamarin.forms><xamarin.android><xamarin.ios> | 2020-01-04 04:59:41 | LQ_CLOSE |
59,588,489 | About Initializing Pointers in C++ | <p>I've been reading C++ Primer 5th edition. It mentions that </p>
<blockquote>
<p>It is illegal to assign an int variable to a pointer, even if the variable’s value happens to be 0.</p>
</blockquote>
<p>I give it a try, and find the following result:</p>
<pre><code>int *u = 0; // success
int *w = 123; // fail
/* compile error:
ptr_test.cc:9:12: error: invalid conversion from 'int' to 'int*' [-fpermissive]
int *w = 123;
*/
int zero = 0;
int *v = zero; // fail
/* compile error
ptr_test.cc:9:12: error: invalid conversion from 'int' to 'int*' [-fpermissive]
int *w = zero;
*/
</code></pre>
<p>Can someone help me explain the exact rule of pointer initialization?
Why assigning to a int pointer to 0 is fine, but 123 is not ok, though they are both integer? Why does 123 result in a to "*int" cast, while 0 does not?</p>
<p>BTW, I'm using g++ (Ubuntu 7.4.0-1ubuntu1~18.04.1) 7.4.0.</p>
| <c++><pointers> | 2020-01-04 06:31:22 | HQ |
59,589,685 | Swift - search strings in TextView and make them bold | <p>I have an <code>UITextField</code> with long text inside, I need to find all the occurrences of a string inside the text and make them bold.
I know I should use <code>NSMutableAttributedString</code> for making the text bold, but how can I search specific substring inside the text?</p>
| <ios><swift><uitextfield><nsmutableattributedstring> | 2020-01-04 10:02:40 | LQ_CLOSE |
59,590,110 | How to disable wifi show password in ubuntu 18.04 | <p>Is there any way to disable wifi show password in ubuntu 18.04 or is there any way stop system to store wifi passwords. </p>
| <linux><security><wifi><ubuntu-18.04><disable> | 2020-01-04 11:09:19 | LQ_CLOSE |
59,590,374 | How to turn on User Location - Blue Dot | <p>I'm playing with this example - <a href="https://www.raywenderlich.com/425-mapkit-tutorial-overlay-views" rel="nofollow noreferrer">https://www.raywenderlich.com/425-mapkit-tutorial-overlay-views</a></p>
<p>But how do I turn on User Location? (Blue dot)</p>
<p>Thanks</p>
| <ios><swift><iphone><xcode> | 2020-01-04 11:50:29 | LQ_CLOSE |
59,590,998 | How to create numpy array with every alternative number starting from 5 to 55 | <p><strong>please help</strong>
*I've just started python and I'm lost here *
*kindly just tell me the way I'll do it *</p>
| <python><numpy> | 2020-01-04 13:11:15 | LQ_CLOSE |
59,591,166 | How can I make Angular HTTP Post wait for node js response | <p>i am new to Angular/Node JS, and I am doing a project for university where I am trying to implement authorization/authentication in my frontend and backend.</p>
<p>So I made the method Login in the Node JS and testing with postman the response is what I want. But when I send call the method login in the Angular it doesnt return anything.</p>
<p>Using debug I could observe that the angular doesnt await for the response of Node JS, how can I make it only continue when the response arrives?</p>
<p>Node JS Method</p>
<pre><code>exports.cliente_login = function (req, res){
let cliente = transform.ToLogin(req);
service.ClienteLogin(cliente, function (cliente, erro) {
if (cliente) {
res.json(cliente);
} else {
return res.send(erro);
}
})
</code></pre>
<p>Angular Service Method </p>
<pre><code>loginCliente(cliente): Observable<Cliente> {
return this.http.post<Cliente>(this.myAppUrl + this.myApiUrl + 'login', JSON.stringify(cliente), this.httpOptions)
.pipe(
retry(1),
catchError(this.errorHandler)
);
}
</code></pre>
<p>Angular Auth Method</p>
<pre><code>login(email: string, password: string) {
let user: any;
let userLogin = new UserToLogin();
userLogin.email = email;
userLogin.password = password;
user = this.clienteService.loginCliente(userLogin);
if (user && user.token) {
// store user details and jwt token in local storage to keep user logged in between page refreshes
localStorage.setItem('currentUser', JSON.stringify(user));
this.currentUserSubject.next(user);
}
return user;
}
</code></pre>
<p>Thank you for your help !</p>
| <node.js><angular><authentication><authorization> | 2020-01-04 13:32:24 | LQ_CLOSE |
59,591,360 | Regex remove all text to the left of certain last character | Im trying to remove all the text which falls before the last character in a regex pattern.
Example:
```
rom.com/run/login.php
```
Becomes:
```
login.php
```
How would I go about doing this in javascript? I'm new to regular expressions. | <javascript><node.js><regex><npm><substring> | 2020-01-04 13:57:55 | LQ_EDIT |
59,591,724 | Sort a vector by specific member C++ | <p>Is it possible to sort a <code>vector</code> by a specific member of it's class? </p>
<p>I have a class called <code>Car</code>:</p>
<pre><code>class Carro {
private:
int positionX;
int place;
public:
Carro(string marca, float energiaInicial, float energiaMaxima, int velocMax, string model = "modelo base");
~Carro();
void setPosition(int posX);
void setPlace(int place);
int getPositionX() const;
int getPlace() const;};
</code></pre>
<p>And a vector of cars: <code>vector<Car*> raceTrack;</code></p>
<p>What I want to do is sort this vector according to car's position. If the car A is ahead of car B then A takes 1st place and B takes 2nd place, and so on.</p>
<p>P.S. Imagine that all the cars have already a place defined (ex: car A has 1, car B has 2, car C has 3...)</p>
| <c++><class><sorting> | 2020-01-04 14:40:28 | LQ_CLOSE |
59,591,843 | Counting the Digits in a number | <p>So, I want to find a way to make sure an int is exactly 18 digits long, in Python, and give different responses depending on whether it is or isn't. So, if, say, 336819654318227461 was entered, it would respond by saying "Yes, that's 18 digits!" or whatever else, but if, say, 15 was entered, it would say something like "No, that's not 18 digits!"</p>
<p>It's for a bot I'm making on Discord, where, if it is 18 digits, it'll try to kick a person based off their ID, but, if it isn't, it'll just say that it's not a real person.</p>
| <python><discord.py> | 2020-01-04 14:55:45 | LQ_CLOSE |
59,592,150 | Component not showing its content on lazy loading | <p>I am having trouble sharing components in modules in Angular 8. I was trying to build a stackblitz but I got stuck in some problem. I don't know if the problem is related to Angular or stackblitz itselft.
My example can be accessed here</p>
<p><a href="https://stackblitz.com/edit/angular-jdw21n" rel="nofollow noreferrer">here</a></p>
<p>When you click the link, to simulate a successful login you go to the home component. it has content but nothing appears.</p>
| <angular><stackblitz> | 2020-01-04 15:31:07 | LQ_CLOSE |
59,593,198 | Cannot read property 'previous' of undefined | <p>Functions in firebase throws me this error:</p>
<pre><code>TypeError: Cannot read property 'previous' of undefined
at exports.sendNotifications.functions.database.ref.onWrite (/srv/index.js:5:19)
at cloudFunction (/srv/node_modules/firebase-functions/lib/cloud-functions.js:131:23)
at /worker/worker.js:825:24
at <anonymous>
at process._tickDomainCallback (internal/process/next_tick.js:229:7)
</code></pre>
<p>And my code is this:</p>
<pre><code>exports.sendNotifications=functions.database.ref('/notifications/{notificationId}').onWrite((event)=>{
if(event.data.previous.val()){
return;
}
if(!event.data.exists()){
return;
}
})
</code></pre>
<p>Any idea how to fix this?</p>
| <javascript><node.js><firebase><vue.js><google-cloud-functions> | 2020-01-04 17:34:09 | LQ_CLOSE |
59,593,950 | How can send mail in java, nonlogin process | <p>I have a requirement of sending the email with the attachment of a file. I found few online java code but that is through gmail/yahoo with login credentials. But I want to send it as anonymous instead of logging in.</p>
<p>Similar to what is available in oracle plsql UTIL_SMTP</p>
<p>Any body can help here!
Thanks inadvance</p>
| <java> | 2020-01-04 19:06:53 | LQ_CLOSE |
59,594,260 | How to Fix Segmentation fault (core dumped) Error | <p>I am trying to read some values from a txt file and load it into mem, this is actually a dataset for neural network training, I am getting a segmentation fault when the following function is called, how can i fix this error, my main issue is this error does not show it is thrown, how can i find the line and resolve it.
This function takes a file pointer and allocates mem to a strcut named dataset, which consist of data_members as shown below and split into training and testing data</p>
<pre><code>typedef struct data_member {
double* inputs; /* The input data */
double* targets; /* The target outputs */
} data_member;
typedef struct dataset{
data_member* members; /* The members of the dataset */
int num_members; /* The number of members in the set */
int num_inputs; /* The number of inputs in the set */
int num_outputs; /* The number of outputs in the set */
} dataset;
</code></pre>
<p>the function</p>
<pre><code>
dataset *load_dataset(FILE *datafile, double ratio, dataset *testset)
{
dataset *trainset;
int num_inputs, num_outputs, num_members;
int i, j;
double temp=0.0;
char trainset_check = 0x00;
char testset_check = 0x00;
/* Load first line which contain settings */
fscanf(datafile, "%d, %d, %d\n", &num_members, &num_inputs, &num_outputs);
/* Set ratio of split*/
int trainset_size = (int) num_members * (1- ratio);
int testset_size = (int) num_members * (ratio);
printf("size of train:%d, test: %d\n", trainset_size, testset_size);
/* Setup the dataset */
/* Allocate memory for the trainset */
if ((trainset = (dataset *)malloc(sizeof(dataset))) == NULL)
{
perror("Couldn't allocate the trainset\n");
return (NULL);
}
/* Allocate memory for the testset */
if ((testset = (dataset *)malloc(sizeof(dataset))) == NULL)
{
perror("Couldn't allocate the testset\n");
return (NULL);
}
/* Set the variables trainset*/
trainset->num_members = trainset_size;
trainset->num_inputs = num_inputs;
trainset->num_outputs = num_outputs;
/* Set the variables testset*/
testset->num_members = testset_size;
testset->num_inputs = num_inputs;
testset->num_outputs = num_outputs;
/* Allocate memory for the arrays in the trainset */
if ((trainset->members = (data_member *)malloc(trainset_size * sizeof(data_member))) != NULL)
trainset_check |= 0x01;
/* Allocate memory for the arrays in the testset */
if ((trainset->members = (data_member *)malloc(testset_size * sizeof(data_member))) != NULL)
testset_check |= 0x01;
if (trainset_check < 1)
{
printf("1.Couldn't allocate trainset\n");
if (trainset_check & 0x01)
free(trainset->members);
free(trainset);
return (NULL);
}
if (testset_check < 1)
{
printf("1.Couldn't allocate testset\n");
if (testset_check & 0x01)
free(testset->members);
free(testset);
return (NULL);
}
/* Get the data for trainset */
/* For each Member */
for (i = 0; i < trainset_size; i++)
{
printf("itr:%d\n", i);
/* Allocate the memory for the member */
trainset_check = 0x00;
if (((trainset->members + i)->inputs = (double *)malloc(num_inputs * sizeof(double))) != NULL)
trainset_check |= 0x01;
if (((trainset->members + i)->targets = (double *)malloc(num_outputs * sizeof(double))) != NULL)
trainset_check |= 0x03;
if (trainset_check < 3)
{
printf("2.Couldn't allocate trainset\n");
/* Deallocate the previous loops */
for (j = 0; j < i; j++)
{
free((trainset->members + j)->inputs);
free((trainset->members + j)->targets);
}
if (trainset_check & 0x01)
free((trainset->members + i)->inputs);
if (trainset_check & 0x02)
free((trainset->members + i)->targets);
free(trainset->members);
free(trainset);
return (NULL);
}
/* Read the inputs */
for (j = 0; j < num_inputs; j++)
{
fscanf(datafile, "%lf, ", &temp);
printf("%lf, ", temp);
(trainset->members + i)->inputs[j] = temp;
}
/* Read the outputs */
for (j = 0; j < num_outputs - 1; j++)
{
fscanf(datafile, "%lf, ", &temp);
printf("%lf, ", temp);
(trainset->members + i)->targets[j] = temp;
}
fscanf(datafile, "%lf\n", &temp);
printf("%lf\n", temp);
printf("****************\n");
(trainset->members + i)->targets[j] = temp;
printf("########################%d\n",i);
}
printf("done loading trainset");
/* Get the data for testset */
/* For each Member */
for (i = 0; i < testset_size -1; i++)
{
/* Allocate the memory for the member */
testset_check = 0x00;
if (((testset->members + i)->inputs = (double *)malloc(num_inputs * sizeof(double))) != NULL)
testset_check |= 0x01;
if (((testset->members + i)->targets = (double *)malloc(num_outputs * sizeof(double))) != NULL)
testset_check |= 0x03;
if (testset_check < 3)
{
printf("2.Couldn't allocate testset\n");
/* Deallocate the previous loops */
for (j = 0; j < i; j++)
{
free((testset->members + j)->inputs);
free((testset->members + j)->targets);
}
if (testset_check & 0x01)
free((testset->members + i)->inputs);
if (testset_check & 0x02)
free((testset->members + i)->targets);
free(testset->members);
free(testset);
return (NULL);
}
/* Read the inputs */
for (j = 0; j < num_inputs; j++)
{
fscanf(datafile, "%lf, ", &temp);
printf("%lf, ", temp);
(testset->members + i)->inputs[j] = temp;
}
/* Read the outputs */
for (j = 0; j < num_outputs - 1; j++)
{
fscanf(datafile, "%lf, ", &temp);
printf("%lf, ", temp);
(testset->members + i)->targets[j] = temp;
}
fscanf(datafile, "%lf\n", &temp);
printf("%lf\n", temp);
(testset->members + i)->targets[j] = temp;
}
/* Make sure the file is closed */
fclose(datafile);
/* Finally, return the pointer to the dataset */
return (trainset);
}
</code></pre>
| <c> | 2020-01-04 19:50:12 | LQ_CLOSE |
59,594,943 | Capture and Store Google Places Data | I need to make a job that summarize amount of business in one specific region (district, city, province or country).
I would like to use the Google Places API, but this returns only until 60 places. In one city, for example, it can there are more que 30,000 places register in Google Maps.
I need this places for summarize per type (restaurant, coffee, hotel, school, etc...)
I also know that there is the term of use which says that no one is allowed to store any information of Google places in personal Database.
How can I start this job, a little clue where to start already help me. | <google-maps><google-maps-api-3><google-api><google-places-api> | 2020-01-04 21:18:32 | LQ_EDIT |
59,595,168 | Given a binary array return a count the number of consecutive 1's | <p>Write a function that accepts a binary array. This function should return the largest consecutive number of 1's in a row.</p>
| <javascript><arrays><count> | 2020-01-04 21:53:45 | LQ_CLOSE |
59,595,814 | how to convert this json to array. i want display data[x] for my view as table | <p>{ laporan": [ { "segmen": "pu", "judul_baris": [ { "judul": "Tanggal" }, { "judul": "Penambahan Perusahaan" }, { "judul": "Penambahan TK Baru" }, { "judul": "Penambahan TK Eksisting" }, { "judul": "Pengurangan TK" }, { "judul": "Penambahan Iuran" } ], "nilai_baris": [ { "data0": "01-01-2020", "data1": 0, "data2": 0, "data3": 0, "data4": 0, "data5": 0 }, { "data0": "02-01-2020", "data1": "48", "data2": "622", "data3": "409", "data4": "55", "data5": "8350005" }, { "data0": "03-01-2020", "data1": "0", "data2": "0", "data3": "0", "data4": "0", "data5": "0" }, { "data0": "04-01-2020", "data1": 0, "data2": 0, "data3": 0, "data4": 0, "data5": 0 }, { "data0": "Total", "data1": 48, "data2": 622, "data3": 409, "data4": 55, "data5": 8350005 } ] }, { "segmen": "bpu", "judul_baris": [ { "judul": "Tanggal" }, { "judul": "Penambahan TK" }, { "judul": "Penambahan Iuran" } ], "nilai_baris": [ { "data0": "01-01-2020", "data1": 0, "data2": 0 }, { "data0": "02-01-2020", "data1": "15", "data2": "500000" }, { "data0": "03-01-2020", "data1": "0", "data2": "0" }, { "data0": "04-01-2020", "data1": 0, "data2": 0 }, { "data0": "Total", "data1": 15, "data2": 500000 } ] }, { "segmen": "jakon", "judul_baris": [ { "judul": "Tanggal" }, { "judul": "Penambahan TK" }, { "judul": "Penambahan Iuran" } ], "nilai_baris": [ { "data0": "01-01-2020", "data1": 0, "data2": 0 }, { "data0": "02-01-2020", "data1": "60", "data2": "300000" }, { "data0": "03-01-2020", "data1": "0", "data2": "0" }, { "data0": "04-01-2020", "data1": 0, "data2": 0 }, { "data0": "Total", "data1": 60, "data2": 300000 } ] }, { "segmen": "administrasi", "judul_baris": [ { "judul": "Tanggal" }, { "judul": "Pencetakan Kartu" }, { "judul": "Pencetakan Surat" }, { "judul": "Pemadanan TK" } ], "nilai_baris": [ { "data0": "01-01-2020", "data1": 0, "data2": 0, "data3": 0 }, { "data0": "02-01-2020", "data1": "0", "data2": "0", "data3": "0" }, { "data0": "03-01-2020", "data1": "25", "data2": "10", "data3": "20" }, { "data0": "04-01-2020", "data1": 0, "data2": 0, "data3": 0 }, { "data0": "Total", "data1": 25, "data2": 10, "data3": 20</p>
<p>how to convert this json to array. i want display data[x] for my view as table</p>
| <php><json><codeigniter><multidimensional-array> | 2020-01-04 23:44:28 | LQ_CLOSE |
59,596,468 | Is it possible, in a conceptual level, to realize distribute computing in an assembly/compiled code level? | <p>The goal of this question is to ask if it is possible to have some compiled code (think in terms of an ordinary program, not necessarily written in any special way [e.g multi-threaded] or in any particular paradigm/language) being sent through the network to be somehow processed in a cpu located in another machine.</p>
<p>Ok, so this involves a lot of concepts, and i am not particularly familiar with neither distributed computing nor kernel/OS concepts, so pardon me if this question seems too broad or too unfocused; i will do my best to stay on track.</p>
<p>Let's say we have assembly code (instructions) for a function in our code. It's a simple function that takes x and outputs y by adding 1 to x. I know that at the execution level, the CPU needs to fetch the value of x, move it into a CPU register, perform the addition and then perform a RET instruction at the end.</p>
<p><strong>Would it be possible, conceptually, to pass along through the network the instructions alongside any contextual information needed for execution? If so, what would be the necessary information? The initial state of the CPU registers and instructions, or even more information?</strong></p>
<p>I guess the kernel would be deeply involved in the coordination of such process, but what i am mostly struggling to realize is what would be the minimum 'package' of information i would need to assemble into a message so a computer in the other end of the network would be able to perform the simple calculation OR if this just simply makes no sense given the restrictions of PC architectures.</p>
<p>There is a lot of information about distributed computing out there, but it mostly takes for granted that the code is designed in a specific way. I am interested in a similar solution for any already existant code.</p>
| <assembly><distributed><thread-synchronization><message-passing><compiled> | 2020-01-05 02:10:33 | LQ_CLOSE |
59,596,712 | How can I change an IBAction to mouseEntered? | <p>I want to create an IBAction when my mouse enters an NSButton. Whenever I create an IBAction from the button, it only works when I click it.</p>
<p>How can I make it so that the IBActions works when my mouse enters the button?</p>
| <swift><macos><cocoa><ibaction> | 2020-01-05 03:15:48 | LQ_CLOSE |
59,598,286 | How to use time.Parse with string Go? | <p>I have func use to get hour . </p>
<pre><code>func GetHourFromAPI(lastUpdate string) int {
t, err := time.Parse(time.RFC3339, lastUpdate)
var hourTime = t.Hour()
if err != nil {
fmt.Println(err)
}
return hourTime
}
</code></pre>
<p>lastUpdate is type string like this : "20190925141100"
I tried parse lastUpdate with type RFC3339 and get hour . But , system return t= 0001-01-01 00:00:00 +0000 . My issue at time.Parse ? what i am missing ?</p>
| <go><time> | 2020-01-05 08:48:12 | LQ_CLOSE |
59,598,361 | Angular app with firebase auth and node.js / mongodb | <p>I am just planning architecture for my web app and I just wanted to ask you, if it is good idea to use Firebase auth with Angular and mongoDB as a database. (I don't want to use Firestore realtime database)</p>
<p>Is a good idea to use queries directly from my Angular client or do I need some node.js/express backend for this? What would be the best solution?</p>
<p>Thanks for your advices.</p>
| <javascript><node.js><angular><mongodb><firebase> | 2020-01-05 09:00:05 | LQ_CLOSE |
59,598,433 | Cannot Compile Java project | <p>I'm trying to compile an old java program that I wrote on BlueJ but now trying to run it without it.
It's a simple code that uses <code>java.awt., java.io.*, and java.util.*</code> if that makes a difference.</p>
<p>I have the java JDK downloaded and all variables set. I can run a different program that I coded without an IDE (Its an entire project file with its own lib file tho if that makes a different).</p>
<p><strong>If i run it with javac filename.java i get this error:</strong> error: file not found: filename.java
Usage: javac
use --help for a list of possible options</p>
<p><strong>If i add -cp it says:</strong> error: no source files</p>
<p>and I've tried several other things that all resulted in the same or similar errors.</p>
<p>My best guess is java cant locate its lib folder but that shouldn't be a problem considering a JDK and JDR and downloaded and set</p>
| <java> | 2020-01-05 09:12:14 | LQ_CLOSE |
59,598,768 | Order by error in creat view in sql server | **CREATE VIEW tblSanPham_VIEW
AS
SELECT TenSP, MaDanhMuc, Mamau
FROM tblSanPham
ORDER BY MaSP DESC**
Msg 1033, Level 15, State 1, Procedure tblSanPham_VIEW, Line 6 [Batch Start Line 47]
The ORDER BY clause is invalid in views, inline functions, derived tables, subqueries, and common table expressions, unless TOP, OFFSET or FOR XML is also specified. | <sql><sql-server> | 2020-01-05 10:07:22 | LQ_EDIT |
59,599,940 | Parse error: syntax error, unexpected 'exit' (T_EXIT) in C:\xampp\htdocs\Chat\Chat\includes\signup.inc.php on line 12 | <p>trying to make a sign up page but when someone signs in an error comes, why? line(s): 12.</p>
<pre><code>if (empty($username) || empty($password) || empty($passwordrepeat)) {
header("Location: ../signup.php?error=emptyfeilds&".$username)
exit(); // <-- Here!
</code></pre>
| <php> | 2020-01-05 12:38:43 | LQ_CLOSE |
59,600,131 | JavaScript function does not work. Help a newbie :\ | <p>I'm working on a linear gradient generator.
I wanted to add a random gradient function, so it picks the background style and sets a gradient with two random colors. Everything worked until i added this random function. It looks like this:</p>
<pre><code>function getRandomInRange(min, max) {
return Math.floor(Math.random() * (max - min + 1)) + min;
}
function setRandomGradient() {
body.style.background = "linear-gradient(to right, rgb("
+ (getRandomInRange(1, 255)
+ " ,"
+ (getRandomInRange(1, 255)
+ " ,"
+ (getRandomInRange(1, 255)
+ "), rgb("
+ (getRandomInRange(1, 255)
+ " ,"
+ (getRandomInRange(1, 255)
+ " ,"
+ (getRandomInRange(1, 255)
+ "))";
}
</code></pre>
<p>getRandomInRange works well, but setRandomGradient isn't working and console shows me an error like:</p>
<blockquote>
<p>Uncaught SyntaxError: Unexpected token ';'</p>
</blockquote>
<p>Poitning to the last semicolon before a function brakets close. But if i remove the semicolon, the error is starting to point to something else, like closing brakets or something else</p>
| <javascript><function> | 2020-01-05 13:02:01 | LQ_CLOSE |
59,600,742 | Can someone explain this html switch code to me? | // I don't really understand the switch here, from what I know the switch function is supposed allow me to write certain cases and each case is supposed to redirect me to a function, this is an example from my college slides, are the cases numbered "1234","12345", "123" or are those the passwords the user might enter? //
function login(){
var username=document.myForm.userName.value;
var password=document.myForm.pass.value;
if ((username.length==0)||(password.length==0))
{ window.alert("Empty user name or password!");}
else {
switch(password)
{
case "12345" :
window.location="page1.html";
break;
case "1234" :
window.location="page2.html";
break;
case "123":
window.location="page3.html";
break;
default:
window.alert("Invalid Password");
document.myForm.pass.select();
}// end switch case
}
| <javascript><switch-statement> | 2020-01-05 14:15:34 | LQ_EDIT |
59,601,078 | SQL How to create where clause to filter last six periods with this format YYYYMM | I want to run a query with a criteria that sums the previous 6 periods with the following period format yyyymm
Period Usage
====== =====
201907 30
201908 40
201909 50
201910 60
201911 70
201912 60
202001 20 | <sql><sql-server> | 2020-01-05 14:54:33 | LQ_EDIT |
59,601,557 | I have no idea why this error: "missing 1 required positional argument: 'self'" | <p>This is my code:</p>
<pre><code>
from tkinter import Tk, Button
import GUI
root = Tk()
b = GUI.time
button1 = Button(
root, text="Local time", command=b.local_time # text on top of button
) # button click event handler
button1.pack()
button2 = Button(
root, text="Greenwich time", command=b.greenwich_time # text on top of button
) # button click event handler
button2.pack()
root.mainloop()
</code></pre>
<p>And gets the b.local_time and b.greenwich_time from my class time:</p>
<pre><code>from time import strftime, localtime, gmtime
class time:
def __init__(self):
self.gm_time = strftime("Day: %d %b %Y\nTime: %H:%M:%S %p\n", gmtime())
self.l_time = strftime("Day: %d %b %Y\nTime: %H:%M:%S %p\n", localtime())
def greenwich_time(self):
print("Greenwich time:\n" + self.gm_time)
def local_time(self):
print("Local time:\n" + self.l_time)
</code></pre>
<p>But, when I click in the buttons, I get the errors:</p>
<pre><code>Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\carol\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
TypeError: local_time() missing 1 required positional argument: 'self'
Exception in Tkinter callback
Traceback (most recent call last):
File "C:\Users\carol\AppData\Local\Programs\Python\Python37-32\lib\tkinter\__init__.py", line 1705, in __call__
return self.func(*args)
TypeError: greenwich_time() missing 1 required positional argument: 'self'
</code></pre>
<p>Someone could explain to me why is missing the required argument??
Thanks!!!</p>
| <python><python-3.x><oop><tkinter> | 2020-01-05 15:52:25 | LQ_CLOSE |
59,603,355 | Passing a parameter on click gives an error | <pre><code> $(".editorCancel").click({param1: kind}, closeMainMenu);
function closeMainMenu(event){
console.log(event.data.param1);
}
</code></pre>
<p>This will print the right value <code>param1</code>, <strong>but also print an error :</strong></p>
<blockquote>
<p>Cannot read property 'data' of undefined</p>
</blockquote>
<p>So if i get the right values, why is the error ?</p>
| <jquery> | 2020-01-05 19:17:56 | LQ_CLOSE |
59,604,795 | How to verify it's the same computer | <p>I was wondering if there's any Python code I can run that, assuming the Python code has not been tampered with, will return an ID specific to that computer that cannot be spoofed. My initial thought was to use MAC addresses, but I know those can be easily spoofed. How about CPU serial number? How would I go about doing that?</p>
<p>Thanks.</p>
| <python> | 2020-01-05 22:32:06 | LQ_CLOSE |
59,604,859 | Could anyone help me to install Intel package fortran in Mac OS Catalina? | <p>I have downloaded the installation file from the link below but after finishing installation I am not seeing anything to open the application.
<a href="https://software.intel.com/en-us/fortran-compilers/choose-download" rel="nofollow noreferrer">https://software.intel.com/en-us/fortran-compilers/choose-download</a></p>
| <fortran> | 2020-01-05 22:44:30 | LQ_CLOSE |
59,604,979 | How to license C++ software | <p>I would like to start selling some software I have developed in C++. The first line of protection will be the fact that C++ produces an executable. Within that, I will also apply algorithmic and manual obfuscation techniques to make it very hard to understand even once cracked.</p>
<p>With regards to licensing, my plan is to create an API you can send a request to. The data will include your license key and your device fingerprint. Upon receiving this data, the API will check for the license key in the database, and ensure the device fingerprint matches the fingerprint stored. If it does, it will reply with some sort of cryptographic response that must match a certain pattern. The client will then check if that response matches the pre-determined pattern, and if it does the software will be allowed to be used. If it does not, the user will be locked out. And this response will be empty if the API check failed, so that will also cause the user to be locked out.</p>
<p>I am aware that this is not unbreakable, but I would like to make it as difficult to break as possible without investing a ridiculous amount of time. The reason I wanted to add some cryptographic response is so the user can't just spoof the response from my server. Although I will also be using HTTPS on top of that. If this is a good idea, what sort of cryptographic check would you recommend?</p>
<p>The idea of the fingerprint is to prevent users from using the software on multiple computers at a time. I'm not quite sure what to use for this, but I was thinking of hashing a combination of the MAC address, computer name and something else. Any suggestions?</p>
<p>Is there anything else I should be doing to protect my software?</p>
<p>Thanks.</p>
| <c++><cryptography><license-key> | 2020-01-05 23:06:19 | LQ_CLOSE |
59,607,005 | RxSwift, What is the difference between Do and Map? | What is the difference between "do" operator and "map" operator?
It seems the same. I'm learning RxSwift.
Please check the marble diagram of do and map.
do
http://reactivex.io/documentation/operators/do.html
map
http://reactivex.io/documentation/operators/map.html
| <ios><swift><reactive-programming><rx-swift><reactive> | 2020-01-06 05:18:41 | LQ_EDIT |
59,609,655 | How to reduce git repository size | <p>Earlier I pushed some big files to git branch which increased the repository size. Later I removed those redundant files from that branch using,</p>
<pre class="lang-sh prettyprint-override"><code>git rm big_file
git commit -m 'rm bg file'
git push origin branch-name
</code></pre>
<p>But the file size of git repository remained unchanged. </p>
<p>Then I tried using <a href="https://stackoverflow.com/a/26000395/11652623">this</a> method to clear commit history but it didn't worked, the repo size is still the same.</p>
| <git><gitlab> | 2020-01-06 09:34:02 | LQ_CLOSE |
59,610,133 | Why Kubernetes system requirements are so high? | <p>I tried different implentations of Kubernetes and realized that master node requires approximately 2GB RAM with 2 CPU cores and worker node 700MB with 1 core. Each component of k8s seems to be not so heavy-loaded, but it still requires a lot of resources.</p>
<p>What is a bottleneck and is it configurable?</p>
| <kubernetes> | 2020-01-06 10:09:24 | LQ_CLOSE |
59,610,447 | XML Comparison which having attributes in SQL server | I'm having two XML strings in two seperate tables.
**ROOT**
**Node ID=** 1
**name** vignesh **/name**
**street** 1211 **/street**
**/Node**
**Node ID=** 2
**name** ram **/name**
**street** 333 **/street**
**/Node**
**/ROOT**
----------
**ROOT**
**Node ID=** 1
**name** newbie **/name**
**street** 121223 **/street**
**/Node**
**Node ID=** 2
**name** pro **/name**
**street** 445**/street**
**/Node**
**/ROOT**
----------
Please help me to find the comparison between these two XMLs in **SQL** Server and give result as Old value and New value for both ID1 and ID2(Node).
| <sql><sql-server><xml> | 2020-01-06 10:29:21 | LQ_EDIT |
59,610,669 | Conditional Operation on two int values stored as strings | <p>How can I implement a logic similar to the below mentioned code base ? </p>
<pre><code>string a = "1";
string b = "2";
if (a>=b)
{
Console.WriteLine("Greatest is" + a);
}
</code></pre>
<p>This is a simple dummy that I created to achieve my required implementation but I am stuck without a way to compare these two integer values which are stored as a string . As shown I have two strings which has two int values stored
I simply want to be able to check which one of the two strings is greater than the other</p>
| <c#><.net><if-statement><conditional-statements> | 2020-01-06 10:43:54 | LQ_CLOSE |
59,611,833 | how to get a actual direction like east - west in unity? | i am using google api for show a map in unity and also genrate object on map's some location from player position now i want to know actual direct it means identy direction (east-west) from google map or google api.
> i am make a some code but it is not give me actual direction.
var v = transform.forward;
v.y = 0;
v.Normalize();
if (Vector3.Angle(v, Vector3.forward) <= 45.0) {
Debug.Log("North");
}
else if (Vector3.Angle(v, Vector3.right) <= 45.0) {
Debug.Log("East");
}
else if (Vector3.Angle(v, Vector3.back) <= 45.0) {
Debug.Log("South");
}
else {
Debug.Log("West");
}
| <google-maps><unity3d><google-maps-api-3><map-directions> | 2020-01-06 12:07:20 | LQ_EDIT |
59,612,806 | Visible variables in c++ and how to make variable visible more | <p><br>I am still a beginner in c++, but I know something. I am studying the 1st term and I wanna make my own project, IMO it's the best way to learn to program. Anyway<br> I wanna load data from file to dynamic array (and I know how to do that) but I to that job be done by special function and to that array be visible for other function (alternativity global). I know that using global variables is not good idea so I am thinking if it's possible to make variable friend with NO classes (bc I didn't use and learn classes yet)<br>
Thanks in advance!</p>
| <c++><variables> | 2020-01-06 13:15:07 | LQ_CLOSE |
59,613,566 | Eliminating multiple server calls | MS SQL Server | There is a stored procedure which needs to be modified to eliminate a call to another server.
What is the easiest and feasible way to do this so that the final SP's execution time is faster and also preference to solutions which does not involve much change to the application.
Eg:``` select * from dbo.table1 a inner join server2.dbo.table2 b on a.id=b.id``` | <sql><sql-server><stored-procedures> | 2020-01-06 14:08:12 | LQ_EDIT |
59,614,618 | Unity C# | Array of ints - does not exist in the current context | I try to make an array of ints:
using System.Collections;
using System.Collections.Generic;
using UnityEngine;
public class Test : MonoBehaviour
{
int[] levelsSolvedCounter = new int[3];
levelsSolvedCounter[0] = 10;
}
But I get an error "The name 'levelsSolvedCounter' does not exist in the current context", although in online compiler (https://dotnetfiddle.net/) the code works just fine. | <c#><arrays><unity3d> | 2020-01-06 15:20:06 | LQ_EDIT |
59,616,564 | Copy first 7 keys in object into a new object | <p>As the title suggests, how do I make a new object containing the 7 first keys of another object using JS? :) This is the structure of the object I would like to copy the data from.</p>
<pre><code>{"data":[{"id":2338785,"team1":{"id":10531,"name":"Just For Fun"},"team2":{"id":10017,"name":"Rugratz"},"result":"2 - 0","event":{"name":"Mythic Cup 5","id":5148},"format":"bo3","stars":0,"date":1578279271000},....],"last_update":1578329378792}
</code></pre>
<p>Let's say there are 100 keys like this one, and I only want to copy the 7 first ones into a new object in JS.</p>
| <javascript><arrays><json><object><vue.js> | 2020-01-06 17:38:15 | LQ_CLOSE |
59,616,744 | @State variable $ sign usage | <p>Learning SwiftUI and having some difficulty in understanding @State. For example in the code below, why don't we use State variable (that is with $ sign) with if statement? Why only as Toggle argument? How do we differentiate both the states?</p>
<pre><code>import SwiftUI
struct ContentView: View {
@State private var isFrown = true
var body: some View {
VStack
{
Text ("Check toggle state")
Toggle(isOn: $isFrown) {
Text("")
.padding()
if isFrown { //why not $isFrown here
Text("🤨")
}
else {
Text("😃")
}
}
}
}
}
struct ContentView_Previews: PreviewProvider {
static var previews: some View {
ContentView()
}
}
</code></pre>
| <swift><swiftui> | 2020-01-06 17:55:07 | LQ_CLOSE |
59,618,554 | Am I able to add a member-wise initializer to a Codable-conforming object? | <p>I currently have a class that conforms to Codable and has an initializer like so</p>
<pre><code>public class A: Codable {
var aString: String?
public init(input: String?) {
self.aString = input
}
}
</code></pre>
<p>When I try to create an instance of it, I get an error</p>
<pre><code>let myA = A(input: "Goodbye world")
</code></pre>
<blockquote>
<p>Incorrect argument label in call (have 'input:', expected 'from:')</p>
</blockquote>
<p>Am I restricted to only the <code>init(from decoder: Decoder) throws</code> initializer for Codable classes?</p>
| <swift><codable> | 2020-01-06 20:29:51 | LQ_CLOSE |
59,618,768 | How do I set a background transparency I want in CSS? | <p>I try to put a photo under a block of text, but the colors of the photo are too strong and no longer understood what is written.
I tried with comand : "opacity:0.5" but it doesn't work..</p>
| <html><css><opacity><photo> | 2020-01-06 20:47:34 | LQ_CLOSE |
59,619,222 | javascript regex to match number square brackets and get the remaining string | I have a string like following
value[0]
1. I want to check if `str contains square brackets`.
2. If yes than get the number which in above case is `0`
3. Get the rest of the string without brackets and number which in above case is `value`
> var matches = this.key.match('/[([0-9]+)]/'); // 1
> if (null != matches) {
> var num = matches[1]; // 2
> }
How to get 3 point accomplished ?
| <javascript><regex> | 2020-01-06 21:29:16 | LQ_EDIT |
59,619,274 | Python function, need to make it so lists can go through the function. SEC EDGAR | '''
for url in indexurls:
row = parseFormPage(indexurls)
row
'''
indexurls is a list filled with urls
returns an error instead of going through the list.
Need help with iterations!
heres the function code
'''
def parseFormPage(indexurls):
'''
Input: URL
Output:
filer_cik:
filing_date:
report_date:
form_url
'''
# get page and create soup
res = requests.get(indexurls)
html = res.text
soup = BeautifulSoup(html, 'html.parser')
# parse filer Info on 10K page
filer_div = soup.find('div', {'id': 'filerDiv'})
filer_text = filer_div.find('span', {'class': 'companyName'}).find('a').get_text()
filer_cik = re.search(r"(\d{10})\s(\(.+\))$" ,filer_text)[1]
# parse 10K Page Meta data
form_content = soup.find('div', {'class': 'formContent'})
filing_date = form_content.find('div', text='Filing Date').findNext('div').get_text()
report_date = form_content.find('div', text='Period of Report').findNext('div').get_text()
# parse 10-K URL
table = soup.find('table', {'class': 'tableFile', 'summary': 'Document Format Files'})
href = table.find('td', text='10-K').find_parent('tr').find('a')['href']
form_url = "https://www.sec.gov" + href
return filer_cik, filing_date, report_date, form_url
'''
| <python><function><iteration> | 2020-01-06 21:33:56 | LQ_EDIT |
59,619,491 | Creating JSON array using Javascript | I have a json object which I need to remodel and create an array of the Json. The initial json looks like {"id":"[ 1, 2, 3]","priority":"High","assignto":"DanTest","comment":"This is a test"}
Expected result:
[{
id: "1"
priority: "High",
assignto: "DanTest"
comment: "This is a test"
},
{
id: "2"
priority: "High",
assignto: "DanTest"
comment: "This is a test"
},
{
id: "3"
priority: "High",
assignto: "DanTest"
comment: "This is a test"
}
]
| <javascript><json> | 2020-01-06 21:54:36 | LQ_EDIT |
59,620,716 | How do I get past IndentationError with try and except in a for loop in Python? | given_items = ["one", "two", 3, 4, "five", ["six", "seven", "eight"]]
for item in given_items:
try:
for element in item:
except TypeError:
pass
else:
print(element)
prints:
o
n
e
t
w
o (Vertically)
then line 6 (for element in item) crashes the program with a 'gives a IndentationError: expected an indented block' on reaching 3 in the list. The object of the program is catch items that cannot be iterated and print the rest. How do I get past this error? Thanks in advance.
| <python> | 2020-01-07 00:34:35 | LQ_EDIT |
59,621,185 | while loop with two specific conditions | <p>I've got a code something like:</p>
<pre><code>list1 = input()
while list1 != "y" or list1 != "n":
print()
print("INVALID INPUT")
print()
list1 = input()
</code></pre>
<p>and whenever I run it I get stuck in the loop regardless of the input.</p>
<p>I'd like the loop to end if I enter in either "y" or "n".</p>
| <python> | 2020-01-07 01:45:38 | LQ_CLOSE |
59,621,668 | Check a value is exactly 0? | <p>I want to check whether a value <code>s</code> is exactly zero,but when <code>s = False</code>, <code>s == 0</code> is also true.Thus how to address such case?<br>
Thanks in advance!</p>
| <python> | 2020-01-07 03:04:26 | LQ_CLOSE |
59,622,079 | Load route from ios native code (objective c) | I'm integrating an ios native library. The library opens a third party app, this process data and reload my app using deep, the lib catches the response. I wanna load the JS screen component from the native ios code integrated.
I tried to use the `RCTLinkingManager` but I don't know how to get the application instance and options.
```objectivec
[RCTLinkingManager application:app openURL:url options:options];
```
Any knows how to?
| <ios><objective-c> | 2020-01-07 04:13:21 | LQ_EDIT |
59,622,839 | Why is the max() function returning an item that is smaller than another one in a list? | <p>Here's the code in question:</p>
<pre><code>my_list = ['apples', 'oranges', 'cherries', 'banana']
print(max(my_list)
</code></pre>
<p>Why does it print 'oranges' instead of 'cherries'?</p>
| <python><max> | 2020-01-07 05:46:49 | LQ_CLOSE |
59,622,896 | Disable or avoid fake gps | <p>I have an Android app.</p>
<p>This program can detect fake positions.</p>
<p>But I want to avoid this problem by using Java programming.</p>
<p>Please help me.</p>
<p>Thanks</p>
| <java><android> | 2020-01-07 05:54:21 | LQ_CLOSE |
59,623,369 | React: The `style` prop expects a mapping from style properties to values, not a string | <p>I have the following HTML to render using React:</p>
<pre><code> <a
style='background-color:black;color:white;text-decoration:none;padding:4px 6px;font-family:-apple-system, BlinkMacSystemFont, "San Francisco", "Helvetica Neue", Helvetica, Ubuntu, Roboto, Noto, "Segoe UI", Arial, sans-serif;font-size:8px;font-weight:bold;line-height:1;display:inline-block;border-radius:3px'
href= //...
target='_blank'
rel='noopener noreferrer'
className='credit-box-abs'
>
<span style='display:inline-block;padding:2px 3px;font-size:11px'>
<i className='fas fa-camera-retro'></i>
</span>
<span style='display:inline-block;padding:2px 3px'>Photographer name</span>
</a>
</code></pre>
<p>When I try to compile, I get the following warnings about each <code>style</code>:</p>
<pre><code>Style prop value must be an object
</code></pre>
<p>And the error:</p>
<pre><code>The `style` prop expects a mapping from style properties to values, not a string.
</code></pre>
<p>The suggested solution from the compiler, as well as online, states:</p>
<pre><code><div style={{ styleAttribute: 'whatever', ... }}>
</code></pre>
<p>So I've tried the following:</p>
<pre><code> <a
style={{background-color:'black';color:'white';text-decoration:'none';padding:'4px 6px';font-family:'-apple-system , BlinkMacSystemFont, \"San Francisco\", \"Helvetica Neue\", Helvetica, Ubuntu, Roboto, Noto, \"Segoe UI\", Arial, sans-serif ';font-size:'8px';font-weight:'bold';line-height:'1';display:'inline-block';border-radius:'3px'}}
href= //...
target='_blank'
rel='noopener noreferrer'
className='credit-box-abs'
>
<span style='display:inline-block;padding:2px 3px;font-size:11px'>
<i className='fas fa-camera-retro'></i>
</span>
<span style='display:inline-block;padding:2px 3px'>Photographer name</span>
</a>
</code></pre>
<p>But the syntax is not correct. Am I supposed to wrap all values of each attribute in <code>''</code>? In particular, the syntax for <code>background-color: 'black'</code> is giving redlines under, as well as redline under my closing <code></a></code> tag.</p>
| <javascript><html><reactjs><syntax><react-props> | 2020-01-07 06:38:27 | LQ_CLOSE |
59,623,674 | How to use optional chaining with array in Typescript? | <p>I'm trying to use optional chaining with array instead of object but not sure how to do that:</p>
<p>Here's what I'm trying to do <code>myArray.filter(x => x.testKey === myTestKey)?[0]</code>.</p>
<p>But it's giving error like that so how to use it with array.</p>
| <javascript><arrays><typescript> | 2020-01-07 07:05:02 | HQ |
59,623,748 | background Image gone compressed when keyboard is open | I am making signup page using this image background.
[Background image][1]
[1]: https://i.stack.imgur.com/huxGd.png
It Look like:
[Signup page][2]
[2]: https://i.stack.imgur.com/XGvyJ.jpg
but when i focus edittext and keyboard is opened, background image is compressed. how can i resolve this. | <android><android-layout><android-softkeyboard> | 2020-01-07 07:11:10 | LQ_EDIT |
59,623,848 | I want to concole.log the text of the h2 tag whenever users clicks the tag and when clicks another h2 tag it should display the text of that h2 tag | <p>I want to concole.log the text of the h2 tag whenever users clicks the tag and when clicks another h2 tag it should display the text of that h2 tag the class and id of the tags are same.. </p>
| <javascript><php><html><css> | 2020-01-07 07:19:20 | LQ_CLOSE |
59,623,878 | Returning JSON object that has an element in an array | I want to bring back the error associated with the field 'firstname' but I can't figure out how to reference the correct branch of the json.
<!-- begin snippet: js hide: false console: true babel: false -->
<!-- language: lang-js -->
{
"_original":{
"firstname":"1",
"lastname":"1",
"email":"1@1.com",
"password":"1"
},
"details":[
{
"message":"\"firstname\" length must be at least 3 characters long",
"path":[
"firstname"
],
"type":"string.min",
"context":{
"limit":3,
"value":"1",
"label":"firstname",
"key":"firstname"
}
},
{
"message":"\"lastname\" length must be at least 3 characters long",
"path":[
"lastname"
],
"type":"string.min",
"context":{
"limit":3,
"value":"1",
"label":"lastname",
"key":"lastname"
}
}
]
}
<!-- end snippet -->
How do I return the indented object in the details array? I am searching on path:["firstname"]
| <javascript><reactjs> | 2020-01-07 07:22:00 | LQ_EDIT |
59,624,186 | How to eliminate character with regex? | <p>I have a text data like these event_date=2020-01-05 how to eliminate all characters except the two last digit/date with regex?</p>
| <regex><shell> | 2020-01-07 07:45:40 | LQ_CLOSE |
59,624,375 | How do c++ compilers find an extern variable? | <p>I compile this program by g++ and clang++. There has a difference:<br>
g++ prints 1, but clang++ prints 2.<br>
It seems that<br>
g++: the extern varible is defined in the shortest scope.<br>
clang++: the extern varible is defined in the shortest global scope.</p>
<p>Does C++ spec has any specification about that?</p>
<p>main.cpp</p>
<pre><code>#include <iostream>
static int i;
static int *p = &i;
int main() {
int i;
{
extern int i;
i = 1;
*p = 2;
std::cout << i << std::endl;
}
}
</code></pre>
<p>other.cpp</p>
<pre><code>int i;
</code></pre>
<p>version: g++: 7.4.0/ clang++:10.0.0<br>
compilation: $(CXX) main.cpp other.cpp -o extern.exe</p>
| <c++><language-lawyer><c++17> | 2020-01-07 08:01:16 | HQ |
59,625,170 | I want to show Native_Ads_view In XML file in android studio but it give me error? | hope you will be all fine basically my problem is that when i add native_ads_view in XML file it give me error ("Required XML_attribute "adSize" was missing").
i am stuck here i search alot but failed.I hope you guys give me better a response i am waiting for your answer.
XML FILE
```
<?xml version="1.0" encoding="utf-8"?>
<androidx.constraintlayout.widget.ConstraintLayout
xmlns:android="http://schemas.android.com/apk/res/android"
xmlns:app="http://schemas.android.com/apk/res-auto"
xmlns:tools="http://schemas.android.com/tools"
xmlns:ads="http://schemas.android.com/apk/res/android"
android:layout_width="match_parent"
android:layout_height="match_parent"
android:background="#72B2D1"
tools:context=".SplashScreen">
<com.google.android.gms.ads.AdView
android:id="@+id/adView"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_alignParentBottom="true"
android:layout_centerHorizontal="true"
android:layout_marginTop="10dp"
app:adSize="BANNER"
app:adUnitId="ca-app-pub-3940256099942544/6300978111"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toTopOf="parent">
</com.google.android.gms.ads.AdView>
<com.google.android.gms.ads.NativeExpressAdView
android:id="@+id/sndNativeAds"
ads:adUnitId="ca-app-pub-3940256099942544/2247696110"
android:layout_width="match_parent"
android:layout_height="wrap_content"
ads:adSize="300x200"
app:layout_constraintBottom_toTopOf="@+id/btn_move"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent"
app:layout_constraintTop_toBottomOf="@+id/adView">
</com.google.android.gms.ads.NativeExpressAdView>
<Button
android:id="@+id/btn_move"
android:layout_width="wrap_content"
android:layout_height="wrap_content"
android:layout_marginBottom="20dp"
android:text="Move To Next"
android:textSize="20sp"
android:background="#000000"
android:textColor="#fff"
app:layout_constraintBottom_toBottomOf="parent"
app:layout_constraintEnd_toEndOf="parent"
app:layout_constraintStart_toStartOf="parent" />
</androidx.constraintlayout.widget.ConstraintLayout>
Error
```
Required XML_attribute "adSize" was missing | <android> | 2020-01-07 09:05:50 | LQ_EDIT |
59,626,155 | Multi-Step Form when resizing on mobile devices | So, I'm trying to create a mobile responsive web app, I've already managed to fit it properly on mobile devices, but I don't want the "second form" to go above the first one, but to create a multi-step form when viewing on mobile devices.
Here's my code so far:
<div class="container">
<form action="/action_page.php">
<div class="row">
<div class="col-25">
<label for="fname">First Name</label>
</div>
<div class="col-75">
<input type="text" id="fname" name="firstname" placeholder="Your name..">
</div>
</div>
<div class="row">
<div class="col-25">
<label for="lname">Last Name</label>
</div>
<div class="col-75">
<input type="text" id="lname" name="lastname" placeholder="Your last name..">
</div>
</div>
</form>
</div>
(I have two forms like this one)
| <javascript><html><css> | 2020-01-07 10:03:14 | LQ_EDIT |
59,626,192 | How can I insert date in my SQL Server 2012? | <p>The date that is receive is in the format 'Wed Jan 01 02:00:00 IST 2020'.</p>
<p>If I use hibernate, it automatically converts this format into '2020-01-01 02:00:00' but for this case I have to use native query.</p>
<p>Is it possible in SQL SERVER 2012 to save the date 'Wed Jan 01 02:00:00 IST 2020' as the format '2020-01-01 02:00:00'?</p>
| <java><sql><hibernate><sql-server-2012> | 2020-01-07 10:05:10 | LQ_CLOSE |
59,626,251 | SQL Server Data cleaning | <p>please I want your help
I will start working on data mining project using sql server for database.
I have big database and before I start working on my project for sure I need to do data cleaning on my database, so
please I want your suggestions what I need to do, like removing duplicate, and removing spaces from some columns ? what else and what I need to do to be sure that my data are ready to start working on it with data mining process like clustering and decisions tree ...... </p>
<ul>
<li>Also please if you have any useful videos for Data mining in general using SQL Server Management studio - sql server cleaning data</li>
</ul>
<p>Thanks a lot in Advance...</p>
| <sql><sql-server><data-mining><data-cleaning> | 2020-01-07 10:08:01 | LQ_CLOSE |
59,626,898 | How Can I solve the logical error in the flowing code? | <p>No value is being printed inside if condition block.
Where is the logical error?
Thanks.</p>
<pre><code>#include<bits/stdc++.h>
using namespace std;
int fx[]= {-1,-1,-1,0,1,1,1,0};
int fy[]= {-1,0,1,1,1,0,-1,-1};
int ar[20][20];
int n;
int v1, v2;
void fun(int a, int b)
{
for(int i=0; i<8; i++)
{
v1 = a+fx[i];
v2 = b+fy[i];
//cout<<v1<<" "<<v2<<endl;
if(v1>=0 && v1<n)
{
if(v2>=0 && v2<n)
{
// Not executing
cout<<"----------"<<endl;
cout<<v1<<" "<<v2<<endl;
}
}
}
}
int main()
{
int n;
cin>> n;
for(int i=0; i<n; i++)
{
for(int j=0; j<n; j++)
cin>> ar[i][j];
}
fun(0,1);
return 0;
}
</code></pre>
<p>SAMPLE INPUT:<br>
4<br>
1 1 1 1<br>
1 1 1 1<br>
1 1 1 1<br>
1 1 1 1<br>
EXPECTED OUTPUT:<br>
<p>---------<p>
0 2<br>
1 2<br>
1 1<br>
1 0<br>
0 0<br> </p>
| <c++> | 2020-01-07 10:47:31 | LQ_CLOSE |
59,627,478 | Regular expression to remove the dot (.) from a number | <p>I want to write a regular expression in Java to remove the dot (.) from a number and all the numbers that come after it.</p>
<p>Example: 3.14</p>
<p>Need a regex to return only 3.</p>
<p>I'm trying to use this block:</p>
<pre><code>String value = "3.14";
value = value.replaceAll("[[.]]", "");
System.out.println(value);
</code></pre>
<p>Obviously, it just removes the ".". I tried other matches like [[.*$]] to remove everything until the end of the line, but it is taking me nowhere. </p>
<p>I'm using this table (<a href="http://tutorials.jenkov.com/java-regex/syntax.html" rel="nofollow noreferrer">http://tutorials.jenkov.com/java-regex/syntax.html</a>), what I'm finding pretty good actually, and test its use.</p>
| <java><regex> | 2020-01-07 11:24:38 | LQ_CLOSE |
59,627,701 | HTML/CSS | checkboxes postions in picture | I have a short question to our web developer.
How is it possible to drop a few checkboxes inside a picutre at a specific postion?!
It would be very nice if I can drop the 11 checkboxes at the led position of the palm picture ;)
[LED-Palm][1]
<div class="container">
<img alt="palm" src="palme.png" />
<input type="checkbox" class="led" id="led1" />
<input type="checkbox" class="led" id="led2" />
<input type="checkbox" class="led" id="led3" />
<input type="checkbox" class="led" id="led4" />
<input type="checkbox" class="led" id="led5" />
<input type="checkbox" class="led" id="led6" />
<input type="checkbox" class="led" id="led7" />
<input type="checkbox" class="led" id="led8" />
<input type="checkbox" class="led" id="led9" />
<input type="checkbox" class="led" id="led10" />
<input type="checkbox" class="led" id="led11" />
</div>
[The idea goes back to Christian Hascheks LED-Cactus.][2]
I´am a web newbie and it would be very great if someone can help me :)
Many thanks in advance!
[1]: https://i.stack.imgur.com/PMXEe.jpg
[2]: https://blog.haschek.at/2018/raspberry-pi-controlled-cactus.html | <html><css><user-interface><checkbox><frontend> | 2020-01-07 11:38:27 | LQ_EDIT |
59,628,119 | Pull mysql data between 2 dates | I have searched this site for what i need but i coulldnt find anything to my specific. I have a slight difficulty about pulling data between two dates from mysql. I know the system how to write the code to filter data between two dates but the issue i am having is these two dates are in different months. Let me explain further;
For example I need to pull the data between 25 January - and 24 February. So ideally i can set these dates manually but i need them to be set automatically according to the current time stamp. today is 7th January and the start date should be 25 December and end date should be 24 January and so on. So once we reach 25th Januray and date should be set to 24th of February.
Currently i have the following code and i set them manually.
<?php
$from = strtotime('25/12/2019 00:00');
$till = strtotime('24/01/2020 23:59');
$stmt = $con -> prepare("SELECT SUM(`amount`) as `total` FROM `income` WHERE user_id = ? && time >= ? && time <= ?");
$stmt -> bind_param('iii', $user_id, $from, $till);
$stmt -> execute();
$stmt -> store_result();
$stmt -> bind_result($total_income);
$stmt -> fetch();
?>
So is there any way to set these dates automatically according to the current time?
| <php><mysql><date> | 2020-01-07 12:06:16 | LQ_EDIT |
59,628,247 | One-line sytaxe to Read and return file on python using with loop | I need to read a file and return resulat: this is the syntaxe I use
return json.loads(with open(file, 'r') as f: f.read())
I know that we cannot write with open loop in one line, so I look for the correct syntax to fix that | <python><contextmanager> | 2020-01-07 12:14:41 | LQ_EDIT |
59,628,778 | Convert two array in one multidimensional | <p>I have two array : </p>
<pre><code>a = [a,b,c,d]
b = [1,2,3,4]
</code></pre>
<p>And I would like to convert in this </p>
<pre><code>c = [[a,1], [b,2],[c,3],[d,4]]
</code></pre>
<p>I tried <code>a << b</code> but this does not work, any idea how to convert this ?</p>
| <arrays><ruby-on-rails><ruby> | 2020-01-07 12:50:15 | LQ_CLOSE |
59,630,320 | Is it a best practice in Java to declare variables before give them as parameters | <p>Assuming this code :</p>
<pre><code>public static Dataset<Row> getData(SparkSession sparkSession,
StructType schema, String delimiter, String pathToData) {
final Dataset<Row> dataset = sparkSession
.read()
.option("delimiter", "\\t")
.csv(pathToData);
StructType nSchema= newSchema(schema, schema.size(), dataset.columns().length);
...
}
</code></pre>
<p>Is it a best practice to declare variables and make them final before giving them to newSchema method, like this ?</p>
<pre><code>public static Dataset<Row> getData(SparkSession sparkSession,
StructType schema, String delimiter, String pathToData) {
final Dataset<Row> dataset = sparkSession
.read()
.option("delimiter", "\\t")
.csv(pathToData);
final int dataSize = dataset.columns().length;
final int schemaSize = schema.size();
StructType nSchema = newSchema(schema, schemaSize, dataSize);
...
}
</code></pre>
<p>Thank you</p>
| <java><variables><final> | 2020-01-07 14:24:00 | LQ_CLOSE |
59,630,616 | How to get a daily mean | <p>I got the following question. Currently I am working with RStudio and i want to get a daily mean, however I just started to learn Rstudio and don't know how to continue...</p>
<p>my data set looks like this:</p>
<ol>
<li>row (day): 2019-12-01; 2019-12-01; 2019-12-02; 2019-12-02; 2019-12-02; 2019-12-03;.....</li>
<li>row (value): 1; 2; 3; 1; 3; 3; 1;...</li>
</ol>
<p>And i want my dataset to look like this:</p>
<ol>
<li>row (day): 2019-12-01; 2019-12-02; 2019-12-03;.....</li>
<li>row (average_value): 1; 2; 3;....</li>
</ol>
<p>Which Code do I need to get it like that? Can someone help me?
Thank you very much!!</p>
| <r><rstudio> | 2020-01-07 14:40:32 | LQ_CLOSE |
59,631,029 | if user input dopes not equal alphabet print error message | <p>I am in my first weeks of coding and am trying to solve an issue in my code</p>
<p>the challenge: how to inform user that his input is not in the alphabet and subsequently return him to the input line without continuing the code.</p>
<p>the code i have</p>
<pre><code>import random
import re
print(" _______\\__")
print(" (_. _ ._ _/")
print(" '-' \__. /")
print(" / /")
print(" / / .--. .--.")
print(" ( ( / '' \/ '' \ || || /\ |\ | _____ |\ /| /\ |\ |")
print(" \ \_.' \ ) ||--|| /__\ | \ | | ___ | \/ | /__\ | \ |")
print(" || _ './ || || / \ | \| |____| | | / \| \|")
print(" |\ \ ___.'\ /")
print(" '-./ .' \ |/")
print(" \| / )|\'")
print(" |/ // \\")
print(" |\ __// \\__")
print(" //\\ /__/ \__|")
print(" .--_/ \_--.")
print(" /__/ \__\'")
name_user = str(input("What is your name?:"))
print("Hello,", name_user, "lets play HangMan, try to guess the word i have challenged you with?")
word_list = ["fireboard", "identical", "chocolate", "christmas", "beautiful", "happiness", "wednesday", "challenge", "celebrate"]
random_pick = random.choice(word_list)
random_pick_a = re.sub("[a-z]","*", random_pick)
random_pick_list_a = list(random_pick_a)
print(random_pick)
count = 0
def main_function():
global count
while count <= 9:
user_input = str(input("type a letter:"))
for i, c in enumerate(random_pick):
if c == user_input.casefold():
random_pick_list_a[i] = user_input.casefold()
random_pick_list_b = ''.join(random_pick_list_a)
if random_pick_list_b == random_pick:
print("done")
exit()
else:
continue
else:
if user_input.casefold() not in random_pick:
count = count+1
print(count)
if count == 10:
print("sorry")
exit()
print(random_pick_list_b)
main_function()
</code></pre>
| <python><python-3.x> | 2020-01-07 15:06:16 | LQ_CLOSE |
59,631,237 | Swift "for" inside of ( ) what is this..? | <pre><code>func getIndex(for priority: Task.Priority) -> Int
{
prioritizedTasks.firstIndex { $0.priority == priority }!
}
</code></pre>
<p>what is "for" inside of ()? It is for loop...? what is $0 ? I tried to find them in apple document but I don't know the operator name for them...</p>
| <swift> | 2020-01-07 15:19:15 | LQ_CLOSE |
59,631,672 | How to pad all strings in a comma separated set of strings | <p>Is there a way to pad each individual string in a comma separated string in one shot?</p>
<p>I can split the comma separated string, go through each string and pad it (with 0, for 3 character) and join the array elements again but not sure if it can be done in one shot.</p>
<p>For instance, if I have:</p>
<pre><code>var someString = "01,002,7";
</code></pre>
<p>how can I end up with "001,002,007"?</p>
<p>I can do this client side (jQuery) or server side (C#)</p>
| <c#><jquery><string><split><padding> | 2020-01-07 15:48:30 | LQ_CLOSE |
59,632,231 | How to avoid adding "async" to hundreds of locations in my code when adding a simple fetch call? | <p>I'm working on a big project with complex code that is not well written, it looks like spaghetti, with a lot of imbrications, functions calling each other with a lot of stack depth.</p>
<p>Please note that as of now, <strong>the project code is 100% synchronous</strong> (no promises, no API calls, no database, no IO - it's a very complex test project that relies on hardcoded scenarios).</p>
<p><strong>The evolution I need to code:</strong></p>
<p>In a very deep sub-function, I need to do a very simple API call (using fetch) to return a simple integer value to the parent function, instead of an hardcoded value.</p>
<p><strong>The problem I get:</strong></p>
<p>Obviously, I need to change this function to async and I need to await for the result.</p>
<p>But now, in the functions calling it, I need to await for the result, which means I need to set those parent functions to async as well, but then their parents need to await and to become async... All the way to the top, which, in this project, I estimate to around 100 functions to update.</p>
<p>Is there a way to do this that wouldn't require refactoring so much occurences?</p>
| <javascript><node.js><asynchronous><async-await> | 2020-01-07 16:20:11 | LQ_CLOSE |
59,632,551 | Simple moving averages with formula | <p>I have to calculate Simple Moving Averages on some data with this formula in R:</p>
<p><a href="https://i.stack.imgur.com/dHXCT.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/dHXCT.png" alt="formula"></a></p>
<p>Does anybody know how to do that?</p>
| <r> | 2020-01-07 16:38:57 | LQ_CLOSE |
59,633,021 | Angular get holidays gapis | This is my function inside service
getHolidays() {
let api = 'https://www.googleapis.com/calendar/v3/calendars/tn%40holiday.calendar.google.com/events?key=myKey'
return this.http.get<any>(api, {
headers : new HttpHeaders().append('Content-type', 'application/json')
});
}
it works on browser but give 401 in angular
why ? | <azure><azure-web-sites><azure-web-app-service> | 2020-01-07 17:09:12 | LQ_EDIT |
59,634,016 | What's the difference in the order of applying selectors | <p>The task was to set red color to all paragraphs in the class <code>standart</code></p>
<p>I did it this way</p>
<pre><code>.standart p { color:red; }
</code></pre>
<p>but I was told it's bad solution and this is the "good one"</p>
<pre><code>p.standart { color:red; }
</code></pre>
<p>What's the difference between these two?</p>
| <html><css> | 2020-01-07 18:21:49 | LQ_CLOSE |
59,634,797 | Trying to calculate retention rate in R, how to divide one row by another with the same date and then apply same logic across entire data frame? | <p>I am attempting to calculate retention rate of an Instagram story (# of viewers on the last frame divided by # viewers on first frame) within the same date. I have this data within a data frame in R where each frame is listed as a a row and any frame with the same date makes up the entire story for that date. I am having a hard time figuring out how to obtain the index of the first and last frame within the same date and then dividing them and then applying this to the rest of the data frame? Any help would be greatly appreciated!</p>
| <r><date><row> | 2020-01-07 19:22:15 | LQ_CLOSE |
59,634,852 | python scrabble score calculation | <p><a href="https://i.stack.imgur.com/WoHAH.png" rel="nofollow noreferrer">I am a beginner to python and I'm trying to make a simple scrabble score calculation program. May I know how to get the letter score from the letterScore function and add it to the scrabbleScore function? Thanks a lot for your help! Please have a look on the screenshot for the program I have tried~</a></p>
| <python> | 2020-01-07 19:25:57 | LQ_CLOSE |
59,637,798 | I need to get json object from API, modify & post it using C# | Step 1) Calling an API with my credentials to log in.
Step 2) Once I am logged in I need to get a json object
Step 3) I need to ask user what new objects need to be added to the json object and where it is to be added.
Step 4) I need to add those objects in original json object and then upload/post it.
I have tried using Windows application and console application in Visual studio 2019 using C# and Newtonsoft json library.
So my question is there a way I can do all these steps in sequence without repeating any of the steps like after I take input from user I don't want to make a request again to login.
I had created a console application in which I am calling a method/function called setBase() from main to perform all above steps. This function has async await call to get/post data from API but I need to add readline() function in main after the call to setBase() for await async call to work. Also console app. exits before taking input from user. | <c#><.net><json><visual-studio><async-await> | 2020-01-08 00:05:56 | LQ_EDIT |
59,639,242 | Remove blank line in c++ | <p><strong>How to remover blank lines after reading a text file using c++?</strong></p>
<pre><code>while(arry[i]="/n"){
i++;
}
</code></pre>
<p>This is my code.It gives some output.But it is not a expected output.</p>
| <c++> | 2020-01-08 03:59:43 | LQ_CLOSE |
59,641,263 | How do you tell which category the property belongs to? | <pre><code>typealias Names = String
typealias Works = String
let a: Names = Names()
let b: Works = Works()
if a is Names {// a is not Works
}
</code></pre>
<p>How do I know if "a" belongs to "Names" instead of "Works"?</p>
<p>Thanks!</p>
| <swift><type-alias> | 2020-01-08 07:30:15 | LQ_CLOSE |
59,641,698 | If i click on Recyclerview then how to go for an new activity? | public void onClick(View v) {
Intent i = new Intent(context.getApplicationContext(),Watch.class);
startactivity(i);
}
}); | <android> | 2020-01-08 08:06:31 | LQ_EDIT |
59,644,426 | How to create one vertical column in between rows in Flexbox | <p><a href="https://i.stack.imgur.com/7VcfC.png" rel="nofollow noreferrer"><img src="https://i.stack.imgur.com/7VcfC.png" alt="enter image description here"></a></p>
<p>Is there is a way to create this style with Flexbox? </p>
| <css><flexbox> | 2020-01-08 11:02:57 | LQ_CLOSE |
59,644,845 | How to split a string into substrings using special keywords? | <p>I have to split a string into an array. It has to split when it finds the special substring denoted by '@ + keyword'. Example of keywords:</p>
<ul>
<li>@alpha</li>
<li>@beta</li>
<li><p>@lolli</p>
<p><strong>Input:</strong></p>
<p>'AAHSD@alphaHDHDG@alphaSGTDHDGT@betaSDGSDFHDG@alphaASFAGF@lolliSFDSFG@alphaSGHSHSF@lolliGA'</p>
<p><strong>Desired Output</strong></p>
<p>[A,A,H,S,D, @alpha, H,D,H,D,G, @alpha, S,G,T,D,H,D,G,T, @beta, S,D,G,S,D,F,H,D,G, @alpha,
A,S,F,A,G,F, @lolli, S,F,D,S,F,G, @alpha, S,G,H,S,H,S,F, @lolli, G,A]</p></li>
</ul>
| <angular><string><typescript><split><substring> | 2020-01-08 11:26:25 | LQ_CLOSE |
59,653,283 | Download And Save File From URL in Swift | <p>I'm trying to...</p>
<ul>
<li><p>download a file (an MLModel) from a server</p></li>
<li><p>save that file to the device </p></li>
<li><p>re-launch the app</p></li>
<li><p>use the URL (path) that the file was saved to, to access the downloaded file.. so I don't have to re-download it every time the app launches</p></li>
</ul>
<p>let download = URLSession.shared.downloadTask(with: url) { (urlOrNil, response, error) in</p>
<pre><code> if let error = error {
print("❌ There was an error in \(#function) \(error)")
completion(nil)
return
}
// the location the mlModel is saved at
guard let fileURL = urlOrNil else {print("🔥❇️>>>\(#file) \(#line)"); return }
do {
//compiles the model
let compiledUrl = try MLModel.compileModel(at: fileURL)
//turns the model into an MLModel
let model = try MLModel(contentsOf: compiledUrl)
print("newModel Complete 🍪")
// find the app support directory
let fileManager = FileManager.default
// Finds a place to save the MLModel
let appSupportDirectory = try! fileManager.url(for: .applicationSupportDirectory,
in: .userDomainMask, appropriateFor: compiledUrl, create: true)
// create a permanent URL in the app support directory
let permanentUrl = appSupportDirectory.appendingPathComponent(compiledUrl.lastPathComponent)
print("🎨\(permanentUrl)")
// if the file exists, replace it. Otherwise, copy the file to the destination.
if fileManager.fileExists(atPath: permanentUrl.absoluteString) {
_ = try fileManager.replaceItemAt(permanentUrl, withItemAt: compiledUrl)
} else {
try fileManager.copyItem(at: compiledUrl, to: permanentUrl)
}
let newModel = try MLModel(contentsOf: permanentUrl)
print("🎟", newModel)
completion(newModel)
}catch{
print("❌ There was an error in \(#function) \(error) : \(error.localizedDescription)")
}
}.resume()
</code></pre>
<p>From what I understand, this is saving my MLModel to the "permanentUrl". So I restart the app, I don't run downloadTask again (because the MLModel should be saved?), and I try to access the MLModel that I copied to the permanentURL with this code </p>
<pre><code>let permanentUrl = URL(string:"file:///var/mobile/Containers/Data/Application/659B2FEE-4384-4BBE-97D1-B1575BF1EB3B/Library/Application%20Support/CFNetworkDownload_v3EpLD.mlmodelc")
do {
let model = try MLModel(contentsOf: permanentUrl!)
print(model)
}catch{
print("❌ There was an error in \(#function) \(error) : \(error.localizedDescription)")
}
</code></pre>
<p>I get this Error</p>
<blockquote>
<p>file:///var/mobile/Containers/Data/Application/659B2FEE-4384-4BBE-97D1-B1575BF1EB3B/Library/Application 귑ీƢupport/CFNetworkDownload_v3EpLD.mlmodelc does not exist" UserInfo={NSLocalizedDescription=file:///var/mobile/Containers/Data/Application/659B2FEE-4384-4BBE-97D1-B1575BF1EB3B/Library/Application 귑ీƢupport/CFNetworkDownload_v3EpLD.mlmodelc does not exist} : file:///var/mobile/Containers/Data/Application/659B2FEE-4384-4BBE-97D1-B1575BF1EB3B/Library/Application 귑ీƢupport/CFNetworkDownload_v3EpLD.mlmodelc does not exist</p>
</blockquote>
<p>So I guess the MLModel wasn't saved? What am I missing here? I assume I saved the MLModel with downloadTask and I'm just not retrieving it the right way. How do I access the file that I had saved?</p>
| <swift><coreml><urlsession><mlmodel> | 2020-01-08 20:21:19 | LQ_CLOSE |
59,653,672 | is possible that : "SELECT COUNT (*) < SELECT COUNT (VALUE)?" | the result value SELECT COUNT (*) to be smaller than the value SELECT COUNT (VALUE)?
And why ?
Explain the answer please
| <mysql><sql><group-by> | 2020-01-08 20:55:23 | LQ_EDIT |
59,654,842 | Why do I have a syntax error in this random area of the code? | <pre><code>zone_map = {
'a1': {
ZONENAME = ^'Dungeon',
DESCRIPTION = 'desc'
EXAMINATION = 'exam'
SOLVED = False
UP = 'up'
DOWN = 'down'
LEFT = 'left'
RIGHT = 'right'
</code></pre>
<p>(^ is where the syntax error is) I have had this unknown syntax error for a while now and can't figure out how to solve it. I am working on a RPG and have to run my code, but this problem is in my way. Does anybody have any answers for this?</p>
| <python-3.x> | 2020-01-08 22:43:48 | LQ_CLOSE |
59,655,835 | Better to animate in code or in animation software for website? | <p>So I want to add a animated spinning globe to my 'about' section on my website. Basically, I have a vector image of a globe that I created, I want it to spin a few times, then have a pin drop on my city.
So, i'd want to add some motion graphics to show the spinning, the content on the globe would 'smear' and then the pin and whatever else. How would one implement this into a website?
Better to code the animation?
Gifs? </p>
<p>Thanks so much in advance!</p>
| <html><css><animation> | 2020-01-09 01:01:02 | LQ_CLOSE |
59,655,988 | Implementing a non-copyable C++ class | <p>In Visual Studio 2019, I am trying, without success, to implement the technique for making a class non-copyable shown for C++11, and later, at the accepted answer at <a href="https://stackoverflow.com/questions/2173746/how-do-i-make-this-c-object-non-copyable"><em>How do I make this C++ object non-copyable?</em></a>.</p>
<p>My class is,</p>
<pre><code>class Foo {
public:
Foo();
Foo(std::string name);
~Foo();
std::string m_name;
static std::int32_t s_counter;
public:
Foo(const Foo& inFoo) = delete;
Foo& operator=(const Foo& inFoo) = delete;
};
</code></pre>
<p>The definition code is,</p>
<pre><code>std::int32_t Foo::s_counter = 0;
Foo::Foo(void)
{
Foo::s_counter++;
std::cout << "Foo constructor. Count = " << Foo::s_counter << std::endl;
}
Foo::Foo(std::string name)
{
Foo::s_counter++;
m_name = name;
std::cout << "Foo " << m_name << " constructor. Count = " << Foo::s_counter << std::endl;
}
Foo::~Foo()
{
Foo::s_counter--;
std::cout << "Foo destructor. Count = " << Foo::s_counter << std::endl;
}
</code></pre>
<p>It is used in,</p>
<pre><code>int main(int argc, char** argv) {
std::vector<Foo> fooVector;
{
Foo myFoo1{ Foo() };
fooVector.push_back(std::move(myFoo1));
Foo myFoo2{ Foo("myFoo2") };
fooVector.push_back(std::move(myFoo2));
}
if (Foo::s_counter < 0) {
std::cout << "Foo object count = " << Foo::s_counter << std::endl;
}
std::cin.get();
}
</code></pre>
<p>in which I have intentionally scoped the definition of <code>myFoo1</code> and <code>myFoo2</code> so as to get object count feedback.</p>
<p>When the copy constructor and assignment constructor are made <code>public</code>, as shown, the compile error is "C2280 'Foo::Foo(const Foo &)': attempting to reference a deleted function". When they are made private, the compile error is "C2248 'Foo::Foo': cannot access private member declared in class 'Foo'".</p>
<p>I believe I am misinterpreting something in the original SO answer, but I cannot see what it is.</p>
| <c++><constructor> | 2020-01-09 01:24:00 | LQ_CLOSE |
59,656,614 | Problems pushing in javascript (Cannot read property 'push' of null) | <p>I'm new on javascript and I am having a lot of trouble finding the error to this program:</p>
<pre><code>const listaTweets = document.getElementById("lista-tweets");
//Función para agregar tweets
document.getElementById("formulario").addEventListener("submit", function(e){
e.preventDefault;
//Capturar mensaje
const tweet = document.getElementById("tweet").value;
const lista = document.createElement("li");
lista.innerText = tweet;
//Añadir botón "borrar"
const botonBorrar = document.createElement("a");
botonBorrar.innerText = "X";
botonBorrar.classList = "borrar-tweet";
//Añadir elementos al DOM
lista.appendChild(botonBorrar);
listaTweets.appendChild(lista);
//Añadir tweet a Local Storage
agregarTweetLocalStorage(tweet);
});
//Función para elimitar tweets
document.getElementById("lista-tweets").addEventListener("click", function(e){
e.preventDefault();
if(e.target.className === "borrar-tweet"){
e.target.parentElement.remove();
}
});
//Función para agregar tweets a Local Storage
function agregarTweetLocalStorage(tweet){
let tweets;
//Activar función para obtener tweets y guardar nuevos
tweets = obtenerTweetsLocalStorage()
tweets.push(tweet);
//Convertir arreglo a string para que JSON lo pueda leer
localStorage.setItem("tweets", JSON.stringify(tweets));
}
//Función para leer/obtener los tweets
function obtenerTweetsLocalStorage(){
let tweets;
if(localStorage.getItem("tweets") === "null"){
tweets = [];
}else{
//Conversión del arreglo a JSON
tweets = JSON.parse(localStorage.getItem("tweets"));
}
return tweets;
}
</code></pre>
<p>I'm trying to figure out what is exactly the problem, i know that is on the push() function but i don't really know.</p>
<p>Can you help me please?</p>
| <javascript><arrays><json><function><ecmascript-6> | 2020-01-09 02:57:12 | LQ_CLOSE |
59,657,742 | Invalid syntax in executing SQL query using python | <p>I am trying to run the below SQL query using pymysql in python</p>
<pre><code>cursor.execute(""SELECT count(1) from user_login WHERE user_id="+username + "and password="+password"")
</code></pre>
<p>Here username=abc and password=xyz are variables with values</p>
<p>I know there is a problem with quotation marks.Can someone suggest me the right way to do this?</p>
| <python><mysql><sql><mysql-python><pymysql> | 2020-01-09 05:30:04 | LQ_CLOSE |
59,658,267 | Find a comma saperated word from string in javascript | <p>I am trying to find word from a string
I have a string like</p>
<pre><code> var str="Roof Garden, Garden, Hall, Children Room, Guest Room, Roof_Garden";
</code></pre>
<p>Now i want to find "Garden" in this string
So i want to get only Garden not " Roof Garden" or Roof_Garden
Please suggest me any best way to find the exact word</p>
| <javascript><node.js><string><find> | 2020-01-09 06:22:44 | LQ_CLOSE |
59,658,531 | Difference in applying codes in elements | <p>I would like to ask what is the difference between <code>*{}</code> and <code>body,html{}</code>. It changes the view in the html and I want to have a broad knowledge about this. Thanks.</p>
| <css> | 2020-01-09 06:46:45 | LQ_CLOSE |
59,658,609 | Python 3: Theoretical question about the use of variables in functions | <p>I have a theoretical question about Python 3.0 based on the example below:</p>
<pre><code>def bookstore(book,price):
return ("book Type: "+ book.capitalize() + " costs $" + price)
book_entry=input('Enter book type: ')
price_entry=input('Enter book type price: ')
print (bookstore(book_entry,price_entry))
</code></pre>
<p>By accident I got this script working, but I don't fully understand WHY it need to be done this way.
It is about the following part: </p>
<pre><code>def bookstore(book,price): AND print (bookstore(book_entry,price_entry))
</code></pre>
<ol>
<li><p>Why should the variables [<em>book_entry & price_entry</em>] be entered in the print-funtion instead of in the definition-function [<em>book,price</em>]? </p></li>
<li><p>How is communication possible between the variables? The def function is the only connection, but the variable name are different, how can the code accept this difference without giving an error? </p></li>
</ol>
| <python><python-3.x><theory> | 2020-01-09 06:52:19 | LQ_CLOSE |
Subsets and Splits
No community queries yet
The top public SQL queries from the community will appear here once available.